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);
/**
* 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__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 SharedPreferences preferences;
private final CurrentAccountProvider currentAccountProvider;
@ -718,23 +715,4 @@ public final class AppPreferencesImpl implements AppPreferences {
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.Color;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
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.ThemeUtils;
import androidx.annotation.NonNull;
import javax.inject.Inject;
import androidx.annotation.StringRes;
@ -285,4 +287,13 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
public FrameLayout getPreviewImageContainer() {
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;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
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.ui.activity.FileActivity;
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.GalleryAdapter;
import com.owncloud.android.ui.asynctasks.GallerySearchTask;
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 androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -77,8 +88,7 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
FileActivity activity = (FileActivity) getActivity();
galleryFragmentBottomSheetDialog = new GalleryFragmentBottomSheetDialog(activity,
this,
appPreferences);
this);
}
}
@ -118,6 +128,8 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT;
requireActivity().invalidateOptionsMenu();
updateSubtitle(galleryFragmentBottomSheetDialog.isHideVideos(), galleryFragmentBottomSheetDialog.isHideImages());
handleSearchEvent();
}
@ -349,33 +361,20 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
}
}
//Actions implementation of Bottom Sheet Dialog
@Override
public void hideVideos(boolean isHideVideosClicked) {
public void updateMediaContent(boolean isHideVideos, boolean isHidePhotos) {
if (!mediaObject.isEmpty()) {
mAdapter.setAdapterWithHideShowImage(mediaObject,
preferences.getHideVideoClicked(),
preferences.getHideImageClicked(), imageList, videoList,
isHideVideos,
isHidePhotos, imageList, videoList,
this);
} else {
setEmptyListMessage(SearchType.GALLERY_SEARCH);
}
}
@Override
public void hideImages(boolean isHideImagesClicked) {
if (!mediaObject.isEmpty()) {
mAdapter.setAdapterWithHideShowImage(mediaObject,
preferences.getHideVideoClicked(),
preferences.getHideImageClicked(), imageList, videoList,
this);
updateSubtitle(isHideVideos, isHidePhotos);
} else {
setEmptyListMessage(SearchType.GALLERY_SEARCH);
}
}
@Override
@ -387,7 +386,24 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
public void showAllGalleryItems() {
mAdapter.showAllGalleryItems(mContainerActivity.getStorageManager(), remoteFilePath.getRemotePath(),
mediaObject, preferences.getHideVideoClicked(), preferences.getHideImageClicked(),
mediaObject, galleryFragmentBottomSheetDialog.isHideVideos(),
galleryFragmentBottomSheetDialog.isHideImages(),
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 {
/**
* hide all the images in particular Folder.
* show/hide all the images & videos in particular Folder.
*/
void hideImages(boolean isHideImagesClicked);
/**
* hide all the videos in particular folder.
*/
void hideVideos(boolean isHideVideosClicked);
void updateMediaContent(boolean isHideVideos, boolean isHidePhotos);
/**
* load all media of a particular folder.

View file

@ -36,19 +36,20 @@ import androidx.core.content.ContextCompat;
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 final GalleryFragmentBottomSheetActions actions;
private final AppPreferences preferences;
private boolean isHideImageClicked;
private boolean isHideVideoClicked;
private BottomSheetBehavior mBottomBehavior;
private int currentMediaState = MEDIA_STATE_DEFAULT;
public GalleryFragmentBottomSheetDialog(FileActivity fileActivity,
GalleryFragmentBottomSheetActions actions,
AppPreferences preferences) {
GalleryFragmentBottomSheetActions actions) {
super(fileActivity);
this.actions = actions;
this.preferences = preferences;
}
@ -73,24 +74,15 @@ public class GalleryFragmentBottomSheetDialog extends BottomSheetDialog {
}
private void setupLayout() {
if (!preferences.getHideImageClicked()) {
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);
} else if (preferences.getHideImageClicked()) {
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);
}
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);
if (currentMediaState == MEDIA_STATE_PHOTOS_ONLY) {
binding.tickMarkShowImages.setVisibility(View.VISIBLE);
binding.tickMarkShowVideo.setVisibility(View.GONE);
} else if (currentMediaState == MEDIA_STATE_VIDEOS_ONLY) {
binding.tickMarkShowImages.setVisibility(View.GONE);
binding.tickMarkShowVideo.setVisibility(View.VISIBLE);
} else {
binding.tickMarkShowImages.setVisibility(View.VISIBLE);
binding.tickMarkShowVideo.setVisibility(View.VISIBLE);
}
}
@ -98,63 +90,23 @@ public class GalleryFragmentBottomSheetDialog extends BottomSheetDialog {
binding.hideImages.setOnClickListener(v -> {
if (!preferences.getHideImageClicked() && preferences.getHideVideoClicked()) {
isHideImageClicked = true;
isHideVideoClicked = false;
binding.hideImagesImageview.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_no_camera));
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);
if (currentMediaState == MEDIA_STATE_VIDEOS_ONLY) {
currentMediaState = MEDIA_STATE_DEFAULT;
} else {
currentMediaState = MEDIA_STATE_VIDEOS_ONLY;
}
preferences.setHideImageClicked(isHideImageClicked);
preferences.setHideVideoClicked(isHideVideoClicked);
actions.hideImages(preferences.getHideImageClicked());
notifyStateChange();
dismiss();
});
binding.hideVideo.setOnClickListener(v -> {
if (!preferences.getHideVideoClicked() && !preferences.getHideImageClicked()) {
isHideVideoClicked = true;
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);
} 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);
if (currentMediaState == MEDIA_STATE_PHOTOS_ONLY) {
currentMediaState = MEDIA_STATE_DEFAULT;
} else {
currentMediaState = MEDIA_STATE_PHOTOS_ONLY;
}
preferences.setHideVideoClicked(isHideVideoClicked);
preferences.setHideImageClicked(isHideImageClicked);
actions.hideVideos(preferences.getHideVideoClicked());
notifyStateChange();
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_marginEnd="30dp"
android:layout_toRightOf="@id/hideImagesImageview"
android:text="@string/hide_images"
android:text="@string/show_images"
android:textColor="@color/text_color"
android:textSize="@dimen/bottom_sheet_text_size" />
<ImageView
android:id="@+id/tickMarkHideImages"
android:id="@+id/tickMarkShowImages"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentEnd="true"
@ -100,12 +100,12 @@
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/standard_margin"
android:layout_toRightOf="@id/hideVideoImageView"
android:text="@string/hide_video"
android:text="@string/show_video"
android:textColor="@color/text_color"
android:textSize="@dimen/bottom_sheet_text_size" />
<ImageView
android:id="@+id/tickMarkHideVideo"
android:id="@+id/tickMarkShowVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"

View file

@ -910,11 +910,12 @@
<item quantity="one">%d ausgewählt</item>
<item quantity="other">%d ausgewählt</item>
</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="hide_video">Videos ausblenden</string>
<string name="subtitle_photos_only">Nur Fotos</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="common_select">Auswählen</string>
</resources>

View file

@ -1008,6 +1008,12 @@
<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_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="unlock_file">Unlock file</string>
<string name="error_file_lock">Error changing file lock status</string>