Updated design changes

This commit is contained in:
Kumar 2022-05-03 15:19:29 +05:30 committed by A117870935
parent dee21a4b45
commit 2f258a0a25
9 changed files with 103 additions and 141 deletions

View file

@ -380,15 +380,4 @@ public interface AppPreferences {
void setStoragePermissionRequested(boolean value); void setStoragePermissionRequested(boolean value);
/**
* Saves the show/hide Image State
*/
void setHideImageClicked(boolean isHideImageClicked);
boolean getHideImageClicked();
/**
* Saves the show/hide Video State
*/
void setHideVideoClicked(boolean isHideVideoClicked);
boolean getHideVideoClicked();
} }

View file

@ -101,9 +101,6 @@ public final class AppPreferencesImpl implements AppPreferences {
private static final String PREF__STORAGE_PERMISSION_REQUESTED = "storage_permission_requested"; private static final String PREF__STORAGE_PERMISSION_REQUESTED = "storage_permission_requested";
private static final String PREF__IS_HIDE_IMAGE_CLICKED = "is_hideImage_clicked";
private static final String PREF__IS_HIDE_VIDEO_CLICKED = "is_hideVideo_clicked";
private final Context context; private final Context context;
private final SharedPreferences preferences; private final SharedPreferences preferences;
private final CurrentAccountProvider currentAccountProvider; private final CurrentAccountProvider currentAccountProvider;
@ -718,23 +715,4 @@ public final class AppPreferencesImpl implements AppPreferences {
return (int) Math.min(count / 3d, 10); return (int) Math.min(count / 3d, 10);
} }
@Override
public void setHideImageClicked(boolean isHideImageClicked) {
preferences.edit().putBoolean(PREF__IS_HIDE_IMAGE_CLICKED, isHideImageClicked).apply();
}
@Override
public boolean getHideImageClicked() {
return preferences.getBoolean(PREF__IS_HIDE_IMAGE_CLICKED,false);
}
@Override
public void setHideVideoClicked(boolean isHideVideoClicked) {
preferences.edit().putBoolean(PREF__IS_HIDE_VIDEO_CLICKED, isHideVideoClicked).apply();
}
@Override
public boolean getHideVideoClicked() {
return preferences.getBoolean(PREF__IS_HIDE_VIDEO_CLICKED,false);
}
} }

View file

@ -27,6 +27,7 @@ import android.annotation.SuppressLint;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
@ -49,6 +50,7 @@ import com.owncloud.android.utils.theme.ThemeLayoutUtils;
import com.owncloud.android.utils.theme.ThemeToolbarUtils; import com.owncloud.android.utils.theme.ThemeToolbarUtils;
import com.owncloud.android.utils.theme.ThemeUtils; import com.owncloud.android.utils.theme.ThemeUtils;
import androidx.annotation.NonNull;
import javax.inject.Inject; import javax.inject.Inject;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
@ -285,4 +287,13 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
public FrameLayout getPreviewImageContainer() { public FrameLayout getPreviewImageContainer() {
return mPreviewImageContainer; return mPreviewImageContainer;
} }
public void updateToolbarSubtitle(@NonNull String subtitle) {
if (TextUtils.isEmpty(subtitle)) {
return;
}
ActionBar actionBar = getSupportActionBar();
ThemeToolbarUtils.setColoredSubtitle(actionBar, subtitle, this);
}
} }

View file

@ -23,9 +23,13 @@
package com.owncloud.android.ui.fragment; package com.owncloud.android.ui.fragment;
import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -35,14 +39,21 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.activity.FolderPickerActivity;
import com.owncloud.android.ui.adapter.CommonOCFileListAdapterInterface; import com.owncloud.android.ui.adapter.CommonOCFileListAdapterInterface;
import com.owncloud.android.ui.adapter.GalleryAdapter; import com.owncloud.android.ui.adapter.GalleryAdapter;
import com.owncloud.android.ui.asynctasks.GallerySearchTask; import com.owncloud.android.ui.asynctasks.GallerySearchTask;
import com.owncloud.android.ui.events.ChangeMenuEvent; import com.owncloud.android.ui.events.ChangeMenuEvent;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeMenuUtils;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -77,8 +88,7 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
FileActivity activity = (FileActivity) getActivity(); FileActivity activity = (FileActivity) getActivity();
galleryFragmentBottomSheetDialog = new GalleryFragmentBottomSheetDialog(activity, galleryFragmentBottomSheetDialog = new GalleryFragmentBottomSheetDialog(activity,
this, this);
appPreferences);
} }
} }
@ -118,6 +128,8 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT; menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT;
requireActivity().invalidateOptionsMenu(); requireActivity().invalidateOptionsMenu();
updateSubtitle(galleryFragmentBottomSheetDialog.isHideVideos(), galleryFragmentBottomSheetDialog.isHideImages());
handleSearchEvent(); handleSearchEvent();
} }
@ -349,33 +361,20 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
} }
} }
//Actions implementation of Bottom Sheet Dialog
@Override @Override
public void hideVideos(boolean isHideVideosClicked) { public void updateMediaContent(boolean isHideVideos, boolean isHidePhotos) {
if (!mediaObject.isEmpty()) { if (!mediaObject.isEmpty()) {
mAdapter.setAdapterWithHideShowImage(mediaObject, mAdapter.setAdapterWithHideShowImage(mediaObject,
preferences.getHideVideoClicked(), isHideVideos,
preferences.getHideImageClicked(), imageList, videoList, isHidePhotos, imageList, videoList,
this); this);
} else { } else {
setEmptyListMessage(SearchType.GALLERY_SEARCH); setEmptyListMessage(SearchType.GALLERY_SEARCH);
} }
}
@Override updateSubtitle(isHideVideos, isHidePhotos);
public void hideImages(boolean isHideImagesClicked) {
if (!mediaObject.isEmpty()) {
mAdapter.setAdapterWithHideShowImage(mediaObject,
preferences.getHideVideoClicked(),
preferences.getHideImageClicked(), imageList, videoList,
this);
} else {
setEmptyListMessage(SearchType.GALLERY_SEARCH);
}
} }
@Override @Override
@ -387,7 +386,24 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
public void showAllGalleryItems() { public void showAllGalleryItems() {
mAdapter.showAllGalleryItems(mContainerActivity.getStorageManager(), remoteFilePath.getRemotePath(), mAdapter.showAllGalleryItems(mContainerActivity.getStorageManager(), remoteFilePath.getRemotePath(),
mediaObject, preferences.getHideVideoClicked(), preferences.getHideImageClicked(), mediaObject, galleryFragmentBottomSheetDialog.isHideVideos(),
galleryFragmentBottomSheetDialog.isHideImages(),
imageList, videoList, this); imageList, videoList, this);
updateSubtitle(galleryFragmentBottomSheetDialog.isHideVideos(), galleryFragmentBottomSheetDialog.isHideImages());
}
private void updateSubtitle(boolean isHideVideos, boolean isHidePhotos) {
requireActivity().runOnUiThread(() -> {
String subTitle = requireContext().getResources().getString(R.string.subtitle_photos_videos);
if (isHideVideos) {
subTitle = requireContext().getResources().getString(R.string.subtitle_photos_only);
} else if (isHidePhotos) {
subTitle = requireContext().getResources().getString(R.string.subtitle_videos_only);
}
if (requireActivity() instanceof ToolbarActivity) {
((ToolbarActivity) requireActivity()).updateToolbarSubtitle(subTitle);
}
});
} }
} }

View file

