Skip to content

Commit

Permalink
NMC-2258: Snackbar theme customized.
Browse files Browse the repository at this point in the history
NMC-2047: Customized floating action button.
  • Loading branch information
surinder-tsys committed Dec 16, 2024
1 parent 9f7370f commit d4c2b01
Show file tree
Hide file tree
Showing 12 changed files with 244 additions and 11 deletions.
40 changes: 40 additions & 0 deletions app/src/main/java/com/nmc/android/utils/FabThemeUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.nmc.android.utils

import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.owncloud.android.R

object FabThemeUtils {
@JvmStatic
fun colorFloatingActionButton(
context: Context,
button: FloatingActionButton
) {
val primaryColor = context.resources.getColor(R.color.primary, null)
val disableColor = context.resources.getColor(R.color.grey_0, null)

val bgStates = arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled),
)
val bgColors = intArrayOf(
primaryColor,
disableColor
)

button.backgroundTintList = ColorStateList(bgStates, bgColors)

val imageStates = arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled),
)
val imageColors = intArrayOf(
Color.WHITE,
disableColor
)

button.imageTintList = ColorStateList(imageStates, imageColors)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public void onUrlLoaded(String loadedUrl) {
R.string.timeout_richDocuments, Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.common_cancel, v -> closeView());

viewThemeUtils.material.themeSnackbar(snackbar);
setLoadingSnackbar(snackbar);
snackbar.show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,6 @@ public static void copyAndShareFileLink(FileActivity activity,
Snackbar snackbar = Snackbar.make(activity.findViewById(android.R.id.content), R.string.clipboard_text_copied,
Snackbar.LENGTH_LONG)
.setAction(R.string.share, v -> showShareLinkDialog(activity, file, link));
viewThemeUtils.material.themeSnackbar(snackbar);
snackbar.show();
}
}
Expand Down Expand Up @@ -794,7 +793,6 @@ private void onUpdateShareInformation(RemoteOperationResult result, @StringRes i
snackbar = Snackbar.make(sharingFragment.getView(), result.getMessage(), Snackbar.LENGTH_LONG);
}

viewThemeUtils.material.themeSnackbar(snackbar);
snackbar.show();
}
}
Expand Down Expand Up @@ -871,7 +869,6 @@ private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation ope
operation,
getResources()),
Snackbar.LENGTH_LONG);
viewThemeUtils.material.themeSnackbar(snackbar);
snackbar.show();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import com.nextcloud.common.NextcloudClient;
import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
import com.nextcloud.utils.EditorUtils;
import com.nmc.android.utils.FabThemeUtils;
import com.nextcloud.utils.ShortcutUtil;
import com.nextcloud.utils.extensions.BundleExtensionsKt;
import com.nextcloud.utils.extensions.FileExtensionsKt;
Expand Down Expand Up @@ -337,7 +338,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,

if (mFabMain != null) {
// is not available in FolderPickerActivity
viewThemeUtils.material.themeFAB(mFabMain);
//NMC customization
FabThemeUtils.colorFloatingActionButton(requireContext(), mFabMain);
}

