diff --git a/app/build.gradle b/app/build.gradle index 220c549..39d26e8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { compileSdkVersion 33 buildToolsVersion '29.0.2' useLibrary 'org.apache.http.legacy' - versionCode 142 - versionName "1.8.1" + versionCode 143 + versionName "1.8.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/jens/automation2/Action.java b/app/src/main/java/com/jens/automation2/Action.java index 4800146..4e67137 100644 --- a/app/src/main/java/com/jens/automation2/Action.java +++ b/app/src/main/java/com/jens/automation2/Action.java @@ -33,13 +33,9 @@ public class Action setWifiTethering, setBluetoothTethering, setDisplayRotation, - turnWifiOn,turnWifiOff, - turnBluetoothOn,turnBluetoothOff, triggerUrl, changeSoundProfile, turnUsbTetheringOn,turnUsbTetheringOff, - turnWifiTetheringOn,turnWifiTetheringOff, - enableScreenRotation,disableScreenRotation, startOtherActivity, waitBeforeNextAction, turnScreenOnOrOff, @@ -60,9 +56,9 @@ public class Action startPhoneCall, stopPhoneCall, copyToClipboard, - takeScreenshot, setLocationService, - sendTextMessage; + sendTextMessage, + takeScreenshot; public String getFullName(Context context) { @@ -80,14 +76,6 @@ public class Action return context.getResources().getString(R.string.actionSetUsbTethering); case setDisplayRotation: return context.getResources().getString(R.string.actionSetDisplayRotation); - case turnWifiOn: - return context.getResources().getString(R.string.actionTurnWifiOn); - case turnWifiOff: - return context.getResources().getString(R.string.actionTurnWifiOff); - case turnBluetoothOn: - return context.getResources().getString(R.string.actionTurnBluetoothOn); - case turnBluetoothOff: - return context.getResources().getString(R.string.actionTurnBluetoothOff); case triggerUrl: return context.getResources().getString(R.string.actionTriggerUrl); case changeSoundProfile: @@ -96,14 +84,6 @@ public class Action return context.getResources().getString(R.string.actionTurnUsbTetheringOn); case turnUsbTetheringOff: return context.getResources().getString(R.string.actionTurnUsbTetheringOff); - case turnWifiTetheringOn: - return context.getResources().getString(R.string.actionTurnWifiTetheringOn); - case turnWifiTetheringOff: - return context.getResources().getString(R.string.actionTurnWifiTetheringOff); - case enableScreenRotation: - return context.getResources().getString(R.string.actionEnableScreenRotation); - case disableScreenRotation: - return context.getResources().getString(R.string.actionDisableScreenRotation); case startOtherActivity: return context.getResources().getString(R.string.startOtherActivity); case waitBeforeNextAction: @@ -493,25 +473,9 @@ public class Action for(Action_Enum action : Action_Enum.values()) { if( // exclusion for deprecated types - !action.toString().equals("turnWifiOn") - && - !action.toString().equals("turnWifiOff") - && - !action.toString().equals("turnBluetoothOn") - && - !action.toString().equals("turnBluetoothOff") - && !action.toString().equals("turnUsbTetheringOn") && !action.toString().equals("turnUsbTetheringOff") - && - !action.toString().equals("turnWifiTetheringOn") - && - !action.toString().equals("turnWifiTetheringOff") - && - !action.toString().equals("enableScreenRotation") - && - !action.toString().equals("disableScreenRotation") ) // exclusion for deprecated types actionTypesList.add(action.toString()); } @@ -525,25 +489,9 @@ public class Action for(Action_Enum action : Action_Enum.values()) { if( // exclusion for deprecated types - !action.toString().equals("turnWifiOn") - && - !action.toString().equals("turnWifiOff") - && - !action.toString().equals("turnBluetoothOn") - && - !action.toString().equals("turnBluetoothOff") - && !action.toString().equals("turnUsbTetheringOn") && !action.toString().equals("turnUsbTetheringOff") - && - !action.toString().equals("turnWifiTetheringOn") - && - !action.toString().equals("turnWifiTetheringOff") - && - !action.toString().equals("enableScreenRotation") - && - !action.toString().equals("disableScreenRotation") ) // exclusion for deprecated types actionTypesList.add(action.getFullName(context)); } diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java index a8cfb9e..fa1adcc 100644 --- a/app/src/main/java/com/jens/automation2/Actions.java +++ b/app/src/main/java/com/jens/automation2/Actions.java @@ -208,8 +208,8 @@ public class Actions String[] parts = action.split(Action.actionParameter2Split); broadcastIntent.setAction(parts[0]); - String[] intentparts = parts[1].split(";"); - broadcastIntent = packParametersIntoIntent(broadcastIntent, intentparts, 0); + String[] intentParts = parts[1].split(";"); + broadcastIntent = packParametersIntoIntent(broadcastIntent, intentParts, 0); } else broadcastIntent.setAction(action); @@ -1056,51 +1056,57 @@ public class Actions String params[]; if(param.contains(Action.actionParameter2Split)) - params = param.split(Action.actionParameter2Split); + params = param.split(Action.actionParameter2Split, -1); else - params = param.split(";"); + params = param.split(";", -1); try { Intent externalApplicationIntent; + String packageName, className, activityOrAction, startupType; + + packageName = params[0]; + className = params[1]; + activityOrAction = params[2]; + startupType = params[3]; + if (!startByAction) { - // selected by activity - - String packageName, className; - - packageName = params[0]; - className = params[1]; - + // start by activity Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by activity: " + packageName + " " + className, 3); externalApplicationIntent = new Intent(Intent.ACTION_MAIN); externalApplicationIntent.addCategory(Intent.CATEGORY_LAUNCHER); - if(packageName.equals("dummyPkg")) + if(packageName.equals("dummyPkg") || packageName.length() == 0) externalApplicationIntent.setAction(className); - externalApplicationIntent.setClassName(packageName, className); + externalApplicationIntent.setPackage(packageName); + externalApplicationIntent.setClassName(packageName, activityOrAction); if (!Miscellaneous.doesActivityExist(externalApplicationIntent, Miscellaneous.getAnyContext())) Miscellaneous.logEvent("w", "StartOtherApp", "Activity not found: " + className, 2); } else { - // selected by action + // start by action Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by action: " + param, 3); externalApplicationIntent = new Intent(); - if (!params[0].equals(dummyPackageString)) - externalApplicationIntent.setPackage(params[0]); - - externalApplicationIntent.setAction(params[1]); - - if (params[2].equals(ActivityManageActionStartActivity.startByServiceString) || params[2].equals(ActivityManageActionStartActivity.startByForegroundServiceString)) + if (!packageName.equals(dummyPackageString)) { - externalApplicationIntent.setComponent(new ComponentName(params[0], params[2])); + externalApplicationIntent.setPackage(packageName); + if(!StringUtils.isEmpty(className)) + externalApplicationIntent.setClassName(packageName, className); + } + + externalApplicationIntent.setAction(activityOrAction); + + if (startupType.equals(ActivityManageActionStartActivity.startByServiceString) || startupType.equals(ActivityManageActionStartActivity.startByForegroundServiceString)) + { + externalApplicationIntent.setComponent(new ComponentName(packageName, className)); } } @@ -1109,17 +1115,17 @@ public class Actions // Pack intents if(params.length >= 4) { - if(Miscellaneous.isNumeric(params[3])) + if(Miscellaneous.isNumeric(startupType)) externalApplicationIntent = packParametersIntoIntent(externalApplicationIntent, params, 4); else externalApplicationIntent = packParametersIntoIntent(externalApplicationIntent, params, 3); } - if (params[2].equals(ActivityManageActionStartActivity.startByActivityString)) + if (startupType.equals(ActivityManageActionStartActivity.startByActivityString)) automationServerRef.startActivity(externalApplicationIntent); - else if (params[2].equals(ActivityManageActionStartActivity.startByServiceString)) + else if (startupType.equals(ActivityManageActionStartActivity.startByServiceString)) automationServerRef.startService(externalApplicationIntent); - else if (params[2].equals(ActivityManageActionStartActivity.startByForegroundServiceString) && Build.VERSION.SDK_INT >= 26) + else if (startupType.equals(ActivityManageActionStartActivity.startByForegroundServiceString) && Build.VERSION.SDK_INT >= 26) automationServerRef.startForegroundService(externalApplicationIntent); else automationServerRef.sendBroadcast(externalApplicationIntent); diff --git a/app/src/main/java/com/jens/automation2/ActivityControlCenter.java b/app/src/main/java/com/jens/automation2/ActivityControlCenter.java index f113e1c..2d82729 100644 --- a/app/src/main/java/com/jens/automation2/ActivityControlCenter.java +++ b/app/src/main/java/com/jens/automation2/ActivityControlCenter.java @@ -8,6 +8,7 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.util.Log; +import android.view.KeyEvent; import android.view.View; import android.widget.Button; import android.widget.CheckBox; @@ -98,8 +99,17 @@ public class ActivityControlCenter extends Activity @Override public void onClick(View v) { - Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); - startActivityForResult(intent, requestCodeImport); + AlertDialog dialog = Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.importChooseFolderNotice), ActivityControlCenter.this); + dialog.setOnDismissListener(new DialogInterface.OnDismissListener() + { + @Override + public void onDismiss(DialogInterface dialogInterface) + { + Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); + startActivityForResult(intent, requestCodeImport); + } + }); + dialog.show(); } }); diff --git a/app/src/main/java/com/jens/automation2/ActivityMainScreen.java b/app/src/main/java/com/jens/automation2/ActivityMainScreen.java index 258f6b7..815f40b 100644 --- a/app/src/main/java/com/jens/automation2/ActivityMainScreen.java +++ b/app/src/main/java/com/jens/automation2/ActivityMainScreen.java @@ -590,7 +590,7 @@ public class ActivityMainScreen extends ActivityGeneric Miscellaneous.messageBox(getResources().getString(R.string.app_name), getResources().getString(R.string.android9RecordAudioNotice) + " " + getResources().getString(R.string.messageNotShownAgain), ActivityMainScreen.this).show(); } - if(Build.VERSION.SDK_INT >= 29 && !Settings.noticeAndroid10WifiShown && Rule.isAnyRuleUsing(Action.Action_Enum.setWifi)) + if(Miscellaneous.getTargetSDK(ActivityMainScreen.this) >= 29 && !Settings.noticeAndroid10WifiShown && Rule.isAnyRuleUsing(Action.Action_Enum.setWifi)) { Settings.noticeAndroid10WifiShown = true; Settings.writeSettings(ActivityMainScreen.this); diff --git a/app/src/main/java/com/jens/automation2/ActivityManageActionStartActivity.java b/app/src/main/java/com/jens/automation2/ActivityManageActionStartActivity.java index d712308..8bceb94 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageActionStartActivity.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageActionStartActivity.java @@ -53,7 +53,7 @@ public class ActivityManageActionStartActivity extends Activity Button bSelectApp, bAddIntentPair, bSaveActionStartOtherActivity, showStartProgramExamples; Spinner spinnerParameterType; RadioGroup rgAppStartupType; - boolean edit = false; +// boolean edit = false; ProgressDialog progressDialog = null; RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast, rbStartAppByService, rbStartAppByForegroundService; @@ -95,7 +95,7 @@ public class ActivityManageActionStartActivity extends Activity spinnerParameterType.setAdapter(intentTypeSpinnerAdapter); intentTypeSpinnerAdapter.notifyDataSetChanged(); - etClassName.setEnabled(false); +// etClassName.setEnabled(false); intentPairAdapter = new ArrayAdapter(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList); bSelectApp.setOnClickListener(new OnClickListener() @@ -233,26 +233,29 @@ public class ActivityManageActionStartActivity extends Activity String parameter2 = ""; - if (rbStartAppSelectByActivity.isChecked()) - parameter2 += etPackageName.getText().toString() + Action.actionParameter2Split + etActivityOrActionPath.getText().toString(); - else - { - if (etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0) - parameter2 += etPackageName.getText().toString() + Action.actionParameter2Split + etActivityOrActionPath.getText().toString(); - else - parameter2 += Actions.dummyPackageString + Action.actionParameter2Split + etActivityOrActionPath.getText().toString(); + /* + 0 = packageName + 1 = className + 2 = activityName/actionName + 3 = startType + 4 = parameters + */ - parameter2 += Action.actionParameter2Split + etClassName.getText().toString(); - } + parameter2 += etPackageName.getText().toString() + + Action.actionParameter2Split + + etClassName.getText().toString() + + Action.actionParameter2Split + + etActivityOrActionPath.getText().toString() + + Action.actionParameter2Split; if (rbStartAppByActivity.isChecked()) - parameter2 += Action.actionParameter2Split + startByActivityString; + parameter2 += startByActivityString; else if(rbStartAppByService.isChecked()) - parameter2 += Action.actionParameter2Split + startByServiceString; + parameter2 += startByServiceString; else if(rbStartAppByForegroundService.isChecked()) - parameter2 += Action.actionParameter2Split + startByForegroundServiceString; + parameter2 += startByForegroundServiceString; else - parameter2 += Action.actionParameter2Split + startByBroadcastString; + parameter2 += startByBroadcastString; for (String s : intentPairList) parameter2 += Action.actionParameter2Split + s; @@ -316,23 +319,6 @@ public class ActivityManageActionStartActivity extends Activity } }); - rgAppStartupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() - { - @Override - public void onCheckedChanged(RadioGroup radioGroup, int i) - { - if(rbStartAppByActivity.isChecked()) - etClassName.setEnabled(false); - else if (rbStartAppByBroadcast.isChecked()) - etClassName.setEnabled(false); - else if(rbStartAppByService.isChecked()) - etClassName.setEnabled(true); - else if(rbStartAppByForegroundService.isChecked()) - etClassName.setEnabled(true); - } - }); - - Intent i = getIntent(); if(i.hasExtra(ActivityManageRule.intentNameActionParameter1)) loadValuesIntoGui(i); @@ -625,52 +611,36 @@ public class ActivityManageActionStartActivity extends Activity rbStartAppSelectByActivity.setChecked(!selectionByAction); rbStartAppSelectByAction.setChecked(selectionByAction); - String[] params; - String partsString = input.getStringExtra(ActivityManageRule.intentNameActionParameter2); + /* + 0 = packageName + 1 = className + 2 = activityName/actionName + 3 = startType + 4 = parameters + */ - if(partsString.contains(Action.actionParameter2Split)) - params = partsString.split(Action.actionParameter2Split); - else - params = partsString.split(";"); + try + { + String[] params; + String partsString = input.getStringExtra(ActivityManageRule.intentNameActionParameter2); + + if(partsString.contains(Action.actionParameter2Split)) + params = partsString.split(Action.actionParameter2Split, -1); + else + params = partsString.split(";", -1); + + etPackageName.setText(params[0]); + etClassName.setText(params[1]); + etActivityOrActionPath.setText(params[2]); - if(Miscellaneous.isNumeric(params[2])) // old configuration file - { - rbStartAppByActivity.setChecked(params[2].equals(startByActivityString)); - rbStartAppByBroadcast.setChecked(params[2].equals(startByBroadcastString)); - rbStartAppByService.setChecked(params[2].equals(startByServiceString)); - } - else - { rbStartAppByActivity.setChecked(params[3].equals(startByActivityString)); rbStartAppByBroadcast.setChecked(params[3].equals(startByBroadcastString)); rbStartAppByService.setChecked(params[3].equals(startByServiceString)); rbStartAppByForegroundService.setChecked(params[3].equals(startByForegroundServiceString)); - } - int startIndex = -1; - - if(!selectionByAction) - { - etPackageName.setText(params[0]); - etActivityOrActionPath.setText(params[1]); - } - else - { - if(!params[0].contains(Actions.dummyPackageString)) - etPackageName.setText(params[0]); - - etActivityOrActionPath.setText(params[1]); - etClassName.setText(params[2]); - } - - if (params.length >= 4) - startIndex = 4; - - if(startIndex > -1 && params.length > startIndex) - { intentPairList.clear(); - for(int i=startIndex; i Build.VERSION_CODES.GINGERBREAD_MR1) Miscellaneous.messageBox(context.getResources().getString(R.string.warning), context.getResources().getString(R.string.usbTetheringFailForAboveGingerbread), context).show(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setWifiTethering.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.setWifiTethering.toString())) { newAction.setAction(Action_Enum.setWifiTethering); getActionParameter1Dialog(ActivityManageRule.this).show(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setBluetoothTethering.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.setBluetoothTethering.toString())) { newAction.setAction(Action_Enum.setBluetoothTethering); getActionParameter1Dialog(ActivityManageRule.this).show(); @@ -2339,12 +2339,12 @@ public class ActivityManageRule extends Activity if(Build.VERSION.SDK_INT > Build.VERSION_CODES.O) Miscellaneous.messageBox(context.getResources().getString(R.string.notice), context.getResources().getString(R.string.btTetheringNotice), context).show(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setDisplayRotation.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.setDisplayRotation.toString())) { newAction.setAction(Action_Enum.setDisplayRotation); getActionParameter1Dialog(ActivityManageRule.this).show(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.changeSoundProfile.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.changeSoundProfile.toString())) { if(Profile.getProfileCollection().size() > 0) { @@ -2354,23 +2354,23 @@ public class ActivityManageRule extends Activity else Toast.makeText(context, getResources().getString(R.string.noProfilesCreateOneFirst), Toast.LENGTH_LONG).show(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.startOtherActivity.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.startOtherActivity.toString())) { newAction.setAction(Action_Enum.startOtherActivity); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionStartActivity.class); startActivityForResult(intent, requestCodeActionStartActivityAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.waitBeforeNextAction.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.waitBeforeNextAction.toString())) { newAction.setAction(Action_Enum.waitBeforeNextAction); getActionWaitBeforeNextActionDialog(ActivityManageRule.this).show(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.turnScreenOnOrOff.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.turnScreenOnOrOff.toString())) { newAction.setAction(Action_Enum.turnScreenOnOrOff); getActionParameter1Dialog(ActivityManageRule.this).show(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setAirplaneMode.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.setAirplaneMode.toString())) { newAction.setAction(Action_Enum.setAirplaneMode); getActionParameter1Dialog(ActivityManageRule.this).show(); @@ -2379,13 +2379,13 @@ public class ActivityManageRule extends Activity Miscellaneous.messageBox(getResources().getString(R.string.airplaneMode), getResources().getString(R.string.rootExplanation), ActivityManageRule.this).show(); } } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setDataConnection.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.setDataConnection.toString())) { newAction.setAction(Action_Enum.setDataConnection); getActionParameter1Dialog(ActivityManageRule.this).show(); Miscellaneous.messageBox(getResources().getString(R.string.actionDataConnection), getResources().getString(R.string.rootExplanation), ActivityManageRule.this).show(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.speakText.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.speakText.toString())) { //launch other activity to enter a url and parameters; newAction.setAction(Action_Enum.speakText); @@ -2393,9 +2393,9 @@ public class ActivityManageRule extends Activity Intent editTriggerIntent = new Intent(context, ActivityManageActionSpeakText.class); startActivityForResult(editTriggerIntent, requestCodeActionSpeakTextAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.sendTextMessage.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.sendTextMessage.toString())) { - if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.SEND_SMS)) + if(ActivityPermissions.isPermissionDeclaredInManifest(ActivityManageRule.this, Manifest.permission.SEND_SMS)) { //launch other activity to enter parameters; newAction.setAction(Action_Enum.sendTextMessage); @@ -2404,97 +2404,97 @@ public class ActivityManageRule extends Activity startActivityForResult(editTriggerIntent, requestCodeActionSendTextMessageAdd); } } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.playMusic.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.playMusic.toString())) { newAction.setAction(Action_Enum.playMusic); ruleToEdit.getActionSet().add(newAction); refreshActionList(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.vibrate.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.vibrate.toString())) { newAction.setAction(Action_Enum.vibrate); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionVibrate.class); startActivityForResult(intent, requestCodeActionVibrateAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.sendBroadcast.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.sendBroadcast.toString())) { newAction.setAction(Action_Enum.sendBroadcast); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSendBroadcast.class); startActivityForResult(intent, requestCodeActionSendBroadcastAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.runExecutable.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.runExecutable.toString())) { newAction.setAction(Action_Enum.runExecutable); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionRunExecutable.class); startActivityForResult(intent, requestCodeActionRunExecutableAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.startPhoneCall.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.startPhoneCall.toString())) { newAction.setAction(Action_Enum.startPhoneCall); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionMakePhoneCall.class); startActivityForResult(intent, requestCodeActionMakePhoneCallAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setVariable.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.setVariable.toString())) { newAction.setAction(Action_Enum.setVariable); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSetVariable.class); startActivityForResult(intent, requestCodeActionSetVariableAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.stopPhoneCall.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.stopPhoneCall.toString())) { newAction.setAction(Action_Enum.stopPhoneCall); ruleToEdit.getActionSet().add(newAction); refreshActionList(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.wakelock.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.wakelock.toString())) { newAction.setAction(Action_Enum.wakelock); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionWakeLock.class); startActivityForResult(intent, requestCodeActionWakeLockAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.controlMediaPlayback.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.controlMediaPlayback.toString())) { newAction.setAction(Action_Enum.controlMediaPlayback); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionControlMedia.class); startActivityForResult(intent, requestCodeActionControlMediaAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.createNotification.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.createNotification.toString())) { newAction.setAction(Action_Enum.createNotification); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCreateNotification.class); startActivityForResult(intent, requestCodeActionCreateNotificationAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.closeNotification.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.closeNotification.toString())) { newAction.setAction(Action_Enum.closeNotification); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCloseNotification.class); startActivityForResult(intent, requestCodeActionCloseNotificationAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setScreenBrightness.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.setScreenBrightness.toString())) { newAction.setAction(Action_Enum.setScreenBrightness); Intent actionScreenBrightnessIntent = new Intent(context, ActivityManageActionBrightnessSetting.class); startActivityForResult(actionScreenBrightnessIntent, requestCodeActionScreenBrightnessAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.playSound.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.playSound.toString())) { newAction.setAction(Action_Enum.playSound); Intent actionPlaySoundIntent = new Intent(context, ActivityManageActionPlaySound.class); startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.copyToClipboard.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.copyToClipboard.toString())) { newAction.setAction(Action_Enum.copyToClipboard); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCopyToClipboard.class); startActivityForResult(intent, requestCodeActionCopyTextToClipboardAdd); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.takeScreenshot.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.takeScreenshot.toString())) { newAction.setAction(Action_Enum.takeScreenshot); ruleToEdit.getActionSet().add(newAction); refreshActionList(); } - else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setLocationService.toString())) + else if(actionTypes[which].toString().equals(Action_Enum.setLocationService.toString())) { newAction.setAction(Action_Enum.setLocationService); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionLocationService.class); diff --git a/app/src/main/java/com/jens/automation2/ActivityManageTriggerTimeFrame.java b/app/src/main/java/com/jens/automation2/ActivityManageTriggerTimeFrame.java index 0ba52fd..60d6f04 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageTriggerTimeFrame.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageTriggerTimeFrame.java @@ -41,7 +41,7 @@ public class ActivityManageTriggerTimeFrame extends Activity startPicker = (TimePicker)findViewById(R.id.tpTimeFrameStart); stopPicker = (TimePicker)findViewById(R.id.tpTimeFrameStop); startPicker.setIs24HourView(true); - stopPicker.setIs24HourView(true); + stopPicker.setIs24HourView(true); bSaveTimeFrame = (Button)findViewById(R.id.bSaveTimeFrame); checkMonday = (CheckBox)findViewById(R.id.checkMonday); diff --git a/app/src/main/java/com/jens/automation2/ActivityManageTriggerWifi.java b/app/src/main/java/com/jens/automation2/ActivityManageTriggerWifi.java index 219649c..aa93d77 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageTriggerWifi.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageTriggerWifi.java @@ -15,7 +15,6 @@ import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; -import android.view.KeyEvent; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; @@ -74,7 +73,7 @@ public class ActivityManageTriggerWifi extends Activity if( Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29 && - !ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION) + !ActivityPermissions.isPermissionDeclaredInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION) ) tvWifiTriggerNameLocationNotice.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/jens/automation2/ActivityPermissions.java b/app/src/main/java/com/jens/automation2/ActivityPermissions.java index f637f6f..a78fba0 100644 --- a/app/src/main/java/com/jens/automation2/ActivityPermissions.java +++ b/app/src/main/java/com/jens/automation2/ActivityPermissions.java @@ -11,6 +11,8 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.content.pm.PermissionInfo; +import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.net.Uri; import android.os.Build; @@ -27,8 +29,6 @@ import android.widget.TextView; import com.jens.automation2.receivers.NotificationListener; -import org.w3c.dom.DOMImplementationSource; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -579,7 +579,7 @@ public class ActivityPermissions extends Activity ( Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29 && - isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION) + isPermissionDeclaredInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION) ) || Build.VERSION.SDK_INT >= 33 @@ -611,12 +611,6 @@ public class ActivityPermissions extends Activity if(targetProfile.changeIncomingCallsRingtone || targetProfile.changeNotificationRingtone) addToArrayListUnique(Manifest.permission.READ_EXTERNAL_STORAGE, requiredPermissions); break; - case disableScreenRotation: - addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); - break; - case enableScreenRotation: - addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); - break; case playMusic: break; case controlMediaPlayback: @@ -719,40 +713,12 @@ public class ActivityPermissions extends Activity addToArrayListUnique(Manifest.permission.INTERNET, requiredPermissions); getPermissionsForVariablesInUse(action.getParameter2(), requiredPermissions); break; - case turnBluetoothOff: - addToArrayListUnique(Manifest.permission.BLUETOOTH_ADMIN, requiredPermissions); - addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); - addToArrayListUnique(Manifest.permission.BLUETOOTH, requiredPermissions); - addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions); - break; - case turnBluetoothOn: - addToArrayListUnique(Manifest.permission.BLUETOOTH_ADMIN, requiredPermissions); - addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); - addToArrayListUnique(Manifest.permission.BLUETOOTH, requiredPermissions); - addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions); - break; case turnUsbTetheringOff: addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); break; case turnUsbTetheringOn: addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); break; - case turnWifiOff: - addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); - addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions); - break; - case turnWifiOn: - addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); - addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions); - break; - case turnWifiTetheringOff: - addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); - addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions); - break; - case turnWifiTetheringOn: - addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); - addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions); - break; case waitBeforeNextAction: break; case playSound: @@ -898,18 +864,6 @@ public class ActivityPermissions extends Activity usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); for(String ruleName : getRulesUsing(Action.Action_Enum.setWifiTethering)) usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnBluetoothOff)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnBluetoothOn)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnWifiOff)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnWifiOn)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnWifiTetheringOff)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnWifiTetheringOn)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); break; case Manifest.permission.ACCESS_WIFI_STATE: for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.pointOfInterest)) @@ -922,20 +876,12 @@ public class ActivityPermissions extends Activity usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); for(String ruleName : getRulesUsing(Action.Action_Enum.setBluetooth)) usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnBluetoothOff)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnBluetoothOn)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); break; case Manifest.permission.BLUETOOTH: for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.bluetoothConnection)) usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); for(String ruleName : getRulesUsing(Action.Action_Enum.setBluetooth)) usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnBluetoothOff)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); - for(String ruleName : getRulesUsing(Action.Action_Enum.turnBluetoothOn)) - usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); break; case Manifest.permission.GET_TASKS: for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.process_started_stopped)) @@ -1129,14 +1075,14 @@ public class ActivityPermissions extends Activity { if(permissionNames.equals(Manifest.permission.PROCESS_OUTGOING_CALLS)) { - if(ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.PROCESS_OUTGOING_CALLS) && !Miscellaneous.isGooglePlayInstalled(Miscellaneous.getAnyContext())) + if(ActivityPermissions.isPermissionDeclaredInManifest(Miscellaneous.getAnyContext(), Manifest.permission.PROCESS_OUTGOING_CALLS) && !Miscellaneous.isGooglePlayInstalled(Miscellaneous.getAnyContext())) { permissionList.add(permission); } } else if(permissionNames.equals(Manifest.permission.SEND_SMS)) { - if(ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.SEND_SMS) && !Miscellaneous.isGooglePlayInstalled(Miscellaneous.getAnyContext())) + if(ActivityPermissions.isPermissionDeclaredInManifest(Miscellaneous.getAnyContext(), Manifest.permission.SEND_SMS) && !Miscellaneous.isGooglePlayInstalled(Miscellaneous.getAnyContext())) { permissionList.add(permission); } @@ -1305,7 +1251,7 @@ public class ActivityPermissions extends Activity { if(requiredPermissions.contains(Manifest.permission.PROCESS_OUTGOING_CALLS)) { - if(!ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.SEND_SMS) + if(!ActivityPermissions.isPermissionDeclaredInManifest(Miscellaneous.getAnyContext(), Manifest.permission.SEND_SMS) && Miscellaneous.isGooglePlayInstalled(Miscellaneous.getAnyContext()) ) @@ -1316,7 +1262,7 @@ public class ActivityPermissions extends Activity } if(requiredPermissions.contains(Manifest.permission.SEND_SMS)) { - if(!ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.SEND_SMS) + if(!ActivityPermissions.isPermissionDeclaredInManifest(Miscellaneous.getAnyContext(), Manifest.permission.SEND_SMS) ) { requiredPermissions.remove(Manifest.permission.SEND_SMS); @@ -1686,12 +1632,53 @@ public class ActivityPermissions extends Activity mapActionPermissions.put("wakeupDevice", Manifest.permission.WAKE_LOCK); } - public static boolean isPermissionDeclaratedInManifest(Context context, String permission) + public static boolean isServiceAvailable(Context context, String serviceName) + { + /*int flags = PackageManager.GET_ACTIVITIES + | PackageManager.GET_CONFIGURATIONS + | PackageManager.GET_DISABLED_COMPONENTS + | PackageManager.GET_GIDS | PackageManager.GET_INSTRUMENTATION + | PackageManager.GET_INTENT_FILTERS + | PackageManager.GET_PERMISSIONS | PackageManager.GET_PROVIDERS + | PackageManager.GET_RECEIVERS | PackageManager.GET_SERVICES + | PackageManager.GET_SIGNATURES; + PackageManager packageManager = getPackageManager(); + List installedPackages = packageManager.getInstalledPackages(flags); + for (PackageInfo packageInfo : installedPackages) + { + ServiceInfo[] services = packageInfo.services; + PermissionInfo[] permissions = packageInfo.permissions; + }*/ + + StringBuffer buffer = new StringBuffer(); + try + { + PackageManager packageManager = context.getPackageManager(); + PackageInfo packageInfo = packageManager.getPackageInfo("com.jens.automation2", PackageManager.GET_SERVICES); + ServiceInfo[] services = packageInfo.services; + for (ServiceInfo serviceInfo : services) + { + if(serviceInfo.name.endsWith(serviceName)) + return true; + } + PermissionInfo[] permissions = packageInfo.permissions; + } + catch (PackageManager.NameNotFoundException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return false; + } + + public static boolean isPermissionDeclaredInManifest(Context context, String permission) { PackageManager pm = context.getPackageManager(); try { PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS); + String[] requestedPermissions = null; if (packageInfo != null) { diff --git a/app/src/main/java/com/jens/automation2/AutomationService.java b/app/src/main/java/com/jens/automation2/AutomationService.java index a024003..b4668eb 100644 --- a/app/src/main/java/com/jens/automation2/AutomationService.java +++ b/app/src/main/java/com/jens/automation2/AutomationService.java @@ -322,7 +322,7 @@ public class AutomationService extends Service implements OnInitListener DateTimeListener.setOrResetAlarms(); - if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent) && ActivityPermissions.isPermissionDeclaratedInManifest(AutomationService.getInstance(), Manifest.permission.READ_CALENDAR) && ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, AutomationService.getInstance())) + if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent) && ActivityPermissions.isPermissionDeclaredInManifest(AutomationService.getInstance(), Manifest.permission.READ_CALENDAR) && ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, AutomationService.getInstance())) CalendarReceiver.armOrRearmTimer(); } @@ -392,6 +392,20 @@ public class AutomationService extends Service implements OnInitListener r.activate(AutomationService.this, false); } + if(!Settings.hasBeenDone(Settings.constVersion143StartOtherProgramConfigEditHint)) + { + if(Rule.isAnyRuleUsing(Action.Action_Enum.startOtherActivity)) + { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) + Miscellaneous.createDismissibleNotificationWithDelay(1010, null, getResources().getString(R.string.version143StartOtherActivityHint), 9123, AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE, null); + else + Miscellaneous.createDismissibleNotification(null, getResources().getString(R.string.version143StartOtherActivityHint), 9123, false, AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE, null); + } + + Settings.considerDone(Settings.constVersion143StartOtherProgramConfigEditHint); + Settings.writeSettings(Miscellaneous.getAnyContext()); + } + Settings.serviceStartDone = true; Settings.deviceStartDone = true; } diff --git a/app/src/main/java/com/jens/automation2/ReceiverCoordinator.java b/app/src/main/java/com/jens/automation2/ReceiverCoordinator.java index bfce2cf..9afb3ac 100644 --- a/app/src/main/java/com/jens/automation2/ReceiverCoordinator.java +++ b/app/src/main/java/com/jens/automation2/ReceiverCoordinator.java @@ -213,7 +213,7 @@ public class ReceiverCoordinator if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.screenState)) ScreenStateReceiver.startScreenStateReceiver(AutomationService.getInstance()); - if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent) && ActivityPermissions.isPermissionDeclaratedInManifest(AutomationService.getInstance(), Manifest.permission.READ_CALENDAR) && ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, AutomationService.getInstance())) + if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent) && ActivityPermissions.isPermissionDeclaredInManifest(AutomationService.getInstance(), Manifest.permission.READ_CALENDAR) && ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, AutomationService.getInstance())) CalendarReceiver.startCalendarReceiver(AutomationService.getInstance()); } @@ -470,7 +470,7 @@ public class ReceiverCoordinator } } - if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent) && ActivityPermissions.isPermissionDeclaratedInManifest(AutomationService.getInstance(), Manifest.permission.READ_CALENDAR) && ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, AutomationService.getInstance())) + if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent) && ActivityPermissions.isPermissionDeclaredInManifest(AutomationService.getInstance(), Manifest.permission.READ_CALENDAR) && ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, AutomationService.getInstance())) { if(!CalendarReceiver.getInstance().isListenerRunning()) CalendarReceiver.getInstance().startListener(AutomationService.getInstance()); diff --git a/app/src/main/java/com/jens/automation2/Settings.java b/app/src/main/java/com/jens/automation2/Settings.java index 99c44ae..41bf314 100644 --- a/app/src/main/java/com/jens/automation2/Settings.java +++ b/app/src/main/java/com/jens/automation2/Settings.java @@ -19,8 +19,9 @@ public class Settings implements SharedPreferences public static final String folderName = "Automation"; public static final String zipFileName = "automation.zip"; - public static final String constNewsOptInDone ="newsOptInDone"; - public static final String constNotificationChannelCleanupApk118 ="notificationChannelCleanupApk118"; + public static final String constNewsOptInDone = "newsOptInDone"; + public static final String constNotificationChannelCleanupApk118 = "notificationChannelCleanupApk118"; + public static final String constVersion143StartOtherProgramConfigEditHint = "constVersion143StartOtherProgramConfigEditHint"; public static long minimumDistanceChangeForGpsUpdate; public static long minimumDistanceChangeForNetworkUpdate; diff --git a/app/src/main/java/com/jens/automation2/Trigger.java b/app/src/main/java/com/jens/automation2/Trigger.java index 174ed00..572e00f 100644 --- a/app/src/main/java/com/jens/automation2/Trigger.java +++ b/app/src/main/java/com/jens/automation2/Trigger.java @@ -1665,7 +1665,7 @@ public class Trigger try { Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath); - if (ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), "com.google.android.gms.permission.ACTIVITY_RECOGNITION")) + if (ActivityPermissions.isPermissionDeclaredInManifest(Miscellaneous.getAnyContext(), "com.google.android.gms.permission.ACTIVITY_RECOGNITION")) { // This type doesn't have an activate/deactivate equivalent, at least not yet. returnString.append(Miscellaneous.runMethodReflective(ActivityManageRule.activityDetectionClassPath, "getDescription", new Object[]{getActivityDetectionType()})); diff --git a/app/src/main/java/com/jens/automation2/XmlFileInterface.java b/app/src/main/java/com/jens/automation2/XmlFileInterface.java index 4d48ee9..39fb14d 100644 --- a/app/src/main/java/com/jens/automation2/XmlFileInterface.java +++ b/app/src/main/java/com/jens/automation2/XmlFileInterface.java @@ -1135,28 +1135,10 @@ public class XmlFileInterface // *** deprecated //else - if(actionNameString.equals("turnWifiOn")) - newAction.setAction(Action_Enum.turnWifiOn); - else if(actionNameString.equals("turnWifiOff")) - newAction.setAction(Action_Enum.turnWifiOff); - else if(actionNameString.equals("turnBluetoothOn")) - newAction.setAction(Action_Enum.turnBluetoothOn); - else if(actionNameString.equals("turnBluetoothOff")) - newAction.setAction(Action_Enum.turnBluetoothOff); - else if(actionNameString.equals("turnUsbTetheringOn")) + if(actionNameString.equals("turnUsbTetheringOn")) newAction.setAction(Action_Enum.turnUsbTetheringOn); else if(actionNameString.equals("turnUsbTetheringOff")) newAction.setAction(Action_Enum.turnUsbTetheringOff); - else if(actionNameString.equals("turnWifiTetheringOn")) - newAction.setAction(Action_Enum.turnWifiTetheringOn); - else if(actionNameString.equals("turnWifiTetheringOff")) - newAction.setAction(Action_Enum.turnWifiTetheringOff); - else if(actionNameString.equals("enableScreenRotation")) - newAction.setAction(Action_Enum.enableScreenRotation); - else if(actionNameString.equals("disableScreenRotation")) - newAction.setAction(Action_Enum.disableScreenRotation); - else if(actionNameString.equals("disableScreenRotation")) - newAction.setAction(Action_Enum.disableScreenRotation); else if(actionNameString.equals("playMusic")) { newAction.setAction(Action_Enum.controlMediaPlayback); @@ -1175,31 +1157,7 @@ public class XmlFileInterface else if (name.equals("ActionParameter1")) { // exclusion for deprecated types - if(newAction.getAction().equals(Action_Enum.turnWifiOn)) - { - newAction.setAction(Action_Enum.setWifi); - newAction.setParameter1(true); - readTag(parser, "ActionParameter1"); //read the tag for the parser to head on - } - else if(newAction.getAction().equals(Action_Enum.turnWifiOff)) - { - newAction.setAction(Action_Enum.setWifi); - newAction.setParameter1(false); - readTag(parser, "ActionParameter1"); //read the tag for the parser to head on - } - else if(newAction.getAction().equals(Action_Enum.turnBluetoothOn)) - { - newAction.setAction(Action_Enum.setBluetooth); - newAction.setParameter1(true); - readTag(parser, "ActionParameter1"); //read the tag for the parser to head on - } - else if(newAction.getAction().equals(Action_Enum.turnBluetoothOff)) - { - newAction.setAction(Action_Enum.setBluetooth); - newAction.setParameter1(false); - readTag(parser, "ActionParameter1"); //read the tag for the parser to head on - } - else if(newAction.getAction().equals(Action_Enum.turnUsbTetheringOn)) + if(newAction.getAction().equals(Action_Enum.turnUsbTetheringOn)) { newAction.setAction(Action_Enum.setUsbTethering); newAction.setParameter1(true); @@ -1211,36 +1169,6 @@ public class XmlFileInterface newAction.setParameter1(false); readTag(parser, "ActionParameter1"); //read the tag for the parser to head on } - else if(newAction.getAction().equals(Action_Enum.turnWifiTetheringOn)) - { - newAction.setAction(Action_Enum.setWifiTethering); - newAction.setParameter1(true); - readTag(parser, "ActionParameter1"); //read the tag for the parser to head on - } - else if(newAction.getAction().equals(Action_Enum.turnWifiTetheringOff)) - { - newAction.setAction(Action_Enum.setWifiTethering); - newAction.setParameter1(false); - readTag(parser, "ActionParameter1"); //read the tag for the parser to head on - } - else if(newAction.getAction().equals(Action_Enum.enableScreenRotation)) - { - newAction.setAction(Action_Enum.setDisplayRotation); - newAction.setParameter1(true); - readTag(parser, "ActionParameter1"); //read the tag for the parser to head on - } - else if(newAction.getAction().equals(Action_Enum.disableScreenRotation)) - { - newAction.setAction(Action_Enum.setDisplayRotation); - newAction.setParameter1(false); - readTag(parser, "ActionParameter1"); //read the tag for the parser to head on - } - else if(newAction.getAction().equals(Action_Enum.disableScreenRotation)) - { - newAction.setAction(Action_Enum.setDisplayRotation); - newAction.setParameter1(false); - readTag(parser, "ActionParameter1"); //read the tag for the parser to head on - } else if(newAction.getAction().equals(Action_Enum.turnScreenOnOrOff) && newAction.getParameter1()) { /* diff --git a/app/src/main/java/com/jens/automation2/location/CellLocationChangedReceiver.java b/app/src/main/java/com/jens/automation2/location/CellLocationChangedReceiver.java index 0e61555..8a5de11 100644 --- a/app/src/main/java/com/jens/automation2/location/CellLocationChangedReceiver.java +++ b/app/src/main/java/com/jens/automation2/location/CellLocationChangedReceiver.java @@ -78,7 +78,7 @@ public class CellLocationChangedReceiver extends PhoneStateListener { for(Action action : Rule.getLastActivatedRule().getActionSet()) { - if(action.getAction() == Action.Action_Enum.turnWifiOn) + if(action.getAction() == Action.Action_Enum.setWifi && action.getParameter1()) { // we will be using wifiReceiver, deactivate AccelerometerTimer if applicable SensorActivity.stopAccelerometerTimer(); @@ -88,7 +88,7 @@ public class CellLocationChangedReceiver extends PhoneStateListener catch(NullPointerException ne) { // Nothing to do, there is no last activated rule. Wifi hasn't been activated so we don't - // deactive accelerometer receiver. + // deactivate accelerometer receiver. } } else diff --git a/app/src/main/res/layout/activity_manage_trigger_timeframe.xml b/app/src/main/res/layout/activity_manage_trigger_timeframe.xml index e04b3bf..417f497 100644 --- a/app/src/main/res/layout/activity_manage_trigger_timeframe.xml +++ b/app/src/main/res/layout/activity_manage_trigger_timeframe.xml @@ -1,44 +1,46 @@ - + android:layout_width="match_parent" + android:layout_height="fill_parent" + android:layout_margin="@dimen/default_margin" + android:layout_weight="30"> + - - - - - - - - - + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + + + + + + + + + android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_margin="10dp" + android:background="#aa000000" /> - + - - - + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + + android:orientation="horizontal"> + android:inputType="numberSigned" + android:minWidth="75dp" /> - -