diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 56c0bb0..a52fb96 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,8 +1,8 @@
+ android:versionCode="15"
+ android:versionName="1.5" >
-
-
diff --git a/res/drawable-hdpi/btn_cling_normal.9.png b/res/drawable-hdpi/btn_cling_normal.9.png
new file mode 100644
index 0000000..aea8beb
Binary files /dev/null and b/res/drawable-hdpi/btn_cling_normal.9.png differ
diff --git a/res/drawable-hdpi/btn_cling_pressed.9.png b/res/drawable-hdpi/btn_cling_pressed.9.png
new file mode 100644
index 0000000..ebefd20
Binary files /dev/null and b/res/drawable-hdpi/btn_cling_pressed.9.png differ
diff --git a/res/drawable-hdpi/cling.png b/res/drawable-hdpi/cling.png
new file mode 100644
index 0000000..d605799
Binary files /dev/null and b/res/drawable-hdpi/cling.png differ
diff --git a/res/drawable-hdpi/hand.png b/res/drawable-hdpi/hand.png
new file mode 100644
index 0000000..bd4f6df
Binary files /dev/null and b/res/drawable-hdpi/hand.png differ
diff --git a/res/drawable-xhdpi/btn_cling_normal.9.png b/res/drawable-xhdpi/btn_cling_normal.9.png
new file mode 100644
index 0000000..35511d6
Binary files /dev/null and b/res/drawable-xhdpi/btn_cling_normal.9.png differ
diff --git a/res/drawable-xhdpi/btn_cling_pressed.9.png b/res/drawable-xhdpi/btn_cling_pressed.9.png
new file mode 100644
index 0000000..a38b40f
Binary files /dev/null and b/res/drawable-xhdpi/btn_cling_pressed.9.png differ
diff --git a/res/drawable-xhdpi/cling.png b/res/drawable-xhdpi/cling.png
new file mode 100644
index 0000000..1cee1de
Binary files /dev/null and b/res/drawable-xhdpi/cling.png differ
diff --git a/res/drawable-xhdpi/hand.png b/res/drawable-xhdpi/hand.png
new file mode 100644
index 0000000..35b678c
Binary files /dev/null and b/res/drawable-xhdpi/hand.png differ
diff --git a/res/drawable/button_bg.xml b/res/drawable/button_bg.xml
new file mode 100644
index 0000000..5dbb547
--- /dev/null
+++ b/res/drawable/button_bg.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
diff --git a/res/drawable/cling_button_bg.xml b/res/drawable/cling_button_bg.xml
new file mode 100644
index 0000000..7fd5d37
--- /dev/null
+++ b/res/drawable/cling_button_bg.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
diff --git a/res/drawable/helper_1.JPG b/res/drawable/helper_1.JPG
deleted file mode 100644
index 2ade75f..0000000
Binary files a/res/drawable/helper_1.JPG and /dev/null differ
diff --git a/res/drawable/helper_2.JPG b/res/drawable/helper_2.JPG
deleted file mode 100644
index aa955a7..0000000
Binary files a/res/drawable/helper_2.JPG and /dev/null differ
diff --git a/res/drawable/helper_3.JPG b/res/drawable/helper_3.JPG
deleted file mode 100644
index 669afa9..0000000
Binary files a/res/drawable/helper_3.JPG and /dev/null differ
diff --git a/res/layout/activity_helper.xml b/res/layout/activity_helper.xml
deleted file mode 100644
index 3c8143e..0000000
--- a/res/layout/activity_helper.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/handy.xml b/res/layout/handy.xml
new file mode 100644
index 0000000..426d9f6
--- /dev/null
+++ b/res/layout/handy.xml
@@ -0,0 +1,6 @@
+
+
+
\ No newline at end of file
diff --git a/res/layout/showcase_button.xml b/res/layout/showcase_button.xml
new file mode 100644
index 0000000..918b73e
--- /dev/null
+++ b/res/layout/showcase_button.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml
deleted file mode 100644
index 392a064..0000000
--- a/res/values-ar/strings.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-HALO)))
-اضغط للانطلاق
-البدء
-ايقاف
-اضافة
-اختيار التطبيق
-نوع ايقونة الاختيار
-الايقونة الافتراضيه
-تعديل الايقونة
-غير معلوم
-وقف الازالة
-
diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml
deleted file mode 100644
index 96c6b02..0000000
--- a/res/values-ca/strings.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- HALO)))
- Pitgeu per llançar l\'aplicació
- Inicia
- Atura
- Afegir
- Selecciona aplicació
- Seleccioneu el tipus d\'icona:
- Per defecte
- Personalitzat
- Desconegut
-
- Si us plau atureu el servei abans de treure qualsevol aplicació
-
- Notes
- Nota 1
- Nota 2
- Nota 3
- Nota 4
- Extensions
-
-
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
deleted file mode 100644
index 4ecde11..0000000
--- a/res/values-da/strings.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- HALO)))
- Tryk for at åbne applikationen
- Start
- Stop
- Fastgør
- Fastgør applikation
- Vælg ikon type:
- Standard
- Custom
- Ukendt
-
- Stop venligst denne service før du fjerner en applikation fra listen
-
- Note 1
- Note 2
- Note 3
- Note 4
- Udvidelser
-
-
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
deleted file mode 100644
index 4af2449..0000000
--- a/res/values-de/strings.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
- HALO)))
- Tippen zum Starten der Applikation
- Start
- Stopp
- Anheften
- Applikation anheften
- Symboltyp auswählen:
- Standard
- Eigenen
- Unbekannt
-
- Bitte beende den Dienst bevor du eine Applikation von der Liste entfernst
-
- Hinweise
- Notiz 1
- Notiz 2
- Notiz 3
- Notiz 4
- Erweiterungen
-
- "HALO))) verwenden"
- "HALO))) zu verstehen ist sehr einfach. Einfach auf den Pin Button in der Action Bar tippen. Beachten Sie, dass sich der Button oben oder unten auf Ihrem Bildschirm befinden kann."
- "Als nächstes klicken Sie in der Liste auf die gewünschte Anwendung, die Sie gerne in Halo anpinnen möchten."
- "Zuletzt klicken Sie noch auf die Schaltfläche \'Start\' und schon sind Sie fertig. Wenn Sie HALO))) deaktivieren wollen, klicken Sie auf den Pause Button."
-
- Ist ParanoidAndroid installiert?
- "Halo))) ist speziell für ParanoidAndroid ROMs entwickelt worden. Sie werden unter Umständen nicht dazu in der Lage sein, alle Funktionen dieser App zu nutzen."
- "OK"
- PA Installieren
-
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
deleted file mode 100755
index 260f716..0000000
--- a/res/values-es/strings.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- HALO)))
- Toque para lanzar la aplicación
- Iniciar
- Detener
- Añadir
- Seleccionar aplicación
- Seleccione el tipo de icono:
- Por defecto
- Personalizado
- Desconocido
-
- Por favor detenga el servicio antes de remover cualquier aplicación
-
- Notas
- Nota 1
- Nota 2
- Nota 3
- Nota 4
- Extensiones
-
-
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
deleted file mode 100644
index 1cb8102..0000000
--- a/res/values-fr/strings.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- HALO)))
- Touchez pour lancer l\'application
- Lancer
- Arrêter
- Ajouter
- Sélectionner une application
- Sélectionnez le type d\'icône :
- Par défaut
- Personnalisé
- Inconnue
-
- Arrêtez le service avant de retirer une application
-
- Note 1
- Note 2
- Note 3
- Note 4
- Extensions
-
-
diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml
deleted file mode 100644
index c4b0673..0000000
--- a/res/values-it/strings.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
- HALO)))
- Tocca per avviare l\'applicazione
- Avvia
- Stop
- Vincola
- Vincola applicazione
- Seleziona il tipo di icona:
- Predefinita
- Personalizzata
- Sconosciuto
-
- Per favore disattiva la funzione prima di rimuovere qualsiasi applicazione dalla lista
-
- Note
- Nota 1
- Nota 2
- Nota 3
- Nota 4
- Estensioni
-
- "Usare HALO)))"
- "Capire HALO))) è molto semplice. Tocca il tasto Vincola nella Barra d\'Azione. Tieni presente che il tasto potrebbe essere nella parte superiore o inferiore dello schermo."
- "Ora, Clicca l\'applicazione che vorresti vincolare in HALO))) dalla lista."
- "Infine, Clicca sul tasto start ed è fatta. Se vuoi disabilitare HALO))) clicca il tasto pausa."
-
- ParanoidAndroid è installata?
- "HALO))) è sviluppato per lavorare in primis su ROMs ParanoidAndroid. Potresti non essere in grado di provarne le piene potenzialità e funzioni."
- "OK"
- Installa PA
-
-
diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml
deleted file mode 100755
index a2b0f5f..0000000
--- a/res/values-ko/strings.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
- 클릭하여 앱을 실행합니다.
- 시작
- 중지
- 추가
- 애플리케이션 선택
- 알 수 없음
- 목록에 있는 앱을 제거하기 전에 서비스를 중지해야 합니다.
-
diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml
deleted file mode 100644
index 6066db3..0000000
--- a/res/values-nl/strings.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- HALO)))
- Klik om de app te starten
- Start
- Stop
- Pin
- Pin een app
- Kies een icoonsoort
- Standaard
- Aangepast
- Onbekend
-
- Stop de service voordat je een app verwijdert
-
- Note 1
- Note 2
- Note 3
- Note 4
- Uitbreidingen
-
-
diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml
deleted file mode 100644
index f8b7457..0000000
--- a/res/values-pl/strings.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- HALO)))
- Dotknij, aby uruchomić aplikację
- Uruchom
- Zatrzymaj
- Przypnij
- Przypnij aplikację
- Wybierz ikonę:
- Domyślna
- Inna
- Nieznana
-
- Przed usunięciem aplikacji z listy musisz zatrzymać usługę
-
- Notatka 1
- Notatka 2
- Notatka 3
- Notatka 4
- Rozszerzenia
-
-
\ No newline at end of file
diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml
deleted file mode 100644
index 7e06c6d..0000000
--- a/res/values-pt/strings.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
- HALO)))
- Toque para iniciar a aplicação
- Iniciar
- Parar
- Fixar
- Fixar aplicação
- Selecione o tipo de ícone:
- Padrão
- Customizado
- Desconhecido
-
- Por favor pare o serviço antes de remover qualquer aplicação da lista
-
- Nota 1
- Nota 2
- Nota 3
- Nota 4
- Extensões
-
-
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
deleted file mode 100644
index 64f2b44..0000000
--- a/res/values-ru/strings.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
- HALO)))
- Нажать для запуска приложения
- Старт
- Стоп
- Прикрепить
- Выбрать приложение
- Тип иконки:
- По умолчанию
- Задать
- Неизвестно
-
- Пожалуйста, преостановите сервис, прежде чем удалить приложение из списка
-
- Заметки
- Заметка 1
- Заметка 2
- Заметка 3
- Заметка 4
- Расширения
-
- "HALO))) в использовании"
- "HALO))) очень прост в использовании: простым нажатием кнопки Прикрепить в строке меню. Кнопка Прикрепить может быть расположена в верхней или нижней части экрана."
- "Затем выбрать из списка желаемое приложение и прикрепить его в HALO)))."
- "Для активизации HALO))) нажать кнопку Старт. Для деактивизации HALO))) нажать кнопку Пауза."
-
- У Вас установлен ParanoidAndroid?
- "HALO))) главным образом расчитан на работу в системе ParanoidAndroid. Возможно, Вы не сможете использовать HALO))) со всеми предполагаемыми компонентами и функциями."
- "OK"
- Установить ParanoidAndroid
-
-
\ No newline at end of file
diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml
deleted file mode 100644
index 1c01beb..0000000
--- a/res/values-tr/strings.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- HALO)))
- Uygulamayı başlatmak için dokunun
- Başlat
- Durdur
- Ekle
- Uygulama seç
- Simge tarzı:
- Varsayılan
- Kişisel
- Bilinmeyen
-
- Listeden uygulama çıkartmak için lütfen önce servisi durdurun.
-
- Notlar
- 1. Not
- 2. Not
- 3. Not
- 4. Not
- Eklentiler
-
diff --git a/res/values-zh-rHK/strings.xml b/res/values-zh-rHK/strings.xml
deleted file mode 100644
index a25d69d..0000000
--- a/res/values-zh-rHK/strings.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
- HALO)))
- 按一下開啟應用程式
- 啟動
- 停止
- 加入
- 加入應用程式
- 選擇圖案種類:
- 預設
- 自訂
- 未知
-
- 在移除任何應用程式前,請先停止服務。
-
- 注解 1
- 注解 2
- 注解 3
- 注解 4
- 插件
-
- "使用 HALO)))"
- "使用 HALO))) 很容易,只需要按操作列上的加入按鈕,它有可能在螢幕的上面或下面;"
- "然後選擇你希望加入到 Halo 的應用程式,"
- "最後按啟動開始使用 HALO)))。如果你想停用 HALO))),請按停止。"
-
- ParanoidAndroid 是否已經安裝?
- "HALO))) 特别為 ParanoidAndroid ROMs 而設計,你可能無法體驗 Halo 的完整功能。"
- "確定"
- 安裝 PA
-
-
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
new file mode 100644
index 0000000..029ef5c
--- /dev/null
+++ b/res/values/attrs.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4695edc..b5fe3ad 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -20,7 +20,7 @@
HALO)))
- Tap to launch the Application
+ Tap to launch the application
Start
Stop
Pin
@@ -32,26 +32,23 @@
Please stop the service before removing any application from the list, as not doing so will result in force closes, potentially forcing you to re-flash your ROM.
- Notes
- Note 1
- Note 2
- Note 3
- Note 4
- Extensions
-
- Using HALO)))
- Understanding HALO))) is very simple. Just tap on the Pin button in your Action Bar. Note that the button may be on the top or the bottom of your screen.
- Next, Click the desired application you\'d like to pin on Halo from the list.
- Finally, click on the Start Button and you’re done. If you want to disable HALO))), Click on the \'Stop\' button.
-
- Is ParanoidAndroid installed?
- Halo))) is explicitly designed to work on ParanoidAndroid ROMs. You may not be able to experience the full potential and features, of HALO.
- Okay
- Install ParanoidAndroid
+ Notes
+ Note
+ Empty note
+
+ Your are not running a compatible ROM!
+ HALO))) is explicitly designed to work on ParanoidAndroid ROMs. You will not be able to unleash the full potential of the application!
+ Ok
Helper 1
Helper 2
Helper 3
preferenceiconImageView
-
+
+ OK
+ Pin applications
+ You can keep your applications pinned on HALO, for quicker access
+ Start service
+ You can show or hide your pinned apps by just a tap
+
\ No newline at end of file
diff --git a/res/values/styles.xml b/res/values/styles.xml
new file mode 100644
index 0000000..f57aee4
--- /dev/null
+++ b/res/values/styles.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/xml/extensions.xml b/res/xml/extensions.xml
deleted file mode 100644
index d3e42b3..0000000
--- a/res/xml/extensions.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/com/paranoid/halo/ApplicationsDialog.java b/src/com/paranoid/halo/ApplicationsDialog.java
index 910d4dd..6880e2d 100755
--- a/src/com/paranoid/halo/ApplicationsDialog.java
+++ b/src/com/paranoid/halo/ApplicationsDialog.java
@@ -37,8 +37,8 @@ public class ApplicationsDialog {
public PackageManager mPackageManager;
public List mInstalledApps;
-
- public AppAdapter createAppAdapter(Context context, List installedAppsInfo){
+
+ public AppAdapter createAppAdapter(Context context, List installedAppsInfo) {
mPackageManager = context.getPackageManager();
return new AppAdapter(context, installedAppsInfo);
}
@@ -57,9 +57,9 @@ public int compareTo(AppItem another) {
public class AppAdapter extends BaseAdapter {
protected List mInstalledAppInfo;
protected List mInstalledApps = new LinkedList();
-
+
private Context mContext;
-
+
public AppAdapter(Context context, List installedAppsInfo) {
mInstalledAppInfo = installedAppsInfo;
mContext = context;
@@ -121,7 +121,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
if (convertView != null) {
holder = (ViewHolder) convertView.getTag();
} else {
- final LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ final LayoutInflater layoutInflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.preference_icon, null, false);
holder = new ViewHolder();
convertView.setTag(holder);
diff --git a/src/com/paranoid/halo/BootReceiver.java b/src/com/paranoid/halo/BootReceiver.java
index b3e17aa..389f803 100755
--- a/src/com/paranoid/halo/BootReceiver.java
+++ b/src/com/paranoid/halo/BootReceiver.java
@@ -23,18 +23,23 @@
import android.content.Context;
import android.content.Intent;
+import com.paranoid.halo.utils.Notes;
+import com.paranoid.halo.utils.Utils;
+
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Utils.getStatus(context)) {
String[] packages = Utils.loadArray(context);
- if(packages != null) {
+ if (packages != null) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- for(String packageName : packages){
+ for (String packageName : packages) {
Utils.createNotification(context, notificationManager, packageName);
}
}
}
+
+ Notes.setAllNotes(context);
}
}
\ No newline at end of file
diff --git a/src/com/paranoid/halo/ExtensionsActivity.java b/src/com/paranoid/halo/ExtensionsActivity.java
deleted file mode 100644
index de3d178..0000000
--- a/src/com/paranoid/halo/ExtensionsActivity.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2013 ParanoidAndroid Project
- *
- * This file is part of HALO.
- *
- * HALO is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HALO is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HALO. If not, see .
- */
-package com.paranoid.halo;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceManager;
-import android.support.v4.app.NotificationCompat;
-
-public class ExtensionsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener{
-
- public static final String KEY_EXT_NOTE_1 = "ext_note1";
- public static final String KEY_EXT_NOTE_2 = "ext_note2";
- public static final String KEY_EXT_NOTE_3 = "ext_note3";
- public static final String KEY_EXT_NOTE_4 = "ext_note4";
-
- @SuppressWarnings("deprecation")
- @Override
- public void onCreate(Bundle savedInstanceState){
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.extensions);
-
- Preference pref_note1 = findPreference("ext_note1");
- Preference pref_note2 = findPreference("ext_note2");
- Preference pref_note3 = findPreference("ext_note3");
- Preference pref_note4 = findPreference("ext_note4");
-
- SharedPreferences ext_prefs = PreferenceManager.getDefaultSharedPreferences(this);
-
- String note1 = ext_prefs.getString("ext_note1", null);
- String note2 = ext_prefs.getString("ext_note2", null);
- String note3 = ext_prefs.getString("ext_note3", null);
- String note4 = ext_prefs.getString("ext_note4", null);
-
- pref_note1.setSummary(note1);
- pref_note2.setSummary(note2);
- pref_note3.setSummary(note3);
- pref_note4.setSummary(note4);
-
- }
-
- @SuppressWarnings("deprecation")
- @Override
- protected void onResume(){
- super.onResume();
- getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
- }
-
- public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key){
- Preference pref_note1 = findPreference("ext_note1");
- Preference pref_note2 = findPreference("ext_note2");
- Preference pref_note3 = findPreference("ext_note3");
- Preference pref_note4 = findPreference("ext_note4");
-
- SharedPreferences ext_prefs = PreferenceManager.getDefaultSharedPreferences(this);
-
- String note1 = ext_prefs.getString("ext_note1", null);
- String note2 = ext_prefs.getString("ext_note2", null);
- String note3 = ext_prefs.getString("ext_note3", null);
- String note4 = ext_prefs.getString("ext_note4", null);
-
- NotificationManager ext_notification_manager =
- (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-
- Intent intent = new Intent(this, ExtensionsActivity.class);
- PendingIntent ext_intent = PendingIntent.getActivity(this, 0, intent, 0);
-
- if (key.equals(KEY_EXT_NOTE_1)) {
- NotificationCompat.Builder ext_builder =
- new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_add)
- .setContentIntent(ext_intent)
- .setContentTitle(note1);
-
- Notification notif = ext_builder.build();
- notif.flags |= Notification.FLAG_ONGOING_EVENT;
- notif.priority = Notification.PRIORITY_MIN;
- notif.tickerText = note1;
- ext_notification_manager.notify(1, notif);
-
- pref_note1.setSummary(note1);
- }
-
- if(note1.length() == 0){
- ext_notification_manager.cancel(1);
- pref_note1.setSummary(note1);
- }
-
- if (key.equals(KEY_EXT_NOTE_2)) {
- NotificationCompat.Builder ext_builder =
- new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_add)
- .setContentIntent(ext_intent)
- .setContentTitle(note2);
-
- Notification notif = ext_builder.build();
- notif.flags |= Notification.FLAG_ONGOING_EVENT;
- notif.priority = Notification.PRIORITY_MIN;
- notif.tickerText = note2;
- ext_notification_manager.notify(2, notif);
-
- pref_note2.setSummary(note2);
- }
-
- if(note1.length() == 0){
- ext_notification_manager.cancel(2);
- pref_note2.setSummary(note2);
- }
-
- if (key.equals(KEY_EXT_NOTE_3)) {
- NotificationCompat.Builder ext_builder =
- new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_add)
- .setContentIntent(ext_intent)
- .setContentTitle(note3);
-
- Notification notif = ext_builder.build();
- notif.flags |= Notification.FLAG_ONGOING_EVENT;
- notif.priority = Notification.PRIORITY_MIN;
- notif.tickerText = note3;
- ext_notification_manager.notify(3, notif);
-
- pref_note3.setSummary(note3);
- }
-
- if(note1.length() == 0){
- ext_notification_manager.cancel(3);
- pref_note3.setSummary(note3);
- }
-
- if (key.equals(KEY_EXT_NOTE_4)) {
- NotificationCompat.Builder ext_builder =
- new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_add)
- .setContentIntent(ext_intent)
- .setContentTitle(note4);
-
- Notification notif = ext_builder.build();
- notif.flags |= Notification.FLAG_ONGOING_EVENT;
- notif.priority = Notification.PRIORITY_MIN;
- notif.tickerText = note4;
- ext_notification_manager.notify(4, notif);
-
- pref_note4.setSummary(note4);
- }
-
- if(note1.length() == 0){
- ext_notification_manager.cancel(4);
- pref_note4.setSummary(note4);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/src/com/paranoid/halo/HelperActivity.java b/src/com/paranoid/halo/HelperActivity.java
deleted file mode 100644
index 63992fc..0000000
--- a/src/com/paranoid/halo/HelperActivity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2013 ParanoidAndroid Project
- *
- * This file is part of HALO.
- *
- * HALO is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HALO is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HALO. If not, see .
- */
-package com.paranoid.halo;
-
-import android.os.Bundle;
-import android.app.Activity;
-
-public class HelperActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_helper);
-
- }
-
-}
diff --git a/src/com/paranoid/halo/MainActivity.java b/src/com/paranoid/halo/MainActivity.java
index 5814eef..463e670 100755
--- a/src/com/paranoid/halo/MainActivity.java
+++ b/src/com/paranoid/halo/MainActivity.java
@@ -18,52 +18,59 @@
*/
package com.paranoid.halo;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
import android.app.ActionBar;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.NotificationManager;
import android.content.ActivityNotFoundException;
+import android.content.Context;
import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
-import com.paranoid.halo.ApplicationsDialog.AppAdapter;
-import com.paranoid.halo.ApplicationsDialog.AppItem;
-
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.NotificationManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ResolveInfo;
import android.provider.MediaStore;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
-import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
+import android.widget.Toast;
+
+import com.paranoid.halo.ApplicationsDialog.AppAdapter;
+import com.paranoid.halo.ApplicationsDialog.AppItem;
+import com.paranoid.halo.showcase.ShowcaseUtils;
+import com.paranoid.halo.showcase.ShowcaseView;
+import com.paranoid.halo.utils.Utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
public class MainActivity extends PreferenceActivity {
+ private static final String FIRST_RUN = "app_first_run";
+
private static final int CUSTOM_USER_ICON = 0;
-
+
private static final int MENU_ADD = 0;
private static final int MENU_ACTION = 1;
- private static final int MENU_EXTENSIONS = 2;
-
+ private static final int MENU_NOTES = 2;
+
private NotificationManager mNotificationManager;
private Context mContext;
private boolean mShowing;
@@ -72,20 +79,22 @@ public class MainActivity extends PreferenceActivity {
private AppAdapter mAppAdapter;
private Preference mPreference;
private File mImageTmp;
- private OnPreferenceClickListener mOnItemClickListener = new OnPreferenceClickListener(){
- @Override
- public boolean onPreferenceClick(Preference arg0) {
- if(mShowing){
- Toast.makeText(mContext, R.string.stop_to_remove, Toast.LENGTH_SHORT).show();
- } else {
- mRoot.removePreference(arg0);
- Utils.removeCustomApplicationIcon(arg0.getSummary().toString(), mContext);
- savePreferenceItems(false);
- invalidateOptionsMenu();
- }
- return false;
+ private OnPreferenceClickListener mOnItemClickListener = new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference arg0) {
+ if (mShowing) {
+ Toast.makeText(mContext, R.string.stop_to_remove, Toast.LENGTH_SHORT).show();
+ } else {
+ mRoot.removePreference(arg0);
+ Utils.removeCustomApplicationIcon(arg0.getSummary().toString(), mContext);
+ savePreferenceItems(false);
+ invalidateOptionsMenu();
}
- };
+ return false;
+ }
+ };
+
+ private ShowcaseView mShowcaseView;
@SuppressWarnings("deprecation")
@Override
@@ -116,11 +125,20 @@ protected void onCreate(Bundle savedInstanceState) {
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this));
mRoot = getPreferenceScreen();
loadPreferenceItems();
- helperDialogs();
+ showFirstRunDialog();
+
+ invalidateOptionsMenu();
+ if (ShowcaseUtils.needsShowcase(this, ShowcaseUtils.SHOWCASE_PIN_APPLICATION)) {
+ mShowcaseView = ShowcaseView.insertShowcaseViewWithType(ShowcaseView.ITEM_ACTION_ITEM,
+ MENU_ADD, this, R.string.pin_applications,
+ R.string.pin_applications_summary, null);
+ mShowcaseView.setShowcaseIndicatorScale(0.5f);
+ ShowcaseUtils.setShowcased(this, ShowcaseUtils.SHOWCASE_PIN_APPLICATION);
+ }
}
- @Override
+ @Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem item = menu.getItem(1);
item.setVisible(mRoot.getPreferenceCount() > 0);
@@ -134,13 +152,13 @@ public boolean onPrepareOptionsMenu(Menu menu) {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, MENU_ADD, 0, R.string.add)
- .setIcon(R.drawable.ic_add)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ .setIcon(R.drawable.ic_add)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
menu.add(Menu.NONE, MENU_ACTION, 0, R.string.start)
- .setIcon(R.drawable.ic_start)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
- menu.add(Menu.NONE, MENU_EXTENSIONS, 0, R.string.extensions)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ .setIcon(R.drawable.ic_start)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
+ menu.add(Menu.NONE, MENU_NOTES, 0, R.string.notes)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
return true;
}
@@ -159,12 +177,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView> arg0, View arg1,
- int arg2, long arg3) {
+ int arg2, long arg3) {
final AppItem info = (AppItem) arg0.getItemAtPosition(arg2);
final String packageName = info.packageName;
- for(int i = 0; i items = new ArrayList();
- for(int i = 0; i 0){
- NotificationCompat.Builder ext_builder =
- new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_add)
- .setContentIntent(ext_intent)
- .setContentTitle(note1);
-
- Notification notif = ext_builder.build();
- notif.flags |= Notification.FLAG_ONGOING_EVENT;
- notif.priority = Notification.PRIORITY_MIN;
- notif.tickerText = note1;
- ext_notification_manager.notify(1, notif);
- }
- if(note1.length() == 0){
- ext_notification_manager.cancel(1);
- }
-
- if(note2.length() > 0){
- NotificationCompat.Builder ext_builder =
- new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_add)
- .setContentIntent(ext_intent)
- .setContentTitle(note2);
-
- Notification notif = ext_builder.build();
- notif.flags |= Notification.FLAG_ONGOING_EVENT;
- notif.priority = Notification.PRIORITY_MIN;
- notif.tickerText = note2;
- ext_notification_manager.notify(2, notif);
- }
-
- if(note2.length() == 0){
- ext_notification_manager.cancel(2);
- }
-
- if(note3.length() > 0){
- NotificationCompat.Builder ext_builder =
- new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_add)
- .setContentIntent(ext_intent)
- .setContentTitle(note3);
-
- Notification notif = ext_builder.build();
- notif.flags |= Notification.FLAG_ONGOING_EVENT;
- notif.priority = Notification.PRIORITY_MIN;
- notif.tickerText = note3;
- ext_notification_manager.notify(3, notif);
- }
-
- if(note3.length() == 0){
- ext_notification_manager.cancel(3);
- }
-
- if(note4.length() > 0){
- NotificationCompat.Builder ext_builder =
- new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_add)
- .setContentIntent(ext_intent)
- .setContentTitle(note4);
-
- Notification notif = ext_builder.build();
- notif.flags |= Notification.FLAG_ONGOING_EVENT;
- notif.priority = Notification.PRIORITY_MIN;
- notif.tickerText = note4;
- ext_notification_manager.notify(4, notif);
- }
-
- if(note4.length() == 0){
- ext_notification_manager.cancel(4);
- }
-
- }
- catch(Exception e){
-
- }
+
+ Notes.setAllNotes(this);
}
}
diff --git a/src/com/paranoid/halo/NotesActivity.java b/src/com/paranoid/halo/NotesActivity.java
new file mode 100644
index 0000000..750f5f5
--- /dev/null
+++ b/src/com/paranoid/halo/NotesActivity.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2013 ParanoidAndroid Project
+ *
+ * This file is part of HALO.
+ *
+ * HALO is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HALO is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HALO. If not, see .
+ */
+package com.paranoid.halo;
+
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.os.Bundle;
+import android.preference.EditTextPreference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.support.v4.app.NavUtils;
+import android.view.MenuItem;
+
+import com.paranoid.halo.utils.Notes;
+
+import static com.paranoid.halo.utils.Notes.NOTES;
+
+public class NotesActivity
+ extends PreferenceActivity implements OnSharedPreferenceChangeListener {
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(this);
+ setPreferenceScreen(preferenceScreen);
+
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+
+ for(int i = 0; i spaceBottom
+ ? 128 * metricScale : 24 * metricScale + voidedArea.bottom,
+ canvasW - 48 * metricScale};
+
+ }
+
+ /**
+ * Creates a {@link android.graphics.Rect} which represents the area the showcase covers. Used to calculate
+ * where best to place the text
+ *
+ * @return true if voidedArea has changed, false otherwise.
+ */
+ private boolean makeVoidedRect() {
+
+ // This if statement saves resources by not recalculating voidedArea
+ // if the X & Y coordinates haven't changed
+ if (voidedArea == null || (showcaseX != legacyShowcaseX || showcaseY != legacyShowcaseY)) {
+
+ int cx = (int) showcaseX, cy = (int) showcaseY;
+ int dw = showcase.getIntrinsicWidth();
+ int dh = showcase.getIntrinsicHeight();
+
+ voidedArea = new Rect(cx - dw / 2, cy - dh / 2, cx + dw / 2, cy + dh / 2);
+
+ legacyShowcaseX = showcaseX;
+ legacyShowcaseY = showcaseY;
+
+ return true;
+
+ }
+ return false;
+
+ }
+
+ public void animateGesture(float offsetStartX, float offsetStartY, float offsetEndX, float offsetEndY) {
+ mHandy = ((LayoutInflater) getContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.handy, null);
+ addView(mHandy);
+ moveHand(offsetStartX, offsetStartY, offsetEndX, offsetEndY, new AnimationEndListener() {
+ @Override
+ public void onAnimationEnd() {
+ removeView(mHandy);
+ }
+ });
+ }
+
+ private void moveHand(float offsetStartX, float offsetStartY, float offsetEndX,
+ float offsetEndY, AnimationEndListener listener) {
+ AnimationUtils.createMovementAnimation(mHandy, showcaseX, showcaseY,
+ offsetStartX, offsetStartY,
+ offsetEndX, offsetEndY,
+ listener).start();
+ }
+
+ @Override
+ public void onClick(View view) {
+ hide();
+ }
+
+ public void hide() {
+ if (mEventListener != null) {
+ mEventListener.onShowcaseViewHide(this);
+ }
+ fadeOutShowcase();
+ }
+
+ private void fadeOutShowcase() {
+ AnimationUtils.createFadeOutAnimation(this, new AnimationEndListener() {
+ @Override
+ public void onAnimationEnd() {
+ setVisibility(View.GONE);
+ }
+ }).start();
+ }
+
+ public void show() {
+ if (mEventListener != null) {
+ mEventListener.onShowcaseViewShow(this);
+ }
+ fadeInShowcase();
+ }
+
+ private void fadeInShowcase() {
+ AnimationUtils.createFadeInAnimation(this, new AnimationStartListener() {
+ @Override
+ public void onAnimationStart() {
+ setVisibility(View.VISIBLE);
+ }
+ }).start();
+ }
+
+ @Override
+ public boolean onTouch(View view, MotionEvent motionEvent) {
+
+ float xDelta = Math.abs(motionEvent.getRawX() - showcaseX);
+ float yDelta = Math.abs(motionEvent.getRawY() - showcaseY);
+ double distanceFromFocus = Math.sqrt(Math.pow(xDelta, 2) + Math.pow(yDelta, 2));
+
+ if (mOptions.hideOnClickOutside && distanceFromFocus > showcaseRadius) {
+ this.hide();
+ return true;
+ }
+
+ return mOptions.block && distanceFromFocus > showcaseRadius;
+ }
+
+ public void setShowcaseIndicatorScale(float scaleMultiplier) {
+ this.scaleMultiplier = scaleMultiplier;
+ }
+
+ public interface OnShowcaseEventListener {
+ public void onShowcaseViewHide(ShowcaseView showcaseView);
+
+ public void onShowcaseViewShow(ShowcaseView showcaseView);
+
+ }
+
+ public ShowcaseView setTextColors(int titleTextColor, int detailTextColor) {
+ this.titleTextColor = titleTextColor;
+ this.detailTextColor = detailTextColor;
+ if (mPaintTitle != null) {
+ mPaintTitle.setColor(titleTextColor);
+ }
+ if (mPaintDetail != null) {
+ mPaintDetail.setColor(detailTextColor);
+ }
+ invalidate();
+ return this;
+ }
+
+ public void setText(int titleTextResId, int subTextResId) {
+ String titleText = getContext().getResources().getString(titleTextResId);
+ String subText = getContext().getResources().getString(subTextResId);
+ setText(titleText, subText);
+ }
+
+ public void setText(String titleText, String subText) {
+ mTitleText = titleText;
+ mSubText = subText;
+ mAlteredText = true;
+ invalidate();
+ }
+
+ /**
+ * Get the ghostly gesture hand for custom gestures
+ *
+ * @return a View representing the ghostly hand
+ */
+ public View getHand() {
+ final View mHandy = ((LayoutInflater) getContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.handy, null);
+ addView(mHandy);
+ AnimationUtils.hide(mHandy);
+
+ return mHandy;
+ }
+
+ /**
+ * Point to a specific view
+ *
+ * @param view The {@link android.view.View} to Showcase
+ */
+ public void pointTo(View view) {
+ float x = AnimationUtils.getX(view) + view.getWidth() / 2;
+ float y = AnimationUtils.getY(view) + view.getHeight() / 2;
+ pointTo(x, y);
+ }
+
+ /**
+ * Point to a specific point on the screen
+ *
+ * @param x X-coordinate to point to
+ * @param y Y-coordinate to point to
+ */
+ public void pointTo(float x, float y) {
+ AnimationUtils.createMovementAnimation(mHandy, x, y).start();
+ }
+
+ private void setConfigOptions(ConfigOptions options) {
+ mOptions = options;
+ }
+
+ private ConfigOptions getConfigOptions() {
+ // Make sure that this method never returns null
+ if (mOptions == null) return mOptions = new ConfigOptions();
+ return mOptions;
+ }
+
+ /**
+ * Quick method to insert a ShowcaseView into an Activity
+ *
+ * @param viewToShowcase View to showcase
+ * @param activity Activity to insert into
+ * @param title Text to show as a title. Can be null.
+ * @param detailText More detailed text. Can be null.
+ * @param options A set of options to customise the ShowcaseView
+ * @return the created ShowcaseView instance
+ */
+ public static ShowcaseView insertShowcaseView(View viewToShowcase, Activity activity, String title,
+ String detailText, ConfigOptions options) {
+ ShowcaseView sv = new ShowcaseView(activity);
+ if (options != null) {
+ sv.setConfigOptions(options);
+ }
+ if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
+ ((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
+ } else {
+ ((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
+ }
+ sv.setShowcaseView(viewToShowcase);
+ sv.setText(title, detailText);
+ return sv;
+ }
+
+ /**
+ * Quick method to insert a ShowcaseView into an Activity
+ *
+ * @param viewToShowcase View to showcase
+ * @param activity Activity to insert into
+ * @param title Text to show as a title. Can be null.
+ * @param detailText More detailed text. Can be null.
+ * @param options A set of options to customise the ShowcaseView
+ * @return the created ShowcaseView instance
+ */
+ public static ShowcaseView insertShowcaseView(View viewToShowcase, Activity activity, int title,
+ int detailText, ConfigOptions options) {
+ ShowcaseView sv = new ShowcaseView(activity);
+ if (options != null) {
+ sv.setConfigOptions(options);
+ }
+ if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
+ ((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
+ } else {
+ ((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
+ }
+ sv.setShowcaseView(viewToShowcase);
+ sv.setText(title, detailText);
+ return sv;
+ }
+
+ public static ShowcaseView insertShowcaseView(int showcaseViewId, Activity activity, String title,
+ String detailText, ConfigOptions options) {
+ View v = activity.findViewById(showcaseViewId);
+ if (v != null) {
+ return insertShowcaseView(v, activity, title, detailText, options);
+ }
+ return null;
+ }
+
+ public static ShowcaseView insertShowcaseView(int showcaseViewId, Activity activity, int title,
+ int detailText, ConfigOptions options) {
+ View v = activity.findViewById(showcaseViewId);
+ if (v != null) {
+ return insertShowcaseView(v, activity, title, detailText, options);
+ }
+ return null;
+ }
+
+ public static ShowcaseView insertShowcaseView(float x, float y, Activity activity, String title,
+ String detailText, ConfigOptions options) {
+ ShowcaseView sv = new ShowcaseView(activity);
+ if (options != null) {
+ sv.setConfigOptions(options);
+ }
+ if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
+ ((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
+ } else {
+ ((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
+ }
+ sv.setShowcasePosition(x, y);
+ sv.setText(title, detailText);
+ return sv;
+ }
+
+ public static ShowcaseView insertShowcaseView(float x, float y, Activity activity, int title,
+ int detailText, ConfigOptions options) {
+ ShowcaseView sv = new ShowcaseView(activity);
+ if (options != null) {
+ sv.setConfigOptions(options);
+ }
+ if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
+ ((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
+ } else {
+ ((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
+ }
+ sv.setShowcasePosition(x, y);
+ sv.setText(title, detailText);
+ return sv;
+ }
+
+ public static ShowcaseView insertShowcaseView(View showcase, Activity activity) {
+ return insertShowcaseView(showcase, activity, null, null, null);
+ }
+
+ /**
+ * Quickly insert a ShowcaseView into an Activity, highlighting an item.
+ *
+ * @param type the type of item to showcase (can be ITEM_ACTION_HOME,
+ * ITEM_TITLE_OR_SPINNER, ITEM_ACTION_ITEM or ITEM_ACTION_OVERFLOW)
+ * @param itemId the ID of an Action item to showcase (only required for ITEM_ACTION_ITEM
+ * @param activity Activity to insert the ShowcaseView into
+ * @param title Text to show as a title. Can be null.
+ * @param detailText More detailed text. Can be null.
+ * @param options A set of options to customise the ShowcaseView
+ * @return the created ShowcaseView instance
+ */
+ public static ShowcaseView insertShowcaseViewWithType(int type, int itemId, Activity activity,
+ String title, String detailText, ConfigOptions options) {
+ ShowcaseView sv = new ShowcaseView(activity);
+ if (options != null) {
+ sv.setConfigOptions(options);
+ }
+ if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
+ ((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
+ } else {
+ ((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
+ }
+ sv.setShowcaseItem(type, itemId, activity);
+ sv.setText(title, detailText);
+ return sv;
+ }
+
+ /**
+ * Quickly insert a ShowcaseView into an Activity, highlighting an item.
+ *
+ * @param type the type of item to showcase (can be ITEM_ACTION_HOME,
+ * ITEM_TITLE_OR_SPINNER, ITEM_ACTION_ITEM or ITEM_ACTION_OVERFLOW)
+ * @param itemId the ID of an Action item to showcase (only required for ITEM_ACTION_ITEM)
+ * @param activity Activity to insert the ShowcaseView into
+ * @param title Text to show as a title. Can be null.
+ * @param detailText More detailed text. Can be null.
+ * @param options A set of options to customise the ShowcaseView
+ * @return the created ShowcaseView instance
+ */
+ public static ShowcaseView insertShowcaseViewWithType(int type, int itemId, Activity activity,
+ int title, int detailText, ConfigOptions options) {
+ ShowcaseView sv = new ShowcaseView(activity);
+ if (options != null) {
+ sv.setConfigOptions(options);
+ }
+ if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
+ ((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
+ } else {
+ ((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
+ }
+ sv.setShowcaseItem(type, itemId, activity);
+ sv.setText(title, detailText);
+ return sv;
+ }
+
+ public static ShowcaseView insertShowcaseView(float x, float y, Activity activity) {
+ return insertShowcaseView(x, y, activity, null, null, null);
+ }
+
+ public static class ConfigOptions {
+ public boolean block = true, noButton = false;
+ public int insert = INSERT_TO_DECOR;
+ public boolean hideOnClickOutside = false;
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/paranoid/halo/utils/AnimationUtils.java b/src/com/paranoid/halo/utils/AnimationUtils.java
new file mode 100644
index 0000000..0031c3b
--- /dev/null
+++ b/src/com/paranoid/halo/utils/AnimationUtils.java
@@ -0,0 +1,137 @@
+package com.paranoid.halo.utils;
+
+import android.animation.Animator;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
+import android.os.Handler;
+import android.view.View;
+
+public class AnimationUtils {
+
+ private static final int DEFAULT_DURATION = 300;
+ private static final String ALPHA = "alpha";
+ private static final float INVISIBLE = 0f;
+ private static final float VISIBLE = 1f;
+ private static final String COORD_X = "x";
+ private static final String COORD_Y = "y";
+ private static final int INSTANT = 0;
+
+ public interface AnimationStartListener {
+ void onAnimationStart();
+ }
+
+ public interface AnimationEndListener {
+ void onAnimationEnd();
+ }
+
+ public static float getX(View view) {
+ return view.getX();
+ }
+
+ public static float getY(View view) {
+ return view.getY();
+ }
+
+ public static void hide(View view) {
+ view.setAlpha(INVISIBLE);
+ }
+
+ public static ObjectAnimator createFadeInAnimation(Object target, final AnimationStartListener listener) {
+ return createFadeInAnimation(target, DEFAULT_DURATION, listener);
+ }
+
+ public static ObjectAnimator createFadeInAnimation(Object target, int duration, final AnimationStartListener listener) {
+ ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, VISIBLE);
+ oa.setDuration(duration).addListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animator) {
+ listener.onAnimationStart();
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animator) {
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animator) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animator) {
+ }
+ });
+ return oa;
+ }
+
+ public static ObjectAnimator createFadeOutAnimation(Object target, final AnimationEndListener listener) {
+ return createFadeOutAnimation(target, DEFAULT_DURATION, listener);
+ }
+
+ public static ObjectAnimator createFadeOutAnimation(Object target, int duration, final AnimationEndListener listener) {
+ ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE);
+ oa.setDuration(duration).addListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animator) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animator) {
+ listener.onAnimationEnd();
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animator) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animator) {
+ }
+ });
+ return oa;
+ }
+
+ public static AnimatorSet createMovementAnimation(View view, float canvasX, float canvasY,
+ float offsetStartX, float offsetStartY,
+ float offsetEndX, float offsetEndY,
+ final AnimationEndListener listener) {
+ view.setAlpha(INVISIBLE);
+
+ ObjectAnimator alphaIn = ObjectAnimator.ofFloat(view, ALPHA, INVISIBLE, VISIBLE).setDuration(500);
+
+ ObjectAnimator setUpX = ObjectAnimator.ofFloat(view, COORD_X, canvasX + offsetStartX).setDuration(INSTANT);
+ ObjectAnimator setUpY = ObjectAnimator.ofFloat(view, COORD_Y, canvasY + offsetStartY).setDuration(INSTANT);
+
+ ObjectAnimator moveX = ObjectAnimator.ofFloat(view, COORD_X, canvasX + offsetEndX).setDuration(1000);
+ ObjectAnimator moveY = ObjectAnimator.ofFloat(view, COORD_Y, canvasY + offsetEndY).setDuration(1000);
+ moveX.setStartDelay(1000);
+ moveY.setStartDelay(1000);
+
+ ObjectAnimator alphaOut = ObjectAnimator.ofFloat(view, ALPHA, INVISIBLE).setDuration(500);
+ alphaOut.setStartDelay(2500);
+
+ AnimatorSet as = new AnimatorSet();
+ as.play(setUpX).with(setUpY).before(alphaIn).before(moveX).with(moveY).before(alphaOut);
+
+ Handler handler = new Handler();
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ listener.onAnimationEnd();
+ }
+ };
+ handler.postDelayed(runnable, 3000);
+
+ return as;
+ }
+
+ public static AnimatorSet createMovementAnimation(View view, float x, float y) {
+ ObjectAnimator alphaIn = ObjectAnimator.ofFloat(view, ALPHA, INVISIBLE, VISIBLE).setDuration(500);
+
+ ObjectAnimator setUpX = ObjectAnimator.ofFloat(view, COORD_X, x).setDuration(INSTANT);
+ ObjectAnimator setUpY = ObjectAnimator.ofFloat(view, COORD_Y, y).setDuration(INSTANT);
+
+ AnimatorSet as = new AnimatorSet();
+ as.play(setUpX).with(setUpY).before(alphaIn);
+ return as;
+ }
+}
diff --git a/src/com/paranoid/halo/utils/Notes.java b/src/com/paranoid/halo/utils/Notes.java
new file mode 100644
index 0000000..6b90281
--- /dev/null
+++ b/src/com/paranoid/halo/utils/Notes.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2013 ParanoidAndroid Project
+ *
+ * This file is part of HALO.
+ *
+ * HALO is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HALO is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HALO. If not, see .
+ */
+package com.paranoid.halo.utils;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.support.v4.app.NotificationCompat;
+
+import com.paranoid.halo.NotesActivity;
+import com.paranoid.halo.R;
+
+public class Notes {
+
+ private static final int NOTE_LENGTH = 5; // You can have 100000 notes if you want ;)
+ public static final String[] NOTES = new String[NOTE_LENGTH];
+ private static final int[] NOTE_NOTIF_IDS = new int[NOTES.length];
+
+ static {
+ for(int i = 0; i < 5; i++) {
+ NOTES[i] = "ext_note_" + i;
+ NOTE_NOTIF_IDS[i] = 7325 + i; // this idd is just an identifier for the notification
+ }
+ }
+
+ public static void setAllNotes(Context context) {
+ for(String key : NOTES) {
+ setNoteByKey(context, key);
+ }
+ }
+
+ public static void setNoteByKey(Context context, String key) {
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+ Note[] notes = new Note[NOTES.length];
+ for(int i = 0; i < notes.length; i++) {
+ notes[i] = new Note(NOTES[i],
+ sharedPreferences.getString(NOTES[i], null), NOTE_NOTIF_IDS[i]);
+ }
+
+ NotificationManager notificationManager =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+
+ for(Note note : notes) {
+ if(key.equals(note.getId())) {
+ String content = note.getContent();
+ if(content == null || content.isEmpty()) {
+ notificationManager.cancel(note.getNotificationId());
+ break;
+ }
+ showNoteNotification(context, notificationManager, note.getNotificationId(), content);
+ }
+ }
+ }
+
+ public static void showNoteNotification(
+ Context context, NotificationManager notificationManager, int id, String note) {
+ Intent intent = new Intent(context, NotesActivity.class);
+ PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
+
+ NotificationCompat.Builder ext_builder =
+ new NotificationCompat.Builder(context)
+ .setSmallIcon(R.drawable.ic_add)
+ .setContentIntent(pendingIntent)
+ .setContentTitle(note);
+
+ Notification notif = ext_builder.build();
+ notif.flags |= Notification.FLAG_ONGOING_EVENT;
+ notif.priority = Notification.PRIORITY_MIN;
+ notif.tickerText = note;
+ notificationManager.notify(id, notif);
+ }
+
+ private static class Note {
+ private String id;
+ private String content;
+ private int notificationId;
+
+ private Note(String id, String content, int notificationId) {
+ this.id = id;
+ this.content = content;
+ this.notificationId = notificationId;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public int getNotificationId(){
+ return notificationId;
+ }
+
+ public String getContent() {
+ return content;
+ }
+ }
+}
diff --git a/src/com/paranoid/halo/Utils.java b/src/com/paranoid/halo/utils/Utils.java
old mode 100755
new mode 100644
similarity index 87%
rename from src/com/paranoid/halo/Utils.java
rename to src/com/paranoid/halo/utils/Utils.java
index 76c128c..c5ad09a
--- a/src/com/paranoid/halo/Utils.java
+++ b/src/com/paranoid/halo/utils/Utils.java
@@ -1,228 +1,233 @@
-/*
- * Copyright 2013 ParanoidAndroid Project
- *
- * This file is part of HALO.
- *
- * HALO is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HALO is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HALO. If not, see .
- */
-
-package com.paranoid.halo;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Rect;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Utils {
-
- private static final String ITEMS = "items";
-
- public static int getStringHash(String str){
- int sum = 0;
- for(int i = 0; i packages;
- PackageManager pm = context.getPackageManager();
- packages = pm.getInstalledApplications(0);
- for (ApplicationInfo packageInfo : packages) {
- if(packageInfo.packageName.equals(targetPackage)) return true;
- }
- return false;
- }
-
- public static Bitmap getCustomApplicationIcon(String packageName, Context context) {
- Bitmap result = null;
- SharedPreferences prefs = context.getSharedPreferences("custom_icons", 0);
- String path = prefs.getString(packageName, null);
- result = BitmapFactory.decodeFile(path);
- return result;
- }
-
- public static Bitmap getApplicationIcon(String packageName, Context context){
- Bitmap appIcon = getCustomApplicationIcon(packageName, context);
- if(appIcon == null) {
- try {
- Drawable icon = context.getPackageManager().getApplicationIcon(packageName);
- Bitmap tmp = ((BitmapDrawable)icon).getBitmap();
- int iconSize = context.getResources()
- .getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
- int appIconSize = context.getResources()
- .getDimensionPixelSize(android.R.dimen.app_icon_size);
- Bitmap bmpWithBorder = Bitmap.createBitmap(iconSize, iconSize, tmp.getConfig());
- Canvas canvas = new Canvas(bmpWithBorder);
- canvas.drawColor(Color.TRANSPARENT);
- int margin = (iconSize - appIconSize) / 2;
- canvas.drawBitmap(tmp, null, new Rect(margin, margin,
- appIconSize + margin, appIconSize + margin), null);
- appIcon = bmpWithBorder;
- } catch (NameNotFoundException e) {
- // Ups!
- }
- }
- return appIcon;
- }
-
- public static Drawable getApplicationIconDrawable(String packageName, Context context){
- Bitmap icon = getCustomApplicationIcon(packageName, context);
- Drawable appIcon = new BitmapDrawable(context.getResources(), icon);
- if(icon == null) {
- try {
- appIcon = context.getPackageManager().getApplicationIcon(packageName);
- } catch (NameNotFoundException e) {
- // Ups!
- }
- }
- return appIcon;
- }
-
- public static String getApplicationName(String packageName, Context context){
- PackageManager pm = context.getPackageManager();
- ApplicationInfo ai;
- try {
- ai = pm.getApplicationInfo(packageName, 0);
- } catch (final NameNotFoundException e) {
- ai = null;
- }
- final String applicationName = (String) (ai != null ?
- pm.getApplicationLabel(ai) : context.getString(R.string.unknown));
- return applicationName;
- }
-
- public static void removeCustomApplicationIcon(String packageName, Context context) {
- SharedPreferences prefs = context.getSharedPreferences("custom_icons", 0);
- SharedPreferences.Editor editor = prefs.edit();
- String path = prefs.getString(packageName, null);
- if(path != null) {
- File f = new File(path);
- f.delete();
- }
- editor.remove(packageName);
- editor.commit();
- }
-
- public static boolean setCustomApplicationIcon(String packageName, String path, Context context) {
- SharedPreferences prefs = context.getSharedPreferences("custom_icons", 0);
- SharedPreferences.Editor editor = prefs.edit();
- editor.putString(packageName, path);
- return editor.commit();
- }
-
- public static boolean saveStatus(boolean showing, Context context) {
- SharedPreferences prefs = context.getSharedPreferences("status", 0);
- SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean("status", showing);
- return editor.commit();
- }
-
- public static boolean getStatus(Context context) {
- SharedPreferences prefs = context.getSharedPreferences("status", 0);
- return prefs.getBoolean("status", false);
- }
-
- public static boolean saveArray(String[] array, Context context) {
- SharedPreferences prefs = context.getSharedPreferences("loaded_apps", 0);
- SharedPreferences.Editor editor = prefs.edit();
- editor.clear();
- editor.putInt(ITEMS +"_size", array.length);
- for(int i = 0; i packages = new ArrayList();
- if(size != 0) {
- for(int i = 0; i.
+ */
+
+package com.paranoid.halo.utils;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Rect;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+
+import com.paranoid.halo.R;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Utils {
+
+ private static final String PA_PROPERTY = "ro.pa";
+ private static final String ITEMS = "items";
+
+ public static int getStringHash(String str) {
+ int sum = 0;
+ for (int i = 0; i < str.length(); i++) {
+ sum += str.charAt(i);
+ }
+ return sum;
+ }
+
+ public static boolean packageExists(Context context, String targetPackage) {
+ List packages;
+ PackageManager pm = context.getPackageManager();
+ packages = pm.getInstalledApplications(0);
+ for (ApplicationInfo packageInfo : packages) {
+ if (packageInfo.packageName.equals(targetPackage)) return true;
+ }
+ return false;
+ }
+
+ public static Bitmap getCustomApplicationIcon(String packageName, Context context) {
+ Bitmap result = null;
+ SharedPreferences prefs = context.getSharedPreferences("custom_icons", 0);
+ String path = prefs.getString(packageName, null);
+ result = BitmapFactory.decodeFile(path);
+ return result;
+ }
+
+ public static Bitmap getApplicationIcon(String packageName, Context context) {
+ Bitmap appIcon = getCustomApplicationIcon(packageName, context);
+ if (appIcon == null) {
+ try {
+ Drawable icon = context.getPackageManager().getApplicationIcon(packageName);
+ Bitmap tmp = ((BitmapDrawable) icon).getBitmap();
+ int iconSize = context.getResources()
+ .getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
+ int appIconSize = context.getResources()
+ .getDimensionPixelSize(android.R.dimen.app_icon_size);
+ Bitmap bmpWithBorder = Bitmap.createBitmap(iconSize, iconSize, tmp.getConfig());
+ Canvas canvas = new Canvas(bmpWithBorder);
+ canvas.drawColor(Color.TRANSPARENT);
+ int margin = (iconSize - appIconSize) / 2;
+ canvas.drawBitmap(tmp, null, new Rect(margin, margin,
+ appIconSize + margin, appIconSize + margin), null);
+ appIcon = bmpWithBorder;
+ } catch (NameNotFoundException e) {
+ // Ups!
+ }
+ }
+ return appIcon;
+ }
+
+ public static Drawable getApplicationIconDrawable(String packageName, Context context) {
+ Bitmap icon = getCustomApplicationIcon(packageName, context);
+ Drawable appIcon = new BitmapDrawable(context.getResources(), icon);
+ if (icon == null) {
+ try {
+ appIcon = context.getPackageManager().getApplicationIcon(packageName);
+ } catch (NameNotFoundException e) {
+ // Ups!
+ }
+ }
+ return appIcon;
+ }
+
+ public static String getApplicationName(String packageName, Context context) {
+ PackageManager pm = context.getPackageManager();
+ ApplicationInfo ai;
+ try {
+ ai = pm.getApplicationInfo(packageName, 0);
+ } catch (final NameNotFoundException e) {
+ ai = null;
+ }
+ final String applicationName = (String) (ai != null ?
+ pm.getApplicationLabel(ai) : context.getString(R.string.unknown));
+ return applicationName;
+ }
+
+ public static void removeCustomApplicationIcon(String packageName, Context context) {
+ SharedPreferences prefs = context.getSharedPreferences("custom_icons", 0);
+ SharedPreferences.Editor editor = prefs.edit();
+ String path = prefs.getString(packageName, null);
+ if (path != null) {
+ File f = new File(path);
+ f.delete();
+ }
+ editor.remove(packageName);
+ editor.commit();
+ }
+
+ public static boolean setCustomApplicationIcon(String packageName,
+ String path, Context context) {
+ SharedPreferences prefs = context.getSharedPreferences("custom_icons", 0);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putString(packageName, path);
+ return editor.commit();
+ }
+
+ public static boolean saveStatus(boolean showing, Context context) {
+ SharedPreferences prefs = context.getSharedPreferences("status", 0);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean("status", showing);
+ return editor.commit();
+ }
+
+ public static boolean getStatus(Context context) {
+ SharedPreferences prefs = context.getSharedPreferences("status", 0);
+ return prefs.getBoolean("status", false);
+ }
+
+ public static boolean saveArray(String[] array, Context context) {
+ SharedPreferences prefs = context.getSharedPreferences("loaded_apps", 0);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.clear();
+ editor.putInt(ITEMS + "_size", array.length);
+ for (int i = 0; i < array.length; i++) {
+ editor.putString(ITEMS + "_" + i, array[i]);
+ }
+ return editor.commit();
+ }
+
+ public static String[] loadArray(Context context) {
+ SharedPreferences prefs = context.getSharedPreferences("loaded_apps", 0);
+ int size = prefs.getInt(ITEMS + "_size", 0);
+ ArrayList packages = new ArrayList();
+ if (size != 0) {
+ for (int i = 0; i < size; i++) {
+ String packageName = prefs.getString(ITEMS + "_" + i, null);
+ if (packageExists(context, packageName)) {
+ packages.add(packageName);
+ }
+ }
+ }
+ String[] array = packages.toArray(new String[packages.size()]);
+ return array;
+ }
+
+ public static void createNotification(Context context, NotificationManager notificationManager,
+ String packageName) {
+ try {
+ String appName = Utils.getApplicationName(packageName, context);
+ Notification.Builder mBuilder =
+ new Notification.Builder(context)
+ .setSmallIcon(R.drawable.ic_status)
+ .setAutoCancel(false)
+ .setLargeIcon(Utils.getApplicationIcon(packageName, context))
+ .setContentTitle(appName)
+ .setContentText(context.getString(R.string.tap_to_launch));
+ Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
+ PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
+ intent, 0);
+ mBuilder.setContentIntent(contentIntent);
+ Notification notif = mBuilder.build();
+ notif.flags |= Notification.FLAG_ONGOING_EVENT;
+ notif.priority = Notification.PRIORITY_MIN;
+ notif.tickerText = appName;
+ notificationManager.notify(Utils.getStringHash(packageName), notif);
+ } catch (NullPointerException npe) {
+ // Skip this application
+ }
+ }
+
+ public static String getProp(String prop) {
+ try {
+ Process process = Runtime.getRuntime().exec("getprop " + prop);
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(
+ process.getInputStream()));
+ StringBuilder log = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ log.append(line);
+ }
+ return log.toString();
+ } catch (IOException e) {
+ // Runtime error
+ }
+ return null;
+ }
+
+ public static boolean isParanoidRom() {
+ return getProp(PA_PROPERTY).equals(Boolean.TRUE.toString().toLowerCase());
+ }
+}