merge in jb-mr1-release history after reset to jb-mr1-dev
diff --git a/res/drawable-hdpi/appwidget_item_bg_normal.9.png b/res/drawable-hdpi/appwidget_item_bg_normal.9.png
index baff858..6fd0e6e 100644
--- a/res/drawable-hdpi/appwidget_item_bg_normal.9.png
+++ b/res/drawable-hdpi/appwidget_item_bg_normal.9.png
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_item_bg_pressed.9.png b/res/drawable-hdpi/appwidget_item_bg_pressed.9.png
index 7ec33dd..0da4a1d 100644
--- a/res/drawable-hdpi/appwidget_item_bg_pressed.9.png
+++ b/res/drawable-hdpi/appwidget_item_bg_pressed.9.png
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_item_bg_normal.9.png b/res/drawable-mdpi/appwidget_item_bg_normal.9.png
index 976083f..47009b4 100644
--- a/res/drawable-mdpi/appwidget_item_bg_normal.9.png
+++ b/res/drawable-mdpi/appwidget_item_bg_normal.9.png
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_item_bg_pressed.9.png b/res/drawable-mdpi/appwidget_item_bg_pressed.9.png
index 8f340d3..9a5001b 100644
--- a/res/drawable-mdpi/appwidget_item_bg_pressed.9.png
+++ b/res/drawable-mdpi/appwidget_item_bg_pressed.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_item_bg_normal.9.png b/res/drawable-xhdpi/appwidget_item_bg_normal.9.png
index b26f1d2..3cb534a 100644
--- a/res/drawable-xhdpi/appwidget_item_bg_normal.9.png
+++ b/res/drawable-xhdpi/appwidget_item_bg_normal.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_item_bg_pressed.9.png b/res/drawable-xhdpi/appwidget_item_bg_pressed.9.png
index 3871689..3160e85 100644
--- a/res/drawable-xhdpi/appwidget_item_bg_pressed.9.png
+++ b/res/drawable-xhdpi/appwidget_item_bg_pressed.9.png
Binary files differ
diff --git a/res/layout/keyguard_appwidget_item.xml b/res/layout/keyguard_appwidget_item.xml
index 7280098..de0c855 100755
--- a/res/layout/keyguard_appwidget_item.xml
+++ b/res/layout/keyguard_appwidget_item.xml
@@ -15,21 +15,33 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content" >
- <TextView
- android:id="@+id/icon_and_label"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="8dip"
- android:layout_marginRight="8dip"
- android:layout_marginTop="4dip"
- android:layout_marginBottom="4dip"
- android:background="@drawable/appwidget_item_bg"
- android:minHeight="?android:attr/listPreferredItemHeightSmall"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:drawablePadding="8dip"
- android:paddingStart="11dip"
- android:paddingEnd="11dip" />
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:background="@drawable/appwidget_item_bg"
+ android:layout_marginTop="2dip"
+ android:layout_marginBottom="2dip"
+ android:layout_marginLeft="2dip"
+ android:layout_marginRight="2dip"
+ android:paddingLeft="16dip"
+ android:paddingRight="16dip"
+ android:paddingTop="16dip"
+ android:paddingBottom="16dip" >
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="@dimen/appwidget_preview_width"
+ android:layout_height="@dimen/appwidget_preview_height"
+ android:scaleType="center" />
+ <TextView
+ android:id="@+id/label"
+ style="@style/KeyguardAppWidgetItem"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="24dip"
+ android:paddingBottom="8dip"
+ android:gravity="left|bottom" />
+ </LinearLayout>
</FrameLayout>
diff --git a/res/layout/keyguard_appwidget_pick_layout.xml b/res/layout/keyguard_appwidget_picker_layout.xml
similarity index 76%
rename from res/layout/keyguard_appwidget_pick_layout.xml
rename to res/layout/keyguard_appwidget_picker_layout.xml
index feb85a5..b678925 100644
--- a/res/layout/keyguard_appwidget_pick_layout.xml
+++ b/res/layout/keyguard_appwidget_picker_layout.xml
@@ -18,10 +18,16 @@
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:layout_marginLeft="@dimen/keyguard_appwidget_picker_margin_left"
+ android:layout_marginRight="@dimen/keyguard_appwidget_picker_margin_right"
+ android:paddingTop="2dip"
+ android:paddingBottom="2dip"
android:orientation="vertical" >
<GridView android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
+ android:numColumns="@integer/keyguard_appwidget_picker_cols"
+ android:layout_gravity="center_horizontal"
android:listSelector="@android:color/transparent"
android:id="@+id/widget_list" />
</LinearLayout>
diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml
index 0ff11d3..c8b90ff 100644
--- a/res/values-ar/strings.xml
+++ b/res/values-ar/strings.xml
@@ -724,7 +724,7 @@
<string name="screensaver_settings_summary_sleep" msgid="9086186698140423493">"أثناء الشحن"</string>
<string name="screensaver_settings_summary_dock" msgid="2072657401664633283">"أثناء الإرساء"</string>
<string name="screensaver_settings_summary_off" msgid="2481581696365146473">"إيقاف"</string>
- <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"للتحكم في ما يحدث عندما يتم إرساء الهاتف و/أو عند السكون، شغّل Daydream."</string>
+ <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"للتحكم في ما يحدث عندما يتم إرساء الهاتف و/أو عند السكون، شغّل \"حلم اليقظة\"."</string>
<string name="screensaver_settings_when_to_dream" msgid="8352267826043957746">"وقت تشغيل خلفيات أحلام اليقظة التفاعلية"</string>
<string name="screensaver_settings_dream_start" msgid="4998187847985120168">"البدء الآن"</string>
<string name="screensaver_settings_button" msgid="7292214707625717013">"إعدادات"</string>
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index 55f9c3c..e77d70d 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -808,7 +808,7 @@
<string name="memory_music_usage" msgid="1363785144783011606">"Audio (Musik, Töne, usw.)"</string>
<string name="memory_media_misc_usage" msgid="235452944021647124">"Sonstiges"</string>
<string name="memory_media_cache_usage" msgid="6704293333141177910">"Daten im Cache"</string>
- <string name="sd_eject" product="nosdcard" msgid="4988563376492400073">"Gem. Speicher trennen"</string>
+ <string name="sd_eject" product="nosdcard" msgid="4988563376492400073">"Gemeinsamen Speicher trennen"</string>
<string name="sd_eject" product="default" msgid="6915293408836853020">"SD-Karte entnehmen"</string>
<string name="sd_eject_summary" product="nosdcard" msgid="5009296896648072891">"Internen USB-Speicher trennen"</string>
<string name="sd_eject_summary" product="default" msgid="3300599435073550246">"SD-Karte trennen, damit Sie sie sicher entfernen können"</string>
@@ -1346,7 +1346,7 @@
<string name="battery_since_reset" msgid="7464546661121187045">"Akkuverbrauch seit dem Zurücksetzen"</string>
<string name="battery_stats_on_battery" msgid="4970762168505236033">"<xliff:g id="TIME">%1$s</xliff:g> mit Akku"</string>
<string name="battery_stats_duration" msgid="7464501326709469282">"<xliff:g id="TIME">%1$s</xliff:g> seit dem Ausstecken"</string>
- <string name="battery_stats_charging_label" msgid="4223311142875178785">"Wird geladen"</string>
+ <string name="battery_stats_charging_label" msgid="4223311142875178785">"Wird geladen..."</string>
<string name="battery_stats_screen_on_label" msgid="7150221809877509708">"Bildschirm an"</string>
<string name="battery_stats_gps_on_label" msgid="1193657533641951256">"GPS aktiv"</string>
<string name="battery_stats_wifi_running_label" msgid="3093545080361658269">"WLAN"</string>
@@ -1578,7 +1578,7 @@
<string name="sync_automatically" msgid="1682730255435062059">"App-Daten autom. synchronisieren"</string>
<string name="sync_enabled" msgid="4551148952179416813">"Synchronisierung AN"</string>
<string name="sync_disabled" msgid="8511659877596511991">"Synchronisierung AUS"</string>
- <string name="sync_error" msgid="5060969083117872149">"Synchron.fehler"</string>
+ <string name="sync_error" msgid="5060969083117872149">"Synchronisierungsfehler"</string>
<string name="last_synced" msgid="4242919465367022234">"Zuletzt synchronisiert am <xliff:g id="LAST_SYNC_TIME">%1$s</xliff:g>"</string>
<string name="sync_in_progress" msgid="5151314196536070569">"Synchronisieren…"</string>
<string name="settings_backup" msgid="2274732978260797031">"Einstellungen sichern"</string>
@@ -1688,7 +1688,7 @@
<string name="data_usage_label_foreground" msgid="4938034231928628164">"Vordergrund"</string>
<string name="data_usage_label_background" msgid="3225844085975764519">"Hintergrund"</string>
<string name="data_usage_app_restricted" msgid="3568465218866589705">"eingeschränkt"</string>
- <string name="data_usage_disable_mobile" msgid="5211007048880167438">"Mobile Daten deaktivieren?"</string>
+ <string name="data_usage_disable_mobile" msgid="5211007048880167438">"Mobilfunk deaktivieren?"</string>
<string name="data_usage_disable_mobile_limit" msgid="4644364396844393848">"Limit festlegen"</string>
<string name="data_usage_disable_4g_limit" msgid="6233554774946681175">"4G-Datenlimit festlegen"</string>
<string name="data_usage_disable_3g_limit" msgid="2558557840444266906">"2G-/3G-Datenlimit festlegen"</string>
@@ -1700,7 +1700,7 @@
<string name="data_usage_tab_3g" msgid="6092169523081538718">"2G/3G"</string>
<string name="data_usage_list_mobile" msgid="5588685410495019866">"Mobil"</string>
<string name="data_usage_list_none" msgid="3933892774251050735">"Keine"</string>
- <string name="data_usage_enable_mobile" msgid="986782622560157977">"Mobile Daten"</string>
+ <string name="data_usage_enable_mobile" msgid="986782622560157977">"Mobilfunk"</string>
<string name="data_usage_enable_3g" msgid="6304006671869578254">"2G-/3G-Daten"</string>
<string name="data_usage_enable_4g" msgid="3635854097335036738">"4G-Daten"</string>
<string name="data_usage_app_settings" msgid="8430240158135453271">"App-Einstellungen anzeigen"</string>
@@ -1709,7 +1709,7 @@
<string name="data_usage_app_restrict_background_summary_disabled" msgid="7401927377070755054">"Legen Sie zur Beschränkung der App-Hintergrunddaten zuerst ein Mobildatenlimit fest."</string>
<string name="data_usage_app_restrict_dialog_title" msgid="1613108390242737923">"Hintergrunddaten beschränken?"</string>
<string name="data_usage_app_restrict_dialog" msgid="1466689968707308512">"Diese Funktion kann dazu führen, dass eine auf Hintergrunddaten basierende App nicht mehr funktioniert, wenn nur Mobilfunknetze verfügbar sind."\n\n"Geeignetere Kontrollmechanismen für den Datenverbrauch finden Sie in den Einstellungen der App."</string>
- <string name="data_usage_restrict_denied_dialog" msgid="7086969103661420799">"Hintergrunddaten können nur beschränkt werden, wenn Sie ein Limit für mobile Daten festgelegt haben."</string>
+ <string name="data_usage_restrict_denied_dialog" msgid="7086969103661420799">"Hintergrunddaten können nur beschränkt werden, wenn Sie ein Mobilfunklimit festgelegt haben."</string>
<string name="data_usage_auto_sync_on_dialog_title" msgid="2438617846762244389">"Autom. Synchronisierung aktivieren?"</string>
<string name="data_usage_auto_sync_on_dialog" product="tablet" msgid="7312283529426636845">"Änderungen, die Sie im Web an Ihren Konten vornehmen, werden automatisch auf Ihrem Tablet übernommen."\n\n"Für einige Konten werden möglicherweise auch Änderungen, die Sie auf Ihrem Tablet vornehmen, im Web übernommen. Dies ist die Funktionsweise von Google Konten."\n\n"Unter \"Einstellungen > Konten\" können Sie auswählen, welche Informationen in den einzelnen Konten synchronisiert werden sollen."</string>
<string name="data_usage_auto_sync_on_dialog" product="default" msgid="2374996799819303283">"Änderungen, die Sie im Web an Ihren Konten vornehmen, werden automatisch auf Ihrem Telefon übernommen."\n\n"Für einige Konten werden eventuell auch Änderungen, die Sie auf Ihrem Telefon vornehmen, im Web übernommen. Dies ist die Funktionsweise von Google Konten."\n\n"Unter \"Einstellungen > Konten\" können Sie auswählen, welche Informationen in den einzelnen Konten synchronisiert werden sollen."</string>
diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml
index c8d00b3..9bbb30f 100644
--- a/res/values-fi/strings.xml
+++ b/res/values-fi/strings.xml
@@ -718,13 +718,13 @@
<string name="screen_timeout_summary" msgid="327761329263064327">"Kun laite on ollut käyttämättä <xliff:g id="TIMEOUT_DESCRIPTION">%1$s</xliff:g>"</string>
<string name="wallpaper_settings_title" msgid="5449180116365824625">"Taustakuva"</string>
<string name="wallpaper_settings_fragment_title" msgid="519078346877860129">"Valitse taustakuva"</string>
- <string name="screensaver_settings_title" msgid="3349790120327233241">"Unelmoi"</string>
+ <string name="screensaver_settings_title" msgid="3349790120327233241">"Unelmat"</string>
<string name="screensaver_settings_summary_either_long" msgid="2458481525925378465">"Telakoituna tai virransäästötilassa ja ladattaessa"</string>
<string name="screensaver_settings_summary_either_short" msgid="6140527286137331478">"Joko"</string>
<string name="screensaver_settings_summary_sleep" msgid="9086186698140423493">"Latauksen aikana"</string>
<string name="screensaver_settings_summary_dock" msgid="2072657401664633283">"Telakoituna"</string>
<string name="screensaver_settings_summary_off" msgid="2481581696365146473">"Pois käytöstä"</string>
- <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"Jos haluat hallita puhelimen toimintaa telakoituna ja/tai lepotilassa, ota Unelmointi käyttöön."</string>
+ <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"Jos haluat hallita puhelimen toimintaa telakoituna ja/tai lepotilassa, ota Unelmat käyttöön."</string>
<string name="screensaver_settings_when_to_dream" msgid="8352267826043957746">"Milloin unelmoidaan"</string>
<string name="screensaver_settings_dream_start" msgid="4998187847985120168">"Aloita nyt"</string>
<string name="screensaver_settings_button" msgid="7292214707625717013">"Asetukset"</string>
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index dbea3ab..60ad10e 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -724,7 +724,7 @@
<string name="screensaver_settings_summary_sleep" msgid="9086186698140423493">"Pendant la charge"</string>
<string name="screensaver_settings_summary_dock" msgid="2072657401664633283">"Sur la station d\'accueil"</string>
<string name="screensaver_settings_summary_off" msgid="2481581696365146473">"Désactivé"</string>
- <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"Pour contrôler le comportement du téléphone lorsqu\'il est en veille ou en charge sur sa station d\'accueil, activez l\'écran de veille interactif."</string>
+ <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"Pour contrôler le comportement du téléphone lorsqu\'il se trouve sur une station d\'accueil et/ou lorsqu\'il est en veille, activez l\'écran de veille interactif."</string>
<string name="screensaver_settings_when_to_dream" msgid="8352267826043957746">"Activer l\'écran de veille interactif"</string>
<string name="screensaver_settings_dream_start" msgid="4998187847985120168">"Commencer"</string>
<string name="screensaver_settings_button" msgid="7292214707625717013">"Paramètres"</string>
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 2ced533..498aa4d 100755
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -17,4 +17,9 @@
<resources>
<dimen name="appwidget_width">421dip</dimen>
<dimen name="appwidget_height">68dip</dimen>
+ <dimen name="appwidget_preview_width">120dip</dimen>
+ <dimen name="appwidget_preview_height">70dip</dimen>
+ <dimen name="keyguard_appwidget_picker_margin_left">2dip</dimen>
+ <dimen name="keyguard_appwidget_picker_margin_right">2dip</dimen>
+ <integer name="keyguard_appwidget_picker_cols">2</integer>
</resources>
diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml
new file mode 100644
index 0000000..0903167
--- /dev/null
+++ b/res/values-land/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <style name="KeyguardAppWidgetItem">
+ <item name="android:textSize">16sp</item>
+ </style>
+</resources>
diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml
index dd084f7..8fab8db 100644
--- a/res/values-lt/strings.xml
+++ b/res/values-lt/strings.xml
@@ -724,7 +724,7 @@
<string name="screensaver_settings_summary_sleep" msgid="9086186698140423493">"Įkraunant"</string>
<string name="screensaver_settings_summary_dock" msgid="2072657401664633283">"Kai yra doke"</string>
<string name="screensaver_settings_summary_off" msgid="2481581696365146473">"Išjungta"</string>
- <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"Jei norite valdyti, kas vyksta, kai telefonas yra doke ir (arba) veikia miego režimu, įjunkite funkciją „Sapnai“."</string>
+ <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"Jei norite valdyti, kas vyksta, kai telefonas yra doke ir (arba) veikia miego režimu, įjunkite funkciją „Svajonės“."</string>
<string name="screensaver_settings_when_to_dream" msgid="8352267826043957746">"Kada svajoti"</string>
<string name="screensaver_settings_dream_start" msgid="4998187847985120168">"Pradėti dabar"</string>
<string name="screensaver_settings_button" msgid="7292214707625717013">"Nustatymai"</string>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
index 975db4f..11da9fa 100644
--- a/res/values-ru/strings.xml
+++ b/res/values-ru/strings.xml
@@ -1651,7 +1651,7 @@
<string name="enable_traces_summary_none" msgid="1867562808503494163">"Все трассировки отключены"</string>
<string name="enable_traces_summary_num" msgid="8978230237777454269">"Включено трассировок: <xliff:g id="NUM">%1$d</xliff:g>"</string>
<string name="enable_traces_summary_all" msgid="3950139649125158247">"Все трассировки включены"</string>
- <string name="enable_opengl_traces_title" msgid="6790444011053219871">"Разрешить трассировку OpenGL"</string>
+ <string name="enable_opengl_traces_title" msgid="6790444011053219871">"Вкл. трассировку OpenGL"</string>
<string name="debug_layout" msgid="5981361776594526155">"Показывать границы макета"</string>
<string name="debug_layout_summary" msgid="2001775315258637682">"Показывать границы клипа, поля и т. д."</string>
<string name="show_cpu_usage" msgid="2389212910758076024">"Показывать загрузку ЦП"</string>
diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml
index f45e9e2..5f1f772 100644
--- a/res/values-sw/strings.xml
+++ b/res/values-sw/strings.xml
@@ -716,7 +716,7 @@
<string name="screensaver_settings_summary_sleep" msgid="9086186698140423493">"Inapochaji"</string>
<string name="screensaver_settings_summary_dock" msgid="2072657401664633283">"Inapogatiwa"</string>
<string name="screensaver_settings_summary_off" msgid="2481581696365146473">"Imezimwa"</string>
- <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"Ili kudhibiti kinachotendeka simu inapogatiwa na/au inapolala, washa Kuota mchana."</string>
+ <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"Ili kudhibiti kinachotendeka simu inapogatiwa na/au inapolala, washa Kuota Mchana."</string>
<string name="screensaver_settings_when_to_dream" msgid="8352267826043957746">"Wakati wa kuingia katika hali tulivu"</string>
<string name="screensaver_settings_dream_start" msgid="4998187847985120168">"Anza sasa"</string>
<string name="screensaver_settings_button" msgid="7292214707625717013">"Mipangilio"</string>
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 994d4bb..c0a79ad 100755
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -18,4 +18,6 @@
<dimen name="screen_margin_sides">128dip</dimen>
<dimen name="screen_margin_top">72dip</dimen>
<dimen name="screen_margin_bottom">48dip</dimen>
+ <dimen name="appwidget_preview_height">80dip</dimen>
+ <dimen name="keyguard_appwidget_picker_width">720dip</dimen>
</resources>
diff --git a/res/values-sw600dp-land/styles.xml b/res/values-sw600dp-land/styles.xml
new file mode 100644
index 0000000..645d1fe
--- /dev/null
+++ b/res/values-sw600dp-land/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <style name="KeyguardAppWidgetItem">
+ <item name="android:textSize">18sp</item>
+ </style>
+</resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index cf7ac6b..1374efd 100755
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -32,4 +32,10 @@
<dimen name="setup_item_margin">32dip</dimen>
<dimen name="appwidget_min_width">325dip</dimen>
<dimen name="appwidget_min_height">50dip</dimen>
+
+ <dimen name="appwidget_preview_width">120dip</dimen>
+ <dimen name="appwidget_preview_height">70dip</dimen>
+ <dimen name="keyguard_appwidget_picker_margin_left">2dip</dimen>
+ <dimen name="keyguard_appwidget_picker_margin_right">2dip</dimen>
+ <integer name="keyguard_appwidget_picker_cols">2</integer>
</resources>
diff --git a/res/values-sw600dp/styles.xml b/res/values-sw600dp/styles.xml
index f780f53..9f02164 100644
--- a/res/values-sw600dp/styles.xml
+++ b/res/values-sw600dp/styles.xml
@@ -57,4 +57,8 @@
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
<item name="android:textSize">20sp</item>
</style>
+
+ <style name="KeyguardAppWidgetItem">
+ <item name="android:textSize">16sp</item>
+ </style>
</resources>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 5a58609..d6d9184 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -16,4 +16,7 @@
<resources>
<dimen name="pager_tabs_padding">@*android:dimen/preference_fragment_padding_side</dimen>
+ <dimen name="appwidget_preview_height">80dip</dimen>
+ <integer name="keyguard_appwidget_picker_cols">2</integer>
+ <dimen name="keyguard_appwidget_picker_width">720dip</dimen>
</resources>
diff --git a/res/values-sw720dp/styles.xml b/res/values-sw720dp/styles.xml
new file mode 100644
index 0000000..645d1fe
--- /dev/null
+++ b/res/values-sw720dp/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <style name="KeyguardAppWidgetItem">
+ <item name="android:textSize">18sp</item>
+ </style>
+</resources>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index 0e0577c..90a0d92 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -718,14 +718,14 @@
<string name="screen_timeout_summary" msgid="327761329263064327">"閒置 <xliff:g id="TIMEOUT_DESCRIPTION">%1$s</xliff:g>後"</string>
<string name="wallpaper_settings_title" msgid="5449180116365824625">"桌布"</string>
<string name="wallpaper_settings_fragment_title" msgid="519078346877860129">"選擇桌布來源"</string>
- <string name="screensaver_settings_title" msgid="3349790120327233241">"Daydream"</string>
+ <string name="screensaver_settings_title" msgid="3349790120327233241">"休眠模式"</string>
<string name="screensaver_settings_summary_either_long" msgid="2458481525925378465">"安置於座架上或休眠及充電時"</string>
<string name="screensaver_settings_summary_either_short" msgid="6140527286137331478">"皆可"</string>
<string name="screensaver_settings_summary_sleep" msgid="9086186698140423493">"充電時"</string>
<string name="screensaver_settings_summary_dock" msgid="2072657401664633283">"安置於座架上時"</string>
<string name="screensaver_settings_summary_off" msgid="2481581696365146473">"關閉"</string>
- <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"如要控制手機安置於座架上和/或休眠時的設定,請開啟 Daydream。"</string>
- <string name="screensaver_settings_when_to_dream" msgid="8352267826043957746">"Daydream 開啟時間"</string>
+ <string name="screensaver_settings_disabled_prompt" msgid="3857507943322777651">"如要控制手機安置於座架上和/或休眠時的設定,請開啟休眠模式。"</string>
+ <string name="screensaver_settings_when_to_dream" msgid="8352267826043957746">"休眠模式開啟時間"</string>
<string name="screensaver_settings_dream_start" msgid="4998187847985120168">"立即開啟"</string>
<string name="screensaver_settings_button" msgid="7292214707625717013">"設定"</string>
<string name="automatic_brightness" msgid="5014143533884135461">"自動調整亮度"</string>
@@ -1668,7 +1668,7 @@
<string name="track_frame_time_summary" msgid="447577515813970287">"測量「adb shell dumpsys gfxinfo」指令中的轉譯時間"</string>
<string name="window_animation_scale_title" msgid="6162587588166114700">"視窗動畫比例"</string>
<string name="transition_animation_scale_title" msgid="387527540523595875">"轉場動畫比例"</string>
- <string name="animator_duration_scale_title" msgid="3406722410819934083">"Animator 影片長度比例"</string>
+ <string name="animator_duration_scale_title" msgid="3406722410819934083">"動畫影片長度比例"</string>
<string name="overlay_display_devices_title" msgid="5364176287998398539">"模擬次要顯示器"</string>
<string name="debug_applications_category" msgid="4206913653849771549">"應用程式"</string>
<string name="immediately_destroy_activities" msgid="8366775083630234121">"不要保留活動"</string>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 34b2d86..91f293c 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -54,4 +54,11 @@
<dimen name="pager_tabs_padding">0dp</dimen>
+ <!-- Size of AppWidget previews in KeyguardAppWidgetPickActivity -->
+ <dimen name="appwidget_preview_width">140dip</dimen>
+ <dimen name="appwidget_preview_height">80dip</dimen>
+ <dimen name="keyguard_appwidget_picker_max_width">800dip</dimen>
+ <dimen name="keyguard_appwidget_picker_margin_left">6dip</dimen>
+ <dimen name="keyguard_appwidget_picker_margin_right">6dip</dimen>
+ <integer name="keyguard_appwidget_picker_cols">1</integer>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 9b9cb83..dda22d9 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -191,4 +191,8 @@
<item name="android:textAllCaps">true</item>
<item name="android:textStyle">bold</item>
</style>
+
+ <style name="KeyguardAppWidgetItem">
+ <item name="android:textSize">18sp</item>
+ </style>
</resources>
diff --git a/src/com/android/settings/KeyguardAppWidgetPickActivity.java b/src/com/android/settings/KeyguardAppWidgetPickActivity.java
index c82906e..db5f115 100644
--- a/src/com/android/settings/KeyguardAppWidgetPickActivity.java
+++ b/src/com/android/settings/KeyguardAppWidgetPickActivity.java
@@ -17,26 +17,24 @@
package com.android.settings;
import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.LauncherActivity.IconResizer;
import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
-import android.graphics.ColorFilter;
import android.graphics.Paint;
-import android.graphics.PaintFlagsDrawFilter;
-import android.graphics.PixelFormat;
import android.graphics.Rect;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.PaintDrawable;
+import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
@@ -50,11 +48,13 @@
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
+import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.android.internal.widget.LockPatternUtils;
+import java.lang.ref.WeakReference;
import java.util.List;
/**
@@ -77,18 +77,18 @@
private AppWidgetLoader<Item> mAppWidgetLoader;
private List<Item> mItems;
private GridView mGridView;
+ private AppWidgetAdapter mAppWidgetAdapter;
private AppWidgetManager mAppWidgetManager;
private int mAppWidgetId;
// Might make it possible to make this be false in future
private boolean mAddingToKeyguard = true;
private Intent mResultData;
private LockPatternUtils mLockPatternUtils;
- private boolean mSuccess;
private Bundle mExtraConfigureOptions;
@Override
protected void onCreate(Bundle savedInstanceState) {
- setContentView(R.layout.keyguard_appwidget_pick_layout);
+ setContentView(R.layout.keyguard_appwidget_picker_layout);
super.onCreate(savedInstanceState);
// Set default return data
@@ -105,11 +105,19 @@
mExtraConfigureOptions = intent.getBundleExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS);
mGridView = (GridView) findViewById(R.id.widget_list);
+ DisplayMetrics dm = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(dm);
+ int maxGridWidth = getResources().getDimensionPixelSize(
+ R.dimen.keyguard_appwidget_picker_max_width);
+
+ if (maxGridWidth < dm.widthPixels) {
+ mGridView.getLayoutParams().width = maxGridWidth;
+ }
mAppWidgetManager = AppWidgetManager.getInstance(this);
mAppWidgetLoader = new AppWidgetLoader<Item>(this, mAppWidgetManager, this);
mItems = mAppWidgetLoader.getItems(getIntent());
- AppWidgetAdapter adapter = new AppWidgetAdapter(this, mItems);
- mGridView.setAdapter(adapter);
+ mAppWidgetAdapter = new AppWidgetAdapter(this, mItems);
+ mGridView.setAdapter(mAppWidgetAdapter);
mGridView.setOnItemClickListener(this);
mLockPatternUtils = new LockPatternUtils(this); // TEMP-- we want to delete this
@@ -127,207 +135,40 @@
setResult(code, result);
}
- private static class EmptyDrawable extends Drawable {
- private final int mWidth;
- private final int mHeight;
-
- EmptyDrawable(int width, int height) {
- mWidth = width;
- mHeight = height;
- }
-
- @Override
- public int getIntrinsicWidth() {
- return mWidth;
- }
-
- @Override
- public int getIntrinsicHeight() {
- return mHeight;
- }
-
- @Override
- public int getMinimumWidth() {
- return mWidth;
- }
-
- @Override
- public int getMinimumHeight() {
- return mHeight;
- }
-
- @Override
- public void draw(Canvas canvas) {
- }
-
- @Override
- public void setAlpha(int alpha) {
- }
-
- @Override
- public void setColorFilter(ColorFilter cf) {
- }
-
- @Override
- public int getOpacity() {
- return PixelFormat.TRANSLUCENT;
- }
- }
-
- /**
- * Utility class to resize icons to match default icon size. Code is mostly
- * borrowed from Launcher.
- */
- private static class IconResizer {
- private final int mIconWidth;
- private final int mIconHeight;
-
- private final DisplayMetrics mMetrics;
- private final Rect mOldBounds = new Rect();
- private final Canvas mCanvas = new Canvas();
-
- public IconResizer(int width, int height, DisplayMetrics metrics) {
- mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
- Paint.FILTER_BITMAP_FLAG));
-
- mMetrics = metrics;
- mIconWidth = width;
- mIconHeight = height;
- }
-
- /**
- * Returns a Drawable representing the thumbnail of the specified Drawable.
- * The size of the thumbnail is defined by the dimension
- * android.R.dimen.launcher_application_icon_size.
- *
- * This method is not thread-safe and should be invoked on the UI thread only.
- *
- * @param icon The icon to get a thumbnail of.
- *
- * @return A thumbnail for the specified icon or the icon itself if the
- * thumbnail could not be created.
- */
- public Drawable createIconThumbnail(Drawable icon) {
- int width = mIconWidth;
- int height = mIconHeight;
-
- if (icon == null) {
- return new EmptyDrawable(width, height);
- }
-
- try {
- if (icon instanceof PaintDrawable) {
- PaintDrawable painter = (PaintDrawable) icon;
- painter.setIntrinsicWidth(width);
- painter.setIntrinsicHeight(height);
- } else if (icon instanceof BitmapDrawable) {
- // Ensure the bitmap has a density.
- BitmapDrawable bitmapDrawable = (BitmapDrawable) icon;
- Bitmap bitmap = bitmapDrawable.getBitmap();
- if (bitmap.getDensity() == Bitmap.DENSITY_NONE) {
- bitmapDrawable.setTargetDensity(mMetrics);
- }
- }
- int iconWidth = icon.getIntrinsicWidth();
- int iconHeight = icon.getIntrinsicHeight();
-
- if (iconWidth > 0 && iconHeight > 0) {
- if (width < iconWidth || height < iconHeight) {
- final float ratio = (float) iconWidth / iconHeight;
-
- if (iconWidth > iconHeight) {
- height = (int) (width / ratio);
- } else if (iconHeight > iconWidth) {
- width = (int) (height * ratio);
- }
-
- final Bitmap.Config c = icon.getOpacity() != PixelFormat.OPAQUE ?
- Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
- final Bitmap thumb = Bitmap.createBitmap(mIconWidth, mIconHeight, c);
- final Canvas canvas = mCanvas;
- canvas.setBitmap(thumb);
- // Copy the old bounds to restore them later
- // If we were to do oldBounds = icon.getBounds(),
- // the call to setBounds() that follows would
- // change the same instance and we would lose the
- // old bounds
- mOldBounds.set(icon.getBounds());
- final int x = (mIconWidth - width) / 2;
- final int y = (mIconHeight - height) / 2;
- icon.setBounds(x, y, x + width, y + height);
- icon.draw(canvas);
- icon.setBounds(mOldBounds);
- //noinspection deprecation
- icon = new BitmapDrawable(thumb);
- ((BitmapDrawable) icon).setTargetDensity(mMetrics);
- canvas.setBitmap(null);
- } else if (iconWidth < width && iconHeight < height) {
- final Bitmap.Config c = Bitmap.Config.ARGB_8888;
- final Bitmap thumb = Bitmap.createBitmap(mIconWidth, mIconHeight, c);
- final Canvas canvas = mCanvas;
- canvas.setBitmap(thumb);
- mOldBounds.set(icon.getBounds());
- final int x = (width - iconWidth) / 2;
- final int y = (height - iconHeight) / 2;
- icon.setBounds(x, y, x + iconWidth, y + iconHeight);
- icon.draw(canvas);
- icon.setBounds(mOldBounds);
- //noinspection deprecation
- icon = new BitmapDrawable(thumb);
- ((BitmapDrawable) icon).setTargetDensity(mMetrics);
- canvas.setBitmap(null);
- }
- }
-
- } catch (Throwable t) {
- icon = new EmptyDrawable(width, height);
- }
-
- return icon;
- }
- }
-
/**
* Item that appears in the AppWidget picker grid.
*/
public static class Item implements AppWidgetLoader.LabelledItem {
protected static IconResizer sResizer;
- protected IconResizer getResizer(Context context) {
- if (sResizer == null) {
- final Resources resources = context.getResources();
- int size = (int) resources.getDimension(android.R.dimen.app_icon_size);
- sResizer = new IconResizer(size, size, resources.getDisplayMetrics());
- }
- return sResizer;
- }
+
CharSequence label;
- Drawable icon;
+ int appWidgetPreviewId;
+ int iconId;
String packageName;
String className;
Bundle extras;
+ private WidgetPreviewLoader mWidgetPreviewLoader;
+ private Context mContext;
/**
* Create a list item from given label and icon.
*/
- Item(Context context, CharSequence label, Drawable icon) {
+ Item(Context context, CharSequence label) {
this.label = label;
- this.icon = getResizer(context).createIconThumbnail(icon);
+ mContext = context;
}
- /**
- * Create a list item and fill it with details from the given
- * {@link ResolveInfo} object.
- */
- Item(Context context, PackageManager pm, ResolveInfo resolveInfo) {
- label = resolveInfo.loadLabel(pm);
- if (label == null && resolveInfo.activityInfo != null) {
- label = resolveInfo.activityInfo.name;
- }
+ void loadWidgetPreview(ImageView v) {
+ mWidgetPreviewLoader = new WidgetPreviewLoader(mContext, v);
+ mWidgetPreviewLoader.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, (Void[]) null);
+ }
- icon = getResizer(context).createIconThumbnail(resolveInfo.loadIcon(pm));
- packageName = resolveInfo.activityInfo.applicationInfo.packageName;
- className = resolveInfo.activityInfo.name;
+ void cancelLoadingWidgetPreview() {
+ if (mWidgetPreviewLoader != null) {
+ mWidgetPreviewLoader.cancel(false);
+ mWidgetPreviewLoader = null;
+ }
}
/**
@@ -354,48 +195,259 @@
public CharSequence getLabel() {
return label;
}
+
+ class WidgetPreviewLoader extends AsyncTask<Void, Bitmap, Void> {
+ private Resources mResources;
+ private PackageManager mPackageManager;
+ private int mIconDpi;
+ private ImageView mView;
+ public WidgetPreviewLoader(Context context, ImageView v) {
+ super();
+ mResources = context.getResources();
+ mPackageManager = context.getPackageManager();
+ ActivityManager activityManager =
+ (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ mIconDpi = activityManager.getLauncherLargeIconDensity();
+ mView = v;
+ }
+ public Void doInBackground(Void... params) {
+ if (!isCancelled()) {
+ int appWidgetPreviewWidth =
+ mResources.getDimensionPixelSize(R.dimen.appwidget_preview_width);
+ int appWidgetPreviewHeight =
+ mResources.getDimensionPixelSize(R.dimen.appwidget_preview_height);
+ // TODO: fix the hspan, vspan of the default preview
+ Bitmap b = getWidgetPreview(new ComponentName(packageName, className),
+ appWidgetPreviewId, iconId,
+ appWidgetPreviewWidth, appWidgetPreviewHeight);
+ publishProgress(b);
+ }
+ return null;
+ }
+ public void onProgressUpdate(Bitmap... values) {
+ if (!isCancelled()) {
+ Bitmap b = values[0];
+ mView.setImageBitmap(b);
+ }
+ }
+ abstract class WeakReferenceThreadLocal<T> {
+ private ThreadLocal<WeakReference<T>> mThreadLocal;
+ public WeakReferenceThreadLocal() {
+ mThreadLocal = new ThreadLocal<WeakReference<T>>();
+ }
+
+ abstract T initialValue();
+
+ public void set(T t) {
+ mThreadLocal.set(new WeakReference<T>(t));
+ }
+
+ public T get() {
+ WeakReference<T> reference = mThreadLocal.get();
+ T obj;
+ if (reference == null) {
+ obj = initialValue();
+ mThreadLocal.set(new WeakReference<T>(obj));
+ return obj;
+ } else {
+ obj = reference.get();
+ if (obj == null) {
+ obj = initialValue();
+ mThreadLocal.set(new WeakReference<T>(obj));
+ }
+ return obj;
+ }
+ }
+ }
+
+ class CanvasCache extends WeakReferenceThreadLocal<Canvas> {
+ @Override
+ protected Canvas initialValue() {
+ return new Canvas();
+ }
+ }
+
+ class PaintCache extends WeakReferenceThreadLocal<Paint> {
+ @Override
+ protected Paint initialValue() {
+ return null;
+ }
+ }
+
+ class BitmapCache extends WeakReferenceThreadLocal<Bitmap> {
+ @Override
+ protected Bitmap initialValue() {
+ return null;
+ }
+ }
+
+ class RectCache extends WeakReferenceThreadLocal<Rect> {
+ @Override
+ protected Rect initialValue() {
+ return new Rect();
+ }
+ }
+
+ // Used for drawing widget previews
+ CanvasCache sCachedAppWidgetPreviewCanvas = new CanvasCache();
+ RectCache sCachedAppWidgetPreviewSrcRect = new RectCache();
+ RectCache sCachedAppWidgetPreviewDestRect = new RectCache();
+ PaintCache sCachedAppWidgetPreviewPaint = new PaintCache();
+
+ private Bitmap getWidgetPreview(ComponentName provider, int previewImage,
+ int iconId, int maxWidth, int maxHeight) {
+ // Load the preview image if possible
+ String packageName = provider.getPackageName();
+ if (maxWidth < 0) maxWidth = Integer.MAX_VALUE;
+ if (maxHeight < 0) maxHeight = Integer.MAX_VALUE;
+
+
+ int appIconSize = mResources.getDimensionPixelSize(R.dimen.app_icon_size);
+
+ Drawable drawable = null;
+ if (previewImage != 0) {
+ drawable = mPackageManager.getDrawable(packageName, previewImage, null);
+ if (drawable == null) {
+ Log.w(TAG, "Can't load widget preview drawable 0x" +
+ Integer.toHexString(previewImage) + " for provider: " + provider);
+ }
+ }
+
+ int bitmapWidth;
+ int bitmapHeight;
+ Bitmap defaultPreview = null;
+ boolean widgetPreviewExists = (drawable != null);
+ if (widgetPreviewExists) {
+ bitmapWidth = drawable.getIntrinsicWidth();
+ bitmapHeight = drawable.getIntrinsicHeight();
+ } else {
+ // Generate a preview image if we couldn't load one
+ bitmapWidth = maxWidth;
+ bitmapHeight = maxHeight;
+ defaultPreview = Bitmap.createBitmap(bitmapWidth, bitmapHeight,
+ Config.ARGB_8888);
+ final Canvas c = sCachedAppWidgetPreviewCanvas.get();
+ c.setBitmap(defaultPreview);
+ c.drawColor(0xFF2D2D2D);
+ c.setBitmap(null);
+
+ // Draw the icon in the top left corner
+ final float marginPercentage = 0.125f;
+ final float finalIconSize = (bitmapHeight / 2);
+ float iconScale = finalIconSize / appIconSize;
+
+ try {
+ Drawable icon = null;
+ int hoffset =
+ (int) (finalIconSize * marginPercentage);
+ int yoffset =
+ (int) (finalIconSize * marginPercentage);
+ if (iconId > 0)
+ icon = getFullResIcon(packageName, iconId);
+ if (icon != null) {
+ renderDrawableToBitmap(icon, defaultPreview, hoffset,
+ yoffset, (int) (appIconSize * iconScale),
+ (int) (appIconSize * iconScale));
+ }
+ } catch (Resources.NotFoundException e) {
+ }
+ }
+
+ // Scale to fit width only - let the widget preview be clipped in the
+ // vertical dimension
+ float scale = 1f;
+ if (bitmapWidth > maxWidth) {
+ scale = maxWidth / (float) bitmapWidth;
+ }
+ int finalPreviewWidth = (int) (scale * bitmapWidth);
+ int finalPreviewHeight = (int) (scale * bitmapHeight);
+
+ bitmapWidth = finalPreviewWidth;
+ bitmapHeight = Math.min(finalPreviewHeight, maxHeight);
+
+ Bitmap preview = Bitmap.createBitmap(bitmapWidth, bitmapHeight,
+ Config.ARGB_8888);
+
+ // Draw the scaled preview into the final bitmap
+ if (widgetPreviewExists) {
+ renderDrawableToBitmap(drawable, preview, 0, 0, finalPreviewWidth,
+ finalPreviewHeight);
+ } else {
+ final Canvas c = sCachedAppWidgetPreviewCanvas.get();
+ final Rect src = sCachedAppWidgetPreviewSrcRect.get();
+ final Rect dest = sCachedAppWidgetPreviewDestRect.get();
+ c.setBitmap(preview);
+ src.set(0, 0, defaultPreview.getWidth(), defaultPreview.getHeight());
+ dest.set(0, 0, finalPreviewWidth, finalPreviewHeight);
+
+ Paint p = sCachedAppWidgetPreviewPaint.get();
+ if (p == null) {
+ p = new Paint();
+ p.setFilterBitmap(true);
+ sCachedAppWidgetPreviewPaint.set(p);
+ }
+ c.drawBitmap(defaultPreview, src, dest, p);
+ c.setBitmap(null);
+ }
+ return preview;
+ }
+ public Drawable getFullResDefaultActivityIcon() {
+ return getFullResIcon(Resources.getSystem(),
+ android.R.mipmap.sym_def_app_icon);
+ }
+
+ public Drawable getFullResIcon(Resources resources, int iconId) {
+ Drawable d;
+ try {
+ d = resources.getDrawableForDensity(iconId, mIconDpi);
+ } catch (Resources.NotFoundException e) {
+ d = null;
+ }
+
+ return (d != null) ? d : getFullResDefaultActivityIcon();
+ }
+
+ public Drawable getFullResIcon(String packageName, int iconId) {
+ Resources resources;
+ try {
+ resources = mPackageManager.getResourcesForApplication(packageName);
+ } catch (PackageManager.NameNotFoundException e) {
+ resources = null;
+ }
+ if (resources != null) {
+ if (iconId != 0) {
+ return getFullResIcon(resources, iconId);
+ }
+ }
+ return getFullResDefaultActivityIcon();
+ }
+
+ private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h) {
+ renderDrawableToBitmap(d, bitmap, x, y, w, h, 1f);
+ }
+
+ private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h,
+ float scale) {
+ if (bitmap != null) {
+ Canvas c = new Canvas(bitmap);
+ c.scale(scale, scale);
+ Rect oldBounds = d.copyBounds();
+ d.setBounds(x, y, x + w, y + h);
+ d.draw(c);
+ d.setBounds(oldBounds); // Restore the bounds
+ c.setBitmap(null);
+ }
+ }
+ }
}
@Override
public Item createItem(Context context, AppWidgetProviderInfo info, Bundle extras) {
CharSequence label = info.label;
- Drawable icon = null;
- if (info.icon != 0) {
- try {
- final Resources res = context.getResources();
- final int density = res.getDisplayMetrics().densityDpi;
- int iconDensity;
- switch (density) {
- case DisplayMetrics.DENSITY_MEDIUM:
- iconDensity = DisplayMetrics.DENSITY_LOW;
- case DisplayMetrics.DENSITY_TV:
- iconDensity = DisplayMetrics.DENSITY_MEDIUM;
- case DisplayMetrics.DENSITY_HIGH:
- iconDensity = DisplayMetrics.DENSITY_MEDIUM;
- case DisplayMetrics.DENSITY_XHIGH:
- iconDensity = DisplayMetrics.DENSITY_HIGH;
- case DisplayMetrics.DENSITY_XXHIGH:
- iconDensity = DisplayMetrics.DENSITY_XHIGH;
- default:
- // The density is some abnormal value. Return some other
- // abnormal value that is a reasonable scaling of it.
- iconDensity = (int)((density*0.75f)+.5f);
- }
- Resources packageResources = getPackageManager().
- getResourcesForApplication(info.provider.getPackageName());
- icon = packageResources.getDrawableForDensity(info.icon, iconDensity);
- } catch (NameNotFoundException e) {
- Log.w(TAG, "Can't load icon drawable 0x" + Integer.toHexString(info.icon)
- + " for provider: " + info.provider);
- }
- if (icon == null) {
- Log.w(TAG, "Can't load icon drawable 0x" + Integer.toHexString(info.icon)
- + " for provider: " + info.provider);
- }
- }
-
- Item item = new Item(context, label, icon);
+ Item item = new Item(context, label);
+ item.appWidgetPreviewId = info.previewImage;
+ item.iconId = info.icon;
item.packageName = info.provider.getPackageName();
item.className = info.provider.getClassName();
item.extras = extras;
@@ -444,12 +496,19 @@
}
Item item = (Item) getItem(position);
- TextView textView = (TextView) convertView.findViewById(R.id.icon_and_label);
+ TextView textView = (TextView) convertView.findViewById(R.id.label);
textView.setText(item.label);
- textView.setCompoundDrawablesWithIntrinsicBounds(item.icon, null, null, null);
-
+ ImageView iconView = (ImageView) convertView.findViewById(R.id.icon);
+ iconView.setImageDrawable(null);
+ item.loadWidgetPreview(iconView);
return convertView;
}
+
+ public void cancelAllWidgetPreviewLoaders() {
+ for (int i = 0; i < mItems.size(); i++) {
+ mItems.get(i).cancelLoadingWidgetPreview();
+ }
+ }
}
/**
@@ -468,6 +527,11 @@
setResultData(result, intent);
} else {
try {
+ if (mAddingToKeyguard && mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
+ // Found in KeyguardHostView.java
+ final int KEYGUARD_HOST_ID = 0x4B455947;
+ mAppWidgetId = AppWidgetHost.allocateAppWidgetIdForSystem(KEYGUARD_HOST_ID);
+ }
mAppWidgetManager.bindAppWidgetId(
mAppWidgetId, intent.getComponent(), mExtraConfigureOptions);
result = RESULT_OK;
@@ -489,9 +553,8 @@
}
protected void onDestroy() {
- if (!mSuccess && mAddingToKeyguard &&
- mAppWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
- AppWidgetHost.deleteAppWidgetIdForSystem(mAppWidgetId);
+ if (mAppWidgetAdapter != null) {
+ mAppWidgetAdapter.cancelAllWidgetPreviewLoaders();
}
super.onDestroy();
}
@@ -500,20 +563,20 @@
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_PICK_APPWIDGET || requestCode == REQUEST_CREATE_APPWIDGET) {
- int appWidgetId = (data == null) ? -1 : data.getIntExtra(
- AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
- if ((requestCode == REQUEST_PICK_APPWIDGET) &&
- resultCode == Activity.RESULT_OK) {
+ int appWidgetId;
+ if (data == null) {
+ appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID ;
+ } else {
+ appWidgetId = data.getIntExtra(
+ AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
+ }
+ if (requestCode == REQUEST_PICK_APPWIDGET && resultCode == Activity.RESULT_OK) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
- boolean defaultWidget =
- data.getBooleanExtra(LockPatternUtils.EXTRA_DEFAULT_WIDGET, false);
AppWidgetProviderInfo appWidget = null;
- if (!defaultWidget) {
- appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId);
- }
+ appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId);
- if (!defaultWidget && appWidget.configure != null) {
+ if (appWidget.configure != null) {
// Launch over to configure widget, if needed
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
intent.setComponent(appWidget.configure);
@@ -523,29 +586,31 @@
startActivityForResultSafely(intent, REQUEST_CREATE_APPWIDGET);
} else {
// Otherwise just add it
- if (defaultWidget) {
- // If we selected "none", delete the allocated id
- AppWidgetHost.deleteAppWidgetIdForSystem(appWidgetId);
- data.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
- LockPatternUtils.ID_DEFAULT_STATUS_WIDGET);
- }
onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
}
} else if (requestCode == REQUEST_CREATE_APPWIDGET && resultCode == Activity.RESULT_OK) {
- mSuccess = true;
mLockPatternUtils.addAppWidget(appWidgetId, 0);
- finishDelayedAndShowLockScreen();
+ finishDelayedAndShowLockScreen(appWidgetId);
} else {
- finishDelayedAndShowLockScreen();
+ if (mAddingToKeyguard &&
+ mAppWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
+ AppWidgetHost.deleteAppWidgetIdForSystem(mAppWidgetId);
+ }
+ finishDelayedAndShowLockScreen(AppWidgetManager.INVALID_APPWIDGET_ID);
}
}
}
- private void finishDelayedAndShowLockScreen() {
+ private void finishDelayedAndShowLockScreen(int appWidgetId) {
IBinder b = ServiceManager.getService(Context.WINDOW_SERVICE);
IWindowManager iWm = IWindowManager.Stub.asInterface(b);
+ Bundle opts = null;
+ if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
+ opts = new Bundle();
+ opts.putInt(LockPatternUtils.KEYGUARD_SHOW_APPWIDGET, appWidgetId);
+ }
try {
- iWm.lockNow(null);
+ iWm.lockNow(opts);
} catch (RemoteException e) {
}