From 611ab276d2b13ba9855dc4f000e317a9233a5a69 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. --- .../android/ui/adapter/SyncedFolderAdapter.kt | 5 +- .../android/ui/adapter/UploadListAdapter.java | 5 +- .../android/ui/fragment/GalleryFragment.java | 4 +- .../ui/fragment/OCFileListFragment.java | 3 +- .../ui/preview/PreviewImageFragment.kt | 3 +- .../ui/preview/PreviewMediaFragment.kt | 15 ++++ .../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/nmc_popup_styles.xml | 16 ++++ app/src/main/res/values/styles.xml | 6 +- 12 files changed, 209 insertions(+), 11 deletions(-) create mode 100644 app/src/main/res/values/nmc_popup_styles.xml diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.kt b/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.kt index 215f23f1f4b3..f661455e19b0 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.kt +++ b/app/src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.kt @@ -15,6 +15,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageButton import android.widget.PopupMenu +import androidx.appcompat.view.ContextThemeWrapper import androidx.annotation.VisibleForTesting import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter import com.afollestad.sectionedrecyclerview.SectionedViewHolder @@ -287,7 +288,9 @@ class SyncedFolderAdapter( } private fun onOverflowIconClicked(section: Int, item: SyncedFolderDisplayItem, view: View) { - val popup = PopupMenu(context, view).apply { + // NMC Customisation + val ctw = ContextThemeWrapper(context, R.style.CustomPopupTheme) + val popup = PopupMenu(ctw, view).apply { inflate(R.menu.synced_folders_adapter) setOnMenuItemClickListener { i: MenuItem -> optionsItemSelected(i, section, item) } menu 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 80fdcb89a5c0..d3e864f0a6ee 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 @@ -60,6 +60,7 @@ import java.util.Optional; import androidx.annotation.NonNull; +import androidx.appcompat.view.ContextThemeWrapper; /** * This Adapter populates a ListView with following types of uploads: pending, active, completed. Filtering possible. @@ -626,7 +627,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 b264078da243..5cff548a4c19 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 @@ -43,6 +43,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; @@ -287,7 +288,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 3043c8b91488..849f8f4febdb 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 @@ -759,7 +759,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.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt index 96cc11fc2468..2d1fbb7499fd 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt @@ -352,10 +352,11 @@ class PreviewImageFragment : FileFragment(), Injectable { val item = menu.findItem(R.id.custom_menu_placeholder_item) item.icon?.let { + // NMC customization item.setIcon( viewThemeUtils.platform.colorDrawable( it, - ContextCompat.getColor(requireContext(), R.color.white) + ContextCompat.getColor(requireContext(), R.color.fontAppbar) ) ) } diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.kt index f939dbf8ecfc..0208ca90f077 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.kt @@ -35,6 +35,7 @@ import android.view.ViewGroup import androidx.annotation.OptIn import androidx.annotation.StringRes import androidx.appcompat.content.res.AppCompatResources +import androidx.core.content.ContextCompat import androidx.core.graphics.drawable.DrawableCompat import androidx.core.view.MenuHost import androidx.core.view.MenuProvider @@ -70,6 +71,7 @@ import com.owncloud.android.ui.dialog.ConfirmationDialogFragment 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.concurrent.Executors import javax.inject.Inject @@ -118,6 +120,9 @@ class PreviewMediaFragment : FileFragment(), OnTouchListener, Injectable { @Inject lateinit var backgroundJobManager: BackgroundJobManager + @Inject + lateinit var viewThemeUtils: ViewThemeUtils + lateinit var binding: FragmentPreviewMediaBinding private var emptyListView: ViewGroup? = null private var exoPlayer: ExoPlayer? = null @@ -386,6 +391,16 @@ class PreviewMediaFragment : FileFragment(), OnTouchListener, Injectable { override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { menu.removeItem(R.id.action_search) menuInflater.inflate(R.menu.custom_menu_placeholder, menu) + // NMC customization + val item = menu.findItem(R.id.custom_menu_placeholder_item) + item.icon?.let { + item.setIcon( + viewThemeUtils.platform.colorDrawable( + it, + ContextCompat.getColor(requireContext(), R.color.fontAppbar) + ) + ) + } } override fun onMenuItemSelected(menuItem: MenuItem): Boolean { 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 fefa493ef301..5e6e10cfa2b9 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 @@ -18,6 +18,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 @@ -208,7 +209,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 41f13b37156f..005ca5f75052 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 @@ -103,7 +103,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)) } } } @@ -115,7 +116,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 1ce3f0da4f73..2f79b79712ed 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -36,4 +36,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 89ed00a08bf2..46992e0a67c6 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -75,4 +75,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/nmc_popup_styles.xml b/app/src/main/res/values/nmc_popup_styles.xml new file mode 100644 index 000000000000..145a9c4ea15b --- /dev/null +++ b/app/src/main/res/values/nmc_popup_styles.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4c1563085156..46d30539bd6e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -359,9 +359,9 @@