aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-23 20:14:22 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-23 20:14:22 +0200
commitcd31daea233fa69b7322400dad7b3d6404cd889e (patch)
treead08e6d972c1f4845dd84f102d1d36b6abf24cb7 /src/main/java/de/pixart
parenta7defe344b9d56f5d2f9c63b6ba312c3d65ea2b2 (diff)
made font size selectable
Diffstat (limited to 'src/main/java/de/pixart')
-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
5 files changed, 64 insertions, 25 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