Example usage for android.app Activity setTheme

List of usage examples for android.app Activity setTheme

Introduction

In this page you can find the example usage for android.app Activity setTheme.

Prototype

@Override
    public void setTheme(int resid) 

Source Link

Usage

From source file:gr.scify.newsum.Utils.java

/** Set the theme of the activity, according to the configuration. 
 * @param sTheme *///from   w w w.  j  a  va 2s.  c  o m
public static void onActivityCreateSetTheme(Activity activity, int iTheme) {
    try {
        activity.setTheme(getThemesToResourceIDs(activity).get(getThemeFromThemeID(iTheme, activity)));
    } catch (Exception e) {
        // Could not set theme
        System.err.println("Could not set theme... Continuing normally.");
    }
}

From source file:jahirfiquitiva.iconshowcase.utilities.utils.ThemeUtils.java

public static void onActivityCreateSetTheme(Activity activity) {
    final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity);
    int mTheme = sp.getInt("theme", (activity.getResources().getInteger(R.integer.app_theme) - 1));
    switch (mTheme) {
    default://from  ww  w.ja v a2 s.  c o m
    case LIGHT:
        activity.setTheme(R.style.AppTheme);
        darkTheme = false;
        transparent = false;
        break;
    case DARK:
        activity.setTheme(R.style.AppThemeDark);
        darkTheme = true;
        transparent = false;
        break;
    case CLEAR:
        activity.setTheme(R.style.AppThemeClear);
        darkTheme = true;
        transparent = true;
        break;
    case AUTO:
        Calendar c = Calendar.getInstance();
        transparent = false;
        int timeOfDay = c.get(Calendar.HOUR_OF_DAY);
        if (timeOfDay >= 7 && timeOfDay < 20) {
            activity.setTheme(R.style.AppTheme);
            darkTheme = false;
        } else {
            activity.setTheme(R.style.AppThemeDark);
            darkTheme = true;
        }
        break;
    }
}

From source file:jahirfiquitiva.iconshowcase.utilities.ThemeUtils.java

public static void onActivityCreateSetTheme(Activity activity) {
    final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity);
    int mTheme = sp.getInt("theme", (activity.getResources().getInteger(R.integer.default_theme) - 1));
    switch (mTheme) {
    default:/*from  ww w . j a  v  a 2  s  .  co  m*/
    case LIGHT:
        activity.setTheme(R.style.AppTheme);
        darkTheme = false;
        transparent = false;
        break;
    case DARK:
        activity.setTheme(R.style.AppThemeDark);
        darkTheme = true;
        transparent = false;
        break;
    case CLEAR:
        activity.setTheme(R.style.AppThemeClear);
        darkTheme = true;
        transparent = true;
        break;
    case AUTO:
        Calendar c = Calendar.getInstance();
        transparent = false;
        int timeOfDay = c.get(Calendar.HOUR_OF_DAY);
        if (timeOfDay >= 7 && timeOfDay < 20) {
            activity.setTheme(R.style.AppTheme);
            darkTheme = false;
        } else {
            activity.setTheme(R.style.AppThemeDark);
            darkTheme = true;
        }
        break;
    }
}

From source file:com.koushikdutta.superuser.helper.Theme.java

public static Bundle setTheme(Activity context, SharedPreferences pref) {

    String theme = PREF_LIGHT_THEME;
    int textToolbarDefault = 0xff424242;

    switch (pref.getString(PREF_THEME, PREF_LIGHT_THEME)) {
    case PREF_BLACK_THEME:
        theme = PREF_BLACK_THEME;//from w w  w .ja v a 2  s  . c o m
        textToolbarDefault = 0xffeaeaea;
        context.setTheme(R.style.AppTheme_Black_NoActionBar);
        break;

    case PREF_DARK_THEME:
        theme = PREF_DARK_THEME;
        context.setTheme(R.style.AppTheme_NoActionBar);
        break;

    case PREF_LIGHT_THEME:
        theme = PREF_LIGHT_THEME;
        context.setTheme(R.style.AppTheme_Light_NoActionBar);
        break;
    }

    Bundle bundle = new Bundle();

    bundle.putString(THEME_CURRENT, theme);
    bundle.putInt(TEXT_COLOR_TOOLBAR, pref.getInt(TEXT_COLOR_TOOLBAR, textToolbarDefault));

    return bundle;
}

From source file:io.github.carlorodriguez.alarmon.AppSettings.java

