Skip to content

Commit

Permalink
NMC-2039: Customized action buttons as per magenta cloud theme.
Browse files Browse the repository at this point in the history
NMC-2043: Customized checkbox and switch UIs.
  • Loading branch information
surinder-tsys committed Jan 15, 2025
1 parent b11ea53 commit 8bb4458
Show file tree
Hide file tree
Showing 22 changed files with 371 additions and 49 deletions.
117 changes: 117 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,117 @@
package com.nmc.android.utils

import android.content.res.ColorStateList
import androidx.appcompat.widget.AppCompatCheckBox
import androidx.appcompat.widget.SwitchCompat
import androidx.core.content.res.ResourcesCompat
import com.owncloud.android.R

object CheckableThemeUtils {
@JvmStatic
fun tintCheckbox(vararg checkBoxes: AppCompatCheckBox) {
for (checkBox in checkBoxes) {
val checkEnabled = ResourcesCompat.getColor(
checkBox.context.resources,
R.color.checkbox_checked_enabled,
checkBox.context.theme
)
val checkDisabled = ResourcesCompat.getColor(
checkBox.context.resources,
R.color.checkbox_checked_disabled,
checkBox.context.theme
)
val uncheckEnabled = ResourcesCompat.getColor(
checkBox.context.resources,
R.color.checkbox_unchecked_enabled,
checkBox.context.theme
)
val uncheckDisabled = ResourcesCompat.getColor(
checkBox.context.resources,
R.color.checkbox_unchecked_disabled,
checkBox.context.theme
)

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
)
checkBox.buttonTintList = ColorStateList(states, colors)
}
}

@JvmStatic
@JvmOverloads
fun tintSwitch(switchView: SwitchCompat, color: Int = 0, colorText: Boolean = false) {
if (colorText) {
switchView.setTextColor(color)
}

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)
)

val thumbColorCheckedEnabled = ResourcesCompat.getColor(
switchView.context.resources,
R.color.switch_thumb_checked_enabled,
switchView.context.theme
)
val thumbColorUncheckedEnabled =
ResourcesCompat.getColor(
switchView.context.resources,
R.color.switch_thumb_unchecked_enabled,
switchView.context.theme
)
val thumbColorDisabled =
ResourcesCompat.getColor(
switchView.context.resources,
R.color.switch_thumb_disabled,
switchView.context.theme
)

val thumbColors = intArrayOf(
thumbColorCheckedEnabled,
thumbColorUncheckedEnabled,
thumbColorDisabled
)
val thumbColorStateList = ColorStateList(states, thumbColors)

val trackColorCheckedEnabled = ResourcesCompat.getColor(
switchView.context.resources,
R.color.switch_track_checked_enabled,
switchView.context.theme
)
val trackColorUncheckedEnabled =
ResourcesCompat.getColor(
switchView.context.resources,
R.color.switch_track_unchecked_enabled,
switchView.context.theme
)
val trackColorDisabled =
ResourcesCompat.getColor(
switchView.context.resources,
R.color.switch_track_disabled,
switchView.context.theme
)

val trackColors = intArrayOf(
trackColorCheckedEnabled,
trackColorUncheckedEnabled,
trackColorDisabled
)

val trackColorStateList = ColorStateList(states, trackColors)

switchView.thumbTintList = thumbColorStateList
switchView.trackTintList = trackColorStateList
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -444,23 +444,18 @@ open class FolderPickerActivity :