@ -24,14 +24,9 @@ package com.owncloud.android.ui.fragment;
public interface GalleryFragmentBottomSheetActions { public interface GalleryFragmentBottomSheetActions {
/** /**
* hide all the images in particular Folder. * show/hide all the images & videos in particular Folder.
*/ */
void hideImages(boolean isHideImagesClicked); void updateMediaContent(boolean isHideVideos, boolean isHidePhotos);
/**
* hide all the videos in particular folder.
*/
void hideVideos(boolean isHideVideosClicked);
/** /**
* load all media of a particular folder. * load all media of a particular folder.

View file

@ -36,19 +36,20 @@ import androidx.core.content.ContextCompat;
public class GalleryFragmentBottomSheetDialog extends BottomSheetDialog { public class GalleryFragmentBottomSheetDialog extends BottomSheetDialog {
//media view states
private static final int MEDIA_STATE_DEFAULT = 1; //when both photos and videos selected
private static final int MEDIA_STATE_PHOTOS_ONLY = 2;
private static final int MEDIA_STATE_VIDEOS_ONLY = 3;
private FragmentGalleryBottomSheetBinding binding; private FragmentGalleryBottomSheetBinding binding;
private final GalleryFragmentBottomSheetActions actions; private final GalleryFragmentBottomSheetActions actions;
private final AppPreferences preferences;
private boolean isHideImageClicked;
private boolean isHideVideoClicked;
private BottomSheetBehavior mBottomBehavior; private BottomSheetBehavior mBottomBehavior;
private int currentMediaState = MEDIA_STATE_DEFAULT;
public GalleryFragmentBottomSheetDialog(FileActivity fileActivity, public GalleryFragmentBottomSheetDialog(FileActivity fileActivity,
GalleryFragmentBottomSheetActions actions, GalleryFragmentBottomSheetActions actions) {
AppPreferences preferences) {
super(fileActivity); super(fileActivity);
this.actions = actions; this.actions = actions;
this.preferences = preferences;
} }
@ -73,24 +74,15 @@ public class GalleryFragmentBottomSheetDialog extends BottomSheetDialog {
} }
private void setupLayout() { private void setupLayout() {
if (currentMediaState == MEDIA_STATE_PHOTOS_ONLY) {
if (!preferences.getHideImageClicked()) { binding.tickMarkShowImages.setVisibility(View.VISIBLE);
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_camera)); binding.tickMarkShowVideo.setVisibility(View.GONE);
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.hide_images)); } else if (currentMediaState == MEDIA_STATE_VIDEOS_ONLY) {
binding.tickMarkHideImages.setVisibility(View.GONE); binding.tickMarkShowImages.setVisibility(View.GONE);
} else if (preferences.getHideImageClicked()) { binding.tickMarkShowVideo.setVisibility(View.VISIBLE);
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_camera)); } else {
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.show_images)); binding.tickMarkShowImages.setVisibility(View.VISIBLE);
binding.tickMarkHideImages.setVisibility(View.VISIBLE); binding.tickMarkShowVideo.setVisibility(View.VISIBLE);
}
if (!preferences.getHideVideoClicked()) {
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_video_camera));
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.hide_video));
binding.tickMarkHideVideo.setVisibility(View.GONE);
} else if (preferences.getHideVideoClicked()) {
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_video_camera));
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.show_video));
binding.tickMarkHideVideo.setVisibility(View.VISIBLE);
} }
} }
@ -98,63 +90,23 @@ public class GalleryFragmentBottomSheetDialog extends BottomSheetDialog {
binding.hideImages.setOnClickListener(v -> { binding.hideImages.setOnClickListener(v -> {
if (!preferences.getHideImageClicked() && preferences.getHideVideoClicked()) { if (currentMediaState == MEDIA_STATE_VIDEOS_ONLY) {
isHideImageClicked = true; currentMediaState = MEDIA_STATE_DEFAULT;
isHideVideoClicked = false; } else {
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_camera)); currentMediaState = MEDIA_STATE_VIDEOS_ONLY;
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.show_images));
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_video_camera));
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.hide_video));
binding.tickMarkHideImages.setVisibility(View.VISIBLE);
binding.tickMarkHideVideo.setVisibility(View.GONE);
} else if (!preferences.getHideImageClicked() && !preferences.getHideVideoClicked()) {
isHideImageClicked = true;
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_camera));
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.show_images));
binding.tickMarkHideImages.setVisibility(View.VISIBLE);
} else if (preferences.getHideImageClicked() && !preferences.getHideVideoClicked()) {
isHideImageClicked = false;
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_camera));
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.hide_images));
binding.tickMarkHideImages.setVisibility(View.GONE);
} }
notifyStateChange();
preferences.setHideImageClicked(isHideImageClicked);
preferences.setHideVideoClicked(isHideVideoClicked);
actions.hideImages(preferences.getHideImageClicked());
dismiss(); dismiss();
}); });
binding.hideVideo.setOnClickListener(v -> { binding.hideVideo.setOnClickListener(v -> {
if (!preferences.getHideVideoClicked() && !preferences.getHideImageClicked()) { if (currentMediaState == MEDIA_STATE_PHOTOS_ONLY) {
isHideVideoClicked = true; currentMediaState = MEDIA_STATE_DEFAULT;
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_video_camera)); } else {
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.show_video)); currentMediaState = MEDIA_STATE_PHOTOS_ONLY;
binding.tickMarkHideVideo.setVisibility(View.VISIBLE);
} else if (!preferences.getHideVideoClicked() && preferences.getHideImageClicked()) {
isHideVideoClicked = true;
isHideImageClicked = false;
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_video_camera));
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.show_video));
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_camera));
binding.hideImagesTextview.setText(getContext().getResources().getString(R.string.hide_images));
binding.tickMarkHideImages.setVisibility(View.GONE);
binding.tickMarkHideVideo.setVisibility(View.VISIBLE);
} else if (preferences.getHideVideoClicked() && !preferences.getHideImageClicked()) {
isHideVideoClicked = false;
binding.hideVideoImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_video_camera));
binding.hideVideoTextview.setText(getContext().getResources().getString(R.string.hide_video));
binding.tickMarkHideVideo.setVisibility(View.GONE);
} }
notifyStateChange();
preferences.setHideVideoClicked(isHideVideoClicked);
preferences.setHideImageClicked(isHideImageClicked);
actions.hideVideos(preferences.getHideVideoClicked());
dismiss(); dismiss();
}); });
@ -165,4 +117,18 @@ public class GalleryFragmentBottomSheetDialog extends BottomSheetDialog {
}); });
} }
private void notifyStateChange() {
setupLayout();
actions.updateMediaContent(isHideVideos(), isHideImages());
}
public boolean isHideImages() {
return currentMediaState == MEDIA_STATE_VIDEOS_ONLY;
}
public boolean isHideVideos() {
return currentMediaState == MEDIA_STATE_PHOTOS_ONLY;
}
} }

View file

@ -55,12 +55,12 @@
android:layout_marginStart="@dimen/standard_margin" android:layout_marginStart="@dimen/standard_margin"
android:layout_marginEnd="30dp" android:layout_marginEnd="30dp"
android:layout_toRightOf="@id/hideImagesImageview" android:layout_toRightOf="@id/hideImagesImageview"
android:text="@string/hide_images" android:text="@string/show_images"
android:textColor="@color/text_color" android:textColor="@color/text_color"
android:textSize="@dimen/bottom_sheet_text_size" /> android:textSize="@dimen/bottom_sheet_text_size" />
<ImageView <ImageView
android:id="@+id/tickMarkHideImages" android:id="@+id/tickMarkShowImages"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
@ -100,12 +100,12 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/standard_margin" android:layout_marginStart="@dimen/standard_margin"
android:layout_toRightOf="@id/hideVideoImageView" android:layout_toRightOf="@id/hideVideoImageView"
android:text="@string/hide_video" android:text="@string/show_video"
android:textColor="@color/text_color" android:textColor="@color/text_color"
android:textSize="@dimen/bottom_sheet_text_size" /> android:textSize="@dimen/bottom_sheet_text_size" />
<ImageView <ImageView
android:id="@+id/tickMarkHideVideo" android:id="@+id/tickMarkShowVideo"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"

View file

@ -910,11 +910,12 @@
<item quantity="one">%d ausgewählt</item> <item quantity="one">%d ausgewählt</item>
<item quantity="other">%d ausgewählt</item> <item quantity="other">%d ausgewählt</item>
</plurals> </plurals>
<string name="hide_images">Bilder ausblenden</string> <string name="subtitle_photos_videos">Fotos &amp; videos</string>
<string name="show_images">Bilder anzeigen</string> <string name="show_images">Bilder anzeigen</string>
<string name="hide_video">Videos ausblenden</string> <string name="subtitle_photos_only">Nur Fotos</string>
<string name="show_video">Videos anzeigen</string> <string name="show_video">Videos anzeigen</string>
<string name="select_media_folder">Den Ordner \"Medien\" auswählen</string> <string name="subtitle_videos_only">Nur Videos</string>
<string name="select_media_folder">Medienordner festlegen</string>
<string name="choose_location">Speicherort wählen</string> <string name="choose_location">Speicherort wählen</string>
<string name="common_select">Auswählen</string> <string name="common_select">Auswählen</string>
</resources> </resources>

View file

@ -1008,6 +1008,12 @@
<string name="pdf_zoom_tip">Tap on a page to zoom in</string> <string name="pdf_zoom_tip">Tap on a page to zoom in</string>
<string name="storage_permission_full_access">Full access</string> <string name="storage_permission_full_access">Full access</string>
<string name="storage_permission_media_read_only">Media read-only</string> <string name="storage_permission_media_read_only">Media read-only</string>
<string name="subtitle_photos_videos">Photos &amp; videos</string>
<string name="show_images">Show photos</string>
<string name="subtitle_photos_only">Photos only</string>
<string name="show_video">Show videos</string>
<string name="subtitle_videos_only">Videos only</string>
<string name="select_media_folder">Set media folder</string>
<string name="lock_file">Lock file</string> <string name="lock_file">Lock file</string>
<string name="unlock_file">Unlock file</string> <string name="unlock_file">Unlock file</string>
<string name="error_file_lock">Error changing file lock status</string> <string name="error_file_lock">Error changing file lock status</string>