Skip to content
This repository has been archived by the owner on Sep 8, 2019. It is now read-only.

Commit

Permalink
- minor ui adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
kollerlukas committed Apr 14, 2017
1 parent 46d98c3 commit 568aeac
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 41 deletions.
25 changes: 11 additions & 14 deletions app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,18 @@
import android.transition.Fade;
import android.transition.Slide;
import android.transition.TransitionSet;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowInsets;
import android.view.animation.AccelerateDecelerateInterpolator;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import us.koller.cameraroll.R;
import us.koller.cameraroll.adapter.album.RecyclerViewAdapter;
Expand Down Expand Up @@ -225,7 +222,7 @@ public void onClick(View view) {

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

private int statusBarColor = getColorPrimaryDark();
private int statusBarColor = getStatusBarColor();

@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
Expand All @@ -243,7 +240,8 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
}
toolbar.setTranslationY(translationY);

if (THEME == LIGHT) {
//animate statusBar color
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float animatedValue = (-translationY) / toolbar.getPaddingTop();
if (animatedValue > 1.0f) {
animatedValue = 1.0f;
Expand All @@ -254,16 +252,15 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
int animatedColor = Color.argb(alpha, Color.red(statusBarColor),
Color.green(statusBarColor), Color.blue(statusBarColor));

Window window = getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(animatedColor);
}
getWindow().setStatusBarColor(animatedColor);

animatedValue = (-translationY) / toolbar.getHeight();
if (animatedValue > 0.9f) {
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
} else {
Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
if (THEME == LIGHT) {
animatedValue = (-translationY) / toolbar.getHeight();
if (animatedValue > 0.9f) {
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
} else {
Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ public void onThemeApplied(int theme) {
toolbar.setTitleTextColor(ContextCompat.getColor(this, text_color_res));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int statusBarColorRes = theme == DARK ? R.color.black : R.color.grey_300;
getWindow().setStatusBarColor(ContextCompat.getColor(this, statusBarColorRes));
getWindow().setStatusBarColor(getStatusBarColor());
}

if (theme == LIGHT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,10 @@ public void onThemeApplied(int theme) {
fab.setBackgroundTintList(ColorStateList
.valueOf(ContextCompat.getColor(this, accent_color_res)));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(getStatusBarColor());
}

if (theme == ThemeableActivity.LIGHT) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setActivated(true);
Expand Down
26 changes: 11 additions & 15 deletions app/src/main/java/us/koller/cameraroll/ui/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package us.koller.cameraroll.ui;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
Expand Down Expand Up @@ -28,18 +27,15 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;

import us.koller.cameraroll.R;
import us.koller.cameraroll.adapter.main.RecyclerViewAdapter;
import us.koller.cameraroll.data.Album;
import us.koller.cameraroll.data.Provider.MediaProvider;
import us.koller.cameraroll.data.Settings;
import us.koller.cameraroll.ui.widget.GridMarginDecoration;
import us.koller.cameraroll.ui.widget.ParallaxImageView;
import us.koller.cameraroll.util.SortUtil;
import us.koller.cameraroll.util.Util;
import us.koller.cameraroll.util.animators.ColorFade;

public class MainActivity extends ThemeableActivity {

Expand Down Expand Up @@ -133,7 +129,7 @@ public void onClick(View view) {

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

private int statusBarColor = getColorPrimaryDark();
private int statusBarColor = getStatusBarColor();

@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
Expand All @@ -152,7 +148,8 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {

toolbar.setTranslationY(translationY);

if (THEME == LIGHT) {
//animate statusBar color
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float animatedValue = (-translationY) / toolbar.getPaddingTop();
if (animatedValue > 1.0f) {
animatedValue = 1.0f;
Expand All @@ -163,16 +160,15 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
int animatedColor = Color.argb(alpha, Color.red(statusBarColor),
Color.green(statusBarColor), Color.blue(statusBarColor));

Window window = getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(animatedColor);
}
getWindow().setStatusBarColor(animatedColor);

animatedValue = (-translationY) / toolbar.getHeight();
if (animatedValue > 0.9f) {
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
} else {
Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
if (THEME == LIGHT) {
animatedValue = (-translationY) / toolbar.getHeight();
if (animatedValue > 0.9f) {
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
} else {
Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ public void onThemeApplied(int theme) {
toolbar.setTitleTextColor(ContextCompat.getColor(this, text_color_res));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int statusBarColorRes = theme == DARK ? R.color.black : R.color.grey_300;
getWindow().setStatusBarColor(ContextCompat.getColor(this, statusBarColorRes));
getWindow().setStatusBarColor(getStatusBarColor());
}

if (theme == LIGHT) {
Expand Down
14 changes: 6 additions & 8 deletions app/src/main/java/us/koller/cameraroll/ui/ThemeableActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
Expand Down Expand Up @@ -160,14 +161,11 @@ private void setupTaskDescription() {
overviewIcon.recycle();
}

public int getColorPrimaryDark() {
int[] attrs = new int[]{R.attr.colorPrimaryDark};
TypedArray ta = obtainStyledAttributes(attrs);
int defColor = ContextCompat.getColor(this, R.color.colorPrimaryDark);
int colorPrimaryDark = ta.getColor(0, defColor);
ta.recycle();

return colorPrimaryDark;
public int getStatusBarColor() {
if (THEME == LIGHT) {
return Color.argb(20, 0, 0, 0);
}
return Color.argb(30, 0, 0, 0);
}
}

0 comments on commit 568aeac

Please sign in to comment.