Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,9 @@ public class SearchActivity extends NavigationBaseActivity implements MediaDetai
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean currentThemeIsDark = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme", false);
setContentView(R.layout.activity_search);
ButterKnife.bind(this);
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));
toolbar.setNavigationOnClickListener(v->onBackPressed());
supportFragmentManager = getSupportFragmentManager();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package fr.free.nrw.commons.explore.recentsearches;

import android.content.Context;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -34,7 +32,6 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
ArrayAdapter adapter;
@BindView(R.id.recent_searches_delete_button)
ImageView recent_searches_delete_button;
boolean currentThemeIsDark = false;
@BindView(R.id.recent_searches_text_view)
TextView recent_searches_text_view;

Expand Down Expand Up @@ -68,13 +65,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
.create()
.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.setOnItemClickListener((parent, view, position, id) -> (
(SearchActivity)getContext()).updateText(recentSearches.get(position)));
adapter.notifyDataSetChanged();
updateRecentSearches();
return rootView;
}

Expand All @@ -84,8 +80,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
*/
@Override
public void onResume() {
recentSearches = recentSearchesDao.recentSearches(10);
adapter.notifyDataSetChanged();
updateRecentSearches();
super.onResume();
}

Expand All @@ -94,21 +89,11 @@ public void onResume() {
*/
public void updateRecentSearches() {
recentSearches = recentSearchesDao.recentSearches(10);
setAdapterForThemes(getContext(), currentThemeIsDark);
recentSearchesList.setAdapter(adapter);
adapter.notifyDataSetChanged();

if(!recentSearches.isEmpty()) {
recent_searches_delete_button.setVisibility(View.VISIBLE);
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 change: 0 additions & 1 deletion app/src/main/res/layout/item_recent_searches.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/textView1"
android:layout_width="match_parent"
android:background="@color/item_white_background"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="@dimen/standard_gap"
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/res/layout/item_recent_searches_dark_theme.xml

This file was deleted.