From 1088e01d36051f68883f608fa9d0009c6867551a Mon Sep 17 00:00:00 2001 From: A117870935 Date: Sun, 14 May 2023 23:02:09 +0530 Subject: [PATCH] Customized popup menu, overflow menu and Fastscroller. --- .../ui/adapter/SyncedFolderAdapter.java | 5 +- .../android/ui/adapter/UploadListAdapter.java | 5 +- .../android/ui/fragment/GalleryFragment.java | 4 +- .../ui/fragment/OCFileListFragment.java | 3 +- .../ui/preview/PreviewImageFragment.java | 3 +- .../ui/preview/PreviewMediaFragment.java | 6 ++ .../android/ui/trashbin/TrashbinActivity.kt | 5 +- .../theme/FilesSpecificViewThemeUtils.kt | 5 +- app/src/main/res/values-night/colors.xml | 64 +++++++++++++ app/src/main/res/values/colors.xml | 89 +++++++++++++++++++ app/src/main/res/values/styles.xml | 20 ++++- 11 files changed, 198 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java index 2f316929809b..a21044c551f9 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java @@ -50,6 +50,7 @@ import java.util.concurrent.Executors; import androidx.annotation.NonNull; +import androidx.appcompat.view.ContextThemeWrapper; /** * Adapter to display all auto-synced folders and/or instant upload media folders. @@ -298,7 +299,9 @@ public void onBindHeaderViewHolder(SectionedViewHolder commonHolder, final int s } private void onOverflowIconClicked(int section, SyncedFolderDisplayItem item, View view) { - PopupMenu popup = new PopupMenu(context, view); + //NMC Customisation + ContextThemeWrapper ctw = new ContextThemeWrapper(context, R.style.CustomPopupTheme); + PopupMenu popup = new PopupMenu(ctw, view); popup.inflate(R.menu.synced_folders_adapter); popup.setOnMenuItemClickListener(i -> optionsItemSelected(i, section, item)); popup.getMenu() diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index 50168c5b0dc0..230af3a99a47 100755 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -75,6 +75,7 @@ import java.util.Arrays; import androidx.annotation.NonNull; +import androidx.appcompat.view.ContextThemeWrapper; /** * This Adapter populates a ListView with following types of uploads: pending, active, completed. Filtering possible. @@ -567,7 +568,9 @@ private void showItemConflictPopup(User user, OCUpload item, String status, View view) { - PopupMenu popup = new PopupMenu(MainApp.getAppContext(), view); + //NMC Customisation + ContextThemeWrapper ctw = new ContextThemeWrapper(MainApp.getAppContext(), R.style.CustomPopupTheme); + PopupMenu popup = new PopupMenu(ctw, view); popup.inflate(R.menu.upload_list_item_file_conflict); popup.setOnMenuItemClickListener(i -> { int itemId = i.getItemId(); diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java index 00b5b00adb62..fa9fe79e3d9e 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java @@ -57,6 +57,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -290,7 +291,8 @@ public void onCreateOptionsMenu(Menu menu, @NonNull MenuInflater inflater) { MenuItem menuItem = menu.findItem(R.id.action_three_dot_icon); if (menuItem != null) { - viewThemeUtils.platform.colorMenuItemText(requireContext(), menuItem); + //NMC customization + menuItem.setIcon(viewThemeUtils.platform.colorDrawable(menuItem.getIcon(), ContextCompat.getColor(requireContext(), R.color.fontAppbar))); } } diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 3af6eb035c0a..332c851c72d8 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -749,7 +749,8 @@ public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.custom_menu_placeholder, menu); final MenuItem item = menu.findItem(R.id.custom_menu_placeholder_item); - item.setIcon(viewThemeUtils.platform.colorDrawable(item.getIcon(), ContextCompat.getColor(requireContext(), R.color.white))); + //NMC customization + item.setIcon(viewThemeUtils.platform.colorDrawable(item.getIcon(), ContextCompat.getColor(requireContext(), R.color.fontAppbar))); mode.invalidate(); //set actionMode color diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java index 7c1727ba22ee..b874fcd024c4 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -377,7 +377,8 @@ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflat super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.custom_menu_placeholder, menu); final MenuItem item = menu.findItem(R.id.custom_menu_placeholder_item); - item.setIcon(viewThemeUtils.platform.colorDrawable(item.getIcon(), ContextCompat.getColor(requireContext(), R.color.white))); + //NMC customization + item.setIcon(viewThemeUtils.platform.colorDrawable(item.getIcon(), ContextCompat.getColor(requireContext(), R.color.fontAppbar))); } @Override diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 01b8de50180f..788042b14299 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -75,6 +75,7 @@ import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment; import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.utils.MimeTypeUtil; +import com.owncloud.android.utils.theme.ViewThemeUtils; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -89,6 +90,7 @@ import androidx.annotation.StringRes; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.graphics.drawable.DrawableCompat; +import androidx.core.content.ContextCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -138,6 +140,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene @Inject ClientFactory clientFactory; @Inject UserAccountManager accountManager; @Inject BackgroundJobManager backgroundJobManager; + @Inject ViewThemeUtils viewThemeUtils; FragmentPreviewMediaBinding binding; private ViewGroup emptyListView; private ExoPlayer exoPlayer; @@ -415,6 +418,9 @@ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflat super.onCreateOptionsMenu(menu, inflater); menu.removeItem(R.id.action_search); inflater.inflate(R.menu.custom_menu_placeholder, menu); + //NMC customization + final MenuItem item = menu.findItem(R.id.custom_menu_placeholder_item); + item.setIcon(viewThemeUtils.platform.colorDrawable(item.getIcon(), ContextCompat.getColor(requireContext(), R.color.fontAppbar))); } @Override diff --git a/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.kt b/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.kt index ff99ef902406..ef06b93ae542 100644 --- a/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.kt @@ -33,6 +33,7 @@ import android.widget.TextView import android.widget.Toast import androidx.activity.OnBackPressedCallback import androidx.annotation.VisibleForTesting +import androidx.appcompat.view.ContextThemeWrapper import androidx.core.content.res.ResourcesCompat import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.snackbar.Snackbar @@ -221,7 +222,9 @@ class TrashbinActivity : } override fun onOverflowIconClicked(file: TrashbinFile, view: View) { - val popup = PopupMenu(this, view) + // NMC Customization + val ctw = ContextThemeWrapper(this, R.style.CustomPopupTheme) + val popup = PopupMenu(ctw, view) popup.inflate(R.menu.item_trashbin) popup.setOnMenuItemClickListener { trashbinPresenter?.removeTrashbinFile(file) diff --git a/app/src/main/java/com/owncloud/android/utils/theme/FilesSpecificViewThemeUtils.kt b/app/src/main/java/com/owncloud/android/utils/theme/FilesSpecificViewThemeUtils.kt index 2d728aca05f3..be83cb2b3808 100644 --- a/app/src/main/java/com/owncloud/android/utils/theme/FilesSpecificViewThemeUtils.kt +++ b/app/src/main/java/com/owncloud/android/utils/theme/FilesSpecificViewThemeUtils.kt @@ -118,7 +118,8 @@ class FilesSpecificViewThemeUtils @Inject constructor( .setThumbDrawable(getThumbDrawable(context)) .setPopupStyle { PopupStyles.MD2.accept(it) - it.background = FastScrollPopupBackground(context, scheme.primary) + //NMC customisation + it.background = FastScrollPopupBackground(context, context.resources.getColor(R.color.primary, null)) } } } @@ -132,7 +133,7 @@ class FilesSpecificViewThemeUtils @Inject constructor( me.zhanghai.android.fastscroll.R.drawable.afs_md2_thumb, null ) - return androidViewThemeUtils.tintPrimaryDrawable(context, thumbDrawable)!! + return androidViewThemeUtils.colorDrawable(thumbDrawable!!, context.resources.getColor(R.color.primary, null)) } private fun getHomeAsUpIcon(isMenu: Boolean): Int { diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 0c23e15f1550..cb09bcace39c 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -49,4 +49,68 @@ #1E1E1E @android:color/white + + + #FFFFFF + @color/grey_30 + @color/grey_30 + #CCCCCC + @color/grey_70 + @color/grey_80 + #2D2D2D + @color/grey_70 + @color/grey_70 + + + @color/grey_80 + @color/grey_0 + + + @color/grey_80 + @color/grey_0 + + + @color/grey_60 + @color/grey_0 + @color/grey_0 + @color/grey_30 + #FFFFFF + @color/grey_30 + @color/grey_80 + #FFFFFF + + + @color/grey_80 + @color/grey_30 + @color/grey_0 + + + @color/grey_80 + @color/grey_0 + @color/grey_80 + + + @color/grey_70 + @color/grey_60 + + + @color/grey_70 + @color/grey_70 + + + #FFFFFF + @color/grey_30 + @color/grey_0 + @color/grey_0 + @color/grey_0 + @color/grey_0 + @color/grey_60 + @color/grey_0 + #FFFFFF + + + #121212 + @color/grey_0 + @color/grey_80 + @color/grey_80 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index b18023e7d3df..b9de9c86b30e 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -83,4 +83,93 @@ @android:color/white #666666 #A5A5A5 + + + #191919 + @color/primary + #191919 + #191919 + @color/grey_30 + @android:color/white + #FFFFFF + @color/grey_0 + #CCCCCC + #77c4ff + #B3FFFFFF + @color/grey_10 + + + #101010 + #F2F2F2 + #E5E5E5 + #B2B2B2 + #666666 + #4C4C4C + #333333 + + + @color/design_snackbar_background_color + @color/white + + + #FFFFFF + #191919 + + + @color/grey_0 + #191919 + @color/primary + #191919 + @color/primary + @color/grey_30 + @color/white + #191919 + + + #FFFFFF + #191919 + #191919 + + + #FFFFFF + #191919 + #FFFFFF + + + @color/primary + #F399C7 + #FFFFFF + @color/grey_30 + @color/grey_10 + @color/grey_0 + + + @color/primary + @color/grey_30 + @color/grey_30 + #CCCCCC + + + #191919 + @color/grey_30 + #191919 + #191919 + #191919 + #191919 + @color/grey_30 + #191919 + #000000 + #191919 + #F6E5EB + #C16F81 + #0D39DF + #0099ff + + + @color/grey_0 + #191919 + @color/grey_0 + @color/grey_30 + #77b6bb + #5077b6bb diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c1ef3a3c3f36..946c5c415f57 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -387,9 +387,9 @@ + + + + +