Brion VIBBER has submitted this change and it was merged. Change subject: Design tweaks for nav drawer ......................................................................
Design tweaks for nav drawer - Designers are experimenting with the color - Search bar is hidden as well - Zero indicators have been removed. Need to be re-done - Does not use a ListView anymore. Not customizable enough. - Need to add icons Change-Id: Ic6ef5e3f814ee2d466bdbaddfbf8cc7767fee5fd --- M wikipedia/res/layout/activity_main.xml M wikipedia/res/layout/fragment_navdrawer.xml M wikipedia/res/values/strings.xml M wikipedia/src/main/java/org/wikipedia/NavDrawerFragment.java 4 files changed, 284 insertions(+), 165 deletions(-) Approvals: Brion VIBBER: Verified; Looks good to me, approved diff --git a/wikipedia/res/layout/activity_main.xml b/wikipedia/res/layout/activity_main.xml index 1172107..4f0dfa2 100644 --- a/wikipedia/res/layout/activity_main.xml +++ b/wikipedia/res/layout/activity_main.xml @@ -1,30 +1,29 @@ -<FrameLayout +<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" android:layout_height="match_parent"> - <android.support.v4.widget.DrawerLayout - android:id="@+id/drawer_layout" - android:layout_width="match_parent" - android:saveEnabled="false" - android:layout_height="match_parent"> - <!-- The main content view --> + android:id="@+id/drawer_layout" + android:layout_width="match_parent" + android:saveEnabled="false" + android:layout_height="match_parent"> + <!-- The main content view --> + <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout> - <!-- The navigation drawer --> - <!-- Don't set marginTop here, it somehow also affects marginBottom. wtf?! --> - <fragment android:layout_width="wrap_content" android:layout_height="match_parent" - android:name="org.wikipedia.NavDrawerFragment" - android:layout_gravity="start" + <fragment + android:id="@+id/search_fragment" + android:name="org.wikipedia.search.SearchArticlesFragment" + android:layout_height="wrap_content" + android:layout_width="match_parent" + android:layout_gravity="top" /> - - </android.support.v4.widget.DrawerLayout> - <fragment - android:id="@+id/search_fragment" - android:name="org.wikipedia.search.SearchArticlesFragment" - android:layout_height="wrap_content" - android:layout_width="match_parent" - android:layout_gravity="top" + </FrameLayout> + <!-- The navigation drawer --> + <!-- Don't set marginTop here, it somehow also affects marginBottom. wtf?! --> + <fragment android:layout_width="wrap_content" android:layout_height="match_parent" + android:name="org.wikipedia.NavDrawerFragment" + android:layout_gravity="start" /> -</FrameLayout> + +</android.support.v4.widget.DrawerLayout> diff --git a/wikipedia/res/layout/fragment_navdrawer.xml b/wikipedia/res/layout/fragment_navdrawer.xml index 64f9d9e..993e939 100644 --- a/wikipedia/res/layout/fragment_navdrawer.xml +++ b/wikipedia/res/layout/fragment_navdrawer.xml @@ -1,24 +1,202 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="196dp" android:layout_height="match_parent" - android:orientation="vertical" - android:background="#111"> - <!-- Match marginTop with height of Search Fragment --> - <ListView android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:layout_marginTop="48dp" - android:id="@+id/nav_list"> - </ListView> - <org.wikipedia.styledviews.StyledTextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textSize="12sp" - android:textColor="#777" - android:padding="4dp" - android:id="@+id/nav_drawer_version" - android:gravity="right" - /> -</LinearLayout> \ No newline at end of file + android:fillViewport="true" + android:background="#00af89"> + <LinearLayout android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:id="@+id/nav_item_container" + > + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:id="@+id/nav_item_login" + android:background="?android:attr/selectableItemBackground" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:paddingRight="8dp" + > + <ImageView android:layout_width="32dp" android:layout_height="32dp" + android:layout_margin="8dp" + android:layout_gravity="top" + android:background="#ffffff" + /> + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + > + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + android:layout_gravity="center_vertical" + android:text="@string/nav_item_login" + style="?android:textAppearanceMediumInverse" + /> + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/nav_item_login_benefits" + style="?android:textAppearanceSmallInverse" + /> + </LinearLayout> + </LinearLayout> + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:id="@+id/nav_item_username" + android:background="?android:attr/selectableItemBackground" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:paddingRight="8dp" + android:visibility="gone" + > + <ImageView android:layout_width="32dp" android:layout_height="32dp" + android:layout_margin="8dp" + android:layout_gravity="center_vertical" + android:background="#ffffff" + /> + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + > + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + android:layout_gravity="center_vertical" + android:id="@+id/nav_item_username_primary_text" + style="?android:textAppearanceMediumInverse" + /> + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/nav_item_tap_to_logout" + style="?android:textAppearanceSmallInverse" + /> + </LinearLayout> + </LinearLayout> + + <View android:layout_width="match_parent" android:layout_height="0.5dp" android:background="#038368" /> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:id="@+id/nav_item_history" + android:background="?android:attr/selectableItemBackground" + > + <ImageView android:layout_width="32dp" android:layout_height="32dp" + android:layout_margin="8dp" + android:layout_gravity="center_vertical" + android:background="#ffffff" + /> + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/nav_item_history" + style="?android:textAppearanceMediumInverse" + /> + </LinearLayout> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:id="@+id/nav_item_saved_pages" + android:background="?android:attr/selectableItemBackground" + > + <ImageView android:layout_width="32dp" android:layout_height="32dp" + android:layout_margin="8dp" + android:layout_gravity="center_vertical" + android:background="#ffffff" + /> + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/nav_item_saved_pages" + style="?android:textAppearanceMediumInverse" + /> + </LinearLayout> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:id="@+id/nav_item_random" + android:background="?android:attr/selectableItemBackground" + > + <ImageView android:layout_width="32dp" android:layout_height="32dp" + android:layout_margin="8dp" + android:layout_gravity="center_vertical" + android:background="#ffffff" + /> + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/nav_item_random" + style="?android:textAppearanceMediumInverse" + /> + </LinearLayout> + + <!-- Separator view for providing gap between top items and bottom ones --> + <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> + + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="12sp" + android:textColor="#fff" + android:padding="4dp" + android:id="@+id/nav_drawer_version" + android:gravity="right" + /> + + <View android:layout_width="match_parent" android:layout_height="0.5dp" android:background="#038368" /> + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:id="@+id/nav_item_settings" + android:background="?android:attr/selectableItemBackground" + > + <ImageView android:layout_width="32dp" android:layout_height="32dp" + android:layout_margin="8dp" + android:layout_gravity="center_vertical" + android:background="#ffffff" + /> + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/nav_item_preferences" + style="?android:textAppearanceMediumInverse" + /> + </LinearLayout> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:id="@+id/nav_item_send_feedback" + android:background="?android:attr/selectableItemBackground" + > + <ImageView android:layout_width="32dp" android:layout_height="32dp" + android:layout_margin="8dp" + android:layout_gravity="center_vertical" + android:background="#ffffff" + /> + <org.wikipedia.styledviews.StyledTextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/nav_item_send_feedback" + style="?android:textAppearanceMediumInverse" + /> + </LinearLayout> + + </LinearLayout> +</ScrollView> \ No newline at end of file diff --git a/wikipedia/res/values/strings.xml b/wikipedia/res/values/strings.xml index 2c48660..e2eb86d 100644 --- a/wikipedia/res/values/strings.xml +++ b/wikipedia/res/values/strings.xml @@ -116,4 +116,6 @@ <string name="edit_summary_hint">Edit summary</string> <string name="nav_item_random">Random</string> <string name="random_progress">Fetching random page...</string> + <string name="nav_item_login_benefits">If you Log in, your edits will be associated with your username and your IP will not be publicly visible.</string> + <string name="nav_item_tap_to_logout">Tap to log out</string> </resources> diff --git a/wikipedia/src/main/java/org/wikipedia/NavDrawerFragment.java b/wikipedia/src/main/java/org/wikipedia/NavDrawerFragment.java index 0672b35..98057e8 100644 --- a/wikipedia/src/main/java/org/wikipedia/NavDrawerFragment.java +++ b/wikipedia/src/main/java/org/wikipedia/NavDrawerFragment.java @@ -2,7 +2,6 @@ import android.app.*; import android.content.*; -import android.graphics.*; import android.net.*; import android.os.*; import android.support.v4.app.Fragment; @@ -10,31 +9,22 @@ import android.widget.*; import org.wikipedia.history.*; import org.wikipedia.login.*; -import org.wikipedia.random.RandomHandler; +import org.wikipedia.random.*; import org.wikipedia.savedpages.*; import org.wikipedia.settings.*; -public class NavDrawerFragment extends Fragment implements AdapterView.OnItemClickListener { +public class NavDrawerFragment extends Fragment implements View.OnClickListener { private static final int[] ACTION_ITEMS_TEXT = { - R.string.nav_item_history, - R.string.nav_item_saved_pages, - R.string.nav_item_preferences, - R.string.nav_item_login, - R.string.nav_item_random, - R.string.nav_item_send_feedback, - R.string.zero_free_verbiage - }; - private static final int[] ACTION_ITEM_IMAGES = { - android.R.drawable.ic_menu_recent_history, - android.R.drawable.ic_menu_save, - android.R.drawable.ic_menu_preferences, - android.R.drawable.ic_menu_add, - android.R.drawable.ic_menu_directions, - android.R.drawable.ic_menu_send + R.id.nav_item_history, + R.id.nav_item_saved_pages, + R.id.nav_item_settings, + R.id.nav_item_login, + R.id.nav_item_username, + R.id.nav_item_random, + R.id.nav_item_send_feedback }; - private ListView navList; - private NavListAdapter adapter; + private View[] actionViews = new View[ACTION_ITEMS_TEXT.length]; private WikipediaApp app; private RandomHandler randomHandler; @@ -49,71 +39,40 @@ // Ensure that Login / Logout status is accurate setupDynamicItems(); - ((NavListAdapter)navList.getAdapter()).notifyDataSetChanged(); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - navList = (ListView) getView().findViewById(R.id.nav_list); - adapter = new NavListAdapter(); app = (WikipediaApp)getActivity().getApplicationContext(); ((TextView)getView().findViewById(R.id.nav_drawer_version)).setText(WikipediaApp.APP_VERSION_STRING); - navList.setAdapter(adapter); - navList.setOnItemClickListener(this); + for (int i = 0; i < ACTION_ITEMS_TEXT.length; i++) { + actionViews[i] = getView().findViewById(ACTION_ITEMS_TEXT[i]); + actionViews[i].setOnClickListener(this); + } randomHandler = new RandomHandler(getActivity()); } - @Override - public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - Intent intent = new Intent(); - switch ((Integer)view.getTag()) { - case R.string.nav_item_history: - intent.setClass(this.getActivity(), HistoryActivity.class); - getActivity().startActivity(intent); - break; - case R.string.nav_item_saved_pages: - intent.setClass(this.getActivity(), SavedPagesActivity.class); - startActivity(intent); - break; - case R.string.nav_item_preferences: - intent.setClass(this.getActivity(), SettingsActivity.class); - startActivity(intent); - break; - case R.string.nav_item_login: - intent.setClass(this.getActivity(), LoginActivity.class); - startActivity(intent); - break; - case R.string.nav_item_random: - randomHandler.doVistRandomArticle(); - break; - case R.string.nav_item_logout: - doLogout(); - break; - case R.string.zero_free_verbiage: - return; - case R.string.nav_item_send_feedback: - // Will be stripped out in prod builds - intent.setAction(Intent.ACTION_SENDTO); - // Will be moved to a better email address at some point - // FIXME: Have build info here, perhaps? We can't access it anywhere yet - intent.setData(Uri.parse("mailto:yuvipa...@wikimedia.org?subject=Android App " + WikipediaApp.APP_VERSION_STRING + " Feedback")); - startActivity(intent); - break; - default: - throw new RuntimeException("Unknown ID clicked!"); - } - } - + private View usernameContainer; + private View loginContainer; + private TextView usernamePrimaryText; private void setupDynamicItems() { + if (usernameContainer == null) { + usernameContainer = getView().findViewById(R.id.nav_item_username); + usernamePrimaryText = (TextView) usernameContainer.findViewById(R.id.nav_item_username_primary_text); + loginContainer = getView().findViewById(R.id.nav_item_login); + } // Do login / logout swap if (app.getUserInfoStorage().isLoggedIn()) { - ACTION_ITEMS_TEXT[3] = R.string.nav_item_logout; + loginContainer.setVisibility(View.GONE); + usernameContainer.setVisibility(View.VISIBLE); + usernamePrimaryText.setText(app.getUserInfoStorage().getUser().getUsername()); } else { - ACTION_ITEMS_TEXT[3] = R.string.nav_item_login; + usernameContainer.setVisibility(View.GONE); + loginContainer.setVisibility(View.VISIBLE); } } @@ -132,65 +91,46 @@ public void onFinish(Boolean result) { progressDialog.dismiss(); setupDynamicItems(); - ((NavListAdapter)navList.getAdapter()).notifyDataSetChanged(); } }.execute(); } - private class NavListAdapter extends BaseAdapter { - - @Override - public int getCount() { - return ACTION_ITEMS_TEXT.length; - } - - @Override - public Object getItem(int position) { - return ACTION_ITEMS_TEXT[position]; - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - if (convertView == null) { - convertView = getActivity().getLayoutInflater().inflate(R.layout.item_nav_item, parent, false); - } - TextView navText = (TextView)convertView.findViewById(R.id.nav_item_text); - - if (ACTION_ITEMS_TEXT[position] == R.string.zero_free_verbiage) { - if (WikipediaApp.getWikipediaZeroDisposition()) { - navText.setText(WikipediaApp.getCarrierMessage()); - navText.setTextColor(Color.GRAY); - navText.setTextSize(11.0f); - } else { - navText.setText(""); - } - - convertView.setTag(ACTION_ITEMS_TEXT[position]); - boolean a = true; - return convertView; - } - - ImageView navImage = (ImageView)convertView.findViewById(R.id.nav_item_image); - navText.setText(ACTION_ITEMS_TEXT[position]); - navImage.setImageResource(ACTION_ITEM_IMAGES[position]); - convertView.setTag(ACTION_ITEMS_TEXT[position]); - - return convertView; - } - - @Override - public boolean areAllItemsEnabled() { - return false; - } - - @Override - public boolean isEnabled(int position) { - return ACTION_ITEMS_TEXT[position] == R.string.zero_free_verbiage ? WikipediaApp.getWikipediaZeroDisposition() : true; + @Override + public void onClick(View view) { + Intent intent = new Intent(); + switch (view.getId()) { + case R.id.nav_item_history: + intent.setClass(this.getActivity(), HistoryActivity.class); + getActivity().startActivity(intent); + break; + case R.id.nav_item_saved_pages: + intent.setClass(this.getActivity(), SavedPagesActivity.class); + startActivity(intent); + break; + case R.id.nav_item_settings: + intent.setClass(this.getActivity(), SettingsActivity.class); + startActivity(intent); + break; + case R.id.nav_item_login: + intent.setClass(this.getActivity(), LoginActivity.class); + startActivity(intent); + break; + case R.id.nav_item_random: + randomHandler.doVistRandomArticle(); + break; + case R.id.nav_item_username: + doLogout(); + break; + case R.id.nav_item_send_feedback: + // Will be stripped out in prod builds + intent.setAction(Intent.ACTION_SENDTO); + // Will be moved to a better email address at some point + intent.setData(Uri.parse("mailto:yuvipa...@wikimedia.org?subject=Android App " + WikipediaApp.APP_VERSION_STRING + " Feedback")); + startActivity(intent); + break; + default: + throw new RuntimeException("Unknown ID clicked!"); } } + } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/118670 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic6ef5e3f814ee2d466bdbaddfbf8cc7767fee5fd Gerrit-PatchSet: 3 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Yuvipanda <yuvipa...@gmail.com> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Yuvipanda <yuvipa...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits