Bug 692236 - "Webapps shortcut picker needs a new UI" [r=mark.finkle]

This commit is contained in:
Sriram Ramasubramanian 2011-10-05 16:28:00 -04:00
Родитель 0a2dad47af
Коммит 8e90598b4c
4 изменённых файлов: 51 добавлений и 28 удалений

Просмотреть файл

@ -115,7 +115,8 @@
#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" />

Просмотреть файл

@ -60,7 +60,7 @@ 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;
@ -69,6 +69,7 @@ public class LauncherShortcuts extends ListActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.launch_app_list);
final Intent intent = getIntent();
@ -80,9 +81,8 @@ public class LauncherShortcuts extends ListActivity {
}
}
@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();
@ -219,16 +219,42 @@ public class LauncherShortcuts extends ListActivity {
@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();
}
}
}

Просмотреть файл

@ -5,16 +5,4 @@
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>

Просмотреть файл

@ -2,16 +2,24 @@
<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>