-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
font scale setting screen #6453
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e0340a9
font scale setting screen
57d77d5
small tweaks and fixes
981b751
suppressed "SpUsage" warning for item_font_scale
3531d7c
detekt warnings resolved
7a22245
moved another qualifier to Qualifiers.kt
a2f26f0
code review fixes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 @@ | ||
Adds settings screen to change app font scale or enable using system setting |
6 changes: 6 additions & 0 deletions
6
library/ui-styles/src/main/res/color/radio_button_tint_selector.xml
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="@color/color_primary_alpha25" android:state_checked="true" android:state_enabled="false" /> | ||
<item android:color="?colorPrimary" android:state_checked="true" android:state_enabled="true" /> | ||
<item android:color="?vctr_content_quaternary"/> | ||
</selector> |
5 changes: 5 additions & 0 deletions
5
library/ui-styles/src/main/res/color/vector_content_primary_tint_selector.xml
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="?vctr_content_quaternary" android:state_enabled="false" /> | ||
<item android:color="?vctr_content_primary"/> | ||
</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
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,23 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
@file:Suppress("MatchingDeclarationName") //remove suppression when more qualifiers will be added | ||
package im.vector.app.core.di | ||
|
||
import javax.inject.Qualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class DefaultPreferences |
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
64 changes: 64 additions & 0 deletions
64
vector/src/main/java/im/vector/app/core/epoxy/FontScaleItem.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,64 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.core.epoxy | ||
|
||
import android.util.TypedValue | ||
import android.widget.CompoundButton | ||
import android.widget.RadioButton | ||
import android.widget.TextView | ||
import com.airbnb.epoxy.EpoxyAttribute | ||
import com.airbnb.epoxy.EpoxyModelClass | ||
import im.vector.app.R | ||
import im.vector.app.features.settings.FontScaleValue | ||
|
||
@EpoxyModelClass | ||
abstract class FontScaleItem : VectorEpoxyModel<FontScaleItem.Holder>(R.layout.item_font_scale) { | ||
|
||
companion object { | ||
const val MINIMAL_TEXT_SIZE_DP = 10f | ||
} | ||
|
||
@EpoxyAttribute var fontScale: FontScaleValue? = null | ||
@EpoxyAttribute var selected: Boolean = true | ||
@EpoxyAttribute var enabled: Boolean = true | ||
|
||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) | ||
var checkChangeListener: CompoundButton.OnCheckedChangeListener? = null | ||
|
||
override fun bind(holder: Holder) { | ||
super.bind(holder) | ||
val context = holder.view.context | ||
holder.textView.text = fontScale?.let { | ||
context.resources.getString(it.nameResId) | ||
} | ||
val index = fontScale?.index ?: 0 | ||
holder.textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, MINIMAL_TEXT_SIZE_DP + index * 2) | ||
holder.textView.isEnabled = enabled | ||
holder.button.isChecked = selected | ||
holder.button.isEnabled = enabled | ||
holder.button.isClickable = enabled | ||
holder.view.onClick { | ||
holder.button.performClick() | ||
} | ||
holder.button.setOnCheckedChangeListener(checkChangeListener) | ||
} | ||
|
||
class Holder : VectorEpoxyHolder() { | ||
val button by bind<RadioButton>(R.id.font_scale_radio_button) | ||
val textView by bind<TextView>(R.id.font_scale_text) | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
vector/src/main/java/im/vector/app/core/epoxy/FontScaleSectionItem.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,37 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.core.epoxy | ||
|
||
import android.widget.TextView | ||
import com.airbnb.epoxy.EpoxyAttribute | ||
import com.airbnb.epoxy.EpoxyModelClass | ||
import im.vector.app.R | ||
|
||
@EpoxyModelClass | ||
abstract class FontScaleSectionItem : VectorEpoxyModel<FontScaleSectionItem.Holder>(R.layout.item_font_scale_section) { | ||
|
||
@EpoxyAttribute var sectionName: String = "" | ||
|
||
override fun bind(holder: Holder) { | ||
super.bind(holder) | ||
holder.textView.text = sectionName | ||
} | ||
|
||
class Holder : VectorEpoxyHolder() { | ||
val textView by bind<TextView>(R.id.font_scale_section_name) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
vector/src/main/java/im/vector/app/core/epoxy/FontScaleUseSystemSettingsItem.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,45 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.core.epoxy | ||
|
||
import android.widget.CheckBox | ||
import android.widget.CompoundButton | ||
import com.airbnb.epoxy.EpoxyAttribute | ||
import com.airbnb.epoxy.EpoxyModelClass | ||
import im.vector.app.R | ||
|
||
@EpoxyModelClass | ||
abstract class FontScaleUseSystemSettingsItem : VectorEpoxyModel<FontScaleUseSystemSettingsItem.Holder>(R.layout.item_font_scale_system) { | ||
|
||
@EpoxyAttribute var useSystemSettings: Boolean = true | ||
|
||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) | ||
var checkChangeListener: CompoundButton.OnCheckedChangeListener? = null | ||
|
||
override fun bind(holder: Holder) { | ||
super.bind(holder) | ||
holder.checkBox.isChecked = useSystemSettings | ||
holder.checkBox.setOnCheckedChangeListener(checkChangeListener) | ||
holder.view.onClick { | ||
holder.checkBox.performClick() | ||
} | ||
} | ||
|
||
class Holder : VectorEpoxyHolder() { | ||
val checkBox by bind<CheckBox>(R.id.font_scale_use_system_checkbox) | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