private fun initControls() {
if (this is FilePickerActivity) {
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(filesPickerBinding.folderPickerBtnCancel)
filesPickerBinding.folderPickerBtnCancel.setOnClickListener { finish() }
} else {
viewThemeUtils.material.colorMaterialButtonText(folderPickerBinding.folderPickerBtnCancel)
folderPickerBinding.folderPickerBtnCancel.setOnClickListener { finish() }

viewThemeUtils.material.colorMaterialButtonPrimaryTonal(folderPickerBinding.folderPickerBtnChoose)
folderPickerBinding.folderPickerBtnChoose.setOnClickListener { processOperation(null) }

viewThemeUtils.material.colorMaterialButtonPrimaryFilled(folderPickerBinding.folderPickerBtnCopy)
folderPickerBinding.folderPickerBtnCopy.setOnClickListener {
processOperation(
OperationsService.ACTION_COPY_FILE
)
}

viewThemeUtils.material.colorMaterialButtonPrimaryTonal(folderPickerBinding.folderPickerBtnMove)
folderPickerBinding.folderPickerBtnMove.setOnClickListener {
processOperation(
OperationsService.ACTION_MOVE_FILE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {

setFilename(binding.userInput, selectPos);
binding.userInput.requestFocus();
viewThemeUtils.material.colorTextInputLayout(binding.userInputContainer);

setupSpinner(adapter, selectPos, binding.userInput, binding.fileType);
if (adapter.getCount() == SINGLE_SPINNER_ENTRY) {
Expand Down Expand Up @@ -777,15 +776,13 @@ private void populateDirectoryList(OCFile file) {
setupReceiveExternalFilesAdapter(files);
}

MaterialButton btnChooseFolder = binding.uploaderChooseFolder;
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(btnChooseFolder);
btnChooseFolder.setOnClickListener(this);
MaterialButton btnChooseFolder = binding.uploaderChooseFolder;
btnChooseFolder.setOnClickListener(this);

btnChooseFolder.setEnabled(mFile.canWrite());

viewThemeUtils.platform.themeStatusBar(this);

viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.uploaderCancel);
binding.uploaderCancel.setOnClickListener(this);

sortButton = binding.toolbarLayout.sortButton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ class SyncedFoldersActivity :
viewThemeUtils
)
binding.emptyList.emptyListIcon.setImageResource(R.drawable.nav_synced_folders)
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.emptyList.emptyListViewAction)
val lm = GridLayoutManager(this, gridWidth)
adapter.setLayoutManager(lm)
val spacing = resources.getDimensionPixelSize(R.dimen.media_grid_spacing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,8 @@ public void onCreate(Bundle savedInstanceState) {
mFileListFragment = (LocalFileListFragment) getSupportFragmentManager().findFragmentByTag("local_files_list");

// Set input controllers
viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.uploadFilesBtnCancel);
binding.uploadFilesBtnCancel.setOnClickListener(this);

viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.uploadFilesBtnUpload);
binding.uploadFilesBtnUpload.setOnClickListener(this);
binding.uploadFilesBtnUpload.setEnabled(mLocalFolderPickerMode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.nextcloud.client.di.Injectable
import com.nextcloud.client.preferences.SubFolderRule
import com.nextcloud.utils.extensions.getParcelableArgument
import com.nmc.android.utils.CheckableThemeUtils
import com.owncloud.android.R
import com.owncloud.android.databinding.SyncedFoldersSettingsLayoutBinding
import com.owncloud.android.datamodel.MediaFolderType
Expand Down Expand Up @@ -145,9 +146,9 @@ class SyncedFolderPreferencesDialogFragment : DialogFragment(), Injectable {
}

private fun applyUserColor(binding: SyncedFoldersSettingsLayoutBinding) {
viewThemeUtils?.androidx?.colorSwitchCompat(binding.syncEnabled)
CheckableThemeUtils.tintSwitch(binding.syncEnabled)

viewThemeUtils?.platform?.themeCheckbox(
CheckableThemeUtils.tintCheckbox(
binding.settingInstantUploadOnWifiCheckbox,
binding.settingInstantUploadOnChargingCheckbox,
binding.settingInstantUploadExistingCheckbox,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import com.owncloud.android.utils.PermissionUtil
import com.owncloud.android.utils.PermissionUtil.checkSelfPermission
import com.owncloud.android.utils.theme.ThemeUtils
import com.owncloud.android.utils.theme.ViewThemeUtils
import com.nmc.android.utils.CheckableThemeUtils
import third_parties.daveKoeller.AlphanumComparator
import java.util.Calendar
import java.util.GregorianCalendar
Expand Down Expand Up @@ -221,15 +222,15 @@ class BackupFragment : FileFragment(), OnDateSetListener, Injectable {
}

private fun applyUserColor() {
viewThemeUtils.androidx.colorSwitchCompat(binding.contacts)
viewThemeUtils.androidx.colorSwitchCompat(binding.calendar)
viewThemeUtils.androidx.colorSwitchCompat(binding.dailyBackup)

viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.backupNow)
viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.contactsDatepicker)

viewThemeUtils.platform.colorTextView(binding.dataToBackUpTitle)
viewThemeUtils.platform.colorTextView(binding.backupSettingsTitle)
//NMC Customisation
CheckableThemeUtils.tintSwitch(binding.contacts)
CheckableThemeUtils.tintSwitch(binding.calendar)
CheckableThemeUtils.tintSwitch(binding.dailyBackup)

//NMC Customization
val primaryAccentColor = requireContext().resources.getColor(R.color.primary, null)
binding.dataToBackUpTitle.setTextColor(primaryAccentColor)
binding.backupSettingsTitle.setTextColor(primaryAccentColor)
}

override fun onResume() {
Expand Down Expand Up @@ -529,10 +530,11 @@ class BackupFragment : FileFragment(), OnDateSetListener, Injectable {
show()
}

viewThemeUtils.platform.colorTextButtons(
datePickerDialog!!.getButton(DatePickerDialog.BUTTON_NEGATIVE),
datePickerDialog!!.getButton(DatePickerDialog.BUTTON_POSITIVE)
)
// NMC Customisation
datePickerDialog?.getButton(DatePickerDialog.BUTTON_NEGATIVE)
?.setTextColor(resources.getColor(R.color.text_color, null))
datePickerDialog?.getButton(DatePickerDialog.BUTTON_POSITIVE)
?.setTextColor(resources.getColor(R.color.primary, null))
} else {
DisplayUtils.showSnackMessage(
requireView().findViewById<View>(R.id.contacts_linear_layout),
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/color/primary_button_background_color.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/primary" android:state_enabled="true" />
<item android:color="@color/primary_button_disabled_color" />
</selector>
5 changes: 5 additions & 0 deletions app/src/main/res/color/primary_button_text_color_state.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/white" android:state_enabled="true" />
<item android:color="@color/primary_button_disabled_color" />
</selector>
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/borderless_btn.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

<item android:color="@color/disabled_text" android:state_enabled="false" />

<item android:color="@color/color_accent" />
<item android:color="@color/primary" />

</selector>
</selector>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/ic_cut_paste.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M8.5,21L8.5,22.5L6,22.5L6,21L8.5,21ZM3,19.5C3,20.325 3.675,21 4.5,21L4.5,21L4.5,22.5C2.845,22.5 1.5,21.155 1.5,19.5L1.5,19.5ZM17,19.5C17,21.155 15.655,22.5 14,22.5L14,22.5L14,21C14.825,21 15.5,20.325 15.5,19.5L15.5,19.5ZM12.5,21L12.5,22.5L10,22.5L10,21L12.5,21ZM3,15.5L3,18L1.5,18L1.5,15.5L3,15.5ZM17,15.5L17,18L15.5,18L15.5,15.5L17,15.5ZM22.5,1.5L22.5,14C22.5,15.655 21.155,17 19.5,17L19.5,17L18.5,17L18.5,15.5L19.5,15.5C20.325,15.5 21,14.825 21,14L21,14L21,3L8.5,3L8.5,5.5L7,5.5L7,1.5L22.5,1.5ZM3,11.5L3,14L1.5,14L1.5,11.5L3,11.5ZM17,11.5L17,14L15.5,14L15.5,11.5L17,11.5ZM17,7L17,10L15.5,10L15.5,8.5L14,8.5L14,7L17,7ZM4.5,7L4.5,8.5L3,8.5L3,10L1.5,10L1.5,7L4.5,7ZM12.5,7L12.5,8.5L10,8.5L10,7L12.5,7ZM8.5,7L8.5,8.5L6,8.5L6,7L8.5,7Z"
android:strokeWidth="1"
android:fillColor="#262626"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
</vector>
5 changes: 4 additions & 1 deletion app/src/main/res/layout/backup_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
-->
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/contacts_linear_layout"
android:layout_width="match_parent"
Expand Down Expand Up @@ -112,6 +113,7 @@
android:minHeight="@dimen/minimum_size_for_touchable_area"
android:text="@string/restore_backup"
android:visibility="invisible"
app:cornerRadius="@dimen/button_corner_radius"
tools:visibility="visible" />

<com.google.android.material.button.MaterialButton
Expand All @@ -121,7 +123,8 @@
android:layout_marginStart="@dimen/standard_half_margin"
android:minHeight="@dimen/minimum_size_for_touchable_area"
android:text="@string/contacts_backup_button"
android:theme="@style/Widget.Material3.Button.IconButton.Filled" />
style="@style/Button.Primary"
app:cornerRadius="@dimen/button_corner_radius"/>

</LinearLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/empty_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/standard_half_margin"
android:theme="@style/Button.Primary"
style="@style/Button.Primary"
android:visibility="gone"
app:cornerRadius="@dimen/button_corner_radius"
tools:visibility="visible" />
Expand Down
34 changes: 28 additions & 6 deletions app/src/main/res/layout/files_folder_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,34 @@

<com.google.android.material.button.MaterialButton
android:id="@+id/folder_picker_btn_cancel"
style="@style/Widget.Material3.Button.TextButton"
style="@style/Widget.Material3.Button.IconButton.Outlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/standard_half_margin"
android:layout_weight="1"
android:text="@string/common_cancel"
app:cornerRadius="@dimen/button_corner_radius" />
android:textColor="@color/text_color"
app:cornerRadius="@dimen/button_corner_radius"
app:icon="@drawable/ic_close"
app:iconGravity="textStart"
app:iconPadding="@dimen/standard_quarter_padding"
app:iconTint="@color/text_color"
app:strokeColor="@color/text_color" />

<com.google.android.material.button.MaterialButton
android:id="@+id/folder_picker_btn_choose"
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
style="@style/Widget.Material3.Button.IconButton.Filled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/folder_picker_choose_button_text"
android:textColor="@color/primary_button_text_color_state"
android:visibility="gone"
app:cornerRadius="@dimen/button_corner_radius"
app:icon="@drawable/ic_tick"
app:iconGravity="textStart"
app:iconPadding="@dimen/standard_quarter_padding"
app:iconTint="@color/primary_button_text_color_state"
tools:visibility="visible" />

<View
Expand All @@ -82,16 +94,26 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/folder_picker_copy_button_text"
app:cornerRadius="@dimen/button_corner_radius" />
android:textColor="@color/primary_button_text_color_state"
app:cornerRadius="@dimen/button_corner_radius"
app:icon="@drawable/ic_cut_paste"
app:iconGravity="textStart"
app:iconPadding="@dimen/standard_quarter_padding"
app:iconTint="@color/primary_button_text_color_state"/>

<com.google.android.material.button.MaterialButton
android:id="@+id/folder_picker_btn_move"
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
style="@style/Widget.Material3.Button.IconButton.Filled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/folder_picker_move_button_text"
app:cornerRadius="@dimen/button_corner_radius" />
android:textColor="@color/primary_button_text_color_state"
app:cornerRadius="@dimen/button_corner_radius"
app:icon="@drawable/ic_cut_paste"
app:iconGravity="textStart"
app:iconPadding="@dimen/standard_quarter_padding"
app:iconTint="@color/primary_button_text_color_state"/>

</LinearLayout>

Expand Down
Loading

0 comments on commit 8bb4458

Please sign in to comment.