Skip to content

Commit

Permalink
Add darker color for status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed May 29, 2015
1 parent 2361cd0 commit d203c64
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.widget.TextView;

import com.javiersantos.mlmanager.utils.AppPreferences;
import com.javiersantos.mlmanager.utils.UtilsApp;

public class AboutActivity extends AppCompatActivity {
// Load Settings
Expand Down Expand Up @@ -41,7 +42,7 @@ public void onClick(View view) {
});

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(appPreferences.getPrimaryColorPref());
getWindow().setStatusBarColor(UtilsApp.darker(appPreferences.getPrimaryColorPref(), 0.8));
toolbar.setBackgroundColor(appPreferences.getPrimaryColorPref());
if (!appPreferences.getNavigationBlackPref()) {
getWindow().setNavigationBarColor(appPreferences.getPrimaryColorPref());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void onClick(View view) {
});

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(appPreferences.getPrimaryColorPref());
getWindow().setStatusBarColor(UtilsApp.darker(appPreferences.getPrimaryColorPref(), 0.8));
toolbar.setBackgroundColor(appPreferences.getPrimaryColorPref());
if (!appPreferences.getNavigationBlackPref()) {
getWindow().setNavigationBarColor(appPreferences.getPrimaryColorPref());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void setInitialConfiguration() {
getSupportActionBar().setTitle(R.string.app_name);

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(appPreferences.getPrimaryColorPref());
getWindow().setStatusBarColor(UtilsApp.darker(appPreferences.getPrimaryColorPref(), 0.8));
toolbar.setBackgroundColor(appPreferences.getPrimaryColorPref());
if (!appPreferences.getNavigationBlackPref()) {
getWindow().setNavigationBarColor(appPreferences.getPrimaryColorPref());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public boolean onPreferenceClick(Preference preference) {

private void setInitialConfiguration() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(appPreferences.getPrimaryColorPref());
getWindow().setStatusBarColor(UtilsApp.darker(appPreferences.getPrimaryColorPref(), 0.8));
if (!appPreferences.getNavigationBlackPref()) {
getWindow().setNavigationBarColor(appPreferences.getPrimaryColorPref());
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/javiersantos/mlmanager/utils/UtilsApp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.javiersantos.mlmanager.utils;

import android.graphics.Color;
import android.os.Environment;
import android.util.Log;

Expand Down Expand Up @@ -69,4 +70,13 @@ public static Boolean deleteAppFiles() {
return res;
}

public static int darker (int color, double factor) {
int a = Color.alpha( color );
int r = Color.red(color);
int g = Color.green( color );
int b = Color.blue(color);

return Color.argb(a, Math.max( (int)(r * factor), 0 ), Math.max( (int)(g * factor), 0 ), Math.max( (int)(b * factor), 0 ) );
}

}

0 comments on commit d203c64

Please sign in to comment.