Compare commits

...

2 Commits

Author SHA1 Message Date
d7d806fb5c Added permission for Termux remote commands 2024-08-25 17:11:24 +02:00
910af92989 Multiple bug fixes 2024-08-11 14:58:13 +02:00
22 changed files with 323 additions and 448 deletions

View File

@ -11,8 +11,8 @@ android {
compileSdkVersion 33 compileSdkVersion 33
buildToolsVersion '29.0.2' buildToolsVersion '29.0.2'
useLibrary 'org.apache.http.legacy' useLibrary 'org.apache.http.legacy'
versionCode 142 versionCode 143
versionName "1.8.1" versionName "1.8.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@ -78,7 +78,7 @@
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/> <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<!--android:maxSdkVersion="32" /> <!--android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />--> <uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
<uses-feature <uses-feature
android:name="android.hardware.telephony" android:name="android.hardware.telephony"

View File

@ -76,6 +76,7 @@
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/> <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<!--android:maxSdkVersion="32" /> <!--android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />--> <uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
<uses-feature <uses-feature
android:name="android.hardware.telephony" android:name="android.hardware.telephony"

View File

@ -73,6 +73,7 @@
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!--android:maxSdkVersion="32" /> <!--android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />--> <uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
<application <application
android:allowBackup="true" android:allowBackup="true"

View File

@ -33,13 +33,9 @@ public class Action
setWifiTethering, setWifiTethering,
setBluetoothTethering, setBluetoothTethering,
setDisplayRotation, setDisplayRotation,
turnWifiOn,turnWifiOff,
turnBluetoothOn,turnBluetoothOff,
triggerUrl, triggerUrl,
changeSoundProfile, changeSoundProfile,
turnUsbTetheringOn,turnUsbTetheringOff, turnUsbTetheringOn,turnUsbTetheringOff,
turnWifiTetheringOn,turnWifiTetheringOff,
enableScreenRotation,disableScreenRotation,
startOtherActivity, startOtherActivity,
waitBeforeNextAction, waitBeforeNextAction,
turnScreenOnOrOff, turnScreenOnOrOff,
@ -60,9 +56,9 @@ public class Action
startPhoneCall, startPhoneCall,
stopPhoneCall, stopPhoneCall,
copyToClipboard, copyToClipboard,
takeScreenshot,
setLocationService, setLocationService,
sendTextMessage; sendTextMessage,
takeScreenshot;
public String getFullName(Context context) public String getFullName(Context context)
{ {
@ -80,14 +76,6 @@ public class Action
return context.getResources().getString(R.string.actionSetUsbTethering); return context.getResources().getString(R.string.actionSetUsbTethering);
case setDisplayRotation: case setDisplayRotation:
return context.getResources().getString(R.string.actionSetDisplayRotation); 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: case triggerUrl:
return context.getResources().getString(R.string.actionTriggerUrl); return context.getResources().getString(R.string.actionTriggerUrl);
case changeSoundProfile: case changeSoundProfile:
@ -96,14 +84,6 @@ public class Action
return context.getResources().getString(R.string.actionTurnUsbTetheringOn); return context.getResources().getString(R.string.actionTurnUsbTetheringOn);
case turnUsbTetheringOff: case turnUsbTetheringOff:
return context.getResources().getString(R.string.actionTurnUsbTetheringOff); 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: case startOtherActivity:
return context.getResources().getString(R.string.startOtherActivity); return context.getResources().getString(R.string.startOtherActivity);
case waitBeforeNextAction: case waitBeforeNextAction:
@ -493,25 +473,9 @@ public class Action
for(Action_Enum action : Action_Enum.values()) for(Action_Enum action : Action_Enum.values())
{ {
if( // exclusion for deprecated types 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("turnUsbTetheringOn")
&& &&
!action.toString().equals("turnUsbTetheringOff") !action.toString().equals("turnUsbTetheringOff")
&&
!action.toString().equals("turnWifiTetheringOn")
&&
!action.toString().equals("turnWifiTetheringOff")
&&
!action.toString().equals("enableScreenRotation")
&&
!action.toString().equals("disableScreenRotation")
) // exclusion for deprecated types ) // exclusion for deprecated types
actionTypesList.add(action.toString()); actionTypesList.add(action.toString());
} }
@ -525,25 +489,9 @@ public class Action
for(Action_Enum action : Action_Enum.values()) for(Action_Enum action : Action_Enum.values())
{ {
if( // exclusion for deprecated types 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("turnUsbTetheringOn")
&& &&
!action.toString().equals("turnUsbTetheringOff") !action.toString().equals("turnUsbTetheringOff")
&&
!action.toString().equals("turnWifiTetheringOn")
&&
!action.toString().equals("turnWifiTetheringOff")
&&
!action.toString().equals("enableScreenRotation")
&&
!action.toString().equals("disableScreenRotation")
) // exclusion for deprecated types ) // exclusion for deprecated types
actionTypesList.add(action.getFullName(context)); actionTypesList.add(action.getFullName(context));
} }

View File

@ -208,8 +208,8 @@ public class Actions
String[] parts = action.split(Action.actionParameter2Split); String[] parts = action.split(Action.actionParameter2Split);
broadcastIntent.setAction(parts[0]); broadcastIntent.setAction(parts[0]);
String[] intentparts = parts[1].split(";"); String[] intentParts = parts[1].split(";");
broadcastIntent = packParametersIntoIntent(broadcastIntent, intentparts, 0); broadcastIntent = packParametersIntoIntent(broadcastIntent, intentParts, 0);
} }
else else
broadcastIntent.setAction(action); broadcastIntent.setAction(action);
@ -1056,51 +1056,57 @@ public class Actions
String params[]; String params[];
if(param.contains(Action.actionParameter2Split)) if(param.contains(Action.actionParameter2Split))
params = param.split(Action.actionParameter2Split); params = param.split(Action.actionParameter2Split, -1);
else else
params = param.split(";"); params = param.split(";", -1);
try try
{ {
Intent externalApplicationIntent; Intent externalApplicationIntent;
String packageName, className, activityOrAction, startupType;
packageName = params[0];
className = params[1];
activityOrAction = params[2];
startupType = params[3];
if (!startByAction) if (!startByAction)
{ {
// selected by activity // start by activity
String packageName, className;
packageName = params[0];
className = params[1];
Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by activity: " + packageName + " " + className, 3); Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by activity: " + packageName + " " + className, 3);
externalApplicationIntent = new Intent(Intent.ACTION_MAIN); externalApplicationIntent = new Intent(Intent.ACTION_MAIN);
externalApplicationIntent.addCategory(Intent.CATEGORY_LAUNCHER); externalApplicationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
if(packageName.equals("dummyPkg")) if(packageName.equals("dummyPkg") || packageName.length() == 0)
externalApplicationIntent.setAction(className); externalApplicationIntent.setAction(className);
externalApplicationIntent.setClassName(packageName, className); externalApplicationIntent.setPackage(packageName);
externalApplicationIntent.setClassName(packageName, activityOrAction);
if (!Miscellaneous.doesActivityExist(externalApplicationIntent, Miscellaneous.getAnyContext())) if (!Miscellaneous.doesActivityExist(externalApplicationIntent, Miscellaneous.getAnyContext()))
Miscellaneous.logEvent("w", "StartOtherApp", "Activity not found: " + className, 2); Miscellaneous.logEvent("w", "StartOtherApp", "Activity not found: " + className, 2);
} }
else else
{ {
// selected by action // start by action
Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by action: " + param, 3); Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by action: " + param, 3);
externalApplicationIntent = new Intent(); externalApplicationIntent = new Intent();
if (!params[0].equals(dummyPackageString)) if (!packageName.equals(dummyPackageString))
externalApplicationIntent.setPackage(params[0]);
externalApplicationIntent.setAction(params[1]);
if (params[2].equals(ActivityManageActionStartActivity.startByServiceString) || params[2].equals(ActivityManageActionStartActivity.startByForegroundServiceString))
{ {
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 // Pack intents
if(params.length >= 4) if(params.length >= 4)
{ {
if(Miscellaneous.isNumeric(params[3])) if(Miscellaneous.isNumeric(startupType))
externalApplicationIntent = packParametersIntoIntent(externalApplicationIntent, params, 4); externalApplicationIntent = packParametersIntoIntent(externalApplicationIntent, params, 4);
else else
externalApplicationIntent = packParametersIntoIntent(externalApplicationIntent, params, 3); externalApplicationIntent = packParametersIntoIntent(externalApplicationIntent, params, 3);
} }
if (params[2].equals(ActivityManageActionStartActivity.startByActivityString)) if (startupType.equals(ActivityManageActionStartActivity.startByActivityString))
automationServerRef.startActivity(externalApplicationIntent); automationServerRef.startActivity(externalApplicationIntent);
else if (params[2].equals(ActivityManageActionStartActivity.startByServiceString)) else if (startupType.equals(ActivityManageActionStartActivity.startByServiceString))
automationServerRef.startService(externalApplicationIntent); 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); automationServerRef.startForegroundService(externalApplicationIntent);
else else
automationServerRef.sendBroadcast(externalApplicationIntent); automationServerRef.sendBroadcast(externalApplicationIntent);

View File

@ -8,6 +8,7 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
@ -98,8 +99,17 @@ public class ActivityControlCenter extends Activity
@Override @Override
public void onClick(View v) public void onClick(View v)
{ {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); AlertDialog dialog = Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.importChooseFolderNotice), ActivityControlCenter.this);
startActivityForResult(intent, requestCodeImport); 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();
} }
}); });

