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.

This commit is contained in:
Alex Ning 2019-08-11 16:44:46 +08:00
parent c2f2fc1b39
commit 2913c1583b
12 changed files with 460 additions and 421 deletions

View File

@ -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<CommentData, R
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if(viewType == VIEW_TYPE_DATA) {
CardView cardView = (CardView) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false);
return new DataViewHolder(cardView);
return new DataViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false));
} else if(viewType == VIEW_TYPE_ERROR) {
RelativeLayout relativeLayout = (RelativeLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false);
return new ErrorViewHolder(relativeLayout);
return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
} else {
RelativeLayout relativeLayout = (RelativeLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_loading, parent, false);
return new LoadingViewHolder(relativeLayout);
return new LoadingViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_loading, parent, false));
}
}
@ -165,7 +160,7 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R
}
class DataViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.card_view_item_comment) MaterialCardView cardView;
@BindView(R.id.linear_layout_item_comment) LinearLayout linearLayout;
@BindView(R.id.vertical_block_item_post_comment) View verticalBlock;
@BindView(R.id.author_text_view_item_post_comment) TextView authorTextView;
@BindView(R.id.comment_time_text_view_item_post_comment) TextView commentTimeTextView;
@ -180,7 +175,7 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R
super(itemView);
ButterKnife.bind(this, itemView);
cardView.setOnClickListener(view -> {
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<CommentData, R
verticalBlock.setVisibility(View.GONE);
commentMarkdownView.setOnClickListener(view -> cardView.callOnClick());
commentMarkdownView.setOnClickListener(view -> linearLayout.callOnClick());
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) shareButton.getLayoutParams();
lp.addRule(RelativeLayout.ALIGN_PARENT_END);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view_item_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear_layout_item_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -136,5 +132,3 @@
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

View File

@ -1,9 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -23,5 +19,3 @@
android:textColor="@color/primaryTextColor" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

View File

@ -1,12 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
@ -298,5 +294,3 @@
</RelativeLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

View File

@ -41,4 +41,6 @@
<color name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</color>
<color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color>
<color name="navBarColor">@color/backgroundColor</color>
</resources>

View File

@ -41,4 +41,6 @@
<color name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</color>
<color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color>
<color name="navBarColor">#FFFFFF</color>
</resources>