aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/bienvenidoainternet/baiparser/ThemeManager.java
diff options
context:
space:
mode:
authorLibravatar Renard1911 2016-04-11 17:52:55 -0300
committerLibravatar Renard1911 2016-04-11 17:52:55 -0300
commitc94f0e1d27f0a92a17b2e65363bdce6461249d95 (patch)
tree6990d471d884ad87a2be9234e40fd2a91f6bb827 /app/src/main/java/org/bienvenidoainternet/baiparser/ThemeManager.java
parent0f3adf23154e6d7e0eaced70a31676d71bef8e34 (diff)
parent90ee611af8ba4c38e70f27eb0df55e9134ad625c (diff)
downloadBaiApp-c94f0e1d27f0a92a17b2e65363bdce6461249d95.tar.gz
BaiApp-c94f0e1d27f0a92a17b2e65363bdce6461249d95.tar.xz
BaiApp-c94f0e1d27f0a92a17b2e65363bdce6461249d95.zip
Merge pull request #1 from Renard1911/devv1.6.0
Dev
Diffstat (limited to 'app/src/main/java/org/bienvenidoainternet/baiparser/ThemeManager.java')
-rw-r--r--app/src/main/java/org/bienvenidoainternet/baiparser/ThemeManager.java92
1 files changed, 81 insertions, 11 deletions
diff --git a/app/src/main/java/org/bienvenidoainternet/baiparser/ThemeManager.java b/app/src/main/java/org/bienvenidoainternet/baiparser/ThemeManager.java
index 7f0be86..28c0d74 100644
--- a/app/src/main/java/org/bienvenidoainternet/baiparser/ThemeManager.java
+++ b/app/src/main/java/org/bienvenidoainternet/baiparser/ThemeManager.java
@@ -1,26 +1,54 @@
package org.bienvenidoainternet.baiparser;
+import android.app.Activity;
+import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.Color;
+import android.preference.PreferenceManager;
+import android.util.Log;
/**
* Created by Renard on 16-03-2016.
*/
public class ThemeManager {
- private MainActivity ac;
private int currentThemeId;
- public ThemeManager(MainActivity ac){
- this.ac = ac;
- this.currentThemeId = ac.getCurrentThemeId();
+ private int prefThemeId;
+ private Activity activity;
+ public ThemeManager(Activity activity){
+ this.activity = activity;
+ setCurrentThemeId();
+ }
+
+ public void setCurrentThemeId(){
+ SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(activity);
+ int themeId = Integer.valueOf(settings.getString("pref_theme", "1"));
+ prefThemeId = themeId;
+ switch (themeId) {
+ case 1:
+ currentThemeId = R.style.AppTheme_NoActionBar;
+ break;
+ case 2:
+ currentThemeId = R.style.AppTheme_Dark;
+ break;
+ case 3:
+ currentThemeId = R.style.AppTheme_HeadLine;
+// setTheme(R.style.AppTheme_HeadLine_Activity);
+ break;
+ case 4:
+ currentThemeId = R.style.AppTheme_Black;
+// setTheme(R.style.AppTheme_Black_Activity);
+ break;
+ }
+ Log.d("ThemeManager", "isDarkTheme: " + isDarkTheme());
}
public int getSageColor(){
- TypedArray a = ac.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.sageColor});
+ TypedArray a = activity.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.sageColor});
return a.getColor(0, Color.CYAN);
}
public int getMarginColor(){
- TypedArray a = ac.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.marginColor});
+ TypedArray a = activity.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.marginColor});
return a.getColor(0, Color.CYAN);
}
@@ -29,27 +57,69 @@ public class ThemeManager {
}
public int getNameColor() {
- TypedArray a = ac.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.nameColor});
+ TypedArray a = activity.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.nameColor});
return a.getColor(0, Color.CYAN);
}
public int getTripcodeColor() {
- TypedArray a = ac.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.tripcodeColor});
+ TypedArray a = activity.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.tripcodeColor});
return a.getColor(0, Color.CYAN);
}
public int getPrimaryColor(){
- TypedArray a = ac.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.colorPrimary});
+ TypedArray a = activity.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.colorPrimary});
return a.getColor(0, Color.CYAN);
}
public int getPrimaryDarkColor(){
- TypedArray a = ac.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.colorPrimaryDark});
+ TypedArray a = activity.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.colorPrimaryDark});
return a.getColor(0, Color.CYAN);
}
public boolean isDarkTheme(){
- TypedArray a = ac.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.isDarkTheme});
+ TypedArray a = activity.getTheme().obtainStyledAttributes(currentThemeId, new int[]{R.attr.isDarkTheme});
return a.getBoolean(0, false);
}
+ public int getThemeForActivity(){
+ int id = R.style.AppTheme;
+ switch (prefThemeId) {
+ case 1: // pseudoch
+ id = R.style.AppTheme;
+ break;
+ case 2: // nightmode
+ id = R.style.AppTheme;
+ break;
+ case 3: // photon
+ id = R.style.AppTheme_HeadLineActionBar;
+ break;
+ case 4: // tomorrow
+ id = R.style.AppTheme_BlackActionBar;
+ break;
+ }
+ return id;
+ }
+
+ public int getThemeForMainActivity(){
+ int id = R.style.AppTheme_NoActionBar;
+ switch (prefThemeId) {
+ case 1: // pseudoch
+ id = R.style.AppTheme_NoActionBar;
+ break;
+ case 2: // nightmode
+ id = R.style.AppTheme_NoActionBar;
+ break;
+ case 3: // photon
+ id = R.style.AppTheme_HeadLineActionBar_NoActionBar;
+ break;
+ case 4: // tomorrow
+ id = R.style.AppTheme_BlackActionBar_NoActionBar;
+ break;
+ }
+ return id;
+ }
+
+
+ public int getCurrentThemeId() {
+ return currentThemeId;
+ }
}