View File

@ -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(); 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.noticeAndroid10WifiShown = true;
Settings.writeSettings(ActivityMainScreen.this); Settings.writeSettings(ActivityMainScreen.this);

View File

@ -53,7 +53,7 @@ public class ActivityManageActionStartActivity extends Activity
Button bSelectApp, bAddIntentPair, bSaveActionStartOtherActivity, showStartProgramExamples; Button bSelectApp, bAddIntentPair, bSaveActionStartOtherActivity, showStartProgramExamples;
Spinner spinnerParameterType; Spinner spinnerParameterType;
RadioGroup rgAppStartupType; RadioGroup rgAppStartupType;
boolean edit = false; // boolean edit = false;
ProgressDialog progressDialog = null; ProgressDialog progressDialog = null;
RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast, rbStartAppByService, rbStartAppByForegroundService; RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast, rbStartAppByService, rbStartAppByForegroundService;
@ -95,7 +95,7 @@ public class ActivityManageActionStartActivity extends Activity
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter); spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
intentTypeSpinnerAdapter.notifyDataSetChanged(); intentTypeSpinnerAdapter.notifyDataSetChanged();
etClassName.setEnabled(false); // etClassName.setEnabled(false);
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList); intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
bSelectApp.setOnClickListener(new OnClickListener() bSelectApp.setOnClickListener(new OnClickListener()
@ -233,26 +233,29 @@ public class ActivityManageActionStartActivity extends Activity
String parameter2 = ""; String parameter2 = "";
if (rbStartAppSelectByActivity.isChecked()) /*
parameter2 += etPackageName.getText().toString() + Action.actionParameter2Split + etActivityOrActionPath.getText().toString(); 0 = packageName
else 1 = className
{ 2 = activityName/actionName
if (etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0) 3 = startType
parameter2 += etPackageName.getText().toString() + Action.actionParameter2Split + etActivityOrActionPath.getText().toString(); 4 = parameters
else */
parameter2 += Actions.dummyPackageString + Action.actionParameter2Split + etActivityOrActionPath.getText().toString();
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()) if (rbStartAppByActivity.isChecked())
parameter2 += Action.actionParameter2Split + startByActivityString; parameter2 += startByActivityString;
else if(rbStartAppByService.isChecked()) else if(rbStartAppByService.isChecked())
parameter2 += Action.actionParameter2Split + startByServiceString; parameter2 += startByServiceString;
else if(rbStartAppByForegroundService.isChecked()) else if(rbStartAppByForegroundService.isChecked())
parameter2 += Action.actionParameter2Split + startByForegroundServiceString; parameter2 += startByForegroundServiceString;
else else
parameter2 += Action.actionParameter2Split + startByBroadcastString; parameter2 += startByBroadcastString;
for (String s : intentPairList) for (String s : intentPairList)
parameter2 += Action.actionParameter2Split + s; 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(); Intent i = getIntent();
if(i.hasExtra(ActivityManageRule.intentNameActionParameter1)) if(i.hasExtra(ActivityManageRule.intentNameActionParameter1))
loadValuesIntoGui(i); loadValuesIntoGui(i);
@ -625,52 +611,36 @@ public class ActivityManageActionStartActivity extends Activity
rbStartAppSelectByActivity.setChecked(!selectionByAction); rbStartAppSelectByActivity.setChecked(!selectionByAction);
rbStartAppSelectByAction.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)) try
params = partsString.split(Action.actionParameter2Split); {
else String[] params;
params = partsString.split(";"); 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)); rbStartAppByActivity.setChecked(params[3].equals(startByActivityString));
rbStartAppByBroadcast.setChecked(params[3].equals(startByBroadcastString)); rbStartAppByBroadcast.setChecked(params[3].equals(startByBroadcastString));
rbStartAppByService.setChecked(params[3].equals(startByServiceString)); rbStartAppByService.setChecked(params[3].equals(startByServiceString));
rbStartAppByForegroundService.setChecked(params[3].equals(startByForegroundServiceString)); 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(); intentPairList.clear();
for(int i=startIndex; i<params.length; i++) for(int i=4; i<params.length; i++)
{ {
if(lvIntentPairs.getVisibility() != View.VISIBLE) if(lvIntentPairs.getVisibility() != View.VISIBLE)
lvIntentPairs.setVisibility(View.VISIBLE); lvIntentPairs.setVisibility(View.VISIBLE);
@ -680,6 +650,10 @@ public class ActivityManageActionStartActivity extends Activity
updateIntentPairList(); updateIntentPairList();
} }
catch(Exception e)
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.errorLoadingValues), Toast.LENGTH_LONG).show();
}
} }
private void updateIntentPairList() private void updateIntentPairList()

