Skip to content

Commit a8f7ef2

Browse files
committed
NMC-2039: Customized action buttons as per magenta cloud theme.
NMC-2043: Customized checkbox and switch UIs.
1 parent 9a491e9 commit a8f7ef2

23 files changed

+375
-52
lines changed

app/src/main/java/com/nextcloud/ui/ChooseStorageLocationDialogFragment.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidx.fragment.app.DialogFragment
1818
import com.google.android.material.dialog.MaterialAlertDialogBuilder
1919
import com.nextcloud.client.di.Injectable
2020
import com.nextcloud.client.preferences.AppPreferencesImpl
21+
import com.nmc.android.utils.CheckableThemeUtils
2122
import com.owncloud.android.MainApp
2223
import com.owncloud.android.R
2324
import com.owncloud.android.databinding.DialogDataStorageLocationBinding
@@ -49,9 +50,7 @@ class ChooseStorageLocationDialogFragment :
4950
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
5051
binding = DialogDataStorageLocationBinding.inflate(layoutInflater)
5152

52-
viewThemeUtils.material.colorMaterialSwitch(binding.allowMediaIndexSwitch)
53-
viewThemeUtils.platform.themeRadioButton(binding.storageInternalRadio)
54-
viewThemeUtils.platform.themeRadioButton(binding.storageExternalRadio)
53+
CheckableThemeUtils.tintSwitch(binding.allowMediaIndexSwitch)
5554

5655
val builder = MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.storage_choose_location)
5756
.setPositiveButton(R.string.common_ok) { dialog: DialogInterface, _ ->
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package com.nmc.android.utils
2+
3+
import android.content.res.ColorStateList
4+
import androidx.appcompat.widget.AppCompatCheckBox
5+
import androidx.appcompat.widget.SwitchCompat
6+
import androidx.core.content.res.ResourcesCompat
7+
import com.owncloud.android.R
8+
9+
object CheckableThemeUtils {
10+
@JvmStatic
11+
fun tintCheckbox(vararg checkBoxes: AppCompatCheckBox) {
12+
for (checkBox in checkBoxes) {
13+
val checkEnabled = ResourcesCompat.getColor(
14+
checkBox.context.resources,
15+
R.color.checkbox_checked_enabled,
16+
checkBox.context.theme
17+
)
18+
val checkDisabled = ResourcesCompat.getColor(
19+
checkBox.context.resources,
20+
R.color.checkbox_checked_disabled,
21+
checkBox.context.theme
22+
)
23+
val uncheckEnabled = ResourcesCompat.getColor(
24+
checkBox.context.resources,
25+
R.color.checkbox_unchecked_enabled,
26+
checkBox.context.theme
27+
)
28+
val uncheckDisabled = ResourcesCompat.getColor(
29+
checkBox.context.resources,
30+
R.color.checkbox_unchecked_disabled,
31+
checkBox.context.theme
32+
)
33+
34+
val states = arrayOf(
35+
intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked),
36+
intArrayOf(-android.R.attr.state_enabled, android.R.attr.state_checked),
37+
intArrayOf(android.R.attr.state_enabled, -android.R.attr.state_checked),
38+
intArrayOf(-android.R.attr.state_enabled, -android.R.attr.state_checked)
39+
)
40+
val colors = intArrayOf(
41+
checkEnabled,
42+
checkDisabled,
43+
uncheckEnabled,
44+
uncheckDisabled
45+
)
46+
checkBox.buttonTintList = ColorStateList(states, colors)
47+
}
48+
}
49+
50+
@JvmStatic
51+
@JvmOverloads
52+
fun tintSwitch(switchView: SwitchCompat, color: Int = 0, colorText: Boolean = false) {
53+
if (colorText) {
54+
switchView.setTextColor(color)
55+
}
56+
57+
val states = arrayOf(
58+
intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked),
59+
intArrayOf(android.R.attr.state_enabled, -android.R.attr.state_checked),
60+
intArrayOf(-android.R.attr.state_enabled)
61+
)
62+
63+
val thumbColorCheckedEnabled = ResourcesCompat.getColor(
64+
switchView.context.resources,
65+
R.color.switch_thumb_checked_enabled,
66+
switchView.context.theme
67+
)
68+
val thumbColorUncheckedEnabled =
69+
ResourcesCompat.getColor(
70+
switchView.context.resources,
71+
R.color.switch_thumb_unchecked_enabled,
72+
switchView.context.theme
73+
)
74+
val thumbColorDisabled =
75+
ResourcesCompat.getColor(
76+
switchView.context.resources,
77+
R.color.switch_thumb_disabled,
78+
switchView.context.theme
79+
)
80+
81+
val thumbColors = intArrayOf(
82+
thumbColorCheckedEnabled,
83+
thumbColorUncheckedEnabled,
84+
thumbColorDisabled
85+
)
86+
val thumbColorStateList = ColorStateList(states, thumbColors)
87+
88+
val trackColorCheckedEnabled = ResourcesCompat.getColor(
89+
switchView.context.resources,
90+
R.color.switch_track_checked_enabled,
91+
switchView.context.theme
92+
)
93+
val trackColorUncheckedEnabled =
94+
ResourcesCompat.getColor(
95+
switchView.context.resources,
96+
R.color.switch_track_unchecked_enabled,
97+
switchView.context.theme
98+
)
99+
val trackColorDisabled =
100+
ResourcesCompat.getColor(
101+
switchView.context.resources,
102+
R.color.switch_track_disabled,
103+
switchView.context.theme
104+
)
105+
106+
val trackColors = intArrayOf(
107+
trackColorCheckedEnabled,
108+
trackColorUncheckedEnabled,
109+
trackColorDisabled
110+
)
111+
112+
val trackColorStateList = ColorStateList(states, trackColors)
113+
114+
switchView.thumbTintList = thumbColorStateList
115+
switchView.trackTintList = trackColorStateList
116+
}
117+
}

