/*
 * Copyright 2016 OpenMarket Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package im.vector.util;


import android.app.Activity;

import java.util.HashMap;
import java.util.Map;
import im.vector.R;

/**
 * Util class for managing themes.
 */
public class ThemeUtils {

    private static Integer currentTheme = null;

    // Maps theme names to formal ID's
    private static HashMap<String, Integer> themeMap = new HashMap<>();
    static {
        themeMap.put("dark", R.style.Theme_Vector_Dark);
        themeMap.put("light", R.style.Theme_Vector_Light);
    }


    public static void setTheme(String theme) {
        if (themeMap.containsKey(theme)) {
            if (themeMap.get(theme) != currentTheme) {
                currentTheme = themeMap.get(theme);
            }
        }
    }

    public static void activitySetTheme(Activity a) {
        if (currentTheme != null) {
            a.setTheme(currentTheme);
        } else {
            // Just in case we had some problem anywhere reading, set the theme to light.
            a.setTheme(themeMap.get("light"));
        }
    }

}

@@ -16,9 +16,9 @@
  201
-6
+7
  Ope
@@ -646,16 +646,167 @@
 ctivity;
+%0Aimport android.content.Context;%0Aimport android.support.annotation.AttrRes;%0Aimport android.support.annotation.ColorRes;%0Aimport android.util.TypedValue;
 %0A%0Aimport
@@ -1746,16 +1746,16 @@
 ght%22));%0A
-
         
@@ -1763,10 +1763,407 @@
 %0A    %7D%0A%0A
+    /**%0A     * Translates color attributes to colors%0A     * @param c Context%0A     * @param colorAttribute Color Attribute%0A     * @return Requested Color%0A     */%0A    public static @ColorRes int getColor(Context c, @AttrRes final int colorAttribute) %7B%0A        TypedValue color = new TypedValue();%0A        c.getTheme().resolveAttribute(colorAttribute, color, true);%0A        return color.data;%0A    %7D%0A%0A
 %7D%0A

Add a attribute -> color helper function