mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Fix night mode issues with search and categories (#2213)
This commit is contained in:
parent
55113b3018
commit
5317063689
4 changed files with 4 additions and 36 deletions
|
|
@ -58,16 +58,9 @@ public class SearchActivity extends NavigationBaseActivity implements MediaDetai
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
boolean currentThemeIsDark = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme", false);
|
|
||||||
setContentView(R.layout.activity_search);
|
setContentView(R.layout.activity_search);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
initDrawer();
|
initDrawer();
|
||||||
if (currentThemeIsDark) {
|
|
||||||
searchView.setBackgroundResource(R.color.vpi__bright_foreground_disabled_holo_dark);
|
|
||||||
tabLayout.setBackgroundResource(R.color.vpi__bright_foreground_disabled_holo_dark);
|
|
||||||
toolbar.setBackgroundResource(R.color.vpi__bright_foreground_disabled_holo_dark);
|
|
||||||
viewPager.setBackgroundResource(R.color.vpi__bright_foreground_disabled_holo_dark);
|
|
||||||
}
|
|
||||||
setTitle(getString(R.string.title_activity_search));
|
setTitle(getString(R.string.title_activity_search));
|
||||||
toolbar.setNavigationOnClickListener(v->onBackPressed());
|
toolbar.setNavigationOnClickListener(v->onBackPressed());
|
||||||
supportFragmentManager = getSupportFragmentManager();
|
supportFragmentManager = getSupportFragmentManager();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package fr.free.nrw.commons.explore.recentsearches;
|
package fr.free.nrw.commons.explore.recentsearches;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -34,7 +32,6 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
ArrayAdapter adapter;
|
ArrayAdapter adapter;
|
||||||
@BindView(R.id.recent_searches_delete_button)
|
@BindView(R.id.recent_searches_delete_button)
|
||||||
ImageView recent_searches_delete_button;
|
ImageView recent_searches_delete_button;
|
||||||
boolean currentThemeIsDark = false;
|
|
||||||
@BindView(R.id.recent_searches_text_view)
|
@BindView(R.id.recent_searches_text_view)
|
||||||
TextView recent_searches_text_view;
|
TextView recent_searches_text_view;
|
||||||
|
|
||||||
|
|
@ -68,13 +65,12 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
.create()
|
.create()
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
currentThemeIsDark = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("theme", false);
|
|
||||||
setAdapterForThemes(getContext(), currentThemeIsDark);
|
adapter = new ArrayAdapter<>(requireContext(), R.layout.item_recent_searches, recentSearches);
|
||||||
|
|
||||||
recentSearchesList.setAdapter(adapter);
|
recentSearchesList.setAdapter(adapter);
|
||||||
recentSearchesList.setOnItemClickListener((parent, view, position, id) -> (
|
recentSearchesList.setOnItemClickListener((parent, view, position, id) -> (
|
||||||
(SearchActivity)getContext()).updateText(recentSearches.get(position)));
|
(SearchActivity)getContext()).updateText(recentSearches.get(position)));
|
||||||
adapter.notifyDataSetChanged();
|
updateRecentSearches();
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,8 +80,7 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
recentSearches = recentSearchesDao.recentSearches(10);
|
updateRecentSearches();
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,8 +89,6 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
*/
|
*/
|
||||||
public void updateRecentSearches() {
|
public void updateRecentSearches() {
|
||||||
recentSearches = recentSearchesDao.recentSearches(10);
|
recentSearches = recentSearchesDao.recentSearches(10);
|
||||||
setAdapterForThemes(getContext(), currentThemeIsDark);
|
|
||||||
recentSearchesList.setAdapter(adapter);
|
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
if(!recentSearches.isEmpty()) {
|
if(!recentSearches.isEmpty()) {
|
||||||
|
|
@ -103,12 +96,4 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
recent_searches_text_view.setText(R.string.search_recent_header);
|
recent_searches_text_view.setText(R.string.search_recent_header);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAdapterForThemes(Context context, boolean currentThemeIsDark) {
|
|
||||||
if (currentThemeIsDark) {
|
|
||||||
adapter = new ArrayAdapter<String>(context, R.layout.item_recent_searches_dark_theme, recentSearches);
|
|
||||||
} else {
|
|
||||||
adapter = new ArrayAdapter<String>(context, R.layout.item_recent_searches, recentSearches);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TextView android:id="@+id/textView1"
|
<TextView android:id="@+id/textView1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:background="@color/item_white_background"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:padding="@dimen/standard_gap"
|
android:padding="@dimen/standard_gap"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/textView2"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@color/vpi__bright_foreground_disabled_holo_dark"
|
|
||||||
android:padding="@dimen/standard_gap"
|
|
||||||
android:text="@string/search_commons"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue