forked from nextcloud/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NMC-2039: Customized action buttons as per magenta cloud theme.
NMC-2043: Customized checkbox and switch UIs.
- Loading branch information
1 parent
b11ea53
commit 8bb4458
Showing
22 changed files
with
371 additions
and
49 deletions.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
app/src/main/java/com/nmc/android/utils/CheckableThemeUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.