View File

@ -622,7 +622,7 @@ public class ActivityManageRule extends Activity
items.add(new Item(typesLong[i].toString(), R.drawable.megaphone)); items.add(new Item(typesLong[i].toString(), R.drawable.megaphone));
else if(types[i].toString().equals(Trigger_Enum.phoneCall.toString())) else if(types[i].toString().equals(Trigger_Enum.phoneCall.toString()))
{ {
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.SEND_SMS)) if(ActivityPermissions.isPermissionDeclaredInManifest(ActivityManageRule.this, Manifest.permission.SEND_SMS))
items.add(new Item(typesLong[i].toString(), R.drawable.phone)); items.add(new Item(typesLong[i].toString(), R.drawable.phone));
} }
else if(types[i].toString().equals(Trigger_Enum.nfcTag.toString())) else if(types[i].toString().equals(Trigger_Enum.nfcTag.toString()))
@ -655,7 +655,7 @@ public class ActivityManageRule extends Activity
items.add(new Item(typesLong[i].toString(), R.drawable.variable)); items.add(new Item(typesLong[i].toString(), R.drawable.variable));
else if(types[i].toString().equals(Trigger_Enum.calendarEvent.toString())) else if(types[i].toString().equals(Trigger_Enum.calendarEvent.toString()))
{ {
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.READ_CALENDAR)) if(ActivityPermissions.isPermissionDeclaredInManifest(ActivityManageRule.this, Manifest.permission.READ_CALENDAR))
items.add(new Item(typesLong[i].toString(), R.drawable.calendar)); items.add(new Item(typesLong[i].toString(), R.drawable.calendar));
} }
else else
@ -2238,17 +2238,17 @@ public class ActivityManageRule extends Activity
items.add(new Item(typesLong[i].toString(), R.drawable.script)); items.add(new Item(typesLong[i].toString(), R.drawable.script));
else if(types[i].toString().equals(Action_Enum.startPhoneCall.toString())) else if(types[i].toString().equals(Action_Enum.startPhoneCall.toString()))
{ {
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.CALL_PHONE)) if(ActivityPermissions.isPermissionDeclaredInManifest(ActivityManageRule.this, Manifest.permission.CALL_PHONE))
items.add(new Item(typesLong[i].toString(), R.drawable.phone)); items.add(new Item(typesLong[i].toString(), R.drawable.phone));
} }
else if(types[i].toString().equals(Action_Enum.stopPhoneCall.toString())) else if(types[i].toString().equals(Action_Enum.stopPhoneCall.toString()))
{ {
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.ANSWER_PHONE_CALLS)) if(ActivityPermissions.isPermissionDeclaredInManifest(ActivityManageRule.this, Manifest.permission.ANSWER_PHONE_CALLS))
items.add(new Item(typesLong[i].toString(), R.drawable.phone)); items.add(new Item(typesLong[i].toString(), R.drawable.phone));
} }
else if(types[i].toString().equals(Action_Enum.sendTextMessage.toString())) else if(types[i].toString().equals(Action_Enum.sendTextMessage.toString()))
{ {
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.SEND_SMS)) if(ActivityPermissions.isPermissionDeclaredInManifest(ActivityManageRule.this, Manifest.permission.SEND_SMS))
items.add(new Item(typesLong[i].toString(), R.drawable.message)); items.add(new Item(typesLong[i].toString(), R.drawable.message));
} }
else if(types[i].toString().equals(Action_Enum.copyToClipboard.toString())) else if(types[i].toString().equals(Action_Enum.copyToClipboard.toString()))
@ -2259,7 +2259,7 @@ public class ActivityManageRule extends Activity
items.add(new Item(typesLong[i].toString(), R.drawable.compass_small)); items.add(new Item(typesLong[i].toString(), R.drawable.compass_small));
else if(types[i].toString().equals(Action_Enum.takeScreenshot.toString())) else if(types[i].toString().equals(Action_Enum.takeScreenshot.toString()))
{ {
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.BIND_ACCESSIBILITY_SERVICE)) if(ActivityPermissions.isServiceAvailable(Miscellaneous.getAnyContext(), "MyAccessibilityService"))
items.add(new Item(typesLong[i].toString(), R.drawable.copier)); items.add(new Item(typesLong[i].toString(), R.drawable.copier));
} }
else else
@ -2294,28 +2294,28 @@ public class ActivityManageRule extends Activity
{ {
newAction = new Action(); newAction = new Action();
if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.triggerUrl.toString())) CharSequence[] actionTypes = Action.getActionTypesAsArray();
if(actionTypes[which].toString().equals(Action_Enum.triggerUrl.toString()))
{ {
//launch other activity to enter a url and parameters; //launch other activity to enter a url and parameters;
newAction.setAction(Action_Enum.triggerUrl); newAction.setAction(Action_Enum.triggerUrl);
// ActivityManageActionTriggerUrl.resultingAction = null;
Intent editTriggerIntent = new Intent(context, ActivityManageActionTriggerUrl.class); Intent editTriggerIntent = new Intent(context, ActivityManageActionTriggerUrl.class);
startActivityForResult(editTriggerIntent, requestCodeActionTriggerUrlAdd); startActivityForResult(editTriggerIntent, requestCodeActionTriggerUrlAdd);
} }
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setWifi.toString())) else if(actionTypes[which].toString().equals(Action_Enum.setWifi.toString()))
{ {
newAction.setAction(Action_Enum.setWifi); newAction.setAction(Action_Enum.setWifi);
Intent editSetWifiIntent = new Intent(context, ActivityManageActionWifi.class); Intent editSetWifiIntent = new Intent(context, ActivityManageActionWifi.class);
startActivityForResult(editSetWifiIntent, requestCodeActionSetWifiAdd); startActivityForResult(editSetWifiIntent, requestCodeActionSetWifiAdd);
} }
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setBluetooth.toString())) else if(actionTypes[which].toString().equals(Action_Enum.setBluetooth.toString()))
{ {
if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH))
Miscellaneous.messageBox("Bluetooth", getResources().getString(R.string.deviceDoesNotHaveBluetooth), ActivityManageRule.this).show();; Miscellaneous.messageBox("Bluetooth", getResources().getString(R.string.deviceDoesNotHaveBluetooth), ActivityManageRule.this).show();;
newAction.setAction(Action_Enum.setBluetooth); newAction.setAction(Action_Enum.setBluetooth);
getActionParameter1Dialog(ActivityManageRule.this).show(); getActionParameter1Dialog(ActivityManageRule.this).show();
} }
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setUsbTethering.toString())) else if(actionTypes[which].toString().equals(Action_Enum.setUsbTethering.toString()))
{ {
newAction.setAction(Action_Enum.setUsbTethering); newAction.setAction(Action_Enum.setUsbTethering);
getActionParameter1Dialog(ActivityManageRule.this).show(); getActionParameter1Dialog(ActivityManageRule.this).show();
@ -2323,12 +2323,12 @@ public class ActivityManageRule extends Activity
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) if(Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1)
Miscellaneous.messageBox(context.getResources().getString(R.string.warning), context.getResources().getString(R.string.usbTetheringFailForAboveGingerbread), context).show(); 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); newAction.setAction(Action_Enum.setWifiTethering);
getActionParameter1Dialog(ActivityManageRule.this).show(); 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); newAction.setAction(Action_Enum.setBluetoothTethering);
getActionParameter1Dialog(ActivityManageRule.this).show(); getActionParameter1Dialog(ActivityManageRule.this).show();
@ -2339,12 +2339,12 @@ public class ActivityManageRule extends Activity
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.O) 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(); 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); newAction.setAction(Action_Enum.setDisplayRotation);
getActionParameter1Dialog(ActivityManageRule.this).show(); 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) if(Profile.getProfileCollection().size() > 0)
{ {
@ -2354,23 +2354,23 @@ public class ActivityManageRule extends Activity
else else
Toast.makeText(context, getResources().getString(R.string.noProfilesCreateOneFirst), Toast.LENGTH_LONG).show(); 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); newAction.setAction(Action_Enum.startOtherActivity);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionStartActivity.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionStartActivity.class);
startActivityForResult(intent, requestCodeActionStartActivityAdd); 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); newAction.setAction(Action_Enum.waitBeforeNextAction);
getActionWaitBeforeNextActionDialog(ActivityManageRule.this).show(); 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); newAction.setAction(Action_Enum.turnScreenOnOrOff);
getActionParameter1Dialog(ActivityManageRule.this).show(); 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); newAction.setAction(Action_Enum.setAirplaneMode);
getActionParameter1Dialog(ActivityManageRule.this).show(); 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(); 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); newAction.setAction(Action_Enum.setDataConnection);
getActionParameter1Dialog(ActivityManageRule.this).show(); getActionParameter1Dialog(ActivityManageRule.this).show();
Miscellaneous.messageBox(getResources().getString(R.string.actionDataConnection), getResources().getString(R.string.rootExplanation), 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; //launch other activity to enter a url and parameters;
newAction.setAction(Action_Enum.speakText); newAction.setAction(Action_Enum.speakText);
@ -2393,9 +2393,9 @@ public class ActivityManageRule extends Activity
Intent editTriggerIntent = new Intent(context, ActivityManageActionSpeakText.class); Intent editTriggerIntent = new Intent(context, ActivityManageActionSpeakText.class);
startActivityForResult(editTriggerIntent, requestCodeActionSpeakTextAdd); 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; //launch other activity to enter parameters;
newAction.setAction(Action_Enum.sendTextMessage); newAction.setAction(Action_Enum.sendTextMessage);
@ -2404,97 +2404,97 @@ public class ActivityManageRule extends Activity
startActivityForResult(editTriggerIntent, requestCodeActionSendTextMessageAdd); 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); newAction.setAction(Action_Enum.playMusic);
ruleToEdit.getActionSet().add(newAction); ruleToEdit.getActionSet().add(newAction);
refreshActionList(); 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); newAction.setAction(Action_Enum.vibrate);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionVibrate.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionVibrate.class);
startActivityForResult(intent, requestCodeActionVibrateAdd); 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); newAction.setAction(Action_Enum.sendBroadcast);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSendBroadcast.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSendBroadcast.class);
startActivityForResult(intent, requestCodeActionSendBroadcastAdd); 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); newAction.setAction(Action_Enum.runExecutable);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionRunExecutable.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionRunExecutable.class);
startActivityForResult(intent, requestCodeActionRunExecutableAdd); 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); newAction.setAction(Action_Enum.startPhoneCall);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionMakePhoneCall.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionMakePhoneCall.class);
startActivityForResult(intent, requestCodeActionMakePhoneCallAdd); 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); newAction.setAction(Action_Enum.setVariable);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSetVariable.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSetVariable.class);
startActivityForResult(intent, requestCodeActionSetVariableAdd); 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); newAction.setAction(Action_Enum.stopPhoneCall);
ruleToEdit.getActionSet().add(newAction); ruleToEdit.getActionSet().add(newAction);
refreshActionList(); 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); newAction.setAction(Action_Enum.wakelock);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionWakeLock.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionWakeLock.class);
startActivityForResult(intent, requestCodeActionWakeLockAdd); 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); newAction.setAction(Action_Enum.controlMediaPlayback);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionControlMedia.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionControlMedia.class);
startActivityForResult(intent, requestCodeActionControlMediaAdd); 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); newAction.setAction(Action_Enum.createNotification);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCreateNotification.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCreateNotification.class);
startActivityForResult(intent, requestCodeActionCreateNotificationAdd); 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); newAction.setAction(Action_Enum.closeNotification);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCloseNotification.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCloseNotification.class);
startActivityForResult(intent, requestCodeActionCloseNotificationAdd); 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); newAction.setAction(Action_Enum.setScreenBrightness);
Intent actionScreenBrightnessIntent = new Intent(context, ActivityManageActionBrightnessSetting.class); Intent actionScreenBrightnessIntent = new Intent(context, ActivityManageActionBrightnessSetting.class);
startActivityForResult(actionScreenBrightnessIntent, requestCodeActionScreenBrightnessAdd); 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); newAction.setAction(Action_Enum.playSound);
Intent actionPlaySoundIntent = new Intent(context, ActivityManageActionPlaySound.class); Intent actionPlaySoundIntent = new Intent(context, ActivityManageActionPlaySound.class);
startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundAdd); 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); newAction.setAction(Action_Enum.copyToClipboard);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCopyToClipboard.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCopyToClipboard.class);
startActivityForResult(intent, requestCodeActionCopyTextToClipboardAdd); 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); newAction.setAction(Action_Enum.takeScreenshot);
ruleToEdit.getActionSet().add(newAction); ruleToEdit.getActionSet().add(newAction);
refreshActionList(); 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); newAction.setAction(Action_Enum.setLocationService);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionLocationService.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionLocationService.class);

