Conflicts:
	app/src/main/java/com/jens/automation2/Miscellaneous.java
This commit is contained in:
jens 2021-02-20 02:05:13 +01:00
commit 1388e55ae7
17 changed files with 133 additions and 100 deletions

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# Automation
Automation is an Android app to automate certain things on your device.
Find more information here: https://server47.de/automation/

View File

@ -94,7 +94,7 @@
android:name=".ActivityMainScreen"
android:label="@string/app_name"></activity>
<activity
android:name=".ActivityManageSpecificPoi"
android:name=".ActivityManagePoi"
android:label="@string/title_activity_main"></activity>
<activity
android:name=".ActivitySettings"
@ -135,7 +135,7 @@
<receiver android:name=".receivers.ConnectivityReceiver" />
<receiver android:name=".receivers.TimeZoneListener" />
<activity android:name=".ActivityManageSpecificRule" />
<activity android:name=".ActivityManageRule" />
<activity android:name=".ActivityEditTriggerUrl" />
<activity android:name=".ActivityEditSendTextMessage" />
<activity android:name=".ActivityManageTimeFrame" />
@ -182,7 +182,7 @@
<activity android:name=".ActivityEditSpeakText" />
<activity android:name=".ActivityManageBluetoothTrigger" />
<activity android:name=".ActivityMainProfiles" />
<activity android:name=".ActivityManageSpecificProfile" />
<activity android:name=".ActivityManageProfile" />
<activity android:name=".ActivityVolumeTest" />
<service

View File

@ -90,7 +90,7 @@
android:name=".ActivityMainScreen"
android:label="@string/app_name"></activity>
<activity
android:name=".ActivityManageSpecificPoi"
android:name=".ActivityManagePoi"
android:label="@string/title_activity_main"></activity>
<activity
android:name=".ActivitySettings"
@ -131,7 +131,7 @@
<receiver android:name=".receivers.ConnectivityReceiver" />
<receiver android:name=".receivers.TimeZoneListener" />
<activity android:name=".ActivityManageSpecificRule" />
<activity android:name=".ActivityManageRule" />
<activity android:name=".ActivityEditTriggerUrl" />
<activity android:name=".ActivityEditSendTextMessage" />
<activity android:name=".ActivityManageTimeFrame" />
@ -177,7 +177,7 @@
<activity android:name=".ActivityEditSpeakText" />
<activity android:name=".ActivityManageBluetoothTrigger" />
<activity android:name=".ActivityMainProfiles" />
<activity android:name=".ActivityManageSpecificProfile" />
<activity android:name=".ActivityManageProfile" />
<activity android:name=".ActivityVolumeTest" />
<activity android:name=".ActivityPermissions"></activity>

View File

@ -94,7 +94,7 @@
android:name=".ActivityMainScreen"
android:label="@string/app_name"></activity>
<activity
android:name=".ActivityManageSpecificPoi"
android:name=".ActivityManagePoi"
android:label="@string/title_activity_main"></activity>
<activity
android:name=".ActivitySettings"
@ -135,7 +135,7 @@
<receiver android:name=".receivers.ConnectivityReceiver" />
<receiver android:name=".receivers.TimeZoneListener" />
<activity android:name=".ActivityManageSpecificRule" />
<activity android:name=".ActivityManageRule" />
<activity android:name=".ActivityEditTriggerUrl" />
<activity android:name=".ActivityEditSendTextMessage" />
<activity android:name=".ActivityManageTimeFrame" />
@ -182,7 +182,7 @@
<activity android:name=".ActivityEditSpeakText" />
<activity android:name=".ActivityManageBluetoothTrigger" />
<activity android:name=".ActivityMainProfiles" />
<activity android:name=".ActivityManageSpecificProfile" />
<activity android:name=".ActivityManageProfile" />
<activity android:name=".ActivityVolumeTest" />
<service

View File

@ -94,7 +94,7 @@
android:name=".ActivityMainScreen"
android:label="@string/app_name"></activity>
<activity
android:name=".ActivityManageSpecificPoi"
android:name=".ActivityManagePoi"
android:label="@string/title_activity_main"></activity>
<activity
android:name=".ActivitySettings"
@ -135,7 +135,7 @@
<receiver android:name=".receivers.ConnectivityReceiver" />
<receiver android:name=".receivers.TimeZoneListener" />
<activity android:name=".ActivityManageSpecificRule" />
<activity android:name=".ActivityManageRule" />
<activity android:name=".ActivityEditTriggerUrl" />
<activity android:name=".ActivityEditSendTextMessage" />
<activity android:name=".ActivityManageTimeFrame" />
@ -182,7 +182,7 @@
<activity android:name=".ActivityEditSpeakText" />
<activity android:name=".ActivityManageBluetoothTrigger" />
<activity android:name=".ActivityMainProfiles" />
<activity android:name=".ActivityManageSpecificProfile" />
<activity android:name=".ActivityManageProfile" />
<activity android:name=".ActivityVolumeTest" />
<activity android:name=".ActivityPermissions"></activity>

