From 45a6365a0505f3605e235a1761b0837cef676e1d 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. NMC-2138: Sort filter toolbar button customized. NMC-2035: Customized navigation view theme with drawer options. --- app/src/main/AndroidManifest.xml | 5 +- .../nmc/android/utils/DrawableThemeUtils.kt | 18 ++ .../nmc/android/utils/ToolbarThemeUtils.kt | 27 ++ .../android/ui/activity/DrawerActivity.java | 245 +++++------------- .../ui/activity/ManageSpaceActivity.kt | 7 +- .../android/ui/activity/SettingsActivity.java | 32 ++- .../android/ui/activity/ShareActivity.java | 2 - .../android/ui/activity/ToolbarActivity.java | 39 ++- .../ui/dialog/SortingOrderDialogFragment.kt | 13 +- .../ui/fragment/ExtendedListFragment.java | 6 - .../ui/preview/PreviewImageActivity.kt | 67 +---- .../ui/preview/PreviewMediaActivity.kt | 21 +- .../owncloud/android/utils/StringUtils.java | 31 +++ .../theme/FilesSpecificViewThemeUtils.kt | 27 +- .../drawable/ic_magentacloud_product_logo.xml | 31 +++ .../drawable/menu_background_color_state.xml | 4 + .../res/layout/action_mode_close_layout.xml | 14 + .../res/layout/activity_preview_media.xml | 16 +- app/src/main/res/layout/drawer.xml | 41 ++- .../res/layout/preview_image_activity.xml | 25 +- app/src/main/res/layout/share_activity.xml | 4 +- .../res/layout/sorting_order_fragment.xml | 1 + app/src/main/res/layout/toolbar_standard.xml | 36 ++- .../main/res/menu/partial_drawer_entries.xml | 30 ++- app/src/main/res/values-de/strings.xml | 3 + app/src/main/res/values-night/colors.xml | 64 +++++ app/src/main/res/values-night/themes.xml | 5 + app/src/main/res/values-v27/styles.xml | 2 +- app/src/main/res/values/colors.xml | 89 +++++++ app/src/main/res/values/dimens.xml | 33 +++ .../main/res/values/nmc_navigation_styles.xml | 6 + app/src/main/res/values/setup.xml | 4 +- app/src/main/res/values/strings.xml | 3 + app/src/main/res/values/styles.xml | 15 +- app/src/main/res/values/themes.xml | 5 + 35 files changed, 604 insertions(+), 367 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/drawable/ic_magentacloud_product_logo.xml create mode 100644 app/src/main/res/drawable/menu_background_color_state.xml create mode 100644 app/src/main/res/layout/action_mode_close_layout.xml create mode 100644 app/src/main/res/values/dimens.xml create mode 100644 app/src/main/res/values/nmc_navigation_styles.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6f89c63ac939..0ea70de0ce53 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -336,11 +336,10 @@ + android:theme="@style/Theme.ownCloud" /> + android:exported="false" /> requestBuilder = Glide.with(this) - .using(Glide.buildStreamModelLoader(Uri.class, this), InputStream.class) - .from(Uri.class) - .as(SVGorImage.class) - .transcode(new SvgOrImageBitmapTranscoder(128, 128), Bitmap.class) - .sourceEncoder(new StreamEncoder()) - .cacheDecoder(new FileToStreamDecoder<>(new SvgOrImageDecoder())) - .decoder(new SvgOrImageDecoder()); - - // background image - SimpleTarget target = new SimpleTarget<>() { - @Override - public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) { - - Bitmap logo = resource; - int width = resource.getWidth(); - int height = resource.getHeight(); - int max = Math.max(width, height); - if (max > MAX_LOGO_SIZE_PX) { - logo = BitmapUtils.scaleBitmap(resource, MAX_LOGO_SIZE_PX, width, height, max); - } - - Drawable[] drawables = {new ColorDrawable(primaryColor), - new BitmapDrawable(getResources(), logo)}; - LayerDrawable layerDrawable = new LayerDrawable(drawables); - - String name = capability.getServerName(); - setDrawerHeaderLogo(layerDrawable, name); - } - }; - - requestBuilder - .diskCacheStrategy(DiskCacheStrategy.SOURCE) - .load(Uri.parse(logo)) - .into(target); - } - } - - // hide ecosystem apps according to user preference or in branded client - LinearLayout banner = mNavigationViewHeader.findViewById(R.id.drawer_ecosystem_apps); - boolean shouldHideTopBanner = isClientBranded || !preferences.isShowEcosystemApps(); - - if (shouldHideTopBanner) { - hideTopBanner(banner); - } else { - showTopBanner(banner, primaryColor); - } - } - - private void hideTopBanner(LinearLayout banner) { - banner.setVisibility(View.GONE); - } - - private void showTopBanner(LinearLayout banner, int primaryColor) { - LinearLayout notesView = banner.findViewById(R.id.drawer_ecosystem_notes); - LinearLayout talkView = banner.findViewById(R.id.drawer_ecosystem_talk); - LinearLayout moreView = banner.findViewById(R.id.drawer_ecosystem_more); - LinearLayout assistantView = banner.findViewById(R.id.drawer_ecosystem_assistant); - - notesView.setOnClickListener(v -> openAppOrStore("it.niedermann.owncloud.notes")); - talkView.setOnClickListener(v -> openAppOrStore("com.nextcloud.talk2")); - moreView.setOnClickListener(v -> openAppStore("Nextcloud", true)); - assistantView.setOnClickListener(v -> startComposeActivity(ComposeDestination.AssistantScreen, R.string.assistant_screen_top_bar_title, -1)); - if (getCapabilities() != null && getCapabilities().getAssistant().isTrue()) { - assistantView.setVisibility(View.VISIBLE); - } else { - assistantView.setVisibility(View.GONE); - } - - List views = Arrays.asList(notesView, talkView, moreView, assistantView); - - int iconColor; - if (Hct.fromInt(primaryColor).getTone() < 80.0) { - iconColor = Color.WHITE; - } else { - iconColor = getColor(R.color.grey_800_transparent); - } - - for (LinearLayout view : views) { - ImageView imageView = (ImageView) view.getChildAt(0); - imageView.setImageTintList(ColorStateList.valueOf(iconColor)); - GradientDrawable background = (GradientDrawable) imageView.getBackground(); - background.setStroke(DisplayUtils.convertDpToPixel(1, this), iconColor); - TextView textView = (TextView) view.getChildAt(1); - textView.setTextColor(iconColor); - } - - banner.setVisibility(View.VISIBLE); - } - - /** - * Open specified app and, if not installed redirect to corresponding download. - * - * @param packageName of app to be opened - */ - private void openAppOrStore(String packageName) { - Intent intent = getPackageManager().getLaunchIntentForPackage(packageName); - if (intent != null) { - // app installed - open directly - intent.putExtra(FileDisplayActivity.KEY_ACCOUNT, getUser().get().hashCode()); - startActivity(intent); - } else { - // app not found - open market (Google Play Store, F-Droid, etc.) - openAppStore(packageName, false); - } + viewThemeUtils.material.colorProgressBar(mQuotaProgressBar, getResources().getColor(R.color.primary)); } /** @@ -431,20 +286,6 @@ private void openAppStore(String string, boolean search) { } } - private void setDrawerHeaderLogo(Drawable drawable, String serverName) { - ImageView imageHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_logo); - imageHeader.setImageDrawable(drawable); - imageHeader.setAdjustViewBounds(true); - - if (!TextUtils.isEmpty(serverName)) { - TextView serverNameView = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name); - serverNameView.setVisibility(View.VISIBLE); - serverNameView.setText(serverName); - serverNameView.setTextColor(themeColorUtils.unchangedFontColor(this)); - } - - } - /** * setup drawer content, basically setting the item selected listener. * @@ -471,7 +312,9 @@ private void filterDrawerMenu(final Menu menu, @NonNull final User user) { OCCapability capability = getCapabilities(); DrawerMenuUtil.filterSearchMenuItems(menu, user, getResources()); - DrawerMenuUtil.filterTrashbinMenuItem(menu, capability); + // NMC: trashbin icon is depending on capability due to this it doesn't appear in some of the devices + // so removing the check as we need this option always + // DrawerMenuUtil.filterTrashbinMenuItem(menu, capability); DrawerMenuUtil.filterActivityMenuItem(menu, capability); DrawerMenuUtil.filterGroupfoldersMenuItem(menu, capability); DrawerMenuUtil.filterAssistantMenuItem(menu, capability, getResources()); @@ -782,21 +625,20 @@ private void showQuota(boolean showQuota) { * @param quotaValue {@link GetUserInfoRemoteOperation#SPACE_UNLIMITED} or other to determinate state */ private void setQuotaInformation(long usedSpace, long totalSpace, int relative, long quotaValue) { - if (GetUserInfoRemoteOperation.SPACE_UNLIMITED == quotaValue) { - mQuotaTextPercentage.setText(String.format( - getString(R.string.drawer_quota_unlimited), - DisplayUtils.bytesToHumanReadable(usedSpace))); - } else { - mQuotaTextPercentage.setText(String.format( - getString(R.string.drawer_quota), - DisplayUtils.bytesToHumanReadable(usedSpace), - DisplayUtils.bytesToHumanReadable(totalSpace))); - } + String usageText = String.format( + getString(R.string.drawer_quota_usage), + DisplayUtils.bytesToHumanReadable(usedSpace), + DisplayUtils.bytesToHumanReadable(totalSpace)); + + mQuotaTextUsage.setText(StringUtils.makeTextBold(usageText, DisplayUtils.bytesToHumanReadable(usedSpace))); mQuotaProgressBar.setProgress(relative); + mQuotaTextPercentage.setText(String.format( + getString(R.string.drawer_quota_percentage), relative)); + if (relative < RELATIVE_THRESHOLD_WARNING) { - viewThemeUtils.material.colorProgressBar(mQuotaProgressBar); + viewThemeUtils.material.colorProgressBar(mQuotaProgressBar, getResources().getColor(R.color.primary)); } else { viewThemeUtils.material.colorProgressBar(mQuotaProgressBar, getResources().getColor(R.color.infolevel_warning, getTheme())); @@ -882,10 +724,43 @@ public void onLoadFailed(Exception e, Drawable errorDrawable) { * @param menuItemId the menu item to be highlighted */ protected void setDrawerMenuItemChecked(int menuItemId) { + //NMC customisation + //if item is logout then do not show it as selected + if (menuItemId == R.id.nav_logout) { + //if previous checked item is not NONE then make it selected again + //to show it as selected bg color + if (mCheckedMenuItem != Menu.NONE) { + setDrawerMenuItemChecked(mCheckedMenuItem); + } + return; + } + if (mNavigationView != null && mNavigationView.getMenu().findItem(menuItemId) != null) { - viewThemeUtils.platform.colorNavigationView(mNavigationView); mCheckedMenuItem = menuItemId; - mNavigationView.getMenu().findItem(menuItemId).setChecked(true); + + //for NMC customization + MenuItem currentItem = mNavigationView.getMenu().findItem(menuItemId); + int drawerDefaultTxtColor = getResources().getColor(R.color.nav_txt_unselected_color); + int drawerActiveTxtColor = getResources().getColor(R.color.nav_txt_selected_color); + + int drawerDefaultIconColor = getResources().getColor(R.color.nav_icon_unselected_color); + int drawerActiveIconColor = getResources().getColor(R.color.nav_icon_selected_color); + + currentItem.setChecked(true); + + // For each menu item, change the color of the selected item, and of the other items + for (int i = 0; i < mNavigationView.getMenu().size(); i++) { + MenuItem menuItem = mNavigationView.getMenu().getItem(i); + if (menuItem.getIcon() != null) { + if (menuItem == currentItem) { + viewThemeUtils.platform.colorDrawable(currentItem.getIcon(), drawerActiveIconColor); + currentItem.setTitle(StringUtils.getColorSpan(currentItem.getTitle().toString(), drawerActiveTxtColor)); + } else { + viewThemeUtils.platform.colorDrawable(menuItem.getIcon(), drawerDefaultIconColor); + menuItem.setTitle(StringUtils.getColorSpan(menuItem.getTitle().toString(), drawerDefaultTxtColor)); + } + } + } } else { Log_OC.w(TAG, "setDrawerMenuItemChecked has been called with invalid menu-item-ID"); } @@ -1120,7 +995,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { * @return The view if found or null otherwise. */ private View findQuotaViewById(int id) { - View v = ((NavigationView) findViewById(R.id.nav_view)).getHeaderView(0).findViewById(id); + View v = ((NavigationView) findViewById(R.id.nav_view)).findViewById(id); if (v != null) { return v; diff --git a/app/src/main/java/com/owncloud/android/ui/activity/ManageSpaceActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/ManageSpaceActivity.kt index fe79e7aaa17c..be9af7ed0d03 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/ManageSpaceActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/ManageSpaceActivity.kt @@ -18,6 +18,7 @@ import com.nextcloud.client.di.Injectable import com.nextcloud.client.preferences.AppPreferences import com.owncloud.android.R import com.owncloud.android.lib.common.utils.Log_OC +import com.owncloud.android.utils.theme.ViewThemeUtils import java.io.File import javax.inject.Inject import kotlin.system.exitProcess @@ -30,13 +31,17 @@ class ManageSpaceActivity : AppCompatActivity(), Injectable { @Inject lateinit var userAccountManager: UserAccountManager + @Inject + lateinit var viewThemeUtils: ViewThemeUtils + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_manage_space) val actionBar = supportActionBar if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true) - actionBar.setTitle(R.string.manage_space_title) + //NMC Customisation + viewThemeUtils.files.themeActionBar(this, actionBar, R.string.manage_space_title) } val descriptionTextView = findViewById(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 84d5beaa26de..92c39e8fc1b7 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 @@ -21,6 +21,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; @@ -173,7 +174,7 @@ public void onCreate(Bundle savedInstanceState) { // Sync setupSyncCategory(); - + // More setupMoreCategory(); @@ -313,7 +314,7 @@ private void setupAboutCategory(String appVersion) { } } } - + private void setupSyncCategory() { final PreferenceCategory preferenceCategorySync = (PreferenceCategory) findPreference("sync"); viewThemeUtils.files.themePreferenceCategory(preferenceCategorySync); @@ -557,10 +558,10 @@ private void setupAutoUploadPreference(PreferenceCategory preferenceCategoryMore }); } } - + private void setupInternalTwoWaySyncPreference() { Preference twoWaySync = findPreference("internal_two_way_sync"); - + twoWaySync.setOnPreferenceClickListener(preference -> { Intent intent = new Intent(this, InternalTwoWaySyncActivity.class); startActivity(intent); @@ -875,20 +876,17 @@ public boolean onOptionsItemSelected(MenuItem item) { private void setupActionBar() { ActionBar actionBar = getDelegate().getSupportActionBar(); + if (actionBar == null) return; - if (actionBar != null) { - viewThemeUtils.platform.themeStatusBar(this); - 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)); - } - } + viewThemeUtils.platform.themeStatusBar(this); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowTitleEnabled(true); + + if (getResources() == null) return; + // 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))); } private void launchDavDroidLogin() { 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 e51fd0869b4e..a8ecc29af92a 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 @@ -92,8 +92,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 14f8ba64a26c..56cb92af46b7 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 @@ -17,6 +17,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; @@ -31,9 +32,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; @@ -62,6 +65,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; @@ -82,6 +86,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); @@ -98,8 +103,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); } @@ -162,22 +169,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); } /** @@ -190,7 +186,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); @@ -287,8 +284,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/dialog/SortingOrderDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/SortingOrderDialogFragment.kt index 8a593cabf541..427547760139 100644 --- a/app/src/main/java/com/owncloud/android/ui/dialog/SortingOrderDialogFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/dialog/SortingOrderDialogFragment.kt @@ -10,6 +10,7 @@ package com.owncloud.android.ui.dialog import android.app.Dialog +import android.graphics.Typeface import android.os.Bundle import android.view.View import androidx.fragment.app.DialogFragment @@ -63,11 +64,19 @@ class SortingOrderDialogFragment : DialogFragment(), Injectable { view.tag = sortOrder view.let { it.setOnClickListener(OnSortOrderClickListener()) - viewThemeUtils?.material?.colorMaterialButtonPrimaryBorderless(it) + + // NMC Customization + if ((view.tag as FileSortOrder).name == currentSortOrderName) { + it.setTextColor(resources.getColor(R.color.primary, null)) + it.setIconTintResource(R.color.primary) + it.setTypeface(it.typeface, Typeface.BOLD) + } else { + it.setTextColor(resources.getColor(R.color.standard_grey, null)) + it.setIconTintResource(R.color.standard_grey) + } } } - viewThemeUtils?.material?.colorMaterialButtonPrimaryTonal(binding.cancel) binding.cancel.setOnClickListener { dismiss() } } diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java index 90d5ff624628..54837a342cfb 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -352,13 +352,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, mRefreshListLayout.setOnRefreshListener(this); mSortButton = getActivity().findViewById(R.id.sort_button); - if (mSortButton != null) { - viewThemeUtils.material.colorMaterialTextButton(mSortButton); - } mSwitchGridViewButton = getActivity().findViewById(R.id.switch_grid_view_button); - if (mSwitchGridViewButton != null) { - viewThemeUtils.material.colorMaterialTextButton(mSwitchGridViewButton); - } return v; } diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.kt index 7ebd4af61d3c..1003d9f49e3b 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.kt @@ -10,12 +10,8 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.os.Build import android.os.Bundle import android.view.MenuItem -import android.view.View -import android.view.WindowInsets -import android.view.WindowInsetsController import androidx.appcompat.app.ActionBar import androidx.drawerlayout.widget.DrawerLayout import androidx.localbroadcastmanager.content.LocalBroadcastManager @@ -68,7 +64,6 @@ class PreviewImageActivity : FileActivity(), FileFragment.ContainerActivity, OnR private var savedPosition = 0 private var hasSavedPosition = false private var downloadFinishReceiver: DownloadFinishReceiver? = null - private var fullScreenAnchorView: View? = null private var isDownloadWorkStarted = false private var screenState = PreviewImageActivityState.Idle @@ -95,6 +90,7 @@ class PreviewImageActivity : FileActivity(), FileFragment.ContainerActivity, OnR } setContentView(R.layout.preview_image_activity) + setupToolbar() livePhotoFile = intent.getParcelableArgument(EXTRA_LIVE_PHOTO_FILE, OCFile::class.java) @@ -108,7 +104,6 @@ class PreviewImageActivity : FileActivity(), FileFragment.ContainerActivity, OnR actionBar?.setDisplayHomeAsUpEnabled(true) } - fullScreenAnchorView = window.decorView // to keep our UI controls visibility in line with system bars visibility setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) @@ -227,7 +222,8 @@ class PreviewImageActivity : FileActivity(), FileFragment.ContainerActivity, OnR if (file != null) { // / Refresh the activity according to the Account and OCFile set setFile(file) // reset after getting it fresh from storageManager - updateActionBarTitle(getFile().fileName) + // NMC Customization + updateActionBarTitleAndHomeButton(getFile()) // if (!stateWasRecovered) { initViewPager(optionalUser.get()) @@ -400,15 +396,12 @@ class PreviewImageActivity : FileActivity(), FileFragment.ContainerActivity, OnR } if (currentFile != null) { - updateActionBarTitle(currentFile.fileName) + // NMC Customization + updateActionBarTitleAndHomeButton(currentFile) setDrawerIndicatorEnabled(false) } } - private fun updateActionBarTitle(title: String?) { - supportActionBar?.title = title - } - /** * Class waiting for broadcast events from the [FileDownloadWorker] service. * @@ -471,17 +464,7 @@ class PreviewImageActivity : FileActivity(), FileFragment.ContainerActivity, OnR get() = supportActionBar == null || supportActionBar?.isShowing == true fun toggleFullScreen() { - if (fullScreenAnchorView == null) return - val visible = ( - fullScreenAnchorView!!.systemUiVisibility - and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - ) == 0 - - if (visible) { - hideSystemUI(fullScreenAnchorView!!) - } else { - showSystemUI(fullScreenAnchorView!!) - } + // do nothing for NMC } fun startImageEditor(file: OCFile) { @@ -519,44 +502,6 @@ class PreviewImageActivity : FileActivity(), FileFragment.ContainerActivity, OnR // TODO Auto-generated method stub } - private fun hideSystemUI(anchorView: View) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - window.insetsController?.let { controller -> - controller.hide(WindowInsets.Type.systemBars()) - controller.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE - } - } else { - @Suppress("DEPRECATION") - anchorView.systemUiVisibility = ( - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hides NAVIGATION BAR; Android >= 4.0 - or View.SYSTEM_UI_FLAG_FULLSCREEN // hides STATUS BAR; Android >= 4.1 - or View.SYSTEM_UI_FLAG_IMMERSIVE // stays interactive; Android >= 4.4 - or View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window; Android >= 4.1 - or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1 - or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - ) - } - } - - private fun showSystemUI(anchorView: View) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - window.insetsController?.let { controller -> - controller.show(WindowInsets.Type.systemBars()) - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - controller.systemBarsBehavior = WindowInsetsController.BEHAVIOR_DEFAULT - } - } - } else { - @Suppress("DEPRECATION") - anchorView.systemUiVisibility = ( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window; Android >= 4.1 - or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1 - or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - ) - } - } - companion object { val TAG: String = PreviewImageActivity::class.java.simpleName const val EXTRA_VIRTUAL_TYPE: String = "EXTRA_VIRTUAL_TYPE" diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt index 2b9b793b87ff..8db043f39ef1 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaActivity.kt @@ -37,6 +37,7 @@ import android.widget.LinearLayout 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.ViewCompat import androidx.core.view.WindowCompat @@ -146,7 +147,8 @@ class PreviewMediaActivity : binding = ActivityPreviewMediaBinding.inflate(layoutInflater) setContentView(binding.root) - setSupportActionBar(binding.materialToolbar) + // NMC Customization: Customize toolbar + setupToolbar() WindowCompat.setDecorFitsSystemWindows(window, false) applyWindowInsets() initArguments(savedInstanceState) @@ -257,10 +259,6 @@ class PreviewMediaActivity : it.setDisplayHomeAsUpEnabled(true) viewThemeUtils.files.themeActionBar(this, it) } - - viewThemeUtils.platform.themeStatusBar( - this - ) } private fun showProgressLayout() { @@ -461,7 +459,7 @@ class PreviewMediaActivity : .displayCutout() ) - binding.materialToolbar.updateLayoutParams { + binding.mediaToolbar.appbar.updateLayoutParams { topMargin = insets.top } exoControls.updateLayoutParams { @@ -472,7 +470,7 @@ class PreviewMediaActivity : } exoControls.updatePadding(left = insets.left, right = insets.right) exoProgress.updatePadding(left = insets.left, right = insets.right) - binding.materialToolbar.updatePadding(left = insets.left, right = insets.right) + binding.mediaToolbar.appbar.updatePadding(left = insets.left, right = insets.right) WindowInsetsCompat.CONSUMED } } @@ -505,6 +503,15 @@ class PreviewMediaActivity : override fun onCreateOptionsMenu(menu: Menu?): Boolean { menuInflater.inflate(R.menu.custom_menu_placeholder, menu) + // NMC customization + menu?.findItem(R.id.custom_menu_placeholder_item)?.apply { + icon = icon?.let { + viewThemeUtils.platform.colorDrawable( + it, + ContextCompat.getColor(this@PreviewMediaActivity, R.color.fontAppbar) + ) + } + } return true } 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 d4339f0003eb..637b6c4ea15d 100644 --- a/app/src/main/java/com/owncloud/android/utils/StringUtils.java +++ b/app/src/main/java/com/owncloud/android/utils/StringUtils.java @@ -7,7 +7,14 @@ */ package com.owncloud.android.utils; + +import android.text.Spannable; +import android.text.SpannableString; +import android.text.style.ForegroundColorSpan; + import java.util.Locale; +import android.graphics.Typeface; +import android.text.style.StyleSpan; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -55,6 +62,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) { @@ -63,4 +79,19 @@ String removePrefix(@NonNull String s, @NonNull String prefix) { } return s; } + + /** + * make the passed text bold + * + * @param fullText actual text + * @param textToBold to be bold + * @return + */ + public static Spannable makeTextBold(String fullText, String textToBold) { + Spannable spannable = new SpannableString(fullText); + int indexStart = fullText.indexOf(textToBold); + int indexEnd = indexStart + textToBold.length(); + spannable.setSpan(new StyleSpan(Typeface.BOLD), indexStart, indexEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + return spannable; + } } 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..d075e145d14c 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 @@ -28,7 +28,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 @@ -133,18 +135,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) } /** @@ -171,7 +166,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/drawable/ic_magentacloud_product_logo.xml b/app/src/main/res/drawable/ic_magentacloud_product_logo.xml new file mode 100644 index 000000000000..287fc029a729 --- /dev/null +++ b/app/src/main/res/drawable/ic_magentacloud_product_logo.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/menu_background_color_state.xml b/app/src/main/res/drawable/menu_background_color_state.xml new file mode 100644 index 000000000000..1aee89b3ea28 --- /dev/null +++ b/app/src/main/res/drawable/menu_background_color_state.xml @@ -0,0 +1,4 @@ + + + + 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/activity_preview_media.xml b/app/src/main/res/layout/activity_preview_media.xml index b61873086fc3..0f6087540344 100644 --- a/app/src/main/res/layout/activity_preview_media.xml +++ b/app/src/main/res/layout/activity_preview_media.xml @@ -15,15 +15,6 @@ android:gravity="center" tools:context=".ui.preview.PreviewMediaActivity"> - - + + + + + + + + + android:drawablePadding="@dimen/alternate_half_padding" + android:visibility="gone" /> @@ -60,9 +81,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:drawablePadding="@dimen/alternate_half_padding" - android:fontFamily="sans-serif-medium" + android:paddingLeft="@dimen/standard_padding" + android:paddingRight="@dimen/standard_padding" android:text="@string/drawer_quota" - android:textColor="@color/drawer_text_color" /> + android:textColor="@color/drawer_quota_txt_color" + android:textSize="@dimen/txt_size_14sp" /> diff --git a/app/src/main/res/layout/preview_image_activity.xml b/app/src/main/res/layout/preview_image_activity.xml index 35746487f5f1..f53792ba5b84 100644 --- a/app/src/main/res/layout/preview_image_activity.xml +++ b/app/src/main/res/layout/preview_image_activity.xml @@ -10,17 +10,28 @@ ~ SPDX-FileCopyrightText: 2013 David A. Velasco ~ SPDX-License-Identifier: GPL-2.0-only AND (AGPL-3.0-or-later OR GPL-2.0-only) --> - - + + + + + + + android:layout_height="1dp" + android:background="@color/divider_color" /> @@ -61,11 +61,28 @@ android:layout_marginEnd="1dp" android:contentDescription="@string/action_switch_grid_view" app:cornerRadius="24dp" + app:iconSize="24dp" app:icon="@drawable/ic_view_module" - app:iconTint="@color/fontAppbar" + app:iconTint="@color/icon_color" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + @@ -86,6 +103,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" /> @@ -99,7 +117,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"> @@ -112,6 +130,14 @@ app:popupTheme="@style/Theme.AppCompat.DayNight.NoActionBar" /> + + + android:title="@string/drawer_item_recent_files" + android:visible="false"/> + + + + #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-night/themes.xml b/app/src/main/res/values-night/themes.xml index 19b3ce692520..ef13919a9f09 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -22,6 +22,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 diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v27/styles.xml index 22f2cbfe648f..80d94557e005 100644 --- a/app/src/main/res/values-v27/styles.xml +++ b/app/src/main/res/values-v27/styles.xml @@ -35,7 +35,7 @@ false - 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/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 000000000000..43e80a31e3f2 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,33 @@ + + + 4dp + 16dp + 24dp + 24dp + 6dp + 18sp + 15sp + 15dp + 56dp + 86dp + 80dp + 11sp + 30dp + 55dp + 258dp + 17sp + 20dp + 160dp + 50dp + 150dp + 55dp + 48dp + 48dp + 24dp + 26dp + 20sp + 145dp + 1dp + 13sp + 44dp + \ No newline at end of file diff --git a/app/src/main/res/values/nmc_navigation_styles.xml b/app/src/main/res/values/nmc_navigation_styles.xml new file mode 100644 index 000000000000..5e2acf8f859e --- /dev/null +++ b/app/src/main/res/values/nmc_navigation_styles.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/setup.xml b/app/src/main/res/values/setup.xml index 3b6c7532937e..594559f3457e 100644 --- a/app/src/main/res/values/setup.xml +++ b/app/src/main/res/values/setup.xml @@ -70,7 +70,7 @@ false true - false + true true @@ -103,7 +103,7 @@ - true + false https://f-droid.org/repository/browse/?fdid=com.nextcloud.android.beta https://download.nextcloud.com/android/dev/latest.apk diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e541d34a9c19..f01c34a77431 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -76,8 +76,11 @@ Notifications %1$s of %2$s used %1$s used + %d %% Storage used + %1$s of %2$s Close sidebar Open sidebar + Recent files General More Manage accounts diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4c1563085156..1d46740b9577 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -31,6 +31,11 @@ @style/FallbackDatePickerDialogTheme @color/bg_default @style/Widget.App.TextInputLayout + + @color/primary + + @drawable/ic_arrow_back + @drawable/ic_arrow_back @dimen/dialogBorderRadius @@ -49,6 +54,11 @@ @style/FallbackDatePickerDialogTheme @color/bg_default @style/Widget.App.TextInputLayout + + @color/primary + + @drawable/ic_arrow_back + @drawable/ic_arrow_back @dimen/dialogBorderRadius @@ -285,7 +295,7 @@ end @color/transparent - @color/drawer_active_item_background + @color/text_color diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index cefa8e7856d8..ebc41ddb9a42 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -23,6 +23,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