public static void setTheme(Context context, Activity activity) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);

    String theme = sharedPref.getString(APP_THEME_KEY, "0");

    switch (theme) {
    case "1":
        activity.setTheme(R.style.AppThemeLight);
        break;/*from w w  w.j  av  a 2s.  c o  m*/
    case "2":
        activity.setTheme(R.style.AppThemeLightDarkActionBar);
        break;
    }
}

From source file:io.github.carlorodriguez.alarmon.AppSettings.java

public static void setMainActivityTheme(Context context, Activity activity) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);

    String theme = sharedPref.getString(APP_THEME_KEY, "0");

    switch (theme) {
    case "1":
        activity.setTheme(R.style.MainAppThemeLight);
        break;// w  w  w  .j a  v  a2s.  c  o m
    case "2":
        activity.setTheme(R.style.MainAppThemeLightDarkActionBar);
        break;
    }
}

From source file:com.binomed.showtime.android.util.CineShowTimeLayoutUtils.java

/** Set the theme of the activity, according to the configuration. */
public static void onActivityCreateSetTheme(Activity activity, SharedPreferences pref) {
    String defaultTheme = activity.getResources().getString(R.string.preference_gen_default_theme);
    String theme = pref.getString(activity.getResources().getString(R.string.preference_gen_key_theme),
            defaultTheme);/*from  ww  w  .  j a  va  2 s. co  m*/
    if (theme.equals(defaultTheme)) {
        activity.setTheme(R.style.Theme_Dark_Night);
    } else {
        activity.setTheme(R.style.Theme_Shine_the_lite);
    }

}

From source file:im.vector.util.ThemeUtils.java

/**
 * Set the activity theme according to the selected one.
 *
 * @param activity the activity//w  w  w  . j  av  a 2s .  c om
 */
public static void setActivityTheme(Activity activity) {
    if (TextUtils.equals(getApplicationTheme(activity), THEME_DARK_VALUE)) {
        if (activity instanceof BugReportActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        } else if (activity instanceof AccountCreationActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        } else if (activity instanceof DeactivateAccountActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Dark);
        } else if (activity instanceof CountryPickerActivity) {
            activity.setTheme(R.style.CountryPickerTheme_Dark);
        } else if (activity instanceof FallbackLoginActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        } else if (activity instanceof HistoricalRoomsActivity) {
            activity.setTheme(R.style.HomeActivityTheme_Dark);
        } else if (activity instanceof LanguagePickerActivity) {
            activity.setTheme(R.style.CountryPickerTheme_Dark);
        } else if (activity instanceof NotificationPrivacyActivity) {
            activity.setTheme(R.style.CountryPickerTheme_Dark);
        } else if (activity instanceof LoginActivity) {
            activity.setTheme(R.style.LoginAppTheme_Dark);
        } else if (activity instanceof PhoneNumberAdditionActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Dark);
        } else if (activity instanceof PhoneNumberVerificationActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Dark);
        } else if (activity instanceof RoomDirectoryPickerActivity) {
            activity.setTheme(R.style.DirectoryPickerTheme_Dark);
        } else if (activity instanceof SplashActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Dark);
        } else if (activity instanceof LoggingOutActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Dark);
        } else if (activity instanceof VectorBaseSearchActivity) {
            activity.setTheme(R.style.SearchesAppTheme_Dark);
        } else if (activity instanceof VectorCallViewActivity) {
            activity.setTheme(R.style.CallActivityTheme_Dark);
        } else if (activity instanceof VectorHomeActivity) {
            activity.setTheme(R.style.HomeActivityTheme_Dark);
        } else if (activity instanceof VectorMediasPickerActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_FullScreen_Dark);
        } else if (activity instanceof VectorMediasViewerActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        } else if (activity instanceof VectorMemberDetailsActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Dark);
        } else if (activity instanceof VectorPublicRoomsActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        } else if (activity instanceof VectorRoomActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Dark);
        } else if (activity instanceof VectorRoomCreationActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        } else if (activity instanceof VectorRoomDetailsActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        } else if (activity instanceof VectorSettingsActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        } else if (activity instanceof VectorUniversalLinkActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        } else if (activity instanceof LockScreenActivity) {
            activity.setTheme(R.style.Vector_Lock_Dark);
        } else if (activity instanceof VectorGroupDetailsActivity) {
            activity.setTheme(R.style.AppTheme_Dark);
        }
    }

    if (TextUtils.equals(getApplicationTheme(activity), THEME_BLACK_VALUE)) {
        if (activity instanceof BugReportActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        } else if (activity instanceof AccountCreationActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        } else if (activity instanceof DeactivateAccountActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Black);
        } else if (activity instanceof CountryPickerActivity) {
            activity.setTheme(R.style.CountryPickerTheme_Black);
        } else if (activity instanceof FallbackLoginActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        } else if (activity instanceof HistoricalRoomsActivity) {
            activity.setTheme(R.style.HomeActivityTheme_Black);
        } else if (activity instanceof LanguagePickerActivity) {
            activity.setTheme(R.style.CountryPickerTheme_Black);
        } else if (activity instanceof NotificationPrivacyActivity) {
            activity.setTheme(R.style.CountryPickerTheme_Black);
        } else if (activity instanceof LoginActivity) {
            activity.setTheme(R.style.LoginAppTheme_Black);
        } else if (activity instanceof PhoneNumberAdditionActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Black);
        } else if (activity instanceof PhoneNumberVerificationActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Black);
        } else if (activity instanceof RoomDirectoryPickerActivity) {
            activity.setTheme(R.style.DirectoryPickerTheme_Black);
        } else if (activity instanceof SplashActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Black);
        } else if (activity instanceof LoggingOutActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Black);
        } else if (activity instanceof VectorBaseSearchActivity) {
            activity.setTheme(R.style.SearchesAppTheme_Black);
        } else if (activity instanceof VectorCallViewActivity) {
            activity.setTheme(R.style.CallActivityTheme_Black);
        } else if (activity instanceof VectorHomeActivity) {
            activity.setTheme(R.style.HomeActivityTheme_Black);
        } else if (activity instanceof VectorMediasPickerActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_FullScreen_Black);
        } else if (activity instanceof VectorMediasViewerActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        } else if (activity instanceof VectorMemberDetailsActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Black);
        } else if (activity instanceof VectorPublicRoomsActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        } else if (activity instanceof VectorRoomActivity) {
            activity.setTheme(R.style.AppTheme_NoActionBar_Black);
        } else if (activity instanceof VectorRoomCreationActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        } else if (activity instanceof VectorRoomDetailsActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        } else if (activity instanceof VectorSettingsActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        } else if (activity instanceof VectorUniversalLinkActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        } else if (activity instanceof LockScreenActivity) {
            activity.setTheme(R.style.Vector_Lock_Black);
        } else if (activity instanceof VectorGroupDetailsActivity) {
            activity.setTheme(R.style.AppTheme_Black);
        }
    }

    if (TextUtils.equals(getApplicationTheme(activity), THEME_LIGHT_VALUE)) {
        // Specific quirk for quick reply screen
        if (activity instanceof LockScreenActivity) {
            activity.setTheme(R.style.Vector_Lock_Light);
        }
    }

    mColorByAttr.clear();
}

