Issue 987 chop down most of the wi-fi functionality so that it triggers the network change and moves on; seems much less fragile in the face of Android device strangeness

git-svn-id: https://zxing.googlecode.com/svn/trunk@1929 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2011-09-24 15:46:17 +00:00
parent 6a85049428
commit 4add23c286
39 changed files with 258 additions and 844 deletions

View file

@ -103,11 +103,6 @@ versionName is 2.31, 2.4, or 3.0. -->
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".wifi.WifiActivity"
android:label="@string/wa_name"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden">
</activity>
<activity android:name=".share.ShareActivity"
android:label="@string/share_name"
android:screenOrientation="user"

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/networkStatus"
android:text="Status" android:textSize="20dip"
android:padding="8dip"
android:layout_gravity="center_horizontal|bottom" />
</LinearLayout>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">البحث في Google Book</string>
<string name="share_name">مشاركة عبر الرمز الشريطي</string>
<string name="title_about">إصدار ماسح الرمز الشريطي</string>
<string name="wa_name">التكوين اللاسلك</string>
<string name="wifi_changing_network">تغيير الشبكة</string>
<string name="wifi_connect_failed">فشل شبكة الاتصال</string>
<string name="wifi_connected">متصل</string>
<string name="wifi_creating_network">إنشاء شبكة</string>
<string name="wifi_modifying_network">تعديل شبكة</string>
<string name="wifi_ssid_label">اسم الشبكة</string>
<string name="wifi_ssid_missing">اسم الشبكة مفقود</string>
<string name="wifi_type_incorrect">شبكة نوع غير صحيح</string>
<string name="wifi_type_label">نوع</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Гугъл търсене на книга</string>
<string name="share_name">Сподели чрез баркод</string>
<string name="title_about">Баркод Скенер v</string>
<string name="wa_name">WLAN Връзка</string>
<string name="wifi_changing_network">Смяна на мрежата</string>
<string name="wifi_connect_failed">Неуспешно свързване с мрежата</string>
<string name="wifi_connected">Свързан</string>
<string name="wifi_creating_network">Създаване на мрежата</string>
<string name="wifi_modifying_network">Промяна на мрежата</string>
<string name="wifi_ssid_label">Име на мрежата</string>
<string name="wifi_ssid_missing">Липсва име на мрежата</string>
<string name="wifi_type_incorrect">Некоректен тип мрежа</string>
<string name="wifi_type_label">Тип</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google Knihy hledání</string>
<string name="share_name">Sdílet pomocí čárového kódu</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">Bezdrátová konfigurace</string>
<string name="wifi_changing_network">Změna síť</string>
<string name="wifi_connect_failed">Síťové připojení se nezdařilo</string>
<string name="wifi_connected">Připojeno</string>
<string name="wifi_creating_network">Vytvoření sítě</string>
<string name="wifi_modifying_network">Úprava sítě</string>
<string name="wifi_ssid_label">Jméno sítě</string>
<string name="wifi_ssid_missing">Název sítě chybí</string>
<string name="wifi_type_incorrect">Typ sítě nesprávné</string>
<string name="wifi_type_label">Typ</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google Bøger-søgning</string>
<string name="share_name">Del via stregkode</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">WLAN-forbindelse</string>
<string name="wifi_changing_network">Skifter netværk</string>
<string name="wifi_connect_failed">Netværksforbindelse mislykkedes</string>
<string name="wifi_connected">Forbundet</string>
<string name="wifi_creating_network">Opretter netværk</string>
<string name="wifi_modifying_network">Ændrer netværk</string>
<string name="wifi_ssid_label">Netværksnavn</string>
<string name="wifi_ssid_missing">Netværksnavn mangler</string>
<string name="wifi_type_incorrect">Netværkstype forkert</string>
<string name="wifi_type_label">Type</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google Book Search</string>
<string name="share_name">Weitergabe mittels Barcode</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">WLAN-Konfiguration</string>
<string name="wifi_changing_network">Ändern der Netzwerkeinstellungen</string>
<string name="wifi_connect_failed">Verbinden mit Netzwerk fehlgeschlagen</string>
<string name="wifi_connected">Verbunden</string>
<string name="wifi_creating_network">Erstelle Netzwerk</string>
<string name="wifi_modifying_network">Verändere Netzwerk</string>
<string name="wifi_ssid_label">Netzwerk-Name</string>
<string name="wifi_ssid_missing">Netzwerk-Name fehlt</string>
<string name="wifi_type_incorrect">Falscher Netzwerk-Typ</string>
<string name="wifi_type_label">Typ</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Αναζήτηση βιβλίων Google</string>
<string name="share_name">Κοινή χρήση μέσω barcode</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">Σύνδεση WLAN</string>
<string name="wifi_changing_network">Αλλαγή Δικτύου</string>
<string name="wifi_connect_failed">Σφάλμα στην σύνδεση Δικτύου</string>
<string name="wifi_connected">Συνδέθηκε</string>
<string name="wifi_creating_network">Δημιουργία Δικτύου</string>
<string name="wifi_modifying_network">Επεξεργασία Δικτύου</string>
<string name="wifi_ssid_label">Όνομα Δικτύου</string>
<string name="wifi_ssid_missing">Λείπει όνομα Δικτύου</string>
<string name="wifi_type_incorrect">Λάθος τύπος Δικτύου</string>
<string name="wifi_type_label">Τύπος</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Búsqueda de libros de Google</string>
<string name="share_name">Compartir por códigos de barras</string>
<string name="title_about">Escáner de código de barras v</string>
<string name="wa_name">Configuración de la red</string>
<string name="wifi_changing_network">Cambio de la red</string>
<string name="wifi_connect_failed">Conexión de red no</string>
<string name="wifi_connected">Conectado</string>
<string name="wifi_creating_network">Creación de la Red</string>
<string name="wifi_modifying_network">Modificación de la Red</string>
<string name="wifi_ssid_label">Nombre de red</string>
<string name="wifi_ssid_missing">Nombre de la red desaparecidas</string>
<string name="wifi_type_incorrect">Red de tipo incorrecto</string>
<string name="wifi_type_label">Tipo</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google kirja haku</string>
<string name="share_name">Jaa viivakoodilla</string>
<string name="title_about">Viivakoodin lukija v</string>
<string name="wa_name">Langattoman yhteyden</string>
<string name="wifi_changing_network">Vaihtaminen Verkko</string>
<string name="wifi_connect_failed">Verkkoyhteys ei</string>
<string name="wifi_connected">Kytketty</string>
<string name="wifi_creating_network">Luominen verkoston</string>
<string name="wifi_modifying_network">Muuttaminen Verkko</string>
<string name="wifi_ssid_label">Verkon nimi</string>
<string name="wifi_ssid_missing">Verkon nimi puuttuu</string>
<string name="wifi_type_incorrect">Verkon tyyppi virheellinen</string>
<string name="wifi_type_label">Tyyppi</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Recherche Google Livres</string>
<string name="share_name">Partager par code-barres</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">Configuration du réseau WLAN</string>
<string name="wifi_changing_network">Changement de réseau WLAN</string>
<string name="wifi_connect_failed">La connexion au réseau WLAN a échoué</string>
<string name="wifi_connected">Connecté au réseau WLAN</string>
<string name="wifi_creating_network">Création d\'un réseau WLAN</string>
<string name="wifi_modifying_network">Modification du réseau WLAN</string>
<string name="wifi_ssid_label">Nom du réseau WLAN</string>
<string name="wifi_ssid_missing">Nom du réseau WLAN requis</string>
<string name="wifi_type_incorrect">Type de réseau WLAN incorrect</string>
<string name="wifi_type_label">Type</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google חיפוש ספרים</string>
<string name="share_name">שתף באמצעות ברקוד</string>
<string name="title_about">סורק ברקודים</string>
<string name="wa_name">חיבור רשת אל חוטית</string>
<string name="wifi_changing_network">מחליף רשת</string>
<string name="wifi_connect_failed">חיבור לרשת נכשל</string>
<string name="wifi_connected">מחובר</string>
<string name="wifi_creating_network">יוצר רשת</string>
<string name="wifi_modifying_network">משנה רשת</string>
<string name="wifi_ssid_label">שם רשת</string>
<string name="wifi_ssid_missing">שם הרשת חסר</string>
<string name="wifi_type_incorrect">סוג הרשת שגוי</string>
<string name="wifi_type_label">סוג</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google Könyvek</string>
<string name="share_name">Megosztás vonalkóddal</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">Hálózati konfiguráció</string>
<string name="wifi_changing_network">Változó Hálózat</string>
<string name="wifi_connect_failed">Hálózati kapcsolat nem</string>
<string name="wifi_connected">Összefüggő</string>
<string name="wifi_creating_network">Hálózat létrehozása</string>
<string name="wifi_modifying_network">Módosítása Hálózat</string>
<string name="wifi_ssid_label">Hálózat neve</string>
<string name="wifi_ssid_missing">A hálózat neve hiányzik</string>
<string name="wifi_type_incorrect">Hálózati típusú hibás</string>
<string name="wifi_type_label">Típusú</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Pencarian Google Book</string>
<string name="share_name">Bagian melalui barcode</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">Koneksi WLAN</string>
<string name="wifi_changing_network">Ubah Koneksi</string>
<string name="wifi_connect_failed">Koneksi ke jaringan gagal</string>
<string name="wifi_connected">Terhubung</string>
<string name="wifi_creating_network">Buat Koneksi</string>
<string name="wifi_modifying_network">Perbarui Jaringan</string>
<string name="wifi_ssid_label">Nama Jaringan</string>
<string name="wifi_ssid_missing">Nama jaringan hilang</string>
<string name="wifi_type_incorrect">Jenis jaringan salah</string>
<string name="wifi_type_label">Tipe</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Ricerca Google Book</string>
<string name="share_name">Condividi tramite codice a barre</string>
<string name="title_about">Scansione codice a barre v</string>
<string name="wa_name">Configurazione WLAN</string>
<string name="wifi_changing_network">Cambio rete</string>
<string name="wifi_connect_failed">Connessione di rete fallita</string>
<string name="wifi_connected">Connesso</string>
<string name="wifi_creating_network">Creazione rete</string>
<string name="wifi_modifying_network">Modifica rete</string>
<string name="wifi_ssid_label">Nome rete</string>
<string name="wifi_ssid_missing">Nome di rete mancante</string>
<string name="wifi_type_incorrect">Tipo di rete non corretto</string>
<string name="wifi_type_label">Tipo</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google חיפוש ספרים</string>
<string name="share_name">שתף באמצעות ברקוד</string>
<string name="title_about">סורק ברקודים</string>
<string name="wa_name">חיבור רשת אל חוטית</string>
<string name="wifi_changing_network">מחליף רשת</string>
<string name="wifi_connect_failed">חיבור לרשת נכשל</string>
<string name="wifi_connected">מחובר</string>
<string name="wifi_creating_network">יוצר רשת</string>
<string name="wifi_modifying_network">משנה רשת</string>
<string name="wifi_ssid_label">שם רשת</string>
<string name="wifi_ssid_missing">שם הרשת חסר</string>
<string name="wifi_type_incorrect">סוג הרשת שגוי</string>
<string name="wifi_type_label">סוג</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google ブックス</string>
<string name="share_name">バーコードで共有する</string>
<string name="title_about">QRコードスキャナー v</string>
<string name="wa_name">ネットワーク構成</string>
<string name="wifi_changing_network">ネットワークを変更する</string>
<string name="wifi_connect_failed">ネットワーク接続が失敗しました。</string>
<string name="wifi_connected">接続</string>
<string name="wifi_creating_network">ネットワーク作成</string>
<string name="wifi_modifying_network">ネットワークを変更する</string>
<string name="wifi_ssid_label">ネットワーク名</string>
<string name="wifi_ssid_missing">SSIDがありません</string>
<string name="wifi_type_incorrect">ネットワーク種類が不正</string>
<string name="wifi_type_label">タイプ</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">구글 책 검색</string>
<string name="share_name">바코드로 공유</string>
<string name="title_about">바코드 스캐너 v</string>
<string name="wa_name">WiFi 연결</string>
<string name="wifi_changing_network">연결을 변경중입니다</string>
<string name="wifi_connect_failed">네트워크 연결 실패</string>
<string name="wifi_connected">연결됨</string>
<string name="wifi_creating_network">네트워크를 만드는중</string>
<string name="wifi_modifying_network">네트워크를 수정중</string>
<string name="wifi_ssid_label">네트워크 이름</string>
<string name="wifi_ssid_missing">네트워크 이름이 없습니다</string>
<string name="wifi_type_incorrect">네트워크 종류가 잘못 됬습니다</string>
<string name="wifi_type_label">종류</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Zoek boeken met Google Books</string>
<string name="share_name">Deel via barcode</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">Netwerkconfiguratie</string>
<string name="wifi_changing_network">Veranderen van Netwerk</string>
<string name="wifi_connect_failed">Netwerk verbinding is mislukt</string>
<string name="wifi_connected">Verbonden</string>
<string name="wifi_creating_network">Netwerk creeren</string>
<string name="wifi_modifying_network">Netwerk wijzigen</string>
<string name="wifi_ssid_label">Netwerknaam (SSID)</string>
<string name="wifi_ssid_missing">Netwerk naam ontbreekt</string>
<string name="wifi_type_incorrect">Onjuist netwerktype</string>
<string name="wifi_type_label">Type</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Wyszukiwanie książek Google</string>
<string name="share_name">Udostępnij przez kod paskowy</string>
<string name="title_about">Skaner Kodów Paskowych v</string>
<string name="wa_name">Konfiguracja sieci</string>
<string name="wifi_changing_network">Zmiana sieci</string>
<string name="wifi_connect_failed">Połączenie sieciowe nie</string>
<string name="wifi_connected">Połączony</string>
<string name="wifi_creating_network">Tworzenie sieci</string>
<string name="wifi_modifying_network">Modyfikowanie sieci</string>
<string name="wifi_ssid_label">Nazwa sieci</string>
<string name="wifi_ssid_missing">Nazwa sieci brakuje</string>
<string name="wifi_type_incorrect">Typ sieci nieprawidłowe</string>
<string name="wifi_type_label">Typ</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Pesquisa Google Book</string>
<string name="share_name">Partilhar por código de barras</string>
<string name="title_about">Scanner de código barras v</string>
<string name="wa_name">Configuração de rede</string>
<string name="wifi_changing_network">Mudar Rede</string>
<string name="wifi_connect_failed">A conexão de rede não</string>
<string name="wifi_connected">Ligado</string>
<string name="wifi_creating_network">Criação da rede</string>
<string name="wifi_modifying_network">Modificando Rede</string>
<string name="wifi_ssid_label">Nome da Rede</string>
<string name="wifi_ssid_missing">Nome da rede em falta</string>
<string name="wifi_type_incorrect">Rede de tipo incorreto</string>
<string name="wifi_type_label">Tipo</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Поиск книг Google</string>
<string name="share_name">Поделиться штрих-кодом</string>
<string name="title_about">Сканер штрих-кодов, версия </string>
<string name="wa_name">Подключение к сети</string>
<string name="wifi_changing_network">Изменение сети</string>
<string name="wifi_connect_failed">Подключение к сети не удалось</string>
<string name="wifi_connected">Подключено</string>
<string name="wifi_creating_network">Создание сети</string>
<string name="wifi_modifying_network">Изменение сети</string>
<string name="wifi_ssid_label">Имя сети</string>
<string name="wifi_ssid_missing">Отсутствует имя сети (SSID)</string>
<string name="wifi_type_incorrect">Некорректный тип сети</string>
<string name="wifi_type_label">Тип</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google vyhľadávanie kníh</string>
<string name="share_name">Zdieľať cez čiarový kód</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">Pripojenie WLAN</string>
<string name="wifi_changing_network">Mením sieťové pripojenie</string>
<string name="wifi_connect_failed">Pripojenie k sieti zlyhalo</string>
<string name="wifi_connected">Pripojené</string>
<string name="wifi_creating_network">Vytváram sieťové pripojenie</string>
<string name="wifi_modifying_network">Upravujem sieťové pripojenie</string>
<string name="wifi_ssid_label">Názov sieťového pripojenia</string>
<string name="wifi_ssid_missing">Chýba názov sieťového pripojenia</string>
<string name="wifi_type_incorrect">Nesprávny typ sieťové pripojenie</string>
<string name="wifi_type_label">Typ</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Iskanje z Google Book Search</string>
<string name="share_name">Deli preko črtne kode</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">WLAN povezava</string>
<string name="wifi_changing_network">Menjam omrežje</string>
<string name="wifi_connect_failed">Napaka omrežne povezave</string>
<string name="wifi_connected">Povezan</string>
<string name="wifi_creating_network">Kreiram omrežje</string>
<string name="wifi_modifying_network">Urejam omrežje</string>
<string name="wifi_ssid_label">Ime omrežja</string>
<string name="wifi_ssid_missing">Manjka ime omrežja</string>
<string name="wifi_type_incorrect">Nepravilen tip omrežja</string>
<string name="wifi_type_label">Tip</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google boksökning</string>
<string name="share_name">Dela via streckkod</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">Nätverkskonfiguration</string>
<string name="wifi_changing_network">Ändra Network</string>
<string name="wifi_connect_failed">Nätverksanslutning misslyckades</string>
<string name="wifi_connected">Ansluten</string>
<string name="wifi_creating_network">Skapa nätverk</string>
<string name="wifi_modifying_network">Modifiera nätverk</string>
<string name="wifi_ssid_label">Nätverksnamn</string>
<string name="wifi_ssid_missing">Nätverksnamn saknas</string>
<string name="wifi_type_incorrect">Nätverkstyp felaktig</string>
<string name="wifi_type_label">Typ</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google Kitap Arama</string>
<string name="share_name">Barkod ile paylaş</string>
<string name="title_about">Barkod Tarayıcı</string>
<string name="wa_name">Wi-Fi Bağlantısı</string>
<string name="wifi_changing_network">Ağ değişimi</string>
<string name="wifi_connect_failed">Ağ bağlantısı başarısız</string>
<string name="wifi_connected">Bağlantı sağlandı</string>
<string name="wifi_creating_network">Ağ oluşturma</string>
<string name="wifi_modifying_network">Şebeke değiştirme</string>
<string name="wifi_ssid_label">Ağ adı</string>
<string name="wifi_ssid_missing">Eksik Ağ adı</string>
<string name="wifi_type_incorrect">Ağ tipi yanlış</string>
<string name="wifi_type_label">Tip</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google图书搜索</string>
<string name="share_name">通过条码分享</string>
<string name="title_about">条码扫描器</string>
<string name="wa_name">网络配置</string>
<string name="wifi_changing_network">不稳定的网络</string>
<string name="wifi_connect_failed">网络连接失败</string>
<string name="wifi_connected">已连接</string>
<string name="wifi_creating_network">创建网络</string>
<string name="wifi_modifying_network">修改网络</string>
<string name="wifi_ssid_label">网络SSID</string>
<string name="wifi_ssid_missing">未找到SSID名称</string>
<string name="wifi_type_incorrect">网络类型不正确</string>
<string name="wifi_type_label">类型</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,15 +131,8 @@
<string name="sbc_name">Google 圖書搜尋</string>
<string name="share_name">透過條碼分享</string>
<string name="title_about">條碼掃描器</string>
<string name="wa_name">無線區網設定</string>
<string name="wifi_changing_network">更改網路連接中</string>
<string name="wifi_connect_failed">網路連接失敗</string>
<string name="wifi_connected">已連接</string>
<string name="wifi_creating_network">建立網路連接中</string>
<string name="wifi_modifying_network">修改網絡連接中</string>
<string name="wifi_ssid_label">網路名稱</string>
<string name="wifi_ssid_missing">找不到該網路名稱</string>
<string name="wifi_type_incorrect">網路類型不正確</string>
<string name="wifi_type_label">類型</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>
</resources>

View file

@ -131,14 +131,7 @@
<string name="sbc_name">Google Book Search</string>
<string name="share_name">Share via barcode</string>
<string name="title_about">Barcode Scanner v</string>
<string name="wa_name">WLAN Connection</string>
<string name="wifi_changing_network">Changing Network</string>
<string name="wifi_connected">Connected</string>
<string name="wifi_creating_network">Creating Network</string>
<string name="wifi_modifying_network">Modifying Network</string>
<string name="wifi_ssid_missing">Network name missing</string>
<string name="wifi_type_incorrect">Network type incorrect</string>
<string name="wifi_connect_failed">Network connection failed</string>
<string name="wifi_ssid_label">Network Name</string>
<string name="wifi_type_label">Type</string>
<string name="zxing_url">http://code.google.com/p/zxing</string>

View file

@ -24,10 +24,8 @@ import com.google.zxing.client.android.LocaleManager;
import com.google.zxing.client.android.PreferencesActivity;
import com.google.zxing.client.android.R;
import com.google.zxing.client.android.book.SearchBookContentsActivity;
import com.google.zxing.client.android.wifi.WifiActivity;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.ParsedResultType;
import com.google.zxing.client.result.WifiParsedResult;
import android.app.Activity;
import android.app.AlertDialog;
@ -120,6 +118,10 @@ public abstract class ResultHandler {
return customProductSearch != null;
}
Activity getActivity() {
return activity;
}
/**
* Indicates how many buttons the derived class wants shown.
*
@ -381,15 +383,6 @@ public abstract class ResultHandler {
launchIntent(intent);
}
final void wifiConnect(WifiParsedResult wifiResult) {
Intent intent = new Intent(Intents.WifiConnect.ACTION);
intent.setClassName(activity, WifiActivity.class.getName());
putExtra(intent, Intents.WifiConnect.SSID, wifiResult.getSsid());
putExtra(intent, Intents.WifiConnect.TYPE, wifiResult.getNetworkEncryption());
putExtra(intent, Intents.WifiConnect.PASSWORD, wifiResult.getPassword());
launchIntent(intent);
}
final void openURL(String url) {
launchIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}

View file

@ -17,7 +17,11 @@
package com.google.zxing.client.android.result;
import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.widget.Toast;
import com.google.zxing.client.android.R;
import com.google.zxing.client.android.wifi.WifiConfigManager;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.WifiParsedResult;
@ -54,7 +58,15 @@ public final class WifiResultHandler extends ResultHandler {
// Get the underlying wifi config
WifiParsedResult wifiResult = (WifiParsedResult) getResult();
if (index == 0) {
wifiConnect(wifiResult);
String ssid = wifiResult.getSsid();
if (ssid == null || ssid.length() == 0) {
return;
}
String password = wifiResult.getPassword();
String networkType = wifiResult.getNetworkEncryption();
WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
Toast.makeText(getActivity(), R.string.wifi_changing_network, Toast.LENGTH_LONG).show();
WifiConfigManager.configure(wifiManager, ssid, password, networkType);
}
}

View file

@ -1,77 +0,0 @@
/*
* Copyright (C) 2010 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.wifi;
import java.util.Timer;
import java.util.TimerTask;
import com.google.zxing.client.android.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
/**
* Start a browser after a delay to let the user read the informative
* message.
* @author Vikram Aggarwal
*/
final class Killer implements Runnable {
// Wait for this long, to enable the user to read the status.
private static final long DELAY_MS = 3 * 1000L;
private final Activity parent;
Killer(Activity parent) {
this.parent = parent;
}
void launchIntent(Intent intent) {
if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
try {
parent.startActivity(intent);
} catch (ActivityNotFoundException e) {
AlertDialog.Builder builder = new AlertDialog.Builder(parent);
builder.setTitle(R.string.app_name);
builder.setMessage(R.string.msg_intent_failed);
builder.setPositiveButton(R.string.button_ok, null);
builder.show();
}
}
}
public void run() {
final Handler handler = new Handler();
Timer t = new Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
public void run() {
// This will start the browser.
launchIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com/")));
}
});
}
}, DELAY_MS);
}
}

