mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
First tasker draft.
This commit is contained in:
parent
c69be1f94b
commit
e860d78e03
@ -24,6 +24,7 @@
|
||||
<uses-permission android:name="cyanogenmod.permission.ACCESS_WEATHER_MANAGER" />
|
||||
<uses-permission android:name="cyanogenmod.permission.READ_WEATHER" />
|
||||
<uses-permission android:name="org.omnirom.omnijaws.READ_WEATHER" />
|
||||
<uses-permission android:name="net.dinglisch.android.tasker.PERMISSION_RUN_TASKS" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.bluetooth"
|
||||
@ -40,8 +41,8 @@
|
||||
android:allowBackup="false"
|
||||
android:fullBackupContent="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:theme="@style/GadgetbridgeTheme">
|
||||
<activity
|
||||
android:name=".activities.ControlCenterv2"
|
||||
@ -66,9 +67,9 @@
|
||||
android:label="@string/activity_summaries"
|
||||
android:parentActivityName=".activities.ControlCenterv2" />
|
||||
<activity
|
||||
android:launchMode="singleTop"
|
||||
android:name=".activities.appmanager.AppManagerActivity"
|
||||
android:label="@string/title_activity_appmanager"
|
||||
android:launchMode="singleTop"
|
||||
android:parentActivityName=".activities.ControlCenterv2" />
|
||||
<activity
|
||||
android:name=".activities.AppBlacklistActivity"
|
||||
@ -319,11 +320,12 @@
|
||||
|
||||
<activity android:name=".externalevents.WeatherNotificationConfig">
|
||||
<intent-filter>
|
||||
<action android:name="ru.gelin.android.weather.notification.ACTION_WEATHER_SKIN_PREFERENCES"/>
|
||||
<action android:name="ru.gelin.android.weather.notification.ACTION_WEATHER_SKIN_PREFERENCES" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver android:name=".externalevents.AutoStartReceiver"
|
||||
<receiver
|
||||
android:name=".externalevents.AutoStartReceiver"
|
||||
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
@ -353,8 +355,8 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:enabled="true"
|
||||
android:name="nodomain.freeyourgadget.gadgetbridge.database.PeriodicExporter"
|
||||
android:enabled="true"
|
||||
android:exported="false">
|
||||
|
||||
</receiver>
|
||||
@ -390,10 +392,10 @@
|
||||
android:label="@string/title_activity_pebble_pairing" />
|
||||
<activity
|
||||
android:name=".devices.watch9.Watch9PairingActivity"
|
||||
android:label="@string/title_activity_watch9_pairing" />
|
||||
android:label="@string/title_activity_watch9_pairing" />
|
||||
<activity
|
||||
android:name=".devices.watch9.Watch9CalibrationActivity"
|
||||
android:label="@string/title_activity_watch9_calibration" />
|
||||
android:label="@string/title_activity_watch9_calibration" />
|
||||
<activity
|
||||
android:name=".activities.charts.ChartsActivity"
|
||||
android:label="@string/title_activity_charts"
|
||||
@ -405,8 +407,8 @@
|
||||
<activity
|
||||
android:name=".activities.AlarmDetails"
|
||||
android:label="@string/title_activity_alarm_details"
|
||||
android:screenOrientation="portrait"
|
||||
android:parentActivityName=".activities.ConfigureAlarms" />
|
||||
android:parentActivityName=".activities.ConfigureAlarms"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activities.VibrationActivity"
|
||||
android:label="@string/title_activity_vibration"
|
||||
@ -442,19 +444,21 @@
|
||||
</receiver>
|
||||
|
||||
<activity
|
||||
android:launchMode="singleTask"
|
||||
android:name=".activities.ExternalPebbleJSActivity"
|
||||
android:allowTaskReparenting="true"
|
||||
android:clearTaskOnLaunch="true"
|
||||
android:name=".activities.ExternalPebbleJSActivity"
|
||||
android:label="@string/app_configure"
|
||||
android:launchMode="singleTask"
|
||||
android:parentActivityName=".activities.appmanager.AppManagerActivity">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="gadgetbridge" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
@ -104,6 +104,17 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
pref = findPreference("tasker");
|
||||
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent enableIntent = new Intent(SettingsActivity.this, MiBandPreferencesActivity.class);
|
||||
startActivity(enableIntent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
pref = findPreference("pref_key_miband");
|
||||
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
@ -284,16 +295,16 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
|
||||
pref = findPreference("weather_city");
|
||||
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
// reset city id and force a new lookup
|
||||
GBApplication.getPrefs().getPreferences().edit().putString("weather_cityid", null).apply();
|
||||
preference.setSummary(newVal.toString());
|
||||
Intent intent = new Intent("GB_UPDATE_WEATHER");
|
||||
intent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intent);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
// reset city id and force a new lookup
|
||||
GBApplication.getPrefs().getPreferences().edit().putString("weather_cityid", null).apply();
|
||||
preference.setSummary(newVal.toString());
|
||||
Intent intent = new Intent("GB_UPDATE_WEATHER");
|
||||
intent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
sendBroadcast(intent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
pref = findPreference(GBPrefs.AUTO_EXPORT_LOCATION);
|
||||
@ -357,7 +368,6 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
pref.setSummary(summary);
|
||||
|
||||
|
||||
|
||||
final Preference displayPages = findPreference("bip_display_items");
|
||||
displayPages.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
@ -563,8 +573,7 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
return cursor.getString(cursor.getColumnIndex(DocumentsContract.Document.COLUMN_DISPLAY_NAME));
|
||||
}
|
||||
}
|
||||
catch (Exception fdfsdfds) {
|
||||
} catch (Exception fdfsdfds) {
|
||||
LOG.warn("fuck");
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.xwatch;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -58,6 +55,8 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSuppo
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.DeviceInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.tasker.TaskerIntent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.tasker.TaskerUtil;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
||||
@ -260,7 +259,7 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
||||
@Override
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
try {
|
||||
if(builder == null) {
|
||||
if (builder == null) {
|
||||
builder = performInitialized("fetchActivityData");
|
||||
}
|
||||
requestSummarizedData(builder);
|
||||
@ -451,7 +450,7 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
if (value[5] == 95) {
|
||||
dayToFetch++;
|
||||
if(dayToFetch <= maxDayToFetch) {
|
||||
if (dayToFetch <= maxDayToFetch) {
|
||||
try {
|
||||
builder = performInitialized("fetchActivityData");
|
||||
requestDetailedData(builder);
|
||||
@ -468,27 +467,29 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
private void handleButtonPressed(byte[] value) {
|
||||
long currentTimestamp = System.currentTimeMillis();
|
||||
TaskerUtil.sendTask();
|
||||
|
||||
AudioManager audioManager = (AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE);
|
||||
if(audioManager.isWiredHeadsetOn()) {
|
||||
if (currentTimestamp - lastButtonTimestamp < 1000) {
|
||||
if (audioManager.isMusicActive()) {
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
} else {
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
}
|
||||
} else {
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
}
|
||||
}
|
||||
/**long currentTimestamp = System.currentTimeMillis();
|
||||
|
||||
lastButtonTimestamp = currentTimestamp;
|
||||
AudioManager audioManager = (AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE);
|
||||
if(audioManager.isWiredHeadsetOn()) {
|
||||
if (currentTimestamp - lastButtonTimestamp < 1000) {
|
||||
if (audioManager.isMusicActive()) {
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
} else {
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
}
|
||||
} else {
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
audioManager.dispatchMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
}
|
||||
}
|
||||
|
||||
lastButtonTimestamp = currentTimestamp;**/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -565,7 +566,7 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
||||
minutes
|
||||
);
|
||||
|
||||
timestamp = (int)(cal.getTimeInMillis() / 1000);
|
||||
timestamp = (int) (cal.getTimeInMillis() / 1000);
|
||||
|
||||
return timestamp;
|
||||
}
|
||||
|
@ -0,0 +1,384 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.tasker;
|
||||
|
||||
public class ActionCodes {
|
||||
|
||||
public static final int NONE = -1;
|
||||
public final static int FIRST_PLUGIN_CODE = 1000; // higher are all plugins
|
||||
|
||||
// Deprecated
|
||||
|
||||
public static final int TEST_OLD = 115;
|
||||
public static final int TAKE_PHOTO_OLD = 10;
|
||||
public static final int TAKE_PHOTO_SERIES_OLD = 11;
|
||||
public static final int TAKE_PHOTO_CHRON_OLD = 12;
|
||||
public static final int LIST_VARIABLES = 594;
|
||||
public static final int TEST_FILE_OLD = 411;
|
||||
public static final int SET_SPEECH_PARAMS = 876;
|
||||
public static final int NOTIFY = 500;
|
||||
public static final int NOTIFY_LED_RED = 510;
|
||||
public static final int NOTIFY_LED_GREEN = 520;
|
||||
public static final int PERMANENT_NOTIFY = 777;
|
||||
public static final int NOTIFY_VIBRATE = 530;
|
||||
public static final int NOTIFY_SOUND = 540;
|
||||
public static final int POPUP_IMAGE_TASK_NAMES = 557;
|
||||
public static final int POPUP_TASK_ICONS = 560;
|
||||
public static final int POPUP_TASK_NAMES = 565;
|
||||
public static final int KEYGUARD_PATTERN = 151;
|
||||
|
||||
public static final int IMPORT_DATA = 153;
|
||||
|
||||
// Active
|
||||
|
||||
public static final int ANCHOR = 300;
|
||||
|
||||
// 4.10
|
||||
public static final int EDIT_TASK = 142;
|
||||
public static final int EDIT_SCENE = 143;
|
||||
public static final int TAKE_SCREENSHOT = 176;
|
||||
public static final int SHOW_TASKER_PREFS = 147;
|
||||
public static final int SHOW_TASKER_RUNLOG = 148;
|
||||
public static final int SET_APP_SHORTCUTS = 161;
|
||||
public static final int SET_QUICK_SETTING = 162;
|
||||
public static final int CANCEL_ALARM = 165;
|
||||
public static final int SHOW_ALARMS = 166;
|
||||
public static final int DIALOG_PRINT_SETTINGS = 239;
|
||||
public static final int DIALOG_NOTIFICATION_LISTENER_SETTINGS = 237;
|
||||
public static final int SCENE_ELEMENT_VIDEO_CONTROL = 612;
|
||||
|
||||
public static final int SET_SMS_APP = 252;
|
||||
public static final int SAY_AFTER = 696;
|
||||
public static final int SHUT_UP = 697;
|
||||
public static final int TORCH = 511;
|
||||
public static final int DPAD = 701;
|
||||
public static final int TYPE = 702;
|
||||
public static final int BUTTON = 703;
|
||||
public static final int NOTIFY_PLAIN = 523;
|
||||
public static final int NOTIFY_LED = 525;
|
||||
public static final int NOTIFY_VIBRATE_2 = 536;
|
||||
public static final int NOTIFY_SOUND_2 = 538;
|
||||
public static final int CANCEL_NOTIFY = 779;
|
||||
public static final int FLASH = 548;
|
||||
public static final int POPUP = 550;
|
||||
public static final int HTML_POPUP = 941;
|
||||
public static final int MENU = 551;
|
||||
public static final int POPUP_TASK_BUTTONS = 552;
|
||||
public static final int SET_ALARM = 566;
|
||||
public static final int START_TIMER = 543;
|
||||
public static final int TIMER_WIDGET_CONTROL = 544;
|
||||
public static final int TIMER_WIDGET_SET = 546;
|
||||
public static final int CALENDAR_INSERT = 567;
|
||||
public static final int REBOOT = 59;
|
||||
public static final int VIBRATE = 61;
|
||||
public static final int MIDI_PLAY = 156;
|
||||
|
||||
public static final int NETWORK_ACCESS = 173;
|
||||
public static final int POWER_MODE = 175;
|
||||
|
||||
public static final int QUICK_SETTING_ADD = 157;
|
||||
public static final int QUICK_SETTING_REMOVE = 158;
|
||||
|
||||
public static final int VIBRATE_PATTERN = 62;
|
||||
public static final int STATUS_BAR = 512;
|
||||
public static final int CLOSE_SYSTEM_DIALOGS = 513;
|
||||
public static final int MICROPHONE_MUTE = 301;
|
||||
public static final int VOLUME_ALARM = 303;
|
||||
public static final int VOLUME_RINGER = 304;
|
||||
public static final int VOLUME_NOTIFICATION = 305;
|
||||
public static final int VOLUME_CALL = 306;
|
||||
public static final int VOLUME_MUSIC = 307;
|
||||
public static final int VOLUME_SYSTEM = 308;
|
||||
public static final int VOLUME_DTMF = 309;
|
||||
public static final int VOLUME_BT_VOICE = 311;
|
||||
public static final int SILENT_MODE = 310;
|
||||
public static final int INTERRUPT_MODE = 312;
|
||||
public static final int SOUND_EFFECTS_ENABLED = 136;
|
||||
public static final int HAPTIC_FEEDBACK = 177;
|
||||
public static final int SPEAKERPHONE_STATUS = 254;
|
||||
public static final int RINGER_VIBRATE = 256;
|
||||
public static final int NOTIFICATION_VIBRATE = 258;
|
||||
public static final int NOTIFICATION_PULSE = 259;
|
||||
public static final int DIALOG_SETTINGS = 200;
|
||||
public static final int QUICK_SETTINGS = 219;
|
||||
public static final int SHOW_RECENTS = 247;
|
||||
public static final int LONG_POWER = 246;
|
||||
public static final int BACK_BUTTON = 245;
|
||||
public static final int TOGGLE_APP_DOCK = 244;
|
||||
public static final int DIALOG_ACCESSIBILITY_SETTINGS = 236;
|
||||
public static final int DIALOG_PRIVACY_SETTINGS = 238;
|
||||
public static final int DIALOG_AIRPLANE_MODE_SETTINGS = 201;
|
||||
public static final int DIALOG_ADD_ACCOUNT_SETTINGS = 199;
|
||||
public static final int DIALOG_APN_SETTINGS = 202;
|
||||
public static final int DIALOG_BATTERY_INFO_SETTINGS = 251;
|
||||
|
||||
public static final int DIALOG_DATE_SETTINGS = 203;
|
||||
public static final int DIALOG_DEVELOPER_SETTINGS = 197;
|
||||
public static final int DIALOG_DEVICE_INFO_SETTINGS = 198;
|
||||
public static final int DIALOG_INTERNAL_STORAGE_SETTINGS = 204;
|
||||
public static final int DIALOG_DEVELOPMENT_SETTINGS = 205;
|
||||
public static final int DIALOG_WIFI_SETTINGS = 206;
|
||||
public static final int DIALOG_LOCATION_SOURCE_SETTINGS = 208;
|
||||
public static final int DIALOG_INPUT_METHOD_SETTINGS = 210;
|
||||
public static final int DIALOG_SYNC_SETTINGS = 211;
|
||||
public static final int DIALOG_NFC_SETTINGS = 956;
|
||||
public static final int DIALOG_NFC_SHARING_SETTINGS = 957;
|
||||
public static final int DIALOG_NFC_PAYMENT_SETTINGS = 958;
|
||||
public static final int DIALOG_DREAM_SETTINGS = 959;
|
||||
public static final int DIALOG_WIFI_IP_SETTINGS = 212;
|
||||
public static final int DIALOG_WIRELESS_SETTINGS = 214;
|
||||
public static final int DIALOG_APPLICATION_SETTINGS = 216;
|
||||
public static final int DIALOG_BLUETOOTH_SETTINGS = 218;
|
||||
public static final int DIALOG_ROAMING_SETTINGS = 220;
|
||||
public static final int DIALOG_DISPLAY_SETTINGS = 222;
|
||||
public static final int DIALOG_LOCALE_SETTINGS = 224;
|
||||
public static final int DIALOG_MANAGE_APPLICATION_SETTINGS = 226;
|
||||
public static final int DIALOG_MEMORY_CARD_SETTINGS = 227;
|
||||
public static final int DIALOG_NETWORK_OPERATOR_SETTINGS = 228;
|
||||
public static final int DIALOG_POWER_USAGE_SETTINGS = 257;
|
||||
public static final int DIALOG_QUICK_LAUNCH_SETTINGS = 229;
|
||||
public static final int DIALOG_SECURITY_SETTINGS = 230;
|
||||
public static final int DIALOG_SEARCH_SETTINGS = 231;
|
||||
public static final int DIALOG_SOUND_SETTINGS = 232;
|
||||
public static final int DIALOG_USER_DICTIONARY_SETTINGS = 234;
|
||||
public static final int INPUT_METHOD_SELECT = 804;
|
||||
public static final int POKE_DISPLAY = 806;
|
||||
public static final int SCREEN_BRIGHTNESS_AUTO = 808;
|
||||
public static final int SCREEN_BRIGHTNESS = 810;
|
||||
public static final int SCREEN_OFF_TIMEOUT = 812;
|
||||
public static final int ACCELEROMETER_ROTATION = 822;
|
||||
public static final int STAY_ON_WHILE_PLUGGED_IN = 820;
|
||||
public static final int KEYGUARD_ENABLED = 150;
|
||||
|
||||
public static final int SQL_QUERY = 667;
|
||||
|
||||
public static final int LOCK = 15;
|
||||
public static final int SYSTEM_LOCK = 16;
|
||||
public static final int SHOW_SOFT_KEYBOARD = 987;
|
||||
public static final int CAR_MODE = 988;
|
||||
public static final int NIGHT_MODE = 989;
|
||||
public static final int SET_LIGHT = 999;
|
||||
public static final int READ_BINARY = 776;
|
||||
public static final int WRITE_BINARY = 775;
|
||||
public static final int READ_LINE = 415;
|
||||
public static final int READ_PARA = 416;
|
||||
public static final int READ_FILE = 417;
|
||||
public static final int MOVE_FILE = 400;
|
||||
public static final int COPY_FILE = 404;
|
||||
public static final int COPY_DIR = 405;
|
||||
public static final int DELETE_FILE = 406;
|
||||
public static final int DELETE_DIR = 408;
|
||||
public static final int MAKE_DIR = 409;
|
||||
public static final int WRITE_TO_FILE = 410;
|
||||
public static final int LIST_FILES = 412;
|
||||
public static final int LIST_APPS = 815;
|
||||
public static final int ZIP_FILE = 420;
|
||||
public static final int UNZIP_FILE = 422;
|
||||
public static final int GZIP_FILE = 475;
|
||||
public static final int GUNZIP_FILE = 476;
|
||||
public static final int VIEW_FILE = 102;
|
||||
public static final int BROWSE_FILES = 900;
|
||||
public static final int GET_FIX = 902;
|
||||
public static final int STOP_FIX = 901;
|
||||
public static final int GET_VOICE = 903;
|
||||
public static final int VOICE_COMMAND = 904;
|
||||
public static final int LOAD_IMAGE = 188;
|
||||
public static final int SAVE_IMAGE = 187;
|
||||
public static final int RESIZE_IMAGE = 193;
|
||||
public static final int ROTATE_IMAGE = 191;
|
||||
public static final int FLIP_IMAGE = 190;
|
||||
public static final int FILTER_IMAGE = 185;
|
||||
public static final int CROP_IMAGE = 189;
|
||||
public static final int TAKE_PHOTO_TWO = 101;
|
||||
|
||||
public static final int ENCRYPT_FILE = 434;
|
||||
public static final int DECRYPT_FILE = 435;
|
||||
public static final int ENTER_PASSPHRASE = 436;
|
||||
public static final int CLEAR_PASSPHRASE = 437;
|
||||
public static final int SET_PASSPHRASE = 423;
|
||||
public static final int ENCRYPT_DIR = 428;
|
||||
public static final int DECRYPT_DIR = 429;
|
||||
public static final int KILL_APP = 18;
|
||||
public static final int LOAD_APP = 20;
|
||||
public static final int LOAD_LAST_APP = 22;
|
||||
public static final int SETCPU = 915;
|
||||
public static final int GO_HOME = 25;
|
||||
public static final int WAIT = 30;
|
||||
public static final int WAIT_UNTIL = 35;
|
||||
public static final int IF = 37;
|
||||
public static final int ENDIF = 38;
|
||||
public static final int ELSE = 43;
|
||||
public static final int FOR = 39;
|
||||
public static final int ENDFOR = 40;
|
||||
public static final int SEARCH = 100;
|
||||
public static final int RUN_SCRIPT = 112;
|
||||
public static final int JAVASCRIPTLET = 129;
|
||||
public static final int JAVASCRIPT = 131;
|
||||
public static final int JAVA_FUNC = 664;
|
||||
public static final int JAVA_OBJECT = 665;
|
||||
public static final int RUN_SHELL = 123;
|
||||
public static final int REMOUNT = 124;
|
||||
public static final int RETURN = 126;
|
||||
|
||||
public static final int TEST_NET = 341;
|
||||
public static final int TEST_FILE = 342;
|
||||
public static final int TEST_MEDIA = 343;
|
||||
public static final int TEST_APP = 344;
|
||||
public static final int TEST_VARIABLE = 345;
|
||||
public static final int TEST_PHONE = 346;
|
||||
public static final int TEST_TASKER = 347;
|
||||
public static final int TEST_DISPLAY = 348;
|
||||
public static final int TEST_SYSTEM = 349;
|
||||
|
||||
public static final int TEST_SCENE = 194;
|
||||
public static final int SCENE_ELEMENT_TEST = 195;
|
||||
|
||||
public static final int SAY = 559;
|
||||
public static final int SAY_TO_FILE = 699;
|
||||
public static final int SEND_INTENT = 877;
|
||||
public static final int VIEW_URL = 104;
|
||||
public static final int SHARE_FILE = 376;
|
||||
public static final int SET_CLIPBOARD = 105;
|
||||
public static final int SET_WALLPAPER = 109;
|
||||
public static final int HTTP_GET = 118;
|
||||
public static final int HTTP_POST = 116;
|
||||
public static final int HTTP_HEAD = 117;
|
||||
public static final int OPEN_MAP = 119;
|
||||
public static final int ANDROID_MEDIA_CONTROL = 443;
|
||||
public static final int GRAB_MEDIA_BUTTON = 490;
|
||||
public static final int PLAY_RINGTONE = 192;
|
||||
public static final int BEEP = 171;
|
||||
public static final int MORSE = 172;
|
||||
public static final int MUSIC_PLAY = 445;
|
||||
public static final int MUSIC_PLAY_DIR = 447;
|
||||
public static final int MUSIC_STOP = 449;
|
||||
public static final int MUSIC_FORWARD = 451;
|
||||
public static final int MUSIC_BACK = 453;
|
||||
public static final int SCAN_CARD = 459;
|
||||
public static final int RINGTONE = 457;
|
||||
public static final int SOUND_RECORD = 455;
|
||||
public static final int SOUND_RECORD_STOP = 657;
|
||||
public static final int AUTO_SYNC = 331;
|
||||
public static final int AIRPLANE_MODE = 333;
|
||||
public static final int GPS_STATUS = 332;
|
||||
public static final int BLUETOOTH_STATUS = 294;
|
||||
public static final int BLUETOOTH_NAME = 295;
|
||||
public static final int BLUETOOTH_SCO = 296;
|
||||
public static final int BLOCK_CALLS = 95;
|
||||
public static final int DIVERT_CALLS = 97;
|
||||
public static final int REVERT_CALLS = 99;
|
||||
public static final int CONTACTS = 909;
|
||||
public static final int CALL_LOG = 910;
|
||||
public static final int EMAIL_COMPOSE = 125;
|
||||
public static final int SMS_COMPOSE = 250;
|
||||
public static final int MMS_COMPOSE = 111;
|
||||
public static final int TETHER_WIFI = 113;
|
||||
public static final int TETHER_USB = 114;
|
||||
public static final int TAKE_CALL = 731;
|
||||
public static final int RADIO_STATUS = 732;
|
||||
public static final int END_CALL = 733;
|
||||
public static final int SILENCE_RINGER = 734;
|
||||
public static final int MOBILE_NETWORK_MODE = 735;
|
||||
public static final int MAKE_PHONECALL = 90;
|
||||
public static final int MOBILE_DATA_STATUS = 450;
|
||||
public static final int MOBILE_DATA_STATUS_DIRECT = 433;
|
||||
public static final int SEND_TEXT_SMS = 41;
|
||||
public static final int SEND_DATA_SMS = 42;
|
||||
public static final int AIRPLANE_RADIOS = 323;
|
||||
public static final int WIFI_STATUS = 425;
|
||||
public static final int WIFI_NET_CONTROL = 426;
|
||||
public static final int WIFI_SLEEP_POLICY = 427;
|
||||
public static final int WIMAX_STATUS = 439;
|
||||
public static final int SET_TIMEZONE = 440;
|
||||
public static final int CHANGE_ICON_SET = 140;
|
||||
public static final int CHANGE_WIDGET_TEXT = 155;
|
||||
public static final int CHANGE_WIDGET_ICON = 152;
|
||||
public static final int TOGGLE_PROFILE = 159;
|
||||
public static final int QUERY_ACTION = 134;
|
||||
public static final int RUN_TASK = 130;
|
||||
public static final int GOTO = 135;
|
||||
public static final int STOP = 137;
|
||||
public static final int DISABLE_TASKER = 139;
|
||||
|
||||
public static final int SET_TASKER_ICON = 138;
|
||||
public static final int SET_TASKER_PREF = 133;
|
||||
public static final int CREATE_SCENE = 46;
|
||||
public static final int SHOW_SCENE = 47;
|
||||
public static final int HIDE_SCENE = 48;
|
||||
public static final int DESTROY_SCENE = 49;
|
||||
public static final int SCENE_ELEMENT_VALUE = 50;
|
||||
public static final int SCENE_ELEMENT_FOCUS = 68;
|
||||
public static final int SCENE_ELEMENT_TEXT = 51;
|
||||
public static final int SCENE_ELEMENT_TEXT_COLOUR = 54;
|
||||
public static final int SCENE_ELEMENT_TEXT_SIZE = 71;
|
||||
public static final int SCENE_ELEMENT_BACKGROUND_COLOUR = 55;
|
||||
public static final int SCENE_ELEMENT_BORDER = 56;
|
||||
public static final int SCENE_ELEMENT_POSITION = 57;
|
||||
public static final int SCENE_ELEMENT_SIZE = 58;
|
||||
public static final int SCENE_ELEMENT_ADD_GEOMARKER = 60;
|
||||
public static final int SCENE_ELEMENT_DELETE_GEOMARKER = 63;
|
||||
public static final int SCENE_ELEMENT_WEB_CONTROL = 53;
|
||||
public static final int SCENE_ELEMENT_MAP_CONTROL = 64;
|
||||
public static final int SCENE_ELEMENT_VISIBILITY = 65;
|
||||
public static final int SCENE_ELEMENT_CREATE = 69;
|
||||
public static final int SCENE_ELEMENT_DESTROY = 73;
|
||||
public static final int SCENE_ELEMENT_IMAGE = 66;
|
||||
public static final int SCENE_ELEMENT_DEPTH = 67;
|
||||
public static final int ARRAY_PUSH = 355;
|
||||
public static final int ARRAY_SET = 354;
|
||||
public static final int ARRAY_PROCESS = 369;
|
||||
public static final int ARRAY_POP = 356;
|
||||
public static final int ARRAY_CLEAR = 357;
|
||||
public static final int SET_VARIABLE = 547;
|
||||
public static final int SET_VARIABLE_RANDOM = 545;
|
||||
public static final int INC_VARIABLE = 888;
|
||||
public static final int DEC_VARIABLE = 890;
|
||||
public static final int CLEAR_VARIABLE = 549;
|
||||
public static final int SPLIT_VARIABLE = 590;
|
||||
public static final int JOIN_VARIABLE = 592;
|
||||
public static final int QUERY_VARIABLE = 595;
|
||||
public static final int CONVERT_VARIABLE = 596;
|
||||
public static final int SECTION_VARIABLE = 597;
|
||||
public static final int SEARCH_REPLACE_VARIABLE = 598;
|
||||
public static final int ASTRID = 371;
|
||||
public static final int BEYONDPOD = 555;
|
||||
public static final int DAILYROADS = 568;
|
||||
public static final int DUETODAY = 599;
|
||||
public static final int ANDROID_NOTIFIER = 558;
|
||||
public static final int NEWSROB = 556;
|
||||
public static final int OFFICETALK = 643;
|
||||
public static final int JUICE_DEFENDER_DATA = 456;
|
||||
public static final int JUICE_DEFENDER_STATUS = 395;
|
||||
public static final int SLEEPBOT = 442;
|
||||
public static final int SMSBACKUP = 553;
|
||||
public static final int TESLALED = 444;
|
||||
public static final int WIDGETLOCKER = 458;
|
||||
public static final int GENTLEALARM = 911;
|
||||
public static final int ZOOM_ELEMENT_STATE = 793;
|
||||
public static final int ZOOM_ELEMENT_POSITION = 794;
|
||||
public static final int ZOOM_ELEMENT_SIZE = 795;
|
||||
public static final int ZOOM_ELEMENT_VISIBILITY = 721;
|
||||
public static final int ZOOM_ELEMENT_ALPHA = 760;
|
||||
public static final int ZOOM_ELEMENT_IMAGE = 761;
|
||||
public static final int ZOOM_ELEMENT_COLOUR = 762;
|
||||
public static final int ZOOM_ELEMENT_TEXT = 740;
|
||||
public static final int ZOOM_ELEMENT_TEXT_SIZE = 741;
|
||||
public static final int ZOOM_ELEMENT_TEXT_COLOUR = 742;
|
||||
|
||||
|
||||
//joaomgcd
|
||||
public static final int ACCESSIBILITY_LOCK_SCREEN = 248;
|
||||
public static final int ACCESSIBILITY_TAKE_SCREENSHOT = 249;
|
||||
public static final int SECURE_SETTING = 235;
|
||||
public static final int LOCATION_MODE = 905;
|
||||
public static final int IMMERSIVE_MODE = 906;
|
||||
public static final int HIDE_STATUS_BAR_ICONS = 907;
|
||||
public static final int RINGER_MODE = 313;
|
||||
public static final int AUTHENTICATION_DIALOG = 314;
|
||||
public static final int ENABLE_DISABLE_APP = 315;
|
||||
public static final int DISPLAY_DENSITY = 316;
|
||||
public static final int NFC_STATUS = 317;
|
||||
public static final int FORCE_ROTATION = 318;
|
||||
public static final int ASK_PERMISSION = 319;
|
||||
public static final int PING = 320;
|
||||
public static final int GOOGLE_DRIVE_UPLOAD_FILE = 321;
|
||||
public static final int DATA_BACKUP = 322;
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.tasker;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.MultiSelectListPreference;
|
||||
import android.preference.Preference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBEnvironment;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceService;
|
||||
|
||||
public class TaskerActivity extends AbstractSettingsActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
List<String> devices = new ArrayList<>();
|
||||
for (GBDevice device : GBApplication.app().getDeviceManager().getDevices()) {
|
||||
devices.add(device.getAddress());
|
||||
}
|
||||
|
||||
MultiSelectListPreference actives = (MultiSelectListPreference) findPreference(TaskerPrefs.TASKER_ACTIVE_LIST);
|
||||
actives.setEntries(devices.toArray(new String[]{}));
|
||||
// add activity
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
@ -0,0 +1,449 @@
|
||||
// Version 1.3.3
|
||||
|
||||
// Changelog
|
||||
|
||||
// Version 1.3.3
|
||||
// - increased MAX_NO_ARGS to 10
|
||||
|
||||
// Version 1.3.2
|
||||
// - bug setting app arg
|
||||
// - pulled provider column names out of function
|
||||
|
||||
// For usage examples see http://tasker.dinglisch.net/invoketasks.html
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.tasker;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PatternMatcher;
|
||||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
|
||||
public class TaskerIntent extends Intent {
|
||||
|
||||
// 3 Tasker versions
|
||||
public final static String TASKER_PACKAGE = "net.dinglisch.android.tasker";
|
||||
public final static String TASKER_PACKAGE_MARKET = TASKER_PACKAGE + "m";
|
||||
public final static String TASKER_PACKAGE_CUPCAKE = TASKER_PACKAGE + "cupcake";
|
||||
|
||||
// Play Store download URLs
|
||||
public final static String MARKET_DOWNLOAD_URL_PREFIX = "market://details?id=";
|
||||
private final static String TASKER_MARKET_URL = MARKET_DOWNLOAD_URL_PREFIX + TASKER_PACKAGE_MARKET;
|
||||
private final static String TASKER_MARKET_URL_CUPCAKE = MARKET_DOWNLOAD_URL_PREFIX + TASKER_PACKAGE_CUPCAKE;
|
||||
|
||||
// Direct-purchase version
|
||||
private final static String TASKER_DOWNLOAD_URL = "http://tasker.dinglisch.net/download.html";
|
||||
|
||||
// Intent actions
|
||||
public final static String ACTION_TASK = TASKER_PACKAGE + ".ACTION_TASK";
|
||||
public final static String ACTION_TASK_COMPLETE = TASKER_PACKAGE + ".ACTION_TASK_COMPLETE";
|
||||
public final static String ACTION_TASK_SELECT = TASKER_PACKAGE + ".ACTION_TASK_SELECT";
|
||||
|
||||
// Intent parameters
|
||||
public final static String EXTRA_ACTION_INDEX_PREFIX = "action";
|
||||
public final static String TASK_NAME_DATA_SCHEME = "task";
|
||||
public final static String EXTRA_TASK_NAME = "task_name";
|
||||
public final static String EXTRA_TASK_PRIORITY = "task_priority";
|
||||
public final static String EXTRA_SUCCESS_FLAG = "success";
|
||||
public final static String EXTRA_VAR_NAMES_LIST = "varNames";
|
||||
public final static String EXTRA_VAR_VALUES_LIST = "varValues";
|
||||
public final static String EXTRA_TASK_OUTPUT = "output";
|
||||
|
||||
// Content provider columns
|
||||
public static final String PROVIDER_COL_NAME_EXTERNAL_ACCESS = "ext_access";
|
||||
public static final String PROVIDER_COL_NAME_ENABLED = "enabled";
|
||||
|
||||
// DEPRECATED, use EXTRA_VAR_NAMES_LIST, EXTRA_VAR_VALUES_LIST
|
||||
public final static String EXTRA_PARAM_LIST = "params";
|
||||
|
||||
// Intent data
|
||||
|
||||
public final static String TASK_ID_SCHEME = "id";
|
||||
|
||||
// For particular actions
|
||||
|
||||
public final static String DEFAULT_ENCRYPTION_KEY= "default";
|
||||
public final static String ENCRYPTED_AFFIX = "tec";
|
||||
public final static int MAX_NO_ARGS = 10;
|
||||
|
||||
// Bundle keys
|
||||
// Only useful for Tasker
|
||||
public final static String ACTION_CODE = "action";
|
||||
public final static String APP_ARG_PREFIX = "app:";
|
||||
public final static String ICON_ARG_PREFIX = "icn:";
|
||||
public final static String ARG_INDEX_PREFIX = "arg:";
|
||||
public static final String PARAM_VAR_NAME_PREFIX = "par";
|
||||
|
||||
// Misc
|
||||
private final static String PERMISSION_RUN_TASKS = TASKER_PACKAGE + ".PERMISSION_RUN_TASKS";
|
||||
|
||||
public final static String ACTION_OPEN_PREFS = TASKER_PACKAGE + ".ACTION_OPEN_PREFS";
|
||||
public final static String EXTRA_OPEN_PREFS_TAB_NO = "tno";
|
||||
private final static int MISC_PREFS_TAB_NO = 3; // 0 based
|
||||
|
||||
// To query whether Tasker is enabled and external access is enabled
|
||||
private final static String TASKER_PREFS_URI = "content://" + TASKER_PACKAGE + "/prefs";
|
||||
|
||||
private final static int CUPCAKE_SDK_VERSION = 3;
|
||||
|
||||
// result values for TestSend
|
||||
|
||||
// NotInstalled: Tasker package not found on device
|
||||
// NoPermission: calling app does not have permission PERMISSION_RUN_TASKS
|
||||
// NotEnabled: Tasker is not enabled
|
||||
// AccessBlocked: user prefs disallow external access
|
||||
// NoReceiver: Tasker has not created a listener for external access (probably a Tasker bug)
|
||||
// OK: you should be able to send a task to run. Still need to listen for result
|
||||
// for e.g. task not found
|
||||
|
||||
public static enum Status { NotInstalled, NoPermission, NotEnabled, AccessBlocked, NoReceiver, OK };
|
||||
|
||||
// -------------------------- PRIVATE VARS ---------------------------- //
|
||||
|
||||
private final static String TAG = "TaskerIntent";
|
||||
|
||||
private final static String EXTRA_INTENT_VERSION_NUMBER = "version_number";
|
||||
private final static String INTENT_VERSION_NUMBER = "1.1";
|
||||
|
||||
// Inclusive values
|
||||
private final static int MIN_PRIORITY = 0;
|
||||
private final static int MAX_PRIORITY = 10;
|
||||
|
||||
// For generating random names
|
||||
private static Random rand = new Random();
|
||||
|
||||
// Tracking state
|
||||
private int actionCount = 0;
|
||||
private int argCount;
|
||||
|
||||
// -------------------------- PUBLIC METHODS ---------------------------- //
|
||||
|
||||
public static int getMaxPriority() {
|
||||
return MAX_PRIORITY;
|
||||
}
|
||||
|
||||
public static boolean validatePriority( int pri ) {
|
||||
return (
|
||||
( pri >= MIN_PRIORITY ) ||
|
||||
( pri <= MAX_PRIORITY )
|
||||
);
|
||||
}
|
||||
|
||||
// Tasker has different package names for Play Store and non- versions
|
||||
// for historical reasons
|
||||
|
||||
public static String getInstalledTaskerPackage( Context context ) {
|
||||
|
||||
String foundPackage = null;
|
||||
|
||||
try {
|
||||
context.getPackageManager().getPackageInfo( TASKER_PACKAGE, 0 );
|
||||
foundPackage = TASKER_PACKAGE;
|
||||
}
|
||||
catch ( PackageManager.NameNotFoundException e ) {
|
||||
}
|
||||
|
||||
try {
|
||||
context.getPackageManager().getPackageInfo( TASKER_PACKAGE_MARKET, 0 );
|
||||
foundPackage = TASKER_PACKAGE_MARKET;
|
||||
}
|
||||
catch ( PackageManager.NameNotFoundException e ) {
|
||||
}
|
||||
|
||||
return foundPackage;
|
||||
}
|
||||
|
||||
// test we can send a TaskerIntent to Tasker
|
||||
// use *before* sending an intent
|
||||
// still need to test the *result after* sending intent
|
||||
|
||||
public static Status testStatus( Context c ) {
|
||||
|
||||
Status result;
|
||||
|
||||
if ( ! taskerInstalled( c ) )
|
||||
result = Status.NotInstalled;
|
||||
else if ( ! havePermission( c ) )
|
||||
result = Status.NoPermission;
|
||||
else if ( ! TaskerIntent.prefSet( c, PROVIDER_COL_NAME_ENABLED ) )
|
||||
result = Status.NotEnabled;
|
||||
else if ( ! TaskerIntent.prefSet( c, PROVIDER_COL_NAME_EXTERNAL_ACCESS ) )
|
||||
result = Status.AccessBlocked;
|
||||
else if ( ! new TaskerIntent( "" ).receiverExists( c ) )
|
||||
result = Status.NoReceiver;
|
||||
else
|
||||
result = Status.OK;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check if Tasker installed
|
||||
|
||||
public static boolean taskerInstalled( Context context ) {
|
||||
return ( getInstalledTaskerPackage( context ) != null );
|
||||
}
|
||||
|
||||
// Use with startActivity to retrieve Tasker from Android market
|
||||
public static Intent getTaskerInstallIntent( boolean marketFlag ) {
|
||||
|
||||
return new Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse(
|
||||
marketFlag ?
|
||||
( ( SDKVersion() == CUPCAKE_SDK_VERSION ) ? TASKER_MARKET_URL_CUPCAKE : TASKER_MARKET_URL ) :
|
||||
TASKER_DOWNLOAD_URL
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int SDKVersion() {
|
||||
try {
|
||||
Field f = android.os.Build.VERSION.class.getField( "SDK_INT" );
|
||||
return f.getInt( null );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
return CUPCAKE_SDK_VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
public static IntentFilter getCompletionFilter( String taskName ) {
|
||||
|
||||
IntentFilter filter = new IntentFilter( TaskerIntent.ACTION_TASK_COMPLETE );
|
||||
|
||||
filter.addDataScheme( TASK_NAME_DATA_SCHEME );
|
||||
filter.addDataPath( taskName, PatternMatcher.PATTERN_LITERAL );
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
public static Intent getTaskSelectIntent() {
|
||||
return new Intent( ACTION_TASK_SELECT ).
|
||||
setFlags(
|
||||
Intent.FLAG_ACTIVITY_NO_USER_ACTION |
|
||||
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS |
|
||||
Intent.FLAG_ACTIVITY_NO_HISTORY
|
||||
);
|
||||
}
|
||||
|
||||
// public access deprecated, use TaskerIntent.testSend() instead
|
||||
|
||||
public static boolean havePermission( Context c ) {
|
||||
return c.checkPermission( PERMISSION_RUN_TASKS, Process.myPid(), Process.myUid() ) ==
|
||||
PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
// Get an intent that will bring up the Tasker prefs screen with the External Access control(s)
|
||||
// Probably you want to use startActivity or startActivityForResult with it
|
||||
|
||||
public static Intent getExternalAccessPrefsIntent() {
|
||||
return new Intent( ACTION_OPEN_PREFS ).putExtra( EXTRA_OPEN_PREFS_TAB_NO, MISC_PREFS_TAB_NO );
|
||||
}
|
||||
|
||||
// ------------------------------------- INSTANCE METHODS ----------------------------- //
|
||||
|
||||
public TaskerIntent() {
|
||||
super( ACTION_TASK );
|
||||
setRandomData();
|
||||
putMetaExtras( getRandomString() );
|
||||
}
|
||||
|
||||
public TaskerIntent( String taskName ) {
|
||||
super( ACTION_TASK );
|
||||
setRandomData();
|
||||
putMetaExtras( taskName );
|
||||
}
|
||||
|
||||
public TaskerIntent setTaskPriority( int priority ) {
|
||||
|
||||
if ( validatePriority( priority ) )
|
||||
putExtra( EXTRA_TASK_PRIORITY, priority );
|
||||
else
|
||||
Log.e( TAG, "priority out of range: " + MIN_PRIORITY + ":" + MAX_PRIORITY );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// Sets subsequently %par1, %par2 etc
|
||||
public TaskerIntent addParameter( String value ) {
|
||||
|
||||
int index = 1;
|
||||
|
||||
if ( getExtras().containsKey( EXTRA_VAR_NAMES_LIST ) )
|
||||
index = getExtras().getStringArrayList( EXTRA_VAR_NAMES_LIST ).size() + 1;
|
||||
|
||||
Log.d(TAG, "index: " + index );
|
||||
|
||||
addLocalVariable( "%" + PARAM_VAR_NAME_PREFIX + index, value );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// Arbitrary specification of (local) variable names and values
|
||||
public TaskerIntent addLocalVariable( String name, String value ) {
|
||||
|
||||
ArrayList<String> names, values;
|
||||
|
||||
if ( hasExtra( EXTRA_VAR_NAMES_LIST ) ) {
|
||||
names = getStringArrayListExtra( EXTRA_VAR_NAMES_LIST );
|
||||
values = getStringArrayListExtra( EXTRA_VAR_VALUES_LIST );
|
||||
}
|
||||
else {
|
||||
names = new ArrayList<String>();
|
||||
values = new ArrayList<String>();
|
||||
|
||||
putStringArrayListExtra( EXTRA_VAR_NAMES_LIST, names );
|
||||
putStringArrayListExtra( EXTRA_VAR_VALUES_LIST, values );
|
||||
}
|
||||
|
||||
names.add( name );
|
||||
values.add( value );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskerIntent addAction( int code ) {
|
||||
|
||||
actionCount++;
|
||||
argCount = 1;
|
||||
|
||||
Bundle actionBundle = new Bundle();
|
||||
|
||||
actionBundle.putInt( ACTION_CODE, code );
|
||||
|
||||
// Add action bundle to intent
|
||||
putExtra( EXTRA_ACTION_INDEX_PREFIX + Integer.toString( actionCount ), actionBundle );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// string arg
|
||||
public TaskerIntent addArg( String arg ) {
|
||||
|
||||
Bundle b = getActionBundle();
|
||||
|
||||
if ( b != null )
|
||||
b.putString( ARG_INDEX_PREFIX + Integer.toString( argCount++ ), arg );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// int arg
|
||||
public TaskerIntent addArg( int arg ) {
|
||||
Bundle b = getActionBundle();
|
||||
|
||||
if ( b != null )
|
||||
b.putInt( ARG_INDEX_PREFIX + Integer.toString( argCount++ ), arg );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// boolean arg
|
||||
public TaskerIntent addArg( boolean arg ) {
|
||||
Bundle b = getActionBundle();
|
||||
|
||||
if ( b != null )
|
||||
b.putBoolean( ARG_INDEX_PREFIX + Integer.toString( argCount++ ), arg );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// Application arg
|
||||
public TaskerIntent addArg( String pkg, String cls ) {
|
||||
Bundle b = getActionBundle();
|
||||
|
||||
if ( b != null ) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append( APP_ARG_PREFIX ).
|
||||
append( pkg ). append( "," ). append( cls );
|
||||
b.putString( ARG_INDEX_PREFIX + Integer.toString( argCount++ ), builder.toString() );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntentFilter getCompletionFilter() {
|
||||
return getCompletionFilter( getTaskName() );
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return getStringExtra( EXTRA_TASK_NAME );
|
||||
}
|
||||
|
||||
public boolean receiverExists( Context context ) {
|
||||
List<ResolveInfo> recs = context.getPackageManager().queryBroadcastReceivers( this, 0 );
|
||||
return (
|
||||
( recs != null ) &&
|
||||
( recs.size() > 0 )
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------- PRIVATE METHODS -------------------- //
|
||||
|
||||
private String getRandomString() {
|
||||
return Long.toString( rand.nextLong() );
|
||||
}
|
||||
|
||||
// so that if multiple TaskerIntents are used in PendingIntents there's virtually no
|
||||
// clash chance
|
||||
private void setRandomData() {
|
||||
setData( Uri.parse( TASK_ID_SCHEME + ":" + getRandomString() ) );
|
||||
}
|
||||
|
||||
private Bundle getActionBundle() {
|
||||
|
||||
Bundle toReturn = null;
|
||||
|
||||
if ( argCount > MAX_NO_ARGS )
|
||||
Log.e( TAG, "maximum number of arguments exceeded (" + MAX_NO_ARGS + ")" );
|
||||
else {
|
||||
String key = EXTRA_ACTION_INDEX_PREFIX + Integer.toString( actionCount );
|
||||
|
||||
if ( this.hasExtra( key ) )
|
||||
toReturn = getBundleExtra( key );
|
||||
else
|
||||
Log.e( TAG, "no actions added yet" );
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private void putMetaExtras( String taskName ) {
|
||||
putExtra( EXTRA_INTENT_VERSION_NUMBER, INTENT_VERSION_NUMBER );
|
||||
putExtra( EXTRA_TASK_NAME, taskName );
|
||||
}
|
||||
|
||||
// for testing that Tasker is enabled and external access is allowed
|
||||
|
||||
private static boolean prefSet( Context context, String col ) {
|
||||
|
||||
String [] proj = new String [] { col };
|
||||
|
||||
Cursor c = context.getContentResolver().query( Uri.parse( TASKER_PREFS_URI ), proj, null, null, null );
|
||||
|
||||
boolean acceptingFlag = false;
|
||||
|
||||
if ( c == null )
|
||||
Log.w( TAG, "no cursor for " + TASKER_PREFS_URI );
|
||||
else {
|
||||
c.moveToFirst();
|
||||
|
||||
if ( Boolean.TRUE.toString().equals( c.getString( 0 ) ) )
|
||||
acceptingFlag = true;
|
||||
|
||||
c.close();
|
||||
}
|
||||
|
||||
return acceptingFlag;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.tasker;
|
||||
|
||||
public class TaskerPrefs {
|
||||
|
||||
public static final String TASKER_ACTIVE = "tasker-active";
|
||||
public static final String TASKER_ACTIVE_LIST = "tasker-active-list";
|
||||
public static final String TASKER_TASK = "tasker-task";
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.tasker;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
|
||||
public class TaskerUtil {
|
||||
|
||||
public static boolean sendTask() {
|
||||
|
||||
if (TaskerIntent.testStatus(GBApplication.getContext()).equals(TaskerIntent.Status.OK) || GBApplication.getPrefs().getBoolean(TaskerPrefs.TASKER_ACTIVE, true)) {
|
||||
String task = GBApplication.getPrefs().getString(TaskerPrefs.TASKER_TASK, "watch");
|
||||
if (task != null) {
|
||||
GBApplication.getContext().sendBroadcast(new TaskerIntent(task));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user