From 2913c1583b8001ebdf75babb2d663f3cf9167ca9 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sun, 11 Aug 2019 16:44:46 +0800 Subject: Make nav bar white in day theme and change it to the same color as background color in some activities. Fixed nav bar icon color in dark theme. Minor UI tweaks. --- .../CommentsListingRecyclerViewAdapter.java | 19 +++++++------------ .../infinityforreddit/MainActivity.java | 2 +- .../infinityforreddit/PostImageActivity.java | 11 +++++++++++ .../infinityforreddit/PostLinkActivity.java | 12 ++++++++++++ .../infinityforreddit/PostTextActivity.java | 12 ++++++++++++ .../infinityforreddit/PostVideoActivity.java | 11 +++++++++++ .../infinityforreddit/SearchActivity.java | 12 ++++++++++++ 7 files changed, 66 insertions(+), 13 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java index 6cd7d189..9a7fa962 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java @@ -7,19 +7,17 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.cardview.widget.CardView; import androidx.core.content.ContextCompat; import androidx.paging.PagedListAdapter; import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.material.card.MaterialCardView; - import CustomView.CustomMarkwonView; import butterknife.BindView; import butterknife.ButterKnife; @@ -70,14 +68,11 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter { + linearLayout.setOnClickListener(view -> { Intent intent = new Intent(mContext, ViewPostDetailActivity.class); intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, getItem(getAdapterPosition()).getLinkId()); mContext.startActivity(intent); @@ -188,7 +183,7 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter cardView.callOnClick()); + commentMarkdownView.setOnClickListener(view -> linearLayout.callOnClick()); RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) shareButton.getLayoutParams(); lp.addRule(RelativeLayout.ALIGN_PARENT_END); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index 3fd746aa..14b76146 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -149,7 +149,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe int statusBarResourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (statusBarResourceId > 0) { ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); - params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId); + params.topMargin = resources.getDimensionPixelSize(statusBarResourceId); toolbar.setLayoutParams(params); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostImageActivity.java index 2c22b131..823fa1cd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostImageActivity.java @@ -1,6 +1,7 @@ package ml.docilealligator.infinityforreddit; import android.content.Intent; +import android.content.res.Configuration; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -9,6 +10,7 @@ import android.provider.MediaStore; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.Window; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; @@ -20,6 +22,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; import com.bumptech.glide.Glide; @@ -127,6 +130,14 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS ((Infinity) getApplication()).getAppComponent().inject(this); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + Window window = getWindow(); + if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor)); + } + setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java index e8d028ec..4960b627 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java @@ -1,10 +1,13 @@ package ml.docilealligator.infinityforreddit; import android.content.Intent; +import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.Window; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; @@ -14,6 +17,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.content.ContextCompat; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; @@ -102,6 +106,14 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh ((Infinity) getApplication()).getAppComponent().inject(this); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + Window window = getWindow(); + if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor)); + } + setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java index 6b8784de..e4e94243 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java @@ -1,10 +1,13 @@ package ml.docilealligator.infinityforreddit; import android.content.Intent; +import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.Window; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; @@ -14,6 +17,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.content.ContextCompat; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; @@ -102,6 +106,14 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh ((Infinity) getApplication()).getAppComponent().inject(this); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + Window window = getWindow(); + if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor)); + } + setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java index 6adf0c75..919502f1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java @@ -1,6 +1,7 @@ package ml.docilealligator.infinityforreddit; import android.content.Intent; +import android.content.res.Configuration; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -8,6 +9,7 @@ import android.provider.MediaStore; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.Window; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; @@ -19,6 +21,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.content.ContextCompat; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; @@ -126,6 +129,14 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS ((Infinity) getApplication()).getAppComponent().inject(this); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + Window window = getWindow(); + if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor)); + } + setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchActivity.java index e0bedcdf..cfade0b9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchActivity.java @@ -2,10 +2,13 @@ package ml.docilealligator.infinityforreddit; import android.app.Activity; import android.content.Intent; +import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.Window; import android.view.WindowManager; import android.widget.RelativeLayout; import android.widget.TextView; @@ -14,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import androidx.core.content.ContextCompat; import com.ferfalk.simplesearchview.SimpleSearchView; @@ -49,6 +53,14 @@ public class SearchActivity extends AppCompatActivity { ButterKnife.bind(this); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + Window window = getWindow(); + if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + } + window.setNavigationBarColor(ContextCompat.getColor(this, R.color.navBarColor)); + } + setSupportActionBar(toolbar); boolean searchOnlySubreddits = getIntent().getExtras().getBoolean(EXTRA_SEARCH_ONLY_SUBREDDITS); -- cgit v1.2.3