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 17, 2017
1 parent 568aeac commit d55ad2a
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
Expand Down Expand Up @@ -128,6 +129,9 @@ public Object instantiateItem(ViewGroup container, int position) {
.load(imageRess[position])
.into(imageView);

imageView.setColorFilter(ContextCompat
.getColor(container.getContext(), R.color.colorAccent));

container.addView(view);
return view;
}
Expand Down
43 changes: 17 additions & 26 deletions app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
toolbar.setNavigationIcon(navIcon);
}
Util.setDarkStatusBarIcons(findViewById(R.id.root_view));

Util.colorToolbarOverflowMenuIcon(toolbar,
ContextCompat.getColor(this, R.color.grey_900_translucent));
}

toolbar.setNavigationOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -221,9 +224,6 @@ public void onClick(View view) {
}

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

private int statusBarColor = getStatusBarColor();

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

//animate statusBar color
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float animatedValue = (-translationY) / toolbar.getPaddingTop();
if (animatedValue > 1.0f) {
animatedValue = 1.0f;
}
animatedValue = 1.0f - animatedValue;

int alpha = (int) (Color.alpha(statusBarColor) * animatedValue);
int animatedColor = Color.argb(alpha, Color.red(statusBarColor),
Color.green(statusBarColor), Color.blue(statusBarColor));

getWindow().setStatusBarColor(animatedColor);

