From d4f27224eab5e316131bdbc0d11adbc2c0f721f9 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 | 5 +- .../ui/fragment/OCFileListFragment.java | 3 +- .../ui/preview/PreviewImageFragment.java | 3 +- .../ui/preview/PreviewMediaFragment.java | 6 ++ .../android/ui/trashbin/TrashbinActivity.java | 5 +- .../theme/FilesSpecificViewThemeUtils.kt | 5 +- app/src/main/res/values-night/colors.xml | 66 ++++++++++++++ app/src/main/res/values/colors.xml | 91 +++++++++++++++++++ app/src/main/res/values/styles.xml | 20 +++- 11 files changed, 203 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 8a377a544d05..7bbaf76b4a17 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 c52a53d369fa..ffe7fef72413 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 @@ -70,6 +70,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. @@ -529,7 +530,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 42c86e4c71b8..bb6f08f39c03 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 @@ -34,6 +34,7 @@ import android.view.View; import android.view.ViewGroup; +import com.nmc.android.utils.DrawableThemeUtils; import com.owncloud.android.BuildConfig; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; @@ -52,6 +53,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -261,7 +263,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 bd7bab22e11d..56b710cc42fd 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 @@ -735,7 +735,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 3ec44ab3cfd5..525267d2f0c2 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 @@ -348,7 +348,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 f8b012551d3d..61c0fc2739fe 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 @@ -73,6 +73,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; @@ -85,6 +86,7 @@ import androidx.annotation.NonNull; import androidx.annotation.StringRes; import androidx.appcompat.widget.AppCompatImageButton; +import androidx.core.content.ContextCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -129,6 +131,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; @@ -379,6 +382,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.java b/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.java index 7a823e21fb7b..e8692d9f0205 100644 --- a/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.java @@ -56,6 +56,7 @@ import javax.inject.Inject; import androidx.annotation.VisibleForTesting; +import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.res.ResourcesCompat; import androidx.recyclerview.widget.LinearLayoutManager; @@ -198,7 +199,9 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onOverflowIconClicked(TrashbinFile file, View view) { - PopupMenu popup = new PopupMenu(this, view); + //NMC Customisation + ContextThemeWrapper ctw = new ContextThemeWrapper(this, R.style.CustomPopupTheme); + PopupMenu popup = new PopupMenu(ctw, view); popup.inflate(R.menu.item_trashbin); popup.setOnMenuItemClickListener(item -> { 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 08bf64d552ad..88a29668c4cd 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -48,4 +48,70 @@ #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_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 f844b3156f33..1ddf1a93ca08 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -81,4 +81,95 @@ @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 + @color/grey_0 + @color/grey_0 + #FFFFFF + @color/grey_30 + @color/grey_0 + @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 c95797f2b65a..2a4dc38bfe08 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -387,9 +387,9 @@ + + + + +