notification action
This commit is contained in:
parent
83ee19b4fa
commit
94f6418076
@ -8,7 +8,7 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "com.jens.automation2"
|
||||
minSdkVersion 16
|
||||
compileSdkVersion 29
|
||||
compileSdkVersion 31
|
||||
buildToolsVersion '29.0.2'
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
versionCode 118
|
||||
|
@ -480,7 +480,6 @@ public class ActivityManageRule extends Activity
|
||||
|
||||
for(int i=0; i<types.length; i++)
|
||||
{
|
||||
//pointOfInterest, timeFrame, charging, batteryLevel, usb_host_connection, speed, noiseLevel, wifiConnection, process_started_stopped;
|
||||
if(types[i].toString().equals(Trigger_Enum.pointOfInterest.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.compass_small));
|
||||
else if(types[i].toString().equals(Trigger_Enum.timeFrame.toString()))
|
||||
@ -505,7 +504,6 @@ public class ActivityManageRule extends Activity
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.roaming));
|
||||
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(ActivityManageRule.this, "android.permission.SEND_SMS"))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.phone));
|
||||
}
|
||||
@ -686,6 +684,12 @@ public class ActivityManageRule extends Activity
|
||||
startActivityForResult(bluetoothEditor, requestCodeTriggerBluetoothAdd);
|
||||
return;
|
||||
}
|
||||
else if(triggerType == Trigger_Enum.screenState)
|
||||
{
|
||||
newTrigger.setTriggerType(Trigger_Enum.screenState);
|
||||
getTriggerScreenStateDialog().show();
|
||||
return;
|
||||
}
|
||||
else if(triggerType == Trigger_Enum.headsetPlugged)
|
||||
booleanChoices = new String[]{getResources().getString(R.string.connected), getResources().getString(R.string.disconnected)};
|
||||
|
||||
@ -1017,6 +1021,33 @@ public class ActivityManageRule extends Activity
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
|
||||
private AlertDialog getTriggerScreenStateDialog()
|
||||
{
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
|
||||
|
||||
alertDialog.setTitle(Miscellaneous.getAnyContext().getResources().getString(R.string.selectDesiredState));
|
||||
|
||||
String[] choices = {
|
||||
Miscellaneous.getAnyContext().getResources().getString(R.string.off),
|
||||
Miscellaneous.getAnyContext().getResources().getString(R.string.on),
|
||||
Miscellaneous.getAnyContext().getResources().getString(R.string.unlocked)
|
||||
};
|
||||
|
||||
alertDialog.setItems(choices, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
newTrigger.setTriggerParameter2(String.valueOf(which));
|
||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||
refreshTriggerList();
|
||||
}
|
||||
});
|
||||
|
||||
return alertDialog.create();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||
private AlertDialog getTriggerActivityDetectionDialog()
|
||||
{
|
||||
|
@ -1066,6 +1066,8 @@ public class Trigger
|
||||
return context.getResources().getString(R.string.deviceOrientation);
|
||||
case profileActive:
|
||||
return context.getResources().getString(R.string.profile);
|
||||
case screenState:
|
||||
return context.getResources().getString(R.string.screenState);
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
@ -1516,10 +1518,24 @@ public class Trigger
|
||||
returnString.append(String.format(Miscellaneous.getAnyContext().getString(R.string.profileNotActive), getTriggerParameter2().split(Trigger.triggerParameter2Split)[0]));
|
||||
break;
|
||||
case screenState:
|
||||
if(triggerParameter)
|
||||
returnString.append(String.format(Miscellaneous.getAnyContext().getString(R.string.screenIs), getTriggerParameter2().split(Trigger.triggerParameter2Split)[0]));
|
||||
else
|
||||
returnString.append(String.format(Miscellaneous.getAnyContext().getString(R.string.profileNotActive), getTriggerParameter2().split(Trigger.triggerParameter2Split)[0]));
|
||||
String state;
|
||||
switch(triggerParameter2)
|
||||
{
|
||||
case "0":
|
||||
state = Miscellaneous.getAnyContext().getString(R.string.off);
|
||||
break;
|
||||
case "1":
|
||||
state = Miscellaneous.getAnyContext().getString(R.string.on);
|
||||
break;
|
||||
case "2":
|
||||
state = Miscellaneous.getAnyContext().getString(R.string.unlocked);
|
||||
break;
|
||||
default:
|
||||
state = Miscellaneous.getAnyContext().getString(R.string.unknown);
|
||||
}
|
||||
|
||||
returnString.append(String.format(Miscellaneous.getAnyContext().getString(R.string.screenIs), state));
|
||||
|
||||
break;
|
||||
default:
|
||||
returnString.append("error");
|
||||
@ -1573,11 +1589,7 @@ public class Trigger
|
||||
public static String[] getTriggerTypesAsArray()
|
||||
{
|
||||
ArrayList<String> triggerTypesList = new ArrayList<String>();
|
||||
|
||||
/*for(int i=0; i<Trigger_Enum.values().length; i++)
|
||||
{
|
||||
triggerTypesList.add(Trigger_Enum.values()[i].toString());
|
||||
}*/
|
||||
|
||||
for(Trigger_Enum triggerType : Trigger_Enum.values())
|
||||
triggerTypesList.add(triggerType.name());
|
||||
|
||||
|
@ -68,11 +68,6 @@ public class ScreenStateReceiver extends BroadcastReceiver implements Automation
|
||||
{
|
||||
return screenStateReceiverActive;
|
||||
}
|
||||
|
||||
public static boolean isUsbHostConnected()
|
||||
{
|
||||
return usbHostConnected;
|
||||
}
|
||||
|
||||
public static int getScreenState()
|
||||
{
|
||||
|
@ -769,4 +769,9 @@
|
||||
<string name="controlCenter">Control center</string>
|
||||
<string name="sendEmailToDev">Send email to developer</string>
|
||||
<string name="screenIs">screen is %1$s</string>
|
||||
<string name="on">on</string>
|
||||
<string name="off">off</string>
|
||||
<string name="unlocked">unlocked</string>
|
||||
<string name="selectDesiredState">Select desired state</string>
|
||||
<string name="screenState">Screen state</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user