SHARE
TWEET

Untitled

a guest Oct 18th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.blogspot.dbh4ck.dbtheme;
  2.  
  3. import android.os.Build;
  4. import android.os.Bundle;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.view.WindowManager;
  7.  
  8. /**
  9.  * Created by DB on 22-04-2017.
  10.  */
  11.  
  12. public class BaseActivity extends AppCompatActivity {
  13.  
  14.     private final static int THEME_PINK_1 = 0;
  15.     private final static int THEME_PINK_2 = 1;
  16.     private final static int THEME_PINK_3 = 2;
  17.     private final static int THEME_BLUE_1 = 3;
  18.     private final static int THEME_BLUE_2 = 4;
  19.     private final static int THEME_BLUE_3 = 5;
  20.     private final static int THEME_RED_1 = 6;
  21.     private final static int THEME_RED_2 = 7;
  22.     private final static int THEME_GREEN_1 = 8;
  23.     private final static int THEME_GREEN_2 = 9;
  24.     private final static int THEME_GREEN_3 = 10;
  25.     private final static int THEME_GREEN_4 = 11;
  26.     private final static int THEME_PURPLE_1 = 12;
  27.     private final static int THEME_PURPLE_2 = 13;
  28.     private final static int THEME_BLACK_1 = 14;
  29.     private final static int THEME_YELLOW_1 = 15;
  30.     private final static int THEME_BROWN_1 = 16;
  31.     private final static int THEME_BROWN_2 = 17;
  32.     private final static int THEME_GREEN_SHADE = 18;
  33.     private final static int THEME_GREY_SHADE = 19;
  34.     private final static int THEME_DEFAULT = 20;
  35.  
  36.     @Override
  37.     public void onCreate(Bundle savedInstanceState) {
  38.         super.onCreate(savedInstanceState);
  39.         updateTheme();
  40.     }
  41.  
  42.     public void updateTheme() {
  43.         if (Utility.getTheme(getApplicationContext()) == THEME_PINK_1 ) {
  44.             setTheme(R.style.theme_pink1);
  45.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  46.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  47.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_pink1dark));
  48.             }
  49.         }
  50.         else if (Utility.getTheme(getApplicationContext()) == THEME_PINK_2) {
  51.             setTheme(R.style.theme_pink2);
  52.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  53.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  54.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_pink2dark));
  55.             }
  56.         }
  57.         else if (Utility.getTheme(getApplicationContext()) == THEME_PINK_3) {
  58.             setTheme(R.style.theme_pink3);
  59.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  60.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  61.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_pink3dark));
  62.             }
  63.         }
  64.         else if (Utility.getTheme(getApplicationContext()) == THEME_BLUE_1) {
  65.             setTheme(R.style.theme_blue1);
  66.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  67.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  68.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_blue1dark));
  69.             }
  70.         }
  71.         else if (Utility.getTheme(getApplicationContext()) == THEME_BLUE_2) {
  72.             setTheme(R.style.theme_blue2);
  73.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  74.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  75.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_blue2dark));
  76.             }
  77.         }
  78.         else if (Utility.getTheme(getApplicationContext()) == THEME_BLUE_3) {
  79.             setTheme(R.style.theme_blue3);
  80.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  81.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  82.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_blue3dark));
  83.             }
  84.         }
  85.         else if (Utility.getTheme(getApplicationContext()) == THEME_RED_1) {
  86.             setTheme(R.style.theme_red1);
  87.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  88.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  89.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_red1dark));
  90.             }
  91.         }
  92.         else if (Utility.getTheme(getApplicationContext()) == THEME_RED_2) {
  93.             setTheme(R.style.theme_red2);
  94.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  95.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  96.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_red2dark));
  97.             }
  98.         }
  99.  
  100.         else if (Utility.getTheme(getApplicationContext()) == THEME_GREEN_1) {
  101.             setTheme(R.style.theme_green1);
  102.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  103.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  104.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_green1dark));
  105.             }
  106.         }
  107.         else if (Utility.getTheme(getApplicationContext()) == THEME_GREEN_2) {
  108.             setTheme(R.style.theme_green2);
  109.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  110.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  111.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_green2dark));
  112.             }
  113.         }
  114.         else if (Utility.getTheme(getApplicationContext()) == THEME_GREEN_3) {
  115.             setTheme(R.style.theme_green3);
  116.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  117.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  118.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_green3dark));
  119.             }
  120.         }
  121.         else if (Utility.getTheme(getApplicationContext()) == THEME_GREEN_4) {
  122.             setTheme(R.style.theme_green4);
  123.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  124.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  125.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_green4dark));
  126.             }
  127.         }
  128.         else if (Utility.getTheme(getApplicationContext()) == THEME_PURPLE_1) {
  129.             setTheme(R.style.theme_purple1);
  130.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  131.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  132.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_purple1dark));
  133.             }
  134.         }
  135.         else if (Utility.getTheme(getApplicationContext()) == THEME_PURPLE_2) {
  136.             setTheme(R.style.theme_purple2);
  137.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  138.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  139.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_purple2dark));
  140.             }
  141.         }
  142.  
  143.         else if (Utility.getTheme(getApplicationContext()) == THEME_BLACK_1) {
  144.             setTheme(R.style.theme_black1);
  145.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  146.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  147.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_black1dark));
  148.             }
  149.         }
  150.  
  151.         else if (Utility.getTheme(getApplicationContext()) == THEME_YELLOW_1) {
  152.             setTheme(R.style.theme_yellow1);
  153.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  154.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  155.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_yellow1dark));
  156.             }
  157.         }
  158.         else if (Utility.getTheme(getApplicationContext()) == THEME_BROWN_1) {
  159.             setTheme(R.style.theme_brown1);
  160.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  161.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  162.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_brown1dark));
  163.             }
  164.         }
  165.         else if (Utility.getTheme(getApplicationContext()) == THEME_BROWN_2) {
  166.             setTheme(R.style.theme_brown2);
  167.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  168.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  169.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_brown2dark));
  170.             }
  171.         }
  172.  
  173.         else if (Utility.getTheme(getApplicationContext()) == THEME_GREEN_SHADE) {
  174.             setTheme(R.style.theme_green_shade);
  175.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  176.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  177.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_green_shade_dark));
  178.             }
  179.         }
  180.  
  181.         else if (Utility.getTheme(getApplicationContext()) == THEME_GREY_SHADE) {
  182.             setTheme(R.style.theme_grey);
  183.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  184.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  185.                 getWindow().setStatusBarColor(getResources().getColor(R.color.theme_grey_shade_dark));
  186.             }
  187.         }
  188.  
  189.         else if (Utility.getTheme(getApplicationContext()) == THEME_DEFAULT) {
  190.             setTheme(R.style.NimbuzzTheme);
  191.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  192.                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  193.                 getWindow().setStatusBarColor(getResources().getColor(R.color.app_color_primary_dark));
  194.             }
  195.         }
  196.     }
  197. }
RAW Paste Data
Top