View File

@ -41,7 +41,7 @@ public class ActivityManageTriggerTimeFrame extends Activity
startPicker = (TimePicker)findViewById(R.id.tpTimeFrameStart); startPicker = (TimePicker)findViewById(R.id.tpTimeFrameStart);
stopPicker = (TimePicker)findViewById(R.id.tpTimeFrameStop); stopPicker = (TimePicker)findViewById(R.id.tpTimeFrameStop);
startPicker.setIs24HourView(true); startPicker.setIs24HourView(true);
stopPicker.setIs24HourView(true); stopPicker.setIs24HourView(true);
bSaveTimeFrame = (Button)findViewById(R.id.bSaveTimeFrame); bSaveTimeFrame = (Button)findViewById(R.id.bSaveTimeFrame);
checkMonday = (CheckBox)findViewById(R.id.checkMonday); checkMonday = (CheckBox)findViewById(R.id.checkMonday);

View File

@ -15,7 +15,6 @@ import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@ -74,7 +73,7 @@ public class ActivityManageTriggerWifi extends Activity
if( if(
Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29 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); tvWifiTriggerNameLocationNotice.setVisibility(View.VISIBLE);

View File

@ -11,6 +11,8 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.content.pm.ServiceInfo;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
@ -27,8 +29,6 @@ import android.widget.TextView;
import com.jens.automation2.receivers.NotificationListener; import com.jens.automation2.receivers.NotificationListener;
import org.w3c.dom.DOMImplementationSource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -579,7 +579,7 @@ public class ActivityPermissions extends Activity
( (
Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29 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 Build.VERSION.SDK_INT >= 33
@ -611,12 +611,6 @@ public class ActivityPermissions extends Activity
if(targetProfile.changeIncomingCallsRingtone || targetProfile.changeNotificationRingtone) if(targetProfile.changeIncomingCallsRingtone || targetProfile.changeNotificationRingtone)
addToArrayListUnique(Manifest.permission.READ_EXTERNAL_STORAGE, requiredPermissions); addToArrayListUnique(Manifest.permission.READ_EXTERNAL_STORAGE, requiredPermissions);
break; break;
case disableScreenRotation:
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
break;
case enableScreenRotation:
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
break;
case playMusic: case playMusic:
break; break;
case controlMediaPlayback: case controlMediaPlayback:
@ -719,40 +713,12 @@ public class ActivityPermissions extends Activity
addToArrayListUnique(Manifest.permission.INTERNET, requiredPermissions); addToArrayListUnique(Manifest.permission.INTERNET, requiredPermissions);
getPermissionsForVariablesInUse(action.getParameter2(), requiredPermissions); getPermissionsForVariablesInUse(action.getParameter2(), requiredPermissions);
break; 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: case turnUsbTetheringOff:
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
break; break;
case turnUsbTetheringOn: case turnUsbTetheringOn:
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions); addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
break; 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: case waitBeforeNextAction:
break; break;
case playSound: case playSound:
@ -898,18 +864,6 @@ public class ActivityPermissions extends Activity
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
for(String ruleName : getRulesUsing(Action.Action_Enum.setWifiTethering)) for(String ruleName : getRulesUsing(Action.Action_Enum.setWifiTethering))
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); 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; break;
case Manifest.permission.ACCESS_WIFI_STATE: case Manifest.permission.ACCESS_WIFI_STATE:
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.pointOfInterest)) 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)); usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
for(String ruleName : getRulesUsing(Action.Action_Enum.setBluetooth)) for(String ruleName : getRulesUsing(Action.Action_Enum.setBluetooth))
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); 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; break;
case Manifest.permission.BLUETOOTH: case Manifest.permission.BLUETOOTH:
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.bluetoothConnection)) for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.bluetoothConnection))
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
for(String ruleName : getRulesUsing(Action.Action_Enum.setBluetooth)) for(String ruleName : getRulesUsing(Action.Action_Enum.setBluetooth))
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); 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; break;
case Manifest.permission.GET_TASKS: case Manifest.permission.GET_TASKS:
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.process_started_stopped)) 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(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); permissionList.add(permission);
} }
} }
else if(permissionNames.equals(Manifest.permission.SEND_SMS)) 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); permissionList.add(permission);
} }
@ -1305,7 +1251,7 @@ public class ActivityPermissions extends Activity
{ {
if(requiredPermissions.contains(Manifest.permission.PROCESS_OUTGOING_CALLS)) 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()) Miscellaneous.isGooglePlayInstalled(Miscellaneous.getAnyContext())
) )
@ -1316,7 +1262,7 @@ public class ActivityPermissions extends Activity
} }
if(requiredPermissions.contains(Manifest.permission.SEND_SMS)) 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); requiredPermissions.remove(Manifest.permission.SEND_SMS);
@ -1686,12 +1632,53 @@ public class ActivityPermissions extends Activity
mapActionPermissions.put("wakeupDevice", Manifest.permission.WAKE_LOCK); 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<PackageInfo> 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(); PackageManager pm = context.getPackageManager();
try try
{ {
PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS); PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS);
String[] requestedPermissions = null; String[] requestedPermissions = null;
if (packageInfo != null) if (packageInfo != null)
{ {

View File

@ -322,7 +322,7 @@ public class AutomationService extends Service implements OnInitListener
DateTimeListener.setOrResetAlarms(); 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(); CalendarReceiver.armOrRearmTimer();
} }
@ -392,6 +392,20 @@ public class AutomationService extends Service implements OnInitListener
r.activate(AutomationService.this, false); 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.serviceStartDone = true;
Settings.deviceStartDone = true; Settings.deviceStartDone = true;
} }