From source file:org.openhab.habdroid.util.Util.java

public static void setActivityTheme(@NonNull final Activity activity) {
    final String theme = PreferenceManager.getDefaultSharedPreferences(activity)
            .getString(Constants.PREFERENCE_THEME, activity.getString(R.string.theme_value_dark));
    int themeRes;
    if (theme.equals(activity.getString(R.string.theme_value_light))) {
        themeRes = R.style.HABDroid_Light;
    } else if (theme.equals(activity.getString(R.string.theme_value_black))) {
        themeRes = R.style.HABDroid_Black;
    } else {// www .j  a v a  2s  . c o m
        themeRes = R.style.HABDroid_Dark;
    }
    activity.setTheme(themeRes);
}

From source file:menion.android.whereyougo.gui.extension.activity.CustomActivity.java

protected static void customOnCreate(Activity activity) {
    // Logger.v(activity.getLocalClassName(), "customOnCreate(), id:" +
    // activity.hashCode());
    // set main activity parameters
    if (!(activity instanceof CustomMainActivity)) {
        // Settings.setLanguage(this);
        setScreenBasic(activity);//from w  w w. j a  v a  2s  . c om
    }

    // set screen size
    Const.SCREEN_WIDTH = activity.getWindowManager().getDefaultDisplay().getWidth();
    Const.SCREEN_HEIGHT = activity.getWindowManager().getDefaultDisplay().getHeight();

    switch (Preferences.APPEARANCE_FONT_SIZE) {
    case PreferenceValues.VALUE_FONT_SIZE_SMALL:
        activity.setTheme(R.style.FontSizeSmall);
        break;
    case PreferenceValues.VALUE_FONT_SIZE_MEDIUM:
        activity.setTheme(R.style.FontSizeMedium);
        break;
    case PreferenceValues.VALUE_FONT_SIZE_LARGE:
        activity.setTheme(R.style.FontSizeLarge);
        break;
    }
}