Bug 692236 - "Webapps shortcut picker needs a new UI" [r=mark.finkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 05 Oct 2011 16:28:00 -0400
changeset 79561 07210340e62051febddef9bf37dc7a9097f95f4e
parent 79560 3e2821ec1672ccee51ef1d68cf42b706f9fa54c5
child 79562 ac1d5e94097a71f4e0f58f99c28b72a7e125b9f7
push idunknown
push userunknown
push dateunknown
reviewersmark.finkle
bugs692236
milestone10.0a1
Bug 692236 - "Webapps shortcut picker needs a new UI" [r=mark.finkle]
embedding/android/AndroidManifest.xml.in
embedding/android/LauncherShortcuts.java.in
embedding/android/resources/layout/launch_app_list.xml
embedding/android/resources/layout/launch_app_listitem.xml
--- a/embedding/android/AndroidManifest.xml.in
+++ b/embedding/android/AndroidManifest.xml.in
@@ -110,17 +110,18 @@
             android:excludeFromRecents="true">
           <intent-filter>
             <action android:name="org.mozilla.gecko.reportCrash" />
           </intent-filter>
 	</activity>
 #endif
 
         <activity android:name="LauncherShortcuts"
-                  android:label="@string/launcher_shortcuts_title">
+                  android:label="@string/launcher_shortcuts_title"
+                  android:theme="@android:style/Theme.Translucent">
             <!--  This intent-filter allows your shortcuts to be created in the launcher. -->
             <intent-filter>
                 <action android:name="android.intent.action.CREATE_SHORTCUT" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>
     </application>
 </manifest> 
--- a/embedding/android/LauncherShortcuts.java.in
+++ b/embedding/android/LauncherShortcuts.java.in
@@ -55,39 +55,39 @@ import android.util.*;
 import android.widget.*;
 import android.database.sqlite.*;
 import android.database.*;
 import android.view.*;
 import android.net.Uri;
 import android.graphics.*;
 
 
-public class LauncherShortcuts extends ListActivity {
+public class LauncherShortcuts extends Activity {
 
     private ArrayList <HashMap<String, String>> mWebappsList;
     private File mWebappsFolder;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
         setContentView(R.layout.launch_app_list);
 
         final Intent intent = getIntent();
         final String action = intent.getAction();
 
         if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
             // Doing it as a background task, as it involves file access
             new FetchWebApps().execute();
         }
     }
 
-    @Override
-    public void onListItemClick(ListView l, View v, int position, long id) {
-        HashMap<String, String> map = mWebappsList.get((int) id);
+    public void onListItemClick(int id) {
+        HashMap<String, String> map = mWebappsList.get(id);
         
         String uri = map.get("uri").toString();
         String title = map.get("title").toString();
         String appKey = map.get("appKey").toString();
         String favicon = map.get("favicon").toString();
         
         File manifestFile = new File(mWebappsFolder, appKey + "/manifest.json");
         
@@ -214,22 +214,48 @@ public class LauncherShortcuts extends L
             } catch (JSONException e) {}
             
             return null;
         }
         
         @Override
         protected void onPostExecute(Void unused) {
             if (mWebappsList != null) {
-                TextView emptyText = (TextView)findViewById(android.R.id.empty);
-                emptyText.setText("");
-
-                setListAdapter(new SimpleAdapter(
+                AlertDialog.Builder builder;
+                
+                if (android.os.Build.VERSION.SDK_INT >= 11) {
+                    builder = new AlertDialog.Builder(LauncherShortcuts.this, AlertDialog.THEME_HOLO_LIGHT);
+                } else {
+                    builder = new AlertDialog.Builder(LauncherShortcuts.this);
+                }
+                
+                builder.setTitle(R.string.launcher_shortcuts_title);
+                builder.setAdapter(new SimpleAdapter(
                     LauncherShortcuts.this,
                     mWebappsList,
                     R.layout.launch_app_listitem,
                     new String[] { "favicon", "title" },
                     new int[] { R.id.favicon, R.id.title }
-                ));
+                ), new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int id) {
+                        dialog.dismiss();
+                        onListItemClick(id);
+                        finish();
+                    }
+                });
+                
+                builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
+                    @Override
+                    public void onCancel(DialogInterface dialog) {
+                        dialog.dismiss();
+                        finish();
+                    }
+                });
+                
+                builder.create().show();
+            } else {
+                Toast.makeText(LauncherShortcuts.this, R.string.launcher_shortcuts_empty, Toast.LENGTH_LONG).show();
+                finish();
             }
         }
     }
 }
--- a/embedding/android/resources/layout/launch_app_list.xml
+++ b/embedding/android/resources/layout/launch_app_list.xml
@@ -1,20 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:padding="3dip"
          android:orientation="vertical"
          android:windowIsFloating="true">
-
-    <ListView android:id="@android:id/list"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:layout_weight="1"
-              android:drawSelectorOnTop="false"/>
-
-    <TextView android:id="@android:id/empty"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:gravity="center"
-              android:text="@string/launcher_shortcuts_empty"/>
  </LinearLayout>
--- a/embedding/android/resources/layout/launch_app_listitem.xml
+++ b/embedding/android/resources/layout/launch_app_listitem.xml
@@ -1,17 +1,25 @@
 <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="?android:attr/listPreferredItemHeight"
-    android:padding="6dip"
-    android:orientation="horizontal">
+    android:paddingLeft="16dip"
+    android:paddingRight="16dip"
+    android:orientation="horizontal"
+    android:gravity="left">
     <ImageView
         android:id="@+id/favicon"
-        android:layout_width="wrap_content"
-        android:layout_height="match_parent"
-        android:layout_marginRight="6dip"/>
+        android:layout_width="48dip"
+        android:layout_height="48dip"
+        android:layout_marginRight="12dip"
+        android:layout_gravity="center_vertical"
+        android:adjustViewBounds="true"
+        android:scaleType="fitCenter"/>
     <TextView
         android:id="@+id/title"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:gravity="center_vertical"/>
+        android:gravity="center_vertical"
+        android:textAppearance="?android:attr/textAppearanceLargeInverse"
+        android:ellipsize="marquee"
+        android:fadingEdge="horizontal"/>
  </LinearLayout>