├── .gitignore ├── Android.mk ├── AndroidManifest.xml ├── lint.xml ├── res ├── drawable-hdpi │ ├── appwidget_bg.9.png │ ├── bulb_off.png │ ├── bulb_on.png │ ├── ic_appwidget_torch_off.png │ ├── ic_appwidget_torch_on.png │ ├── ic_menu_accept.png │ ├── icon.png │ ├── ind_bar_off.9.png │ ├── ind_bar_on.9.png │ ├── notification_icon.png │ └── widget_presslayer.9.png ├── drawable-mdpi │ ├── appwidget_bg.9.png │ ├── bulb_off.png │ ├── bulb_on.png │ ├── ic_appwidget_torch_off.png │ ├── ic_appwidget_torch_on.png │ ├── ic_menu_accept.png │ ├── icon.png │ ├── ind_bar_off.9.png │ ├── ind_bar_on.9.png │ ├── notification_icon.png │ └── widget_presslayer.9.png ├── drawable-xhdpi │ ├── appwidget_bg.9.png │ ├── ic_appwidget_torch_off.png │ ├── ic_appwidget_torch_on.png │ ├── ic_menu_accept.png │ ├── icon.png │ ├── ind_bar_off.9.png │ ├── ind_bar_on.9.png │ ├── notification_icon.png │ └── widget_presslayer.9.png ├── drawable │ ├── appwidget_button.xml │ └── bulb.xml ├── layout │ ├── aboutview.xml │ ├── brightwarn.xml │ ├── main.xml │ ├── optionsview.xml │ └── widget.xml ├── menu │ ├── main.xml │ └── widget.xml ├── values-af │ └── strings.xml ├── values-bg │ └── strings.xml ├── values-ca │ └── strings.xml ├── values-cs │ └── strings.xml ├── values-da │ └── strings.xml ├── values-de │ └── strings.xml ├── values-el │ └── strings.xml ├── values-es │ └── strings.xml ├── values-et │ └── strings.xml ├── values-fi │ └── strings.xml ├── values-fr │ └── strings.xml ├── values-hr │ └── strings.xml ├── values-hu │ └── strings.xml ├── values-it │ └── strings.xml ├── values-iw │ └── strings.xml ├── values-ja │ └── strings.xml ├── values-ko │ └── strings.xml ├── values-lt │ └── strings.xml ├── values-mdpi │ └── dimens.xml ├── values-nb │ └── strings.xml ├── values-nl │ └── strings.xml ├── values-pl │ └── strings.xml ├── values-pt │ └── strings.xml ├── values-ru │ └── strings.xml ├── values-sk │ └── strings.xml ├── values-sr │ └── strings.xml ├── values-sv │ └── strings.xml ├── values-ug │ └── strings.xml ├── values-uk │ └── strings.xml ├── values-zh-rCN │ └── strings.xml ├── values-zh-rTW │ └── strings.xml ├── values │ ├── colors.xml │ ├── config.xml │ ├── dimens.xml │ └── strings.xml └── xml │ └── appwidget_info.xml └── src └── net └── cactii └── flash2 ├── FlashDevice.java ├── MainActivity.java ├── SeekBarPreference.java ├── TorchService.java ├── TorchSwitch.java ├── TorchWidgetProvider.java └── WidgetOptionsActivity.java /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | bin/ 4 | gen/ 5 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 The CyanogenMod Project 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # version 3 as published by the Free Software Foundation. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 15 | # MA 02110-1301, USA. 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_SRC_FILES := $(call all-subdir-java-files) 21 | LOCAL_PACKAGE_NAME := Torch 22 | LOCAL_CERTIFICATE := platform 23 | include $(BUILD_PACKAGE) 24 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 35 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /res/drawable-hdpi/appwidget_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/appwidget_bg.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/bulb_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/bulb_off.png -------------------------------------------------------------------------------- /res/drawable-hdpi/bulb_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/bulb_on.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_appwidget_torch_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/ic_appwidget_torch_off.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_appwidget_torch_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/ic_appwidget_torch_on.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_menu_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/ic_menu_accept.png -------------------------------------------------------------------------------- /res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ind_bar_off.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/ind_bar_off.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ind_bar_on.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/ind_bar_on.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/notification_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/notification_icon.png -------------------------------------------------------------------------------- /res/drawable-hdpi/widget_presslayer.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-hdpi/widget_presslayer.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/appwidget_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/appwidget_bg.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/bulb_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/bulb_off.png -------------------------------------------------------------------------------- /res/drawable-mdpi/bulb_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/bulb_on.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_appwidget_torch_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/ic_appwidget_torch_off.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_appwidget_torch_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/ic_appwidget_torch_on.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_menu_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/ic_menu_accept.png -------------------------------------------------------------------------------- /res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ind_bar_off.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/ind_bar_off.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ind_bar_on.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/ind_bar_on.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/notification_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/notification_icon.png -------------------------------------------------------------------------------- /res/drawable-mdpi/widget_presslayer.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-mdpi/widget_presslayer.9.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/appwidget_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-xhdpi/appwidget_bg.9.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_appwidget_torch_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-xhdpi/ic_appwidget_torch_off.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_appwidget_torch_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-xhdpi/ic_appwidget_torch_on.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_menu_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-xhdpi/ic_menu_accept.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ind_bar_off.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-xhdpi/ind_bar_off.9.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ind_bar_on.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-xhdpi/ind_bar_on.9.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/notification_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-xhdpi/notification_icon.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/widget_presslayer.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_packages_apps_Torch/450b3bd93a772d5c7c464842c5806f5abd5c8ad2/res/drawable-xhdpi/widget_presslayer.9.png -------------------------------------------------------------------------------- /res/drawable/appwidget_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 24 | 25 | 29 | 30 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /res/drawable/bulb.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /res/layout/aboutview.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 23 | 24 | 31 | 32 | 40 | 41 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /res/layout/brightwarn.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 23 | 24 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 24 | 25 | 34 | 35 | 40 | 41 | 51 | 52 | 57 | 58 | 68 | 69 | 76 | 77 | 81 | 82 | 92 | 93 | 94 | 95 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /res/layout/optionsview.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 23 | 24 | 28 | 29 | 33 | 34 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /res/layout/widget.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 26 | 27 | 37 | 38 | 46 | 47 | 57 | 58 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 24 | 25 | -------------------------------------------------------------------------------- /res/menu/widget.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /res/values-af/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Flits 21 | Meer oor 22 | Sluit 23 | 24 | Hierdie program manipuleer die kamera LED.\n 25 | Waarskuwing: Om die LED aan te hou vir \'n lang tyd kan dit laat oorverhit.\n\nVolle helderheid “altyd aan“ is getoets vir \'n ½ uur, maar daar is die risiko dat dit kan skade verig aan die LED.\n 26 | Oorspronklike kode van die Nexus One Flits deur Ben Buxton, vrygestel onder die GPL, v3.\nhttp://n1torch.googlecode.com/\n\nDankie aan Dawid Prieto vir die nuwe UI ontwerp\n\nGemodifiseer vir CyanogenMod deur Steve Kondik.\n\n 27 | Waarskuwing 28 | Volle helderheid is suksesvol getoets vir \'n ½ uur, maar die LED het baie warm geword en begin flikker (tydelik) op 45 min. Die langtermyn effek is onbekend.\n\nDie gebruik van \'n legstuk word nie ondersteun nie.\n\nRaak “Aanvaar“ as jy dit wil gebruik op jou eie risiko. 29 | Kanselleer 30 | Aanvaar 31 | 32 | Volle helderheid 33 | Flikker 34 | 35 | Legstuk instellings 36 | Helder legstuk 37 | Flikker legstuk 38 | Flikker frekwensie 39 | Frekwensie 40 | Voeg legstuk by 41 | 42 | Flits aan 43 | Skakel flits af 44 | 45 | -------------------------------------------------------------------------------- /res/values-bg/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Фенерче 21 | Относно 22 | Затвори 23 | 24 | Това приложение използва светкавицата на камерата.\n 25 | Внимание: Продължителната работа на светкавицата може да я прегрее.\n\nПълната яркост е тествана успешно в продължение на ½ час, но съществува риск от повреда на светодиода.\n 26 | Оригинален код от Nexus One Torch на Ben Buxton, лицензиран под GPL, v3.\nhttp://n1torch.googlecode.com/\n\nБлагодарности на David Prieto за новия дизайн.\n\nМодифицирано за CyanogenMod от Steve Kondik.\n\n 27 | Внимание 28 | Пълната яркост е тествана в продължение на ½ час, но светодиодът прегрява и започва да трепти след 45 минути. Дълготрайните ефекти са неизвестни.\n\nТова все още не се поддържа от уиджета.\n\nНатиснете “Приемам”, ако искате да използвате на свой риск. 29 | Отказ 30 | Приемам 31 | 32 | Пълна яркост 33 | Мигаща светлина 34 | 35 | Общи настройки 36 | Пълна яркост 37 | Мигаща светлина 38 | Честота 39 | Честота 40 | Добави уиджета 41 | 42 | Фенерче 43 | 44 | -------------------------------------------------------------------------------- /res/values-ca/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Torch 21 | Quant a 22 | Tanca 23 | Aquest programa manipula el led de la càmera.\n 24 | Advertència: Deixar el LED encès durant molt de temps el podria sobreescalfar.\n\nS\'han fet proves de ½ hora, però hi ha el risc que això pugui danyar el LED.\n 25 | Codi original del Nexus One Torch per Ben Buxton, publicat sota la GPL, v3.\nhttp://n1torch.googlecode.com/\n\nGràcies a David Prieto pel nou disseny de la interfície.\n\nModificat per CyanogenMod per Steve Kondik.\n\n 26 | Avís 27 | La brillantor completa s\'ha provat amb èxit durant mitja hora d\'operació, però es va escalfar considerablement i als 45 minuts va començar a parpellejar. Els efectes a llarg termini són desconeguts.\n\nEncara no s\'ha creat un giny.\n\nPremeu «Accepta» si voleu fer-lo servir pel vostre propi risc. 28 | No, gràcies 29 | Accepta 30 | Brillantor alta 31 | Estroboscòpic 32 | Opcions generals 33 | Giny de brillantor 34 | Flash estroboscòpic 35 | Freqüència estroboscòpica 36 | Freqüència 37 | Afegeix un giny 38 | Torxa engegada 39 | Apaga la torxa 40 | 41 | -------------------------------------------------------------------------------- /res/values-cs/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Svítilna 21 | O aplikaci 22 | Zavřít 23 | 24 | Ovládání osvětlení LED fotoaparátu.\n 25 | Upozornění: Pokud ponecháte zapnuté osvětlení LED delší dobu, riskujete jeho přehřátí a poškození. 26 | Autorem původního kódu pro Nexus One je Ben Buxton uvolěný pod licencí GPL, v3.\nhttp://n1torch.googlecode.com/\n\nPoděkování Davidu Prietovi pro vylepšní uživatelského rozhraní.\n\nUpraveno pro CyanogenMod přímo Steve Kondikem.\n\n 27 | Upozornění 28 | Vysoký jas byl úspěšně testován po dobu půl hodiny, ale poté bylo osvětlení velmi horké a poblikávalo (dočasně pod dobu 45 minut). Dlouhodobé účinky nejsou známi.\n\nToto zatím není ve widgetu podporováno.\n\nKlikněte na “Přijmout” pokud chcete vyzkoušet na vlastní nebezpečí. 29 | Ne děkuji 30 | Přijmout 31 | 32 | Vysoký jas 33 | Blikání 34 | 35 | Obecné nastavení 36 | Widget jasu 37 | Blikání 38 | Frekvence blikání 39 | Frekvence 40 | Přidat widget 41 | 42 | Svítilna zapnuta 43 | Svítilna vypnuta 44 | 45 | -------------------------------------------------------------------------------- /res/values-da/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Lommelygte 21 | Om 22 | Luk 23 | Dette program manipulerer med kameraets LED lys.\n 24 | Advarsel: Hvis man efterlader LED lyset tændt i lang tid er der risiko for overophedning.\n\nFuld lysstyrke er blevet testet i en ½ time i træk uden problemer, men der er risiko for at det kan skade LED\'en.\n 25 | Den originale kode kommer fra Nexus One Torch af Ben Buxtun, udgivet under GPL, v3\nhttp://n1torch.googlecode.com/\n\nTak til David Prieto for nyt UI design.\n\nTilpasset til CyanogenMod af Steve Kondik.\n\n 26 | Advarsel 27 | Fuld lysstyrke er blevet tested uden problemer i ½ time i træk, men efter 45 minutter blev den ret varm og begyndte at flimre (midlertidigt). Langtidseffekten er ukendt.\n\nWidgeten understøtter ikke denne funktionalitet endnu.\n\nTryk “Accepter” hvis du ønsker at bruge det på eget ansvar. 28 | Nej tak 29 | Accepter 30 | Høj lysstyrke 31 | Stroboskoplys 32 | Generelle Indstillinger 33 | Høj lysstyrke widget 34 | Stroboskop flash 35 | Stroboskop frekvens 36 | Frekvens 37 | Tilføj widget 38 | Lommelygte tændt 39 | Sluk lommelygte 40 | 41 | -------------------------------------------------------------------------------- /res/values-de/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Taschenlampe 21 | Über 22 | Schließen 23 | 24 | Dieses Programm manipuliert die Kamera-LED.\n 25 | Warnung: Langes Einschalten kann zur Überhitzung der LED führen.\n\nVolle Helligkeit wurde für eine halbe Stunde getestet, aber es besteht das Risiko, die LED zu beschädigen.\n 26 | Originaler Code von Nexus One Torch von Ben Buxton, veröffentlicht unter der GPLv3.\nhttp://n1torch.googlecode.com/\n\nDanke an David Prieto für das neue Design.\n\nModifiziert für CyanogenMod durch Steve Kondik.\n\n 27 | Warnung 28 | Volle Helligkeit wurde erfolgreich für die Dauer einer halben Stunde getestet, aber die LED wurde dabei sehr warm und begann nach 45 Minuten vorübergehend zu flackern. Langzeiteffekte sind unbekannt.\n\nBisher gibt es keine Unterstützung für das Widget.\n\nDurch Auswahl von “Akzeptieren” bestätigen Sie, diese Funktion auf eigene Gefahr zu nutzen. 29 | Nein Danke 30 | Akzeptieren 31 | 32 | Hohe Helligkeit 33 | Stroboskop 34 | 35 | Allgemeine Optionen 36 | Helles Widget 37 | Stroboskop 38 | Blitzfrequenz 39 | Frequenz 40 | Widget hinzufügen 41 | 42 | Taschenlampe an 43 | Ausschalten 44 | 45 | -------------------------------------------------------------------------------- /res/values-el/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Φακός 21 | Σχετικά 22 | Κλείσιμο 23 | Αυτό το πρόγραμμα χρησιμοποιεί το LED της κάμερας.\n 24 | Προειδοποίηση: Όταν το LED είναι ανοιχτό για μεγάλο χρονικό διάστημα μπορεί να υπερθερμανθεί.\n\nΗ υψηλή φωτεινότητα έχει δοκιμαστεί για μισή ώρα, αλλά υπάρχει κίνδυνος να βλάψει το LED.\n 25 | Αρχικός κώδικας από το Nexus One Torch του Ben Buxton, που διατίθεται βάσει της GPL, v3.\nhttp://n1torch.googlecode.com/\n\nΕυχαριστούμε τον David Prieto για το νέο UI.\n\nΤροποποιήθηκε για CyanogenMod από τον Steve Kondik.\n\n 26 | Προσοχή 27 | Η υψηλή φωτεινότητα έχει δοκιμαστεί επιτυχώς για μισή ώρα, αλλά το LED ανέπτυξε μεγάλη θερμοκρασία και άρχισε να τρεμοπαίζει στα 45 λεπτά. Οι μακροπρόθεσμες επιπτώσεις είναι άγνωστες.\n\nΚάντε κλικ στο κουμπί “Αποδοχή”, αν θέλετε να το χρησιμοποιήσετε με δική σας ευθύνη. 28 | Όχι, ευχαριστώ 29 | Αποδοχή 30 | Υψηλή φωτεινότητα 31 | Στροβιλισμός 32 | Γενικές ρυθμίσεις 33 | Υψηλή φωτεινότητα 34 | Στροβιλισμός 35 | Συχνότητα στροβιλισμού 36 | Συχνότητα 37 | Προσθήκη widget 38 | Φακός ενεργός 39 | Απενεργοποίηση φακού 40 | 41 | -------------------------------------------------------------------------------- /res/values-es/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Linterna 21 | Acerca de 22 | Cerrar 23 | Este programa manipula el LED de la camara.\n 24 | Aviso: Dejar el flash LED encendido demasiado tiempo puede producir un sobrecalentamiento del mismo.\n\nEl modo \u00ABbrillo alto\u00BB ha sido probado durante 1 ó 2 horas, pero podría ser peligroso para el LED, llegando incluso a dañarlo.\n 25 | Código original para Nexus One Torch escrito por Ben Buxton, liberado bajo licencia GPL, v3.\nhttp://n1torch.googlecode.com/\n\nGracias a David Prieto por el nuevo diseño.\n\nModificado para CyanogenMod por Steve Kondik.\n\n 26 | Aviso 27 | El modo \u00ABbrillo alto\u00BB ha sido probado durante 1 ó 2 horas continuadas, pero el LED se sobrecalienta a los 45 minutos, pudiendo ocasionar efectos secundarios desconocidos.\n\nToca en \u00ABAceptar\u00BB si quieres usarlo y asumir el riesgo.\n 28 | No, gracias 29 | Aceptar 30 | Brillo alto 31 | Parpadeo 32 | Opciones 33 | Widget con brillo alto 34 | Parpadeo activo 35 | Frecuencia del parpadeo 36 | Frecuencia 37 | Añadir widget 38 | Linterna encendida 39 | Apagar linterna 40 | 41 | -------------------------------------------------------------------------------- /res/values-et/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Lamp 21 | Teave 22 | Sulge 23 | 24 | See programm kasutab kaamera LED-välku.\n 25 | Hoiatus: märgutule pikaajaline pidev kasutamine võib põhjustada ülekuumenemist.\n\nTäielikku heledust “alati peal” on proovitud pidevalt pool tundi, kuid on olemas oht, et see kahjustab LED-välku.\n 26 | Originaalne kood: Nexus One Torch by Ben Buxton, released under the GPL, v3.\nhttp://n1torch.googlecode.com/\n\nAitäh David Prieto uuest välimusest.\n\nMuutnud CyanogenModile: Steve Kondik.\n\n 27 | Hoiatus 28 | Täielikku heledust on edukalt testitud poole tunni ajal, mille jooksul LED-välk kuumenes ja 45 minuti kohal hakkas vilkuma. Pikaajaline kasutamine võib kahjustada LED-välku.\n\nVidin ei toeta veel seda funktsiooni\n\nValige “Nõustu” kui soovite siiski kasutada seda omal vastutusel. 29 | Keeldu 30 | Nõustu 31 | 32 | täielik heledus 33 | Strobo 34 | 35 | Üldised seaded 36 | Hele vidin 37 | Strobo 38 | Strobo segadus 39 | Segadus 40 | Lisa vidin 41 | 42 | Lamp on peal 43 | 44 | -------------------------------------------------------------------------------- /res/values-fi/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Lamppu 21 | Tietoja 22 | Sulje 23 | 24 | Tämä ohjelma käyttää kameran LED-salamaa.\n 25 | Varoitus: LEDin pitkäaikainen yhtäjaksoinen käyttö saattaa aiheuttaa ylikuumenemista.\n\nTäyttä kirkkautta “aina päällä” on kokeiltu yhtäjaksoisesti puoli tuntia, mutta on olemassa riski, että se vahingoittaa LED-salamaa.\n 26 | Alkuperäinen koodi: Nexus One Torch by Ben Buxton, released under the GPL, v3.\nhttp://n1torch.googlecode.com/\n\nKiitos David Prieto uudesta ulkoasusta.\n\nMuokannut CyanogenModiin Steve Kondik.\n\n 27 | Varoitus 28 | Täyttä kirkkautta on testattu onnistuneesti puolen tunnin ajan, jonka aikana LED-salama kuumeni ja 45 minuutin kohdalla alkoi vilkkua. Pitkäaikainen käyttö voi vahingoittaa LED-salamaa.\n\nWidget ei vielä tue tämä toimintoa.\n\nValitse “Hyväksy” jos haluat kuitenkin käyttää tätä omalla vastuulla. 29 | Hylkää 30 | Hyväksy 31 | 32 | Täysi kirkkaus 33 | Strobo 34 | 35 | Yleiset asetukset 36 | Kirkas widget 37 | Strobo 38 | Strobon taajuus 39 | Taajuus 40 | Lisää widget 41 | 42 | Lamppu päällä 43 | Sulje lamppu 44 | 45 | -------------------------------------------------------------------------------- /res/values-fr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Lampe de poche 21 | À propos de 22 | Fermer 23 | Ce programme agit sur la LED de l\'appareil photo.\n 24 | Attention : Laisser la LED activée pendant un long moment pourrait la faire surchauffer.\n\nLe réglage “Luminosité maximale” a été testé pendant une demi-heure, mais le risque d\'endommager la LED existe.\n 25 | Code original de Nexus One Torch par Ben Buxton, licencié sous GPL, v3.\nhttp://n1torch.googlecode.com/\n\nRemerciements à David Prieto pour le nouveau design de l\'interface.\n\nModifié pour CyanogenMod par Steve Kondik.\n\n 26 | Attention 27 | La luminosité maximale a été testée avec succès pendant une demi-heure, mais la LED est devenue plutôt chaude, et a commencé a scintiller (temporairement) après 45 minutes. Les effets à long terme sont inconnus.\n\nCeci n\'est pas encore supporté par le widget.\n\nChoisissez Accepter si vous souhaitez l\'utiliser à vos propres risques. 28 | Non merci 29 | Accepter 30 | Luminosité maximale 31 | Stroboscope 32 | Options générales 33 | Widget luminosité maximale 34 | Flash stroboscopique 35 | Fréquence stroboscope 36 | Fréquence 37 | Ajouter le widget 38 | Torche active 39 | Éteindre la torche 40 | 41 | -------------------------------------------------------------------------------- /res/values-hr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Lampa 21 | O 22 | Zatvori 23 | Ovaj program koristi LED diodu (bljeskalicu) kamere.\n 24 | Upozorenje: Ostavljanje LED diode upaljene na dulje vrijeme bi je moglo pregrijati.\n\nPuna svjetlina “uvijek upaljena” je bila testirana ½ sata ali postoji rizik da bi ovo moglo oštetiti LED diodu.\n 25 | Originalni kod od Nexus One Baklje od Ben Buxton, objavljen pod GPL, v3.\nhttp://n1torch.googlecode.com/\n\nZahvala David Prieto za novi UI dizajn.\n\nModificiran za CyanogenMod od strane Steve Kondik.\n\n 26 | Upozorenje 27 | Puna svjetlina je testirana uspješno za ½sata rada ali je postala prilično vruća i počela treperiti (privremeno) na 45 mins. Dugotrajne posljedice su nepoznate\n\n Ovo nije podržano na widgetu još.\n\nPritisni “Prihvaćam” ako je želite koristiti na vlastitu odgovornost. 28 | Ne hvala 29 | Prihvaćam 30 | Visoka svjetilna 31 | Titranje 32 | Opće opcije 33 | Puna svjetlina 34 | Titranje bljeskalice 35 | Frekvencija titranja 36 | Frekvencija 37 | Dodaj widget 38 | Baklja upaljena 39 | Isključi baklju 40 | 41 | -------------------------------------------------------------------------------- /res/values-hu/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Zseblámpa 21 | Zseblámpa 22 | Bezárás 23 | Ezzel a programmal a telefon kamerájához tartozó LED-et lehet vezérelni.\n 24 | Figyelmeztetés: A LED hosszú ideig történő használata túlmelegedéshez vezethet.\n\nAz alkalmazást ½ órán át teszteltük “Folyamatos fény” opcióval, de ettől még fennáll az esélye hogy károsodhat a LED.\n 25 | Az eredeti forráskód a Nexus One Torch kódjából származik. Ben Buxton adta ki a GNU GPL v3 licensz alatt. http://n1torch.googlecode.com/\n\nKöszönet David Prieto-nak az új dizájnért.\n\nA CyanogenMod-hoz optimalizálta: Steve Kondik.\n\n 26 | Figyelmeztetés 27 | A folyamatos LED használattal futtatott tesztünk során az alkalmazás megfelelően működött, viszont a készülék eléggé melegedett, valamint ¾ óra elteltével ideiglenes villogásba is kezdett. Hosszabb távú hatásai nem ismertek.\n\nJelenleg nincs modul gomb az alkalmazáshoz.\n\nKattintson az “Elfogadás” gombra, ha saját felelősségre mégis használni kívánja. 28 | Nem, köszönöm 29 | Elfogadás 30 | Zseblámpa 31 | Stroboszkóp 32 | Stroboszkóp frekvencia 33 | Frekvencia 34 | Modul hozzáadása 35 | Zseblámpa 36 | Stroboszkóp 37 | Zseblámpa 38 | Általános opciók 39 | Zseblámpa kikapcsolása 40 | 41 | -------------------------------------------------------------------------------- /res/values-it/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Torcia 21 | Info 22 | Chiudi 23 | Questo programma manipola il LED della fotocamera.\n 24 | Attenzione: Lasciare il LED acceso a lungo può surriscaldarlo.\n\nLa modalità Alta Luminosità è stata testata per ½ ora, ma c\'è il rischio che possa danneggiare il LED.\n 25 | Codice originale da Nexus One Torch scritto da Ben Buxton, rilasciato sotto GPL, v3.\nhttp://n1torch.googlecode.com/\n\nGrazie a David Prieto per il nuovo design della UI.\n\nModificato per CyanogenMod da Steve Kondik.\n\n 26 | Attenzione 27 | L\'Alta Luminosità è stata testata con successo per ½ ora di attività, ma il LED si è scaldato notevolmente e dopo 45 min ha iniziato a tremolare (temporaneamete). Effetti a lungo termine sono sconosciuti.\n\nQuesta modalità non è ancora supportata nel widget.\n\nClicca “Accetto” se vuoi usarla a tuo rischio. 28 | No grazie 29 | Accetto 30 | Alta Luminosità 31 | Strobo 32 | Impostazioni generali 33 | Widget alta luminosità 34 | Flash strobo 35 | Frequenza strobo 36 | Frequenza 37 | Aggiungi widget 38 | Torcia attiva 39 | Spegni la torcia 40 | 41 | -------------------------------------------------------------------------------- /res/values-iw/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | פנס 21 | אודות 22 | סגור 23 | 24 | יישום זה משתמש בנורת הLED של המצלמה.\n 25 | אזהרה: השארת נורת הLED של המצלמה דולקת לזמן ארוך עלולה לגרום לחימום יתר שלה.\n\nבהירות מלאה “תמיד דולק” נבדקה למשך כחצי שעה, אך הסיכון לגרימת נזק לנורת הLED קיים.\n 26 | הקוד המקורי נלקח מאפליקציית הפנס לNexus One מאת בן באקסטון, ששוחררה תחת GPL גרסה 3.\nhttp://n1torch.googlecode.com/\n\n תודה לדוד פרייטו עבור הממשק החדש.\n\n הותאם עבור CyanogenMod על ידי סטיב קונדיק.\n\n 27 | אזהרה 28 | בהירות מלאה נבדקה בהצלחה למשך חצי שעת פעולה, אבל גרמה לנורה להתחמם, וגרמה להבהובים (זמניים) לאחר 45 דקות. השפעות לטווח הארוך לא ידועות.\n\n מצב זה לא נתמך עדיין בWidget.\n\n לחיצה על “קבל” משמעה שהשימוש במצב זה הוא על אחריותך בלבד. 29 | לא תודה 30 | קבל 31 | 32 | בהירות גבוהה 33 | הבהוב 34 | 35 | אפשרויות כלליות 36 | ‏Widget אור בהיר 37 | הבהוב 38 | תדירות הבהוב 39 | תדירות 40 | הוסף Widget 41 | 42 | פנס פועל 43 | 44 | -------------------------------------------------------------------------------- /res/values-ja/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | トーチ 21 | 情報 22 | 閉じる 23 | このプログラムはカメラのLEDを操作します。・\n 24 | 注意: 長時間LEDをこのままにするとオーバーヒートするかもしれません。\n\n最大明度を“常に有効”にしたテストは 30分ほど行ないましたが、LEDにダメージを与える危険性があります。\n 25 | オリジナルソースコードはBen BuxtonによるNexus One Torchで、GPLv3の下にリリースされています。\nhttp://n1torch.googlecode.com/\n\n新しいUIのデザインをしてくれたDavid Prietoに感謝します。\n\nCyanogenMod向けの変更はSteve Kondikが行ないました。 26 | 危険 27 | 最大明度は30分のテストに成功しましたが、とても熱くなり、45分ほど一時的に明滅するようになりました。長時間使用の影響はわかりません。\n\nウィジェットのサポートはまだありません。.\n\n\自己責任での使用を望むのなら“了解”を押してください。 28 | やめます 29 | 了解 30 | 高明度 31 | ストロボ 32 | オプション 33 | 高明度ウィジェット 34 | ストロボフラッシュ 35 | ストロボ頻度 36 | 頻度 37 | ウィジェットを追加 38 | トーチオン 39 | トーチオフ 40 | 41 | -------------------------------------------------------------------------------- /res/values-ko/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 전등 21 | 정보 22 | 닫기 23 | 24 | 이 프로그램은 카메라 LED를 조작합니다. 25 | 경고: LED를 오랫동안 켜두면 과열될 수 있습니다.\n\n최대 밝기 “항상 켬”은 30분동안 시험해 보았지만 LED가 고장날 위험이 있습니다. 26 | 원본 코드는 GPLv3인 Ben Buxton의 Nexus One Torch에서 왔습니다..\nhttp://n1torch.googlecode.com/\n\n새로운 UI 디자인에 대하여 David Prieto에게 감사드립니다.\n\nCyanogenMod을 위하여 Steve Kondik가 수정했습니다..\n\n 27 | 경고 28 | 최대 밝기는 30분동안 성공적으로 작동하였지만 살짝 뜨거워졌으며, 45분 후부터는 일시적으로 깜빡이기 시작하였습니다. 길게 작동하였을 때의 문제는 아직 알려지지 않았습니다.\n\n이 방법은 위젯에서 아직 지원되지 안습니다.\n\n위험을 감수하고 사용하시겠다면 “확인” 버튼을 눌러 사용하시기 바랍니다. 29 | 아니오 30 | 확인 31 | 32 | 고휘도 33 | 깜빡이기 34 | 35 | 일반 옵션 36 | 전등 위젯 37 | 깜빡이기 38 | 깜빡임 주기 39 | 주기 40 | 위젯 추가 41 | 42 | 전등 켜짐 43 | 44 | -------------------------------------------------------------------------------- /res/values-lt/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Žibintuvėlis 21 | Apie 22 | Užverti 23 | Ši programa naudoja kameros šviesos diodą.\n 24 | Dėmesio: Paliekant šviesos diodą įjungtą ilgam laikui jis gali perkaisti.\n\nVisu šviesumu „visada įjungta“ buvo bandoma 0,5 val., bet gali būti rizika sugadinti šviesos diodą.\n 25 | Originalus kodas iš Nexus One Torch, kurį sukūrė Ben Buxton, yra platinamas pagal GPL, v3.\nhttp://n1torch.googlecode.com/\n\nDėkojame David Prieto už naują naudotojo sąsajos dizainą.\n\nProgramą CyanogenMod pritaikė Steve Kondik.\n\n 26 | Perspėjimas 27 | Pilnu šviesumas buvo bandoma 0,5 val., bet šviesos diodas tapo pakankamai karštas ir pradėjo mirksėti (laikinai) 45 minutes. Ilgalaikės pasekmės yra nežinomos.\n\nDar nepalaikoma kaip valdiklis.\n\nSpauskite „Sutinku“ jei norite naudoti savo rizikos sąskaita. 28 | Ne, dėkui 29 | Sutinku 30 | Visas šviesumas 31 | Stroboskopas 32 | Bendri nustatymai 33 | Šviesumo valdiklis 34 | Mirgėjimas 35 | Mirgėjimo dažnis 36 | Dažnis 37 | Pridėti valdiklį 38 | Žibintuvėlis įjungtas 39 | Išjungti žibintuvėlį 40 | 41 | -------------------------------------------------------------------------------- /res/values-mdpi/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | -8dp 21 | 22 | -------------------------------------------------------------------------------- /res/values-nb/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Lommelykt 21 | Om 22 | Lukk 23 | 24 | Dette programmet manipulerer kameraets LED-lys.\n 25 | Advarsel: Langvarig bruk av LED-lyset kan forårsake overoppheting.\n\nFull lys-styrke har blitt testet i 2 timer men det er fortsatt en mulighet for at dette kan skade LED-lyset.\n 26 | Original kode fra Nexus One Torch av Ben Buxton, gitt ut under GPLv3.\nhttp://n1torch.googlecode.com/\n\nTakk til David Prieto for nytt UI-design\n\nModifisert for CyanogenMOD av Steve Kondik\n\n 27 | Advarsel 28 | Full lysstyrke har blitt testet i en halvtime noe som forårsaket mye varme og midlertidig flimring etter 45 min. Langvarig effekter er ukjente.\n\nDette er ikke støttet av Widget\'en enda.\n\nVelg “Godta”, hvis du ønsker å bruke programmet på eget ansvar. 29 | Nei takk 30 | Godta 31 | 32 | Høy lysstyrke 33 | Strobe 34 | 35 | Generelle innstillinger 36 | Sterkt lys widget 37 | Strobeblits 38 | Strobeblitsfrekvens 39 | Frekvens 40 | Legg til widget 41 | 42 | Lommelykt på 43 | Skru av lommelykten 44 | 45 | -------------------------------------------------------------------------------- /res/values-nl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Zaklamp 21 | Over 22 | Sluiten 23 | Annuleren 24 | Accepteren 25 | Fel licht 26 | Knipperen 27 | Algemeen 28 | Helderheidswidget 29 | Knipperend licht 30 | Knipperfrequentie 31 | Frequentie 32 | Widget toevoegen 33 | Zaklamp actief 34 | Zaklamp uitschakelen 35 | Deze app manipuleert de cameraled.\n 36 | Let op 37 | 38 | 39 | Let op: als de led te lang aan staat, kan dit leiden tot oververhitting. 40 | \n 41 | \n 42 | De led fel aan is een half uur lang getest zonder problemen, maar het risico bestaat dat dit schadelijk kan zijn voor de led. 43 | \n 44 | 45 | 46 | 47 | Originele code van \'Nexus One Torch\u2019, ontwikkeld door Ben Buxton, uitgegeven onder de GPL versie 3. 48 | \n 49 | http://n1torch.googlecode.com/ 50 | \n 51 | \n 52 | Met dank aan David Prieto voor de nieuwe layout. 53 | \n 54 | \n 55 | Aangepast voor CyanogenMod door Steve Kondik. 56 | \n 57 | \n 58 | 59 | 60 | 61 | Fel licht is een half uur lang getest zonder problemen, maar de led werd heet en begon bij 45 minuten te knipperen. De effecten op de lange termijn zijn niet bekend. 62 | \n 63 | \n 64 | Dit is nog niet beschikbaar in de widget. 65 | \n 66 | Tik op \'Accepteren\u2019 om op eigen risico te gebruiken. 67 | 68 | -------------------------------------------------------------------------------- /res/values-pl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Latarka 21 | O latarce 22 | Zamknij 23 | 24 | Ten program używa diody LED aparatu.\n 25 | Uwaga: Zostawienie diody włączonej na dłuższy czas może spowodować jej przegrzanie.\n\nPrzeprowadzono pomyślne ½ godzinne testy przy maksymalnej jasności, ale istnieje ryzyko uszkodzenia diody.\n 26 | Oryginalny kod Nexus One Torch Bena Buxtona, na licencji GPL, v3.\nhttp://n1torch.googlecode.com/\n\nPodziękowania dla Davida Prieto za nowy interfejs.\n\nZmodyfikowany na potrzeby CyanogenMod przez Stevea Kondika.\n\n 27 | Uwaga 28 | Przeprowadzono pomyślne ½ godzinne testy przy maksymalnej jasności, ale dioda się nagrzała, i zaczeła migotać (chilowo) przy 45 min. Skutki długotrwałe są nieznane.\n\nFunkcja nie jest jeszcze wspierana przez widget.\n\nKliknij “Akceptuj” jeśli chcesz kontynuować na własne ryzyko. 29 | Anuluj 30 | Akceptuj 31 | 32 | Maksymalna jasność 33 | Miganie 34 | 35 | Ustawienia ogólne 36 | Widget 37 | Miganie 38 | Częstotliwość 39 | Częstotliwość 40 | Dodaj widget 41 | 42 | Latarka włączona 43 | Wyłącz latarkę 44 | 45 | -------------------------------------------------------------------------------- /res/values-pt/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Lanterna 21 | Sobre Lanterna 22 | Fechar 23 | 24 | Esse programa manipula o LED da câmera.\n 25 | Aviso: Deixar o LED aceso por muito tempo pode sobreaquecê-lo.\n\nBrilho máximo “sempre ativo” foi testado por 30min, mas há um risco de dano ao LED.\n 26 | Código original do Nexus One por by Ben Buxton, lançado sobre a GPL, v3.\nhttp://n1torch.googlecode.com/\n\nObrigado a David Prieto pelo novo design de IU.\n\nModificado por CyanogenMod por Steve Kondik.\n\n 27 | Aviso 28 | Brilho máximo foi testado bem sucedido por 30min de operação, mas ficou bem quente, e começou a oscilar (temporariamente) em 45 mins. Efeito a longo prazo é desconhecido.\n\nIsto não é suportado no widget ainda.\n\nClique “Aceitar” se você quer usar em seu próprio risco. 29 | Não obrigado 30 | Aceitar 31 | 32 | Brilho Alto 33 | Piscar 34 | 35 | Opções Gerais 36 | Widget de Brilho 37 | Flash do pisca pisca 38 | Frequência de piscagem 39 | Frequência 40 | Adicionar widget 41 | 42 | Lanterna ligada 43 | Desligar lanterna 44 | 45 | -------------------------------------------------------------------------------- /res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Фонарик 21 | О программе 22 | Закрыть 23 | 24 | Эта программа использует светодиод вспышки камеры в качестве фонарика.\n 25 | Осторожно: включённый на длительное время светодиод может перегреться и даже выйти из строя.\n\nРежим максимальной яркости тестировался в течение получаса, но на некоторых устройствах вспышка может нагреваться гораздо быстрее.\n 26 | Оригинальный код Nexus One Torch (GPL v3): Ben Buxton — http://n1torch.googlecode.com/\nДизайн интерфейса: David Prieto\nМодификация для CyanogenMod: Steve Kondik 27 | Внимание! 28 | Режим максимальной яркости тестировался в течение получаса на некоторых устройствах. За это время светодиод сильно нагрелся, а потом начал мерцать, пока не остыл.\nЧто может случиться при постоянном использовании этого режима — неизвестно!\n\nНажмите «Согласиться», если вы хотите использовать эту функцию и осознаёте возможный риск. 29 | Нет, спасибо 30 | Согласиться 31 | 32 | Максимальная яркость 33 | Стробоскоп 34 | 35 | Настройки виджета 36 | Максимальная яркость 37 | Стробоскоп 38 | Частота стробоскопа 39 | Частота 40 | Добавить виджет 41 | 42 | Фонарик включён 43 | Выключить фонарик 44 | 45 | -------------------------------------------------------------------------------- /res/values-sk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Svietidlo 21 | O programe 22 | Zavrieť 23 | Tento program ovláda LED diódu fotoaparátu.\n 24 | Upozornenie: Príliš dlhé svietenie LED diódy môže spôsobiť prehriatie.\n\nVysoký jas bol odskúšaný po dobu pol hodiny, ale zapnutím môžete riskovať poškodenie LED diódy.\n 25 | Pôvodný kód z Nexus One Torch od Bena Buxtona, vydaný po licenciou GPL, v3.\nhttp://n1torch.googlecode.com/\n\nPoďakovanie patrí Davidovi Prietovi za nový dizajn užívateľského rozhrania.\n\nPre CyanogenMod upravil Steve Kondik.\n\n 26 | Upozornenie 27 | Vysoký jas bol úspešne odskúšaný po dobu pol hodiny, ale dióda sa zahriala a začala blikať (dočasne) po 45-tich minútach. Dlhodobé účinky nie sú známe.\n\nToto zatiaľ nie je podporované v miniaplikácii.\n\nKliknite na „Prijímam”, ak chcete pokračovať na vlastné riziko. 28 | Nie, ďakujem 29 | Prijímam 30 | Vysoký jas 31 | Prerušované svietenie 32 | Všeobecné voľbys 33 | Miniaplikácia pre vysoký jas 34 | Prerušované svietenie 35 | Frekvencia prerušovania 36 | Frekvencia 37 | Pridať miniaplikáciu 38 | Svietidlo zapnuté 39 | Vypnúť svietidlo 40 | 41 | -------------------------------------------------------------------------------- /res/values-sr/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Бакља 21 | О програму 22 | Затвори 23 | 24 | Овај програм користи блиц (LED) камере.\n 25 | 26 | Упозорење: Остављање блица укљученог дуго времена може да га 27 | прегреје.\n\n„Увек укључена“ пуна јачина је тестирана у периоду од 28 | ½ сата, али постоји ризик да може да оштети блиц.\n 29 | 30 | 31 | Оригинални код из Nexus One Torch-а од Бена Бакстона, објављен 32 | под ГПЛ, в3.\nhttp://n1torch.googlecode.com/\n\nХвала Давиду 33 | Приету за нови дизајн сучеља.\n\nМодификовао за CyanogenMod Стив 34 | Кондик.\n\n 35 | 36 | Упозорење 37 | 38 | Пуна јачина је успешно тестирана у периоду од ½ сата, али 39 | се блиц јако угрејао и почео да трепери (привремено) за 45 40 | минута. Дуготрајни ефекти су непознати.\n\nОво још није подржано 41 | на виџету.\n\nКликните на „Прихватам“ ако желите да користите 42 | ову опцију на сопствени ризик. 43 | 44 | Не, хвала 45 | Прихватам 46 | 47 | Пуна јачина 48 | Стробоскоп 49 | 50 | Опште поставке 51 | Пуна јачина 52 | Стробоскоп 53 | Фреквенција стробоскопа 54 | Фреквенција 55 | Додај виџет 56 | 57 | Бакља укључена 58 | 59 | -------------------------------------------------------------------------------- /res/values-sv/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Ficklampa 21 | Om 22 | Stäng 23 | Detta program manipulerar kamerans LED.\n 24 | Varning: Att lämna LED-lampan på under en längre tid kan överhetta den.\n\nMaximal ljusstyrka “alltid på” har testats i 30 minuter, men risken finns att detta skadar LED-lampan.\n 25 | Ursprunglig kod från Nexus One Torch av Ben Buxton, släppt under GPL, v3.\nhttp://n1torch.googlecode.com/\n\nTack till David Prieto för ny gränssnittsdesign.\n\nModifierad för CyanogenMod av Steve Kondik.\n\n 26 | Varning 27 | Maximal ljusstyrka har testats under en halvtimmes drift med framgång. Lampan blev dock ganska varm och började flimra (temporärt) efter 45 minuter. Långtidseffekter är okända.\n\nDetta stöds inte av widgeten än.\n\nKlicka på “Acceptera” om du vill använda detta på egen risk. 28 | Nej tack 29 | Acceptera 30 | Hög ljusstyrka 31 | Stroboskop 32 | Allmänna inställningar 33 | Hög ljusstyrka 34 | Stroboskop 35 | Frekvens 36 | Frekvens 37 | Lägg till widget 38 | Ficklampa på 39 | Ficklampa av 40 | 41 | -------------------------------------------------------------------------------- /res/values-ug/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | قول چىراغ 21 | ھەققىدە 22 | ياپ 23 | بۇ پىروگرامما كامېرانىڭ چاقماق لامپىسى LED نى باشقۇرالايدۇ.\n 24 | ئاگاھلاندۇرۇش: LED ئۇزۇن ۋاقىت يورۇتۇلسا بەك قىزىپ كېتىدۇ.\n\nسىناش نەتىجىسىدە چاقماق چىراغ يۇقىرى يورۇقلۇق ھالىتىدە ئەڭ ئۇزۇن بولغاندا يېرىم سائەت تۇرسا بولىدۇ ئەمما يەنىلا LED نى كۆيدۈرۈۋېتىش خەۋپى بار. 25 | ئەسلى كودنىڭ مەنبەسى Ben Buxton يازغان Nexus One قول چىراغدىن كەلگەن، GPL, v3 نەشرىدە تارقىتىلغان.\nhttp://n1torch.googlecode.com/\n\nDavid Prieto نىڭ يېڭى ئارايۈز لايىھەسى بىلەن تەمىنلىگەنلىكىگە رەھمەت.\n\nئۆزگەرتىلگەندىن كېيىن Steve Kondik قۇرغان CyanogenMod تا ئىشلىتىلىدۇ.\n\n 26 | ئاگاھلاندۇرۇش 27 | سىناش نەتىجىسىدە چاقماق چىراغ يۇقىرى يورۇقلۇق ھالىتىدە ئەڭ ئۇزۇن بولغاندا يېرىم سائەت تۇرسا بولىدۇ ئەمما بەق قىزىپ كېتىدۇ، 45 مىنۇتتىن كېيىن (ۋاقىتلىق) بىر يېنىپ بىر ئۆچۈشكە باشلايدۇ.\n\nبۇ ئەپچە تېخى قوللىمايدۇ.\n\nئەگەر بۇ خەتەرگە تەۋەككۈل قىلىشنى خالىسىڭىز، «قوشۇل» توپچىنى چېكىڭ. 28 | ياق، رەھمەت 29 | قوشۇل 30 | يۇقىرى يورۇقلۇق 31 | چاقماق 32 | ئادەتتىكى تاللانما 33 | يورۇقلۇق ئەپچە 34 | چاقنات 35 | چاستوتا 36 | چاستوتا 37 | ئەپچە قوش 38 | قول چىراغ ئوچۇق 39 | 40 | -------------------------------------------------------------------------------- /res/values-uk/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Ліхтарик 21 | Про ліхтарик 22 | Закрити 23 | дозволяє керувати спалахом камери.\n 24 | Попередження: світлодіод спалаху, залишений увімкнутим на довгий час, може перегрітися.\n\nРежим повної яскравості протестований протягом півгодини, але все ж існує ризик пошкодження світлодіода.\n 25 | Оригінальний код Nexus One Torch написав Бен Бакстон (Ben Buxton). Розповсюджується під ліцензією GPL вер. 3.\nhttp://n1torch.googlecode.com/\n\nДякуємо Давиду Пріето (David Prieto) за новий дизайн інтерфейсу.\n\n Для CyanogenMod програму адаптував Стів Кондік (Steve Kondik).\n\n 26 | Увага 27 | Робота спалаху в режимі повної яскравості була успішно протестована протягом півгодини, але викликала сильне нагрівання та тимчасове мерехтіння спалаху (через 45 хвилин). Наслідки довгострокового застосування невідомі.\n\nПідтримка режиму віджетом поки що не реалізована.\n\nНатисніть “Прийняти”, якщо бажаєте використовувати режим на свій страх і ризик. 28 | Ні, дякую 29 | Прийняти 30 | Висока яскравість 31 | Стробоскоп 32 | Основні налаштування 33 | Віджет ліхтарика 34 | Стробоскоп 35 | Частота спалахів 36 | Частота 37 | Додати віджет 38 | Ліхтарик увімкнений 39 | 40 | -------------------------------------------------------------------------------- /res/values-zh-rCN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 手电筒 21 | 关于 22 | 关闭 23 | 24 | 本应用程序能够操纵相机闪光灯的 LED。\n 25 | 警告:长期开启 LED 会使其过热。\n\n经测试闪光灯高亮模式可以“长开”半小时,但仍然有令 LED 损坏的风险。\n 26 | 原程序代码来自 Ben Buxton 编写的 Nexus One 手电筒,在 GPL v3 的授权下发布。\nhttp://n1torch.googlecode.com/\n\n感谢 David Prieto 提供的新界面设计。\n\n经过修改在 Steve Kondik 所创立的 CyanogenMod 上使用。\n\n 27 | 警告 28 | 高亮模式曾经成功测试过能够开启半小时,但会变得很热,并于 45 分钟后开始(暂时性的)忽暗忽亮。目前未知是否会有长期性的副作用。\n\n此模式尚未在桌面小部件上支持。\n\n如果您愿意承受该风险,请点击“接受”按钮。 29 | 拒绝 30 | 接受 31 | 32 | 高亮模式 33 | 闪烁 34 | 35 | 常规选项 36 | 高亮模式 37 | 闪烁 38 | 频率 39 | 频率 40 | 添加小部件 41 | 42 | 手电筒已开启 43 | 关闭手电筒 44 | 45 | -------------------------------------------------------------------------------- /res/values-zh-rTW/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 手電筒 21 | 關於 22 | 關閉 23 | 24 | 本應用程式能操控相機 LED\n 25 | 警告:長期開啟 LED 會使其過熱。\n\n經測試探射燈可“長開”半小時,但仍是有令 LED 損壞的風險。\n 26 | 原本的程式碼來自 Ben Buxton 編寫的 Nexus One 手電筒,在 GPL, v3 的規管下釋出。\nhttp://n1torch.googlecode.com/\n\n鳴謝 David Prieto 提供新介面設計。\n\n經過修改在 Steve Kondik 所創立的 CyanogenMod 上使用。\n\n 27 | 警告 28 | 探射燈曾經成功測試能運作半個小時,但變得頗熱,並於 45 分鐘時開始(暫時)驟暗驟明。未知會否有長期的副作用。\n\n這尚未在小工具上支援。\n\n若您願意承受此等風險,請按“接受”。 29 | 不用了 30 | 接受 31 | 32 | 探射燈 33 | 閃光燈 34 | 35 | 小工具選項 36 | 探射燈 37 | 閃光燈 38 | 閃光頻率 39 | 頻率 40 | 新增小工具 41 | 42 | 手電筒已開 43 | 關閉手電筒 44 | 45 | -------------------------------------------------------------------------------- /res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | #FF000000 22 | #FF555555 23 | #FFff8080 24 | #FFFFFFFF 25 | #FFff0000 26 | 27 | -------------------------------------------------------------------------------- /res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 24 | false 25 | 26 | 27 | /sys/class/leds/flashlight/brightness 28 | 29 | 30 | 31 | 32 | 0 33 | 34 | 1 35 | 36 | 37 | 50 38 | 39 | 128 40 | 41 | 3 42 | 43 | 44 | true 45 | 46 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 16dp 21 | 22 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Torch 21 | About 22 | Close 23 | 24 | This program manipulates the camera LED.\n 25 | Warning: Leaving the LED on for a long time might overheat it.\n\nFull brightness “always on” has been tested running for ½ hr, but there is the risk this could damage the LED.\n 26 | Original code from Nexus One Torch by Ben Buxton, released under the GPL, v3.\nhttp://n1torch.googlecode.com/\n\nThanks to David Prieto for new UI design.\n\nModified for CyanogenMod by Steve Kondik.\n\n 27 | Warning 28 | Full brightness has been tested successfully for ½ hour of operation, but got quite hot, and started flickering (temporarily) at 45 mins. Long term effects are unknown.\n\nThis is not supported on the widget yet.\n\nClick “Accept” if you want to use it at your own risk. 29 | No thanks 30 | Accept 31 | 32 | High brightness 33 | Strobe 34 | 35 | General options 36 | Bright widget 37 | Strobe flash 38 | Strobe frequency 39 | Frequency 40 | Hz 41 | Add widget 42 | 43 | Torch on 44 | Turn torch off 45 | 46 | -------------------------------------------------------------------------------- /res/xml/appwidget_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 26 | 27 | -------------------------------------------------------------------------------- /src/net/cactii/flash2/FlashDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The CyanogenMod Project 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 3 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 | * MA 02110-1301, USA. 17 | */ 18 | 19 | package net.cactii.flash2; 20 | 21 | import android.content.Context; 22 | import android.graphics.SurfaceTexture; 23 | import android.hardware.Camera; 24 | import android.os.PowerManager; 25 | import android.os.PowerManager.WakeLock; 26 | import android.util.Log; 27 | 28 | import net.cactii.flash2.R; 29 | 30 | import java.io.FileWriter; 31 | import java.io.IOException; 32 | 33 | public class FlashDevice { 34 | 35 | private static final String MSG_TAG = "TorchDevice"; 36 | 37 | /* New variables, init'ed by resource items */ 38 | private static int mValueOff; 39 | private static int mValueOn; 40 | private static int mValueLow; 41 | private static int mValueHigh; 42 | private static int mValueDeathRay; 43 | private static String mFlashDevice; 44 | private static String mFlashDeviceLuminosity; 45 | private static boolean mUseCameraInterface; 46 | private WakeLock mWakeLock; 47 | 48 | public static final int STROBE = -1; 49 | public static final int OFF = 0; 50 | public static final int ON = 1; 51 | public static final int HIGH = 128; 52 | public static final int DEATH_RAY = 3; 53 | 54 | private static FlashDevice sInstance; 55 | 56 | private FileWriter mFlashDeviceWriter = null; 57 | private FileWriter mFlashDeviceLuminosityWriter = null; 58 | 59 | private int mFlashMode = OFF; 60 | 61 | private Camera mCamera = null; 62 | private SurfaceTexture mSurfaceTexture = null; 63 | 64 | private FlashDevice(Context context) { 65 | mValueOff = context.getResources().getInteger(R.integer.valueOff); 66 | mValueOn = context.getResources().getInteger(R.integer.valueOn); 67 | mValueLow = context.getResources().getInteger(R.integer.valueLow); 68 | mValueHigh = context.getResources().getInteger(R.integer.valueHigh); 69 | mValueDeathRay = context.getResources().getInteger(R.integer.valueDeathRay); 70 | mFlashDevice = context.getResources().getString(R.string.flashDevice); 71 | mFlashDeviceLuminosity = context.getResources().getString(R.string.flashDeviceLuminosity); 72 | mUseCameraInterface = context.getResources().getBoolean(R.bool.useCameraInterface); 73 | if (mUseCameraInterface) { 74 | PowerManager pm 75 | = (PowerManager) context.getSystemService(Context.POWER_SERVICE); 76 | this.mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Torch"); 77 | } 78 | } 79 | 80 | public static synchronized FlashDevice instance(Context context) { 81 | if (sInstance == null) { 82 | sInstance = new FlashDevice(context.getApplicationContext()); 83 | } 84 | return sInstance; 85 | } 86 | 87 | public synchronized void setFlashMode(int mode) { 88 | Log.d(MSG_TAG, "setFlashMode " + mode); 89 | try { 90 | int value = mode; 91 | switch (mode) { 92 | case STROBE: 93 | value = OFF; 94 | break; 95 | case DEATH_RAY: 96 | if (mValueDeathRay >= 0) { 97 | value = mValueDeathRay; 98 | } else if (mValueHigh >= 0) { 99 | value = mValueHigh; 100 | } else { 101 | value = 0; 102 | Log.d(MSG_TAG,"Broken device configuration"); 103 | } 104 | break; 105 | case ON: 106 | if (mValueOn >= 0) { 107 | value = mValueOn; 108 | } else { 109 | value = 0; 110 | Log.d(MSG_TAG,"Broken device configuration"); 111 | } 112 | break; 113 | } 114 | if (mUseCameraInterface) { 115 | if (mCamera == null) { 116 | mCamera = Camera.open(); 117 | } 118 | if (value == OFF) { 119 | Camera.Parameters params = mCamera.getParameters(); 120 | params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); 121 | mCamera.setParameters(params); 122 | if (mode != STROBE) { 123 | mCamera.stopPreview(); 124 | mCamera.release(); 125 | mCamera = null; 126 | if (mSurfaceTexture != null) { 127 | mSurfaceTexture.release(); 128 | mSurfaceTexture = null; 129 | } 130 | } 131 | if (mWakeLock.isHeld()) 132 | mWakeLock.release(); 133 | } else { 134 | if (mSurfaceTexture == null) { 135 | // Create a dummy texture, otherwise setPreview won't work on some devices 136 | mSurfaceTexture = new SurfaceTexture(0); 137 | mCamera.setPreviewTexture(mSurfaceTexture); 138 | mCamera.startPreview(); 139 | } 140 | Camera.Parameters params = mCamera.getParameters(); 141 | params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); 142 | mCamera.setParameters(params); 143 | if (!mWakeLock.isHeld()) { // only get the wakelock if we don't have it already 144 | mWakeLock.acquire(); // we don't want to go to sleep while cam is up 145 | } 146 | } 147 | } else { 148 | // Devices with sysfs toggle and sysfs luminosity 149 | if (mFlashDeviceLuminosity != null && mFlashDeviceLuminosity.length() > 0) { 150 | if (mFlashDeviceWriter == null) { 151 | mFlashDeviceWriter = new FileWriter(mFlashDevice); 152 | } 153 | if (mFlashDeviceLuminosityWriter == null) { 154 | mFlashDeviceLuminosityWriter = new FileWriter(mFlashDeviceLuminosity); 155 | } 156 | 157 | mFlashDeviceWriter.write(String.valueOf(mValueOn)); 158 | mFlashDeviceWriter.flush(); 159 | 160 | switch (mode) { 161 | case ON: 162 | mFlashDeviceLuminosityWriter.write(String.valueOf(mValueLow)); 163 | mFlashDeviceLuminosityWriter.flush(); 164 | break; 165 | case OFF: 166 | mFlashDeviceLuminosityWriter.write(String.valueOf(mValueLow)); 167 | mFlashDeviceLuminosityWriter.close(); 168 | mFlashDeviceLuminosityWriter = null; 169 | mFlashDeviceWriter.write(String.valueOf(mValueOff)); 170 | mFlashDeviceWriter.close(); 171 | mFlashDeviceWriter = null; 172 | break; 173 | case STROBE: 174 | mFlashDeviceWriter.write(String.valueOf(OFF)); 175 | mFlashDeviceWriter.flush(); 176 | break; 177 | case DEATH_RAY: 178 | if (mValueDeathRay >= 0) { 179 | mFlashDeviceLuminosityWriter.write(String.valueOf(mValueDeathRay)); 180 | mFlashDeviceLuminosityWriter.flush(); 181 | } else if (mValueHigh >= 0) { 182 | mFlashDeviceLuminosityWriter.write(String.valueOf(mValueHigh)); 183 | mFlashDeviceLuminosityWriter.flush(); 184 | } else { 185 | mFlashDeviceLuminosityWriter.write(String.valueOf(OFF)); 186 | mFlashDeviceLuminosityWriter.flush(); 187 | Log.d(MSG_TAG,"Broken device configuration"); 188 | } 189 | break; 190 | } 191 | } else { 192 | // Devices with just a sysfs toggle 193 | if (mFlashDeviceWriter == null) { 194 | mFlashDeviceWriter = new FileWriter(mFlashDevice); 195 | } 196 | // Write to sysfs only if not already on 197 | if (mode != mFlashMode) { 198 | mFlashDeviceWriter.write(String.valueOf(value)); 199 | mFlashDeviceWriter.flush(); 200 | } 201 | if (mode == OFF) { 202 | mFlashDeviceWriter.close(); 203 | mFlashDeviceWriter = null; 204 | } 205 | } 206 | } 207 | mFlashMode = mode; 208 | } catch (IOException e) { 209 | throw new RuntimeException("Can't open flash device", e); 210 | } 211 | } 212 | 213 | public synchronized int getFlashMode() { 214 | return mFlashMode; 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /src/net/cactii/flash2/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The CyanogenMod Project 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 3 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 | * MA 02110-1301, USA. 17 | */ 18 | 19 | package net.cactii.flash2; 20 | 21 | import android.app.Activity; 22 | import android.app.AlertDialog; 23 | import android.content.BroadcastReceiver; 24 | import android.content.Context; 25 | import android.content.DialogInterface; 26 | import android.content.Intent; 27 | import android.content.IntentFilter; 28 | import android.content.SharedPreferences; 29 | import android.os.Bundle; 30 | import android.preference.PreferenceManager; 31 | import android.view.LayoutInflater; 32 | import android.view.Menu; 33 | import android.view.MenuItem; 34 | import android.view.View; 35 | import android.view.View.OnClickListener; 36 | import android.widget.LinearLayout; 37 | import android.widget.Switch; 38 | import android.widget.ToggleButton; 39 | import android.widget.CompoundButton; 40 | import android.widget.CompoundButton.OnCheckedChangeListener; 41 | import android.widget.SeekBar; 42 | import android.widget.SeekBar.OnSeekBarChangeListener; 43 | import android.widget.TextView; 44 | 45 | public class MainActivity extends Activity { 46 | private TorchWidgetProvider mWidgetProvider; 47 | 48 | private ToggleButton mButtonOn; 49 | private Switch mStrobeSwitch; 50 | private Switch mBrightSwitch; 51 | 52 | private boolean mBright; 53 | private boolean mTorchOn; 54 | 55 | // Strobe frequency slider. 56 | private SeekBar mSlider; 57 | 58 | // Period of strobe, in milliseconds 59 | private int mStrobePeriod; 60 | 61 | // Label showing strobe frequency 62 | private TextView mStrobeLabel; 63 | 64 | // Preferences 65 | private SharedPreferences mPrefs; 66 | 67 | private boolean mHasBrightSetting = false; 68 | 69 | private final BroadcastReceiver mStateReceiver = new BroadcastReceiver() { 70 | @Override 71 | public void onReceive(Context context, Intent intent) { 72 | if (intent.getAction().equals(TorchSwitch.TORCH_STATE_CHANGED)) { 73 | mTorchOn = intent.getIntExtra("state", 0) != 0; 74 | updateBigButtonState(); 75 | } 76 | } 77 | }; 78 | 79 | /** Called when the activity is first created. */ 80 | @Override 81 | public void onCreate(Bundle savedInstanceState) { 82 | super.onCreate(savedInstanceState); 83 | 84 | setContentView(R.layout.main); 85 | 86 | mButtonOn = (ToggleButton) findViewById(R.id.buttonOn); 87 | mStrobeSwitch = (Switch) findViewById(R.id.strobe_switch); 88 | mStrobeLabel = (TextView) findViewById(R.id.strobeTimeLabel); 89 | mSlider = (SeekBar) findViewById(R.id.slider); 90 | mBrightSwitch = (Switch) findViewById(R.id.bright_switch); 91 | 92 | mStrobePeriod = 100; 93 | mTorchOn = false; 94 | 95 | mWidgetProvider = TorchWidgetProvider.getInstance(); 96 | 97 | // Preferences 98 | mPrefs = PreferenceManager.getDefaultSharedPreferences(this); 99 | 100 | mHasBrightSetting = getResources().getBoolean(R.bool.hasHighBrightness); 101 | if (mHasBrightSetting) { 102 | mBright = mPrefs.getBoolean("bright", false); 103 | mBrightSwitch.setChecked(mBright); 104 | mBrightSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { 105 | @Override 106 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 107 | if (isChecked && mPrefs.getBoolean("bright", false)) { 108 | mBright = true; 109 | } else if (isChecked) { 110 | openBrightDialog(); 111 | } else { 112 | mBright = false; 113 | mPrefs.edit().putBoolean("bright", false).commit(); 114 | } 115 | } 116 | }); 117 | } else { 118 | // Fully hide the UI elements on Crespo since we can't use them 119 | mBrightSwitch.setVisibility(View.GONE); 120 | findViewById(R.id.ruler2).setVisibility(View.GONE); 121 | } 122 | 123 | // Set the state of the strobing section and hide as appropriate 124 | final boolean isStrobing = mPrefs.getBoolean("strobe", false); 125 | final LinearLayout strobeLayout = (LinearLayout) findViewById(R.id.strobeRow); 126 | int visibility = isStrobing ? View.VISIBLE : View.GONE; 127 | 128 | strobeLayout.setVisibility(visibility); 129 | mStrobeSwitch.setChecked(isStrobing); 130 | mStrobeSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { 131 | @Override 132 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 133 | int visibility = isChecked ? View.VISIBLE : View.GONE; 134 | strobeLayout.setVisibility(visibility); 135 | mPrefs.edit().putBoolean("strobe", isChecked).commit(); 136 | } 137 | }); 138 | 139 | mButtonOn.setOnClickListener(new OnClickListener() { 140 | @Override 141 | public void onClick(View v) { 142 | Intent intent = new Intent(TorchSwitch.TOGGLE_FLASHLIGHT); 143 | intent.putExtra("strobe", mStrobeSwitch.isChecked()); 144 | intent.putExtra("period", mStrobePeriod); 145 | intent.putExtra("bright", mBright); 146 | sendBroadcast(intent); 147 | } 148 | }); 149 | 150 | // Strobe frequency slider bar handling 151 | setProgressBarVisibility(true); 152 | updateStrobePeriod(mPrefs.getInt("strobeperiod", 100)); 153 | mSlider.setHorizontalScrollBarEnabled(true); 154 | mSlider.setProgress(400 - mStrobePeriod); 155 | 156 | mSlider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { 157 | @Override 158 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 159 | updateStrobePeriod(Math.max(20, 401 - progress)); 160 | 161 | Intent intent = new Intent("net.cactii.flash2.SET_STROBE"); 162 | intent.putExtra("period", mStrobePeriod); 163 | sendBroadcast(intent); 164 | } 165 | 166 | @Override 167 | public void onStartTrackingTouch(SeekBar seekBar) { 168 | } 169 | 170 | @Override 171 | public void onStopTrackingTouch(SeekBar seekBar) { 172 | } 173 | }); 174 | 175 | // Show the about dialog, the first time the user runs the app. 176 | if (!mPrefs.getBoolean("aboutSeen", false)) { 177 | openAboutDialog(); 178 | mPrefs.edit().putBoolean("aboutSeen", true).commit(); 179 | } 180 | } 181 | 182 | @Override 183 | public void onPause() { 184 | mPrefs.edit().putInt("strobeperiod", mStrobePeriod).commit(); 185 | updateWidget(); 186 | unregisterReceiver(mStateReceiver); 187 | super.onPause(); 188 | } 189 | 190 | @Override 191 | public void onDestroy() { 192 | updateWidget(); 193 | super.onDestroy(); 194 | } 195 | 196 | @Override 197 | public void onResume() { 198 | updateBigButtonState(); 199 | updateWidget(); 200 | registerReceiver(mStateReceiver, new IntentFilter(TorchSwitch.TORCH_STATE_CHANGED)); 201 | super.onResume(); 202 | } 203 | 204 | @Override 205 | public boolean onCreateOptionsMenu(Menu menu) { 206 | getMenuInflater().inflate(R.menu.main, menu); 207 | return true; 208 | } 209 | 210 | @Override 211 | public boolean onOptionsItemSelected(MenuItem menuItem) { 212 | if (menuItem.getItemId() == R.id.action_about) { 213 | openAboutDialog(); 214 | return true; 215 | } 216 | return false; 217 | } 218 | 219 | private void updateStrobePeriod(int period) { 220 | mStrobeLabel.setText(getString(R.string.setting_frequency_title) + ": " + 221 | 666 / period + "Hz / " + 40000 / period + "BPM"); 222 | mStrobePeriod = period; 223 | } 224 | 225 | private void openAboutDialog() { 226 | LayoutInflater inflater = LayoutInflater.from(this); 227 | View view = inflater.inflate(R.layout.aboutview, null); 228 | 229 | new AlertDialog.Builder(this) 230 | .setTitle(R.string.about_title) 231 | .setView(view) 232 | .setNegativeButton(R.string.about_close, null) 233 | .show(); 234 | } 235 | 236 | private void openBrightDialog() { 237 | LayoutInflater inflater = LayoutInflater.from(this); 238 | View view = inflater.inflate(R.layout.brightwarn, null); 239 | 240 | new AlertDialog.Builder(this) 241 | .setTitle(R.string.warning_label) 242 | .setView(view) 243 | .setNegativeButton(R.string.brightwarn_negative, new DialogInterface.OnClickListener() { 244 | @Override 245 | public void onClick(DialogInterface dialog, int whichButton) { 246 | mBrightSwitch.setChecked(false); 247 | } 248 | }) 249 | .setPositiveButton(R.string.brightwarn_accept, new DialogInterface.OnClickListener() { 250 | @Override 251 | public void onClick(DialogInterface dialog, int whichButton) { 252 | mBright = true; 253 | mPrefs.edit().putBoolean("bright", true).commit(); 254 | } 255 | }) 256 | .show(); 257 | } 258 | 259 | private void updateWidget() { 260 | mWidgetProvider.updateAllStates(this); 261 | } 262 | 263 | private void updateBigButtonState() { 264 | mButtonOn.setChecked(mTorchOn); 265 | mBrightSwitch.setEnabled(!mTorchOn && mHasBrightSetting); 266 | mStrobeSwitch.setEnabled(!mTorchOn); 267 | mSlider.setEnabled(!mTorchOn || mStrobeSwitch.isChecked()); 268 | } 269 | } 270 | -------------------------------------------------------------------------------- /src/net/cactii/flash2/SeekBarPreference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The CyanogenMod Project 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 3 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 | * MA 02110-1301, USA. 17 | */ 18 | 19 | package net.cactii.flash2; 20 | 21 | import android.content.Context; 22 | import android.preference.DialogPreference; 23 | import android.util.AttributeSet; 24 | import android.view.Gravity; 25 | import android.view.View; 26 | import android.widget.LinearLayout; 27 | import android.widget.SeekBar; 28 | import android.widget.TextView; 29 | 30 | public class SeekBarPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener { 31 | private SeekBar mSeekBar; 32 | private TextView mSplashText, mValueText; 33 | private final String mDialogMessage, mSuffix; 34 | private int mDefault, mMax, mValue = 0; 35 | 36 | public SeekBarPreference(Context context, AttributeSet attrs) { 37 | super(context, attrs); 38 | 39 | mDialogMessage = context.getString(R.string.setting_frequency_dialog); 40 | mSuffix = context.getString(R.string.setting_frequency_hz); 41 | //has min value of 1hz but displays 0hz 42 | mDefault = 4; 43 | mMax = 24; 44 | } 45 | 46 | @Override 47 | protected View onCreateDialogView() { 48 | final Context context = getContext(); 49 | LinearLayout.LayoutParams params; 50 | LinearLayout layout = new LinearLayout(context); 51 | layout.setOrientation(LinearLayout.VERTICAL); 52 | layout.setPadding(6, 6, 6, 6); 53 | 54 | mSplashText = new TextView(context); 55 | if (mDialogMessage != null) { 56 | mSplashText.setText(mDialogMessage); 57 | } 58 | layout.addView(mSplashText); 59 | 60 | mValueText = new TextView(context); 61 | mValueText.setGravity(Gravity.CENTER_HORIZONTAL); 62 | mValueText.setTextSize(32); 63 | params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 64 | LinearLayout.LayoutParams.WRAP_CONTENT); 65 | layout.addView(mValueText, params); 66 | 67 | mSeekBar = new SeekBar(context); 68 | mSeekBar.setOnSeekBarChangeListener(this); 69 | layout.addView(mSeekBar, new LinearLayout.LayoutParams( 70 | LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); 71 | 72 | if (shouldPersist()) { 73 | mValue = getPersistedInt(mDefault); 74 | } 75 | 76 | mSeekBar.setMax(mMax); 77 | mSeekBar.setProgress(mValue); 78 | return layout; 79 | } 80 | 81 | @Override 82 | protected void onBindDialogView(View v) { 83 | super.onBindDialogView(v); 84 | mSeekBar.setMax(mMax); 85 | mSeekBar.setProgress(mValue); 86 | } 87 | 88 | @Override 89 | protected void onSetInitialValue(boolean restore, Object defaultValue) { 90 | super.onSetInitialValue(restore, defaultValue); 91 | if (restore) { 92 | mValue = shouldPersist() ? getPersistedInt(mDefault) : 0; 93 | } else { 94 | mValue = (Integer) defaultValue; 95 | } 96 | } 97 | 98 | @Override 99 | public void onProgressChanged(SeekBar seek, int value, boolean fromTouch) { 100 | String t = String.valueOf(value + 1); 101 | mValueText.setText(mSuffix == null ? t : t.concat(mSuffix)); 102 | if (shouldPersist()) { 103 | persistInt(value); 104 | } 105 | callChangeListener(value); 106 | } 107 | 108 | @Override 109 | public void onStartTrackingTouch(SeekBar seek) { 110 | } 111 | 112 | @Override 113 | public void onStopTrackingTouch(SeekBar seek) { 114 | } 115 | 116 | public void setMax(int max) { 117 | mMax = max; 118 | } 119 | 120 | public int getMax() { 121 | return mMax; 122 | } 123 | 124 | public void setProgress(int progress) { 125 | mValue = progress; 126 | if (mSeekBar != null) { 127 | mSeekBar.setProgress(progress); 128 | } 129 | } 130 | 131 | public int getProgress() { 132 | return mValue; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/net/cactii/flash2/TorchService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The CyanogenMod Project 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 3 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 | * MA 02110-1301, USA. 17 | */ 18 | 19 | package net.cactii.flash2; 20 | 21 | import android.app.Notification; 22 | import android.app.PendingIntent; 23 | import android.app.Service; 24 | import android.content.BroadcastReceiver; 25 | import android.content.Context; 26 | import android.content.Intent; 27 | import android.content.IntentFilter; 28 | import android.os.Handler; 29 | import android.os.IBinder; 30 | import android.os.Message; 31 | import android.util.Log; 32 | 33 | public class TorchService extends Service { 34 | private static final String MSG_TAG = "TorchRoot"; 35 | 36 | private int mFlashMode; 37 | private int mStrobePeriod; 38 | private boolean mStrobeOn; 39 | 40 | private static final int MSG_UPDATE_FLASH = 1; 41 | private static final int MSG_DO_STROBE = 2; 42 | 43 | private final BroadcastReceiver mStrobeReceiver = new BroadcastReceiver() { 44 | @Override 45 | public void onReceive(Context context, Intent intent) { 46 | mHandler.removeMessages(MSG_DO_STROBE); 47 | mStrobePeriod = intent.getIntExtra("period", 200); 48 | mHandler.sendEmptyMessage(MSG_DO_STROBE); 49 | } 50 | }; 51 | 52 | private final Handler mHandler = new Handler() { 53 | @Override 54 | public void handleMessage(Message msg) { 55 | final FlashDevice flash = FlashDevice.instance(TorchService.this); 56 | 57 | switch (msg.what) { 58 | case MSG_UPDATE_FLASH: 59 | if (mStrobePeriod != 0) { 60 | flash.setFlashMode(mStrobeOn ? mFlashMode : FlashDevice.STROBE); 61 | } else { 62 | flash.setFlashMode(mFlashMode); 63 | } 64 | removeMessages(MSG_UPDATE_FLASH); 65 | sendEmptyMessageDelayed(MSG_UPDATE_FLASH, 100); 66 | break; 67 | case MSG_DO_STROBE: 68 | mStrobeOn = !mStrobeOn; 69 | removeMessages(MSG_UPDATE_FLASH); 70 | sendEmptyMessage(MSG_UPDATE_FLASH); 71 | sendEmptyMessageDelayed(MSG_DO_STROBE, mStrobePeriod); 72 | break; 73 | } 74 | } 75 | }; 76 | 77 | @Override 78 | public int onStartCommand(Intent intent, int flags, int startId) { 79 | Log.d(MSG_TAG, "Starting torch"); 80 | 81 | if (intent == null) { 82 | stopSelf(); 83 | return START_NOT_STICKY; 84 | } 85 | 86 | mFlashMode = intent.getBooleanExtra("bright", false) 87 | ? FlashDevice.DEATH_RAY : FlashDevice.ON; 88 | 89 | if (intent.getBooleanExtra("strobe", false)) { 90 | mStrobePeriod = intent.getIntExtra("period", 200); 91 | mStrobeOn = false; 92 | mHandler.sendEmptyMessage(MSG_DO_STROBE); 93 | } else { 94 | mStrobePeriod = 0; 95 | } 96 | mHandler.sendEmptyMessage(MSG_UPDATE_FLASH); 97 | 98 | registerReceiver(mStrobeReceiver, new IntentFilter("net.cactii.flash2.SET_STROBE")); 99 | 100 | PendingIntent contentIntent = PendingIntent.getActivity(this, 101 | 0, new Intent(this, MainActivity.class), 0); 102 | PendingIntent turnOffIntent = PendingIntent.getBroadcast(this, 0, 103 | new Intent(TorchSwitch.TOGGLE_FLASHLIGHT), 0); 104 | 105 | Notification notification = new Notification.Builder(this) 106 | .setSmallIcon(R.drawable.notification_icon) 107 | .setTicker(getString(R.string.not_torch_title)) 108 | .setContentTitle(getString(R.string.not_torch_title)) 109 | .setContentIntent(contentIntent) 110 | .setAutoCancel(false) 111 | .setOngoing(true) 112 | .addAction(R.drawable.ic_appwidget_torch_off, 113 | getString(R.string.not_torch_toggle), turnOffIntent) 114 | .build(); 115 | 116 | startForeground(getString(R.string.app_name).hashCode(), notification); 117 | updateState(true); 118 | 119 | return START_STICKY; 120 | } 121 | 122 | @Override 123 | public void onDestroy() { 124 | unregisterReceiver(mStrobeReceiver); 125 | stopForeground(true); 126 | mHandler.removeCallbacksAndMessages(null); 127 | FlashDevice.instance(this).setFlashMode(FlashDevice.OFF); 128 | updateState(false); 129 | } 130 | 131 | @Override 132 | public IBinder onBind(Intent intent) { 133 | return null; 134 | } 135 | 136 | private void updateState(boolean on) { 137 | Intent intent = new Intent(TorchSwitch.TORCH_STATE_CHANGED); 138 | intent.putExtra("state", on ? 1 : 0); 139 | sendStickyBroadcast(intent); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/net/cactii/flash2/TorchSwitch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The CyanogenMod Project 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 3 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 | * MA 02110-1301, USA. 17 | */ 18 | 19 | package net.cactii.flash2; 20 | 21 | import android.app.Activity; 22 | import android.app.ActivityManager; 23 | import android.app.ActivityManager.RunningServiceInfo; 24 | import android.content.BroadcastReceiver; 25 | import android.content.ComponentName; 26 | import android.content.Context; 27 | import android.content.Intent; 28 | import android.content.SharedPreferences; 29 | import android.preference.PreferenceManager; 30 | 31 | import java.util.List; 32 | 33 | public class TorchSwitch extends BroadcastReceiver { 34 | 35 | public static final String TOGGLE_FLASHLIGHT = "net.cactii.flash2.TOGGLE_FLASHLIGHT"; 36 | public static final String TORCH_STATE_CHANGED = "net.cactii.flash2.TORCH_STATE_CHANGED"; 37 | 38 | @Override 39 | public void onReceive(Context context, Intent intent) { 40 | if (intent.getAction().equals(TOGGLE_FLASHLIGHT)) { 41 | // bright setting can come from intent or from prefs depending on 42 | // on what send the broadcast 43 | // 44 | // Unload intent extras if they exist: 45 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 46 | boolean bright = intent.getBooleanExtra("bright", prefs.getBoolean("bright", false)); 47 | boolean strobe = intent.getBooleanExtra("strobe", prefs.getBoolean("strobe", false)); 48 | int period = intent.getIntExtra("period", 200); 49 | 50 | Intent i = new Intent(context, TorchService.class); 51 | if (this.torchServiceRunning(context)) { 52 | context.stopService(i); 53 | } else { 54 | i.putExtra("bright", bright); 55 | i.putExtra("strobe", strobe); 56 | i.putExtra("period", period); 57 | context.startService(i); 58 | } 59 | } 60 | } 61 | 62 | private boolean torchServiceRunning(Context context) { 63 | ActivityManager am = (ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE); 64 | List svcList = am.getRunningServices(100); 65 | 66 | for (RunningServiceInfo serviceInfo : svcList) { 67 | ComponentName serviceName = serviceInfo.service; 68 | if (serviceName.getClassName().endsWith(".TorchService") 69 | || serviceName.getClassName().endsWith(".RootTorchService")) 70 | return true; 71 | } 72 | return false; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/net/cactii/flash2/TorchWidgetProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The CyanogenMod Project 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 3 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 | * MA 02110-1301, USA. 17 | */ 18 | 19 | package net.cactii.flash2; 20 | 21 | import android.app.PendingIntent; 22 | import android.appwidget.AppWidgetManager; 23 | import android.appwidget.AppWidgetProvider; 24 | import android.content.ComponentName; 25 | import android.content.Context; 26 | import android.content.Intent; 27 | import android.content.IntentFilter; 28 | import android.content.SharedPreferences; 29 | import android.net.Uri; 30 | import android.preference.PreferenceManager; 31 | import android.widget.RemoteViews; 32 | 33 | public class TorchWidgetProvider extends AppWidgetProvider { 34 | 35 | private static TorchWidgetProvider sInstance; 36 | 37 | static synchronized TorchWidgetProvider getInstance() { 38 | if (sInstance == null) { 39 | sInstance = new TorchWidgetProvider(); 40 | } 41 | return sInstance; 42 | } 43 | 44 | private enum WidgetState { 45 | OFF (R.drawable.ic_appwidget_torch_off,R.drawable.ind_bar_off), 46 | ON (R.drawable.ic_appwidget_torch_on,R.drawable.ind_bar_on); 47 | 48 | /** 49 | * The drawable resources associated with this widget state. 50 | */ 51 | private final int mDrawImgRes; 52 | private final int mDrawIndRes; 53 | 54 | private WidgetState(int drawImgRes, int drawIndRes) { 55 | mDrawImgRes = drawImgRes; 56 | mDrawIndRes = drawIndRes; 57 | } 58 | 59 | public int getImgDrawable() { 60 | return mDrawImgRes; 61 | } 62 | 63 | public int getIndDrawable() { 64 | return mDrawIndRes; 65 | } 66 | } 67 | 68 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { 69 | for (int appWidgetId : appWidgetIds) 70 | this.updateState(context, appWidgetId); 71 | } 72 | 73 | private static PendingIntent getLaunchPendingIntent(Context context, int appWidgetId) { 74 | Intent launchIntent = new Intent(); 75 | launchIntent.setClass(context, TorchWidgetProvider.class); 76 | launchIntent.addCategory(Intent.CATEGORY_ALTERNATIVE); 77 | launchIntent.setData(Uri.parse("custom:" + appWidgetId + "/" + 0)); 78 | return PendingIntent.getBroadcast(context, 79 | 0 /* no requestCode */, launchIntent, 0 /* no flags */); 80 | } 81 | 82 | public void onReceive(Context context, Intent intent) { 83 | super.onReceive(context, intent); 84 | SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context); 85 | if (intent.hasCategory(Intent.CATEGORY_ALTERNATIVE)) { 86 | String[] parts = intent.getData().getSchemeSpecificPart().split("/"); 87 | int widgetId = Integer.parseInt(parts[0]); 88 | int buttonId = Integer.parseInt(parts[1]); 89 | 90 | if (buttonId == 0) { 91 | Intent pendingIntent = new Intent(TorchSwitch.TOGGLE_FLASHLIGHT); 92 | pendingIntent.putExtra("bright", 93 | mPrefs.getBoolean("widget_bright_" + widgetId, false)); 94 | pendingIntent.putExtra("strobe", 95 | mPrefs.getBoolean("widget_strobe_" + widgetId, false)); 96 | pendingIntent.putExtra("period", 97 | mPrefs.getInt("widget_strobe_freq_" + widgetId, 200)); 98 | context.sendBroadcast(pendingIntent); 99 | } 100 | try { 101 | Thread.sleep(50); 102 | } catch (InterruptedException e) { 103 | // TODO Auto-generated catch block 104 | e.printStackTrace(); 105 | } 106 | this.updateAllStates(context); 107 | } else if (intent.getAction().equals(TorchSwitch.TORCH_STATE_CHANGED)) { 108 | this.updateAllStates(context); 109 | } 110 | } 111 | 112 | public void updateAllStates(Context context) { 113 | final AppWidgetManager am = AppWidgetManager.getInstance(context); 114 | int[] appWidgetIds = am.getAppWidgetIds( 115 | new ComponentName(context, this.getClass())); 116 | for (int appWidgetId : appWidgetIds) 117 | this.updateState(context, appWidgetId); 118 | } 119 | 120 | void updateState(Context context, int appWidgetId) { 121 | RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); 122 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 123 | Intent stateIntent = context.registerReceiver(null, 124 | new IntentFilter(TorchSwitch.TORCH_STATE_CHANGED)); 125 | boolean on = stateIntent != null && stateIntent.getIntExtra("state", 0) != 0; 126 | 127 | views.setOnClickPendingIntent(R.id.btn, getLaunchPendingIntent(context, appWidgetId)); 128 | 129 | if (on) { 130 | views.setImageViewResource(R.id.img_torch, WidgetState.ON.getImgDrawable()); 131 | views.setImageViewResource(R.id.ind_torch, WidgetState.ON.getIndDrawable()); 132 | } else { 133 | views.setImageViewResource(R.id.img_torch, WidgetState.OFF.getImgDrawable()); 134 | views.setImageViewResource(R.id.ind_torch, WidgetState.OFF.getIndDrawable()); 135 | } 136 | 137 | if (prefs.getBoolean("widget_strobe_" + appWidgetId, false)) { 138 | views.setTextViewText(R.id.ind_text, context.getString(R.string.label_strobe)); 139 | } else if (prefs.getBoolean("widget_bright_" + appWidgetId, false)) { 140 | views.setTextViewText(R.id.ind_text, context.getString(R.string.label_high)); 141 | } 142 | 143 | final AppWidgetManager gm = AppWidgetManager.getInstance(context); 144 | gm.updateAppWidget(appWidgetId, views); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/net/cactii/flash2/WidgetOptionsActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The CyanogenMod Project 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 3 as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 | * MA 02110-1301, USA. 17 | */ 18 | 19 | package net.cactii.flash2; 20 | 21 | import android.app.PendingIntent; 22 | import android.appwidget.AppWidgetManager; 23 | import android.content.Context; 24 | import android.content.Intent; 25 | import android.content.SharedPreferences; 26 | import android.content.SharedPreferences.Editor; 27 | import android.content.SharedPreferences.OnSharedPreferenceChangeListener; 28 | import android.net.Uri; 29 | import android.os.Bundle; 30 | import android.preference.CheckBoxPreference; 31 | import android.preference.PreferenceActivity; 32 | import android.preference.PreferenceManager; 33 | import android.view.Menu; 34 | import android.view.MenuInflater; 35 | import android.view.MenuItem; 36 | import android.widget.RemoteViews; 37 | 38 | public class WidgetOptionsActivity extends PreferenceActivity implements 39 | OnSharedPreferenceChangeListener { 40 | 41 | private int mAppWidgetId; 42 | private SeekBarPreference mStrobeFrequency; 43 | private SharedPreferences mPreferences; 44 | 45 | @SuppressWarnings("deprecation") 46 | //No need to go to fragments right now 47 | public void onCreate(Bundle savedInstanceState) { 48 | super.onCreate(savedInstanceState); 49 | 50 | addPreferencesFromResource(R.layout.optionsview); 51 | 52 | mPreferences = PreferenceManager.getDefaultSharedPreferences(this); 53 | Bundle extras = getIntent().getExtras(); 54 | if (extras != null) { 55 | mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, 56 | AppWidgetManager.INVALID_APPWIDGET_ID); 57 | } 58 | 59 | CheckBoxPreference brightPref = (CheckBoxPreference) findPreference("widget_bright"); 60 | brightPref.setChecked(false); 61 | 62 | CheckBoxPreference strobePref = (CheckBoxPreference) findPreference("widget_strobe"); 63 | strobePref.setChecked(false); 64 | 65 | mStrobeFrequency = (SeekBarPreference) findPreference("widget_strobe_freq"); 66 | mStrobeFrequency.setEnabled(false); 67 | 68 | //keeps 'Strobe frequency' option available 69 | getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); 70 | } 71 | 72 | void addWidget() { 73 | Editor editor = mPreferences.edit(); 74 | 75 | editor.putBoolean("widget_strobe_" + mAppWidgetId, 76 | mPreferences.getBoolean("widget_strobe", false)); 77 | //TODO: Fix temporary patch 78 | //had to do +1 to fix division by zero crash, only temporary fix: 79 | editor.putInt("widget_strobe_freq_" + mAppWidgetId, 80 | 666 / (1 + mPreferences.getInt("widget_strobe_freq", 5))); 81 | editor.putBoolean("widget_bright_" + mAppWidgetId, 82 | mPreferences.getBoolean("widget_bright", false)); 83 | editor.commit(); 84 | 85 | //Initialize widget view for first update 86 | Context context = getApplicationContext(); 87 | RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); 88 | Intent launchIntent = new Intent(); 89 | launchIntent.setClass(context, TorchWidgetProvider.class); 90 | launchIntent.addCategory(Intent.CATEGORY_ALTERNATIVE); 91 | launchIntent.setData(Uri.parse("custom:" + mAppWidgetId + "/0")); 92 | 93 | PendingIntent pi = PendingIntent.getBroadcast(context, 94 | 0 /* no requestCode */, launchIntent, 0 /* no flags */); 95 | views.setOnClickPendingIntent(R.id.btn, pi); 96 | 97 | if (mPreferences.getBoolean("widget_strobe_" + mAppWidgetId, false)) { 98 | views.setTextViewText(R.id.ind_text, context.getString(R.string.label_strobe)); 99 | } else if (mPreferences.getBoolean("widget_bright_" + mAppWidgetId, false)) { 100 | views.setTextViewText(R.id.ind_text, context.getString(R.string.label_high)); 101 | } 102 | 103 | final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); 104 | appWidgetManager.updateAppWidget(mAppWidgetId, views); 105 | 106 | Intent resultValue = new Intent(); 107 | resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); 108 | setResult(RESULT_OK, resultValue); 109 | 110 | //close the activity 111 | finish(); 112 | } 113 | 114 | @Override 115 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { 116 | if (key.equals("widget_strobe")) { 117 | mStrobeFrequency.setEnabled(sharedPreferences.getBoolean("widget_strobe", false)); 118 | } 119 | } 120 | 121 | @Override 122 | public boolean onCreateOptionsMenu(Menu menu) { 123 | MenuInflater inflater = getMenuInflater(); 124 | inflater.inflate(R.menu.widget, menu); 125 | return true; 126 | } 127 | 128 | @Override 129 | public boolean onOptionsItemSelected(MenuItem item) { 130 | switch (item.getItemId()) { 131 | case R.id.saveSetting : //Changes are accepted 132 | addWidget(); 133 | return true; 134 | default: 135 | return super.onOptionsItemSelected(item); 136 | } 137 | } 138 | } 139 | --------------------------------------------------------------------------------