Fixed UI problems introduced by dark theme.

This commit is contained in:
Alex Ning 2019-06-05 11:25:05 +08:00
parent c8d1a9e37a
commit 7d8c497c77
17 changed files with 27 additions and 35 deletions

Binary file not shown.

View File

@ -5,8 +5,8 @@ import javax.inject.Singleton;
import dagger.Component; import dagger.Component;
@Singleton @Singleton
@Component(modules = NetworkModule.class) @Component(modules = AppModule.class)
interface NetworkComponent { interface AppComponent {
void inject(MainActivity mainActivity); void inject(MainActivity mainActivity);
void inject(LoginActivity loginActivity); void inject(LoginActivity loginActivity);
void inject(PostFragment postFragment); void inject(PostFragment postFragment);

View File

@ -14,10 +14,10 @@ import retrofit2.Retrofit;
import retrofit2.converter.scalars.ScalarsConverterFactory; import retrofit2.converter.scalars.ScalarsConverterFactory;
@Module @Module
class NetworkModule { class AppModule {
Application mApplication; Application mApplication;
public NetworkModule(Application application) { public AppModule(Application application) {
mApplication = application; mApplication = application;
} }

View File

@ -79,11 +79,11 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
((CommentViewHolder) holder).commentTimeTextView.setText(commentItem.getCommentTime()); ((CommentViewHolder) holder).commentTimeTextView.setText(commentItem.getCommentTime());
SpannableConfiguration spannableConfiguration = SpannableConfiguration.builder(mContext).linkResolver((view, link) -> { SpannableConfiguration spannableConfiguration = SpannableConfiguration.builder(mContext).linkResolver((view, link) -> {
if (link.startsWith("/u/")) { if (link.startsWith("/u/") || link.startsWith("u/")) {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class); Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, link.substring(3)); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, link.substring(3));
mContext.startActivity(intent); mContext.startActivity(intent);
} else if (link.startsWith("/r/")) { } else if (link.startsWith("/r/") || link.startsWith("r/")) {
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class); Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, link.substring(3)); intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, link.substring(3));
mContext.startActivity(intent); mContext.startActivity(intent);

View File

@ -3,18 +3,18 @@ package ml.docilealligator.infinityforreddit;
import android.app.Application; import android.app.Application;
public class Infinity extends Application { public class Infinity extends Application {
private NetworkComponent mNetworkComponent; private AppComponent mAppComponent;
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
mNetworkComponent = DaggerNetworkComponent.builder() mAppComponent = DaggerAppComponent.builder()
.networkModule(new NetworkModule(this)) .appModule(new AppModule(this))
.build(); .build();
} }
public NetworkComponent getmNetworkComponent() { public AppComponent getmAppComponent() {
return mNetworkComponent; return mAppComponent;
} }
} }

View File

@ -41,7 +41,7 @@ public class LoginActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
((Infinity) getApplication()).getmNetworkComponent().inject(this); ((Infinity) getApplication()).getmAppComponent().inject(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@ -98,7 +98,7 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
ButterKnife.bind(this); ButterKnife.bind(this);
((Infinity) getApplication()).getmNetworkComponent().inject(this); ((Infinity) getApplication()).getmAppComponent().inject(this);
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);

View File

@ -83,7 +83,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_post, container, false); View rootView = inflater.inflate(R.layout.fragment_post, container, false);
((Infinity) getActivity().getApplication()).getmNetworkComponent().inject(this); ((Infinity) getActivity().getApplication()).getmAppComponent().inject(this);
ButterKnife.bind(this, rootView); ButterKnife.bind(this, rootView);
@ -91,14 +91,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mLinearLayoutManager = new LinearLayoutManager(getActivity()); mLinearLayoutManager = new LinearLayoutManager(getActivity());
mPostRecyclerView.setLayoutManager(mLinearLayoutManager); mPostRecyclerView.setLayoutManager(mLinearLayoutManager);
/*FloatingActionButton fab = rootView.findViewById(R.id.fab_post_fragment);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});*/
mPostType = getArguments().getInt(POST_TYPE_KEY); mPostType = getArguments().getInt(POST_TYPE_KEY);

View File

@ -238,7 +238,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
.into(((DataViewHolder) holder).subredditIconGifImageView); .into(((DataViewHolder) holder).subredditIconGifImageView);
} }
((DataViewHolder) holder).subredditNameTextView.setTextColor(mContext.getResources().getColor(R.color.colorPrimaryDark)); ((DataViewHolder) holder).subredditNameTextView.setTextColor(mContext.getResources().getColor(R.color.textColorPrimaryDark));
((DataViewHolder) holder).subredditNameTextView.setText(author); ((DataViewHolder) holder).subredditNameTextView.setText(author);
((DataViewHolder) holder).subredditIconNameLinearLayout.setOnClickListener(view -> { ((DataViewHolder) holder).subredditIconNameLinearLayout.setOnClickListener(view -> {

View File

@ -69,7 +69,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
// Inflate the layout for this fragment // Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_subreddit_listing, container, false); View rootView = inflater.inflate(R.layout.fragment_subreddit_listing, container, false);
((Infinity) getActivity().getApplication()).getmNetworkComponent().inject(this); ((Infinity) getActivity().getApplication()).getmAppComponent().inject(this);
ButterKnife.bind(this, rootView); ButterKnife.bind(this, rootView);

View File

@ -76,7 +76,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
// Inflate the layout for this fragment // Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_user_listing, container, false); View rootView = inflater.inflate(R.layout.fragment_user_listing, container, false);
((Infinity) getActivity().getApplication()).getmNetworkComponent().inject(this); ((Infinity) getActivity().getApplication()).getmAppComponent().inject(this);
ButterKnife.bind(this, rootView); ButterKnife.bind(this, rootView);

View File

@ -133,7 +133,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
((Infinity) getApplication()).getmNetworkComponent().inject(this); ((Infinity) getApplication()).getmAppComponent().inject(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -557,11 +557,11 @@ public class ViewPostDetailActivity extends AppCompatActivity {
private SpannableConfiguration getCustomSpannableConfiguration() { private SpannableConfiguration getCustomSpannableConfiguration() {
return SpannableConfiguration.builder(this).linkResolver((view, link) -> { return SpannableConfiguration.builder(this).linkResolver((view, link) -> {
if(link.startsWith("/u/")) { if(link.startsWith("/u/") || link.startsWith("u/")) {
Intent intent = new Intent(ViewPostDetailActivity.this, ViewUserDetailActivity.class); Intent intent = new Intent(ViewPostDetailActivity.this, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, link.substring(3)); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, link.substring(3));
startActivity(intent); startActivity(intent);
} else if(link.startsWith("/r/")) { } else if(link.startsWith("/r/") || link.startsWith("r/")) {
Intent intent = new Intent(ViewPostDetailActivity.this, ViewSubredditDetailActivity.class); Intent intent = new Intent(ViewPostDetailActivity.this, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, link.substring(3)); intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, link.substring(3));
startActivity(intent); startActivity(intent);

View File

@ -79,7 +79,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
setContentView(R.layout.activity_view_subreddit_detail); setContentView(R.layout.activity_view_subreddit_detail);
ButterKnife.bind(this); ButterKnife.bind(this);
((Infinity) getApplication()).getmNetworkComponent().inject(this); ((Infinity) getApplication()).getmAppComponent().inject(this);
//Get status bar height //Get status bar height
int statusBarHeight = 0; int statusBarHeight = 0;

View File

@ -76,7 +76,7 @@ public class ViewUserDetailActivity extends AppCompatActivity {
ButterKnife.bind(this); ButterKnife.bind(this);
((Infinity) getApplication()).getmNetworkComponent().inject(this); ((Infinity) getApplication()).getmAppComponent().inject(this);
//Get status bar height //Get status bar height
int statusBarHeight = 0; int statusBarHeight = 0;

View File

@ -50,7 +50,7 @@
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:tint="@color/textColorPrimaryDark" android:tint="@color/backgroundColorPrimaryDark"
android:visibility="gone" android:visibility="gone"
app:layout_constraintStart_toEndOf="@id/subreddit_icon_name_linear_layout_view_item_best_post" app:layout_constraintStart_toEndOf="@id/subreddit_icon_name_linear_layout_view_item_best_post"
app:layout_constraintEnd_toStartOf="@+id/post_time_text_view_best_post_item" app:layout_constraintEnd_toStartOf="@+id/post_time_text_view_best_post_item"

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#242424</color> <color name="colorPrimary">#242424</color>
<color name="colorPrimaryDark">#141414</color> <color name="colorPrimaryDark">#121212</color>
<color name="colorAccent">#FF4081</color> <color name="colorAccent">#FF4081</color>
<color name="minusButtonColor">#E91E63</color> <color name="minusButtonColor">#E91E63</color>
@ -20,7 +20,7 @@
<color name="grey">#424242</color> <color name="grey">#424242</color>
<color name="backgroundColor">#181818</color> <color name="backgroundColor">#121212</color>
<color name="backgroundColorPrimaryDark">#1976D2</color> <color name="backgroundColorPrimaryDark">#1565C0</color>
</resources> </resources>

View File

@ -14,7 +14,7 @@
<color name="textColorPrimaryDark">@color/colorPrimaryDark</color> <color name="textColorPrimaryDark">@color/colorPrimaryDark</color>
<color name="circularProgressBarBackground">#242424</color> <color name="circularProgressBarBackground">#FFFFFF</color>
<color name="dividerColor">#E0E0E0</color> <color name="dividerColor">#E0E0E0</color>