Log_OC.i(TAG, "onCreateView() end");
Expand Down Expand Up @@ -489,7 +491,8 @@ public void registerFabListener() {

if (mFabMain != null) {
// is not available in FolderPickerActivity
viewThemeUtils.material.themeFAB(mFabMain);
//NMC customization
FabThemeUtils.colorFloatingActionButton(requireContext(), mFabMain);
mFabMain.setOnClickListener(v -> {
final OCFileListBottomSheetDialog dialog =
new OCFileListBottomSheetDialog(activity,
Expand Down Expand Up @@ -2177,7 +2180,8 @@ public void setFabVisible(final boolean visible) {
getActivity().runOnUiThread(() -> {
if (visible) {
mFabMain.show();
viewThemeUtils.material.themeFAB(mFabMain);
//NMC customization
FabThemeUtils.colorFloatingActionButton(requireContext(), mFabMain);
} else {
mFabMain.hide();
}
Expand Down Expand Up @@ -2227,10 +2231,12 @@ public void setFabEnabled(final boolean enabled) {
getActivity().runOnUiThread(() -> {
if (enabled) {
mFabMain.setEnabled(true);
viewThemeUtils.material.themeFAB(mFabMain);
//NMC customization
FabThemeUtils.colorFloatingActionButton(requireContext(), mFabMain);
} else {
mFabMain.setEnabled(false);
viewThemeUtils.material.themeFAB(mFabMain);
//NMC customization
FabThemeUtils.colorFloatingActionButton(requireContext(), mFabMain);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.nextcloud.android.lib.richWorkspace.RichWorkspaceDirectEditingRemoteOperation;
import com.nextcloud.utils.extensions.FileExtensionsKt;
import com.nmc.android.utils.FabThemeUtils;
import com.owncloud.android.R;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.ui.activity.FileDisplayActivity;
Expand Down Expand Up @@ -85,7 +86,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
fabMain.setOnClickListener(v -> edit());

fabMain.setImageResource(R.drawable.ic_edit);
viewThemeUtils.material.themeFAB(fabMain);
//NMC customization
FabThemeUtils.colorFloatingActionButton(requireActivity(), fabMain);

return view;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ object PermissionUtil {
Snackbar.LENGTH_INDEFINITE
).setAction(R.string.common_ok) {
doRequest()
}.also { viewThemeUtils.material.themeSnackbar(it) }.show()
}.show()
} else {
// No explanation needed, request the permission.
doRequest()
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 @@ -38,4 +38,68 @@
<color name="fontAppbar">@android:color/white</color>

<color name="actionbar_color">#101418</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>
4 changes: 4 additions & 0 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="windowNoTitle">true</item>
<!-- SnackBar Styling -->
<item name="snackbarStyle">@style/SnackBarBackgroundStyle</item>
<item name="snackbarButtonStyle">@style/SnackBarActionButtonStyle</item>
<item name="snackbarTextViewStyle">@style/SnackBarTextViewStyle</item>
<item name="textInputStyle">@style/Widget.App.TextInputLayout</item>
<item name="popupMenuStyle">@style/Nextcloud.Widget.PopupMenu</item>
<item name="bottomSheetDialogTheme">@style/ThemeOverlay.App.BottomSheetDialog</item>
Expand Down
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 @@ -78,4 +78,93 @@
<color name="fontSecondaryAppbar">#A5A5A5</color>

<color name="actionbar_color">#F7F9FF</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_snackbar_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="SnackBarBackgroundStyle" parent="Widget.Material3.Snackbar">
<item name="android:backgroundTint">@color/snackbar_bg_color</item>
<item name="backgroundTint">@color/snackbar_bg_color</item>
</style>

<style name="SnackBarActionButtonStyle" parent="Widget.Material3.Button.TextButton.Snackbar">
<item name="android:textColor">@color/white</item>
</style>

<style name="SnackBarTextViewStyle" parent="Widget.Material3.Snackbar.TextView">
<item name="android:textColor">@color/snackbar_txt_color</item>
</style>
</resources>
12 changes: 12 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorSecondary">@color/secondary_text_color</item>
<item name="searchViewStyle">@style/ownCloud.SearchView</item>
<!-- SnackBar Styling -->
<item name="snackbarStyle">@style/SnackBarBackgroundStyle</item>
<item name="snackbarButtonStyle">@style/SnackBarActionButtonStyle</item>
<item name="snackbarTextViewStyle">@style/SnackBarTextViewStyle</item>
<item name="android:actionModeBackground">@color/action_mode_background</item>
<item name="android:datePickerDialogTheme">@style/FallbackDatePickerDialogTheme</item>
<item name="android:navigationBarColor">@color/bg_default</item>
Expand All @@ -45,6 +49,10 @@
<item name="android:windowBackground">@color/bg_default</item>
<item name="colorSecondary">@color/secondary_text_color</item>
<item name="dialogTheme">@style/FallbackTheming.Dialog</item>
<!-- SnackBar Styling -->
<item name="snackbarStyle">@style/SnackBarBackgroundStyle</item>
<item name="snackbarButtonStyle">@style/SnackBarActionButtonStyle</item>
<item name="snackbarTextViewStyle">@style/SnackBarTextViewStyle</item>
<item name="android:actionModeBackground">@color/action_mode_background</item>
<item name="android:datePickerDialogTheme">@style/FallbackDatePickerDialogTheme</item>
<item name="android:navigationBarColor">@color/bg_default</item>
Expand Down Expand Up @@ -279,6 +287,10 @@
<style name="Theme.ownCloud.Dialog.NoTitle" parent="@style/Theme.ownCloud.Dialog">
<item name="windowNoTitle">true</item>
<item name="colorAccent">@color/color_accent</item>
<!-- SnackBar Styling -->
<item name="snackbarStyle">@style/SnackBarBackgroundStyle</item>
<item name="snackbarButtonStyle">@style/SnackBarActionButtonStyle</item>
<item name="snackbarTextViewStyle">@style/SnackBarTextViewStyle</item>
</style>

<style name="NavigationView_ItemTextAppearance">
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="windowNoTitle">true</item>
<!-- SnackBar Styling -->
<item name="snackbarStyle">@style/SnackBarBackgroundStyle</item>
<item name="snackbarButtonStyle">@style/SnackBarActionButtonStyle</item>
<item name="snackbarTextViewStyle">@style/SnackBarTextViewStyle</item>
<item name="textInputStyle">@style/Widget.App.TextInputLayout</item>
<item name="popupMenuStyle">@style/Nextcloud.Widget.PopupMenu</item>
<item name="bottomSheetDialogTheme">@style/ThemeOverlay.App.BottomSheetDialog</item>
Expand Down

0 comments on commit d4c2b01

Please sign in to comment.