Bug 1130203 - Round the corners of the first item in the share overlay. r=mhaigh a=sylvestre
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 17 Mar 2015 17:47:38 -0700
changeset 258340 5dd03a21c376
parent 258339 feb7a6808bfb
child 258341 c3ec8ada4705
push id4648
push usermichael.l.comella@gmail.com
push date2015-04-08 16:26 +0000
treeherdermozilla-beta@e399294c9df3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh, sylvestre
bugs1130203
milestone38.0
Bug 1130203 - Round the corners of the first item in the share overlay. r=mhaigh a=sylvestre
mobile/android/base/overlays/ui/SendTabDeviceListArrayAdapter.java
mobile/android/base/overlays/ui/ShareDialog.java
mobile/android/base/resources/drawable/overlay_share_button_background.xml
mobile/android/base/resources/drawable/overlay_share_button_background_first.xml
mobile/android/base/resources/layout/overlay_share_dialog.xml
--- a/mobile/android/base/overlays/ui/SendTabDeviceListArrayAdapter.java
+++ b/mobile/android/base/overlays/ui/SendTabDeviceListArrayAdapter.java
@@ -9,16 +9,17 @@ import java.util.Collection;
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.Assert;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.overlays.service.sharemethods.ParcelableClientRecord;
 import org.mozilla.gecko.overlays.ui.SendTabList.State;
 
 import android.app.AlertDialog;
 import android.content.Context;
+import android.graphics.drawable.Drawable;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
 import android.widget.TextView;
 
 public class SendTabDeviceListArrayAdapter extends ArrayAdapter<ParcelableClientRecord> {
     @SuppressWarnings("unused")
@@ -88,16 +89,21 @@ public class SendTabDeviceListArrayAdapt
         final Context context = getContext();
 
         // Reuse View objects if they exist.
         TextView row = (TextView) convertView;
         if (row == null) {
             row = (TextView) View.inflate(context, R.layout.overlay_share_send_tab_item, null);
         }
 
+        // The first view in the list has a unique style.
+        if (position == 0) {
+            row.setBackgroundResource(R.drawable.overlay_share_button_background_first);
+        }
+
         if (currentState != State.LIST) {
             // If we're in a special "Button-like" state, use the override string and a generic icon.
             row.setText(dummyRecordName);
             row.setCompoundDrawablesWithIntrinsicBounds(R.drawable.overlay_send_tab_icon, 0, 0, 0);
         }
 
         // If we're just a button to launch the dialog, set the listener and abort.
         if (currentState == State.SHOW_DEVICES) {
--- a/mobile/android/base/overlays/ui/ShareDialog.java
+++ b/mobile/android/base/overlays/ui/ShareDialog.java
@@ -117,16 +117,26 @@ public class ShareDialog extends Locales
 
         sendTabList.setSyncClients(clientrecords);
 
         if (state == State.DEVICES_ONLY ||
                 clientrecords == null ||
                 clientrecords.length <= MAXIMUM_INLINE_DEVICES) {
             // Show the list of devices in-line.
             sendTabList.switchState(SendTabList.State.LIST);
+
+            // The first item in the list has a unique style. If there are no items
+            // in the list, the next button appears to be the first item in the list.
+            //
+            // Note: a more thorough implementation would add this
+            // (and other non-ListView buttons) into a custom ListView.
+            if (clientrecords == null || clientrecords.length == 0) {
+                readingListButton.setBackgroundResource(
+                        R.drawable.overlay_share_button_background_first);
+            }
             return;
         }
 
         // Just show a button to launch the list of devices to choose from.
         sendTabList.switchState(SendTabList.State.SHOW_DEVICES);
     }
 
     @Override
--- a/mobile/android/base/resources/drawable/overlay_share_button_background.xml
+++ b/mobile/android/base/resources/drawable/overlay_share_button_background.xml
@@ -1,13 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
   - This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/.
   -->
 
+<!-- Should be kept in sync with overlay_share_button_background_first.xml -->
+
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
 
     <item android:state_pressed="true" android:drawable="@color/overlay_share_selected" />
     <item android:drawable="@color/overlay_share_background"/>
 
 </selector>
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/resources/drawable/overlay_share_button_background_first.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  - This Source Code Form is subject to the terms of the Mozilla Public
+  - License, v. 2.0. If a copy of the MPL was not distributed with this
+  - file, You can obtain one at http://mozilla.org/MPL/2.0/.
+  -->
+
+<!-- Should be kept in sync with overlay_share_button_background.xml
+
+     This first item in the list has rounded corners. -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:state_pressed="true">
+        <shape>
+            <solid android:color="@color/overlay_share_selected"/>
+            <corners android:topLeftRadius="@dimen/button_corner_radius"
+                     android:topRightRadius="@dimen/button_corner_radius"/>
+        </shape>
+    </item>
+
+    <item>
+        <shape>
+            <solid android:color="@color/overlay_share_background"/>
+            <corners android:topLeftRadius="@dimen/button_corner_radius"
+                     android:topRightRadius="@dimen/button_corner_radius"/>
+        </shape>
+    </item>
+
+</selector>
--- a/mobile/android/base/resources/layout/overlay_share_dialog.xml
+++ b/mobile/android/base/resources/layout/overlay_share_dialog.xml
@@ -39,34 +39,35 @@
             android:layout_height="wrap_content"/>
 
         <!-- TODO: Add back drop shadow? -->
         <!-- Buttons -->
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="20dp"
-            android:background="@color/overlay_share_background"
             android:orientation="vertical">
 
             <!-- "Send to Firefox Sync" -->
             <org.mozilla.gecko.overlays.ui.SendTabList
                 style="@style/ShareOverlayButton"
                 android:id="@+id/overlay_send_tab_btn"
                 android:padding="0dp"
                 android:divider="@null"/>
 
             <!-- "Add to reading list" -->
             <org.mozilla.gecko.overlays.ui.OverlayDialogButton
                 style="@style/ShareOverlayButton.Text.Container"
                 android:id="@+id/overlay_share_reading_list_btn"
+                android:background="@drawable/overlay_share_button_background"
                 android:enabled="false"/>
 
             <!-- "Add bookmark" -->
             <org.mozilla.gecko.overlays.ui.OverlayDialogButton
                 style="@style/ShareOverlayButton.Text.Container"
                 android:id="@+id/overlay_share_bookmark_btn"
+                android:background="@drawable/overlay_share_button_background"
                 android:enabled="false"/>
 
         </LinearLayout>
     </LinearLayout>
 
 </FrameLayout>