Dbrant has uploaded a new change for review.
https://gerrit.wikimedia.org/r/173087
Change subject: Styling tweaks for Search.
......................................................................
Styling tweaks for Search.
- Make Title/Full buttons fill up the whole width, and update the button
background to match the currently selected search type.
- Put "delete recent" button outside of ActionBar menu, to the right of
"Recent searches" text.
Change-Id: I21c5faa5de57e3bd4324810e77236f787b2144d0
---
M wikipedia/res/layout/fragment_search.xml
M wikipedia/res/layout/fragment_search_full.xml
M wikipedia/res/layout/fragment_search_recent.xml
M wikipedia/res/values-qq/strings.xml
M wikipedia/res/values/attrs.xml
M wikipedia/res/values/colors.xml
M wikipedia/res/values/strings.xml
M wikipedia/res/values/styles_wikidark.xml
M wikipedia/res/values/styles_wikilight.xml
M wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java
10 files changed, 85 insertions(+), 58 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia
refs/changes/87/173087/1
diff --git a/wikipedia/res/layout/fragment_search.xml
b/wikipedia/res/layout/fragment_search.xml
index 28df6b5..baa83c0 100644
--- a/wikipedia/res/layout/fragment_search.xml
+++ b/wikipedia/res/layout/fragment_search.xml
@@ -6,8 +6,8 @@
android:id="@+id/search_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="?attr/window_background_color"
- android:paddingTop="@dimen/actionBarHeight">
+ android:background="?attr/search_background_color"
+ android:paddingTop="?attr/actionBarSize">
<LinearLayout
android:id="@+id/search_panel_types"
@@ -18,29 +18,34 @@
<LinearLayout
android:id="@+id/search_type_button_container"
android:orientation="horizontal"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="4dp"
- android:layout_marginBottom="8dp"
android:layout_gravity="center_horizontal">
<Button
- android:layout_width="140dp"
- android:layout_height="32dp"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"
+ android:maxWidth="120dp"
+ android:layout_weight="0.5"
android:id="@+id/button_search_title"
- android:background="@drawable/button_shape_flat"
+ android:background="?attr/window_background_color"
android:text="@string/search_titles_button"
- style="?android:textAppearanceSmall"
/>
+
+ <View android:layout_width="0.5dp"
android:layout_height="match_parent"
android:background="?attr/list_separator_color" />
+
<Button
- android:layout_width="140dp"
- android:layout_height="32dp"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"
+ android:maxWidth="120dp"
+ android:layout_weight="0.5"
android:id="@+id/button_search_full"
- android:background="@drawable/button_shape_flat"
+ android:background="?attr/window_background_color"
android:text="@string/search_full_button"
- style="?android:textAppearanceSmall"
/>
</LinearLayout>
+ <View android:layout_width="match_parent"
android:layout_height="0.5dp" android:background="?attr/list_separator_color" />
+
<FrameLayout
android:id="@+id/search_types_container"
android:layout_width="match_parent"
diff --git a/wikipedia/res/layout/fragment_search_full.xml
b/wikipedia/res/layout/fragment_search_full.xml
index 7394c75..1f9ddf9 100644
--- a/wikipedia/res/layout/fragment_search_full.xml
+++ b/wikipedia/res/layout/fragment_search_full.xml
@@ -29,14 +29,13 @@
android:layout_gravity="center_horizontal"
android:visibility="gone"
android:layout_marginTop="8dp"
- android:layout_marginBottom="8dp"
+ android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
<ListView
android:id="@+id/full_search_results_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:dividerHeight="0dp"
/>
diff --git a/wikipedia/res/layout/fragment_search_recent.xml
b/wikipedia/res/layout/fragment_search_recent.xml
index 3b253b7..da0421a 100644
--- a/wikipedia/res/layout/fragment_search_recent.xml
+++ b/wikipedia/res/layout/fragment_search_recent.xml
@@ -5,12 +5,32 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recent_searches_container">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="8dp"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/search_recent_header" />
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="48dp"
+ android:layout_gravity="start"
+ android:gravity="center_vertical"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold"
+ android:text="@string/search_recent_header" />
+ <ImageView
+ android:id="@+id/recent_searches_delete_button"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_gravity="end"
+ android:clickable="true"
+ android:src="@drawable/ic_delete"
+ android:scaleType="centerInside"
+
android:contentDescription="@string/button_clear_all_recent_searches"
+ android:background="@drawable/selectable_item_background"/>
+ </FrameLayout>
+
+ <View android:layout_width="match_parent" android:layout_height="0.5dp"
android:background="?attr/list_separator_color" />
<ListView
android:id="@+id/recent_searches_list"
diff --git a/wikipedia/res/values-qq/strings.xml
b/wikipedia/res/values-qq/strings.xml
index 158eb04..35e4b98 100644
--- a/wikipedia/res/values-qq/strings.xml
+++ b/wikipedia/res/values-qq/strings.xml
@@ -333,7 +333,8 @@
{{Identical|Retry}}</string>
<string name="search_redirect_title">Label that tells the user that the
search result is actually a redirect from another page, specified by the \"%s\"
symbol.</string>
<string name="search_recent_header">Label at the top of the list of recent
searches that the user performed.</string>
- <string name="menu_clear_all_recent_searches">Menu item to clear search
history; visible when in search mode.</string>
+ <string name="button_clear_all_recent_searches">Button hint for clearing
search history; visible when in search mode.</string>
+ <string name="clear_recent_searches_confirm">Dialog message that asks if the
user really wants to clear the search history.</string>
<string name="search_titles_button">Button label for searching page title
matches.
{{Identical|Title}}</string>
<string name="search_full_button">Button label for searching the full text
of pages.</string>
diff --git a/wikipedia/res/values/attrs.xml b/wikipedia/res/values/attrs.xml
index 4aace67..181bd88 100644
--- a/wikipedia/res/values/attrs.xml
+++ b/wikipedia/res/values/attrs.xml
@@ -15,4 +15,5 @@
<attr name="ic_find_next_drawable" format="reference"/>
<attr name="lead_image_drawable" format="reference"/>
<attr name="lead_disabled_text_color" format="reference"/>
+ <attr name="list_separator_color" format="reference"/>
</resources>
\ No newline at end of file
diff --git a/wikipedia/res/values/colors.xml b/wikipedia/res/values/colors.xml
index 19c1ec5..c78df57 100644
--- a/wikipedia/res/values/colors.xml
+++ b/wikipedia/res/values/colors.xml
@@ -24,8 +24,6 @@
<color name="gray_background">#ff606060</color>
<color name="gray_disabled">#80606060</color>
<color name="gray_highlight">#ff808080</color>
- <color name="fulltext_search_text">#AAAAAA</color>
- <color name="fulltext_search_highlight">#00AF89</color>
<color name="announcement_background">#0C0C0C</color>
<color name="announcement_text">#AAAAAA</color>
<color name="page_info_heading">#555555</color>
@@ -43,6 +41,7 @@
<color name="edit_text_light">#ff000000</color>
<color name="abusefilter_background_light">#E8E8E8</color>
<color name="subtle_gray_light">#fff0f0f0</color>
+ <color name="list_separator_light">#ffcccccc</color>
<color name="link_dark">#ff2B6FB2</color>
<color name="button_dark">#ff2B6FB2</color>
@@ -50,13 +49,14 @@
<color name="page_background_dark">#ff000000</color>
<color name="actionbar_background_dark">#ff303030</color>
<color name="actionbar_line_dark">#ff606060</color>
- <color name="search_background_dark">#ff404040</color>
+ <color name="search_background_dark">#ff303030</color>
<color name="toc_background_dark">#ff0C0C0C</color>
<color name="toc_section_text_dark">#ffd0d0d0</color>
<color name="toc_subsection_text_dark">#ffa0a0a0</color>
<color name="edit_text_dark">#ff909090</color>
<color name="abusefilter_background_dark">#505050</color>
<color name="subtle_gray_dark">#ff141414</color>
+ <color name="list_separator_dark">#ff606060</color>
<color name="list_item_highlight">#a033b5e5</color>
<color name="list_item_selected">#d033b5e5</color>
diff --git a/wikipedia/res/values/strings.xml b/wikipedia/res/values/strings.xml
index f2b43db..fd88f6b 100644
--- a/wikipedia/res/values/strings.xml
+++ b/wikipedia/res/values/strings.xml
@@ -247,7 +247,8 @@
<string name="search_error_retry">Retry</string>
<string name="search_redirect_title">Redirect from \"%s\".</string>
<string name="search_recent_header">Recent searches:</string>
- <string name="menu_clear_all_recent_searches">Clear recent
searches</string>
+ <string name="button_clear_all_recent_searches">Clear recent
searches</string>
+ <string name="clear_recent_searches_confirm">Are you sure you want to
clear your search history?</string>
<string name="search_titles_button">Titles</string>
<string name="search_full_button">Within articles</string>
<string name="toc_hint">Swipe left for sections, or use the menu button on
the top right.</string>
diff --git a/wikipedia/res/values/styles_wikidark.xml
b/wikipedia/res/values/styles_wikidark.xml
index 6d652df..744e02b 100644
--- a/wikipedia/res/values/styles_wikidark.xml
+++ b/wikipedia/res/values/styles_wikidark.xml
@@ -24,6 +24,7 @@
<item name="ic_find_next_drawable">@drawable/ic_find_next_dark</item>
<item name="lead_image_drawable">@drawable/lead_default_dark</item>
<item
name="lead_disabled_text_color">@color/lead_disabled_text_dark</item>
+ <item name="list_separator_color">@color/list_separator_dark</item>
</style>
<style name="ActionBar.Solid.WikiDark"
parent="@style/Widget.AppCompat.ActionBar.Solid">
diff --git a/wikipedia/res/values/styles_wikilight.xml
b/wikipedia/res/values/styles_wikilight.xml
index 5ff126a..e1063cf 100644
--- a/wikipedia/res/values/styles_wikilight.xml
+++ b/wikipedia/res/values/styles_wikilight.xml
@@ -22,6 +22,7 @@
<item name="ic_find_next_drawable">@drawable/ic_find_next_light</item>
<item name="lead_image_drawable">@drawable/lead_default</item>
<item
name="lead_disabled_text_color">@color/lead_disabled_text_light</item>
+ <item name="list_separator_color">@color/list_separator_light</item>
</style>
<style name="ActionBar.Solid.WikiLight"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
diff --git
a/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java
b/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java
index 3750fb5..c0472ae 100644
--- a/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java
+++ b/wikipedia/src/main/java/org/wikipedia/search/SearchArticlesFragment.java
@@ -10,7 +10,9 @@
import org.wikipedia.page.PageActivity;
import com.squareup.otto.Subscribe;
-import android.graphics.Color;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat;
@@ -25,6 +27,7 @@
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
+import android.widget.ImageView;
import android.widget.TextView;
public class SearchArticlesFragment extends Fragment {
@@ -80,7 +83,6 @@
private View buttonTitleSearch;
private View buttonFullSearch;
- private int defaultTextColor;
public SearchArticlesFragment() {
}
@@ -113,6 +115,24 @@
}
});
+ parentLayout.findViewById(R.id.recent_searches_delete_button).
+ setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ AlertDialog.Builder alert = new
AlertDialog.Builder(getActivity());
+
alert.setMessage(getString(R.string.clear_recent_searches_confirm));
+ alert.setPositiveButton(getString(R.string.yes), new
DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int
id) {
+ new DeleteAllRecentSearchesTask(app).execute();
+ }
+ });
+ alert.setNegativeButton(getString(R.string.no), null);
+ alert.create().show();
+ }
+ });
+ app.adjustDrawableToTheme(((ImageView)parentLayout.
+
findViewById(R.id.recent_searches_delete_button)).getDrawable());
+
recentSearchesFragment =
(RecentSearchesFragment)getActivity().getSupportFragmentManager().findFragmentById(R.id.search_panel_recent);
searchTypesContainer =
parentLayout.findViewById(R.id.search_panel_types);
@@ -139,8 +159,6 @@
startSearch(lastSearchedText, true);
}
});
-
- defaultTextColor =
((TextView)buttonFullSearch).getTextColors().getDefaultColor();
titleSearchFragment =
(TitleSearchFragment)getActivity().getSupportFragmentManager().findFragmentById(R.id.fragment_search_title);
titleSearchFragment.setOnNoResultsListener(new
TitleSearchFragment.OnNoResultsListener() {
@@ -221,18 +239,18 @@
break;
case PANEL_TITLE_SEARCH:
searchTypesContainer.setVisibility(View.VISIBLE);
-
buttonTitleSearch.setBackgroundResource(R.drawable.button_shape_flat_highlight);
- ((TextView)buttonTitleSearch).setTextColor(Color.WHITE);
-
buttonFullSearch.setBackgroundResource(R.drawable.button_shape_flat);
- ((TextView)buttonFullSearch).setTextColor(defaultTextColor);
+
buttonTitleSearch.setBackgroundColor(getResources().getColor(Utils.getThemedAttributeId(getActivity(),
R.attr.search_background_color)));
+ ((TextView)buttonTitleSearch).setTypeface(null, Typeface.BOLD);
+
buttonFullSearch.setBackgroundColor(getResources().getColor(Utils.getThemedAttributeId(getActivity(),
R.attr.window_background_color)));
+ ((TextView)buttonFullSearch).setTypeface(null,
Typeface.NORMAL);
titleSearchFragment.show();
break;
case PANEL_FULL_SEARCH:
searchTypesContainer.setVisibility(View.VISIBLE);
-
buttonFullSearch.setBackgroundResource(R.drawable.button_shape_flat_highlight);
- ((TextView)buttonFullSearch).setTextColor(Color.WHITE);
-
buttonTitleSearch.setBackgroundResource(R.drawable.button_shape_flat);
- ((TextView)buttonTitleSearch).setTextColor(defaultTextColor);
+
buttonFullSearch.setBackgroundColor(getResources().getColor(Utils.getThemedAttributeId(getActivity(),
R.attr.search_background_color)));
+ ((TextView)buttonFullSearch).setTypeface(null, Typeface.BOLD);
+
buttonTitleSearch.setBackgroundColor(getResources().getColor(Utils.getThemedAttributeId(getActivity(),
R.attr.window_background_color)));
+ ((TextView)buttonTitleSearch).setTypeface(null,
Typeface.NORMAL);
fullSearchFragment.show();
break;
default:
@@ -358,10 +376,6 @@
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (isSearchActive) {
addSearchView(menu);
- // TODO: remove this when ready for production
- if (app.getReleaseType() != WikipediaApp.RELEASE_PROD) {
- addDeleteRecentSearchesMenu(menu);
- }
}
}
@@ -391,22 +405,6 @@
}
}
MenuItemCompat.setActionView(searchAction, searchView);
- }
-
- private void addDeleteRecentSearchesMenu(Menu menu) {
- MenuItem deleteAction = menu.add(0,
R.id.menu_clear_all_recent_searches, Menu.NONE,
getString(R.string.menu_clear_all_recent_searches));
- MenuItemCompat.setShowAsAction(deleteAction,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
- deleteAction.setIcon(R.drawable.ic_delete);
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.menu_clear_all_recent_searches:
- new DeleteAllRecentSearchesTask(app).execute();
- return true;
- default:
- return false;
- }
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/173087
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I21c5faa5de57e3bd4324810e77236f787b2144d0
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits