From 36d1b7b4b5b41015cf5b39aaa1741786d63c51f9 Mon Sep 17 00:00:00 2001 From: A117870935 Date: Sun, 14 May 2023 14:45:37 +0530 Subject: [PATCH] Customized theme of toolbar and action mode. --- app/src/main/AndroidManifest.xml | 5 +- .../nmc/android/utils/DrawableThemeUtils.kt | 18 ++++ .../nmc/android/utils/ToolbarThemeUtils.kt | 27 ++++++ .../android/ui/activity/DrawerActivity.java | 8 +- .../ui/activity/ManageSpaceActivity.kt | 7 +- .../android/ui/activity/SettingsActivity.java | 11 ++- .../android/ui/activity/ShareActivity.java | 2 - .../android/ui/activity/ToolbarActivity.java | 39 ++++---- .../ui/preview/PreviewImageActivity.java | 48 +--------- .../owncloud/android/utils/StringUtils.java | 13 +++ .../theme/FilesSpecificViewThemeUtils.kt | 27 +++--- .../res/layout/action_mode_close_layout.xml | 14 +++ .../main/res/layout/file_details_fragment.xml | 2 +- .../res/layout/preview_image_activity.xml | 21 +++-- app/src/main/res/layout/share_activity.xml | 4 +- app/src/main/res/layout/toolbar_standard.xml | 27 +++++- app/src/main/res/values-night/colors.xml | 64 +++++++++++++ app/src/main/res/values/colors.xml | 89 +++++++++++++++++++ app/src/main/res/values/styles.xml | 18 +++- 19 files changed, 342 insertions(+), 102 deletions(-) create mode 100644 app/src/main/java/com/nmc/android/utils/DrawableThemeUtils.kt create mode 100644 app/src/main/java/com/nmc/android/utils/ToolbarThemeUtils.kt create mode 100644 app/src/main/res/layout/action_mode_close_layout.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c0494a90d4c0..434134ad7ead 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -229,11 +229,10 @@ + android:theme="@style/Theme.ownCloud" /> + android:exported="false" /> (R.id.general_description) descriptionTextView.text = getString(R.string.manage_space_description, getString(R.string.app_name)) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java index 3017ff43b8b4..5cde5d405c8b 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java @@ -33,6 +33,7 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; +import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Bundle; import android.preference.ListPreference; @@ -874,12 +875,10 @@ private void setupActionBar() { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); if (this.getResources() != null) { - viewThemeUtils.androidx.themeActionBar(this, - actionBar, - getString(R.string.actionbar_settings), - ResourcesCompat.getDrawable(this.getResources(), - R.drawable.ic_arrow_back, - null)); + //custom color for back arrow for NMC + viewThemeUtils.files.themeActionBar(this, actionBar, getResources().getString(R.string.actionbar_settings)); + //required for NMC + actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.bg_default, null))); } } } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java index b5da83327702..b0b7e7bee9cd 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/ShareActivity.java @@ -100,8 +100,6 @@ protected void onCreate(Bundle savedInstanceState) { // Name binding.shareFileName.setText(getResources().getString(R.string.share_file, file.getFileName())); - viewThemeUtils.platform.colorViewBackground(binding.shareHeaderDivider); - // Size binding.shareFileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength())); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java index b9823f0fa1f5..2c03e8c3494e 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java @@ -28,6 +28,7 @@ import android.annotation.SuppressLint; import android.graphics.Bitmap; import android.graphics.Color; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.view.View; import android.widget.FrameLayout; @@ -42,9 +43,11 @@ import com.google.android.material.card.MaterialCardView; import com.google.android.material.textview.MaterialTextView; import com.nextcloud.client.di.Injectable; +import com.nmc.android.utils.ToolbarThemeUtils; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.utils.StringUtils; import com.owncloud.android.utils.theme.ThemeColorUtils; import com.owncloud.android.utils.theme.ThemeUtils; import com.owncloud.android.utils.theme.ViewThemeUtils; @@ -73,6 +76,7 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable private LinearLayout mInfoBox; private TextView mInfoBoxMessage; protected AppCompatSpinner mToolbarSpinner; + private View mDefaultToolbarDivider; private boolean isHomeSearchToolbarShow = false; @Inject public ThemeColorUtils themeColorUtils; @@ -93,6 +97,7 @@ private void setupToolbar(boolean isHomeSearchToolbarShow, boolean showSortListB mMenuButton = findViewById(R.id.menu_button); mSearchText = findViewById(R.id.search_text); mSwitchAccountButton = findViewById(R.id.switch_account_button); + mDefaultToolbarDivider = findViewById(R.id.default_toolbar_divider); if (showSortListButtonGroup) { findViewById(R.id.sort_list_button_group).setVisibility(View.VISIBLE); @@ -109,8 +114,10 @@ private void setupToolbar(boolean isHomeSearchToolbarShow, boolean showSortListB mToolbarSpinner = findViewById(R.id.toolbar_spinner); - viewThemeUtils.material.themeToolbar(mToolbar); - viewThemeUtils.material.colorToolbarOverflowIcon(mToolbar); + // custom color for overflow icon required for NMC + if (mToolbar.getOverflowIcon() != null) { + mToolbar.getOverflowIcon().setColorFilter(getResources().getColor(R.color.fontAppbar, null), PorterDuff.Mode.SRC_ATOP); + } viewThemeUtils.platform.themeStatusBar(this); viewThemeUtils.material.colorMaterialTextButton(mSwitchAccountButton); } @@ -157,22 +164,11 @@ private void showHomeSearchToolbar(String title, boolean isRoot) { @SuppressLint("PrivateResource") private void showHomeSearchToolbar(boolean isShow) { - viewThemeUtils.material.themeToolbar(mToolbar); - if (isShow) { - viewThemeUtils.platform.resetStatusBar(this); - mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(), - R.animator.appbar_elevation_off)); - mDefaultToolbar.setVisibility(View.GONE); - mHomeSearchToolbar.setVisibility(View.VISIBLE); - viewThemeUtils.material.themeCardView(mHomeSearchToolbar); - viewThemeUtils.material.themeSearchBarText(mSearchText); - } else { - mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(), - R.animator.appbar_elevation_on)); - viewThemeUtils.platform.themeStatusBar(this); - mDefaultToolbar.setVisibility(View.VISIBLE); - mHomeSearchToolbar.setVisibility(View.GONE); - } + mAppBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(mAppBar.getContext(), + R.animator.appbar_elevation_on)); + viewThemeUtils.platform.themeStatusBar(this); + mDefaultToolbar.setVisibility(View.VISIBLE); + mHomeSearchToolbar.setVisibility(View.GONE); } /** @@ -185,7 +181,8 @@ public void updateActionBarTitleAndHomeButtonByString(String title) { // set home button properties if (actionBar != null) { if (title != null) { - actionBar.setTitle(title); + //custom styling for action bar title required for NMC + ToolbarThemeUtils.setColoredTitle(this, actionBar, title); actionBar.setDisplayShowTitleEnabled(true); } else { actionBar.setDisplayShowTitleEnabled(false); @@ -282,8 +279,8 @@ public FrameLayout getPreviewImageContainer() { public void updateToolbarSubtitle(@NonNull String subtitle) { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { - actionBar.setSubtitle(subtitle); - viewThemeUtils.androidx.themeActionBarSubtitle(this, actionBar); + //required for NMC + actionBar.setSubtitle(StringUtils.getColorSpan(subtitle, getResources().getColor(R.color.fontAppbar, null))); } } diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java index 586ce7815fac..8d7d4d3847b9 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -96,7 +96,6 @@ public class PreviewImageActivity extends FileActivity implements private boolean mRequestWaitingForBinder; private DownloadFinishReceiver mDownloadFinishReceiver; private UploadFinishReceiver mUploadFinishReceiver; - private View mFullScreenAnchorView; private boolean isDownloadWorkStarted = false; @Inject AppPreferences preferences; @@ -123,6 +122,7 @@ protected void onCreate(Bundle savedInstanceState) { } setContentView(R.layout.preview_image_activity); + setupToolbar(); livePhotoFile = IntentExtensionsKt.getParcelableArgument(getIntent(), EXTRA_LIVE_PHOTO_FILE, OCFile.class); @@ -137,7 +137,6 @@ protected void onCreate(Bundle savedInstanceState) { actionBar.setDisplayHomeAsUpEnabled(true); } - mFullScreenAnchorView = getWindow().getDecorView(); // to keep our UI controls visibility in line with system bars visibility setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); @@ -257,7 +256,7 @@ public void onStart() { if (file != null) { /// Refresh the activity according to the Account and OCFile set setFile(file); // reset after getting it fresh from storageManager - getSupportActionBar().setTitle(getFile().getFileName()); + updateActionBarTitleAndHomeButton(getFile()); //if (!stateWasRecovered) { initViewPager(optionalUser.get()); //} @@ -404,9 +403,7 @@ public void onPageSelected(int position) { OCFile currentFile = mPreviewImagePagerAdapter.getFileAt(position); if (currentFile != null) { - if (getSupportActionBar() != null) { - getSupportActionBar().setTitle(currentFile.getFileName()); - } + updateActionBarTitleAndHomeButton(currentFile); setDrawerIndicatorEnabled(false); if (currentFile.isEncrypted() && !currentFile.isDown() && @@ -504,22 +501,7 @@ public boolean isSystemUIVisible() { } public void toggleFullScreen() { - boolean visible = (mFullScreenAnchorView.getSystemUiVisibility() - & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; - - if (visible) { - hideSystemUI(mFullScreenAnchorView); - // actionBar.hide(); // propagated through - // OnSystemUiVisibilityChangeListener() - } else { - showSystemUI(mFullScreenAnchorView); - // actionBar.show(); // propagated through - // OnSystemUiVisibilityChangeListener() - } - } - - public void switchToFullScreen() { - hideSystemUI(mFullScreenAnchorView); + // do nothing for NMC } public void startImageEditor(OCFile file) { @@ -543,26 +525,4 @@ public void onTransferStateChanged(OCFile file, boolean downloading, boolean upl // TODO Auto-generated method stub } - - - @SuppressLint("InlinedApi") - private void hideSystemUI(View anchorView) { - anchorView.setSystemUiVisibility( - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hides NAVIGATION BAR; Android >= 4.0 - | View.SYSTEM_UI_FLAG_FULLSCREEN // hides STATUS BAR; Android >= 4.1 - | View.SYSTEM_UI_FLAG_IMMERSIVE // stays interactive; Android >= 4.4 - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window; Android >= 4.1 - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1 - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // draw full window; Android >= 4.1 - ); - } - - @SuppressLint("InlinedApi") - private void showSystemUI(View anchorView) { - anchorView.setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window; Android >= 4.1 - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1 - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // draw full window; Android >= 4. - ); - } } diff --git a/app/src/main/java/com/owncloud/android/utils/StringUtils.java b/app/src/main/java/com/owncloud/android/utils/StringUtils.java index 5c6871dcab73..cab320ee9901 100644 --- a/app/src/main/java/com/owncloud/android/utils/StringUtils.java +++ b/app/src/main/java/com/owncloud/android/utils/StringUtils.java @@ -21,6 +21,10 @@ package com.owncloud.android.utils; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.style.ForegroundColorSpan; + import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -69,6 +73,15 @@ String searchAndColor(@Nullable String text, @Nullable String searchText, } } + public static Spannable getColorSpan(@NonNull String title, @ColorInt int color) { + Spannable text = new SpannableString(title); + text.setSpan(new ForegroundColorSpan(color), + 0, + text.length(), + Spannable.SPAN_INCLUSIVE_INCLUSIVE); + return text; + } + public static @NonNull String removePrefix(@NonNull String s, @NonNull String prefix) { 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..400c3cbbdb6a 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 @@ -43,7 +43,9 @@ import com.nextcloud.android.common.ui.theme.MaterialSchemes import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase import com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils import com.nextcloud.android.common.ui.theme.utils.AndroidXViewThemeUtils +import com.nmc.android.utils.ToolbarThemeUtils import com.nextcloud.utils.view.FastScrollPopupBackground +import com.nmc.android.utils.DrawableThemeUtils import com.owncloud.android.R import com.owncloud.android.lib.common.utils.Log_OC import com.owncloud.android.lib.resources.shares.ShareType @@ -150,18 +152,11 @@ class FilesSpecificViewThemeUtils @Inject constructor( // TODO move back arrow resource to lib and use lib method directly? @JvmOverloads fun themeActionBar(context: Context, actionBar: ActionBar, title: String, isMenu: Boolean = false) { - val icon = getHomeAsUpIcon(isMenu) - val backArrow = ResourcesCompat.getDrawable( - context.resources, - icon, - null - )!! - androidXViewThemeUtils.themeActionBar( - context, - actionBar, - title, - backArrow - ) + //custom styling for action bar title required for NMC + ToolbarThemeUtils.setColoredTitle(context, actionBar, title) + + //custom color for back arrow for NMC + themeActionBar(context, actionBar, isMenu) } /** @@ -188,7 +183,13 @@ class FilesSpecificViewThemeUtils @Inject constructor( getHomeAsUpIcon(isMenu), null )!! - androidXViewThemeUtils.themeActionBar(context, actionBar, backArrow) + //custom color for back arrow for NMC + actionBar.setHomeAsUpIndicator( + DrawableThemeUtils.tintDrawable( + backArrow, + context.resources.getColor(R.color.fontAppbar, null) + ) + ) } fun themeTemplateCardView(cardView: MaterialCardView) { diff --git a/app/src/main/res/layout/action_mode_close_layout.xml b/app/src/main/res/layout/action_mode_close_layout.xml new file mode 100644 index 000000000000..36e355cb18c3 --- /dev/null +++ b/app/src/main/res/layout/action_mode_close_layout.xml @@ -0,0 +1,14 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/file_details_fragment.xml b/app/src/main/res/layout/file_details_fragment.xml index 41795e3aceb1..5f9f898c9fa4 100644 --- a/app/src/main/res/layout/file_details_fragment.xml +++ b/app/src/main/res/layout/file_details_fragment.xml @@ -183,7 +183,7 @@ + android:background="@color/divider_color" /> - + + + + + + + android:layout_height="1dp" + android:background="@color/divider_color" /> + + + + @@ -97,6 +113,7 @@ android:id="@+id/preview_image" android:layout_width="match_parent" android:layout_height="@dimen/nav_drawer_header_height" + android:background="@color/bg_default" android:contentDescription="@string/preview_image_description" android:scaleType="centerCrop" /> @@ -110,7 +127,7 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:background="@color/appbar" + android:background="@color/bg_default" android:theme="@style/Theme.ToolbarTheme" tools:visibility="gone"> @@ -123,6 +140,14 @@ app:popupTheme="@style/Theme.AppCompat.DayNight.NoActionBar" /> + + diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 08bf64d552ad..e926fdcc432f 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -48,4 +48,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 58fcdecf1fc2..b05b582157a7 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -82,4 +82,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/styles.xml b/app/src/main/res/values/styles.xml index c1ef3a3c3f36..6732b8fa9feb 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -38,6 +38,11 @@ @style/FallbackDatePickerDialogTheme @color/bg_default @style/Widget.App.TextInputLayout + + @color/primary + + @drawable/ic_arrow_back + @drawable/ic_arrow_back @dimen/dialogBorderRadius @@ -56,6 +61,11 @@ @style/FallbackDatePickerDialogTheme @color/bg_default @style/Widget.App.TextInputLayout + + @color/primary + + @drawable/ic_arrow_back + @drawable/ic_arrow_back @dimen/dialogBorderRadius @@ -122,6 +132,11 @@ @style/Widget.App.TextInputLayout @style/Nextcloud.Widget.PopupMenu @style/ThemeOverlay.App.BottomSheetDialog + + @color/primary + + @drawable/ic_arrow_back + @drawable/ic_arrow_back @style/App.ActionMode @@ -476,10 +491,11 @@