From a4b93699d8f5649ada3a3c1e20ac7a3a18735875 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 18 Jun 2019 21:27:40 +0800 Subject: Minor UI tweaks. --- .../infinityforreddit/ViewImageActivity.java | 104 +++++++++------------ .../ViewSubredditDetailActivity.java | 4 +- .../infinityforreddit/ViewUserDetailActivity.java | 4 +- .../infinityforreddit/ViewVideoActivity.java | 51 +++++----- .../main/res/layout/activity_view_post_detail.xml | 5 - app/src/main/res/layout/item_post.xml | 1 + 6 files changed, 71 insertions(+), 98 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java index e610d28d..69ed511a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java @@ -8,6 +8,7 @@ import android.annotation.SuppressLint; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; +import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -15,12 +16,6 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Environment; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatActivity; import android.text.Spannable; import android.text.SpannableString; import android.text.style.ForegroundColorSpan; @@ -33,6 +28,13 @@ import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + import com.alexvasilkov.gestures.GestureController; import com.alexvasilkov.gestures.State; import com.alexvasilkov.gestures.views.GestureImageView; @@ -89,25 +91,25 @@ public class ViewImageActivity extends AppCompatActivity { setContentView(R.layout.activity_view_image); ButterKnife.bind(this); - final ActionBar actionBar = getSupportActionBar(); - final Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); + ActionBar actionBar = getSupportActionBar(); + Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); actionBar.setHomeAsUpIndicator(upArrow); + actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarColor))); Intent intent = getIntent(); mImageUrl = intent.getExtras().getString(IMAGE_URL_KEY); mImageFileName = intent.getExtras().getString(FILE_NAME_KEY); + String title = intent.getExtras().getString(TITLE_KEY); - final Spannable text = new SpannableString(title); + Spannable text = new SpannableString(title); + text.setSpan(new ForegroundColorSpan(Color.WHITE), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); setTitle(text); - mLoadErrorLinearLayout.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if(!isSwiping) { - mProgressBar.setVisibility(View.VISIBLE); - mLoadErrorLinearLayout.setVisibility(View.GONE); - loadImage(); - } + mLoadErrorLinearLayout.setOnClickListener(view -> { + if(!isSwiping) { + mProgressBar.setVisibility(View.VISIBLE); + mLoadErrorLinearLayout.setVisibility(View.GONE); + loadImage(); } }); @@ -126,31 +128,18 @@ public class ViewImageActivity extends AppCompatActivity { actionBarColorAnimation.setDuration(300); actionBarElementColorAnimation.setDuration(300); - activityColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - mRelativeLayout.setBackgroundColor((int) valueAnimator.getAnimatedValue()); - } - }); + activityColorAnimation.addUpdateListener(valueAnimator -> mRelativeLayout.setBackgroundColor((int) valueAnimator.getAnimatedValue())); - actionBarColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - actionBar.setBackgroundDrawable(new ColorDrawable((int) valueAnimator.getAnimatedValue())); - } - }); + actionBarColorAnimation.addUpdateListener(valueAnimator -> actionBar.setBackgroundDrawable(new ColorDrawable((int) valueAnimator.getAnimatedValue()))); - actionBarElementColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - text.setSpan(new ForegroundColorSpan((int) valueAnimator.getAnimatedValue()), 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); - actionBar.setTitle(text); - upArrow.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); - if(mMenu != null) { - Drawable drawable = mMenu.getItem(0).getIcon(); - //drawable.mutate(); - drawable.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); - } + actionBarElementColorAnimation.addUpdateListener(valueAnimator -> { + text.setSpan(new ForegroundColorSpan((int) valueAnimator.getAnimatedValue()), 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); + actionBar.setTitle(text); + upArrow.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); + if(mMenu != null) { + Drawable drawable = mMenu.getItem(0).getIcon(); + //drawable.mutate(); + drawable.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); } }); @@ -316,25 +305,22 @@ public class ViewImageActivity extends AppCompatActivity { mImageView.getController().getSettings().setPanEnabled(true); - mImageView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (isActionBarHidden) { - getWindow().getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - isActionBarHidden = false; - } else { - getWindow().getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE); - isActionBarHidden = true; - } + mImageView.setOnClickListener(view -> { + if (isActionBarHidden) { + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + isActionBarHidden = false; + } else { + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE); + isActionBarHidden = true; } }); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java index 37171a8a..ccc9b6de 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java @@ -192,7 +192,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity { @Override public void onSubredditSubscriptionSuccess() { subscribeSubredditChip.setText(R.string.subscribe); - subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.textColorPrimaryDark)); + subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark)); makeSnackbar(R.string.unsubscribed); subscriptionReady = true; } @@ -219,7 +219,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity { @Override public void isNotSubscribed() { subscribeSubredditChip.setText(R.string.subscribe); - subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.textColorPrimaryDark)); + subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark)); subscriptionReady = true; } }).execute(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java index 787b2e0e..fc3be116 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java @@ -180,7 +180,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { @Override public void onUserFollowingSuccess() { subscribeUserChip.setText(R.string.follow); - subscribeUserChip.setChipBackgroundColor(getResources().getColorStateList(R.color.textColorPrimaryDark)); + subscribeUserChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark)); makeSnackbar(R.string.unfollowed); subscriptionReady = true; } @@ -206,7 +206,7 @@ public class ViewUserDetailActivity extends AppCompatActivity { @Override public void isNotSubscribed() { subscribeUserChip.setText(R.string.follow); - subscribeUserChip.setChipBackgroundColor(getResources().getColorStateList(R.color.textColorPrimaryDark)); + subscribeUserChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark)); subscriptionReady = true; } }).execute(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java index 6ef9b47e..1d164bb3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java @@ -8,6 +8,7 @@ import android.app.DownloadManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; +import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -16,11 +17,6 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; -import androidx.annotation.NonNull; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatActivity; import android.text.Spannable; import android.text.SpannableString; import android.text.style.ForegroundColorSpan; @@ -33,6 +29,12 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + import com.github.pwittchen.swipe.library.rx2.SimpleSwipeListener; import com.github.pwittchen.swipe.library.rx2.Swipe; import com.google.android.exoplayer2.ExoPlayerFactory; @@ -91,8 +93,9 @@ public class ViewVideoActivity extends AppCompatActivity { ButterKnife.bind(this); setVolumeControlStream(AudioManager.STREAM_MUSIC); - final ActionBar actionBar = getSupportActionBar(); - final Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); + ActionBar actionBar = getSupportActionBar(); + actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarColor))); + Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); getSupportActionBar().setHomeAsUpIndicator(upArrow); //Set player controller margin bottom in order to display it above the navbar @@ -106,7 +109,8 @@ public class ViewVideoActivity extends AppCompatActivity { mIsDashVideo = intent.getExtras().getBoolean(IS_DASH_VIDEO_KEY); String title = intent.getExtras().getString(TITLE_KEY); - final Spannable text = new SpannableString(title); + Spannable text = new SpannableString(title); + text.setSpan(new ForegroundColorSpan(Color.WHITE), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); setTitle(text); if(intent.getExtras().getBoolean(IS_DOWNLOADABLE_KEY)) { @@ -130,30 +134,17 @@ public class ViewVideoActivity extends AppCompatActivity { actionBarColorAnimation.setDuration(300); actionBarElementColorAnimation.setDuration(300); - activityColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - relativeLayout.setBackgroundColor((int) valueAnimator.getAnimatedValue()); - } - }); + activityColorAnimation.addUpdateListener(valueAnimator -> relativeLayout.setBackgroundColor((int) valueAnimator.getAnimatedValue())); - actionBarColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - actionBar.setBackgroundDrawable(new ColorDrawable((int) valueAnimator.getAnimatedValue())); - } - }); + actionBarColorAnimation.addUpdateListener(valueAnimator -> actionBar.setBackgroundDrawable(new ColorDrawable((int) valueAnimator.getAnimatedValue()))); - actionBarElementColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - text.setSpan(new ForegroundColorSpan((int) valueAnimator.getAnimatedValue()), 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); - actionBar.setTitle(text); - upArrow.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); - if(mMenu != null) { - Drawable drawable = mMenu.getItem(0).getIcon(); - drawable.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); - } + actionBarElementColorAnimation.addUpdateListener(valueAnimator -> { + text.setSpan(new ForegroundColorSpan((int) valueAnimator.getAnimatedValue()), 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); + actionBar.setTitle(text); + upArrow.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); + if(mMenu != null) { + Drawable drawable = mMenu.getItem(0).getIcon(); + drawable.setColorFilter((int) valueAnimator.getAnimatedValue(), PorterDuff.Mode.SRC_IN); } }); diff --git a/app/src/main/res/layout/activity_view_post_detail.xml b/app/src/main/res/layout/activity_view_post_detail.xml index 99056019..0c9f6786 100644 --- a/app/src/main/res/layout/activity_view_post_detail.xml +++ b/app/src/main/res/layout/activity_view_post_detail.xml @@ -319,11 +319,6 @@ android:textColor="@color/primaryTextColor" android:textSize="18sp" /> - -