View file

@ -1,59 +0,0 @@
/*
* Copyright (C) 2010 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.wifi;
import com.google.zxing.client.android.wifi.WifiActivity.NetworkType;
/**
* Everything we could get from the barcode is to be here
*
* @author Vikram Aggarwal
*/
final class NetworkSetting {
/** The ancillary network setting from the barcode */
private final NetworkType networkType;
/** The password this ssid has */
private final String password;
/** The ssid we read from the barcode */
private final String ssid;
/**
* Create a new NetworkSetting object.
* @param ssid: The SSID
* @param password: Password for the setting, blank if unsecured network
* @param networkType: WPA for WPA/WPA2, or WEP for WEP or unsecured
*/
NetworkSetting(String ssid, String password, NetworkType networkType){
this.ssid = ssid;
this.password = password;
this.networkType = networkType;
}
NetworkType getNetworkType() {
return networkType;
}
String getPassword() {
return password;
}
String getSsid() {
return ssid;
}
}

View file

@ -0,0 +1,38 @@
/*
* Copyright (C) 2011 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.wifi;
enum NetworkType {
WEP,
WPA,
NO_PASSWORD;
static NetworkType forIntentValue(String networkTypeString) {
if ("WPA".equals(networkTypeString)) {
return WPA;
}
if ("WEP".equals(networkTypeString)) {
return WEP;
}
if ("nopass".equals(networkTypeString)) {
return NO_PASSWORD;
}
throw new IllegalArgumentException(networkTypeString);
}
}

View file

@ -1,73 +0,0 @@
/*
* Copyright (C) 2010 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.wifi;
import java.util.regex.Pattern;
import android.text.TextUtils;
/**
* Try with:
* http://chart.apis.google.com/chart?cht=qr&chs=240x240&chl=WIFI:S:linksys;P:mypass;T:WPA;;
*
* TODO(vikrama): Test with binary ssid or password.
*
* @author Vikram Aggarwal
*/
final class NetworkUtil {
private static final Pattern HEX_DIGITS = Pattern.compile("[0-9A-Fa-f]+");
private NetworkUtil() {
}
/**
* Encloses the incoming string inside double quotes, if it isn't already quoted.
* @param string: the input string
* @return a quoted string, of the form "input". If the input string is null, it returns null
* as well.
*/
static String convertToQuotedString(String string) {
if (string == null){
return null;
}
if (TextUtils.isEmpty(string)) {
return "";
}
int lastPos = string.length() - 1;
if (lastPos < 0 || (string.charAt(0) == '"' && string.charAt(lastPos) == '"')) {
return string;
}
return '\"' + string + '\"';
}
/**
* Check if wepKey is a valid hexadecimal string.
* @param wepKey the input to be checked
* @return true if the input string is indeed hex or empty. False if the input string is non-hex
* or null.
*/
static boolean isHexWepKey(CharSequence wepKey) {
if (wepKey == null) {
return false;
}
int length = wepKey.length();
// WEP-40, WEP-104, and some vendors using 256-bit WEP (WEP-232?)
return (length == 10 || length == 26 || length == 58) && HEX_DIGITS.matcher(wepKey).matches();
}
}