View File

@ -213,7 +213,7 @@ public class ReceiverCoordinator
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.screenState)) if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.screenState))
ScreenStateReceiver.startScreenStateReceiver(AutomationService.getInstance()); 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()); 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()) if(!CalendarReceiver.getInstance().isListenerRunning())
CalendarReceiver.getInstance().startListener(AutomationService.getInstance()); CalendarReceiver.getInstance().startListener(AutomationService.getInstance());

View File

@ -19,8 +19,9 @@ public class Settings implements SharedPreferences
public static final String folderName = "Automation"; public static final String folderName = "Automation";
public static final String zipFileName = "automation.zip"; public static final String zipFileName = "automation.zip";
public static final String constNewsOptInDone ="newsOptInDone"; public static final String constNewsOptInDone = "newsOptInDone";
public static final String constNotificationChannelCleanupApk118 ="notificationChannelCleanupApk118"; public static final String constNotificationChannelCleanupApk118 = "notificationChannelCleanupApk118";
public static final String constVersion143StartOtherProgramConfigEditHint = "constVersion143StartOtherProgramConfigEditHint";
public static long minimumDistanceChangeForGpsUpdate; public static long minimumDistanceChangeForGpsUpdate;
public static long minimumDistanceChangeForNetworkUpdate; public static long minimumDistanceChangeForNetworkUpdate;

