package com.noprestige.kanaquiz.themes;

import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;

import com.noprestige.kanaquiz.R;
import com.noprestige.kanaquiz.options.OptionsControl;

public final class ThemeManager
{
    private ThemeManager() {}

    public static int getCurrentThemeId()
    {
        if (OptionsControl.compareStrings(R.string.prefid_selected_theme, R.string.themeid_cherry_blossom_tree))
            return R.style.CherryBlossomTree;
        else if (OptionsControl.compareStrings(R.string.prefid_selected_theme, R.string.themeid_shibuya_night))
            return R.style.ShibuyaNight;
        else
            return R.style.CherryBlossomTree;
    }

    public static int getThemeColour(Context context, int attr)
    {
        TypedArray array = context.getTheme().obtainStyledAttributes(new int[]{attr});
        int returnValue = array.getColor(0, 0);
        array.recycle();
        return returnValue;
    }

    public static Typeface getThemeFont(Context context, int attr, int fontStyle)
    {
        TypedArray array = context.getTheme().obtainStyledAttributes(new int[]{attr});
        String fontFamily = array.getString(0);
        array.recycle();
        return Typeface.create(fontFamily, fontStyle);
    }

    public static Drawable getThemeDrawable(Context context, int attr)
    {
        TypedArray array = context.getTheme().obtainStyledAttributes(new int[]{attr});
        Drawable returnValue = array.getDrawable(0);
        array.recycle();
        return returnValue;
    }

    public static void setTheme(Activity activity)
    {
        activity.setTheme(getCurrentThemeId());
    }
}

@@ -95,16 +95,54 @@
 ontext;%0A
+import android.content.res.Resources;%0A
 import a
@@ -893,32 +893,172 @@
 int attr)%0A    %7B%0A
+        return getThemeColour(context.getTheme(), attr);%0A    %7D%0A%0A    public static int getThemeColour(Resources.Theme theme, int attr)%0A    %7B%0A
         TypedArr
@@ -1068,34 +1068,21 @@
 array = 
-context.getT
+t
 heme
-()
 .obtainS
@@ -1303,32 +1303,199 @@
 ontStyle)%0A    %7B%0A
+        return getThemeFont(context.getTheme(), attr, fontStyle);%0A    %7D%0A%0A    public static Typeface getThemeFont(Resources.Theme theme, int attr, int fontStyle)%0A    %7B%0A
         TypedArr
@@ -1505,34 +1505,21 @@
 array = 
-context.getT
+t
 heme
-()
 .obtainS
@@ -1756,32 +1756,181 @@
 int attr)%0A    %7B%0A
+        return getThemeDrawable(context.getTheme(), attr);%0A    %7D%0A%0A    public static Drawable getThemeDrawable(Resources.Theme theme, int attr)%0A    %7B%0A
         TypedArr
@@ -1940,34 +1940,21 @@
 array = 
-context.getT
+t
 heme
-()
 .obtainS

Split up theme attribute methods