View File

@ -107,7 +107,7 @@ public class ActivityMainPoi extends ActivityGeneric
private void buttonAddPoi()
{
poiToEdit = null;
Intent manageSpecificPoiIntent = new Intent(ActivityMainPoi.this, ActivityManageSpecificPoi.class);
Intent manageSpecificPoiIntent = new Intent(ActivityMainPoi.this, ActivityManagePoi.class);
manageSpecificPoiIntent.putExtra("action", "create");
startActivityForResult(manageSpecificPoiIntent, 1000);
}
@ -182,7 +182,7 @@ public class ActivityMainPoi extends ActivityGeneric
break;*/
case 0:
poiToEdit = pointOfInterest;
Intent manageSpecificPoiIntent = new Intent (ActivityMainPoi.this, ActivityManageSpecificPoi.class);
Intent manageSpecificPoiIntent = new Intent (ActivityMainPoi.this, ActivityManagePoi.class);
manageSpecificPoiIntent.putExtra("action", "change");
startActivityForResult(manageSpecificPoiIntent, 2000);
break;

View File

@ -57,7 +57,7 @@ public class ActivityMainProfiles extends ActivityGeneric
}
profileToEdit = null;
Intent manageSpecificProfileIntent = new Intent (ActivityMainProfiles.this, ActivityManageSpecificProfile.class);
Intent manageSpecificProfileIntent = new Intent (ActivityMainProfiles.this, ActivityManageProfile.class);
manageSpecificProfileIntent.putExtra("action", "create");
startActivityForResult(manageSpecificProfileIntent, 1000);
}
@ -179,7 +179,7 @@ public class ActivityMainProfiles extends ActivityGeneric
break;
case 1:
profileToEdit = profile;
Intent manageSpecificProfileIntent = new Intent (ActivityMainProfiles.this, ActivityManageSpecificProfile.class);
Intent manageSpecificProfileIntent = new Intent (ActivityMainProfiles.this, ActivityManageProfile.class);
manageSpecificProfileIntent.putExtra("action", "change");
startActivityForResult(manageSpecificProfileIntent, 2000);
break;

View File

@ -59,7 +59,7 @@ public class ActivityMainRules extends ActivityGeneric
}
ruleToEdit = null;
Intent startAddRuleIntent = new Intent(ActivityMainRules.this, ActivityManageSpecificRule.class);
Intent startAddRuleIntent = new Intent(ActivityMainRules.this, ActivityManageRule.class);
startActivityForResult(startAddRuleIntent, 3000);
}
});
@ -211,7 +211,7 @@ public class ActivityMainRules extends ActivityGeneric
break;
case 1:
ruleToEdit = ruleThisIsAbout;
Intent manageSpecificRuleIntent = new Intent (ActivityMainRules.this, ActivityManageSpecificRule.class);
Intent manageSpecificRuleIntent = new Intent (ActivityMainRules.this, ActivityManageRule.class);
startActivityForResult(manageSpecificRuleIntent, 4000);
break;
case 2:

View File

@ -35,7 +35,7 @@ public class ActivityMainScreen extends ActivityGeneric
private static ActivityMainScreen activityMainScreenInstance = null;
private ToggleButton toggleService, tbLockSound;
private Button bShowHelp, bPrivacy, bSettingsErase, bSettingsSetToDefault, bVolumeTest, bAddSoundLockTIme;
private TextView tvActivePoi, tvClosestPoi, tvLastRule, tvMainScreenNote, tvlockSoundDuration;
private TextView tvActivePoi, tvClosestPoi, tvLastRule, tvMainScreenNote, tvMainScreenNote2, tvlockSoundDuration;
private ListView lvRuleHistory;
private ArrayAdapter<Rule> ruleHistoryListViewAdapter;
@ -65,6 +65,7 @@ public class ActivityMainScreen extends ActivityGeneric
lvRuleHistory = (ListView) findViewById(R.id.lvRuleHistory);
tvLastRule = (TextView) findViewById(R.id.tvTimeFrameHelpText);
tvMainScreenNote = (TextView) findViewById(R.id.tvMainScreenNote);
tvMainScreenNote2 = (TextView) findViewById(R.id.tvMainScreenNote2);
tvlockSoundDuration = (TextView)findViewById(R.id.tvlockSoundDuration);
tbLockSound = (ToggleButton) findViewById(R.id.tbLockSound);
toggleService = (ToggleButton) findViewById(R.id.tbArmMastListener);
@ -292,6 +293,17 @@ public class ActivityMainScreen extends ActivityGeneric
activityMainScreenInstance.tvMainScreenNote.setVisibility(View.GONE);
}
if(Miscellaneous.restrictedFeaturesConfigured())
{
activityMainScreenInstance.tvMainScreenNote2.setText(R.string.settingsReferringToRestrictedFeatures);
activityMainScreenInstance.tvMainScreenNote2.setVisibility(View.VISIBLE);
}
else
{
activityMainScreenInstance.tvMainScreenNote2.setText("");
activityMainScreenInstance.tvMainScreenNote2.setVisibility(View.GONE);
}
if (AutomationService.isMyServiceRunning(activityMainScreenInstance))
{
Miscellaneous.logEvent("i", "MainScreen", "Service is running. Updating mainscreen with this info.", 5);
@ -548,4 +560,9 @@ public class ActivityMainScreen extends ActivityGeneric
Miscellaneous.messageBox(title, text, ActivityMainScreen.getActivityMainScreenInstance());
}
void checkForNews()
{
String newsUrl = "https://server47.de/automation/appNews.php";
String newsContent = Miscellaneous.downloadURL(newsUrl, null, null);
}
}

