aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/ui/AboutActivity.java6
-rw-r--r--src/main/java/de/pixart/messenger/ui/MemorizingActivity.java15
-rw-r--r--src/main/java/de/pixart/messenger/ui/RecordingActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java9
-rw-r--r--src/main/java/de/pixart/messenger/utils/ThemeHelper.java56
-rw-r--r--src/main/res/values/arrays.xml10
-rw-r--r--src/main/res/values/defaults.xml1
-rw-r--r--src/main/res/values/strings.xml5
-rw-r--r--src/main/res/values/themes.xml70
-rw-r--r--src/main/res/xml/preferences.xml12
10 files changed, 142 insertions, 45 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/AboutActivity.java b/src/main/java/de/pixart/messenger/ui/AboutActivity.java
index e417149d6..093ea3bb7 100644
--- a/src/main/java/de/pixart/messenger/ui/AboutActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/AboutActivity.java
@@ -3,6 +3,7 @@ package de.pixart.messenger.ui;
import android.os.Bundle;
import de.pixart.messenger.R;
+import de.pixart.messenger.utils.ThemeHelper;
public class AboutActivity extends XmppActivity {
@@ -19,10 +20,9 @@ public class AboutActivity extends XmppActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- this.mTheme = findTheme();
- setTheme(this.mTheme);
+ setTheme(ThemeHelper.find(this));
setContentView(R.layout.activity_about);
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
}
-}
+} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/ui/MemorizingActivity.java b/src/main/java/de/pixart/messenger/ui/MemorizingActivity.java
index 2d9a2b499..a47adc6eb 100644
--- a/src/main/java/de/pixart/messenger/ui/MemorizingActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/MemorizingActivity.java
@@ -27,9 +27,7 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
-import android.content.SharedPreferences;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
@@ -39,6 +37,7 @@ import java.util.logging.Logger;
import de.pixart.messenger.R;
import de.pixart.messenger.entities.MTMDecision;
import de.pixart.messenger.services.MemorizingTrustManager;
+import de.pixart.messenger.utils.ThemeHelper;
public class MemorizingActivity extends AppCompatActivity implements OnClickListener,OnCancelListener {
@@ -51,7 +50,7 @@ public class MemorizingActivity extends AppCompatActivity implements OnClickList
@Override
public void onCreate(Bundle savedInstanceState) {
LOGGER.log(Level.FINE, "onCreate");
- //setTheme(findTheme());
+ setTheme(ThemeHelper.find(this));
super.onCreate(savedInstanceState);
getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content));
setSupportActionBar(findViewById(R.id.toolbar));
@@ -88,16 +87,6 @@ public class MemorizingActivity extends AppCompatActivity implements OnClickList
finish();
}
- protected int findTheme() {
- return 0;
- //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
public void onClick(DialogInterface dialog, int btnId) {
int decision;
diff --git a/src/main/java/de/pixart/messenger/ui/RecordingActivity.java b/src/main/java/de/pixart/messenger/ui/RecordingActivity.java
index 7ea474c75..3aaa6b42b 100644
--- a/src/main/java/de/pixart/messenger/ui/RecordingActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/RecordingActivity.java
@@ -180,8 +180,7 @@ public class RecordingActivity extends XmppActivity implements View.OnClickListe
}
protected int findTheme() {
- Boolean dark = getPreferences().getString(SettingsActivity.THEME, getResources().getString(R.string.theme)).equals("dark");
-
+ final Boolean dark = getPreferences().getString(SettingsActivity.THEME, getResources().getString(R.string.theme)).equals("dark");
if (dark) {
return R.style.ConversationsDialog_Dark;
} else {
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index c51e2ffe6..5c104cada 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -80,6 +80,7 @@ import de.pixart.messenger.ui.util.PresenceSelector;
import de.pixart.messenger.utils.CryptoHelper;
import de.pixart.messenger.utils.ExceptionHelper;
import de.pixart.messenger.utils.MenuDoubleTabUtil;
+import de.pixart.messenger.utils.ThemeHelper;
import de.pixart.messenger.xmpp.OnKeyStatusUpdated;
import de.pixart.messenger.xmpp.OnUpdateBlocklist;
import rocks.xmpp.addr.Jid;
@@ -1046,13 +1047,7 @@ public abstract class XmppActivity extends AppCompatActivity {
}
protected int findTheme() {
- Boolean dark = getPreferences().getString(SettingsActivity.THEME, getResources().getString(R.string.theme)).equals("dark");
-
- if (dark) {
- return R.style.ConversationsTheme_Dark;
- } else {
- return R.style.ConversationsTheme;
- }
+ return ThemeHelper.find(this);
}
@Override
diff --git a/src/main/java/de/pixart/messenger/utils/ThemeHelper.java b/src/main/java/de/pixart/messenger/utils/ThemeHelper.java
new file mode 100644
index 000000000..199e12d5e
--- /dev/null
+++ b/src/main/java/de/pixart/messenger/utils/ThemeHelper.java
@@ -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 de.pixart.messenger.utils;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.res.Resources;
+import android.preference.PreferenceManager;
+
+import de.pixart.messenger.R;
+import de.pixart.messenger.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;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml
index 7d7823a46..fe18139fd 100644
--- a/src/main/res/values/arrays.xml
+++ b/src/main/res/values/arrays.xml
@@ -103,4 +103,14 @@
<item>@string/default_off</item>
</string-array>
+ <string-array name="font_size_entry_values">
+ <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>
diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml
index d3f76d528..d38c01174 100644
--- a/src/main/res/values/defaults.xml
+++ b/src/main/res/values/defaults.xml
@@ -104,5 +104,6 @@
<bool name="scroll_to_bottom">true</bool>
<string name="omemo_setting_default">default_off</string>
<string name="theme">light</string>
+ <string name="default_font_size">small</string>
</resources>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 809b77dba..7aeadd71d 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -782,4 +782,9 @@
<string name="pref_theme_options_summary">Select the color palette</string>
<string name="pref_theme_options">Theme</string>
<string name="chooce_account">Choose account</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="small">Small</string>
+ <string name="medium">Medium</string>
+ <string name="large">Large</string>
</resources>
diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml
index 4495b2f49..5bf27cbfd 100644
--- a/src/main/res/values/themes.xml
+++ b/src/main/res/values/themes.xml
@@ -238,21 +238,6 @@
<item name="ic_settings_about" type="reference">@drawable/ic_help_circle_white_24dp</item>
</style>
-
- <style name="ConversationsTheme.LargerText" parent="ConversationsTheme">
- <item name="TextSizeCaption">12sp</item>
- <item name="TextSizeBody1">14sp</item>
- <item name="TextSizeBody2">14sp</item>
- <item name="TextSizeSubhead">16sp</item>
- <item name="TextSizeTitle">20sp</item>
- <item name="TextSizeInput">16sp</item>
- <item name="TextSeparation">5sp</item>
- <item name="IconSize">18sp</item>
- <item name="TextSizeInfo">12sp</item>
- <item name="TextSizeBody">14sp</item>
- <item name="TextSizeHeadline">18sp</item>
- </style>
-
<style name="ConversationsDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
@@ -314,4 +299,59 @@
<item name="android:windowBackground">@drawable/background</item>
</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>
+ <item name="TextSizeInfo">14sp</item>
+ <item name="TextSizeBody">16sp</item>
+ <item name="TextSizeHeadline">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>
+ <item name="TextSizeInfo">14sp</item>
+ <item name="TextSizeBody">16sp</item>
+ <item name="TextSizeHeadline">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>
+ <item name="TextSizeInfo">16sp</item>
+ <item name="TextSizeBody">18sp</item>
+ <item name="TextSizeHeadline">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>
+ <item name="TextSizeInfo">16sp</item>
+ <item name="TextSizeBody">18sp</item>
+ <item name="TextSizeHeadline">22sp</item>
+ </style>
</resources> \ No newline at end of file
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index 822abddcc..f3fa6a5ed 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -21,11 +21,13 @@
android:key="theme"
android:summary="@string/pref_theme_options_summary"
android:title="@string/pref_theme_options" />
- <CheckBoxPreference
- android:defaultValue="@bool/use_larger_font"
- android:key="use_larger_font"
- android:summary="@string/pref_use_larger_font_summary"
- android:title="@string/pref_use_larger_font" />
+ <ListPreference
+ android:defaultValue="@string/default_font_size"
+ android:entries="@array/font_size_entries"
+ android:entryValues="@array/font_size_entry_values"
+ android:key="font_size"
+ android:summary="@string/pref_font_size_summary"
+ android:title="@string/pref_font_size" />
<CheckBoxPreference
android:defaultValue="@bool/send_button_status"
android:key="send_button_status"