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 Feb 14, 2024
1 parent f59caa7 commit 1088e01
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
Expand All @@ -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 {
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 @@ -49,4 +49,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 @@ -83,4 +83,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>
20 changes: 17 additions & 3 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,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 @@ -402,7 +402,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 Expand Up @@ -449,6 +449,20 @@
<item name="hwSecuritySurfaceColor">@color/primary</item>
</style>

<!-- NMC Customization -->
<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>

<style name="Nextcloud.Material.TextButton" parent="Widget.Material3.Button.TextButton.Icon">
<item name="android:typeface">sans</item>
<item name="android:textStyle">bold</item>
Expand Down

0 comments on commit 1088e01

Please sign in to comment.