fedilab-Android-App/app/src/main/java/app/fedilab/android/helper/ThemeHelper.java

47 lines
1.4 KiB
Java
Raw Normal View History

2019-11-07 18:57:05 +01:00
package app.fedilab.android.helper;
import android.app.Activity;
2019-11-07 19:07:19 +01:00
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.util.TypedValue;
import com.afollestad.aesthetic.Aesthetic;
2019-11-07 18:57:05 +01:00
import app.fedilab.android.R;
2019-11-07 19:07:19 +01:00
import static android.content.Context.MODE_PRIVATE;
2019-11-07 18:57:05 +01:00
public class ThemeHelper {
2019-11-07 19:07:19 +01:00
public static void changeTheme(Context context, int theme){
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
2019-11-07 18:57:05 +01:00
2019-11-07 19:07:19 +01:00
Aesthetic.get()
.activityTheme(theme)
.attribute(R.attr.cardviewColor,null, R.color.mastodonC1, true)
.colorAccent(null, R.color.mastodonC4)
.colorPrimary(null,R.color.mastodonC1)
.colorPrimaryDark(null,R.color.mastodonC1)
.colorNavigationBar(null,R.color.mastodonC1)
.colorStatusBar(null,R.color.mastodonC1)
.toolbarIconColor(null,R.color.white)
.colorWindowBackground(null,R.color.mastodonC1)
2019-11-07 18:57:05 +01:00
2019-11-07 19:07:19 +01:00
.apply();
}
public static int getAttColor(Context context, int attColor){
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(attColor, typedValue, true);
return typedValue.data;
2019-11-07 18:57:05 +01:00
}
}