app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,23 +441,18 @@ open class FolderPickerActivity :
441441

442442
private fun initControls() {
443443
if (this is FilePickerActivity) {
444-
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(filesPickerBinding.folderPickerBtnCancel)
445444
filesPickerBinding.folderPickerBtnCancel.setOnClickListener { finish() }
446445
} else {
447-
viewThemeUtils.material.colorMaterialButtonText(folderPickerBinding.folderPickerBtnCancel)
448446
folderPickerBinding.folderPickerBtnCancel.setOnClickListener { finish() }
449447

450-
viewThemeUtils.material.colorMaterialButtonPrimaryTonal(folderPickerBinding.folderPickerBtnChoose)
451448
folderPickerBinding.folderPickerBtnChoose.setOnClickListener { processOperation(null) }
452449

453-
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(folderPickerBinding.folderPickerBtnCopy)
454450
folderPickerBinding.folderPickerBtnCopy.setOnClickListener {
455451
processOperation(
456452
OperationsService.ACTION_COPY_FILE
457453
)
458454
}
459455

460-
viewThemeUtils.material.colorMaterialButtonPrimaryTonal(folderPickerBinding.folderPickerBtnMove)
461456
folderPickerBinding.folderPickerBtnMove.setOnClickListener {
462457
processOperation(
463458
OperationsService.ACTION_MOVE_FILE

app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
464464

465465
setFilename(binding.userInput, selectPos);
466466
binding.userInput.requestFocus();
467-
viewThemeUtils.material.colorTextInputLayout(binding.userInputContainer);
468467

469468
setupSpinner(adapter, selectPos, binding.userInput, binding.fileType);
470469
if (adapter.getCount() == SINGLE_SPINNER_ENTRY) {
@@ -786,15 +785,13 @@ private void populateDirectoryList(OCFile file) {
786785
setupReceiveExternalFilesAdapter(files);
787786
}
788787

789-
MaterialButton btnChooseFolder = binding.uploaderChooseFolder;
790-
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(btnChooseFolder);
791-
btnChooseFolder.setOnClickListener(this);
788+
MaterialButton btnChooseFolder = binding.uploaderChooseFolder;
789+
btnChooseFolder.setOnClickListener(this);
792790

793791
btnChooseFolder.setEnabled(mFile.canCreateFileAndFolder());
794792

795793
viewThemeUtils.platform.themeStatusBar(this);
796794

797-
viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.uploaderCancel);
798795
binding.uploaderCancel.setOnClickListener(this);
799796

800797
sortButton = binding.toolbarLayout.sortButton;

app/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ class SyncedFoldersActivity :
255255
connectivityService
256256
)
257257
binding.emptyList.emptyListIcon.setImageResource(R.drawable.nav_synced_folders)
258-
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.emptyList.emptyListViewAction)
259258
val lm = GridLayoutManager(this, gridWidth)
260259
adapter.setLayoutManager(lm)
261260
val spacing = resources.getDimensionPixelSize(R.dimen.media_grid_spacing)

app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,8 @@ public void onCreate(Bundle savedInstanceState) {
192192
mFileListFragment = (LocalFileListFragment) getSupportFragmentManager().findFragmentByTag("local_files_list");
193193

194194
// Set input controllers
195-
viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.uploadFilesBtnCancel);
196195
binding.uploadFilesBtnCancel.setOnClickListener(this);
197196

198-
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.uploadFilesBtnUpload);
199197
binding.uploadFilesBtnUpload.setOnClickListener(this);
200198
binding.uploadFilesBtnUpload.setEnabled(mLocalFolderPickerMode);
201199

app/src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
2323
import com.nextcloud.client.di.Injectable
2424
import com.nextcloud.client.preferences.SubFolderRule
2525
import com.nextcloud.utils.extensions.getParcelableArgument
26+
import com.nmc.android.utils.CheckableThemeUtils
2627
import com.owncloud.android.R
2728
import com.owncloud.android.databinding.SyncedFoldersSettingsLayoutBinding
2829
import com.owncloud.android.datamodel.MediaFolderType
@@ -147,9 +148,9 @@ class SyncedFolderPreferencesDialogFragment :
147148
}
148149