View File

@ -1665,7 +1665,7 @@ public class Trigger
try try
{ {
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath); 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. // This type doesn't have an activate/deactivate equivalent, at least not yet.
returnString.append(Miscellaneous.runMethodReflective(ActivityManageRule.activityDetectionClassPath, "getDescription", new Object[]{getActivityDetectionType()})); returnString.append(Miscellaneous.runMethodReflective(ActivityManageRule.activityDetectionClassPath, "getDescription", new Object[]{getActivityDetectionType()}));

View File

@ -1135,28 +1135,10 @@ public class XmlFileInterface
// *** deprecated // *** deprecated
//else //else
if(actionNameString.equals("turnWifiOn")) if(actionNameString.equals("turnUsbTetheringOn"))
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"))
newAction.setAction(Action_Enum.turnUsbTetheringOn); newAction.setAction(Action_Enum.turnUsbTetheringOn);
else if(actionNameString.equals("turnUsbTetheringOff")) else if(actionNameString.equals("turnUsbTetheringOff"))
newAction.setAction(Action_Enum.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")) else if(actionNameString.equals("playMusic"))
{ {
newAction.setAction(Action_Enum.controlMediaPlayback); newAction.setAction(Action_Enum.controlMediaPlayback);
@ -1175,31 +1157,7 @@ public class XmlFileInterface
else if (name.equals("ActionParameter1")) else if (name.equals("ActionParameter1"))
{ {
// exclusion for deprecated types // exclusion for deprecated types
if(newAction.getAction().equals(Action_Enum.turnWifiOn)) if(newAction.getAction().equals(Action_Enum.turnUsbTetheringOn))
{
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))
{ {
newAction.setAction(Action_Enum.setUsbTethering); newAction.setAction(Action_Enum.setUsbTethering);
newAction.setParameter1(true); newAction.setParameter1(true);
@ -1211,36 +1169,6 @@ public class XmlFileInterface
newAction.setParameter1(false); newAction.setParameter1(false);
readTag(parser, "ActionParameter1"); //read the tag for the parser to head on 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()) else if(newAction.getAction().equals(Action_Enum.turnScreenOnOrOff) && newAction.getParameter1())
{ {
/* /*

View File

@ -78,7 +78,7 @@ public class CellLocationChangedReceiver extends PhoneStateListener
{ {
for(Action action : Rule.getLastActivatedRule().getActionSet()) 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 // we will be using wifiReceiver, deactivate AccelerometerTimer if applicable
SensorActivity.stopAccelerometerTimer(); SensorActivity.stopAccelerometerTimer();
@ -88,7 +88,7 @@ public class CellLocationChangedReceiver extends PhoneStateListener
catch(NullPointerException ne) catch(NullPointerException ne)
{ {
// Nothing to do, there is no last activated rule. Wifi hasn't been activated so we don't // 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 else

View File

@ -1,44 +1,46 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_weight="30" android:layout_margin="@dimen/default_margin"
android:layout_margin="@dimen/default_margin" > android:layout_weight="30">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" > android:orientation="vertical">
<TextView <TextView
android:id="@+id/tvRuleTitle" android:id="@+id/tvRuleTitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/start" android:text="@string/start"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:textAppearance="?android:attr/textAppearanceLarge" />
<TimePicker <TimePicker
android:id="@+id/tpTimeFrameStart" android:id="@+id/tpTimeFrameStart"
android:layout_width="wrap_content" android:descendantFocusability="blocksDescendants"
android:layout_height="wrap_content" /> android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tvLastRule" <TextView
android:layout_width="wrap_content" android:id="@+id/tvLastRule"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="@string/end" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:text="@string/end"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TimePicker
android:id="@+id/tpTimeFrameStop" <TimePicker
android:layout_width="wrap_content" android:id="@+id/tpTimeFrameStop"
android:layout_height="wrap_content" /> android:descendantFocusability="blocksDescendants"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_margin="10dp" android:layout_margin="10dp"
android:background="#aa000000" /> android:background="#aa000000" />
<TextView <TextView
android:id="@+id/textView2" android:id="@+id/textView2"
@ -47,24 +49,24 @@
android:text="@string/insideOrOutsideTimeFrames" android:text="@string/insideOrOutsideTimeFrames"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:textAppearance="?android:attr/textAppearanceLarge" />
<RadioGroup <RadioGroup
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<RadioButton <RadioButton
android:id="@+id/radioTimeFrameEntering" android:id="@+id/radioTimeFrameEntering"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="true" android:checked="true"
android:text="@string/entering" /> android:text="@string/entering" />
<RadioButton <RadioButton
android:id="@+id/radioTimeFrameLeaving" android:id="@+id/radioTimeFrameLeaving"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/leaving" /> android:text="@string/leaving" />
</RadioGroup> </RadioGroup>
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
@ -80,52 +82,52 @@
<TextView <TextView
android:id="@+id/tvDaysHint" android:id="@+id/tvDaysHint"
android:layout_marginVertical="@dimen/default_margin"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/default_margin"
android:textColor="@color/red" /> android:textColor="@color/red" />
<CheckBox <CheckBox
android:id="@+id/checkMonday" android:id="@+id/checkMonday"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/monday" /> android:text="@string/monday" />
<CheckBox <CheckBox
android:id="@+id/checkTuesday" android:id="@+id/checkTuesday"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/tuesday" /> android:text="@string/tuesday" />
<CheckBox <CheckBox
android:id="@+id/checkWednesday" android:id="@+id/checkWednesday"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/wednesday" /> android:text="@string/wednesday" />
<CheckBox <CheckBox
android:id="@+id/checkThursday" android:id="@+id/checkThursday"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/thursday" /> android:text="@string/thursday" />
<CheckBox <CheckBox
android:id="@+id/checkFriday" android:id="@+id/checkFriday"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/friday" /> android:text="@string/friday" />
<CheckBox <CheckBox
android:id="@+id/checkSaturday" android:id="@+id/checkSaturday"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/saturday" /> android:text="@string/saturday" />
<CheckBox <CheckBox
android:id="@+id/checkSunday" android:id="@+id/checkSunday"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/sunday" /> android:text="@string/sunday" />
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -136,7 +138,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" > android:orientation="horizontal">
<CheckBox <CheckBox
android:id="@+id/chkRepeat" android:id="@+id/chkRepeat"
@ -146,22 +148,22 @@
<EditText <EditText
android:id="@+id/etRepeatEvery" android:id="@+id/etRepeatEvery"
android:layout_marginLeft="@dimen/default_margin"
android:minWidth="75dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/default_margin"
android:enabled="false" android:enabled="false"
android:inputType="numberSigned" /> android:inputType="numberSigned"
android:minWidth="75dp" />
</LinearLayout> </LinearLayout>
<Button <Button
android:id="@+id/bSaveTimeFrame" android:id="@+id/bSaveTimeFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_margin" android:layout_marginTop="@dimen/default_margin"
android:layout_width="wrap_content" android:text="@string/save" />
android:layout_height="wrap_content"
android:text="@string/save" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@ -592,7 +592,7 @@
<string name="brightnessAuto">automatic brightness</string> <string name="brightnessAuto">automatic brightness</string>
<string name="brightnessManual">manual brightness</string> <string name="brightnessManual">manual brightness</string>
<string name="autoBrightnessNotice">If you use auto brightness the brightness value you use below will probably not be used long.</string> <string name="autoBrightnessNotice">If you use auto brightness the brightness value you use below will probably not be used long.</string>
<string name="screenLockSoundNotice">Screenlock sounds cannot automatically be changed anymore on devices running Android version 6.0 or higher. Whatever you set here, it will not work in either direction.</string> <string name="screenLockSoundNotice">Screen lock sounds cannot automatically be changed anymore on devices running Android version 6.0 or higher. Whatever you set here, it will not work in either direction.</string>
<string name="startScreen">Start screen</string> <string name="startScreen">Start screen</string>
<string name="startScreenSummary">Select the screen the applications opens with at start.</string> <string name="startScreenSummary">Select the screen the applications opens with at start.</string>
<string name="executeRulesAndProfilesWithSingleClickTitle">Run rules/profiles with single click.</string> <string name="executeRulesAndProfilesWithSingleClickTitle">Run rules/profiles with single click.</string>
@ -947,4 +947,6 @@
<string name="notCharging">not charging</string> <string name="notCharging">not charging</string>
<string name="triggerChargingComment">The type will only be evaluated if the device is charging. If not charging is chosen, it will fire at any previous charging type. If you want to evaluate that, consider using the variables trigger/action.</string> <string name="triggerChargingComment">The type will only be evaluated if the device is charging. If not charging is chosen, it will fire at any previous charging type. If you want to evaluate that, consider using the variables trigger/action.</string>
<string name="helpTextProfiles">A profile is a collection of settings for ringtones, volumes and other audio related settings that you can have applied from rules or apply it manually.\n\nIt is also possible to query for the last activated profile as a trigger. In the normal case it will only query if the profile was the last activated one (regardless if specific audio settings have been changed in the meantime). But you can also have the individual settings compared.</string> <string name="helpTextProfiles">A profile is a collection of settings for ringtones, volumes and other audio related settings that you can have applied from rules or apply it manually.\n\nIt is also possible to query for the last activated profile as a trigger. In the normal case it will only query if the profile was the last activated one (regardless if specific audio settings have been changed in the meantime). But you can also have the individual settings compared.</string>
<string name="version143StartOtherActivityHint">In version 1.8.2 it was necessary to revise the way actions to start other programs were saved. Compatibility could not be ensured. Please check and edit your start other activity actions to make sure they are still working.</string>
<string name="importChooseFolderNotice">In the following dialog do not try to select specific files, but choose the folder in which the Automation backup files reside. If the choose button is disabled, you have found an Android limitation. In that case try moving the files to a subdirectory first.</string>
</resources> </resources>

View File

@ -0,0 +1,2 @@
* Fixed: Start other program action revised, editing of your actions may be necessary to continue working
* Fixed: Action type menu would in some cases pick up another action than selected