Updated design changes

This commit is contained in:
Kumar 2022-05-03 15:19:29 +05:30 committed by A117870935
parent 3cd34b4bfb
commit e4e29d8cdc
9 changed files with 97 additions and 177 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

@ -2,11 +2,9 @@
* Nextcloud Android client application
*
* @author Andy Scherzinger
* @author TSI-mc
* Copyright (C) 2016 Andy Scherzinger
* Copyright (C) 2016 Nextcloud
* Copyright (C) 2016 ownCloud Inc.
* Copyright (C) 2022 TSI-mc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@ -29,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;
@ -40,19 +39,14 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.textview.MaterialTextView;
import com.nextcloud.client.di.Injectable;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.ThemeLayoutUtils;
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
import com.owncloud.android.utils.theme.ThemeUtils;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting;
@ -64,7 +58,7 @@ import androidx.core.content.ContextCompat;
/**
* Base class providing toolbar registration functionality, see {@link #setupToolbar(boolean, boolean)}.
*/
public abstract class ToolbarActivity extends BaseActivity implements Injectable {
public abstract class ToolbarActivity extends BaseActivity {
protected MaterialButton mMenuButton;
protected MaterialTextView mSearchText;
protected MaterialButton mSwitchAccountButton;
@ -80,23 +74,16 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
protected AppCompatSpinner mToolbarSpinner;
private boolean isHomeSearchToolbarShow = false;
@Inject public ThemeColorUtils themeColorUtils;
@Inject public ThemeLayoutUtils themeLayoutUtils;
@Inject public ThemeToolbarUtils themeToolbarUtils;
@Inject public ThemeUtils themeUtils;
@Inject public ThemeDrawableUtils themeDrawableUtils;
@Inject public ThemeButtonUtils themeButtonUtils;
/**
* Toolbar setup that must be called in implementer's {@link #onCreate} after {@link #setContentView} if they want
* to use the toolbar.
*/
private void setupToolbar(boolean isHomeSearchToolbarShow, boolean showSortListButtonGroup) {
int fontColor = themeColorUtils.appBarPrimaryFontColor(this);
int fontColor = ThemeColorUtils.appBarPrimaryFontColor(this);
mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
themeToolbarUtils.colorStatusBar(this);
ThemeToolbarUtils.colorStatusBar(this);
mAppBar = findViewById(R.id.appbar);
mDefaultToolbar = findViewById(R.id.default_toolbar);
@ -121,11 +108,11 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
mToolbarSpinner = findViewById(R.id.toolbar_spinner);
if (mToolbar.getOverflowIcon() != null) {
themeDrawableUtils.tintDrawable(mToolbar.getOverflowIcon(), fontColor);
ThemeDrawableUtils.tintDrawable(mToolbar.getOverflowIcon(), fontColor);
}
if (mToolbar.getNavigationIcon() != null) {
themeDrawableUtils.tintDrawable(mToolbar.getNavigationIcon(), fontColor);
ThemeDrawableUtils.tintDrawable(mToolbar.getNavigationIcon(), fontColor);
}
}
@ -144,7 +131,7 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
String title;
boolean isRoot = isRoot(chosenFile);
title = isRoot ? themeUtils.getDefaultDisplayNameForRootFolder(this) : chosenFile.getFileName();
title = isRoot ? ThemeUtils.getDefaultDisplayNameForRootFolder(this) : chosenFile.getFileName();
updateActionBarTitleAndHomeButtonByString(title);
if (mAppBar != null) {
@ -176,13 +163,13 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
R.animator.appbar_elevation_off));
mDefaultToolbar.setVisibility(View.GONE);
mHomeSearchToolbar.setVisibility(View.VISIBLE);
themeToolbarUtils.colorStatusBar(this, ContextCompat.getColor(this, R.color.bg_default));
ThemeToolbarUtils.colorStatusBar(this, ContextCompat.getColor(this, R.color.bg_default));
} else {
mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(),
R.animator.appbar_elevation_on));
mDefaultToolbar.setVisibility(View.VISIBLE);
mHomeSearchToolbar.setVisibility(View.GONE);
themeToolbarUtils.colorStatusBar(this);
ThemeToolbarUtils.colorStatusBar(this);
}
}
@ -198,7 +185,7 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
// set & color the chosen title
ActionBar actionBar = getSupportActionBar();
themeToolbarUtils.setColoredTitle(actionBar, titleToSet, this);
ThemeToolbarUtils.setColoredTitle(actionBar, titleToSet, this);
// set home button properties
if (actionBar != null) {
@ -290,14 +277,11 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
}
public void updateToolbarSubtitle(@NonNull String subtitle) {
ActionBar actionBar = getSupportActionBar();
themeToolbarUtils.setColoredSubtitle(actionBar, subtitle, this);
}
public void clearToolbarSubtitle() {
ActionBar actionBar = getSupportActionBar();
if(actionBar != null){
actionBar.setSubtitle(null);
if (TextUtils.isEmpty(subtitle)) {
return;
}
ActionBar actionBar = getSupportActionBar();
ThemeToolbarUtils.setColoredSubtitle(actionBar, subtitle, this);
}
}

View file

@ -40,6 +40,7 @@ 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.activity.ToolbarActivity;
import com.owncloud.android.ui.adapter.CommonOCFileListAdapterInterface;
import com.owncloud.android.ui.adapter.GalleryAdapter;
import com.owncloud.android.ui.asynctasks.GallerySearchTask;
@ -92,8 +93,7 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
FileActivity activity = (FileActivity) getActivity();
galleryFragmentBottomSheetDialog = new GalleryFragmentBottomSheetDialog(activity,
this,
appPreferences);
this);
}
imageList = new ArrayList<>();
videoList = new ArrayList<>();
@ -141,6 +141,8 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT;
requireActivity().invalidateOptionsMenu();
updateSubtitle(galleryFragmentBottomSheetDialog.isHideVideos(), galleryFragmentBottomSheetDialog.isHideImages());
handleSearchEvent();
}
@ -379,33 +381,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
@ -417,7 +406,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

@ -904,11 +904,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,11 +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="hide_images">Hide images</string>
<string name="show_images">Show images</string>
<string name="hide_video">Hide video</string>
<string name="show_video">Show video</string>
<string name="select_media_folder">Select the \"Media\" folder</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="choose_location">Choose location</string>
<string name="common_select">Select</string>
</resources>