made font size selectable
This commit is contained in:
parent
1500299607
commit
8b70d945cc
|
@ -5,6 +5,7 @@ import android.preference.PreferenceManager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.utils.ThemeHelper;
|
||||||
|
|
||||||
import static eu.siacs.conversations.ui.XmppActivity.configureActionBar;
|
import static eu.siacs.conversations.ui.XmppActivity.configureActionBar;
|
||||||
|
|
||||||
|
@ -14,10 +15,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
Boolean dark = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
|
setTheme(ThemeHelper.find(this));
|
||||||
.getString("theme", "light").equals("dark");
|
|
||||||
int mTheme = dark ? R.style.ConversationsTheme_Dark : R.style.ConversationsTheme;
|
|
||||||
setTheme(mTheme);
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_about);
|
setContentView(R.layout.activity_about);
|
||||||
setSupportActionBar(findViewById(R.id.toolbar));
|
setSupportActionBar(findViewById(R.id.toolbar));
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.util.logging.Logger;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.MTMDecision;
|
import eu.siacs.conversations.entities.MTMDecision;
|
||||||
import eu.siacs.conversations.services.MemorizingTrustManager;
|
import eu.siacs.conversations.services.MemorizingTrustManager;
|
||||||
|
import eu.siacs.conversations.utils.ThemeHelper;
|
||||||
|
|
||||||
public class MemorizingActivity extends AppCompatActivity implements OnClickListener, OnCancelListener {
|
public class MemorizingActivity extends AppCompatActivity implements OnClickListener, OnCancelListener {
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ public class MemorizingActivity extends AppCompatActivity implements OnClickList
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
LOGGER.log(Level.FINE, "onCreate");
|
LOGGER.log(Level.FINE, "onCreate");
|
||||||
setTheme(findTheme());
|
setTheme(ThemeHelper.find(this));
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content));
|
getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content));
|
||||||
setSupportActionBar(findViewById(R.id.toolbar));
|
setSupportActionBar(findViewById(R.id.toolbar));
|
||||||
|
@ -89,15 +90,6 @@ public class MemorizingActivity extends AppCompatActivity implements OnClickList
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int findTheme() {
|
|
||||||
return getPreferences().getString(SettingsActivity.THEME, getResources().getString(R.string.theme)).equals("dark") ? R.style.ConversationsTheme_Dark : R.style.ConversationsTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SharedPreferences getPreferences() {
|
|
||||||
return PreferenceManager
|
|
||||||
.getDefaultSharedPreferences(getApplicationContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
// react on AlertDialog button press
|
// react on AlertDialog button press
|
||||||
public void onClick(DialogInterface dialog, int btnId) {
|
public void onClick(DialogInterface dialog, int btnId) {
|
||||||
int decision;
|
int decision;
|
||||||
|
|
|
@ -71,6 +71,7 @@ import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinde
|
||||||
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
|
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
|
||||||
import eu.siacs.conversations.ui.util.PresenceSelector;
|
import eu.siacs.conversations.ui.util.PresenceSelector;
|
||||||
import eu.siacs.conversations.utils.ExceptionHelper;
|
import eu.siacs.conversations.utils.ExceptionHelper;
|
||||||
|
import eu.siacs.conversations.utils.ThemeHelper;
|
||||||
import eu.siacs.conversations.xmpp.OnKeyStatusUpdated;
|
import eu.siacs.conversations.xmpp.OnKeyStatusUpdated;
|
||||||
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
@ -845,13 +846,7 @@ public abstract class XmppActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int findTheme() {
|
protected int findTheme() {
|
||||||
Boolean dark = getPreferences().getString(SettingsActivity.THEME, getResources().getString(R.string.theme)).equals("dark");
|
return ThemeHelper.find(this);
|
||||||
|
|
||||||
if (dark) {
|
|
||||||
return R.style.ConversationsTheme_Dark;
|
|
||||||
} else {
|
|
||||||
return R.style.ConversationsTheme;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Daniel Gultsch All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package eu.siacs.conversations.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.R;
|
||||||
|
import eu.siacs.conversations.ui.SettingsActivity;
|
||||||
|
|
||||||
|
public class ThemeHelper {
|
||||||
|
|
||||||
|
public static int find(Context context) {
|
||||||
|
final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
final Resources resources = context.getResources();
|
||||||
|
final boolean dark = sharedPreferences.getString(SettingsActivity.THEME, resources.getString(R.string.theme)).equals("dark");
|
||||||
|
final String fontSize = sharedPreferences.getString("font_size", resources.getString(R.string.default_font_size));
|
||||||
|
switch (fontSize) {
|
||||||
|
case "medium":
|
||||||
|
return dark ? R.style.ConversationsTheme_Dark_Medium : R.style.ConversationsTheme_Medium;
|
||||||
|
case "large":
|
||||||
|
return dark ? R.style.ConversationsTheme_Dark_Large : R.style.ConversationsTheme_Large;
|
||||||
|
default:
|
||||||
|
return dark ? R.style.ConversationsTheme_Dark : R.style.ConversationsTheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -100,6 +100,14 @@
|
||||||
<item>@string/default_on</item>
|
<item>@string/default_on</item>
|
||||||
<item>@string/default_off</item>
|
<item>@string/default_off</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string name="default_on">On by default</string>
|
<string-array name="font_size_entry_values">
|
||||||
<string name="default_off">Off by default</string>
|
<item>small</item>
|
||||||
|
<item>medium</item>
|
||||||
|
<item>large</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="font_size_entries">
|
||||||
|
<item>@string/small</item>
|
||||||
|
<item>@string/medium</item>
|
||||||
|
<item>@string/large</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -43,4 +43,5 @@
|
||||||
<bool name="show_qr_code_scan">true</bool>
|
<bool name="show_qr_code_scan">true</bool>
|
||||||
<bool name="scroll_to_bottom">true</bool>
|
<bool name="scroll_to_bottom">true</bool>
|
||||||
<string name="omemo_setting_default">default_on</string>
|
<string name="omemo_setting_default">default_on</string>
|
||||||
|
<string name="default_font_size">small</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -349,7 +349,7 @@
|
||||||
<string name="could_not_verify_fingerprint">Could not verify fingerprint</string>
|
<string name="could_not_verify_fingerprint">Could not verify fingerprint</string>
|
||||||
<string name="manually_verify">Manually verify</string>
|
<string name="manually_verify">Manually verify</string>
|
||||||
<string name="are_you_sure_verify_fingerprint">Are you sure that you want to verify your contact’s OTR fingerprint?</string>
|
<string name="are_you_sure_verify_fingerprint">Are you sure that you want to verify your contact’s OTR fingerprint?</string>
|
||||||
<string name="pref_show_dynamic_tags">Show dynamic tags</string>
|
<string name="pref_show_dynamic_tags">Dynamic Tags</string>
|
||||||
<string name="pref_show_dynamic_tags_summary">Display read-only tags underneath contacts</string>
|
<string name="pref_show_dynamic_tags_summary">Display read-only tags underneath contacts</string>
|
||||||
<string name="enable_notifications">Enable notifications</string>
|
<string name="enable_notifications">Enable notifications</string>
|
||||||
<string name="no_conference_server_found">No group chat server found</string>
|
<string name="no_conference_server_found">No group chat server found</string>
|
||||||
|
@ -739,4 +739,11 @@
|
||||||
<string name="pref_omemo_setting_summary_always">OMEMO will always be used for one-on-one and private group chats.</string>
|
<string name="pref_omemo_setting_summary_always">OMEMO will always be used for one-on-one and private group chats.</string>
|
||||||
<string name="pref_omemo_setting_summary_default_on">OMEMO will be used by default for new conversations.</string>
|
<string name="pref_omemo_setting_summary_default_on">OMEMO will be used by default for new conversations.</string>
|
||||||
<string name="pref_omemo_setting_summary_default_off">OMEMO will have to be turned on explicitly for new conversations.</string>
|
<string name="pref_omemo_setting_summary_default_off">OMEMO will have to be turned on explicitly for new conversations.</string>
|
||||||
|
<string name="pref_font_size">Font Size</string>
|
||||||
|
<string name="pref_font_size_summary">The relative font size used within the app.</string>
|
||||||
|
<string name="default_on">On by default</string>
|
||||||
|
<string name="default_off">Off by default</string>
|
||||||
|
<string name="small">Small</string>
|
||||||
|
<string name="medium">Medium</string>
|
||||||
|
<string name="large">Large</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -167,6 +167,50 @@
|
||||||
<item type="reference" name="icon_enable_undecided_device">@drawable/ic_new_releases_white_24dp</item>
|
<item type="reference" name="icon_enable_undecided_device">@drawable/ic_new_releases_white_24dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="ConversationsTheme.Medium" parent="ConversationsTheme">
|
||||||
|
<item name="TextSizeCaption">14sp</item>
|
||||||
|
<item name="TextSizeBody1">16sp</item>
|
||||||
|
<item name="TextSizeBody2">16sp</item>
|
||||||
|
<item name="TextSizeSubhead">18sp</item>
|
||||||
|
<item name="TextSizeTitle">22sp</item>
|
||||||
|
<item name="TextSizeInput">18sp</item>
|
||||||
|
<item name="TextSeparation">6sp</item>
|
||||||
|
<item name="IconSize">20sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="ConversationsTheme.Dark.Medium" parent="ConversationsTheme.Dark">
|
||||||
|
<item name="TextSizeCaption">14sp</item>
|
||||||
|
<item name="TextSizeBody1">16sp</item>
|
||||||
|
<item name="TextSizeBody2">16sp</item>
|
||||||
|
<item name="TextSizeSubhead">18sp</item>
|
||||||
|
<item name="TextSizeTitle">22sp</item>
|
||||||
|
<item name="TextSizeInput">18sp</item>
|
||||||
|
<item name="TextSeparation">6sp</item>
|
||||||
|
<item name="IconSize">20sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="ConversationsTheme.Dark.Large" parent="ConversationsTheme.Dark">
|
||||||
|
<item name="TextSizeCaption">16sp</item>
|
||||||
|
<item name="TextSizeBody1">18sp</item>
|
||||||
|
<item name="TextSizeBody2">18sp</item>
|
||||||
|
<item name="TextSizeSubhead">20sp</item>
|
||||||
|
<item name="TextSizeTitle">24sp</item>
|
||||||
|
<item name="TextSizeInput">20sp</item>
|
||||||
|
<item name="TextSeparation">7sp</item>
|
||||||
|
<item name="IconSize">22sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="ConversationsTheme.Large" parent="ConversationsTheme">
|
||||||
|
<item name="TextSizeCaption">16sp</item>
|
||||||
|
<item name="TextSizeBody1">18sp</item>
|
||||||
|
<item name="TextSizeBody2">18sp</item>
|
||||||
|
<item name="TextSizeSubhead">20sp</item>
|
||||||
|
<item name="TextSizeTitle">24sp</item>
|
||||||
|
<item name="TextSizeInput">20sp</item>
|
||||||
|
<item name="TextSeparation">7sp</item>
|
||||||
|
<item name="IconSize">22sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="ConversationsTheme.FullScreen" parent="@style/Theme.AppCompat.Light">
|
<style name="ConversationsTheme.FullScreen" parent="@style/Theme.AppCompat.Light">
|
||||||
<item name="colorPrimary">@color/primary500</item>
|
<item name="colorPrimary">@color/primary500</item>
|
||||||
<item name="colorPrimaryDark">@color/primary700</item>
|
<item name="colorPrimaryDark">@color/primary700</item>
|
||||||
|
|
|
@ -147,16 +147,23 @@
|
||||||
android:key="theme"
|
android:key="theme"
|
||||||
android:summary="@string/pref_theme_options_summary"
|
android:summary="@string/pref_theme_options_summary"
|
||||||
android:title="@string/pref_theme_options"/>
|
android:title="@string/pref_theme_options"/>
|
||||||
<CheckBoxPreference
|
|
||||||
android:defaultValue="@bool/use_subject"
|
|
||||||
android:key="use_subject"
|
|
||||||
android:summary="@string/pref_conference_name_summary"
|
|
||||||
android:title="@string/pref_conference_name"/>
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="@bool/use_green_background"
|
android:defaultValue="@bool/use_green_background"
|
||||||
android:key="use_green_background"
|
android:key="use_green_background"
|
||||||
android:summary="@string/pref_use_green_background_summary"
|
android:summary="@string/pref_use_green_background_summary"
|
||||||
android:title="@string/pref_use_green_background"/>
|
android:title="@string/pref_use_green_background"/>
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="@string/default_font_size"
|
||||||
|
android:key="font_size"
|
||||||
|
android:title="@string/pref_font_size"
|
||||||
|
android:summary="@string/pref_font_size_summary"
|
||||||
|
android:entryValues="@array/font_size_entry_values"
|
||||||
|
android:entries="@array/font_size_entries"/>
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="@bool/use_subject"
|
||||||
|
android:key="use_subject"
|
||||||
|
android:summary="@string/pref_conference_name_summary"
|
||||||
|
android:title="@string/pref_conference_name"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="@bool/send_button_status"
|
android:defaultValue="@bool/send_button_status"
|
||||||
android:key="send_button_status"
|
android:key="send_button_status"
|
||||||
|
|
Loading…
Reference in New Issue