mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
Commit share app functionality for broader testing and comments
git-svn-id: https://zxing.googlecode.com/svn/trunk@1110 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
b710e257eb
commit
58b5bf7b0f
|
@ -105,6 +105,13 @@ versionName is 2.31, 2.4, or 3.0. -->
|
|||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".share.AppPickerActivity"
|
||||
android:label="@string/app_picker_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PICK"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".HelpActivity"
|
||||
android:screenOrientation="user">
|
||||
<intent-filter>
|
||||
|
|
|
@ -45,29 +45,39 @@
|
|||
android:src="@drawable/share_via_barcode"
|
||||
android:paddingRight="48dip"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/share_view"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button android:id="@+id/contact_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_contact"/>
|
||||
<TableRow>
|
||||
|
||||
<Button android:id="@+id/bookmark_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_bookmark"/>
|
||||
<Button android:id="@+id/contact_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_contact"/>
|
||||
|
||||
<Button android:id="@+id/clipboard_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_clipboard"/>
|
||||
<Button android:id="@+id/bookmark_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_bookmark"/>
|
||||
|
||||
</LinearLayout>
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<Button android:id="@+id/clipboard_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_clipboard"/>
|
||||
|
||||
<Button android:id="@+id/app_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_app"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -45,20 +45,39 @@
|
|||
android:src="@drawable/share_via_barcode"
|
||||
android:paddingBottom="32dip"/>
|
||||
|
||||
<Button android:id="@+id/contact_button"
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_contact"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button android:id="@+id/bookmark_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_bookmark"/>
|
||||
<TableRow>
|
||||
|
||||
<Button android:id="@+id/clipboard_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_clipboard"/>
|
||||
<Button android:id="@+id/contact_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_contact"/>
|
||||
|
||||
<Button android:id="@+id/bookmark_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_bookmark"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<Button android:id="@+id/clipboard_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_clipboard"/>
|
||||
|
||||
<Button android:id="@+id/app_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_app"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_picker_name">Anwendungen</string>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
<string name="bookmark_picker_name">Lesezeichen</string>
|
||||
<string name="button_add_calendar">Termin hinzufügen</string>
|
||||
|
@ -34,11 +35,12 @@
|
|||
<string name="button_product_search">Produktsuche</string>
|
||||
<string name="button_search_book_contents">Buchinhalt durchsuchen</string>
|
||||
<string name="button_read_book">Buch anzeigen</string>
|
||||
<string name="button_share_bookmark">Lesezeichen weitergeben</string>
|
||||
<string name="button_share_app">Anwendung</string>
|
||||
<string name="button_share_bookmark">Lesezeichen</string>
|
||||
<string name="button_share_by_email">Als E-Mail weitergeben</string>
|
||||
<string name="button_share_by_sms">Als SMS weitergeben</string>
|
||||
<string name="button_share_clipboard">Zwischenablage weitergeben</string>
|
||||
<string name="button_share_contact">Kontakt weitergeben</string>
|
||||
<string name="button_share_clipboard">Zwischenablage</string>
|
||||
<string name="button_share_contact">Kontakt</string>
|
||||
<string name="button_show_map">Karte anzeigen</string>
|
||||
<string name="button_sms">SMS senden</string>
|
||||
<string name="button_web_search">Im Web suchen</string>
|
||||
|
@ -63,6 +65,7 @@
|
|||
<string name="msg_encode_contents_failed">Aus den Daten kann kein Barcode erzeugt werden.</string>
|
||||
<string name="msg_encode_in_progress">Erzeuge Barcode\u2026</string>
|
||||
<string name="msg_intent_failed">Die gewünschte Applikation kann nicht geöffnet werden. Der Barcode könnte ungültig sein.</string>
|
||||
<string name="msg_loading_apps">Laden einer Liste von Anwendungen</string>
|
||||
<string name="msg_sbc_book_not_searchable">Das Buch kann nicht durchsucht werden.</string>
|
||||
<string name="msg_sbc_failed">Bei der Suche ist ein Fehler aufgetreten.</string>
|
||||
<string name="msg_sbc_no_page_returned">Keine Seite zurückgeliefert.</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_picker_name">Aplicaciónes</string>
|
||||
<string name="app_name">Escáner de código de barras</string>
|
||||
<string name="bookmark_picker_name">Marcadores</string>
|
||||
<string name="button_add_calendar">Añadir a calendario</string>
|
||||
|
@ -34,11 +35,12 @@
|
|||
<string name="button_product_search">Búsqueda de productos</string>
|
||||
<string name="button_search_book_contents">Buscar contenido dellibro</string>
|
||||
<string name="button_read_book">Búsqueda de libro</string>
|
||||
<string name="button_share_bookmark">Compartir marcador</string>
|
||||
<string name="button_share_app">Aplicación</string>
|
||||
<string name="button_share_bookmark">Marcador</string>
|
||||
<string name="button_share_by_email">Compartir por correo electrónico</string>
|
||||
<string name="button_share_by_sms">Compartir por SMS</string>
|
||||
<string name="button_share_clipboard">Compartir portapapeles</string>
|
||||
<string name="button_share_contact">Compartir contacto</string>
|
||||
<string name="button_share_clipboard">Portapapeles</string>
|
||||
<string name="button_share_contact">Contacto</string>
|
||||
<string name="button_show_map">Mostrar mapa</string>
|
||||
<string name="button_sms">Enviar SMS</string>
|
||||
<string name="button_web_search">Búsqueda Web</string>
|
||||
|
@ -63,6 +65,7 @@
|
|||
<string name="msg_encode_contents_failed">No puede codificar un código de barras con estos datos.</string>
|
||||
<string name="msg_encode_in_progress">Generando un código de barras\u2026</string>
|
||||
<string name="msg_intent_failed">Lo sentimos, la aplicación solicitada no pudo ser lanzada. El contenido de código de barras puede ser inválida.</string>
|
||||
<string name="msg_loading_apps">Cargando una lista de aplicaciones</string>
|
||||
<string name="msg_sbc_book_not_searchable">Lo sentimos, no se puede buscar en este libro.</string>
|
||||
<string name="msg_sbc_failed">Lo sentimos, la búsqueda ha detectado un problema.</string>
|
||||
<string name="msg_sbc_no_page_returned">Página no encontrada</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_picker_name">Applications</string>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
<string name="bookmark_picker_name">Marques-pages</string>
|
||||
<string name="button_add_calendar">Ajouter à l\'agenda</string>
|
||||
|
@ -34,11 +35,12 @@
|
|||
<string name="button_product_search">Recherche de produits</string>
|
||||
<string name="button_search_book_contents">Recherche contenu du livre</string>
|
||||
<string name="button_read_book">Parcourir le livre</string>
|
||||
<string name="button_share_bookmark">Partager marques-pages</string>
|
||||
<string name="button_share_app">Application</string>
|
||||
<string name="button_share_bookmark">Marques-pages</string>
|
||||
<string name="button_share_by_email">Partager par email</string>
|
||||
<string name="button_share_by_sms">Partager par SMS</string>
|
||||
<string name="button_share_clipboard">Partager le presse papier</string>
|
||||
<string name="button_share_contact">Partager contact</string>
|
||||
<string name="button_share_clipboard">Presse papier</string>
|
||||
<string name="button_share_contact">Contact</string>
|
||||
<string name="button_show_map">Montrer la carte</string>
|
||||
<string name="button_sms">Envoyer SMS</string>
|
||||
<string name="button_web_search">Recherche Web</string>
|
||||
|
@ -63,6 +65,7 @@
|
|||
<string name="msg_encode_contents_failed">Impossible de créer le code barre à partir des données fournies.</string>
|
||||
<string name="msg_encode_in_progress">Génération du code barre\u2026</string>
|
||||
<string name="msg_intent_failed">Désolé, l\'application demandée n\'a pas pu être lancé. Le contenu du code barre peut être invalide.</string>
|
||||
<string name="msg_loading_apps">Chargement d'une liste d'applications</string>
|
||||
<string name="msg_sbc_book_not_searchable">Désolé, ce livre n\'est pas trouvable.</string>
|
||||
<string name="msg_sbc_failed">Désolé, la recherche a rencontrée un problème.</string>
|
||||
<string name="msg_sbc_no_page_returned">Page non trouvée</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_picker_name">Applications</string>
|
||||
<string name="app_name">Scansione codice a barre</string>
|
||||
<string name="bookmark_picker_name">Segnalibri</string>
|
||||
<string name="button_add_calendar">Aggiungi al calendario</string>
|
||||
|
@ -34,11 +35,12 @@
|
|||
<string name="button_product_search">Cerca prodotto</string>
|
||||
<string name="button_search_book_contents">Cerca contenuti libro</string>
|
||||
<string name="button_read_book">Sfoglia libro</string>
|
||||
<string name="button_share_bookmark">Condividi segnalibro</string>
|
||||
<string name="button_share_app">Applicazione</string>
|
||||
<string name="button_share_bookmark">Segnalibro</string>
|
||||
<string name="button_share_by_email">Condividi tramite email</string>
|
||||
<string name="button_share_by_sms">Condividi tramite SMS</string>
|
||||
<string name="button_share_clipboard">Condividi appunti</string>
|
||||
<string name="button_share_contact">Condividi contatto</string>
|
||||
<string name="button_share_clipboard">Appunti</string>
|
||||
<string name="button_share_contact">Contatto</string>
|
||||
<string name="button_show_map">Mostra mappa</string>
|
||||
<string name="button_sms">Invia SMS</string>
|
||||
<string name="button_web_search">Ricerca web</string>
|
||||
|
@ -63,6 +65,7 @@
|
|||
<string name="msg_encode_contents_failed">Impossibile codificare un codice a barre dai dati forniti.</string>
|
||||
<string name="msg_encode_in_progress">Generazione codice a barre\u2026</string>
|
||||
<string name="msg_intent_failed">Spiacenti, l\'applicazione richiesta non può essere avviata. Il contenuto del codice a barre può essere non valido.</string>
|
||||
<string name="msg_loading_apps">Carico della lista delle applicazioni</string>
|
||||
<string name="msg_sbc_book_not_searchable">Spiacenti, questo libro non è ricercabile.</string>
|
||||
<string name="msg_sbc_failed">Spiacenti, la ricerca ha avuto un problema.</string>
|
||||
<string name="msg_sbc_no_page_returned">Nessuna pagina restitiuta</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_picker_name">アプリケーション</string>
|
||||
<string name="app_name">QRコードスキャナー</string>
|
||||
<string name="bookmark_picker_name">ブックマーク</string>
|
||||
<string name="button_add_calendar">カレンダーに追加</string>
|
||||
|
@ -34,6 +35,7 @@
|
|||
<string name="button_product_search">商品検索</string>
|
||||
<string name="button_search_book_contents">書籍の内容を検索する</string>
|
||||
<string name="button_read_book">閲覧図書</string>
|
||||
<string name="button_share_app">応募で送信する</string>
|
||||
<string name="button_share_bookmark">ブックマークを送信する</string>
|
||||
<string name="button_share_by_email">メールで送信する</string>
|
||||
<string name="button_share_by_sms">SMSで送信する</string>
|
||||
|
@ -63,6 +65,7 @@
|
|||
<string name="msg_encode_contents_failed">このデータからバーコードを作成できませんでした。</string>
|
||||
<string name="msg_encode_in_progress">バーコード作成中\u2026</string>
|
||||
<string name="msg_intent_failed">指定されたアプリケーションを起動できませんでした。バーコードの内容が無効である可能性があります。</string>
|
||||
<string name="msg_loading_apps">適用のリストの負荷</string>
|
||||
<string name="msg_sbc_book_not_searchable">この書籍は検索できません。</string>
|
||||
<string name="msg_sbc_failed">検索中に問題が発生しました。</string>
|
||||
<string name="msg_sbc_no_page_returned">検索結果はありません</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_picker_name">Применения</string>
|
||||
<string name="app_name">Сканер штрих-кодов</string>
|
||||
<string name="bookmark_picker_name">Закладки</string>
|
||||
<string name="button_add_calendar">Добавить в календарь</string>
|
||||
|
@ -34,11 +35,12 @@
|
|||
<string name="button_product_search">Поиск товара</string>
|
||||
<string name="button_search_book_contents">Поиск содержания книги</string>
|
||||
<string name="button_read_book">Открыть книгу</string>
|
||||
<string name="button_share_bookmark">Поделиться закладкой</string>
|
||||
<string name="button_share_app">Приложение</string>
|
||||
<string name="button_share_bookmark">Закладкой</string>
|
||||
<string name="button_share_by_email">Поделиться через эл. почту</string>
|
||||
<string name="button_share_by_sms">Поделиться через SMS</string>
|
||||
<string name="button_share_clipboard">Поделиться буфером обмена</string>
|
||||
<string name="button_share_contact">Поделиться контактом</string>
|
||||
<string name="button_share_clipboard">Буфер обмена</string>
|
||||
<string name="button_share_contact">Контактом</string>
|
||||
<string name="button_show_map">Показать карту</string>
|
||||
<string name="button_sms">Послать SMS</string>
|
||||
<string name="button_web_search">Поиск в Вебе</string>
|
||||
|
@ -63,6 +65,7 @@
|
|||
<string name="msg_encode_contents_failed">Не могу закодировать штрих-код от источник данных.</string>
|
||||
<string name="msg_encode_in_progress">Генерация штрих-кода\u2026</string>
|
||||
<string name="msg_intent_failed">К сожалению, запрошенное приложение не может быть запущенно. Содержимое штрих-кода может быть повреждено.</string>
|
||||
<string name="msg_loading_apps">Нагружать список применений</string>
|
||||
<string name="msg_sbc_book_not_searchable">К сожалению, поиск книги не удался.</string>
|
||||
<string name="msg_sbc_failed">К сожалению, у поиска возникли проблемы.</string>
|
||||
<string name="msg_sbc_no_page_returned">Ни одна страница не возвращена</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_picker_name">应用</string>
|
||||
<string name="app_name">条码扫描器</string>
|
||||
<string name="bookmark_picker_name">书签</string>
|
||||
<string name="button_add_calendar">添加事件至日历</string>
|
||||
|
@ -34,6 +35,7 @@
|
|||
<string name="button_product_search">打开产品搜索</string>
|
||||
<string name="button_search_book_contents">搜索图书内容</string>
|
||||
<string name="button_read_book">浏览本书</string>
|
||||
<string name="button_share_app">共享应用</string>
|
||||
<string name="button_share_bookmark">分享书签</string>
|
||||
<string name="button_share_by_email">通过email分享</string>
|
||||
<string name="button_share_by_sms">通过短信分享</string>
|
||||
|
@ -63,6 +65,7 @@
|
|||
<string name="msg_encode_contents_failed">不能从已有数据中读取条码。 </string>
|
||||
<string name="msg_encode_in_progress">正在生成条码\u2026</string>
|
||||
<string name="msg_intent_failed">抱歉,无法打开所需软件。 条码内容可能无效。</string>
|
||||
<string name="msg_loading_apps">装载应用名单</string>
|
||||
<string name="msg_sbc_book_not_searchable">抱歉,无法找到此图书。</string>
|
||||
<string name="msg_sbc_failed">抱歉,搜索时遇到错误。</string>
|
||||
<string name="msg_sbc_no_page_returned">没有返回页面</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_picker_name">應用</string>
|
||||
<string name="app_name">條碼掃描器</string>
|
||||
<string name="bookmark_picker_name">書簽</string>
|
||||
<string name="button_add_calendar">添加事件至日歷</string>
|
||||
|
@ -34,6 +35,7 @@
|
|||
<string name="button_product_search">打開產品搜索</string>
|
||||
<string name="button_search_book_contents">搜索圖書內容</string>
|
||||
<string name="button_read_book">瀏覽本書</string>
|
||||
<string name="button_share_app">共享應用</string>
|
||||
<string name="button_share_bookmark">分享書簽</string>
|
||||
<string name="button_share_by_email">通過email分享</string>
|
||||
<string name="button_share_by_sms">通過短信分享</string>
|
||||
|
@ -63,6 +65,7 @@
|
|||
<string name="msg_encode_contents_failed">不能從已有數據中讀取條碼。 </string>
|
||||
<string name="msg_encode_in_progress">正在生成條碼\u2026</string>
|
||||
<string name="msg_intent_failed">抱歉,無法打開所需軟件。 條碼內容可能無效。</string>
|
||||
<string name="msg_loading_apps">裝載應用名單</string>
|
||||
<string name="msg_sbc_book_not_searchable">抱歉,無法找到此圖書。</string>
|
||||
<string name="msg_sbc_failed">抱歉,搜索時遇到錯誤。</string>
|
||||
<string name="msg_sbc_no_page_returned">沒有返回頁面</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="app_picker_name">Applications</string>
|
||||
<string name="app_name">Barcode Scanner</string>
|
||||
<string name="bookmark_picker_name">Bookmarks</string>
|
||||
<string name="button_add_calendar">Add to calendar</string>
|
||||
|
@ -34,11 +35,12 @@
|
|||
<string name="button_product_search">Product Search</string>
|
||||
<string name="button_search_book_contents">Search book contents</string>
|
||||
<string name="button_read_book">Browse book</string>
|
||||
<string name="button_share_bookmark">Share bookmark</string>
|
||||
<string name="button_share_app">Application</string>
|
||||
<string name="button_share_bookmark">Bookmark</string>
|
||||
<string name="button_share_by_email">Share via email</string>
|
||||
<string name="button_share_by_sms">Share via SMS</string>
|
||||
<string name="button_share_clipboard">Share clipboard</string>
|
||||
<string name="button_share_contact">Share contact</string>
|
||||
<string name="button_share_clipboard">Clipboard</string>
|
||||
<string name="button_share_contact">Contact</string>
|
||||
<string name="button_show_map">Show map</string>
|
||||
<string name="button_sms">Send SMS</string>
|
||||
<string name="button_web_search">Web search</string>
|
||||
|
@ -63,6 +65,7 @@
|
|||
<string name="msg_encode_contents_failed">Could not encode a barcode from the data provided.</string>
|
||||
<string name="msg_encode_in_progress">Generating a barcode\u2026</string>
|
||||
<string name="msg_intent_failed">Sorry, the requested application could not be launched. The barcode contents may be invalid.</string>
|
||||
<string name="msg_loading_apps">Loading list of applications</string>
|
||||
<string name="msg_sbc_book_not_searchable">Sorry, this book is not searchable.</string>
|
||||
<string name="msg_sbc_failed">Sorry, the search encountered a problem.</string>
|
||||
<string name="msg_sbc_no_page_returned">No page returned</string>
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (C) 2009 ZXing authors
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.zxing.client.android.share;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Browser;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import com.google.zxing.client.android.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class AppPickerActivity extends ListActivity {
|
||||
|
||||
private final List<String[]> labelsPackages = new ArrayList<String[]>();
|
||||
private ProgressDialog dialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
dialog = ProgressDialog.show(this, "", getString(R.string.msg_loading_apps), true, true);
|
||||
new LoadPackagesAsyncTask(this).execute(labelsPackages);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View view, int position, long id) {
|
||||
if (position >= 0 && position < labelsPackages.size()) {
|
||||
String url = "market://search?q=pname:" + labelsPackages.get(position)[1];
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Browser.BookmarkColumns.URL, url);
|
||||
setResult(RESULT_OK, intent);
|
||||
} else {
|
||||
setResult(RESULT_CANCELED);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
ProgressDialog getProgressDialog() {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (C) 2009 ZXing authors
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.zxing.client.android.share;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<String[]>> {
|
||||
|
||||
private final AppPickerActivity appPickerActivity;
|
||||
|
||||
LoadPackagesAsyncTask(AppPickerActivity appPickerActivity) {
|
||||
this.appPickerActivity = appPickerActivity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String[]> doInBackground(List<String[]>... objects) {
|
||||
List<String[]> labelsPackages = objects[0];
|
||||
PackageManager packageManager = appPickerActivity.getPackageManager();
|
||||
List<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
|
||||
for (ApplicationInfo appInfo : appInfos) {
|
||||
CharSequence label = appInfo.loadLabel(packageManager);
|
||||
if (label != null) {
|
||||
labelsPackages.add(new String[]{label.toString(), appInfo.packageName});
|
||||
}
|
||||
}
|
||||
Collections.sort(labelsPackages, new Comparator<String[]>() {
|
||||
public int compare(String[] o1, String[] o2) {
|
||||
return o1[0].compareTo(o2[0]);
|
||||
}
|
||||
});
|
||||
return labelsPackages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<String[]> results) {
|
||||
List<String> labels = new ArrayList<String>(results.size());
|
||||
for (String[] result : results) {
|
||||
labels.add(result[0]);
|
||||
}
|
||||
ListAdapter listAdapter = new ArrayAdapter<String>(
|
||||
appPickerActivity, android.R.layout.simple_list_item_1, labels);
|
||||
appPickerActivity.setListAdapter(listAdapter);
|
||||
appPickerActivity.getProgressDialog().dismiss();
|
||||
}
|
||||
|
||||
}
|
|
@ -39,8 +39,10 @@ import com.google.zxing.client.android.R;
|
|||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
public final class ShareActivity extends Activity {
|
||||
|
||||
private static final int PICK_BOOKMARK = 0;
|
||||
private static final int PICK_CONTACT = 1;
|
||||
private static final int PICK_APP = 2;
|
||||
|
||||
//private static final int METHODS_ID_COLUMN = 0;
|
||||
private static final int METHODS_KIND_COLUMN = 1;
|
||||
|
@ -76,6 +78,14 @@ public final class ShareActivity extends Activity {
|
|||
}
|
||||
};
|
||||
|
||||
private final Button.OnClickListener appListener = new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK);
|
||||
intent.setClassName(ShareActivity.this, AppPickerActivity.class.getName());
|
||||
startActivityForResult(intent, PICK_APP);
|
||||
}
|
||||
};
|
||||
|
||||
private final Button.OnClickListener clipboardListener = new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
|
@ -95,10 +105,9 @@ public final class ShareActivity extends Activity {
|
|||
super.onCreate(icicle);
|
||||
setContentView(R.layout.share);
|
||||
|
||||
Button mContactButton = (Button) findViewById(R.id.contact_button);
|
||||
mContactButton.setOnClickListener(contactListener);
|
||||
Button mBookmarkButton = (Button) findViewById(R.id.bookmark_button);
|
||||
mBookmarkButton.setOnClickListener(bookmarkListener);
|
||||
findViewById(R.id.contact_button).setOnClickListener(contactListener);
|
||||
findViewById(R.id.bookmark_button).setOnClickListener(bookmarkListener);
|
||||
findViewById(R.id.app_button).setOnClickListener(appListener);
|
||||
clipboardButton = (Button) findViewById(R.id.clipboard_button);
|
||||
clipboardButton.setOnClickListener(clipboardListener);
|
||||
}
|
||||
|
@ -122,6 +131,7 @@ public final class ShareActivity extends Activity {
|
|||
if (resultCode == RESULT_OK) {
|
||||
switch (requestCode) {
|
||||
case PICK_BOOKMARK:
|
||||
case PICK_APP:
|
||||
showTextAsBarcode(intent.getStringExtra(Browser.BookmarkColumns.URL));
|
||||
break;
|
||||
case PICK_CONTACT:
|
||||
|
|
Loading…
Reference in a new issue