Skip to content

Commit

Permalink
Sharing theming updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed May 16, 2023
1 parent 28e324d commit 688d6b0
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 40 deletions.
86 changes: 86 additions & 0 deletions app/src/main/java/com/nmc/android/utils/CheckableThemeUtils.kt
Original file line number Diff line number Diff line change
@@ -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)
}
}
22 changes: 22 additions & 0 deletions app/src/main/java/com/nmc/android/utils/SearchViewThemeUtils.kt
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public void bind(OCShare publicShare, ShareeListAdapterListener listener) {
}
}

viewThemeUtils.platform.colorImageViewBackgroundAndIcon(binding.icon);
}

String permissionName = SharingMenuHelper.getPermissionName(context, publicShare);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -218,7 +219,6 @@ class FileDetailsSharingProcessFragment :
showShareProcessSecond()
}

// ThemeCheckableUtils.tintSwitch(binding.shareProcessHideDownloadCheckbox, 0)
binding.shareProcessPermissionRadioGroup.setOnCheckedChangeListener(this)
implementClickEvents()
binding.shareProcessHideDownloadCheckbox.setOnCheckedChangeListener { _, isChecked ->
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">

Expand Down Expand Up @@ -63,7 +64,8 @@
<LinearLayout
android:id="@+id/menu_share_advanced_permissions"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_item_height"
android:layout_height="wrap_content"
android:minHeight="@dimen/minimum_size_for_touchable_area"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal"
android:paddingLeft="@dimen/standard_padding"
Expand Down Expand Up @@ -95,7 +97,8 @@
<LinearLayout
android:id="@+id/menu_share_send_new_email"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_item_height"
android:layout_height="wrap_content"
android:minHeight="@dimen/minimum_size_for_touchable_area"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal"
android:paddingLeft="@dimen/standard_padding"
Expand Down Expand Up @@ -127,7 +130,8 @@
<LinearLayout
android:id="@+id/menu_share_send_link"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_item_height"
android:layout_height="wrap_content"
android:minHeight="@dimen/minimum_size_for_touchable_area"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal"
android:paddingLeft="@dimen/standard_padding"
Expand Down Expand Up @@ -161,7 +165,8 @@
<LinearLayout
android:id="@+id/menu_share_unshare"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_item_height"
android:layout_height="wrap_content"
android:minHeight="@dimen/minimum_size_for_touchable_area"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal"
android:paddingLeft="@dimen/standard_padding"
Expand Down Expand Up @@ -193,7 +198,8 @@
<LinearLayout
android:id="@+id/menu_share_add_another_link"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_item_height"
android:layout_height="wrap_content"
android:minHeight="@dimen/minimum_size_for_touchable_area"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal"
android:paddingLeft="@dimen/standard_padding"
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/item_quick_share_permissions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_item_height"
android:background="?android:attr/selectableItemBackground"
android:layout_height="wrap_content"
android:padding="@dimen/standard_padding">

<ImageView
Expand All @@ -43,7 +42,7 @@
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/standard_margin"
android:text="@string/link_share_read_only"
android:textColor="@color/text_color"
android:textColor="@color/bottom_sheet_txt_color"
android:textSize="@dimen/bottom_sheet_text_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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:paddingTop="@dimen/standard_padding"
android:paddingBottom="@dimen/standard_padding"
android:orientation="vertical">
Expand Down
16 changes: 15 additions & 1 deletion app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<color name="disabled_text">#ff6F6F6F</color>
<color name="secondary_text_color">#A5A5A5</color>
<color name="list_divider_background">#222222</color>
<color name="list_icon_color">@color/grey_30</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>
Expand All @@ -34,7 +37,6 @@
<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>
<color name="list_icon_color">@color/grey_30</color>

<!-- Colors -->
<color name="dark">#ffffff</color>
Expand All @@ -43,10 +45,22 @@
<color name="grey_200">#818181</color>
<color name="nc_grey">#222222</color>
<color name="icon_on_nc_grey">#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>

<!-- Switch Compat Colors -->
<color name="switch_thumb_checked_disabled">@color/grey_70</color>
<color name="switch_track_checked_disabled">@color/grey_60</color>
<color name="switch_thumb_unchecked_disabled">@color/grey_70</color>
<color name="switch_track_unchecked_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>

<!-- Multiselect backgrounds -->
<color name="action_mode_background">@color/appbar</color>
<color name="selected_item_background">#373535</color>
Expand Down
Loading

0 comments on commit 688d6b0

Please sign in to comment.