View File

@ -21,7 +21,7 @@ import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
public class ActivityManageSpecificPoi extends Activity
public class ActivityManagePoi extends Activity
{
public LocationManager myLocationManager;
MyLocationListenerGps myLocationListenerGps = new MyLocationListenerGps();
@ -211,7 +211,7 @@ public class ActivityManageSpecificPoi extends Activity
// break;
// }
progressDialog = ProgressDialog.show(ActivityManageSpecificPoi.this, "", getResources().getString(R.string.gettingPosition), true, true);
progressDialog = ProgressDialog.show(ActivityManagePoi.this, "", getResources().getString(R.string.gettingPosition), true, true);
getLocation();
}
};

View File

@ -29,7 +29,7 @@ import androidx.annotation.RequiresApi;
import java.io.File;
public class ActivityManageSpecificProfile extends Activity
public class ActivityManageProfile extends Activity
{
private static ProgressDialog progressDialog;
final static int intentCodeRingtonePickerCallsFile = 9010;
@ -195,7 +195,7 @@ public class ActivityManageSpecificProfile extends Activity
checkBoxScreenLockUnlockSound.setEnabled(isChecked);
if(isChecked && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
Miscellaneous.messageBox("Info", getResources().getString(R.string.screenLockSoundNotice), ActivityManageSpecificProfile.this).show();
Miscellaneous.messageBox("Info", getResources().getString(R.string.screenLockSoundNotice), ActivityManageProfile.this).show();
}
});
checkBoxChangeHapticFeedback.setOnCheckedChangeListener(new OnCheckedChangeListener()
@ -223,13 +223,13 @@ public class ActivityManageSpecificProfile extends Activity
try
{
if(ActivityMainProfiles.profileToEdit == null)
createProfile(ActivityManageSpecificProfile.this);
createProfile(ActivityManageProfile.this);
else
changeProfile();
}
catch(Exception ex)
{
Toast.makeText(ActivityManageSpecificProfile.this, getResources().getString(R.string.errorWritingFile) + " " + ex.getMessage(), Toast.LENGTH_LONG).show();
Toast.makeText(ActivityManageProfile.this, getResources().getString(R.string.errorWritingFile) + " " + ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
});
@ -440,14 +440,14 @@ public class ActivityManageSpecificProfile extends Activity
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
if (uri != null)
{
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageSpecificProfile.this, uri);
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, uri);
setIncomingCallsRingtone(new File(ringTonePath));
}
break;
}
case intentCodeRingtonePickerCallsFile:
{
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageSpecificProfile.this, data.getData());
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
setIncomingCallsRingtone(new File(ringTonePath));
break;
}
@ -456,14 +456,14 @@ public class ActivityManageSpecificProfile extends Activity
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
if (uri != null)
{
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageSpecificProfile.this, data.getData());
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
setNotificationsRingtone(new File(ringTonePath));
}
break;
}
case intentCodeRingtonePickerNotificationsFile:
{
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageSpecificProfile.this, data.getData());
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
setNotificationsRingtone(new File(ringTonePath));
break;
}

View File

