-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
167 additions
and
78 deletions.
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 @@ | ||
New settings "Appearance" |
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
94 changes: 94 additions & 0 deletions
94
vector/src/main/java/im/vector/app/features/settings/VectorSettingsAppearanceFragment.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,94 @@ | ||
/* | ||
* Copyright 2019 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("UNUSED_VARIABLE", "UNUSED_ANONYMOUS_PARAMETER", "UNUSED_PARAMETER") | ||
|
||
package im.vector.app.features.settings | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.preference.Preference | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import im.vector.app.R | ||
import im.vector.app.core.extensions.restart | ||
import im.vector.app.core.preference.VectorListPreference | ||
import im.vector.app.core.preference.VectorPreference | ||
import im.vector.app.features.VectorFeatures | ||
import im.vector.app.features.analytics.plan.MobileScreen | ||
import im.vector.app.features.settings.font.FontScaleSettingActivity | ||
import im.vector.app.features.themes.ThemeUtils | ||
import javax.inject.Inject | ||
|
||
@AndroidEntryPoint | ||
class VectorSettingsAppearanceFragment : | ||
VectorSettingsBaseFragment() { | ||
|
||
@Inject lateinit var vectorPreferences: VectorPreferences | ||
@Inject lateinit var vectorFeatures: VectorFeatures | ||
@Inject lateinit var fontScalePreferences: FontScalePreferences | ||
|
||
override var titleRes = R.string.settings_appearance_title | ||
override val preferenceXmlRes = R.xml.vector_settings_appearance | ||
|
||
private val textSizePreference by lazy { | ||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_INTERFACE_TEXT_SIZE_KEY)!! | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
analyticsScreenName = MobileScreen.ScreenName.SettingsAppearance | ||
} | ||
|
||
override fun bindPref() { | ||
// user interface preferences | ||
setUserInterfacePreferences() | ||
|
||
// Themes | ||
findPreference<VectorListPreference>(ThemeUtils.APPLICATION_THEME_KEY)!! | ||
.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> | ||
if (newValue is String) { | ||
ThemeUtils.setApplicationTheme(requireContext().applicationContext, newValue) | ||
// Restart the Activity | ||
activity?.restart() | ||
true | ||
} else { | ||
false | ||
} | ||
} | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
} | ||
|
||
override fun onPause() { | ||
super.onPause() | ||
} | ||
|
||
// ============================================================================================================== | ||
// user interface management | ||
// ============================================================================================================== | ||
|
||
private fun setUserInterfacePreferences() { | ||
// Text size | ||
textSizePreference.summary = getString(fontScalePreferences.getResolvedFontScaleValue().nameResId) | ||
|
||
textSizePreference.onPreferenceClickListener = Preference.OnPreferenceClickListener { | ||
startActivity(Intent(activity, FontScaleSettingActivity::class.java)) | ||
true | ||
} | ||
} | ||
} |
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,4 @@ | ||
<vector android:height="25dp" android:viewportHeight="18" | ||
android:viewportWidth="18" android:width="25dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#000000" android:fillType="evenOdd" android:pathData="M16.296,6.95C17.281,8.163 17.302,9.849 16.33,11.071C14.95,12.806 12.514,15 9.024,15C5.533,15 3.098,12.806 1.718,11.071C0.745,9.849 0.766,8.163 1.751,6.95C3.163,5.212 5.628,3 9.024,3C12.42,3 14.884,5.212 16.296,6.95ZM13,9C13,11.209 11.209,13 9,13C6.791,13 5,11.209 5,9C5,6.791 6.791,5 9,5C11.209,5 13,6.791 13,9ZM9,11C10.105,11 11,10.105 11,9C11,7.895 10.105,7 9,7C7.895,7 7,7.895 7,9C7,10.105 7.895,11 9,11Z"/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.preference.PreferenceScreen 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"> | ||
|
||
<im.vector.app.core.preference.VectorPreferenceCategory | ||
android:key="SETTINGS_USER_INTERFACE_KEY" | ||
android:title="@string/settings_user_interface"> | ||
|
||
<im.vector.app.core.preference.VectorListPreference | ||
android:defaultValue="system" | ||
android:entries="@array/theme_entries" | ||
android:entryValues="@array/theme_values" | ||
android:key="APPLICATION_THEME_KEY" | ||
android:summary="%s" | ||
android:title="@string/settings_theme" | ||
app:iconSpaceReserved="false" /> | ||
|
||
<im.vector.app.core.preference.VectorPreference | ||
android:dialogTitle="@string/font_size" | ||
android:key="SETTINGS_INTERFACE_TEXT_SIZE_KEY" | ||
android:persistent="false" | ||
android:title="@string/font_size" /> | ||
|
||
</im.vector.app.core.preference.VectorPreferenceCategory> | ||
|
||
<im.vector.app.core.preference.VectorPreferenceCategory android:title="@string/settings_category_timeline"> | ||
|
||
<im.vector.app.core.preference.VectorSwitchPreference | ||
android:defaultValue="@bool/settings_interface_bubble_default" | ||
android:key="SETTINGS_INTERFACE_BUBBLE_KEY" | ||
android:title="@string/message_bubbles" | ||
app:isPreferenceVisible="@bool/settings_interface_bubble_visible" /> | ||
|
||
</im.vector.app.core.preference.VectorPreferenceCategory> | ||
|
||
</androidx.preference.PreferenceScreen> |
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