View file

@ -1,311 +0,0 @@
/*
* Copyright (C) 2010 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.wifi;
import java.util.List;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import com.google.zxing.client.android.Intents;
import com.google.zxing.client.android.R;
/**
* A new activity showing the progress of Wifi connection
*
* @author Vikram Aggarwal
*/
public final class WifiActivity extends Activity {
private static final String TAG = WifiActivity.class.getSimpleName();
private static final int MAX_ERROR_COUNT = 3;
private static final int FAILURE_NO_NETWORK_ID = -1;
private static final Pattern HEX_DIGITS_64 = Pattern.compile("[0-9A-Fa-f]{64}");
private WifiManager wifiManager;
private TextView statusView;
private WifiReceiver wifiReceiver;
private boolean receiverRegistered;
private int networkId;
private int errorCount;
private IntentFilter mWifiStateFilter;
void gotError() {
errorCount++;
Log.d(TAG, "Encountered another error. Errorcount = " + errorCount);
if (errorCount > MAX_ERROR_COUNT){
errorCount = 0;
doError(R.string.wifi_connect_failed);
}
}
public enum NetworkType {
NETWORK_WEP, NETWORK_WPA, NETWORK_NOPASS, NETWORK_INVALID,
}
private int changeNetwork(NetworkSetting setting) {
// If the SSID is empty, throw an error and return
if (setting.getSsid() == null || setting.getSsid().length() == 0) {
return doError(R.string.wifi_ssid_missing);
}
// If the network type is invalid
if (setting.getNetworkType() == NetworkType.NETWORK_INVALID){
return doError(R.string.wifi_type_incorrect);
}
// If the password is empty, this is an unencrypted network
if (setting.getPassword() == null || setting.getPassword().length() == 0 ||
setting.getNetworkType() == null ||
setting.getNetworkType() == NetworkType.NETWORK_NOPASS) {
return changeNetworkUnEncrypted(setting);
}
if (setting.getNetworkType() == NetworkType.NETWORK_WPA) {
return changeNetworkWPA(setting);
} else {
return changeNetworkWEP(setting);
}
}
private int doError(int resource_string) {
statusView.setText(resource_string);
// Give up on the connection
wifiManager.disconnect();
if (networkId > 0) {
wifiManager.removeNetwork(networkId);
networkId = -1;
}
if (receiverRegistered) {
unregisterReceiver(wifiReceiver);
receiverRegistered = false;
}
return -1;
}
private WifiConfiguration changeNetworkCommon(NetworkSetting input){
statusView.setText(R.string.wifi_creating_network);
Log.d(TAG, "Adding new configuration: \nSSID: " + input.getSsid() + "\nType: " +
input.getNetworkType());
WifiConfiguration config = new WifiConfiguration();
config.allowedAuthAlgorithms.clear();
config.allowedGroupCiphers.clear();
config.allowedKeyManagement.clear();
config.allowedPairwiseCiphers.clear();
config.allowedProtocols.clear();
// Android API insists that an ascii SSID must be quoted to be correctly handled.
config.SSID = NetworkUtil.convertToQuotedString(input.getSsid());
config.hiddenSSID = true;
return config;
}
private int requestNetworkChange(WifiConfiguration config){
statusView.setText(R.string.wifi_changing_network);
return updateNetwork(config, false);
}
// Adding a WEP network
private int changeNetworkWEP(NetworkSetting input) {
WifiConfiguration config = changeNetworkCommon(input);
String pass = input.getPassword();
if (NetworkUtil.isHexWepKey(pass)) {
config.wepKeys[0] = pass;
} else {
config.wepKeys[0] = NetworkUtil.convertToQuotedString(pass);
}
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
config.wepTxKeyIndex = 0;
return requestNetworkChange(config);
}
// Adding a WPA or WPA2 network
private int changeNetworkWPA(NetworkSetting input) {
WifiConfiguration config = changeNetworkCommon(input);
String pass = input.getPassword();
// Hex passwords that are 64 bits long are not to be quoted.
if (HEX_DIGITS_64.matcher(pass).matches()){
Log.d(TAG, "A 64 bit hex password entered.");
config.preSharedKey = pass;
} else {
Log.d(TAG, "A normal password entered: I am quoting it.");
config.preSharedKey = NetworkUtil.convertToQuotedString(pass);
}
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
// For WPA
config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
// For WPA2
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
return requestNetworkChange(config);
}
// Adding an open, unsecured network
private int changeNetworkUnEncrypted(NetworkSetting input){
Log.d(TAG, "Empty password prompting a simple account setting");
WifiConfiguration config = changeNetworkCommon(input);
config.wepKeys[0] = "";
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
config.wepTxKeyIndex = 0;
return requestNetworkChange(config);
}
/**
* If the given ssid name exists in the settings, then change its password to the one given here,
* and save
* @param ssid
*/
private WifiConfiguration findNetworkInExistingConfig(String ssid){
List<WifiConfiguration> existingConfigs = wifiManager.getConfiguredNetworks();
for (WifiConfiguration existingConfig : existingConfigs) {
if (existingConfig.SSID.equals(ssid)) {
return existingConfig;
}
}
return null;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
if (intent == null || !intent.getAction().equals(Intents.WifiConnect.ACTION)) {
finish();
return;
}
String ssid = intent.getStringExtra(Intents.WifiConnect.SSID);
String password = intent.getStringExtra(Intents.WifiConnect.PASSWORD);
String networkType = intent.getStringExtra(Intents.WifiConnect.TYPE);
setContentView(R.layout.network);
statusView = (TextView) findViewById(R.id.networkStatus);
NetworkType networkT;
if ("WPA".equals(networkType)) {
networkT = NetworkType.NETWORK_WPA;
} else if ("WEP".equals(networkType)) {
networkT = NetworkType.NETWORK_WEP;
} else if ("nopass".equals(networkType)) {
networkT = NetworkType.NETWORK_NOPASS;
} else {
networkT = NetworkType.NETWORK_INVALID;
}
// This is not available before onCreate
wifiManager = (WifiManager) this.getSystemService(WIFI_SERVICE);
// Start WiFi, otherwise nothing will work
wifiManager.setWifiEnabled(true);
// So we know when the network changes
wifiReceiver = new WifiReceiver(wifiManager, this, statusView);
// The order matters!
mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
mWifiStateFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
mWifiStateFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
registerReceiver(wifiReceiver, mWifiStateFilter);
receiverRegistered = true;
if (password == null) {
password = "";
}
Log.d(TAG, "Adding new configuration: \nSSID: " + ssid + "Type: " + networkT);
NetworkSetting setting = new NetworkSetting(ssid, password, networkT);
changeNetwork(setting);
}
@Override
public void onPause() {
super.onPause();
if (receiverRegistered) {
unregisterReceiver(wifiReceiver);
receiverRegistered = false;
}
}
@Override
public void onResume() {
super.onResume();
if (wifiReceiver != null && mWifiStateFilter != null && !receiverRegistered) {
registerReceiver(wifiReceiver, mWifiStateFilter);
receiverRegistered = true;
}
}
@Override
protected void onDestroy() {
if (wifiReceiver != null) {
if (receiverRegistered) {
unregisterReceiver(wifiReceiver);
receiverRegistered = false;
}
wifiReceiver = null;
}
super.onDestroy();
}
/**
* Update the network: either create a new network or modify an existing network
* @param config the new network configuration
* @param disableOthers true if other networks must be disabled
* @return network ID of the connected network.
*/
private int updateNetwork(WifiConfiguration config, boolean disableOthers) {
WifiConfiguration found = findNetworkInExistingConfig(config.SSID);
wifiManager.disconnect();
if (found == null) {
statusView.setText(R.string.wifi_creating_network);
} else {
statusView.setText(R.string.wifi_modifying_network);
Log.d(TAG, "Removing network " + found.networkId);
wifiManager.removeNetwork(found.networkId);
wifiManager.saveConfiguration();
}
networkId = wifiManager.addNetwork(config);
Log.d(TAG, "Inserted/Modified network " + networkId);
if (networkId < 0) {
return FAILURE_NO_NETWORK_ID;
}
// Try to disable the current network and start a new one.
if (!wifiManager.enableNetwork(networkId, disableOthers)) {
networkId = FAILURE_NO_NETWORK_ID;
return FAILURE_NO_NETWORK_ID;
}
errorCount = 0;
wifiManager.reassociate();
return networkId;
}
}

View file

@ -0,0 +1,194 @@
/*
* Copyright (C) 2011 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.wifi;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.text.TextUtils;
import java.util.List;
import java.util.regex.Pattern;
/**
* @author Vikram Aggarwal
* @author Sean Owen
*/
public final class WifiConfigManager {
private static final Pattern HEX_DIGITS_64 = Pattern.compile("[0-9A-Fa-f]{64}");
private static final Pattern HEX_DIGITS = Pattern.compile("[0-9A-Fa-f]+");
private WifiConfigManager() {
}
public static void configure(WifiManager wifiManager, String ssid, String password, String networkTypeString) {
// If the SSID is empty, throw an error and return
if (ssid == null || ssid.length() == 0) {
throw new IllegalArgumentException();
}
NetworkType networkType;
if (password == null || password.length() == 0 || networkTypeString == null) {
networkType = NetworkType.NO_PASSWORD;
} else {
networkType = NetworkType.forIntentValue(networkTypeString);
}
// Start WiFi, otherwise nothing will work
if (!wifiManager.isWifiEnabled()) {
wifiManager.setWifiEnabled(true);
}
switch (networkType) {
case WEP:
changeNetworkWEP(wifiManager, ssid, password);
break;
case WPA:
changeNetworkWPA(wifiManager, ssid, password);
break;
case NO_PASSWORD:
changeNetworkUnEncrypted(wifiManager, ssid);
break;
}
}
/**
* Update the network: either create a new network or modify an existing network
* @param config the new network configuration
* @return network ID of the connected network.
*/
private static void updateNetwork(WifiManager wifiManager, WifiConfiguration config) {
Integer foundNetworkID = findNetworkInExistingConfig(wifiManager, config.SSID);
if (foundNetworkID != null) {
wifiManager.removeNetwork(foundNetworkID);
wifiManager.saveConfiguration();
}
int networkId = wifiManager.addNetwork(config);
if (networkId >= 0) {
// Try to disable the current network and start a new one.
if (wifiManager.enableNetwork(networkId, true)) {
wifiManager.reassociate();
}
}
}
private static WifiConfiguration changeNetworkCommon(String ssid) {
WifiConfiguration config = new WifiConfiguration();
config.allowedAuthAlgorithms.clear();
config.allowedGroupCiphers.clear();
config.allowedKeyManagement.clear();
config.allowedPairwiseCiphers.clear();
config.allowedProtocols.clear();
// Android API insists that an ascii SSID must be quoted to be correctly handled.
config.SSID = convertToQuotedString(ssid);
return config;
}
// Adding a WEP network
private static void changeNetworkWEP(WifiManager wifiManager, String ssid, String password) {
WifiConfiguration config = changeNetworkCommon(ssid);
if (isHexWepKey(password)) {
config.wepKeys[0] = password;
} else {
config.wepKeys[0] = convertToQuotedString(password);
}
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
config.wepTxKeyIndex = 0;
updateNetwork(wifiManager, config);
}
// Adding a WPA or WPA2 network
private static void changeNetworkWPA(WifiManager wifiManager, String ssid, String password) {
WifiConfiguration config = changeNetworkCommon(ssid);
// Hex passwords that are 64 bits long are not to be quoted.
if (HEX_DIGITS_64.matcher(password).matches()) {
config.preSharedKey = password;
} else {
config.preSharedKey = convertToQuotedString(password);
}
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
// For WPA
config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
// For WPA2
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
updateNetwork(wifiManager, config);
}
// Adding an open, unsecured network
private static void changeNetworkUnEncrypted(WifiManager wifiManager, String ssid) {
WifiConfiguration config = changeNetworkCommon(ssid);
config.wepKeys[0] = "";
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
config.wepTxKeyIndex = 0;
updateNetwork(wifiManager, config);
}
private static Integer findNetworkInExistingConfig(WifiManager wifiManager, String ssid) {
List<WifiConfiguration> existingConfigs = wifiManager.getConfiguredNetworks();
for (WifiConfiguration existingConfig : existingConfigs) {
if (existingConfig.SSID.equals(ssid)) {
return existingConfig.networkId;
}
}
return null;
}
/**
* Encloses the incoming string inside double quotes, if it isn't already quoted.
* @param string the input string
* @return a quoted string, of the form "input". If the input string is null, it returns null
* as well.
*/
private static String convertToQuotedString(String string) {
if (string == null){
return null;
}
if (TextUtils.isEmpty(string)) {
return "";
}
int lastPos = string.length() - 1;
if (lastPos < 0 || (string.charAt(0) == '"' && string.charAt(lastPos) == '"')) {
return string;
}
return '\"' + string + '\"';
}
/**
* Check if wepKey is a valid hexadecimal string.
* @param wepKey the input to be checked
* @return true if the input string is indeed hex or empty. False if the input string is non-hex
* or null.
*/
private static boolean isHexWepKey(CharSequence wepKey) {
if (wepKey == null) {
return false;
}
int length = wepKey.length();
// WEP-40, WEP-104, and some vendors using 256-bit WEP (WEP-232?)
return (length == 10 || length == 26 || length == 58) && HEX_DIGITS.matcher(wepKey).matches();
}
}

View file

@ -1,104 +0,0 @@
/*
* Copyright (C) 2010 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.wifi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiManager;
import android.util.Log;
import android.widget.TextView;
import com.google.zxing.client.android.R;
/**
* Get a broadcast when the network is connected, and kill the activity.
*/
final class WifiReceiver extends BroadcastReceiver {
private static final String TAG = WifiReceiver.class.getSimpleName();
private final WifiManager mWifiManager;
private final WifiActivity parent;
private final TextView statusView;
WifiReceiver(WifiManager wifiManager, WifiActivity wifiActivity, TextView statusView) {
this.parent = wifiActivity;
this.statusView = statusView;
this.mWifiManager = wifiManager;
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) {
// Wifi supplicant (WPA client software) changed state.
handleChange(
(SupplicantState) intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE),
intent.hasExtra(WifiManager.EXTRA_SUPPLICANT_ERROR));
} else if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)){
// The network state changed.
handleNetworkStateChanged((NetworkInfo) intent.getParcelableExtra(
WifiManager.EXTRA_NETWORK_INFO));
} else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
// We might be connected.
ConnectivityManager con = (ConnectivityManager) parent.getSystemService(
Context.CONNECTIVITY_SERVICE);
NetworkInfo[] s = con.getAllNetworkInfo();
for (NetworkInfo i : s){
if (i.getTypeName().contentEquals("WIFI")){
NetworkInfo.State state = i.getState();
String ssid = mWifiManager.getConnectionInfo().getSSID();
if (state == NetworkInfo.State.CONNECTED && ssid != null){
// Yes, we connected to the network specified in the barcode.
// Let's save the configuration, since we know it works. Then,
// we stop this application by calling the killer.
mWifiManager.saveConfiguration();
String label = parent.getString(R.string.wifi_connected);
statusView.setText(label + '\n' + ssid);
Runnable delayKill = new Killer(parent);
delayKill.run();
}
if (state == NetworkInfo.State.DISCONNECTED){
// We couldn't connect to the specified network. Let the parent
// know that we were unsuccessful.
Log.d(TAG, "Got state Disconnected for ssid: " + ssid);
parent.gotError();
}
}
}
}
}
private void handleNetworkStateChanged(NetworkInfo networkInfo) {
NetworkInfo.DetailedState state = networkInfo.getDetailedState();
if (state == NetworkInfo.DetailedState.FAILED){
Log.d(TAG, "Detailed Network state failed");
parent.gotError();
}
}
private void handleChange(SupplicantState state, boolean hasError) {
if (hasError || state == SupplicantState.INACTIVE){
Log.d(TAG, "Found an error");
parent.gotError();
}
}
}

View file

@ -181,10 +181,17 @@ public final class HtmlAssetTranslator {
NamedNodeMap attributes = node.getAttributes();
if (attributes != null) {
Node classAttribute = attributes.getNamedItem("class");
if (classAttribute != null && "notranslate".equals(classAttribute.getTextContent())) {
return false;
if (classAttribute != null) {
String textContent = classAttribute.getTextContent();
if (textContent != null && textContent.contains("notranslate")) {
return false;
}
}
}
String nodeName = node.getNodeName();
if ("script".equalsIgnoreCase(nodeName)) {
return false;
}
// Ignore non-text snippets
String textContent = node.getTextContent();
if (textContent != null) {