149150
private fun applyUserColor(binding: SyncedFoldersSettingsLayoutBinding) {
150-
viewThemeUtils?.androidx?.colorSwitchCompat(binding.syncEnabled)
151+
CheckableThemeUtils.tintSwitch(binding.syncEnabled)
151152

152-
viewThemeUtils?.platform?.themeCheckbox(
153+
CheckableThemeUtils.tintCheckbox(
153154
binding.settingInstantUploadOnWifiCheckbox,
154155
binding.settingInstantUploadOnChargingCheckbox,
155156
binding.settingInstantUploadExistingCheckbox,

app/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/BackupFragment.kt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import com.owncloud.android.utils.theme.ViewThemeUtils
4646
import kotlinx.coroutines.Dispatchers
4747
import kotlinx.coroutines.launch
4848
import kotlinx.coroutines.withContext
49+
import com.nmc.android.utils.CheckableThemeUtils
4950
import third_parties.daveKoeller.AlphanumComparator
5051
import java.util.Calendar
5152
import java.util.GregorianCalendar
@@ -234,15 +235,15 @@ class BackupFragment :
234235
}
235236

236237
private fun applyUserColor() {
237-
viewThemeUtils.androidx.colorSwitchCompat(binding.contacts)
238-
viewThemeUtils.androidx.colorSwitchCompat(binding.calendar)
239-
viewThemeUtils.androidx.colorSwitchCompat(binding.dailyBackup)
240-
241-
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.backupNow)
242-
viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.contactsDatepicker)
243-
244-
viewThemeUtils.platform.colorTextView(binding.dataToBackUpTitle)
245-
viewThemeUtils.platform.colorTextView(binding.backupSettingsTitle)
238+
//NMC Customisation
239+
CheckableThemeUtils.tintSwitch(binding.contacts)
240+
CheckableThemeUtils.tintSwitch(binding.calendar)
241+
CheckableThemeUtils.tintSwitch(binding.dailyBackup)
242+
243+
//NMC Customization
244+
val primaryAccentColor = requireContext().resources.getColor(R.color.primary, null)
245+
binding.dataToBackUpTitle.setTextColor(primaryAccentColor)
246+
binding.backupSettingsTitle.setTextColor(primaryAccentColor)
246247
}
247248

248249
override fun onResume() {
@@ -548,10 +549,11 @@ class BackupFragment :
548549
show()
549550
}
550551

551-
viewThemeUtils.platform.colorTextButtons(
552-
datePickerDialog!!.getButton(DatePickerDialog.BUTTON_NEGATIVE),
553-
datePickerDialog!!.getButton(DatePickerDialog.BUTTON_POSITIVE)
554-
)
552+
// NMC Customisation
553+
datePickerDialog?.getButton(DatePickerDialog.BUTTON_NEGATIVE)
554+
?.setTextColor(resources.getColor(R.color.text_color, null))
555+
datePickerDialog?.getButton(DatePickerDialog.BUTTON_POSITIVE)
556+
?.setTextColor(resources.getColor(R.color.primary, null))
555557
} else {
556558
DisplayUtils.showSnackMessage(
557559
requireView().findViewById<View>(R.id.contacts_linear_layout),
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:color="@color/primary" android:state_enabled="true" />
4+
<item android:color="@color/primary_button_disabled_color" />
5+
</selector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:color="@color/white" android:state_enabled="true" />
4+
<item android:color="@color/primary_button_disabled_color" />
5+
</selector>

0 commit comments

Comments
 (0)