├── settings.gradle
├── translation tables
├── slovenian.txt
└── cyrilic.txt
├── app
├── lint.xml
├── src
│ └── main
│ │ ├── assets
│ │ └── xposed_init
│ │ ├── res
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-hdpi
│ │ │ ├── ic_social_share.png
│ │ │ ├── ic_action_pebble.png
│ │ │ ├── notificationicon.png
│ │ │ ├── ic_action_action_settings.png
│ │ │ ├── ic_action_content_select_all.png
│ │ │ └── ic_action_content_select_none.png
│ │ ├── drawable-mdpi
│ │ │ ├── ic_social_share.png
│ │ │ ├── ic_action_pebble.png
│ │ │ ├── notificationicon.png
│ │ │ ├── ic_action_action_settings.png
│ │ │ ├── ic_action_content_select_all.png
│ │ │ └── ic_action_content_select_none.png
│ │ ├── drawable-xhdpi
│ │ │ ├── ic_action_pebble.png
│ │ │ ├── ic_social_share.png
│ │ │ ├── notificationicon.png
│ │ │ ├── ic_action_action_settings.png
│ │ │ ├── ic_action_content_select_all.png
│ │ │ └── ic_action_content_select_none.png
│ │ ├── drawable-xxhdpi
│ │ │ ├── ic_action_pebble.png
│ │ │ ├── ic_social_share.png
│ │ │ ├── notificationicon.png
│ │ │ ├── ic_action_action_settings.png
│ │ │ ├── ic_action_content_select_all.png
│ │ │ └── ic_action_content_select_none.png
│ │ ├── layout
│ │ │ ├── view_regex_list_separator.xml
│ │ │ ├── setting_separator.xml
│ │ │ ├── dialog_text_entry.xml
│ │ │ ├── activity_xposed_settings.xml
│ │ │ ├── item_icon.xml
│ │ │ ├── tasker_app_list_item.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── fragment_regex_list_header.xml
│ │ │ ├── fragment_regex_list_item.xml
│ │ │ ├── dialog_iconpicker.xml
│ │ │ ├── fragment_replacement.xml
│ │ │ ├── activity_per_app_settings.xml
│ │ │ ├── pebble_app_list_item.xml
│ │ │ ├── dialog_add_action_intent.xml
│ │ │ ├── setting_category.xml
│ │ │ ├── fragment_pebble_app_list.xml
│ │ │ ├── fragment_app_list.xml
│ │ │ ├── fragment_app_list_item.xml
│ │ │ ├── setting_spinner.xml
│ │ │ ├── setting_customview.xml
│ │ │ ├── dialog_replacer_file_picker.xml
│ │ │ ├── setting_edittext.xml
│ │ │ ├── fragment_regex_list.xml
│ │ │ ├── setting_checkbox.xml
│ │ │ ├── activity_tasker_action_picker.xml
│ │ │ ├── setting_button.xml
│ │ │ ├── fragment_options.xml
│ │ │ ├── setting_list.xml
│ │ │ ├── activity_tasker_dismiss.xml
│ │ │ ├── setting_color.xml
│ │ │ ├── setting_icon.xml
│ │ │ ├── dialog_vibration_pattern.xml
│ │ │ ├── activity_tasker_notification.xml
│ │ │ ├── setting_tasklist.xml
│ │ │ ├── dialog_replacer_edit.xml
│ │ │ └── setting_intent_list.xml
│ │ ├── values
│ │ │ ├── module_scope.xml
│ │ │ ├── dimens.xml
│ │ │ ├── colors.xml
│ │ │ ├── strings_watchapp_handling.xml
│ │ │ ├── strings_xposed.xml
│ │ │ ├── strings_pebble_app_retrieval.xml
│ │ │ └── styles.xml
│ │ ├── drawable
│ │ │ ├── category_background.xml
│ │ │ ├── black_border.xml
│ │ │ ├── ic_action_content_new.xml
│ │ │ └── list_background.xml
│ │ ├── menu
│ │ │ ├── tasker_setup.xml
│ │ │ ├── replacer.xml
│ │ │ ├── pebbleapps.xml
│ │ │ └── main.xml
│ │ ├── drawable-v21
│ │ │ └── list_background.xml
│ │ ├── xml
│ │ │ └── settings_xposed.xml
│ │ └── raw
│ │ │ └── notices.xml
│ │ └── java
│ │ └── com
│ │ ├── matejdro
│ │ └── pebblenotificationcenter
│ │ │ ├── appsetting
│ │ │ ├── PebbleAppNotificationMode.java
│ │ │ ├── AbsAppSettingStorage.java
│ │ │ └── AppSettingStorage.java
│ │ │ ├── pebble
│ │ │ ├── appretrieval
│ │ │ │ ├── AppRetrievalCallback.java
│ │ │ │ └── Sdk2AppRetrieval.java
│ │ │ └── DeliveryListener.java
│ │ │ ├── ui
│ │ │ ├── perapp
│ │ │ │ └── settingitems
│ │ │ │ │ ├── ActivityResultItem.java
│ │ │ │ │ ├── AppEnabledCheckboxItem.java
│ │ │ │ │ ├── BaseSettingItem.java
│ │ │ │ │ ├── WritingPhrasesItem.java
│ │ │ │ │ ├── CannedResponsesItem.java
│ │ │ │ │ ├── VibrationPatternItem.java
│ │ │ │ │ ├── ResetDefaultsButtonItem.java
│ │ │ │ │ ├── CheckBoxItem.java
│ │ │ │ │ └── TaskerTaskListItem.java
│ │ │ ├── XposedSettingsActivity.java
│ │ │ ├── OptionsFragment.java
│ │ │ ├── ReplacerFilePickerDialog.java
│ │ │ ├── DialogVibrationPatternPicker.java
│ │ │ └── ReplacerEditDialog.java
│ │ │ ├── lists
│ │ │ ├── NotificationListAdapter.java
│ │ │ ├── NotificationHistoryAdapter.java
│ │ │ └── ActiveNotificationsAdapter.java
│ │ │ ├── PebbleConnectedReceiver.java
│ │ │ ├── notifications
│ │ │ ├── actions
│ │ │ │ ├── lists
│ │ │ │ │ ├── ActionList.java
│ │ │ │ │ ├── NotificationActionList.java
│ │ │ │ │ └── WritingPhrasesList.java
│ │ │ │ ├── NotificationAction.java
│ │ │ │ ├── DismissOnPebbleAction.java
│ │ │ │ ├── NotifyAction.java
│ │ │ │ ├── PendingIntentAction.java
│ │ │ │ ├── MuteAppAction.java
│ │ │ │ ├── ReplaceNotificationAction.java
│ │ │ │ ├── MuteAppTemporarilyAction.java
│ │ │ │ └── IntentAction.java
│ │ │ ├── SideChannelNotificationListener.java
│ │ │ ├── AccesibilityNotificationListener.java
│ │ │ ├── JellybeanNotificationListener.java
│ │ │ └── NCUserPrompter.java
│ │ │ ├── CustomNotificationCatcher.java
│ │ │ ├── util
│ │ │ ├── SettingsMemoryStorage.java
│ │ │ └── ConfigBackup.java
│ │ │ ├── tasker
│ │ │ ├── TaskerDismissActivity.java
│ │ │ ├── TaskerAppSettingsActivity.java
│ │ │ ├── TaskerActionPickerActivity.java
│ │ │ ├── TaskerNotificationActivity.java
│ │ │ └── TaskerGlobalSettingsActivity.java
│ │ │ ├── ProcessedNotification.java
│ │ │ ├── NotificationHistoryStorage.java
│ │ │ ├── NotificationKey.java
│ │ │ ├── PebbleNotificationCenter.java
│ │ │ └── location
│ │ │ └── LocationLookup.java
│ │ └── luckycatlabs
│ │ └── sunrisesunset
│ │ ├── Zenith.java
│ │ └── dto
│ │ └── Location.java
└── build.gradle
├── promo
├── icon.png
├── icon.psd
├── Pebble.psd
├── Pebble1.png
├── Pebble2.png
├── Pebble3.png
├── Pebble4.png
├── color_hand.png
├── banner-pebble.png
├── banner-pebble.psd
├── pebbleshot1.png
├── pebbleshot2.png
├── pebbleshot3.png
├── pebbleshot4.png
├── banner-android.png
├── banner-android.psd
├── color_pebbleshot1.png
├── color_pebbleshot2.png
├── round_pebbleshot1.png
├── round_pebbleshot2.png
└── round_pebbleshot3.png
├── .gitmodules
├── .gitignore
└── README.md
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':PebbleAndroidCommons'
--------------------------------------------------------------------------------
/translation tables/slovenian.txt:
--------------------------------------------------------------------------------
1 | U+010C > C
2 | U+010D > c
--------------------------------------------------------------------------------
/app/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/assets/xposed_init:
--------------------------------------------------------------------------------
1 | com.matejdro.pebblenotificationcenter.xposed.NotificationCenterFixer
--------------------------------------------------------------------------------
/promo/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/icon.png
--------------------------------------------------------------------------------
/promo/icon.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/icon.psd
--------------------------------------------------------------------------------
/promo/Pebble.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/Pebble.psd
--------------------------------------------------------------------------------
/promo/Pebble1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/Pebble1.png
--------------------------------------------------------------------------------
/promo/Pebble2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/Pebble2.png
--------------------------------------------------------------------------------
/promo/Pebble3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/Pebble3.png
--------------------------------------------------------------------------------
/promo/Pebble4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/Pebble4.png
--------------------------------------------------------------------------------
/promo/color_hand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/color_hand.png
--------------------------------------------------------------------------------
/promo/banner-pebble.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/banner-pebble.png
--------------------------------------------------------------------------------
/promo/banner-pebble.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/banner-pebble.psd
--------------------------------------------------------------------------------
/promo/pebbleshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/pebbleshot1.png
--------------------------------------------------------------------------------
/promo/pebbleshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/pebbleshot2.png
--------------------------------------------------------------------------------
/promo/pebbleshot3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/pebbleshot3.png
--------------------------------------------------------------------------------
/promo/pebbleshot4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/pebbleshot4.png
--------------------------------------------------------------------------------
/promo/banner-android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/banner-android.png
--------------------------------------------------------------------------------
/promo/banner-android.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/banner-android.psd
--------------------------------------------------------------------------------
/promo/color_pebbleshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/color_pebbleshot1.png
--------------------------------------------------------------------------------
/promo/color_pebbleshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/color_pebbleshot2.png
--------------------------------------------------------------------------------
/promo/round_pebbleshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/round_pebbleshot1.png
--------------------------------------------------------------------------------
/promo/round_pebbleshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/round_pebbleshot2.png
--------------------------------------------------------------------------------
/promo/round_pebbleshot3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/promo/round_pebbleshot3.png
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "PebbleAndroidCommons"]
2 | path = PebbleAndroidCommons
3 | url = https://github.com/matejdro/PebbleAndroidCommons
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_social_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-hdpi/ic_social_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_social_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-mdpi/ic_social_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_pebble.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-hdpi/ic_action_pebble.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/notificationicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-hdpi/notificationicon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_pebble.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-mdpi/ic_action_pebble.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/notificationicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-mdpi/notificationicon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_pebble.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xhdpi/ic_action_pebble.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_social_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xhdpi/ic_social_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/notificationicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xhdpi/notificationicon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_pebble.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_pebble.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_social_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xxhdpi/ic_social_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/notificationicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xxhdpi/notificationicon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_action_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-hdpi/ic_action_action_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_action_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-mdpi/ic_action_action_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_content_select_all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-hdpi/ic_action_content_select_all.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_content_select_all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-mdpi/ic_action_content_select_all.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_action_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xhdpi/ic_action_action_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_action_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_action_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_content_select_none.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-hdpi/ic_action_content_select_none.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_content_select_none.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-mdpi/ic_action_content_select_none.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_content_select_all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xhdpi/ic_action_content_select_all.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_content_select_none.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xhdpi/ic_action_content_select_none.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_content_select_all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_content_select_all.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_content_select_none.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matejdro/PebbleNotificationCenter-Android/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_content_select_none.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_regex_list_separator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/module_scope.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - com.getpebble.android.basalt
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/category_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_separator.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/black_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/tasker_setup.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/list_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | -
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/appsetting/PebbleAppNotificationMode.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.appsetting;
2 |
3 | public interface PebbleAppNotificationMode
4 | {
5 | public static final int OPEN_IN_NOTIFICATION_CENTER = 0;
6 | public static final int SHOW_NATIVE_NOTIFICATION = 1;
7 | public static final int DISABLE_NOTIFICATION = 2;
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/pebble/appretrieval/AppRetrievalCallback.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.pebble.appretrieval;
2 |
3 | import com.matejdro.pebblecommons.pebble.PebbleApp;
4 |
5 | import java.util.Collection;
6 | import java.util.List;
7 |
8 | public interface AppRetrievalCallback
9 | {
10 | void addApps(Collection apps);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_action_content_new.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/pebble/DeliveryListener.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.pebble;
2 |
3 | /**
4 | * Created by Matej on 21.11.2014.
5 | */
6 | public interface DeliveryListener
7 | {
8 | /*
9 | @return Should I keep comm line free for sender of this packet to send something new
10 | */
11 | public boolean packetDelivered();
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/perapp/settingitems/ActivityResultItem.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui.perapp.settingitems;
2 |
3 | import android.content.Intent;
4 |
5 | /**
6 | * Created by Matej on 19.10.2014.
7 | */
8 | public interface ActivityResultItem
9 | {
10 | public void onActivityResult(int requestCode, int resultCode, Intent data);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF9800
4 | #F57C00
5 | #00C853
6 | #000000
7 | #cccccc
8 | #ff0000
9 | #BC0000
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/list_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_watchapp_handling.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Notification Center watchapp update
4 | Click on this notiifcation to open link to the download
5 | Notification Center beta watchapp update
6 | Click to get release info and update link
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_text_entry.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | *.iws
3 | *.ipr
4 | .idea/
5 | .gradle/
6 | local.properties
7 | keystore.properties
8 | out/
9 | build/
10 | gradle*
11 |
12 | bin/
13 | .classpath
14 | .project
15 | .settings*
16 | gen/
17 |
18 | */build/
19 | *.apk
20 |
21 | # OS generated files #
22 | ######################
23 | .DS_Store
24 | .DS_Store?
25 | ._*
26 | .Spotlight-V100
27 | .Trashes
28 | ehthumbs.db
29 | Thumbs.db
30 |
31 | crashlytics.properties
32 | com_crashlytics_export_strings.xml
33 | crashlytics-build.properties
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_xposed_settings.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | PebbleNotificationCenter-Android
2 | ================================
3 |
4 | Android part of the Notification center for Pebble
5 |
6 | Watch counterpart: https://github.com/matejdro/PebbleNotificationCenter-Watchapp
7 | Play store entry: https://play.google.com/store/apps/details?id=com.matejdro.pebblenotificationcenter
8 | Discussion forums: https://plus.google.com/communities/116982109550451242571
9 |
10 | ## Building
11 |
12 | To build this project, just pull the repo and open it in Android Studio. If it starts complaining about missing `PebbleAndroidCommons`, make sure you also pulled the submodules.
--------------------------------------------------------------------------------
/app/src/main/res/layout/tasker_app_list_item.xml:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_regex_list_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_regex_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_iconpicker.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/lists/NotificationListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.lists;
2 |
3 | import com.getpebble.android.kit.PebbleKit;
4 | import com.getpebble.android.kit.util.PebbleDictionary;
5 | import com.matejdro.pebblenotificationcenter.PebbleNotification;
6 | import com.matejdro.pebblenotificationcenter.pebble.modules.ListModule;
7 | import com.matejdro.pebblecommons.util.TextUtil;
8 | import java.text.DateFormat;
9 | import java.util.Date;
10 | import timber.log.Timber;
11 |
12 | public interface NotificationListAdapter {
13 | public PebbleNotification getNotificationAt(int index);
14 | public int getNumOfNotifications();
15 | public void forceRefresh();
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_replacement.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/PebbleConnectedReceiver.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 |
7 | import com.matejdro.pebblenotificationcenter.pebble.modules.SystemModule;
8 |
9 | import timber.log.Timber;
10 |
11 | public class PebbleConnectedReceiver extends BroadcastReceiver
12 | {
13 |
14 | @Override
15 | public void onReceive(Context context, Intent intent)
16 | {
17 | Timber.d("Pebble reconnected");
18 |
19 | Intent serviceIntent = new Intent(context, NCTalkerService.class);
20 | serviceIntent.setAction(SystemModule.INTENT_PEBBLE_CONNECTED);
21 | context.startService(serviceIntent);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/perapp/settingitems/AppEnabledCheckboxItem.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui.perapp.settingitems;
2 |
3 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
4 |
5 | /**
6 | * Created by Matej on 19.10.2014.
7 | */
8 | public class AppEnabledCheckboxItem extends CheckBoxItem
9 | {
10 | public AppEnabledCheckboxItem(AppSettingStorage settingsStorage, int textResource, int descriptionResource)
11 | {
12 | super(settingsStorage, null, textResource, descriptionResource);
13 | }
14 |
15 | @Override
16 | protected void settingChanged(boolean change)
17 | {
18 | settingsStorage.setAppChecked(change);
19 |
20 | }
21 |
22 | @Override
23 | protected boolean getSavedValue()
24 | {
25 | return settingsStorage.isAppChecked();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/lists/ActionList.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions.lists;
2 |
3 | import com.getpebble.android.kit.PebbleKit;
4 | import com.getpebble.android.kit.util.PebbleDictionary;
5 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
6 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
7 | import com.matejdro.pebblecommons.util.TextUtil;
8 |
9 | public abstract class ActionList
10 | {
11 | public abstract int getNumberOfItems();
12 | public abstract String getItem(int id);
13 |
14 | /*
15 | @return true if action executed when item is picked definitely sent something towards Pebble
16 | */
17 | public abstract boolean itemPicked(NCTalkerService service, int id);
18 |
19 |
20 | public boolean isTertiaryTextList()
21 | {
22 | return false;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/replacer.xml:
--------------------------------------------------------------------------------
1 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_per_app_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
13 |
14 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/settings_xposed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
12 |
16 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/pebble_app_list_item.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
15 |
16 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_add_action_intent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
13 |
14 |
19 |
20 |
25 |
26 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/pebbleapps.xml:
--------------------------------------------------------------------------------
1 |
36 |
--------------------------------------------------------------------------------
/translation tables/cyrilic.txt:
--------------------------------------------------------------------------------
1 | Thanks to Morbyd for this table
2 |
3 | U+0401 > Yo
4 | U+0410 > A
5 | U+0411 > B
6 | U+0412 > V
7 | U+0413 > G
8 | U+0414 > D
9 | U+0415 > E
10 | U+0416 > Zh
11 | U+0417 > Z
12 | U+0418 > I
13 | U+0419 > Y
14 | U+041A > K
15 | U+041B > L
16 | U+041C > M
17 | U+041D > N
18 | U+041E > O
19 | U+041F > P
20 | U+0420 > R
21 | U+0421 > S
22 | U+0422 > T
23 | U+0423 > U
24 | U+0424 > F
25 | U+0425 > Kh
26 | U+0426 > Is
27 | U+0427 > Ch
28 | U+0428 > Sh
29 | U+0429 > Sch
30 | U+042A >
31 | U+042B > Y
32 | U+042C >
33 | U+042D > E
34 | U+042E > Yu
35 | U+042F > Ya
36 | U+0430 > a
37 | U+0431 > b
38 | U+0432 > v
39 | U+0433 > g
40 | U+0434 > d
41 | U+0435 > e
42 | U+0436 > zh
43 | U+0437 > z
44 | U+0438 > i
45 | U+0439 > y
46 | U+043A > k
47 | U+043B > l
48 | U+043C > m
49 | U+043D > n
50 | U+043E > o
51 | U+043F > p
52 | U+0440 > r
53 | U+0441 > s
54 | U+0442 > t
55 | U+0443 > u
56 | U+0444 > f
57 | U+0445 > kh
58 | U+0446 > ts
59 | U+0447 > ch
60 | U+0448 > sh
61 | U+0449 > sch
62 | U+044A >
63 | U+044B > y
64 | U+044C >
65 | U+044D > e
66 | U+044E > yu
67 | U+044F > ya
68 | U+0451 > yo
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_category.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
21 |
22 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/perapp/settingitems/BaseSettingItem.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui.perapp.settingitems;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.view.View;
5 |
6 | import com.matejdro.pebblenotificationcenter.appsetting.AppSetting;
7 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
8 | import com.matejdro.pebblenotificationcenter.ui.perapp.PerAppActivity;
9 |
10 | /**
11 | * Created by Matej on 19.10.2014.
12 | */
13 | public abstract class BaseSettingItem
14 | {
15 | protected AppSettingStorage settingsStorage;
16 | private AppSetting associatedSetting;
17 |
18 | protected BaseSettingItem(AppSettingStorage settingsStorage, AppSetting associatedSetting) {
19 | this.settingsStorage = settingsStorage;
20 | this.associatedSetting = associatedSetting;
21 | }
22 |
23 | public @Nullable AppSetting getAssociatedSetting() {
24 | return associatedSetting;
25 | }
26 |
27 | public abstract View getView(PerAppActivity activity);
28 | public abstract boolean onClose();
29 | public abstract void setEnabled(boolean enabled);
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/NotificationAction.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions;
2 |
3 | import android.os.Parcelable;
4 |
5 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
6 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
7 |
8 | /**
9 | * Created by Matej on 22.9.2014.
10 | */
11 | public abstract class NotificationAction implements Parcelable
12 | {
13 | public static final int MAX_NUMBER_OF_ACTIONS = 20;
14 |
15 | public static final int VISIBILITY_OPTION_HIDDEN = 0;
16 | public static final int VISIBILITY_OPTION_BEFORE_APP_OPTIONS = 1;
17 | public static final int VISIBILITY_OPTION_AFTER_APP_OPTIONS = 2;
18 |
19 |
20 | protected String actionText;
21 |
22 | public NotificationAction(String actionText)
23 | {
24 | this.actionText = actionText;
25 | }
26 |
27 | public String getActionText()
28 | {
29 | return actionText;
30 | }
31 |
32 | /*
33 | @return true if action definitely sent something towards Pebble
34 | */
35 | public abstract boolean executeAction(NCTalkerService service, ProcessedNotification notification);
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/appsetting/AbsAppSettingStorage.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.appsetting;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.crashlytics.android.core.CrashlyticsCore;
6 |
7 | public abstract class AbsAppSettingStorage implements AppSettingStorage
8 | {
9 | @SuppressWarnings("unchecked")
10 | @Override
11 | public > T getEnum(AppSetting setting)
12 | {
13 | Enum defEnum = (Enum) setting.getDefault();
14 |
15 | String name = getStringByKey(setting.getKey());
16 |
17 | if (name == null)
18 | return (T) defEnum;
19 |
20 | try
21 | {
22 | return (T) Enum.valueOf(defEnum.getClass(), name);
23 | }
24 | catch (IllegalArgumentException e)
25 | {
26 | CrashlyticsCore.getInstance().logException(e);
27 | return (T) defEnum;
28 | }
29 | }
30 |
31 | @Override
32 | public void setEnum(AppSetting setting, Enum> val)
33 | {
34 | setStringByKey(setting.getKey(), val.name());
35 | }
36 |
37 | public abstract @Nullable String getStringByKey(String key);
38 | public abstract void setStringByKey(String key, String value);
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/appsetting/AppSettingStorage.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.appsetting;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import java.util.Collection;
6 | import java.util.List;
7 |
8 | /**
9 | * Created by Matej on 16.9.2014.
10 | */
11 | public interface AppSettingStorage
12 | {
13 | public String getString(AppSetting setting);
14 | public boolean getBoolean(AppSetting setting);
15 | public int getInt(AppSetting setting);
16 | public List getStringList(AppSetting setting);
17 | public > T getEnum(AppSetting setting);
18 |
19 | public void setString(AppSetting setting, String val);
20 | public void setBoolean(AppSetting setting, boolean val);
21 | public void setInt(AppSetting setting, int val);
22 | public void setStringList(AppSetting setting, Collection val);
23 | public void setEnum(AppSetting setting, Enum> val);
24 |
25 | public void deleteSetting(AppSetting setting);
26 |
27 | /*
28 | Returns true if app is Checked (either excluded or included depending on option)
29 | */
30 | public boolean isAppChecked();
31 | public void setAppChecked(boolean checked);
32 | public boolean canAppSendNotifications();
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_pebble_app_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
11 |
12 |
19 |
20 |
21 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_app_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
14 |
15 |
20 |
21 |
27 |
28 |
29 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_xposed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Module that fixes various annoyances in the Pebble app.
4 | Fix failed error
5 | Fix Failed error that pops up when activating actions on native notifications sent by Notification Center.
6 | Disable developer connection timeout
7 | Prevent Pebble\'s developer connection from automatically turning off after some time, breaking many Notification Center features.
8 | Block notifications from Pebble app
9 | Sometimes Pebble app can still send native notifications despite unchecking all apps. This settings fixes this.\n\nHealth, timeline and call notifications are not affected.
10 | Disable system music app
11 | Disable Pebble\'s default music control app.\n\n This is useful if you are using 3rd party music control app and don\'t want default one jumping to the top of the menu.
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_app_list_item.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
16 |
17 |
27 |
28 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/SideChannelNotificationListener.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications;
2 |
3 | import android.app.Notification;
4 | import android.support.v4.app.NotificationCompatSideChannelService;
5 |
6 | import com.matejdro.pebblenotificationcenter.NotificationKey;
7 | import com.matejdro.pebblenotificationcenter.pebble.modules.DismissUpwardsModule;
8 |
9 | import timber.log.Timber;
10 |
11 | /**
12 | * Created by Matej on 29.9.2014.
13 | */
14 | public class SideChannelNotificationListener extends NotificationCompatSideChannelService
15 | {
16 | @Override
17 | public void notify(String packageName, int id, String tag, Notification notification)
18 | {
19 | Timber.d("Got new side channel notification");
20 | NotificationHandler.newNotification(this, new NotificationKey(packageName, id, tag), notification, true);
21 | }
22 |
23 | @Override
24 | public void cancel(String packageName, int id, String tag)
25 | {
26 | NotificationKey key = new NotificationKey(packageName, id, tag);
27 | Timber.d("Dismiss side channel %s", key);
28 |
29 | DismissUpwardsModule.dismissNotification(this, key);
30 | }
31 |
32 | @Override
33 | public void cancelAll(String packageName)
34 | {
35 | DismissUpwardsModule.dismissWholePackage(this, packageName);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_spinner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
19 |
29 |
30 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/AccesibilityNotificationListener.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications;
2 |
3 | import android.accessibilityservice.AccessibilityService;
4 | import android.app.Notification;
5 | import android.os.Parcelable;
6 | import android.view.accessibility.AccessibilityEvent;
7 | import com.matejdro.pebblenotificationcenter.NotificationKey;
8 | import timber.log.Timber;
9 |
10 | public class AccesibilityNotificationListener extends AccessibilityService {
11 | public static AccesibilityNotificationListener instance;
12 |
13 | @Override
14 | public void onCreate() {
15 | instance = this;
16 | NotificationHandler.active = true;
17 |
18 | super.onCreate();
19 | }
20 |
21 | @Override
22 | public void onDestroy() {
23 | NotificationHandler.active = false;
24 |
25 | super.onDestroy();
26 | }
27 |
28 | @Override
29 | public void onAccessibilityEvent(AccessibilityEvent event) {
30 | Parcelable parcelable = event.getParcelableData();
31 | if (!(parcelable instanceof Notification))
32 | return;
33 |
34 | Notification notification = (Notification) parcelable;
35 |
36 | Timber.d("Got new accessibility notification");
37 | NotificationHandler.newNotification(this, new NotificationKey(event.getPackageName().toString(), null, null), notification, false);
38 | }
39 |
40 | @Override
41 | public void onInterrupt() {
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_customview.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
19 |
29 |
30 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_replacer_file_picker.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
17 |
18 |
19 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
36 |
37 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_edittext.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
19 |
29 |
30 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/XposedSettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.preference.PreferenceFragmentCompat;
8 |
9 | import com.matejdro.pebblenotificationcenter.R;
10 |
11 | public class XposedSettingsActivity extends AppCompatActivity
12 | {
13 | public static final String SHARED_PREFERENCES_NAME = "xposed";
14 |
15 | public static final String SETTING_FIX_FAILED_ERROR = "fixFailed";
16 | public static final String SETTING_FIX_DEVELOPER_CONNECTION = "fixDevConnTimeout";
17 | public static final String SETTING_BLOCK_PEBBLE_NOTIFICATIONS = "blockPebbleNotifications";
18 | public static final String SETTING_DISABLE_MUSIC_JUMP = "disableMusicJump";
19 |
20 | @Override
21 | protected void onCreate(@Nullable Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_xposed_settings);
24 | }
25 |
26 | public static class XposedSettingsFragment extends PreferenceFragmentCompat
27 | {
28 | @Override
29 | public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
30 | getPreferenceManager().setSharedPreferencesName(SHARED_PREFERENCES_NAME);
31 | //noinspection deprecation
32 |
33 | addPreferencesFromResource(R.xml.settings_xposed);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/lists/NotificationActionList.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions.lists;
2 |
3 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
4 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
5 | import com.matejdro.pebblenotificationcenter.notifications.actions.NotificationAction;
6 | import java.util.List;
7 |
8 | /**
9 | * Created by Matej on 2.10.2014.
10 | */
11 | public class NotificationActionList extends ActionList
12 | {
13 | private ProcessedNotification notification;
14 |
15 | public NotificationActionList(ProcessedNotification notification)
16 | {
17 | this.notification = notification;
18 | }
19 |
20 | @Override
21 | public int getNumberOfItems()
22 | {
23 | if (notification.source.getActions() == null)
24 | return 0;
25 |
26 | return notification.source.getActions().size();
27 | }
28 |
29 | @Override
30 | public String getItem(int id)
31 | {
32 | NotificationAction action = notification.source.getActions().get(id);
33 | if (action == null)
34 | return "";
35 |
36 | return action.getActionText();
37 | }
38 |
39 | @Override
40 | public boolean itemPicked(NCTalkerService service, int id)
41 | {
42 | NotificationAction action = notification.source.getActions().get(id);
43 | if (action == null)
44 | return false;
45 |
46 | return action.executeAction(service, notification);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_regex_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
21 |
22 |
29 |
30 |
31 |
36 |
37 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_checkbox.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
19 |
27 |
28 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_pebble_app_retrieval.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Continue
4 | Manual mode
5 | Cancel
6 |
7 | Error while connecting to Pebble\'s developer connection. Do you have it on?
8 | Pebble appears to be disconnected. This action cannot be performed.
9 | Unable to acquire root access. Do you want to switch to manual mode?
10 | Failed to get list of your locker apps. Are you connected to the internet?
11 |
12 | Pebbles running SDK 3 (connected to unrooted phone) do not support retrieving all installed apps at once, but you can add every app manually (you have to re-do this procedure for every app you want to add).\n\nPlease open app on Pebble you want to add and press Continue.
13 | Enter name of the app:
14 | Pebbles running SDK 3 normally do not support retrieving all installed apps at once, but since your phone is rooted, you can use workaround method that also requires internet access. \n\nIf your phone was not correctly detected as rooted or you don\'t have internet connection, you can switch to manual mode. You will also have to use manual mode to add all system apps (for example stock Music app).
15 |
16 | Retrieving current app…
17 | Retrieving apps…
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luckycatlabs/sunrisesunset/Zenith.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2009 Mike Reedell / LuckyCatLabs.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.luckycatlabs.sunrisesunset;
18 |
19 | import java.math.BigDecimal;
20 |
21 | /**
22 | * Defines the solar declination used in computing the sunrise/sunset.
23 | */
24 | public class Zenith {
25 | /**
26 | * Astronomical sunrise/set is when the sun is 18 degrees below the horizon.
27 | */
28 | public static final Zenith ASTRONOMICAL = new Zenith(108);
29 |
30 | /** Nautical sunrise/set is when the sun is 12 degrees below the horizon. */
31 | public static final Zenith NAUTICAL = new Zenith(102);
32 |
33 | /**
34 | * Civil sunrise/set (dawn/dusk) is when the sun is 6 degrees below the
35 | * horizon.
36 | */
37 | public static final Zenith CIVIL = new Zenith(96);
38 |
39 | /** Official sunrise/set is when the sun is 50' below the horizon. */
40 | public static final Zenith OFFICIAL = new Zenith(90.8333);
41 |
42 | private final BigDecimal degrees;
43 |
44 | public Zenith(double degrees) {
45 | this.degrees = BigDecimal.valueOf(degrees);
46 | }
47 |
48 | public BigDecimal degrees() {
49 | return degrees;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tasker_action_picker.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
15 |
16 |
23 |
29 |
30 |
36 |
37 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/notices.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Guava
5 | https://github.com/google/guava
6 | Copyright (C) 2012 The Guava Authors
7 | Apache Software License 2.0
8 |
9 |
10 | Xposed Bridge
11 | https://github.com/rovo89/XposedBridge
12 | Copyright 2013 rovo89, Tungstwenty
13 | Apache Software License 2.0
14 |
15 |
16 | Color Picker view
17 | https://github.com/danielnilsson9/color-picker-view
18 | Copyright (C) 2015 Daniel Nilsson
19 | Apache Software License 2.0
20 |
21 |
22 | Android SVG
23 | http://bigbadaboom.github.io/androidsvg/
24 | Copyright 2013 Paul LeBeau, Cave Rock Software Ltd.
25 | Apache Software License 2.0
26 |
27 |
28 | Java Websocket
29 | https://github.com/TooTallNate/Java-WebSocket
30 | Copyright (c) 2010-2012 Nathan Rajlich
31 | MIT License
32 |
33 |
34 | PNGJ
35 | https://github.com/leonbloy/pngj/
36 | Apache Software License 2.0
37 |
38 |
39 | Needle
40 | https://github.com/ZsoltSafrany/needle
41 | MIT License
42 | Copyright (c) 2014 Zsolt Safrany
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
19 |
29 |
30 |
38 |
39 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/DismissOnPebbleAction.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions;
2 |
3 | import android.content.Context;
4 | import android.os.Parcel;
5 |
6 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
7 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
8 | import com.matejdro.pebblenotificationcenter.R;
9 | import com.matejdro.pebblenotificationcenter.pebble.modules.DismissUpwardsModule;
10 |
11 | /**
12 | * Created by Matej on 22.9.2014.
13 | */
14 | public class DismissOnPebbleAction extends NotificationAction
15 | {
16 | public DismissOnPebbleAction(String text)
17 | {
18 | super(text);
19 | }
20 |
21 | public DismissOnPebbleAction(Context context)
22 | {
23 | super(context.getString(R.string.dismissOnPebble));
24 | }
25 |
26 | @Override
27 | public boolean executeAction(NCTalkerService service, ProcessedNotification notification)
28 | {
29 | DismissUpwardsModule.dismissPebbleID(service, notification.id);
30 | return true;
31 | }
32 |
33 | @Override
34 | public int describeContents()
35 | {
36 | return 0;
37 | }
38 |
39 | @Override
40 | public void writeToParcel(Parcel parcel, int i)
41 | {
42 | parcel.writeValue(actionText);
43 | }
44 |
45 | public static final Creator CREATOR = new Creator()
46 | {
47 | @Override
48 | public DismissOnPebbleAction createFromParcel(Parcel parcel)
49 | {
50 | String text = (String) parcel.readValue(String.class.getClassLoader());
51 |
52 | return new DismissOnPebbleAction(text);
53 | }
54 |
55 | @Override
56 | public DismissOnPebbleAction[] newArray(int i)
57 | {
58 | return new DismissOnPebbleAction[0];
59 | }
60 | };
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/NotifyAction.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions;
2 |
3 | import android.os.Parcel;
4 |
5 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
6 | import com.matejdro.pebblenotificationcenter.PebbleNotification;
7 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
8 | import com.matejdro.pebblenotificationcenter.pebble.modules.NotificationSendingModule;
9 |
10 | /**
11 | * Created by Matej on 22.9.2014.
12 | */
13 | public class NotifyAction extends NotificationAction
14 | {
15 | private PebbleNotification notification;
16 | public NotifyAction(String actionText, PebbleNotification notification)
17 | {
18 | super(actionText);
19 | this.notification = notification;
20 | }
21 |
22 | @Override
23 | public boolean executeAction(NCTalkerService service, ProcessedNotification activeNotification)
24 | {
25 | NotificationSendingModule.notify(this.notification, service);
26 | return true;
27 | }
28 |
29 | @Override
30 | public int describeContents()
31 | {
32 | return 0;
33 | }
34 |
35 | @Override
36 | public void writeToParcel(Parcel parcel, int i)
37 | {
38 | parcel.writeValue(actionText);
39 | parcel.writeValue(notification);
40 | }
41 |
42 | public static final Creator CREATOR = new Creator()
43 | {
44 | @Override
45 | public NotifyAction createFromParcel(Parcel parcel)
46 | {
47 | String text = (String) parcel.readValue(String.class.getClassLoader());
48 | PebbleNotification notification = (PebbleNotification) parcel.readValue(getClass().getClassLoader());
49 |
50 | return new NotifyAction(text, notification);
51 | }
52 |
53 | @Override
54 | public NotifyAction[] newArray(int i)
55 | {
56 | return new NotifyAction[0];
57 | }
58 | };
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/PendingIntentAction.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions;
2 |
3 | import android.app.PendingIntent;
4 | import android.os.Parcel;
5 |
6 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
7 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
8 |
9 | /**
10 | * Created by Matej on 22.9.2014.
11 | */
12 | public class PendingIntentAction extends NotificationAction
13 | {
14 | private PendingIntent actionIntent;
15 | public PendingIntentAction(String actionText, PendingIntent intent)
16 | {
17 | super(actionText);
18 | this.actionIntent = intent;
19 | }
20 |
21 | @Override
22 | public boolean executeAction(NCTalkerService service, ProcessedNotification notification)
23 | {
24 | try
25 | {
26 | actionIntent.send();
27 | } catch (PendingIntent.CanceledException e)
28 | {
29 | e.printStackTrace();
30 | }
31 |
32 | return false;
33 | }
34 |
35 | @Override
36 | public int describeContents()
37 | {
38 | return 0;
39 | }
40 |
41 | @Override
42 | public void writeToParcel(Parcel parcel, int i)
43 | {
44 | parcel.writeValue(actionText);
45 |
46 | parcel.writeValue(actionIntent);
47 | }
48 |
49 | public static final Creator CREATOR = new Creator()
50 | {
51 | @Override
52 | public PendingIntentAction createFromParcel(Parcel parcel)
53 | {
54 | String text = (String) parcel.readValue(String.class.getClassLoader());
55 | PendingIntent intent = (PendingIntent) parcel.readValue(PendingIntent.class.getClassLoader());
56 |
57 | return new PendingIntentAction(text, intent);
58 | }
59 |
60 | @Override
61 | public PendingIntentAction[] newArray(int i)
62 | {
63 | return new PendingIntentAction[0];
64 | }
65 | };
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_options.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
23 |
24 |
31 |
32 |
33 |
34 |
38 |
39 |
45 |
46 |
47 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/CustomNotificationCatcher.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import com.matejdro.pebblenotificationcenter.appsetting.AppSetting;
7 | import com.matejdro.pebblenotificationcenter.appsetting.DefaultAppSettingsStorage;
8 | import com.matejdro.pebblenotificationcenter.pebble.modules.NotificationSendingModule;
9 | import org.json.JSONArray;
10 | import org.json.JSONException;
11 | import org.json.JSONObject;
12 |
13 | public class CustomNotificationCatcher extends BroadcastReceiver {
14 |
15 | @Override
16 | public void onReceive(Context context, Intent intent) {
17 | DefaultAppSettingsStorage storage = PebbleNotificationCenter.getInMemorySettings().getDefaultSettingsStorage();
18 | if (storage.canAppSendNotifications(AppSetting.VIRTUAL_APP_THIRD_PARTY))
19 | {
20 | String notificationData = intent.getStringExtra("notificationData");
21 | if (notificationData == null)
22 | return;
23 | try
24 | {
25 | JSONArray array = new JSONArray(notificationData);
26 | JSONObject data = array.getJSONObject(0);
27 |
28 | String title = data.getString("title");
29 | String text = data.getString("body");
30 | boolean noHistory = false;
31 | if (text.endsWith("NOHISTORY"))
32 | {
33 | text = text.substring(0, text.length() - 9);
34 | noHistory = true;
35 | }
36 |
37 | PebbleNotification notification = new PebbleNotification(title, text, new NotificationKey(AppSetting.VIRTUAL_APP_THIRD_PARTY, null, null));
38 | notification.setNoHistory(noHistory);
39 | if (data.has("subtitle"))
40 | notification.setSubtitle(data.getString("subtitle"));
41 |
42 | NotificationSendingModule.notify(notification, context);
43 | }
44 | catch (JSONException e)
45 | {
46 | return;
47 | }
48 |
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
19 |
28 |
29 |
37 |
43 |
44 |
45 |
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/MuteAppAction.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions;
2 |
3 | import android.content.Context;
4 | import android.os.Parcel;
5 |
6 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
7 | import com.matejdro.pebblenotificationcenter.PebbleNotificationCenter;
8 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
9 | import com.matejdro.pebblenotificationcenter.R;
10 | import com.matejdro.pebblenotificationcenter.pebble.modules.DismissUpwardsModule;
11 |
12 | public class MuteAppAction extends NotificationAction {
13 | public MuteAppAction(Context context) {
14 | super(context.getString(R.string.action_mute_app));
15 | }
16 |
17 | public MuteAppAction(String text) {
18 | super(text);
19 | }
20 |
21 | @Override
22 | public boolean executeAction(NCTalkerService service, ProcessedNotification notification) {
23 | DismissUpwardsModule.dismissPebbleID(service, notification.id);
24 |
25 | String appPackage = notification.source.getKey().getPackage();
26 | if (appPackage == null)
27 | return true;
28 |
29 | boolean includingMode = service.getGlobalSettings().getBoolean(PebbleNotificationCenter.APP_INCLUSION_MODE, false);
30 | notification.source.getSettingStorage(service).setAppChecked(!includingMode);
31 |
32 | return true;
33 | }
34 |
35 |
36 | @Override
37 | public int describeContents()
38 | {
39 | return 0;
40 | }
41 |
42 | @Override
43 | public void writeToParcel(Parcel parcel, int i)
44 | {
45 | parcel.writeValue(actionText);
46 | }
47 |
48 | public static final Creator CREATOR = new Creator()
49 | {
50 | @Override
51 | public MuteAppAction createFromParcel(Parcel parcel)
52 | {
53 | String text = (String) parcel.readValue(String.class.getClassLoader());
54 |
55 | return new MuteAppAction(text);
56 | }
57 |
58 | @Override
59 | public MuteAppAction[] newArray(int i)
60 | {
61 | return new MuteAppAction[0];
62 | }
63 | };
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/ReplaceNotificationAction.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions;
2 |
3 | import android.os.Parcel;
4 |
5 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
6 | import com.matejdro.pebblenotificationcenter.PebbleNotification;
7 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
8 | import com.matejdro.pebblenotificationcenter.pebble.modules.DismissUpwardsModule;
9 | import com.matejdro.pebblenotificationcenter.pebble.modules.NotificationSendingModule;
10 |
11 | /**
12 | * Created by Matej on 22.9.2014.
13 | */
14 | public class ReplaceNotificationAction extends NotificationAction
15 | {
16 | private ProcessedNotification notification;
17 |
18 | public ReplaceNotificationAction(String actionText, ProcessedNotification notification)
19 | {
20 | super(actionText);
21 | this.notification = notification;
22 | }
23 |
24 | @Override
25 | public boolean executeAction(NCTalkerService service, ProcessedNotification activeNotification)
26 | {
27 | DismissUpwardsModule.dismissPebbleID(service, activeNotification.id);
28 | NotificationSendingModule.get(service).sendNotification(this.notification);
29 | return true;
30 | }
31 |
32 | @Override
33 | public int describeContents()
34 | {
35 | return 0;
36 | }
37 |
38 | @Override
39 | public void writeToParcel(Parcel parcel, int i)
40 | {
41 | parcel.writeValue(actionText);
42 | parcel.writeValue(notification);
43 | }
44 |
45 | public static final Creator CREATOR = new Creator()
46 | {
47 | @Override
48 | public ReplaceNotificationAction createFromParcel(Parcel parcel)
49 | {
50 | String text = (String) parcel.readValue(String.class.getClassLoader());
51 | ProcessedNotification notification = (ProcessedNotification) parcel.readValue(getClass().getClassLoader());
52 |
53 | return new ReplaceNotificationAction(text, notification);
54 | }
55 |
56 | @Override
57 | public ReplaceNotificationAction[] newArray(int i)
58 | {
59 | return new ReplaceNotificationAction[0];
60 | }
61 | };
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/OptionsFragment.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui;
2 |
3 | import timber.log.Timber;
4 | import android.support.v4.app.Fragment;
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.preference.PreferenceManager;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.AdapterView;
12 | import android.widget.ArrayAdapter;
13 | import android.widget.Spinner;
14 |
15 | import com.matejdro.pebblenotificationcenter.PebbleNotificationCenter;
16 | import com.matejdro.pebblenotificationcenter.R;
17 |
18 | /**
19 | * Created by jbergler on 25/11/2013.
20 | */
21 | public class OptionsFragment extends Fragment {
22 | private static SharedPreferences preferences;
23 | private static SharedPreferences.Editor editor;
24 |
25 | @Override
26 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
27 |
28 | preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
29 | editor = preferences.edit();
30 |
31 | return inflater.inflate(R.layout.fragment_options, null);
32 | }
33 |
34 | @Override
35 | public void onActivityCreated(Bundle savedInstanceState) {
36 |
37 | Spinner appModeSpinner = (Spinner) getActivity().findViewById(R.id.appModePickerSpinner);
38 | ArrayAdapter appModeAdapter = ArrayAdapter.createFromResource(getActivity(),
39 | R.array.appModePickerModes, android.R.layout.simple_spinner_item);
40 | appModeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
41 | appModeSpinner.setAdapter(appModeAdapter);
42 |
43 | boolean appMode = preferences.getBoolean(PebbleNotificationCenter.APP_INCLUSION_MODE, false);
44 | appModeSpinner.setSelection(appMode ? 1 : 0);
45 |
46 | appModeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
47 | @Override
48 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
49 |
50 | boolean appMode = position == 1;
51 | editor.putBoolean(PebbleNotificationCenter.APP_INCLUSION_MODE, appMode);
52 | editor.apply();
53 | }
54 |
55 | @Override
56 | public void onNothingSelected(AdapterView> parent) {
57 | }
58 | });
59 |
60 | super.onActivityCreated(savedInstanceState);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tasker_dismiss.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
15 |
16 |
22 |
23 |
28 |
29 |
36 |
37 |
42 |
43 |
50 |
51 |
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
20 |
21 |
31 |
32 |
40 |
41 |
51 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luckycatlabs/sunrisesunset/dto/Location.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2009 Mike Reedell / LuckyCatLabs.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.luckycatlabs.sunrisesunset.dto;
18 |
19 | import java.math.BigDecimal;
20 |
21 | /**
22 | * Simple VO class to store latitude/longitude information.
23 | */
24 | public class Location {
25 | private BigDecimal latitude;
26 | private BigDecimal longitude;
27 |
28 | /**
29 | * Creates a new instance of Location with the given
30 | * parameters.
31 | *
32 | * @param latitude
33 | * the latitude, in degrees, of this location. North latitude is
34 | * positive, south negative.
35 | * @param longitude
36 | * the longitude, in degrees of this location. East longitude is
37 | * positive, west negative.
38 | */
39 | public Location(String latitude, String longitude) {
40 | this.latitude = new BigDecimal(latitude);
41 | this.longitude = new BigDecimal(longitude);
42 | }
43 |
44 | /**
45 | * Creates a new instance of Location with the given
46 | * parameters.
47 | *
48 | * @param latitude
49 | * the latitude, in degrees, of this location. North latitude is
50 | * positive, south negative.
51 | * @param longitude
52 | * the longitude, in degrees, of this location. East longitude is
53 | * positive, east negative.
54 | */
55 | public Location(double latitude, double longitude) {
56 | this.latitude = new BigDecimal(latitude);
57 | this.longitude = new BigDecimal(longitude);
58 | }
59 |
60 | /**
61 | * @return the latitude
62 | */
63 | public BigDecimal getLatitude() {
64 | return latitude;
65 | }
66 |
67 | /**
68 | * @return the longitude
69 | */
70 | public BigDecimal getLongitude() {
71 | return longitude;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven { url 'https://maven.fabric.io/public' }
4 | }
5 |
6 | dependencies {
7 | classpath 'io.fabric.tools:gradle:1.+'
8 | }
9 | }
10 | apply plugin: 'com.android.application'
11 | apply plugin: 'io.fabric'
12 |
13 | repositories {
14 | maven { url 'https://maven.fabric.io/public' }
15 | maven { url 'http://dl.bintray.com/danielnilsson9/maven' }
16 | maven { url "https://oss.sonatype.org/content/groups/public/" }
17 | }
18 |
19 |
20 | android {
21 | compileSdkVersion 25
22 | buildToolsVersion '25.0.2'
23 |
24 | defaultConfig {
25 | applicationId "com.matejdro.pebblenotificationcenter"
26 | minSdkVersion 18
27 | targetSdkVersion 25
28 | }
29 |
30 | lintOptions {
31 | disable 'ExpiredTargetSdkVersion'
32 | }
33 |
34 | }
35 | dependencies {
36 | compile 'com.android.support:appcompat-v7:25.2.0'
37 | compile 'com.android.support:preference-v14:25.2.0'
38 | compile 'com.android.support:cardview-v7:25.2.0'
39 | compile "com.android.support:palette-v7:25.2.0"
40 | compile 'com.google.guava:guava:20.0'
41 | provided 'de.robv.android.xposed:api:82'
42 | provided 'de.robv.android.xposed:api:82:sources'
43 | compile project(':PebbleAndroidCommons')
44 | compile('com.crashlytics.sdk.android:crashlytics:2.3.2@aar') {
45 | transitive = true;
46 | }
47 | compile "com.github.danielnilsson9:color-picker-view:1.4.0@aar"
48 |
49 | compile 'com.caverock:androidsvg:1.2.2-beta-1@aar'
50 | compile('de.psdev.licensesdialog:licensesdialog:1.8.0')
51 | compile 'com.zsoltsafrany:needle:1.0.0'
52 | }
53 |
54 | allprojects {
55 | afterEvaluate { project ->
56 | def keystoreProperties = rootProject.file('keystore.properties')
57 | def debugConfig = 'debug'
58 |
59 | if (keystoreProperties.exists() && android.signingConfigs.hasProperty(debugConfig)) {
60 | def props = new Properties()
61 | props.load(new FileInputStream(keystoreProperties))
62 | android.signingConfigs[debugConfig].storeFile = file(props['storeFile'])
63 | android.signingConfigs[debugConfig].storePassword = props['storePassword']
64 | android.signingConfigs[debugConfig].keyAlias = props['keyAlias']
65 | android.signingConfigs[debugConfig].keyPassword = props['keyPassword']
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
20 |
21 |
31 |
32 |
40 |
41 |
51 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_vibration_pattern.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
21 |
22 |
23 |
27 |
28 |
42 |
43 |
49 |
50 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
16 |
17 |
23 |
24 |
28 |
29 |
33 |
34 |
41 |
42 |
50 |
51 |
54 |
55 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/util/SettingsMemoryStorage.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.util;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.preference.PreferenceManager;
6 |
7 | import com.matejdro.pebblecommons.util.PreferencesUtil;
8 | import com.matejdro.pebblenotificationcenter.PebbleNotificationCenter;
9 | import com.matejdro.pebblenotificationcenter.appsetting.DefaultAppSettingsStorage;
10 | import java.util.HashMap;
11 | import java.util.Iterator;
12 |
13 | public class SettingsMemoryStorage {
14 | private Context context;
15 |
16 | private boolean dirty = true;
17 |
18 | private SharedPreferences preferences;
19 | private DefaultAppSettingsStorage appSettingsStorage;
20 | private HashMap replacingStrings;
21 |
22 | public SettingsMemoryStorage(Context context)
23 | {
24 | this.context = context;
25 | this.preferences = PreferenceManager.getDefaultSharedPreferences(context);
26 | this.replacingStrings = new HashMap();
27 | }
28 |
29 | public void markDirty()
30 | {
31 | dirty = true;
32 | }
33 |
34 | private void loadSettings()
35 | {
36 | replacingStrings.clear();
37 |
38 | preferences = PreferenceManager.getDefaultSharedPreferences(context);
39 | appSettingsStorage = new DefaultAppSettingsStorage(preferences, preferences.edit());
40 |
41 | Iterator replacingKeys = PreferencesUtil.getDirectIterator(preferences, PebbleNotificationCenter.REPLACING_KEYS_LIST);
42 | Iterator replacingValues = PreferencesUtil.getDirectIterator(preferences, PebbleNotificationCenter.REPLACING_VALUES_LIST);
43 | while (replacingKeys.hasNext() && replacingValues.hasNext())
44 | {
45 | String keyString = replacingKeys.next();
46 | if (keyString.isEmpty())
47 | continue;
48 |
49 | String valueString = replacingValues.next();
50 |
51 | replacingStrings.put(keyString, valueString);
52 | }
53 |
54 | dirty = false;
55 | }
56 |
57 | public SharedPreferences getSharedPreferences()
58 | {
59 | if (dirty)
60 | loadSettings();
61 |
62 | return preferences;
63 | }
64 |
65 | public DefaultAppSettingsStorage getDefaultSettingsStorage()
66 | {
67 | if (dirty)
68 | loadSettings();
69 |
70 | return appSettingsStorage;
71 | }
72 |
73 |
74 | public HashMap getReplacingStrings()
75 | {
76 | if (dirty)
77 | loadSettings();
78 |
79 | return replacingStrings;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/tasker/TaskerDismissActivity.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.tasker;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.widget.CheckBox;
7 | import android.widget.EditText;
8 | import com.matejdro.pebblenotificationcenter.R;
9 | import net.dinglisch.android.tasker.TaskerPlugin;
10 |
11 | public class TaskerDismissActivity extends Activity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 |
17 | setContentView(R.layout.activity_tasker_dismiss);
18 |
19 | loadIntent();
20 | }
21 |
22 | protected void loadIntent() {
23 | Intent intent = getIntent();
24 |
25 | if (intent == null)
26 | return;
27 |
28 | Bundle bundle = intent.getBundleExtra("com.twofortyfouram.locale.intent.extra.BUNDLE");
29 | if (bundle == null)
30 | return;
31 |
32 | int action = bundle.getInt("action");
33 | if (action != 3)
34 | return;
35 |
36 | ((EditText) findViewById(R.id.packageText)).setText(bundle.getString("package"));
37 | ((EditText) findViewById(R.id.idText)).setText(bundle.getString("id"));
38 | ((EditText) findViewById(R.id.tagText)).setText(bundle.getString("tag"));
39 | }
40 |
41 | @Override
42 | public void onBackPressed()
43 | {
44 | Intent intent = new Intent();
45 |
46 | Bundle bundle = new Bundle();
47 |
48 | bundle.putInt("action", 3);
49 |
50 | String pkg = ((EditText) findViewById(R.id.packageText)).getText().toString();
51 | String id = ((EditText) findViewById(R.id.idText)).getText().toString();
52 | String tag = ((EditText) findViewById(R.id.tagText)).getText().toString();
53 |
54 | String description = getString(R.string.taskerDescriptionDismiss, pkg);
55 |
56 | bundle.putString("package", pkg);
57 | bundle.putString("id", id);
58 | bundle.putString("tag", tag);
59 |
60 | TaskerPlugin.Setting.setVariableReplaceKeys(bundle, new String[] { "package", "id", "tag" });
61 |
62 | intent.putExtra("com.twofortyfouram.locale.intent.extra.BLURB", description);
63 | intent.putExtra("com.twofortyfouram.locale.intent.extra.BUNDLE", bundle);
64 |
65 | setResult(RESULT_OK, intent);
66 |
67 | super.onBackPressed();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_tasker_notification.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
16 |
21 |
22 |
29 |
30 |
35 |
36 |
43 |
44 |
49 |
50 |
57 |
58 |
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ProcessedNotification.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | public class ProcessedNotification implements Parcelable
10 | {
11 | public int id;
12 | public int prevId = 0;
13 | public List textChunks = new ArrayList<>(13);
14 | public short firstSubtitleIndex = Short.MAX_VALUE;
15 | public short firstTextIndex = Short.MAX_VALUE;
16 | public short textLength;
17 |
18 | public boolean needsIconSending = false;
19 | public byte[] iconData;
20 | public byte[] backgroundImageData;
21 |
22 | public boolean vibrated = false;
23 | public int nextChunkToSend = -1;
24 | public boolean nativeNotification;
25 |
26 | public PebbleNotification source;
27 | public boolean wasSentToWatch = false;
28 | public boolean waitingForConfirmation = false;
29 |
30 | @Override
31 | public int describeContents()
32 | {
33 | return 0;
34 | }
35 |
36 | @Override
37 | public void writeToParcel(Parcel parcel, int i)
38 | {
39 | parcel.writeInt(id);
40 | parcel.writeInt(prevId);
41 | parcel.writeValue(textChunks);
42 | parcel.writeByte((byte) (vibrated ? 1 : 0));
43 | parcel.writeInt(nextChunkToSend);
44 | parcel.writeByte((byte) (nativeNotification ? 1 : 0));
45 | parcel.writeValue(source);
46 | }
47 |
48 | public static final Creator CREATOR = new Creator()
49 | {
50 | @Override
51 | public ProcessedNotification createFromParcel(Parcel parcel)
52 | {
53 | ProcessedNotification notification = new ProcessedNotification();
54 | notification.id = parcel.readInt();
55 | notification.prevId = parcel.readInt();
56 | notification.textChunks = (List) parcel.readValue(getClass().getClassLoader());
57 | notification.vibrated = parcel.readByte() == 1;
58 | notification.nextChunkToSend = parcel.readInt();
59 | notification.nativeNotification = parcel.readByte() == 1;
60 | notification.source = (PebbleNotification) parcel.readValue(getClass().getClassLoader());
61 |
62 | return notification;
63 | }
64 |
65 | @Override
66 | public ProcessedNotification[] newArray(int i)
67 | {
68 | return new ProcessedNotification[0];
69 | }
70 | };
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_tasklist.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
19 |
28 |
29 |
37 |
38 |
48 |
49 |
55 |
56 |
57 |
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/MuteAppTemporarilyAction.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions;
2 |
3 | import android.content.Context;
4 | import android.os.Parcel;
5 |
6 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
7 | import com.matejdro.pebblenotificationcenter.PebbleNotificationCenter;
8 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
9 | import com.matejdro.pebblenotificationcenter.R;
10 | import com.matejdro.pebblenotificationcenter.pebble.modules.DismissUpwardsModule;
11 | import com.matejdro.pebblenotificationcenter.pebble.modules.NotificationSendingModule;
12 |
13 | public class MuteAppTemporarilyAction extends NotificationAction {
14 | private int muteDurationMinutes;
15 |
16 | public MuteAppTemporarilyAction(Context context, int muteDurationMinutes) {
17 | this(context.getString(R.string.action_mute_app_temporarily_minutes, muteDurationMinutes), muteDurationMinutes);
18 | }
19 |
20 | public MuteAppTemporarilyAction(String text, int muteDurationMinutes) {
21 | super(text);
22 |
23 | this.muteDurationMinutes = muteDurationMinutes;
24 | }
25 |
26 | @Override
27 | public boolean executeAction(NCTalkerService service, ProcessedNotification notification) {
28 | DismissUpwardsModule.dismissPebbleID(service, notification.id);
29 |
30 | String appPackage = notification.source.getKey().getPackage();
31 | if (appPackage == null)
32 | return true;
33 |
34 | NotificationSendingModule.muteApp(service, appPackage, System.currentTimeMillis() + muteDurationMinutes * 60 * 1000);
35 | return true;
36 | }
37 |
38 |
39 | @Override
40 | public int describeContents()
41 | {
42 | return 0;
43 | }
44 |
45 | @Override
46 | public void writeToParcel(Parcel parcel, int i)
47 | {
48 | parcel.writeValue(actionText);
49 | parcel.writeInt(muteDurationMinutes);
50 | }
51 |
52 | public static final Creator CREATOR = new Creator()
53 | {
54 | @Override
55 | public MuteAppTemporarilyAction createFromParcel(Parcel parcel)
56 | {
57 | String text = (String) parcel.readValue(String.class.getClassLoader());
58 | int muteDuration = parcel.readInt();
59 |
60 | return new MuteAppTemporarilyAction(text, muteDuration);
61 | }
62 |
63 | @Override
64 | public MuteAppTemporarilyAction[] newArray(int i)
65 | {
66 | return new MuteAppTemporarilyAction[0];
67 | }
68 | };
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/tasker/TaskerAppSettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.tasker;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import com.matejdro.pebblenotificationcenter.R;
6 | import com.matejdro.pebblenotificationcenter.appsetting.AbsAppSettingStorage;
7 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
8 | import com.matejdro.pebblenotificationcenter.ui.perapp.PerAppActivity;
9 |
10 | /**
11 | * Created by Matej on 18.9.2014.
12 | */
13 | public class TaskerAppSettingsActivity extends PerAppActivity
14 | {
15 | private Bundle storage;
16 |
17 | @Override
18 | public AbsAppSettingStorage initAppSettingStorage()
19 | {
20 | storage = new Bundle();
21 | loadIntent();
22 |
23 | AbsAppSettingStorage original = super.initAppSettingStorage();
24 | return new BundleAppSettingsStorage(original, storage);
25 | }
26 |
27 | protected void loadIntent() {
28 | Intent intent = getIntent();
29 |
30 | if (intent == null)
31 | return;
32 |
33 | Bundle bundle = intent.getBundleExtra("com.twofortyfouram.locale.intent.extra.BUNDLE");
34 | if (bundle == null)
35 | return;
36 |
37 | int action = bundle.getInt("action");
38 | if (action != 2)
39 | return;
40 |
41 | storage.putAll(bundle);
42 | for (String key : bundle.keySet())
43 | {
44 | if (!key.startsWith("setting_") && !key.startsWith("special_"))
45 | {
46 | storage.remove(key);
47 | }
48 | }
49 | }
50 |
51 | @Override
52 | protected void loadAppSettings()
53 | {
54 | super.loadAppSettings();
55 |
56 | if (!defaultSettings)
57 | settings.get(0).settings.remove(1); //Remove reset to default button - does not work in tasker
58 | }
59 |
60 | @Override
61 | public boolean save()
62 | {
63 | if (!super.save())
64 | return false;
65 |
66 | Intent intent = new Intent();
67 |
68 | Bundle bundle = new Bundle();
69 |
70 | bundle.putInt("action", 2);
71 | String description = getString(R.string.taskerDescriptionPerAppSetting, appName);
72 |
73 | bundle.putAll(storage);
74 | bundle.putString("appName", appName);
75 | bundle.putString("appPackage", appPackage);
76 |
77 | intent.putExtra("com.twofortyfouram.locale.intent.extra.BLURB", description);
78 | intent.putExtra("com.twofortyfouram.locale.intent.extra.BUNDLE", bundle);
79 |
80 | setResult(RESULT_OK, intent);
81 |
82 | return true;
83 | }
84 |
85 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/perapp/settingitems/WritingPhrasesItem.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui.perapp.settingitems;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.DialogInterface;
5 | import android.widget.EditText;
6 | import com.matejdro.pebblenotificationcenter.R;
7 | import com.matejdro.pebblenotificationcenter.appsetting.AppSetting;
8 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
9 |
10 | /**
11 | * Created by Matej on 19.10.2014.
12 | */
13 | public class WritingPhrasesItem extends ListItem
14 | {
15 | public WritingPhrasesItem(AppSettingStorage settingsStorage, AppSetting associatedSetting, int textResource, int descriptionResource)
16 | {
17 | super(settingsStorage, associatedSetting, textResource, descriptionResource);
18 | }
19 |
20 | @Override
21 | protected void openAddDialog(String text)
22 | {
23 | AlertDialog.Builder builder = new AlertDialog.Builder(activity);
24 |
25 | final EditText editField = new EditText(activity);
26 | editField.setText(text);
27 |
28 | builder.setTitle(R.string.addWritingPhrase);
29 | builder.setView(editField);
30 |
31 | builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
32 | {
33 | @Override
34 | public void onClick(DialogInterface dialog, int which)
35 | {
36 | add(editField.getText().toString());
37 | }
38 | });
39 | builder.setNegativeButton(R.string.cancel, null);
40 | builder.show();
41 | }
42 |
43 | @Override
44 | protected void openEditDialog(final int id, String text)
45 | {
46 | AlertDialog.Builder builder = new AlertDialog.Builder(activity);
47 |
48 | final EditText editField = new EditText(activity);
49 | editField.setText(text);
50 |
51 | builder.setTitle(R.string.editWritingPhrase);
52 | builder.setView(editField);
53 |
54 | builder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener()
55 | {
56 | @Override
57 | public void onClick(DialogInterface dialog, int which)
58 | {
59 | update(id, editField.getText().toString());
60 | }
61 | });
62 |
63 | builder.setNeutralButton(R.string.delete, new DialogInterface.OnClickListener()
64 | {
65 | @Override
66 | public void onClick(DialogInterface dialog, int which)
67 | {
68 | remove(id);
69 | }
70 | });
71 |
72 | builder.setNegativeButton(R.string.cancel, null);
73 | builder.show();
74 |
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/perapp/settingitems/CannedResponsesItem.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui.perapp.settingitems;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.DialogInterface;
5 | import android.widget.EditText;
6 | import com.matejdro.pebblenotificationcenter.R;
7 | import com.matejdro.pebblenotificationcenter.appsetting.AppSetting;
8 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
9 |
10 | /**
11 | * Created by Matej on 19.10.2014.
12 | */
13 | public class CannedResponsesItem extends ListItem
14 | {
15 | public CannedResponsesItem(AppSettingStorage settingsStorage, AppSetting associatedSetting, int textResource, int descriptionResource)
16 | {
17 | super(settingsStorage, associatedSetting, textResource, descriptionResource);
18 | }
19 |
20 | @Override
21 | protected void openAddDialog(String text)
22 | {
23 | AlertDialog.Builder builder = new AlertDialog.Builder(activity);
24 |
25 | final EditText editField = new EditText(activity);
26 | editField.setText(text);
27 |
28 | builder.setTitle(R.string.addCannedResponse);
29 | builder.setView(editField);
30 |
31 | builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
32 | {
33 | @Override
34 | public void onClick(DialogInterface dialog, int which)
35 | {
36 | add(editField.getText().toString());
37 | }
38 | });
39 | builder.setNegativeButton(R.string.cancel, null);
40 | builder.show();
41 | }
42 |
43 | @Override
44 | protected void openEditDialog(final int id, String text)
45 | {
46 | AlertDialog.Builder builder = new AlertDialog.Builder(activity);
47 |
48 | final EditText editField = new EditText(activity);
49 | editField.setText(text);
50 |
51 | builder.setTitle(R.string.editCannedResponse);
52 | builder.setView(editField);
53 |
54 | builder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener()
55 | {
56 | @Override
57 | public void onClick(DialogInterface dialog, int which)
58 | {
59 | update(id, editField.getText().toString());
60 | }
61 | });
62 |
63 | builder.setNeutralButton(R.string.delete, new DialogInterface.OnClickListener()
64 | {
65 | @Override
66 | public void onClick(DialogInterface dialog, int which)
67 | {
68 | remove(id);
69 | }
70 | });
71 |
72 | builder.setNegativeButton(R.string.cancel, null);
73 | builder.show();
74 |
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/tasker/TaskerActionPickerActivity.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.tasker;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import com.matejdro.pebblenotificationcenter.R;
8 |
9 | /**
10 | * Created by Matej on 18.9.2014.
11 | */
12 | public class TaskerActionPickerActivity extends Activity
13 | {
14 | private static final Class[] actions = new Class[] {TaskerNotificationActivity.class, TaskerGlobalSettingsActivity.class, TaskerAppListActivity.class, TaskerDismissActivity.class};
15 | private static final int TASKER_ACTION_REQUEST = 1;
16 |
17 | @Override
18 | public void onCreate(Bundle savedInstanceState)
19 | {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_tasker_action_picker);
22 |
23 | loadIntent();
24 | }
25 |
26 | public void loadIntent()
27 | {
28 | Intent intent = getIntent();
29 |
30 | if (intent == null)
31 | return;
32 |
33 | Bundle bundle = intent.getBundleExtra("com.twofortyfouram.locale.intent.extra.BUNDLE");
34 | if (bundle == null)
35 | return;
36 |
37 | int action = bundle.getInt("action");
38 | if (action < 0 || action >= actions.length)
39 | return;
40 |
41 | loadNextScreen(actions[action], bundle);
42 | }
43 |
44 | public void notification(View view)
45 | {
46 | loadNextScreen(TaskerNotificationActivity.class, null);
47 | }
48 |
49 | public void globalSetting(View view)
50 | {
51 | loadNextScreen(TaskerGlobalSettingsActivity.class, null);
52 | }
53 |
54 | public void appSetting(View view)
55 | {
56 | loadNextScreen(TaskerAppListActivity.class, null);
57 | }
58 |
59 | public void dismiss(View view)
60 | {
61 | loadNextScreen(TaskerDismissActivity.class, null);
62 | }
63 |
64 | private void loadNextScreen(Class cls, Bundle existingData)
65 | {
66 | Intent intent = new Intent(this, cls);
67 | if (existingData != null)
68 | intent.putExtra("com.twofortyfouram.locale.intent.extra.BUNDLE", existingData);
69 | startActivityForResult(intent, TASKER_ACTION_REQUEST);
70 | }
71 |
72 | @Override
73 | protected void onActivityResult(int requestCode, int resultCode, Intent data)
74 | {
75 | if (resultCode == RESULT_OK)
76 | {
77 | setResult(RESULT_OK, data);
78 | finish();
79 | }
80 | }
81 |
82 | @Override
83 | public void onBackPressed()
84 | {
85 | setResult(RESULT_CANCELED);
86 | super.onBackPressed();
87 | }
88 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/lists/NotificationHistoryAdapter.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.lists;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import com.matejdro.pebblenotificationcenter.NotificationHistoryStorage;
6 | import com.matejdro.pebblenotificationcenter.NotificationKey;
7 | import com.matejdro.pebblenotificationcenter.PebbleNotification;
8 | import com.matejdro.pebblenotificationcenter.pebble.modules.ListModule;
9 | import com.matejdro.pebblenotificationcenter.pebble.modules.NotificationSendingModule;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import android.database.Cursor;
14 | import android.graphics.Bitmap;
15 | import android.graphics.BitmapFactory;
16 |
17 | public class NotificationHistoryAdapter implements NotificationListAdapter {
18 | private List notifications;
19 | private NotificationHistoryStorage storage;
20 | private Context context;
21 |
22 | public NotificationHistoryAdapter(Context context, NotificationHistoryStorage storage) {
23 | this.storage = storage;
24 | this.context = context;
25 |
26 | loadNotifications(context);
27 | }
28 |
29 | public void loadNotifications(Context context)
30 | {
31 | Cursor cursor = storage.getReadableDatabase().rawQuery("SELECT PostTime, Title, Subtitle, Text, Icon FROM notifications ORDER BY PostTime DESC LIMIT 150", null);
32 | notifications = new ArrayList(cursor.getCount());
33 |
34 | while (cursor.moveToNext())
35 | {
36 | long sendingDate = cursor.getLong(0);
37 | String title = cursor.getString(1);
38 | String text = cursor.getString(3) + "\n\nSent on " + ListModule.getFormattedDate(context, sendingDate);
39 | NotificationKey key = new NotificationKey(null, null, null);
40 | byte[] iconData = cursor.getBlob(4);
41 | Bitmap icon = null;
42 | if (iconData != null)
43 | icon = BitmapFactory.decodeByteArray(iconData, 0, iconData.length);
44 |
45 | PebbleNotification notification = new PebbleNotification(title, text, key);
46 | notification.setSubtitle(cursor.getString(2));
47 | notification.setPostTime(sendingDate);
48 | notification.setListNotification(true);
49 | notification.setDismissable(true);
50 | notification.setNotificationIcon(icon);
51 |
52 | notifications.add(notification);
53 | }
54 |
55 | cursor.close();
56 | }
57 |
58 | @Override
59 | public PebbleNotification getNotificationAt(int index) {
60 | return notifications.get(index);
61 | }
62 |
63 | @Override
64 | public int getNumOfNotifications() {
65 | return notifications.size();
66 | }
67 |
68 | @Override
69 | public void forceRefresh() {
70 | loadNotifications(context);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_replacer_edit.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
17 |
18 |
26 |
27 |
28 |
31 |
32 |
38 |
39 |
47 |
48 |
49 |
50 |
54 |
55 |
60 |
61 |
66 |
67 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_intent_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
19 |
20 |
31 |
32 |
40 |
41 |
51 |
52 |
58 |
59 |
60 |
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/lists/ActiveNotificationsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.lists;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Notification;
5 | import android.content.Context;
6 | import android.os.Build;
7 | import android.service.notification.StatusBarNotification;
8 |
9 | import com.matejdro.pebblenotificationcenter.PebbleNotification;
10 | import com.matejdro.pebblenotificationcenter.notifications.JellybeanNotificationListener;
11 | import com.matejdro.pebblenotificationcenter.notifications.NotificationHandler;
12 |
13 | import java.util.ArrayList;
14 | import java.util.Collections;
15 | import java.util.Comparator;
16 | import java.util.List;
17 |
18 | @TargetApi(value = Build.VERSION_CODES.JELLY_BEAN_MR2)
19 | public class ActiveNotificationsAdapter implements NotificationListAdapter {
20 | private List pebbleNotifications;
21 | private Context context;
22 |
23 | public ActiveNotificationsAdapter(Context context) {
24 | this.context = context;
25 |
26 | loadNotifications(context);
27 | }
28 |
29 | private void loadNotifications(Context context)
30 | {
31 | pebbleNotifications = new ArrayList<>();
32 |
33 | StatusBarNotification[] sbns = JellybeanNotificationListener.getCurrentNotifications();
34 | if (sbns == null)
35 | return;
36 |
37 | for (StatusBarNotification sbn : sbns)
38 | {
39 | Notification notification = sbn.getNotification();
40 |
41 | PebbleNotification pn = NotificationHandler.getPebbleNotificationFromAndroidNotification(context, NotificationHandler.getKeyFromSbn(sbn), notification, sbn.isClearable());
42 | if (pn == null)
43 | continue;
44 |
45 | pn.setListNotification(true);
46 | pn.setPostTime(sbn.getPostTime());
47 |
48 | pebbleNotifications.add(pn);
49 | }
50 |
51 | Collections.sort(pebbleNotifications, new NotificationComparable());
52 | }
53 |
54 |
55 | @Override
56 | public PebbleNotification getNotificationAt(int index) {
57 | return pebbleNotifications.get(index);
58 | }
59 |
60 | @Override
61 | public int getNumOfNotifications() {
62 | return pebbleNotifications.size();
63 | }
64 |
65 | @Override
66 | public void forceRefresh() {
67 | loadNotifications(context);
68 | }
69 |
70 | private static class NotificationComparable implements Comparator
71 | {
72 |
73 | @Override
74 | public int compare(PebbleNotification lhs, PebbleNotification rhs) {
75 | //First sort by normal/onging, then by date.
76 |
77 | if (lhs.isDismissable() != rhs.isDismissable())
78 | {
79 | if (lhs.isDismissable())
80 | return -1;
81 | else
82 | return 11;
83 | }
84 |
85 | return (int) (rhs.getPostTime() - lhs.getPostTime());
86 | }
87 |
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/ReplacerFilePickerDialog.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui;
2 |
3 |
4 | import java.io.File;
5 |
6 | import android.app.Dialog;
7 | import android.content.Context;
8 | import android.os.Bundle;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.AdapterView;
13 | import android.widget.AdapterView.OnItemClickListener;
14 | import android.widget.ArrayAdapter;
15 | import android.widget.Button;
16 | import android.widget.ListView;
17 | import android.widget.TextView;
18 |
19 | import com.matejdro.pebblenotificationcenter.R;
20 |
21 | public class ReplacerFilePickerDialog extends Dialog {
22 | private FilePickerDialogResult listener;
23 | private File[] fileList;
24 |
25 | private ArrayAdapter fileAdapter;
26 |
27 | public ReplacerFilePickerDialog(Context context, File[] fileList) {
28 | super(context);
29 | this.fileList = fileList;
30 | }
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 |
36 | setContentView(R.layout.dialog_replacer_file_picker);
37 |
38 | setTitle("Import");
39 |
40 | ((Button) findViewById(R.id.buttonCancel)).setOnClickListener(new View.OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | dismiss();
44 | }
45 | });
46 |
47 | fileAdapter = new FileListAdapter(getContext(), R.layout.fragment_regex_list_item, fileList);
48 |
49 | ListView view = (ListView) findViewById(R.id.listView1);
50 | view.setAdapter(fileAdapter);
51 |
52 | view.setOnItemClickListener(new OnItemClickListener() {
53 | @Override
54 | public void onItemClick(AdapterView> arg0, View arg1, int pos,
55 | long arg3) {
56 | if (listener != null)
57 | {
58 | listener.dialogFinished(fileList[pos]);
59 | }
60 |
61 | dismiss();
62 | }
63 | });
64 | }
65 |
66 | public void setFilePickListener(FilePickerDialogResult listener)
67 | {
68 | this.listener = listener;
69 | }
70 |
71 | public static abstract class FilePickerDialogResult
72 | {
73 | public abstract void dialogFinished(File name);
74 | }
75 |
76 | private class FileListAdapter extends ArrayAdapter
77 | {
78 | public FileListAdapter(Context context, int resource, File[] objects) {
79 | super(context, resource, objects);
80 | }
81 |
82 | @Override
83 | public View getView(int position, View convertView,
84 | ViewGroup parent) {
85 | if (convertView == null)
86 | convertView = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.fragment_regex_list_item, null);
87 |
88 | ((TextView) convertView.findViewById(R.id.regex)).setText(fileList[position].getName());
89 |
90 | return convertView;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/tasker/TaskerNotificationActivity.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.tasker;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.widget.CheckBox;
7 | import android.widget.EditText;
8 | import com.matejdro.pebblenotificationcenter.R;
9 | import net.dinglisch.android.tasker.TaskerPlugin;
10 |
11 | public class TaskerNotificationActivity extends Activity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 |
17 | setContentView(R.layout.activity_tasker_notification);
18 |
19 | loadIntent();
20 | }
21 |
22 | protected void loadIntent() {
23 | Intent intent = getIntent();
24 |
25 | if (intent == null)
26 | return;
27 |
28 | Bundle bundle = intent.getBundleExtra("com.twofortyfouram.locale.intent.extra.BUNDLE");
29 | if (bundle == null)
30 | return;
31 |
32 | int action = bundle.getInt("action");
33 | if (action != 0)
34 | return;
35 |
36 | ((EditText) findViewById(R.id.titleText)).setText(bundle.getString("title"));
37 | ((EditText) findViewById(R.id.subtitleText)).setText(bundle.getString("subtitle"));
38 | ((EditText) findViewById(R.id.bodyText)).setText(bundle.getString("body"));
39 |
40 | ((CheckBox) findViewById(R.id.storeInHistoryCheck)).setChecked(bundle.getBoolean("storeInHistory"));
41 | }
42 |
43 | @Override
44 | public void onBackPressed()
45 | {
46 | Intent intent = new Intent();
47 |
48 | Bundle bundle = new Bundle();
49 |
50 | bundle.putInt("action", 0);
51 |
52 | String title = ((EditText) findViewById(R.id.titleText)).getText().toString();
53 | String subtitle = ((EditText) findViewById(R.id.subtitleText)).getText().toString();
54 | String body = ((EditText) findViewById(R.id.bodyText)).getText().toString();
55 | boolean storeInHistory = ((CheckBox) findViewById(R.id.storeInHistoryCheck)).isChecked();
56 |
57 | String description = getString(R.string.taskerDescriptionNotification, title);
58 |
59 | bundle.putString("title", title);
60 | bundle.putString("subtitle", subtitle);
61 | bundle.putString("body", body);
62 | bundle.putBoolean("storeInHistory", storeInHistory);
63 |
64 | TaskerPlugin.Setting.setVariableReplaceKeys(bundle, new String[] { "title", "subtitle", "body" });
65 |
66 | intent.putExtra("com.twofortyfouram.locale.intent.extra.BLURB", description);
67 | intent.putExtra("com.twofortyfouram.locale.intent.extra.BUNDLE", bundle);
68 |
69 | setResult(RESULT_OK, intent);
70 |
71 | super.onBackPressed();
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/util/ConfigBackup.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.util;
2 |
3 | import android.content.Context;
4 | import android.os.Environment;
5 | import com.google.common.io.Files;
6 | import java.io.File;
7 | import java.io.IOException;
8 |
9 | /**
10 | * Created by Matej on 17.9.2014.
11 | */
12 | public class ConfigBackup
13 | {
14 | public static void backup(Context context)
15 | {
16 | File targetFolder = Environment.getExternalStoragePublicDirectory("NotificationCenter");
17 | if (!targetFolder.exists())
18 | targetFolder.mkdir();
19 |
20 | targetFolder = new File(targetFolder, "settings");
21 | if (!targetFolder.exists())
22 | targetFolder.mkdir();
23 |
24 | File[] existingBackup = targetFolder.listFiles();
25 | for (File f : existingBackup)
26 | f.delete();
27 |
28 | File sourceFolder = context.getFilesDir();
29 |
30 | sourceFolder = new File(sourceFolder, "../shared_prefs");
31 |
32 | for (File file : sourceFolder.listFiles())
33 | {
34 | if (file.getName().startsWith("com.crash"))
35 | continue;
36 |
37 | File target = new File(targetFolder, file.getName());
38 | try
39 | {
40 | Files.copy(file, target);
41 | } catch (IOException e)
42 | {
43 | e.printStackTrace();
44 | }
45 | }
46 | }
47 |
48 | public static boolean restore(Context context)
49 | {
50 | File sourceFolder = Environment.getExternalStoragePublicDirectory("NotificationCenter");
51 | if (!sourceFolder.exists())
52 | return false;
53 |
54 | sourceFolder = new File(sourceFolder, "settings");
55 | if (!sourceFolder.exists())
56 | return false;
57 |
58 |
59 | File targetFolder = context.getFilesDir();
60 | targetFolder = new File(targetFolder, "../shared_prefs");
61 |
62 | File[] existingConfig = targetFolder.listFiles();
63 | for (File f : existingConfig)
64 | {
65 | if (f.getName().startsWith("com.crash"))
66 | continue;
67 |
68 | f.delete();
69 | }
70 |
71 | for (File file : sourceFolder.listFiles())
72 | {
73 | if (!file.getName().endsWith(".xml"))
74 | continue;
75 |
76 | File target = new File(targetFolder, file.getName());
77 |
78 | try
79 | {
80 | Files.copy(file, target);
81 | } catch (IOException e)
82 | {
83 | e.printStackTrace();
84 | }
85 |
86 | context.getSharedPreferences(file.getName().substring(0, file.getName().length() - 4), Context.MODE_MULTI_PROCESS);
87 | }
88 |
89 | return true;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/DialogVibrationPatternPicker.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui;
2 |
3 | import android.app.DialogFragment;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.preference.PreferenceActivity;
8 | import android.preference.PreferenceManager;
9 | import android.support.annotation.Nullable;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import com.matejdro.pebblecommons.vibration.VibrationPatternPicker;
15 | import com.matejdro.pebblenotificationcenter.PebbleNotificationCenter;
16 | import com.matejdro.pebblenotificationcenter.R;
17 |
18 | public class DialogVibrationPatternPicker extends DialogFragment
19 | {
20 | private VibrationPatternPicker vibrationPatternPicker;
21 | private SharedPreferences sharedPreferences;
22 |
23 | @Override
24 | public void onActivityCreated(Bundle savedInstanceState) {
25 | super.onActivityCreated(savedInstanceState);
26 | sharedPreferences = ((PreferenceActivity) getActivity()).getPreferenceManager().getSharedPreferences();
27 |
28 | String currentPattern = sharedPreferences.getString(PebbleNotificationCenter.PERIODIC_VIBRATION_PATTERN, "100");
29 | vibrationPatternPicker.setCurrentPattern(currentPattern);
30 | }
31 |
32 | @Nullable
33 | @Override
34 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
35 | {
36 | return inflater.inflate(R.layout.dialog_vibration_pattern, container, false);
37 | }
38 |
39 | @Override
40 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
41 | {
42 |
43 | vibrationPatternPicker = (VibrationPatternPicker) view.findViewById(R.id.vibration_pattern_picker);
44 |
45 | view.findViewById(R.id.button_ok).setOnClickListener(new View.OnClickListener()
46 | {
47 | @Override
48 | public void onClick(View v)
49 | {
50 | onOkPressed();
51 | }
52 | });
53 |
54 | view.findViewById(R.id.button_cancel).setOnClickListener(new View.OnClickListener()
55 | {
56 | @Override
57 | public void onClick(View v)
58 | {
59 | onCancelPressed();
60 | }
61 | });
62 | }
63 |
64 | private void onCancelPressed()
65 | {
66 | dismiss();
67 | }
68 |
69 | private void onOkPressed()
70 | {
71 | String newPattern = vibrationPatternPicker.validateAndGetCurrentPattern();
72 | if (newPattern != null)
73 | {
74 | dismiss();
75 | sharedPreferences.edit().putString(PebbleNotificationCenter.PERIODIC_VIBRATION_PATTERN, newPattern).apply();
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/perapp/settingitems/VibrationPatternItem.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui.perapp.settingitems;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.Context;
5 | import android.view.View;
6 | import android.widget.EditText;
7 | import android.widget.FrameLayout;
8 | import android.widget.TextView;
9 |
10 | import com.matejdro.pebblecommons.vibration.VibrationPatternPicker;
11 | import com.matejdro.pebblenotificationcenter.R;
12 | import com.matejdro.pebblenotificationcenter.appsetting.AppSetting;
13 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
14 | import com.matejdro.pebblenotificationcenter.ui.perapp.PerAppActivity;
15 |
16 | /**
17 | * Created by Matej on 19.10.2014.
18 | */
19 | public class VibrationPatternItem extends BaseSettingItem
20 | {
21 | private int textResource;
22 | private int descriptionResource;
23 | private VibrationPatternPicker vibrationPatternPicker;
24 | private Context context;
25 |
26 | public VibrationPatternItem(AppSettingStorage settingsStorage, int textResource, int descriptionResource)
27 | {
28 | super(settingsStorage, AppSetting.VIBRATION_PATTERN);
29 | this.textResource = textResource;
30 | this.descriptionResource = descriptionResource;
31 | }
32 |
33 | @Override
34 | public View getView(PerAppActivity activity) {
35 | this.context = activity;
36 |
37 | View view = activity.getLayoutInflater().inflate(R.layout.setting_customview, null);
38 | TextView nameText = (TextView) view.findViewById(R.id.name);
39 | TextView descriptionText = (TextView) view.findViewById(R.id.description);
40 | FrameLayout settingContainer = (FrameLayout) view.findViewById(R.id.settingContainer);
41 |
42 | nameText.setText(textResource);
43 | descriptionText.setText(descriptionResource);
44 |
45 | vibrationPatternPicker = new VibrationPatternPicker(activity);
46 | vibrationPatternPicker.setCurrentPattern(settingsStorage.getString(AppSetting.VIBRATION_PATTERN));
47 | settingContainer.addView(vibrationPatternPicker);
48 |
49 | return view;
50 | }
51 |
52 | @Override
53 | public boolean onClose()
54 | {
55 | String vibrationPattern = vibrationPatternPicker.validateAndGetCurrentPattern();
56 |
57 | if (vibrationPattern == null)
58 | {
59 | AlertDialog.Builder builder = new AlertDialog.Builder(context);
60 | builder.setMessage(R.string.invalidVibrationPattern);
61 | builder.setPositiveButton(R.string.ok, null);
62 | builder.show();
63 | return false;
64 | }
65 |
66 | settingsStorage.setString(AppSetting.VIBRATION_PATTERN, vibrationPattern);
67 | return true;
68 | }
69 |
70 | @Override
71 | public void setEnabled(boolean enabled) {
72 | if (vibrationPatternPicker != null)
73 | vibrationPatternPicker.setEnabled(enabled);
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/lists/WritingPhrasesList.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions.lists;
2 |
3 | import android.content.Context;
4 |
5 | import com.matejdro.pebblecommons.pebble.PebbleTalkerService;
6 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
7 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
8 | import com.matejdro.pebblenotificationcenter.appsetting.AppSetting;
9 | import com.matejdro.pebblenotificationcenter.notifications.actions.NotificationAction;
10 | import com.matejdro.pebblenotificationcenter.notifications.actions.WearVoiceAction;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | /**
15 | * Created by Matej on 19.12.2014.
16 | */
17 | public class WritingPhrasesList extends ActionList
18 | {
19 | private WearVoiceAction action;
20 | private NCTalkerService service;
21 | private List phrases;
22 |
23 | public WritingPhrasesList(WearVoiceAction action, NCTalkerService service)
24 | {
25 | this.action = action;
26 | this.service = service;
27 |
28 | populateList(service);
29 | }
30 |
31 | private void populateList(NCTalkerService service)
32 | {
33 | phrases = new ArrayList();
34 |
35 | phrases.add("Send");
36 |
37 | ProcessedNotification notification = action.getNotification(service);
38 | if (notification == null)
39 | return;
40 |
41 | ArrayList userProvidedPhrases = (ArrayList) notification.source.getSettingStorage(service).getStringList(AppSetting.WRITING_PHRASES);
42 | if (userProvidedPhrases != null)
43 | {
44 | for (String choice : userProvidedPhrases)
45 | {
46 | phrases.add(choice);
47 | if (phrases.size() >= NotificationAction.MAX_NUMBER_OF_ACTIONS)
48 | break;
49 | }
50 | }
51 |
52 | if (phrases.size() < NotificationAction.MAX_NUMBER_OF_ACTIONS)
53 | {
54 | for (String cannedResponse : action.getCannedResponses())
55 | {
56 | phrases.add(cannedResponse);
57 | }
58 | }
59 | }
60 |
61 |
62 | @Override
63 | public int getNumberOfItems()
64 | {
65 | return phrases.size();
66 | }
67 |
68 | @Override
69 | public String getItem(int id)
70 | {
71 | return phrases.get(id);
72 | }
73 |
74 | @Override
75 | public boolean itemPicked(NCTalkerService service, int id)
76 | {
77 | return false;
78 | }
79 |
80 | public void reply(String text)
81 | {
82 | action.sendReply(text, service);
83 | }
84 |
85 | @Override
86 | public boolean isTertiaryTextList()
87 | {
88 | return true;
89 | }
90 |
91 | @Override
92 | public String toString()
93 | {
94 | return "WritingPhrasesList{" +
95 | "phrases=" + phrases +
96 | '}';
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/ReplacerEditDialog.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.EditText;
9 | import com.matejdro.pebblenotificationcenter.R;
10 |
11 |
12 | public class ReplacerEditDialog extends Dialog {
13 |
14 | private ReplacerDialogResult OKListener;
15 | private ReplacerDialogResult deleteListener;
16 |
17 | private boolean editMode;
18 | private String existingCharacter;
19 | private String existingReplacement;
20 |
21 | public ReplacerEditDialog(Context context) {
22 | super(context);
23 | editMode = false;
24 | }
25 |
26 | public ReplacerEditDialog(Context context, String existingCharacter, String existingReplacement) {
27 | super(context);
28 | editMode = true;
29 | this.existingCharacter = existingCharacter;
30 | this.existingReplacement = existingReplacement;
31 | }
32 |
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 |
37 | setContentView(R.layout.dialog_replacer_edit);
38 |
39 | if (editMode)
40 | {
41 | setTitle("Edit replacement pair");
42 | ((EditText) findViewById(R.id.editCharacter)).setText(existingCharacter);
43 | ((EditText) findViewById(R.id.editReplacement)).setText(existingReplacement);
44 | }
45 | else
46 | {
47 | setTitle("Create new pair");
48 | findViewById(R.id.buttonDelete).setVisibility(View.GONE);
49 | }
50 |
51 | ((Button) findViewById(R.id.buttonCancel)).setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | dismiss();
55 | }
56 | });
57 |
58 | ((Button) findViewById(R.id.buttonDelete)).setOnClickListener(new View.OnClickListener() {
59 | @Override
60 | public void onClick(View v) {
61 | if (deleteListener != null)
62 | deleteListener.dialogFinished(null, null);
63 |
64 | dismiss();
65 | }
66 | });
67 |
68 |
69 | ((Button) findViewById(R.id.buttonOK)).setOnClickListener(new View.OnClickListener() {
70 | @Override
71 | public void onClick(View v) {
72 | EditText characterField = (EditText) findViewById(R.id.editCharacter);
73 | CharSequence character = characterField.getText();
74 |
75 | if (OKListener != null)
76 | {
77 | EditText replacementField = (EditText) findViewById(R.id.editReplacement);
78 | CharSequence replacement = replacementField.getText();
79 |
80 | OKListener.dialogFinished(character, replacement);
81 | }
82 |
83 | dismiss();
84 | }
85 | });
86 | }
87 |
88 | public void setOKListener(ReplacerDialogResult listener)
89 | {
90 | OKListener = listener;
91 | }
92 |
93 | public void setDeleteListener(ReplacerDialogResult listener)
94 | {
95 | deleteListener = listener;
96 | }
97 |
98 | public static abstract class ReplacerDialogResult
99 | {
100 | public abstract void dialogFinished(CharSequence character, CharSequence replacement);
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/JellybeanNotificationListener.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications;
2 |
3 | import android.annotation.TargetApi;
4 | import android.os.Build;
5 | import android.service.notification.NotificationListenerService;
6 | import android.service.notification.StatusBarNotification;
7 |
8 | import com.matejdro.pebblenotificationcenter.NotificationKey;
9 | import com.matejdro.pebblenotificationcenter.pebble.modules.DismissUpwardsModule;
10 |
11 | import timber.log.Timber;
12 |
13 | @TargetApi(value = Build.VERSION_CODES.JELLY_BEAN_MR2)
14 | public class JellybeanNotificationListener extends NotificationListenerService {
15 | public static JellybeanNotificationListener instance;
16 |
17 | @Override
18 | public void onDestroy() {
19 | NotificationHandler.active = false;
20 |
21 | Timber.d("Notification Listener stopped...");
22 |
23 | instance = null;
24 | }
25 |
26 | @Override
27 | public void onCreate() {
28 | Timber.d("Creating Notification Listener...");
29 |
30 | instance = this;
31 |
32 | NotificationHandler.active = true;
33 |
34 | Timber.d("Finished creating Notification Listener...");
35 |
36 |
37 |
38 | super.onCreate();
39 | }
40 |
41 | @Override
42 | public void onNotificationPosted(final StatusBarNotification sbn) {
43 | Timber.d("Got new jellybean notification");
44 | NotificationHandler.newNotification(JellybeanNotificationListener.this, NotificationHandler.getKeyFromSbn(sbn), sbn.getNotification(), true);
45 | }
46 |
47 | @Override
48 | public void onNotificationRemoved(StatusBarNotification sbn) {
49 | if (sbn == null) {
50 | return;
51 | }
52 |
53 | NotificationKey key = NotificationHandler.getKeyFromSbn(sbn);
54 | Timber.d("Got jellybean dismiss %s", key);
55 |
56 |
57 | DismissUpwardsModule.dismissNotification(this, key);
58 | }
59 |
60 | @TargetApi(value = Build.VERSION_CODES.LOLLIPOP)
61 | public static boolean isNotificationFilteredByDoNotInterrupt(NotificationKey key)
62 | {
63 | if (instance == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || key.getLolipopKey() == null)
64 | return false;
65 |
66 | RankingMap rankingMap = instance.getCurrentRanking();
67 | if (rankingMap == null)
68 | return false;
69 |
70 | Ranking ranking = new Ranking();
71 | if (!rankingMap.getRanking(key.getLolipopKey(), ranking))
72 | return false;
73 |
74 | return !ranking.matchesInterruptionFilter();
75 | }
76 |
77 |
78 | @TargetApi(value = Build.VERSION_CODES.LOLLIPOP)
79 | public static void dismissNotification(NotificationKey key)
80 | {
81 | Timber.d("dismissing from phone %s %b", key, (instance != null));
82 |
83 | if (instance == null)
84 | return;
85 |
86 | if (key.getLolipopKey() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
87 | instance.cancelNotification(key.getLolipopKey());
88 | else
89 | instance.cancelNotification(key.getPackage(), key.getTag(), key.getAndroidId());
90 | }
91 |
92 | public static StatusBarNotification[] getCurrentNotifications()
93 | {
94 | if (instance == null)
95 | return new StatusBarNotification[0];
96 |
97 | return instance.getActiveNotifications();
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/tasker/TaskerGlobalSettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.tasker;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.preference.Preference;
6 | import android.preference.PreferenceManager;
7 |
8 | import com.matejdro.pebblecommons.util.BundleSharedPreferences;
9 | import com.matejdro.pebblenotificationcenter.R;
10 | import com.matejdro.pebblenotificationcenter.ui.SettingsActivity;
11 | import java.lang.reflect.Field;
12 |
13 | /**
14 | * Created by Matej on 18.9.2014.
15 | */
16 | public class TaskerGlobalSettingsActivity extends SettingsActivity
17 | {
18 | private Bundle storage;
19 |
20 | @Override
21 | public void init()
22 | {
23 | storage = new Bundle();
24 |
25 | loadIntent();
26 |
27 | replaceSharedPreferences();
28 | Preference p;
29 |
30 | super.init();
31 | }
32 |
33 | protected void loadIntent() {
34 | Intent intent = getIntent();
35 |
36 | if (intent == null)
37 | return;
38 |
39 | Bundle bundle = intent.getBundleExtra("com.twofortyfouram.locale.intent.extra.BUNDLE");
40 | if (bundle == null)
41 | return;
42 |
43 | int action = bundle.getInt("action");
44 | if (action != 1)
45 | return;
46 |
47 | storage.putAll(bundle);
48 | for (String key : bundle.keySet())
49 | {
50 | if (!key.startsWith("setting_"))
51 | {
52 | storage.remove(key);
53 | }
54 | }
55 | }
56 |
57 | public void onBackPressed()
58 | {
59 | Intent intent = new Intent();
60 |
61 | Bundle bundle = new Bundle();
62 |
63 | bundle.putInt("action", 1);
64 |
65 | String description = getString(R.string.taskerDescriptionGlobalSetting);
66 |
67 | bundle.putAll(storage);
68 |
69 | intent.putExtra("com.twofortyfouram.locale.intent.extra.BLURB", description);
70 | intent.putExtra("com.twofortyfouram.locale.intent.extra.BUNDLE", bundle);
71 |
72 | setResult(RESULT_OK, intent);
73 |
74 | super.onBackPressed();
75 | }
76 |
77 | private void replaceSharedPreferences()
78 | {
79 | PreferenceManager manager = getPreferenceManager();
80 | BundleSharedPreferences bundleSharedPreferences = new BundleSharedPreferences(manager.getSharedPreferences(), storage);
81 |
82 | try
83 | {
84 | Field field = PreferenceManager.class.getDeclaredField("mSharedPreferences");
85 | field.setAccessible(true);
86 | field.set(manager, bundleSharedPreferences);
87 |
88 | field = PreferenceManager.class.getDeclaredField("mEditor");
89 | field.setAccessible(true);
90 | field.set(manager, bundleSharedPreferences.edit());
91 |
92 | } catch (Exception e)
93 | {
94 | e.printStackTrace();
95 | }
96 | }
97 |
98 | public static String bundle2string(Bundle bundle) {
99 | String string = "Bundle{";
100 | for (String key : bundle.keySet()) {
101 | string += " " + key + " => " + bundle.get(key) + ";";
102 | }
103 | string += " }Bundle";
104 | return string;
105 | }
106 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/actions/IntentAction.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications.actions;
2 |
3 | import android.content.Intent;
4 | import android.os.Parcel;
5 |
6 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
7 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
8 | import com.matejdro.pebblenotificationcenter.appsetting.AppSetting;
9 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
10 | import com.matejdro.pebblenotificationcenter.notifications.NotificationHandler;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | /**
15 | * Created by Matej on 22.9.2014.
16 | */
17 | public class IntentAction extends NotificationAction
18 | {
19 | private String intentAction;
20 |
21 | public IntentAction(String actionName, String intentAction)
22 | {
23 | super(actionName);
24 | this.intentAction = intentAction;
25 | }
26 |
27 | @Override
28 | public boolean executeAction(NCTalkerService service, ProcessedNotification notification)
29 | {
30 | Intent intent = new Intent(intentAction);
31 |
32 | intent.putExtra("ncappname", NotificationHandler.getAppName(service, notification.source.getKey().getPackage()));
33 | intent.putExtra("ncapppkg", notification.source.getKey().getPackage());
34 | intent.putExtra("ncid", Integer.toString(notification.source.getKey().getAndroidId()));
35 | intent.putExtra("nctitle", notification.source.getTitle());
36 | intent.putExtra("ncsubtitle", notification.source.getSubtitle());
37 | intent.putExtra("nctext", notification.source.getText());
38 |
39 | if (notification.source.getKey().getTag() != null)
40 | intent.putExtra("nctag", notification.source.getKey().getTag());
41 |
42 | service.sendBroadcast(intent);
43 | return false;
44 | }
45 |
46 | @Override
47 | public int describeContents()
48 | {
49 | return 0;
50 | }
51 |
52 | @Override
53 | public void writeToParcel(Parcel parcel, int i)
54 | {
55 | parcel.writeValue(actionText);
56 | parcel.writeValue(intentAction);
57 | }
58 |
59 | public static final Creator CREATOR = new Creator()
60 | {
61 | @Override
62 | public IntentAction createFromParcel(Parcel parcel)
63 | {
64 | String name = (String) parcel.readValue(String.class.getClassLoader());
65 | String action = (String) parcel.readValue(String.class.getClassLoader());
66 |
67 | return new IntentAction(name, action);
68 | }
69 |
70 | @Override
71 | public IntentAction[] newArray(int i)
72 | {
73 | return new IntentAction[0];
74 | }
75 | };
76 |
77 | public static void addIntentActions(AppSettingStorage settings, ArrayList storage)
78 | {
79 | if (storage.size() >= NotificationAction.MAX_NUMBER_OF_ACTIONS)
80 | return;
81 |
82 | List names = settings.getStringList(AppSetting.INTENT_ACTIONS_NAMES);
83 | List actions = settings.getStringList(AppSetting.INTENT_ACTIONS_ACTIONS);
84 |
85 | for (int i = 0; i < names.size(); i++)
86 | {
87 | storage.add(new IntentAction(names.get(i), actions.get(i)));
88 |
89 | if (storage.size() >= NotificationAction.MAX_NUMBER_OF_ACTIONS)
90 | return;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/pebble/appretrieval/Sdk2AppRetrieval.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.pebble.appretrieval;
2 |
3 | import android.app.AlertDialog;
4 | import android.app.ProgressDialog;
5 | import android.content.Context;
6 | import android.content.DialogInterface;
7 | import android.os.AsyncTask;
8 |
9 | import com.matejdro.pebblecommons.pebble.PebbleApp;
10 | import com.matejdro.pebblecommons.pebble.PebbleDeveloperConnection;
11 | import com.matejdro.pebblenotificationcenter.R;
12 |
13 | import java.net.URISyntaxException;
14 | import java.util.List;
15 |
16 | public class Sdk2AppRetrieval
17 | {
18 | private Context context;
19 | private AppRetrievalCallback appRetrievalCallback;
20 |
21 | public Sdk2AppRetrieval(Context context, AppRetrievalCallback appRetrievalCallback)
22 | {
23 | this.context = context;
24 | this.appRetrievalCallback = appRetrievalCallback;
25 | }
26 |
27 | public void retrieveApps()
28 | {
29 | new GetAppsTask().execute((Void[]) null);
30 |
31 | }
32 |
33 | private class GetAppsTask extends AsyncTask
34 | {
35 | private ProgressDialog progressDialog;
36 |
37 |
38 | @Override
39 | protected void onPreExecute()
40 | {
41 | progressDialog = new ProgressDialog(context);
42 | progressDialog.setIndeterminate(true);
43 | progressDialog.setMessage(context.getString(R.string.retrieving_apps));
44 | progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener()
45 | {
46 | @Override
47 | public void onCancel(DialogInterface dialog)
48 | {
49 | cancel(false);
50 | }
51 | });
52 |
53 | progressDialog.show();
54 | }
55 |
56 | @Override
57 | protected List doInBackground(Void... params)
58 | {
59 | PebbleDeveloperConnection developerConnection = null;
60 | try
61 | {
62 | developerConnection = new PebbleDeveloperConnection(context);
63 | developerConnection.connectBlocking();
64 |
65 | if (developerConnection.isOpen())
66 | {
67 | List installedPebbleApps = developerConnection.getInstalledPebbleApps();
68 | if (installedPebbleApps == null)
69 | return null;
70 |
71 | installedPebbleApps.addAll(PebbleApp.getSystemApps(context));
72 | developerConnection.close();
73 |
74 | return installedPebbleApps;
75 | }
76 | } catch (URISyntaxException e)
77 | {
78 | e.printStackTrace();
79 | }
80 | catch (InterruptedException e)
81 | {
82 | e.printStackTrace();
83 | }
84 | finally
85 | {
86 | if (developerConnection != null)
87 | developerConnection.close();
88 | }
89 |
90 | return null;
91 | }
92 |
93 | @Override
94 | protected void onPostExecute(final List list)
95 | {
96 | progressDialog.hide();
97 |
98 | if (list == null)
99 | {
100 | new AlertDialog.Builder(context).setMessage(R.string.error_developer_connection).setPositiveButton(R.string.ok, null).show();
101 | return;
102 | }
103 | appRetrievalCallback.addApps(list);
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/perapp/settingitems/ResetDefaultsButtonItem.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui.perapp.settingitems;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.TextView;
8 | import com.matejdro.pebblenotificationcenter.R;
9 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
10 | import com.matejdro.pebblenotificationcenter.appsetting.SharedPreferencesAppStorage;
11 | import com.matejdro.pebblenotificationcenter.ui.perapp.PerAppActivity;
12 |
13 | /**
14 | * Created by Matej on 19.10.2014.
15 | */
16 | public class ResetDefaultsButtonItem extends BaseSettingItem
17 | {
18 | private int textResource;
19 | private int descriptionResource;
20 | private int buttonResource;
21 |
22 | protected PerAppActivity activity;
23 |
24 | private TextView nameText;
25 | private TextView descriptionText;
26 | private Button button;
27 |
28 | private boolean enabled = true;
29 |
30 | public ResetDefaultsButtonItem(AppSettingStorage settingsStorage, int textResource, int descriptionResource, int buttonResource)
31 | {
32 | super(settingsStorage, null);
33 | this.textResource = textResource;
34 | this.descriptionResource = descriptionResource;
35 | this.buttonResource = buttonResource;
36 | }
37 |
38 |
39 |
40 | @Override
41 | public View getView(final PerAppActivity activity)
42 | {
43 | this.activity = activity;
44 |
45 | View view = activity.getLayoutInflater().inflate(R.layout.setting_button, null);
46 |
47 | nameText = (TextView) view.findViewById(R.id.name);
48 | descriptionText = (TextView) view.findViewById(R.id.description);
49 | button = (Button) view.findViewById(R.id.button);
50 |
51 | nameText.setText(textResource);
52 | descriptionText.setText(descriptionResource);
53 | button.setText(buttonResource);
54 |
55 | button.setOnClickListener(new View.OnClickListener()
56 | {
57 | @Override
58 | public void onClick(View v)
59 | {
60 | if (!(settingsStorage instanceof SharedPreferencesAppStorage))
61 | return;
62 |
63 | String pkg = ((SharedPreferencesAppStorage) settingsStorage).getAppPackage();
64 | SharedPreferences.Editor editor = activity.getSharedPreferences(SharedPreferencesAppStorage.getSharedPreferencesName(pkg), Context.MODE_MULTI_PROCESS).edit();
65 | editor.clear();
66 | editor.apply();
67 |
68 | activity.finish();
69 | }
70 | });
71 |
72 | setEnabled(enabled);
73 |
74 | return view;
75 |
76 | }
77 |
78 | @Override
79 | public boolean onClose()
80 | {
81 | return true;
82 | }
83 |
84 | @Override
85 | public void setEnabled(boolean enabled)
86 | {
87 | this.enabled = enabled;
88 |
89 | if (activity == null)
90 | return;
91 |
92 | button.setEnabled(enabled);
93 |
94 | if (enabled)
95 | {
96 | nameText.setTextColor(activity.getResources().getColor(R.color.text_enabled));
97 | descriptionText.setTextColor(activity.getResources().getColor(R.color.text_enabled));
98 | }
99 | else
100 | {
101 | nameText.setTextColor(activity.getResources().getColor(R.color.text_disabled));
102 | descriptionText.setTextColor(activity.getResources().getColor(R.color.text_disabled));
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/NotificationHistoryStorage.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.content.SharedPreferences.Editor;
7 | import android.database.Cursor;
8 | import android.database.sqlite.SQLiteCantOpenDatabaseException;
9 | import android.database.sqlite.SQLiteDatabase;
10 | import android.database.sqlite.SQLiteOpenHelper;
11 | import android.graphics.Bitmap;
12 | import android.preference.PreferenceManager;
13 |
14 | import java.io.ByteArrayOutputStream;
15 |
16 | import timber.log.Timber;
17 |
18 | public class NotificationHistoryStorage extends SQLiteOpenHelper {
19 |
20 |
21 | private Context context;
22 |
23 | public NotificationHistoryStorage(Context context) {
24 | super(context, "notifications", null, 2);
25 | this.context = context;
26 | }
27 |
28 |
29 | @Override
30 | public void onCreate(SQLiteDatabase db) {
31 | db.execSQL("CREATE TABLE IF NOT EXISTS notifications (PostTime INTEGER, Title STRING, Subtitle STRING, Text STRING, Icon BLOB DEFAULT NULL)");
32 | }
33 |
34 |
35 | @Override
36 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
37 | if (newVersion == 2)
38 | {
39 | db.execSQL("ALTER TABLE notifications ADD COLUMN Icon BLOB DEFAULT NULL");
40 | }
41 | }
42 |
43 |
44 | public void storeNotification(long time, String title, String subtitle, String text, Bitmap icon)
45 | {
46 | ContentValues values = new ContentValues();
47 | values.put("PostTime", time);
48 | values.put("Title", title);
49 | values.put("Subtitle", subtitle);
50 | values.put("Text", text);
51 |
52 | if (icon == null)
53 | values.put("Icon", (byte[]) null);
54 | else
55 | {
56 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
57 | icon.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
58 | values.put("Icon", byteArrayOutputStream.toByteArray());
59 | }
60 |
61 | try
62 | {
63 | getWritableDatabase().insert("notifications", null, values);
64 | }
65 | catch (SQLiteCantOpenDatabaseException e)
66 | {
67 | Timber.e(e, "Database open exception!");
68 | e.printStackTrace();
69 | }
70 | }
71 |
72 | @Override
73 | public synchronized void close() {
74 | getWritableDatabase().close();
75 | super.close();
76 | }
77 |
78 | public void clearDatabase()
79 | {
80 | SQLiteDatabase database = getWritableDatabase();
81 |
82 | database.delete("notifications", null, null);
83 |
84 |
85 | Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
86 | editor.putLong("lastCleanup", System.currentTimeMillis());
87 | editor.apply();
88 | }
89 |
90 | public void cleanDatabase()
91 | {
92 | SQLiteDatabase database = getWritableDatabase();
93 | Cursor cursor = database.rawQuery("SELECT MIN(PostTime) FROM (SELECT PostTime FROM notifications ORDER BY PostTime DESC LIMIT 100)", null);
94 | if (!cursor.moveToNext())
95 | return;
96 |
97 | long lastDate = cursor.getLong(0);
98 |
99 | database.delete("notifications", "PostTime < ?", new String[] {Long.toString(lastDate)});
100 |
101 |
102 | Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
103 | editor.putLong("lastCleanup", System.currentTimeMillis());
104 | editor.apply();
105 |
106 | cursor.close();
107 | }
108 |
109 |
110 | public void tryCleanDatabase()
111 | {
112 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
113 | long lastCleanup = preferences.getLong("lastCleanup", 0);
114 | if (System.currentTimeMillis() - lastCleanup > 24 * 3600 * 1000)
115 | cleanDatabase();
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/perapp/settingitems/CheckBoxItem.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui.perapp.settingitems;
2 |
3 | import android.view.View;
4 | import android.widget.CheckBox;
5 | import android.widget.CompoundButton;
6 | import android.widget.TextView;
7 | import com.matejdro.pebblenotificationcenter.R;
8 | import com.matejdro.pebblenotificationcenter.appsetting.AppSetting;
9 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
10 | import com.matejdro.pebblenotificationcenter.ui.perapp.PerAppActivity;
11 |
12 | /**
13 | * Created by Matej on 19.10.2014.
14 | */
15 | public class CheckBoxItem extends BaseSettingItem
16 | {
17 | private AppSetting associatedSetting;
18 | private int textResource;
19 | private int descriptionResource;
20 |
21 | private TextView nameText;
22 | private TextView descriptionText;
23 | private CheckBox checkBox;
24 | private boolean enabled = true;
25 |
26 | protected PerAppActivity activity;
27 |
28 | public CheckBoxItem(AppSettingStorage settingsStorage, AppSetting associatedSetting, int textResource, int descriptionResource)
29 | {
30 | super(settingsStorage, associatedSetting);
31 |
32 | this.associatedSetting = associatedSetting;
33 | this.textResource = textResource;
34 | this.descriptionResource = descriptionResource;
35 | }
36 |
37 | @Override
38 | public View getView(PerAppActivity activity)
39 | {
40 | this.activity = activity;
41 |
42 | View view = activity.getLayoutInflater().inflate(R.layout.setting_checkbox, null);
43 |
44 | nameText = (TextView) view.findViewById(R.id.name);
45 | descriptionText = (TextView) view.findViewById(R.id.description);
46 | checkBox = (CheckBox) view.findViewById(R.id.checkbox);
47 |
48 | nameText.setText(textResource);
49 | descriptionText.setText(descriptionResource);
50 |
51 | view.setOnClickListener(new View.OnClickListener()
52 | {
53 | @Override
54 | public void onClick(View v)
55 | {
56 | if (enabled)
57 | checkBox.toggle();
58 | }
59 | });
60 |
61 | checkBox.setChecked(getSavedValue());
62 | checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
63 | {
64 | @Override
65 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
66 | {
67 | settingChanged(isChecked);
68 | }
69 | });
70 |
71 | setEnabled(enabled);
72 |
73 | return view;
74 | }
75 |
76 | protected boolean getSavedValue()
77 | {
78 | return settingsStorage.getBoolean(associatedSetting);
79 | }
80 |
81 | protected void settingChanged(boolean change)
82 | {
83 | settingsStorage.setBoolean(associatedSetting, change);
84 | }
85 |
86 | @Override
87 | public boolean onClose()
88 | {
89 | return true;
90 | }
91 |
92 | @Override
93 | public void setEnabled(boolean enabled)
94 | {
95 | this.enabled = enabled;
96 | if (activity == null)
97 | return;
98 |
99 | if (enabled)
100 | {
101 | nameText.setTextColor(activity.getResources().getColor(R.color.text_enabled));
102 | descriptionText.setTextColor(activity.getResources().getColor(R.color.text_enabled));
103 | }
104 | else
105 | {
106 | nameText.setTextColor(activity.getResources().getColor(R.color.text_disabled));
107 | descriptionText.setTextColor(activity.getResources().getColor(R.color.text_disabled));
108 | }
109 |
110 | checkBox.setEnabled(enabled);
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/notifications/NCUserPrompter.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.notifications;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Parcel;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.NotificationCompat;
8 |
9 | import com.matejdro.pebblecommons.userprompt.UserPrompter;
10 | import com.matejdro.pebblenotificationcenter.NCTalkerService;
11 | import com.matejdro.pebblenotificationcenter.NotificationKey;
12 | import com.matejdro.pebblenotificationcenter.PebbleNotification;
13 | import com.matejdro.pebblenotificationcenter.PebbleNotificationCenter;
14 | import com.matejdro.pebblenotificationcenter.ProcessedNotification;
15 | import com.matejdro.pebblenotificationcenter.notifications.actions.NotificationAction;
16 | import com.matejdro.pebblenotificationcenter.pebble.modules.DismissUpwardsModule;
17 | import com.matejdro.pebblenotificationcenter.pebble.modules.NotificationSendingModule;
18 |
19 | import java.util.ArrayList;
20 |
21 | public class NCUserPrompter implements UserPrompter
22 | {
23 | private static NotificationKey NC_PROMPTER_KEY = new NotificationKey(PebbleNotificationCenter.PACKAGE, 12345, null);
24 |
25 | private Context context;
26 |
27 | public NCUserPrompter(Context context)
28 | {
29 | this.context = context;
30 | }
31 |
32 | @Override
33 | public void promptUser(String title, @Nullable String subtitle, String body, PromptAnswer... answers)
34 | {
35 | PebbleNotification notification = new PebbleNotification(title, body, NC_PROMPTER_KEY);
36 | ArrayList actionList = new ArrayList<>();
37 | for (PromptAnswer answer : answers)
38 | {
39 | actionList.add(new DismissIntentAction(answer.getText(), answer.getAction()));
40 | }
41 |
42 | notification.setSubtitle(subtitle);
43 | notification.setDismissable(false);
44 | notification.setForceActionMenu(true);
45 | notification.setForceSwitch(true);
46 | notification.setActions(actionList);
47 | notification.setNoHistory(true);
48 |
49 | NotificationSendingModule.notify(notification, context);
50 | }
51 |
52 | private static class DismissIntentAction extends NotificationAction
53 | {
54 | private Intent intent;
55 |
56 | public DismissIntentAction(String actionName, Intent intent)
57 | {
58 | super(actionName);
59 | this.intent = intent;
60 | }
61 |
62 | @Override
63 | public boolean executeAction(NCTalkerService service, ProcessedNotification notification)
64 | {
65 | service.sendBroadcast(intent);
66 | DismissUpwardsModule.dismissPebbleID(service, notification.id);
67 | return false;
68 | }
69 |
70 | @Override
71 | public int describeContents()
72 | {
73 | return 0;
74 | }
75 |
76 | @Override
77 | public void writeToParcel(Parcel parcel, int i)
78 | {
79 | parcel.writeValue(actionText);
80 | parcel.writeParcelable(intent, i);
81 | }
82 |
83 | public static final Creator CREATOR = new Creator()
84 | {
85 | @Override
86 | public DismissIntentAction createFromParcel(Parcel parcel)
87 | {
88 | String name = (String) parcel.readValue(String.class.getClassLoader());
89 | Intent intent = (Intent) parcel.readParcelable(String.class.getClassLoader());
90 |
91 | return new DismissIntentAction(name, intent);
92 | }
93 |
94 | @Override
95 | public DismissIntentAction[] newArray(int i)
96 | {
97 | return new DismissIntentAction[0];
98 | }
99 | };
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/NotificationKey.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 | import android.support.annotation.Nullable;
6 |
7 | import java.util.regex.Pattern;
8 |
9 | /**
10 | * Created by Matej on 18.10.2014.
11 | */
12 | public class NotificationKey implements Parcelable
13 | {
14 | private String lolipopKey;
15 |
16 | private String pkg;
17 | private Integer androidId;
18 | private String tag;
19 |
20 | public NotificationKey(String lolipopKey)
21 | {
22 | this.lolipopKey = lolipopKey;
23 |
24 | String[] split = lolipopKey.split(Pattern.quote("|"));
25 |
26 | pkg = split[1];
27 | androidId = Integer.parseInt(split[2]);
28 |
29 | if (!split[3].equals("null"))
30 | tag = split[3];
31 | }
32 |
33 | public NotificationKey(String pkg, Integer androidId, String tag)
34 | {
35 | this.pkg = pkg;
36 | this.androidId = androidId;
37 | this.tag = tag;
38 | }
39 |
40 | public @Nullable String getLolipopKey()
41 | {
42 | return lolipopKey;
43 | }
44 |
45 | public @Nullable String getPackage()
46 | {
47 | return pkg;
48 | }
49 |
50 | public @Nullable Integer getAndroidId()
51 | {
52 | return androidId;
53 | }
54 |
55 | public @Nullable String getTag()
56 | {
57 | return tag;
58 | }
59 |
60 | public boolean equals(NotificationKey comparing)
61 | {
62 | if (this.lolipopKey != null && comparing.lolipopKey != null)
63 | return lolipopKey.equals(comparing.lolipopKey);
64 |
65 | if (pkg == null || comparing.pkg == null)
66 | return false;
67 |
68 | if (androidId == null || comparing.androidId == null)
69 | return false;
70 |
71 | return pkg.equals(comparing.pkg) && androidId.equals(comparing.androidId) && ((tag == null && comparing.tag == null) || (tag != null && tag.equals(comparing.tag)));
72 | }
73 |
74 | @Override
75 | public String toString()
76 | {
77 | if (lolipopKey != null)
78 | return lolipopKey;
79 | else
80 | return pkg + " " + androidId + " " + getTag();
81 | }
82 |
83 | @Override
84 | public int describeContents()
85 | {
86 | return 0;
87 | }
88 |
89 | @Override
90 | public void writeToParcel(Parcel dest, int flags)
91 | {
92 | if (lolipopKey != null)
93 | {
94 | dest.writeByte((byte) 0);
95 | dest.writeValue(lolipopKey);
96 | }
97 | else
98 | {
99 | dest.writeByte((byte) 1);
100 | dest.writeValue(pkg);
101 | dest.writeValue(androidId);
102 | dest.writeValue(tag);
103 | }
104 | }
105 |
106 | public static final Creator CREATOR = new Creator()
107 | {
108 | @Override
109 | public NotificationKey createFromParcel(Parcel parcel)
110 | {
111 | boolean hasLollipopKey = parcel.readByte() == 0;
112 |
113 | if (hasLollipopKey)
114 | {
115 | String lollipopKey = (String) parcel.readValue(getClass().getClassLoader());
116 | return new NotificationKey(lollipopKey);
117 | }
118 | else
119 | {
120 | String pkg = (String) parcel.readValue(getClass().getClassLoader());
121 | Integer androidId = (Integer) parcel.readValue(getClass().getClassLoader());
122 | String tag = (String) parcel.readValue(getClass().getClassLoader());
123 |
124 | return new NotificationKey(pkg, androidId, tag);
125 |
126 | }
127 | }
128 |
129 | @Override
130 | public NotificationKey[] newArray(int i)
131 | {
132 | return new NotificationKey[i];
133 | }
134 | };
135 | }
136 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/ui/perapp/settingitems/TaskerTaskListItem.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.ui.perapp.settingitems;
2 |
3 | import android.app.Activity;
4 | import android.app.AlertDialog;
5 | import android.content.ActivityNotFoundException;
6 | import android.content.DialogInterface;
7 | import android.content.Intent;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.Toast;
11 | import com.matejdro.pebblenotificationcenter.R;
12 | import com.matejdro.pebblenotificationcenter.appsetting.AppSetting;
13 | import com.matejdro.pebblenotificationcenter.appsetting.AppSettingStorage;
14 | import com.matejdro.pebblenotificationcenter.ui.perapp.PerAppActivity;
15 | import net.dinglisch.android.tasker.TaskerIntent;
16 |
17 | /**
18 | * Created by Matej on 19.10.2014.
19 | */
20 | public class TaskerTaskListItem extends ListItem implements ActivityResultItem
21 | {
22 | public TaskerTaskListItem(AppSettingStorage settingsStorage, AppSetting associatedSetting, int textResource, int descriptionResource)
23 | {
24 | super(settingsStorage, associatedSetting, textResource, descriptionResource);
25 | }
26 |
27 | private boolean waitingForResult = false;
28 | private Button variablesButton;
29 |
30 | @Override
31 | protected void openAddDialog(String text)
32 | {
33 | try
34 | {
35 | activity.startActivityForResult(TaskerIntent.getTaskSelectIntent(), 0);
36 | } catch (ActivityNotFoundException e)
37 | {
38 | Toast.makeText(activity, R.string.errorNoTasker, Toast.LENGTH_LONG).show();
39 | }
40 | waitingForResult = true;
41 | }
42 |
43 | @Override
44 | protected void openEditDialog(final int id, String text)
45 | {
46 | AlertDialog.Builder builder = new AlertDialog.Builder(activity);
47 |
48 | builder.setTitle(activity.getString(R.string.removeTaskConfirmation, text));
49 |
50 | builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener()
51 | {
52 | @Override
53 | public void onClick(DialogInterface dialog, int which)
54 | {
55 | remove(id);
56 | }
57 | });
58 |
59 | builder.setNegativeButton(R.string.no, null);
60 | builder.show();
61 |
62 | }
63 |
64 | @Override
65 | public View getView(final PerAppActivity activity)
66 | {
67 | View view = super.getView(activity);
68 |
69 | variablesButton = (Button) view.findViewById(R.id.variablesButton);
70 | variablesButton.setOnClickListener(new View.OnClickListener()
71 | {
72 | @Override
73 | public void onClick(View view)
74 | {
75 | AlertDialog.Builder builder = new AlertDialog.Builder(activity);
76 |
77 | builder.setMessage(R.string.taskerVariablesDescription);
78 | builder.setPositiveButton(R.string.ok, null);
79 |
80 | builder.show();
81 |
82 | }
83 | });
84 |
85 | if (!enabled)
86 | setEnabled(false);
87 |
88 | return view;
89 | }
90 |
91 | @Override
92 | protected int getLayout()
93 | {
94 | return R.layout.setting_tasklist;
95 | }
96 |
97 | @Override
98 | public void setEnabled(boolean enabled)
99 | {
100 | super.setEnabled(enabled);
101 |
102 | if (activity != null && variablesButton != null)
103 | variablesButton.setEnabled(enabled);
104 | }
105 |
106 | @Override
107 | public void onActivityResult(int requestCode, int resultCode, Intent data)
108 | {
109 | if (!waitingForResult)
110 | return;
111 | waitingForResult = false;
112 |
113 | if (resultCode != Activity.RESULT_OK || data == null)
114 | return;
115 |
116 | String task = data.getDataString();
117 | if (task != null)
118 | add(task);
119 |
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/PebbleNotificationCenter.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter;
2 |
3 | import android.content.pm.ApplicationInfo;
4 |
5 | import com.crashlytics.android.core.CrashlyticsCore;
6 | import com.matejdro.pebblecommons.PebbleCompanionApplication;
7 | import com.matejdro.pebblecommons.pebble.PebbleTalkerService;
8 | import com.matejdro.pebblecommons.util.LogWriter;
9 | import com.matejdro.pebblenotificationcenter.util.SettingsMemoryStorage;
10 |
11 | import java.util.Map;
12 | import java.util.UUID;
13 |
14 | import io.fabric.sdk.android.Fabric;
15 | import timber.log.Timber;
16 |
17 | public class PebbleNotificationCenter extends PebbleCompanionApplication
18 | {
19 | public static final String PACKAGE = "com.matejdro.pebblenotificationcenter";
20 |
21 | public static final String APP_INCLUSION_MODE = "includeMode";
22 | public static final String SELECTED_PACKAGES = "CheckedApps";
23 | public static final String REPLACING_KEYS_LIST = "ReplacingKeys";
24 | public static final String REPLACING_VALUES_LIST = "ReplacingValues";
25 | public static final String FONT_TITLE = "fontTitle";
26 | public static final String FONT_SUBTITLE = "fontSubtitle";
27 | public static final String FONT_BODY = "fontBody";
28 | public static final String LIGHT_SCREEN_ON_NOTIFICATIONS = "lightScreenNotifications";
29 | public static final String CLOSE_TO_LAST_APP = "closeToLastApp";
30 | public static final String DONT_VIBRATE_WHEN_CHARGING = "noVibrateCharge";
31 | public static final String RESPECT_ON_WATCH_QUIET_TIME = "respectWatchQuietTime";
32 | public static final String SHAKE_ACTION = "shakeAction";
33 | public static final String WHITE_NOTIFICATION_TEXT = "whiteNotificationText";
34 | public static final String SKEW_NOTIFICATION_IMAGE_COLORS = "skewBackgroundImageColors";
35 | public static final String NO_NOTIFY_VIBRATE = "noNotificationsSilent";
36 | public static final String NOTIFICATIONS_DISABLED = "noNotifications";
37 | public static final String VIBRATION_DISABLED = "noVibration";
38 | public static final String DISPLAY_SCROLL_SHADOW = "displayScrollShadow";
39 | public static final String OPEN_NC_AFTER_RECONNECT = "openAfterReconnect";
40 | public static final String SCROLL_BY_PAGE = "scrollByPage";
41 | public static final String DISPLAY_DISCONNECTED_NOTIFICATION = "displayDisconnectedNotification";
42 | public static final String PERIODIC_VIBRATION_PATTERN = "periodicVibrationPattern";
43 | public static final String ENABLE_GESTURES = "enableGestures";
44 | public static final String EXPERT_MODE = "expertMode";
45 |
46 | public static final String LATITUDE = "latitude";
47 | public static final String LONGITUDE = "longitude";
48 | public static final String ALTITUDE = "altitude";
49 |
50 | public final static UUID WATCHAPP_UUID = UUID.fromString("0a7575eb-e5b9-456b-8701-3eacb62d74f1");
51 |
52 | private static SettingsMemoryStorage settingsMemoryStorage;
53 |
54 | @Override public void onCreate() {
55 | super.onCreate();
56 |
57 | boolean isDebuggable = ( 0 != ( getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE ) );
58 |
59 | CrashlyticsCore crashlytics = new CrashlyticsCore.Builder().disabled(isDebuggable).build();
60 | Fabric.with(this, crashlytics);
61 |
62 | settingsMemoryStorage = new SettingsMemoryStorage(this);
63 |
64 | Timber.setAppTag("PebbleNotificationCenter");
65 | Timber.plant(new Timber.AppTaggedDebugTree());
66 | LogWriter.init(settingsMemoryStorage.getSharedPreferences(), "NotificationCenter", this);
67 | }
68 |
69 | public static SettingsMemoryStorage getInMemorySettings()
70 | {
71 | return settingsMemoryStorage;
72 | }
73 |
74 | @Override
75 | public UUID getPebbleAppUUID()
76 | {
77 | return WATCHAPP_UUID;
78 | }
79 |
80 | @Override
81 | public Class extends PebbleTalkerService> getTalkerServiceClass()
82 | {
83 | return NCTalkerService.class;
84 | }
85 |
86 | @Override
87 | public Map getTextReplacementTable()
88 | {
89 | return settingsMemoryStorage.getReplacingStrings();
90 | }
91 |
92 | @SuppressWarnings("ConstantConditions")
93 | public static boolean isXposedModuleRunning()
94 | {
95 | return false;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/com/matejdro/pebblenotificationcenter/location/LocationLookup.java:
--------------------------------------------------------------------------------
1 | package com.matejdro.pebblenotificationcenter.location;
2 |
3 | import android.Manifest;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.content.SharedPreferences.Editor;
7 | import android.content.pm.PackageManager;
8 | import android.location.Location;
9 | import android.location.LocationListener;
10 | import android.location.LocationManager;
11 | import android.os.Bundle;
12 | import android.preference.PreferenceManager;
13 | import android.support.v4.content.ContextCompat;
14 |
15 | import com.matejdro.pebblecommons.util.TimeUtil;
16 | import com.matejdro.pebblenotificationcenter.PebbleNotificationCenter;
17 |
18 | import java.util.Date;
19 |
20 | public class LocationLookup {
21 | static private LocationLookup _instance = null;
22 | private LocationListener locationListener = null;
23 | private Context context;
24 | private SharedPreferences settings;
25 | private Date gotLastLocation;
26 |
27 | public LocationLookup(Context activity) {
28 | this.context = activity;
29 | _instance = this;
30 | settings = PreferenceManager.getDefaultSharedPreferences(activity);
31 | }
32 |
33 | static public synchronized LocationLookup getInstance() {
34 | return _instance;
35 | }
36 |
37 | public void lookup() {
38 | if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_DENIED)
39 | return;
40 |
41 | boolean backlight = settings.getString(PebbleNotificationCenter.LIGHT_SCREEN_ON_NOTIFICATIONS, "2").equals("3");
42 | // will lookup time once a hour
43 | if (backlight && TimeUtil.hasTimePassed(gotLastLocation, 60 * 60 * 1000)) {
44 | // Acquire a reference to the system Location Manager
45 | LocationManager locationManager =
46 | (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
47 | String locationProvider = LocationManager.NETWORK_PROVIDER;
48 |
49 | if (!locationManager.isProviderEnabled(locationProvider))
50 | return;
51 | // Or use LocationManager.GPS_PROVIDER
52 |
53 |
54 | Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);
55 | if (lastKnownLocation == null) {
56 | // Define a listener that responds to location updates
57 | locationListener = new LocationListener() {
58 | public void onLocationChanged(Location location) {
59 | // Called when a new location is found by the network
60 | // location provider.
61 | Editor edit = settings.edit();
62 | edit.putFloat(PebbleNotificationCenter.LATITUDE,
63 | (float) location.getLatitude());
64 | edit.putFloat(PebbleNotificationCenter.LONGITUDE,
65 | (float) location.getLongitude());
66 | edit.putFloat(PebbleNotificationCenter.ALTITUDE,
67 | (float) location.getAltitude());
68 | edit.commit();
69 | gotLastLocation = new Date();
70 | }
71 |
72 | public void onStatusChanged(String provider, int status, Bundle extras) {}
73 |
74 | public void onProviderEnabled(String provider) {}
75 |
76 | public void onProviderDisabled(String provider) {}
77 | };
78 |
79 | // Register the listener with the Location Manager to receive
80 | // location updates
81 | locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
82 | locationListener);
83 | } else {
84 | Editor edit = settings.edit();
85 | edit.putFloat("latitude", (float) lastKnownLocation.getLatitude());
86 | edit.putFloat("longitude", (float) lastKnownLocation.getLongitude());
87 | edit.commit();
88 | }
89 | }
90 | }
91 |
92 | public void close() {
93 | if (locationListener != null) {
94 | LocationManager locationManager =
95 | (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
96 |
97 | if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED)
98 | locationManager.removeUpdates(locationListener);
99 | }
100 | _instance = null;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------