From 688d6b04708cdc53a5d4ee008ad83164d9c6bfe7 Mon Sep 17 00:00:00 2001 From: A117870935 Date: Tue, 16 May 2023 01:37:06 +0530 Subject: [PATCH] Sharing theming updated. --- .../nmc/android/utils/CheckableThemeUtils.kt | 86 +++++++++++++++++++ .../nmc/android/utils/SearchViewThemeUtils.kt | 22 +++++ .../ui/adapter/LinkShareViewHolder.java | 1 - .../fragment/FileDetailSharingFragment.java | 4 +- ...ileDetailSharingMenuBottomSheetDialog.java | 8 -- .../FileDetailsSharingProcessFragment.kt | 20 ++--- ...ckSharingPermissionsBottomSheetDialog.java | 2 - ...ils_sharing_menu_bottom_sheet_fragment.xml | 16 ++-- .../layout/item_quick_share_permissions.xml | 5 +- ...ring_permissions_bottom_sheet_fragment.xml | 1 + app/src/main/res/values-night/colors.xml | 16 +++- app/src/main/res/values/colors.xml | 34 +++++++- app/src/main/res/values/styles.xml | 1 + 13 files changed, 176 insertions(+), 40 deletions(-) create mode 100644 app/src/main/java/com/nmc/android/utils/CheckableThemeUtils.kt create mode 100644 app/src/main/java/com/nmc/android/utils/SearchViewThemeUtils.kt diff --git a/app/src/main/java/com/nmc/android/utils/CheckableThemeUtils.kt b/app/src/main/java/com/nmc/android/utils/CheckableThemeUtils.kt new file mode 100644 index 000000000000..7c86042db7cb --- /dev/null +++ b/app/src/main/java/com/nmc/android/utils/CheckableThemeUtils.kt @@ -0,0 +1,86 @@ +package com.nmc.android.utils + +import android.content.res.ColorStateList +import androidx.appcompat.widget.AppCompatCheckBox +import androidx.appcompat.widget.SwitchCompat +import androidx.core.graphics.drawable.DrawableCompat +import androidx.core.widget.CompoundButtonCompat +import com.owncloud.android.MainApp +import com.owncloud.android.R + +object CheckableThemeUtils { + @JvmStatic + fun tintCheckbox(vararg checkBoxes: AppCompatCheckBox) { + for (checkBox in checkBoxes) { + val checkEnabled = MainApp.getAppContext().resources.getColor(R.color.checkbox_checked_enabled) + val checkDisabled = MainApp.getAppContext().resources.getColor(R.color.checkbox_checked_disabled) + val uncheckEnabled = MainApp.getAppContext().resources.getColor(R.color.checkbox_unchecked_enabled) + val uncheckDisabled = MainApp.getAppContext().resources.getColor(R.color.checkbox_unchecked_disabled) + + val states = arrayOf( + intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_enabled, android.R.attr.state_checked), + intArrayOf(android.R.attr.state_enabled, -android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_enabled, -android.R.attr.state_checked) + ) + val colors = intArrayOf( + checkEnabled, + checkDisabled, + uncheckEnabled, + uncheckDisabled + ) + val checkColorStateList = ColorStateList(states, colors) + CompoundButtonCompat.setButtonTintList(checkBox, checkColorStateList) + } + } + + @JvmStatic + @JvmOverloads + fun tintSwitch(switchView: SwitchCompat, color: Int = 0, colorText: Boolean = false) { + if (colorText) { + switchView.setTextColor(color) + } + val thumbColorCheckedEnabled = MainApp.getAppContext().resources.getColor(R.color.switch_thumb_checked_enabled) + val thumbColorUncheckedEnabled = + MainApp.getAppContext().resources.getColor(R.color.switch_thumb_unchecked_enabled) + val thumbColorCheckedDisabled = + MainApp.getAppContext().resources.getColor(R.color.switch_thumb_checked_disabled) + val thumbColorUncheckedDisabled = + MainApp.getAppContext().resources.getColor(R.color.switch_thumb_unchecked_disabled) + + val states = arrayOf( + intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_enabled, android.R.attr.state_checked), + intArrayOf(android.R.attr.state_enabled, -android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_enabled, -android.R.attr.state_checked) + ) + val thumbColors = intArrayOf( + thumbColorCheckedEnabled, + thumbColorCheckedDisabled, + thumbColorUncheckedEnabled, + thumbColorUncheckedDisabled + ) + val thumbColorStateList = ColorStateList(states, thumbColors) + val trackColorCheckedEnabled = MainApp.getAppContext().resources.getColor(R.color.switch_track_checked_enabled) + val trackColorUncheckedEnabled = + MainApp.getAppContext().resources.getColor(R.color.switch_track_unchecked_enabled) + val trackColorCheckedDisabled = + MainApp.getAppContext().resources.getColor(R.color.switch_track_checked_disabled) + val trackColorUncheckedDisabled = + MainApp.getAppContext().resources.getColor(R.color.switch_track_unchecked_disabled) + + val trackColors = intArrayOf( + trackColorCheckedEnabled, + trackColorCheckedDisabled, + trackColorUncheckedEnabled, + trackColorUncheckedDisabled + ) + val trackColorStateList = ColorStateList(states, trackColors) + + // setting the thumb color + DrawableCompat.setTintList(switchView.thumbDrawable, thumbColorStateList) + + // setting the track color + DrawableCompat.setTintList(switchView.trackDrawable, trackColorStateList) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nmc/android/utils/SearchViewThemeUtils.kt b/app/src/main/java/com/nmc/android/utils/SearchViewThemeUtils.kt new file mode 100644 index 000000000000..769a460e8fb9 --- /dev/null +++ b/app/src/main/java/com/nmc/android/utils/SearchViewThemeUtils.kt @@ -0,0 +1,22 @@ +package com.nmc.android.utils + +import android.content.Context +import android.widget.ImageView +import androidx.appcompat.widget.SearchView +import com.owncloud.android.R + +object SearchViewThemeUtils { + fun themeSearchView(context: Context, searchView: SearchView) { + val fontColor = context.resources.getColor(R.color.fontAppbar, null) + val editText: SearchView.SearchAutoComplete = searchView.findViewById(R.id.search_src_text) + editText.textSize = 16F + editText.setTextColor(fontColor) + editText.highlightColor = context.resources.getColor(R.color.search_et_highlight_color, null) + editText.setHintTextColor(context.resources.getColor(R.color.fontSecondaryAppbar, null)) + val closeButton: ImageView = searchView.findViewById(R.id.search_close_btn) + closeButton.setColorFilter(fontColor) + val searchButton: ImageView = searchView.findViewById(R.id.search_button) + searchButton.setImageResource(R.drawable.ic_search) + searchButton.setColorFilter(fontColor) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/LinkShareViewHolder.java b/app/src/main/java/com/owncloud/android/ui/adapter/LinkShareViewHolder.java index fc952f8b3e62..405a69fe8383 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/LinkShareViewHolder.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/LinkShareViewHolder.java @@ -82,7 +82,6 @@ public void bind(OCShare publicShare, ShareeListAdapterListener listener) { } } - viewThemeUtils.platform.colorImageViewBackgroundAndIcon(binding.icon); } String permissionName = SharingMenuHelper.getPermissionName(context, publicShare); diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java index ced6882511c3..caaf8413a931 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java @@ -43,6 +43,7 @@ import com.nextcloud.client.di.Injectable; import com.nextcloud.client.network.ClientFactory; import com.nextcloud.utils.EditorUtils; +import com.nmc.android.utils.SearchViewThemeUtils; import com.owncloud.android.R; import com.owncloud.android.databinding.FileDetailsSharingFragmentBinding; import com.owncloud.android.datamodel.FileDataStorageManager; @@ -222,8 +223,7 @@ private void setUpSearchView() { binding.searchView, fileActivity.getComponentName()); - // TODO: 04/27/23 Customize it later with theming changes - //ThemeToolbarUtils.themeSearchView(binding.searchView, requireContext()); + SearchViewThemeUtils.INSTANCE.themeSearchView(requireContext(), binding.searchView); binding.searchView.setQueryHint(getResources().getString(R.string.share_search)); binding.searchView.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingMenuBottomSheetDialog.java b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingMenuBottomSheetDialog.java index 5404c342b650..b1e6acc0805d 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingMenuBottomSheetDialog.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingMenuBottomSheetDialog.java @@ -62,14 +62,6 @@ protected void onCreate(Bundle savedInstanceState) { getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } - viewThemeUtils.platform.themeDialog(binding.getRoot()); - - viewThemeUtils.platform.colorImageView(binding.menuIconAddAnotherLink); - viewThemeUtils.platform.colorImageView(binding.menuIconAdvancedPermissions); - viewThemeUtils.platform.colorImageView(binding.menuIconSendLink); - viewThemeUtils.platform.colorImageView(binding.menuIconUnshare); - viewThemeUtils.platform.colorImageView(binding.menuIconSendNewEmail); - updateUI(); setupClickListener(); diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt index f42a763b993f..623299923239 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailsSharingProcessFragment.kt @@ -32,6 +32,7 @@ import android.view.ViewGroup import android.widget.RadioGroup import androidx.fragment.app.Fragment import com.nextcloud.client.di.Injectable +import com.nmc.android.utils.CheckableThemeUtils import com.owncloud.android.R import com.owncloud.android.databinding.FileDetailsSharingProcessFragmentBinding import com.owncloud.android.datamodel.OCFile @@ -218,7 +219,6 @@ class FileDetailsSharingProcessFragment : showShareProcessSecond() } - // ThemeCheckableUtils.tintSwitch(binding.shareProcessHideDownloadCheckbox, 0) binding.shareProcessPermissionRadioGroup.setOnCheckedChangeListener(this) implementClickEvents() binding.shareProcessHideDownloadCheckbox.setOnCheckedChangeListener { _, isChecked -> @@ -240,19 +240,11 @@ class FileDetailsSharingProcessFragment : } private fun themeView() { - viewThemeUtils.platform.colorPrimaryTextViewElement(binding.shareProcessAdvancePermissionTitle) - - viewThemeUtils.platform.themeRadioButton(binding.shareProcessPermissionReadOnly) - viewThemeUtils.platform.themeRadioButton(binding.shareProcessPermissionUploadEditing) - viewThemeUtils.platform.themeRadioButton(binding.shareProcessPermissionFileDrop) - - viewThemeUtils.androidx.colorSwitchCompat(binding.shareProcessSetPasswordSwitch) - viewThemeUtils.androidx.colorSwitchCompat(binding.shareProcessSetExpDateSwitch) - viewThemeUtils.androidx.colorSwitchCompat(binding.shareProcessHideDownloadCheckbox) - viewThemeUtils.androidx.colorSwitchCompat(binding.shareProcessChangeNameSwitch) - - viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.shareProcessBtnNext) - viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.shareProcessBtnCancel) + CheckableThemeUtils.tintSwitch(binding.shareProcessSetPasswordSwitch) + CheckableThemeUtils.tintSwitch(binding.shareProcessSetExpDateSwitch) + CheckableThemeUtils.tintSwitch(binding.shareProcessHideDownloadCheckbox) + CheckableThemeUtils.tintSwitch(binding.shareProcessChangeNameSwitch) + CheckableThemeUtils.tintSwitch(binding.shareProcessDownloadLimitSwitch) } override fun onConfigurationChanged(newConfig: Configuration) { diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/QuickSharingPermissionsBottomSheetDialog.java b/app/src/main/java/com/owncloud/android/ui/fragment/QuickSharingPermissionsBottomSheetDialog.java index 84058d6817fb..e8495eb08775 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/QuickSharingPermissionsBottomSheetDialog.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/QuickSharingPermissionsBottomSheetDialog.java @@ -76,8 +76,6 @@ protected void onCreate(Bundle savedInstanceState) { getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } - viewThemeUtils.platform.themeDialog(binding.getRoot()); - setUpRecyclerView(); setOnShowListener(d -> BottomSheetBehavior.from((View) binding.getRoot().getParent()) diff --git a/app/src/main/res/layout/file_details_sharing_menu_bottom_sheet_fragment.xml b/app/src/main/res/layout/file_details_sharing_menu_bottom_sheet_fragment.xml index 8553fee36128..5983cccd50ef 100644 --- a/app/src/main/res/layout/file_details_sharing_menu_bottom_sheet_fragment.xml +++ b/app/src/main/res/layout/file_details_sharing_menu_bottom_sheet_fragment.xml @@ -24,6 +24,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="@color/bottom_sheet_bg_color" android:orientation="vertical" android:paddingTop="@dimen/standard_padding"> @@ -63,7 +64,8 @@ diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 5b9d8d37c44a..841176f74c2a 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -25,6 +25,9 @@ #ff6F6F6F #A5A5A5 #222222 + @color/grey_30 + + #FFFFFF @color/grey_30 @color/grey_0 @@ -34,7 +37,6 @@ @color/grey_60 @color/grey_0 #FFFFFF - @color/grey_30 #ffffff @@ -43,10 +45,22 @@ #818181 #222222 #ffffff + + @color/grey_80 @color/grey_30 @color/grey_0 + + @color/grey_70 + @color/grey_60 + @color/grey_70 + @color/grey_60 + + + @color/grey_70 + @color/grey_70 + @color/appbar #373535 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c44b14f6e899..91174d9064e9 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -32,8 +32,11 @@ #EEEEEE #00000000 #666666 + #77c4ff #191919 #e53935 + + #191919 @color/grey_30 #191919 @@ -46,17 +49,21 @@ #191919 #F6E5EB #C16F81 + #0D39DF #757575 #222222 - #EEEEEE - #BDBDBD - #666666 + #101010 #F2F2F2 + #E5E5E5 #B2B2B2 #666666 + #4C4C4C #333333 + #EEEEEE + #BDBDBD + #666666 @@ -75,6 +82,10 @@ #000000 #ededed #000000 + + + #FFFFFF + #191919 #191919 #ffffff @@ -95,11 +106,26 @@ #616161 #80000000 + + @color/primary + #F399C7 + @color/grey_0 + @color/grey_0 + #FFFFFF + @color/grey_30 + @color/grey_0 + @color/grey_0 + + + @color/primary + @color/grey_30 + @color/grey_30 + #CCCCCC + @android:color/white #666666 #B3FFFFFF #A5A5A5 - #0D39DF #0099ff diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ab29558e81e3..b4f549f967bb 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -199,6 +199,7 @@ bold +