Skip to content

Commit

Permalink
Customized popup menu, overflow menu and Fastscroller.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed Aug 5, 2024
1 parent cf222d4 commit 611ab27
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
Expand All @@ -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 {
Expand Down
64 changes: 64 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,68 @@
<!-- App bar -->
<color name="appbar">#1E1E1E</color>
<color name="fontAppbar">@android:color/white</color>

<!-- NMC Colors -->
<color name="icon_color">#FFFFFF</color>
<color name="sort_text_color">@color/grey_30</color>
<color name="list_icon_color">@color/grey_30</color>
<color name="warning_icon_color">#CCCCCC</color>
<color name="divider_color">@color/grey_70</color>
<color name="spinner_bg_color">@color/grey_80</color>
<color name="refresh_layout_bg_color">#2D2D2D</color>
<color name="primary_button_disabled_color">@color/grey_70</color>
<color name="toolbar_divider_color">@color/grey_70</color>

<!-- Snackbar Colors -->
<color name="snackbar_bg_color">@color/grey_80</color>
<color name="snackbar_txt_color">@color/grey_0</color>

<!-- Alert Dialog Colors -->
<color name="alert_bg_color">@color/grey_80</color>
<color name="alert_txt_color">@color/grey_0</color>

<!-- NavigationView colors -->
<color name="nav_selected_bg_color">@color/grey_60</color>
<color name="nav_txt_unselected_color">@color/grey_0</color>
<color name="nav_txt_selected_color">@color/grey_0</color>
<color name="nav_icon_unselected_color">@color/grey_30</color>
<color name="nav_icon_selected_color">#FFFFFF</color>
<color name="nav_divider_color">@color/grey_30</color>
<color name="nav_bg_color">@color/grey_80</color>
<color name="drawer_quota_txt_color">#FFFFFF</color>

<!-- Bottom Sheet Colors -->
<color name="bottom_sheet_bg_color">@color/grey_80</color>
<color name="bottom_sheet_icon_color">@color/grey_30</color>
<color name="bottom_sheet_txt_color">@color/grey_0</color>

<!-- Popup Menu Colors -->
<color name="popup_menu_bg">@color/grey_80</color>
<color name="popup_menu_txt_color">@color/grey_0</color>
<color name="overflow_bg_color">@color/grey_80</color>

<!-- Switch Compat Colors -->
<color name="switch_thumb_disabled">@color/grey_70</color>
<color name="switch_track_disabled">@color/grey_60</color>

<!-- Checkbox Colors -->
<color name="checkbox_checked_disabled">@color/grey_70</color>
<color name="checkbox_unchecked_disabled">@color/grey_70</color>

<!-- Share Colors -->
<color name="share_title_txt_color">#FFFFFF</color>
<color name="share_subtitle_txt_color">@color/grey_30</color>
<color name="share_info_txt_color">@color/grey_0</color>
<color name="share_search_border_color">@color/grey_0</color>
<color name="share_btn_txt_color">@color/grey_0</color>
<color name="share_list_item_txt_color">@color/grey_0</color>
<color name="share_disabled_txt_color">@color/grey_60</color>
<color name="share_txt_color">@color/grey_0</color>
<color name="share_et_divider">#FFFFFF</color>

<!-- Scan Colors -->
<color name="scan_doc_bg_color">#121212</color>
<color name="scan_text_color">@color/grey_0</color>
<color name="scan_edit_bottom_color">@color/grey_80</color>
<color name="scan_count_bg_color">@color/grey_80</color>
</resources>
89 changes: 89 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,93 @@
<color name="appbar">@android:color/white</color>
<color name="fontAppbar">#666666</color>
<color name="fontSecondaryAppbar">#A5A5A5</color>

<!-- NMC Colors -->
<color name="icon_color">#191919</color>
<color name="sort_text_color">@color/primary</color>
<color name="list_icon_color">#191919</color>
<color name="warning_icon_color">#191919</color>
<color name="divider_color">@color/grey_30</color>
<color name="spinner_bg_color">@android:color/white</color>
<color name="refresh_layout_bg_color">#FFFFFF</color>
<color name="primary_button_disabled_color">@color/grey_0</color>
<color name="toolbar_divider_color">#CCCCCC</color>
<color name="et_highlight_color">#77c4ff</color>
<color name="white_trans_70">#B3FFFFFF</color>
<color name="progress_bar_background">@color/grey_10</color>

<!-- Grey Colors -->
<color name="dark_grey">#101010</color>
<color name="grey_0">#F2F2F2</color>
<color name="grey_10">#E5E5E5</color>
<color name="grey_30">#B2B2B2</color>
<color name="grey_60">#666666</color>
<color name="grey_70">#4C4C4C</color>
<color name="grey_80">#333333</color>

<!-- Snackbar Colors -->
<color name="snackbar_bg_color">@color/design_snackbar_background_color</color>
<color name="snackbar_txt_color">@color/white</color>

<!-- Alert Dialog Colors -->
<color name="alert_bg_color">#FFFFFF</color>
<color name="alert_txt_color">#191919</color>

<!-- NavigationView colors -->
<color name="nav_selected_bg_color">@color/grey_0</color>
<color name="nav_txt_unselected_color">#191919</color>
<color name="nav_txt_selected_color">@color/primary</color>
<color name="nav_icon_unselected_color">#191919</color>
<color name="nav_icon_selected_color">@color/primary</color>
<color name="nav_divider_color">@color/grey_30</color>
<color name="nav_bg_color">@color/white</color>
<color name="drawer_quota_txt_color">#191919</color>

<!-- Bottom Sheet Colors -->
<color name="bottom_sheet_bg_color">#FFFFFF</color>
<color name="bottom_sheet_icon_color">#191919</color>
<color name="bottom_sheet_txt_color">#191919</color>

<!-- Popup Menu Colors -->
<color name="popup_menu_bg">#FFFFFF</color>
<color name="popup_menu_txt_color">#191919</color>
<color name="overflow_bg_color">#FFFFFF</color>

<!-- Switch Compat Colors -->
<color name="switch_thumb_checked_enabled">@color/primary</color>
<color name="switch_track_checked_enabled">#F399C7</color>
<color name="switch_thumb_unchecked_enabled">#FFFFFF</color>
<color name="switch_track_unchecked_enabled">@color/grey_30</color>
<color name="switch_thumb_disabled">@color/grey_10</color>
<color name="switch_track_disabled">@color/grey_0</color>

<!-- Checkbox Colors -->
<color name="checkbox_checked_enabled">@color/primary</color>
<color name="checkbox_unchecked_enabled">@color/grey_30</color>
<color name="checkbox_checked_disabled">@color/grey_30</color>
<color name="checkbox_unchecked_disabled">#CCCCCC</color>

<!-- Share Colors -->
<color name="share_title_txt_color">#191919</color>
<color name="share_subtitle_txt_color">@color/grey_30</color>
<color name="share_info_txt_color">#191919</color>
<color name="share_search_border_color">#191919</color>
<color name="share_btn_txt_color">#191919</color>
<color name="share_list_item_txt_color">#191919</color>
<color name="share_disabled_txt_color">@color/grey_30</color>
<color name="share_txt_color">#191919</color>
<color name="share_et_divider">#000000</color>
<color name="share_warning_txt_color">#191919</color>
<color name="sharing_warning_bg_color">#F6E5EB</color>
<color name="sharing_warning_border_color">#C16F81</color>
<color name="share_color">#0D39DF</color>
<color name="shared_with_me_color">#0099ff</color>

<!-- Scan Colors -->
<color name="scan_doc_bg_color">@color/grey_0</color>
<color name="scan_text_color">#191919</color>
<color name="scan_edit_bottom_color">@color/grey_0</color>
<color name="scan_count_bg_color">@color/grey_30</color>
<color name="neptune">#77b6bb</color>
<color name="neptune_50">#5077b6bb</color>
</resources>
16 changes: 16 additions & 0 deletions app/src/main/res/values/nmc_popup_styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="CustomPopupTheme">
<!-- if using android.widget.PopupMenu -->
<item name="android:popupMenuStyle">@style/PopupMenu</item>
<!-- if using android.support.v7.widget.PopupMenu -->
<item name="popupMenuStyle">@style/PopupMenu</item>
</style>

<style name="PopupMenu" parent="ThemeOverlay.AppTheme.PopupMenu">
<item name="android:popupBackground">@color/popup_menu_bg</item>
<item name="android:textColor">@color/popup_menu_txt_color</item>
<item name="android:popupElevation">20dp</item>
</style>
</resources>
6 changes: 3 additions & 3 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@

<style name="ThemeOverlay.AppTheme.PopupMenu" parent="ThemeOverlay.Material3.Dark">
<!-- popup menu background - NEVER "android:background" !!! in themes -->
<item name="android:colorBackground">@color/bg_default</item>
<item name="android:colorBackground">@color/popup_menu_bg</item>
<!-- popup menu item text color -->
<item name="android:textColorPrimary">@color/text_color</item>
<item name="android:textColorPrimary">@color/popup_menu_txt_color</item>
</style>

<style name="Nextcloud.Widget.PopupMenu" parent="@style/Widget.Material3.PopupMenu">
Expand All @@ -374,7 +374,7 @@
</style>

<style name="OverflowMenuStyle" parent="Widget.Material3.PopupMenu.Overflow">
<item name="android:popupBackground">@color/bg_default</item>
<item name="android:popupBackground">@color/overflow_bg_color</item>
</style>

<style name="MaterialListItemSingleLine">
Expand Down

0 comments on commit 611ab27

Please sign in to comment.