if (THEME == LIGHT) {
animatedValue = (-translationY) / toolbar.getHeight();
//animate statusBarIcon color
if (THEME == LIGHT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float animatedValue = (-translationY) / toolbar.getHeight();
if (animatedValue > 0.9f) {
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
} else {
Expand Down Expand Up @@ -444,10 +432,10 @@ protected void onPostResume() {

@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (!pick_photos) {
getMenuInflater().inflate(R.menu.album, menu);
this.menu = menu;
getMenuInflater().inflate(R.menu.album, menu);
this.menu = menu;

if (!pick_photos) {
//set share icon tint
Drawable icon = menu.findItem(R.id.share).getIcon().mutate();
icon = DrawableCompat.wrap(icon);
Expand All @@ -461,6 +449,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
Provider.getExcludedPaths());
menu.findItem(R.id.exclude).setEnabled(enabled);
menu.findItem(R.id.exclude).setChecked(album.excluded || !enabled);
} else {
menu.findItem(R.id.share).setVisible(false);
menu.findItem(R.id.exclude).setVisible(false);
}

int sort_by = Settings.getInstance(this).sortAlbumBy();
Expand Down Expand Up @@ -829,6 +820,10 @@ public void setTitle(Toolbar toolbar) {
ContextCompat.getColor(this, R.color.grey_900_translucent),
ContextCompat.getColor(this, text_color_secondary_res));

if (THEME != ThemeableActivity.LIGHT) {
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
}

Drawable navIcon = toolbar.getNavigationIcon();
if (navIcon instanceof Animatable) {
((Animatable) navIcon).start();
Expand All @@ -855,10 +850,6 @@ public void run() {
text_color_secondary_res));
toolbar.setNavigationIcon(d);

if (THEME != ThemeableActivity.LIGHT) {
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
}

menu.findItem(R.id.exclude).setVisible(true);
menu.findItem(R.id.share).setVisible(false);
menu.findItem(R.id.copy).setVisible(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ public void onThemeApplied(int theme) {
toolbar.setBackgroundColor(ContextCompat.getColor(this, toolbar_color_res));
toolbar.setTitleTextColor(ContextCompat.getColor(this, text_color_res));

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

if (theme == LIGHT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,12 +704,14 @@ public void run() {
Drawable d;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AnimatedVectorDrawable drawable = (AnimatedVectorDrawable)
ContextCompat.getDrawable(FileExplorerActivity.this, R.drawable.cancel_to_back_avd);
ContextCompat.getDrawable(FileExplorerActivity.this,
R.drawable.cancel_to_back_avd);
//mutating avd to reset it
drawable.mutate();
d = drawable;
} else {
d = ContextCompat.getDrawable(FileExplorerActivity.this, R.drawable.ic_arrow_back_white_24dp);
d = ContextCompat.getDrawable(FileExplorerActivity.this,
R.drawable.ic_arrow_back_white_24dp);
}
d = DrawableCompat.wrap(d);
DrawableCompat.setTint(d.mutate(),
Expand Down Expand Up @@ -878,8 +880,9 @@ public void setTitle(Toolbar toolbar) {
public void resetToolbar() {
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

if (THEME != ThemeableActivity.LIGHT) {
if (THEME != LIGHT) {
toolbar.setActivated(false);
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
}

ColorFade.fadeBackgroundColor(toolbar,
Expand Down Expand Up @@ -926,19 +929,6 @@ public void run() {
text_color_secondary_res));
toolbar.setNavigationIcon(d);

if (THEME != ThemeableActivity.LIGHT) {
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
}

/*int color = ContextCompat.getColor(FileExplorerActivity.this, text_color_res);
ColorFade.fadeToolbarTitleColor(toolbar, color,
new ColorFade.ToolbarTitleFadeCallback() {
@Override
public void setTitle(Toolbar toolbar) {
toolbar.setTitle(currentDir.getPath());
}
}, false);*/

//hide menu items
for (int i = 0; i < menu.size(); i++) {
int id = menu.getItem(i).getItemId();
Expand Down Expand Up @@ -967,10 +957,6 @@ 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
27 changes: 5 additions & 22 deletions app/src/main/java/us/koller/cameraroll/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ public void onClick(View view) {
recyclerView.setAdapter(recyclerViewAdapter);

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

private int statusBarColor = getStatusBarColor();

@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
Expand All @@ -148,22 +145,10 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {

toolbar.setTranslationY(translationY);

//animate statusBar color
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float animatedValue = (-translationY) / toolbar.getPaddingTop();
if (animatedValue > 1.0f) {
animatedValue = 1.0f;
}
animatedValue = 1.0f - animatedValue;

int alpha = (int) (Color.alpha(statusBarColor) * animatedValue);
int animatedColor = Color.argb(alpha, Color.red(statusBarColor),
Color.green(statusBarColor), Color.blue(statusBarColor));

getWindow().setStatusBarColor(animatedColor);

if (THEME == LIGHT) {
animatedValue = (-translationY) / toolbar.getHeight();
//animate statusBarIcon color
if (THEME == LIGHT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float animatedValue = (-translationY) / toolbar.getHeight();
if (animatedValue > 0.9f) {
Util.setLightStatusBarIcons(findViewById(R.id.root_view));
} else {
Expand Down Expand Up @@ -193,7 +178,7 @@ public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setLayoutParams(toolbarParams);

recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(),
recyclerView.getPaddingTop() + (pick_photos ? 0 : +insets.getSystemWindowInsetTop()),
recyclerView.getPaddingTop() + (pick_photos ? 0 : insets.getSystemWindowInsetTop()),
recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(),
recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom());

Expand All @@ -218,8 +203,6 @@ public void onGlobalLayout() {
Math.abs(screenSize[2] - rootView.getRight()),
Math.abs(screenSize[3] - rootView.getBottom())};

Log.d("MainActivity", "windowInsets: " + Arrays.toString(windowInsets));

toolbar.setPadding(toolbar.getPaddingStart(),
toolbar.getPaddingTop() + windowInsets[1],
toolbar.getPaddingEnd(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ public void onThemeApplied(int theme) {
toolbar.setBackgroundColor(ContextCompat.getColor(this, toolbar_color_res));
toolbar.setTitleTextColor(ContextCompat.getColor(this, text_color_res));

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

if (theme == LIGHT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
Expand Down
36 changes: 29 additions & 7 deletions app/src/main/java/us/koller/cameraroll/ui/ThemeableActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -90,8 +93,7 @@ public void setColors() {
text_color_secondary_res = dark ? R.color.white_translucent1
: R.color.grey_900_translucent;

accent_color_res = dark ? R.color.colorAccent
: R.color.colorAccent_light;
accent_color_res = R.color.colorAccent;
}

public void setViewBgColors() {
Expand All @@ -106,7 +108,6 @@ public void setViewBgColors() {

int bg_color = ContextCompat.getColor(this, bg_color_res);
for (int i = 0; i < views.size(); i++) {
Log.d("ThemeableActivity", "setViewBgColor");
views.get(i).setBackgroundColor(bg_color);
}
}
Expand Down Expand Up @@ -161,11 +162,32 @@ private void setupTaskDescription() {
overviewIcon.recycle();
}

public int getStatusBarColor() {
if (THEME == LIGHT) {
return Color.argb(20, 0, 0, 0);
public void addStatusBarOverlay(final Toolbar toolbar,
int toolbarColor,
final int statusBarHeight) {
float darken = 0.9f;
if (toolbarColor == -1) {
toolbarColor = ContextCompat
.getColor(this, toolbar_color_res);
}
return Color.argb(30, 0, 0, 0);
int statusBarColor = Color.argb(
(int) (Color.alpha(toolbarColor) * darken),
(int) (Color.red(toolbarColor) * darken),
(int) (Color.green(toolbarColor) * darken),
(int) (Color.blue(toolbarColor) * darken));

final Drawable statusBarOverlay
= new ColorDrawable(statusBarColor);

toolbar.post(new Runnable() {
@Override
public void run() {
toolbar.getOverlay().clear();
statusBarOverlay.setBounds(0, 0,
toolbar.getWidth(), statusBarHeight);
toolbar.getOverlay().add(statusBarOverlay);
}
});
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.Toolbar;

import us.koller.cameraroll.R;
import us.koller.cameraroll.util.Util;

//Solution heavily inspired by: https://github.com/WangDaYeeeeee/Mysplash/blob/master/app/src/main/res/about/layout/activity_about.xml

Expand Down Expand Up @@ -132,12 +136,10 @@ private void reset() {
}

private void setSwipeTranslation() {
setTranslationY((float) (1.0 * swipeDistance / SWIPE_RADIO));
float translationY = (float) (1.0 * swipeDistance / SWIPE_RADIO);
setTranslationY(translationY);
if (listener != null) {
listener.onSwipeProcess(
(float) Math.min(
1,
Math.abs(1.0 * swipeDistance / SWIPE_TRIGGER)));
listener.onSwipeProcess(Math.min(1, Math.abs(translationY)));
}
}

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/us/koller/cameraroll/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ public void run() {
}
}

public static boolean areStatusBarIconsDark(final View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return v.getSystemUiVisibility() != 0;
}
return false;
}

public static String getParentPath(String path) {
return new File(path).getParent();
}
Expand Down
Binary file modified app/src/main/res/drawable/style_cards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/style_parallax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions app/src/main/res/layout/pref_dialog_style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
android:orientation="vertical"
android:paddingTop="18dp">

<!--<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>-->

<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/pref_dialog_style_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:fontFamily="monospace"
android:layout_gravity="center_horizontal"
android:layout_margin="16dp" />
android:layout_margin="16dp"
android:fontFamily="monospace"
android:textSize="18sp" />

<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="32dp"
android:layout_gravity="center_horizontal" />
android:layout_gravity="center_horizontal"
android:layout_margin="16dp"
android:layout_weight="1" />
</LinearLayout>
Loading

0 comments on commit d55ad2a

Please sign in to comment.