@ -45,7 +45,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
public class ActivityManageSpecificRule extends Activity
public class ActivityManageRule extends Activity
{
final static String activityDetectionClassPath = "com.jens.automation2.receivers.ActivityDetectionReceiver";
@ -54,7 +54,7 @@ public class ActivityManageSpecificRule extends Activity
private ListView triggerListView, actionListView;
private EditText etRuleName;
private CheckBox chkRuleActive, chkRuleToggle;
private static ActivityManageSpecificRule instance = null;
private static ActivityManageRule instance = null;
ImageView imageHelpButton;
private static ProgressDialog progressDialog = null;
@ -96,10 +96,10 @@ public class ActivityManageSpecificRule extends Activity
final static int requestCodeActionScreenBrightnessEdit = 402;
final static int requestCodeActionSendTextMessage = 7001;
public static ActivityManageSpecificRule getInstance()
public static ActivityManageRule getInstance()
{
if(instance == null)
instance = new ActivityManageSpecificRule();
instance = new ActivityManageRule();
return instance;
}
@ -182,7 +182,7 @@ public class ActivityManageSpecificRule extends Activity
finish();
}
else
Toast.makeText(ActivityManageSpecificRule.this, getResources().getString(R.string.errorWritingConfig), Toast.LENGTH_LONG).show();
Toast.makeText(ActivityManageRule.this, getResources().getString(R.string.errorWritingConfig), Toast.LENGTH_LONG).show();
}
else
{
@ -194,7 +194,7 @@ public class ActivityManageSpecificRule extends Activity
finish();
}
else
Toast.makeText(ActivityManageSpecificRule.this, getResources().getString(R.string.errorWritingConfig), Toast.LENGTH_LONG).show();
Toast.makeText(ActivityManageRule.this, getResources().getString(R.string.errorWritingConfig), Toast.LENGTH_LONG).show();
}
}
});
@ -234,7 +234,7 @@ public class ActivityManageSpecificRule extends Activity
// break;
case timeFrame:
ActivityManageTimeFrame.editedTimeFrameTrigger = selectedTrigger;
Intent timeFrameEditor = new Intent(ActivityManageSpecificRule.this, ActivityManageTimeFrame.class);
Intent timeFrameEditor = new Intent(ActivityManageRule.this, ActivityManageTimeFrame.class);
startActivityForResult(timeFrameEditor, requestCodeTriggerTimeframeEdit);
break;
// case usb_host_connection:
@ -243,7 +243,7 @@ public class ActivityManageSpecificRule extends Activity
// break;
case bluetoothConnection:
ActivityManageBluetoothTrigger.editedBluetoothTrigger = selectedTrigger;
Intent bluetoothEditor = new Intent(ActivityManageSpecificRule.this, ActivityManageBluetoothTrigger.class);
Intent bluetoothEditor = new Intent(ActivityManageRule.this, ActivityManageBluetoothTrigger.class);
startActivityForResult(bluetoothEditor, requestCodeTriggerBluetoothEdit);
break;
default:
@ -288,13 +288,13 @@ public class ActivityManageSpecificRule extends Activity
// case setAirplaneMode:
// break;
case startOtherActivity:
Intent intent = new Intent(ActivityManageSpecificRule.this, ActivityManageStartActivity.class);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageStartActivity.class);
ActivityManageStartActivity.resultingAction = a;
intent.putExtra("edit", true);
startActivityForResult(intent, requestCodeActionStartActivityEdit);
break;
case triggerUrl:
Intent activityEditTriggerUrlIntent = new Intent(ActivityManageSpecificRule.this, ActivityEditTriggerUrl.class);
Intent activityEditTriggerUrlIntent = new Intent(ActivityManageRule.this, ActivityEditTriggerUrl.class);
// activityEditTriggerUrlIntent.putExtra("urlToTrigger", a.getParameter2());
ActivityEditTriggerUrl.resultingAction = a;
activityEditTriggerUrlIntent.putExtra("edit", true);
@ -321,19 +321,19 @@ public class ActivityManageSpecificRule extends Activity
// case wakeupDevice:
// break;
case speakText:
Intent activitySpeakTextIntent = new Intent(ActivityManageSpecificRule.this, ActivityEditSpeakText.class);
Intent activitySpeakTextIntent = new Intent(ActivityManageRule.this, ActivityEditSpeakText.class);
ActivityEditSpeakText.resultingAction = a;
activitySpeakTextIntent.putExtra("edit", true);
startActivityForResult(activitySpeakTextIntent, requestCodeActionSpeakTextEdit);
break;
case sendTextMessage:
Intent activitySendTextMessageIntent = new Intent(ActivityManageSpecificRule.this, ActivityEditSendTextMessage.class);
Intent activitySendTextMessageIntent = new Intent(ActivityManageRule.this, ActivityEditSendTextMessage.class);
ActivityEditSendTextMessage.resultingAction = a;
activitySendTextMessageIntent.putExtra("edit", true);
startActivityForResult(activitySendTextMessageIntent, requestCodeActionSendTextMessage);
break;
case setScreenBrightness:
Intent activityEditScreenBrightnessIntent = new Intent(ActivityManageSpecificRule.this, ActivityManageBrightnessSetting.class);
Intent activityEditScreenBrightnessIntent = new Intent(ActivityManageRule.this, ActivityManageBrightnessSetting.class);
// ActivityEditTriggerUrl.resultingAction = a;
activityEditScreenBrightnessIntent.putExtra("autoBrightness", a.getParameter1());
activityEditScreenBrightnessIntent.putExtra("brightnessValue", Integer.parseInt(a.getParameter2()));
@ -368,7 +368,7 @@ public class ActivityManageSpecificRule extends Activity
guiEditing = true;
chkRuleToggle.setChecked(false);
guiEditing = false;
Toast.makeText(ActivityManageSpecificRule.this, getResources().getString(R.string.toggleNotAllowed), Toast.LENGTH_LONG).show();
Toast.makeText(ActivityManageRule.this, getResources().getString(R.string.toggleNotAllowed), Toast.LENGTH_LONG).show();
}
}
});
@ -379,7 +379,7 @@ public class ActivityManageSpecificRule extends Activity
public void onClick(View v)
{
// Open help popup
Miscellaneous.messageBox(getResources().getString(R.string.whatsThis), getResources().getString(R.string.helpTextToggable), ActivityManageSpecificRule.this).show();
Miscellaneous.messageBox(getResources().getString(R.string.whatsThis), getResources().getString(R.string.helpTextToggable), ActivityManageRule.this).show();
}
});
}
@ -455,7 +455,7 @@ public class ActivityManageSpecificRule extends Activity
else if(types[i].toString().equals(Trigger_Enum.phoneCall.toString()))
{
// if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageSpecificRule.this, "android.permission.SEND_SMS") && !Miscellaneous.isGooglePlayInstalled(ActivityManageSpecificRule.this))
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageSpecificRule.this, "android.permission.SEND_SMS"))
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, "android.permission.SEND_SMS"))
items.add(new Item(typesLong[i].toString(), R.drawable.phone));
}
else if(types[i].toString().equals(Trigger_Enum.nfcTag.toString()))
@ -551,7 +551,7 @@ public class ActivityManageSpecificRule extends Activity
Toast.makeText(myContext, getResources().getString(R.string.triggerOnlyAvailableIfPlayServicesInstalled), Toast.LENGTH_LONG).show();
}
else
Miscellaneous.messageBox(getResources().getString(R.string.error), getResources().getString(R.string.featureNotInFdroidVersion), ActivityManageSpecificRule.this).show();
Miscellaneous.messageBox(getResources().getString(R.string.error), getResources().getString(R.string.featureNotInFdroidVersion), ActivityManageRule.this).show();
}
catch (IllegalAccessException | InvocationTargetException e)
{
@ -561,7 +561,7 @@ public class ActivityManageSpecificRule extends Activity
}
else if(triggerType == Trigger_Enum.nfcTag)
{
if(NfcReceiver.checkNfcRequirements(ActivityManageSpecificRule.this, true))
if(NfcReceiver.checkNfcRequirements(ActivityManageRule.this, true))
{
newTrigger.setTriggerType(Trigger_Enum.nfcTag);
Intent nfcEditor = new Intent(myContext, ActivityManageNfc.class);
@ -572,7 +572,7 @@ public class ActivityManageSpecificRule extends Activity
else if(triggerType == Trigger_Enum.bluetoothConnection)
{
if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH))
Miscellaneous.messageBox("Bluetooth", getResources().getString(R.string.deviceDoesNotHaveBluetooth), ActivityManageSpecificRule.this).show();;
Miscellaneous.messageBox("Bluetooth", getResources().getString(R.string.deviceDoesNotHaveBluetooth), ActivityManageRule.this).show();;
newTrigger.setTriggerType(Trigger_Enum.bluetoothConnection);
ActivityManageBluetoothTrigger.editedBluetoothTrigger = newTrigger;
@ -585,7 +585,7 @@ public class ActivityManageSpecificRule extends Activity
if(triggerType == Trigger_Enum.nfcTag)
{
if (NfcReceiver.checkNfcRequirements(ActivityManageSpecificRule.this, true))
if (NfcReceiver.checkNfcRequirements(ActivityManageRule.this, true))
getTriggerParamterDialog(context, booleanChoices).show();
}
else
@ -658,7 +658,7 @@ public class ActivityManageSpecificRule extends Activity
{
progressDialog = ProgressDialog.show(myContext, null, getResources().getString(R.string.gettingListOfInstalledApplications), true, false);
newTrigger.setTriggerType(Trigger_Enum.process_started_stopped);
new GenerateApplicationSelectionsDialogTask().execute(ActivityManageSpecificRule.this);
new GenerateApplicationSelectionsDialogTask().execute(ActivityManageRule.this);
// getTriggerRunningProcessDialog1(myContext).show();
}
else if(triggerType.equals(Trigger_Enum.phoneCall))
@ -820,7 +820,7 @@ public class ActivityManageSpecificRule extends Activity
public void onClick(DialogInterface dialog, int which)
{
newTrigger.setPhoneDirection(which);
getTriggerPhoneNumberDialog(ActivityManageSpecificRule.this).show();
getTriggerPhoneNumberDialog(ActivityManageRule.this).show();
}
});
@ -965,10 +965,10 @@ public class ActivityManageSpecificRule extends Activity
return alertDialog.create();
}
private static class GenerateApplicationSelectionsDialogTask extends AsyncTask<ActivityManageSpecificRule, Void, String[]>
private static class GenerateApplicationSelectionsDialogTask extends AsyncTask<ActivityManageRule, Void, String[]>
{
@Override
protected String[] doInBackground(ActivityManageSpecificRule... params)
protected String[] doInBackground(ActivityManageRule... params)
{
// Looper.prepare();
final String[] applicationArray = ActivityManageStartActivity.getApplicationNameListString(params[0]);
@ -984,13 +984,13 @@ public class ActivityManageSpecificRule extends Activity
progressDialog = null;
}
ActivityManageSpecificRule.getInstance().showProcessDialog(result);
ActivityManageRule.getInstance().showProcessDialog(result);
}
}
void showProcessDialog(String[] programStrings)
{
getTriggerRunningProcessDialog1(ActivityManageSpecificRule.this, programStrings).show();
getTriggerRunningProcessDialog1(ActivityManageRule.this, programStrings).show();
}
private AlertDialog getTriggerRunningProcessDialog1(final Context myContext, final String[] applicationArray)
@ -1026,7 +1026,7 @@ public class ActivityManageSpecificRule extends Activity
{
String packageName = packageArray[which];
getTriggerRunningProcessDialog3(myContext, packageName).show();
Miscellaneous.messageBox(getResources().getString(R.string.hint), getResources().getString(R.string.chooseActivityHint), ActivityManageSpecificRule.this).show();
Miscellaneous.messageBox(getResources().getString(R.string.hint), getResources().getString(R.string.chooseActivityHint), ActivityManageRule.this).show();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
@ -1248,7 +1248,7 @@ public class ActivityManageSpecificRule extends Activity
else if(types[i].toString().equals(Action_Enum.sendTextMessage.toString()))
{
// if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageSpecificRule.this, "android.permission.SEND_SMS") && !Miscellaneous.isGooglePlayInstalled(ActivityManageSpecificRule.this))
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageSpecificRule.this, "android.permission.SEND_SMS"))
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, "android.permission.SEND_SMS"))
items.add(new Item(typesLong[i].toString(), R.drawable.message));
}
else
@ -1303,31 +1303,31 @@ public class ActivityManageSpecificRule extends Activity
newAction.setAction(Action_Enum.setWifi);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
Toast.makeText(context, context.getResources().getString(R.string.android10WifiToggleNotice), Toast.LENGTH_LONG).show();
getActionParameter1Dialog(ActivityManageSpecificRule.this).show();
getActionParameter1Dialog(ActivityManageRule.this).show();
}
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setBluetooth.toString()))
{
if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH))
Miscellaneous.messageBox("Bluetooth", getResources().getString(R.string.deviceDoesNotHaveBluetooth), ActivityManageSpecificRule.this).show();;
Miscellaneous.messageBox("Bluetooth", getResources().getString(R.string.deviceDoesNotHaveBluetooth), ActivityManageRule.this).show();;
newAction.setAction(Action_Enum.setBluetooth);
getActionParameter1Dialog(ActivityManageSpecificRule.this).show();
getActionParameter1Dialog(ActivityManageRule.this).show();
}
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setUsbTethering.toString()))
{
newAction.setAction(Action_Enum.setUsbTethering);
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1)
Toast.makeText(context, context.getResources().getString(R.string.usbTetheringFailForAboveGingerbread), Toast.LENGTH_LONG).show();
getActionParameter1Dialog(ActivityManageSpecificRule.this).show();
getActionParameter1Dialog(ActivityManageRule.this).show();
}
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setWifiTethering.toString()))
{
newAction.setAction(Action_Enum.setWifiTethering);
getActionParameter1Dialog(ActivityManageSpecificRule.this).show();
getActionParameter1Dialog(ActivityManageRule.this).show();
}
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setDisplayRotation.toString()))
{
newAction.setAction(Action_Enum.setDisplayRotation);
getActionParameter1Dialog(ActivityManageSpecificRule.this).show();
getActionParameter1Dialog(ActivityManageRule.this).show();
}
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.changeSoundProfile.toString()))
{
@ -1342,34 +1342,34 @@ public class ActivityManageSpecificRule extends Activity
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.startOtherActivity.toString()))
{
newAction.setAction(Action_Enum.startOtherActivity);
Intent intent = new Intent(ActivityManageSpecificRule.this, ActivityManageStartActivity.class);
Intent intent = new Intent(ActivityManageRule.this, ActivityManageStartActivity.class);
startActivityForResult(intent, 3000);
}
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.waitBeforeNextAction.toString()))
{
newAction.setAction(Action_Enum.waitBeforeNextAction);
getActionWaitBeforeNextActionDialog(ActivityManageSpecificRule.this).show();
getActionWaitBeforeNextActionDialog(ActivityManageRule.this).show();
}
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.wakeupDevice.toString()))
{
newAction.setAction(Action_Enum.wakeupDevice);
getActionWakeupDeviceDialog(ActivityManageSpecificRule.this).show();
getActionWakeupDeviceDialog(ActivityManageRule.this).show();
}
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setAirplaneMode.toString()))
{
if(Build.VERSION.SDK_INT >= 17)
{
Toast.makeText(context, getResources().getString(R.string.airplaneModeSdk17Warning), Toast.LENGTH_LONG).show();
Miscellaneous.messageBox(getResources().getString(R.string.airplaneMode), getResources().getString(R.string.rootExplanation), ActivityManageSpecificRule.this).show();
Miscellaneous.messageBox(getResources().getString(R.string.airplaneMode), getResources().getString(R.string.rootExplanation), ActivityManageRule.this).show();
}
newAction.setAction(Action_Enum.setAirplaneMode);
getActionParameter1Dialog(ActivityManageSpecificRule.this).show();
getActionParameter1Dialog(ActivityManageRule.this).show();
}
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setDataConnection.toString()))
{
newAction.setAction(Action_Enum.setDataConnection);
getActionParameter1Dialog(ActivityManageSpecificRule.this).show();
Miscellaneous.messageBox(getResources().getString(R.string.actionDataConnection), getResources().getString(R.string.rootExplanation), ActivityManageSpecificRule.this).show();
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()))
{
@ -1382,7 +1382,7 @@ public class ActivityManageSpecificRule extends Activity
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.sendTextMessage.toString()))
{
// if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageSpecificRule.this, "android.permission.SEND_SMS") && !Miscellaneous.isGooglePlayInstalled(ActivityManageSpecificRule.this))
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageSpecificRule.this, "android.permission.SEND_SMS"))
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, "android.permission.SEND_SMS"))
{
//launch other activity to enter parameters;
newAction.setAction(Action_Enum.sendTextMessage);
@ -1482,7 +1482,7 @@ public class ActivityManageSpecificRule extends Activity
else
{
// Is already at the top
Toast.makeText(ActivityManageSpecificRule.this, getResources().getString(R.string.cantMoveUp), Toast.LENGTH_LONG).show();
Toast.makeText(ActivityManageRule.this, getResources().getString(R.string.cantMoveUp), Toast.LENGTH_LONG).show();
}
break;
case 2:
@ -1497,7 +1497,7 @@ public class ActivityManageSpecificRule extends Activity
else
{
// Is already at the bottom
Toast.makeText(ActivityManageSpecificRule.this, getResources().getString(R.string.cantMoveDown), Toast.LENGTH_LONG).show();
Toast.makeText(ActivityManageRule.this, getResources().getString(R.string.cantMoveDown), Toast.LENGTH_LONG).show();
}
break;
}
@ -1583,8 +1583,8 @@ public class ActivityManageSpecificRule extends Activity
{
if(input.getText().toString().length() == 0| input.getText().toString().equals("0") | input.getText().toString().contains(",") | input.getText().toString().contains("."))
{
Toast.makeText(myContext, ActivityManageSpecificRule.this.getResources().getString(R.string.enterAPositiveValidNonDecimalNumber), Toast.LENGTH_LONG).show();
getActionWaitBeforeNextActionDialog(ActivityManageSpecificRule.this).show();
Toast.makeText(myContext, ActivityManageRule.this.getResources().getString(R.string.enterAPositiveValidNonDecimalNumber), Toast.LENGTH_LONG).show();
getActionWaitBeforeNextActionDialog(ActivityManageRule.this).show();
}
else
{
@ -1625,8 +1625,8 @@ public class ActivityManageSpecificRule extends Activity
{
if(input.getText().toString().length() == 0| input.getText().toString().contains(",") | input.getText().toString().contains("."))
{
Toast.makeText(myContext, ActivityManageSpecificRule.this.getResources().getString(R.string.enterAPositiveValidNonDecimalNumber), Toast.LENGTH_LONG).show();
getActionWakeupDeviceDialog(ActivityManageSpecificRule.this).show();
Toast.makeText(myContext, ActivityManageRule.this.getResources().getString(R.string.enterAPositiveValidNonDecimalNumber), Toast.LENGTH_LONG).show();
getActionWakeupDeviceDialog(ActivityManageRule.this).show();
}
else
{

View File

@ -83,14 +83,15 @@ public class ActivityPermissions extends Activity
}
});
bRequestPermissions.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
finish();
}
});
// bRequestPermissions.setOnClickListener(new View.OnClickListener()
// {
// @Override
// public void onClick(View v)
// {
// finish();
// }
// });
bRequestPermissions.setOnClickListener(new View.OnClickListener()
{
@Override

View File

@ -36,6 +36,7 @@ public class AutomationService extends Service implements OnInitListener
{
protected TextToSpeech ttsEngine = null;
protected final static int notificationId = 1000;
protected final static int notificationIdRestrictions = 1005;
final static String NOTIFICATION_CHANNEL_ID = "com.jens.automation2";
final static String channelName = "Automation notifications";
@ -373,18 +374,18 @@ public class AutomationService extends Service implements OnInitListener
protected void checkForRestrictedFeatures()
{
try
if(Rule.isAnyRuleUsing(Trigger_Enum.activityDetection))
{
Class testClass = Class.forName(ActivityManageSpecificRule.activityDetectionClassPath);
}
catch (ClassNotFoundException e)
{
if(Rule.isAnyRuleUsing(Trigger_Enum.activityDetection))
try
{
Intent intent = new Intent(AutomationService.this, ActivityMainScreen.class);
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath);
}
catch (ClassNotFoundException e)
{
Intent intent = new Intent(AutomationService.this, ActivityMainTabLayout.class);
PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, 0);
// Miscellaneous.createDismissableNotification(getResources().getString(R.string.settingsReferringToRestrictedFeatures), ActivityPermissions.notificationIdPermissions, pi);
Miscellaneous.createDismissableNotification(getResources().getString(R.string.settingsReferringToRestrictedFeatures), 1, pi);
Miscellaneous.createDismissableNotification(getResources().getString(R.string.settingsReferringToRestrictedFeatures), notificationIdRestrictions, pi);
}
}
}

View File

@ -18,7 +18,7 @@ import com.jens.automation2.receivers.TimeZoneListener;
import androidx.annotation.RequiresApi;
import static com.jens.automation2.ActivityManageSpecificRule.activityDetectionClassPath;
import static com.jens.automation2.ActivityManageRule.activityDetectionClassPath;
/**
* Created by jens on 08.03.2017.
@ -165,7 +165,7 @@ public class ReceiverCoordinator
try
{
Class testClass = Class.forName(ActivityManageSpecificRule.activityDetectionClassPath);
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath);
//startActivityDetectionReceiver
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.activityDetection))
{
@ -202,7 +202,7 @@ public class ReceiverCoordinator
try
{
Class testClass = Class.forName(ActivityManageSpecificRule.activityDetectionClassPath);
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath);
Miscellaneous.runMethodReflective("ActivityDetectionReceiver", "stopActivityDetectionReceiver", null);
// ActivityDetectionReceiver.stopActivityDetectionReceiver();
}

View File

@ -8,8 +8,6 @@ import androidx.annotation.RequiresApi;
import com.jens.automation2.receivers.BluetoothReceiver;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -355,13 +353,13 @@ public class Trigger
case activityDetection:
try
{
Class testClass = Class.forName(ActivityManageSpecificRule.activityDetectionClassPath);
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath);
if (ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), "com.google.android.gms.permission.ACTIVITY_RECOGNITION"))
{
// This type doesn't have an activate/deactivate equivalent, at least not yet.
// try
// {
returnString.append(Miscellaneous.runMethodReflective(ActivityManageSpecificRule.activityDetectionClassPath, "getDescription", new Object[]{getActivityDetectionType()}));
returnString.append(Miscellaneous.runMethodReflective(ActivityManageRule.activityDetectionClassPath, "getDescription", new Object[]{getActivityDetectionType()}));
// for(Method method : activityDetection.getMethods())
// {
// if(method.getName().equalsIgnoreCase("getDescription"))

View File

@ -37,6 +37,18 @@
android:textColor="@color/importantMessage"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvMainScreenNote2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:scrollHorizontally="false"
android:textColor="@color/importantMessage"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TableLayout
android:layout_width="fill_parent"