Calendar trigger
This commit is contained in:
parent
d2606b72cd
commit
2ba25a9e65
@ -144,7 +144,7 @@ public class Action
|
||||
case takeScreenshot:
|
||||
return context.getResources().getString(R.string.takeScreenshot);
|
||||
case setLocationService:
|
||||
return context.getResources().getString(R.string.setLocationService);
|
||||
return context.getResources().getString(R.string.setLocationServiceCapital);
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
@ -644,6 +644,8 @@ public class ActivityManageRule extends Activity
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.router));
|
||||
else if(types[i].toString().equals(Trigger_Enum.subSystemState.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.subsystemstate));
|
||||
else if(types[i].toString().equals(Trigger_Enum.checkVariable.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.variable));
|
||||
else if(types[i].toString().equals(Trigger_Enum.calendarEvent.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.calendar));
|
||||
else
|
||||
@ -2203,6 +2205,8 @@ public class ActivityManageRule extends Activity
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.clipboard));
|
||||
else if(types[i].toString().equals(Action_Enum.takeScreenshot.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.copier));
|
||||
else if(types[i].toString().equals(Action_Enum.setVariable.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.variable));
|
||||
else if(types[i].toString().equals(Action_Enum.setLocationService.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.compass_small));
|
||||
else
|
||||
|
@ -12,6 +12,7 @@ import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@ -30,6 +31,7 @@ public class ActivityManageTriggerCalendar extends Activity
|
||||
Button bSaveTriggerCalendar;
|
||||
List<CheckBox> checkboxesCalendars = new ArrayList<>();
|
||||
final static String separator = ",";
|
||||
TextView tvMissingCalendarHint;
|
||||
|
||||
private static String[] directions;
|
||||
ArrayAdapter<String> directionSpinnerAdapter;
|
||||
@ -51,6 +53,8 @@ public class ActivityManageTriggerCalendar extends Activity
|
||||
chkCalendarAvailabilityOutOfOffice = (CheckBox)findViewById(R.id.chkCalendarAvailabilityOutOfOffice);
|
||||
chkCalendarAvailabilityWorkingElsewhere = (CheckBox)findViewById(R.id.chkCalendarAvailabilityWorkingElsewhere);
|
||||
|
||||
tvMissingCalendarHint = (TextView) findViewById(R.id.tvMissingCalendarHint);
|
||||
|
||||
llCalendarSelection = (LinearLayout)findViewById(R.id.llCalendarSelection);
|
||||
|
||||
etCalendarTitle = (EditText)findViewById(R.id.etCalendarTitle);
|
||||
@ -207,6 +211,8 @@ public class ActivityManageTriggerCalendar extends Activity
|
||||
chkCalendarAvailabilityWorkingElsewhere.setChecked(true);
|
||||
}
|
||||
|
||||
List<String> usedCalendarIDs = new ArrayList<>();
|
||||
List<String> unusedCalendarIDs = new ArrayList<>();
|
||||
for(CheckBox checkbox : checkboxesCalendars)
|
||||
{
|
||||
int id = ((CalendarReceiver.AndroidCalendar)checkbox.getTag()).calendarId;
|
||||
@ -214,11 +220,27 @@ public class ActivityManageTriggerCalendar extends Activity
|
||||
{
|
||||
if(calId.equals(String.valueOf(id)))
|
||||
{
|
||||
usedCalendarIDs.add(String.valueOf(id));
|
||||
checkbox.setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(String calId : calendars)
|
||||
{
|
||||
if(!Miscellaneous.arraySearch((ArrayList<String>) usedCalendarIDs, calId, false, true))
|
||||
unusedCalendarIDs.add(calId);
|
||||
}
|
||||
if(unusedCalendarIDs.size() > 0)
|
||||
{
|
||||
/*
|
||||
A calendar has been configured that has been deleted since. We cannot resolve it.
|
||||
It will be removed with the next save, but we should inform this user
|
||||
of these circumstances.
|
||||
*/
|
||||
|
||||
tvMissingCalendarHint.setText(String.format(getResources().getString(R.string.calendarsMissingHint), Miscellaneous.explode(", ", (ArrayList<String>) unusedCalendarIDs)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -622,7 +622,7 @@ public class Trigger
|
||||
try
|
||||
{
|
||||
String[] conditions = this.getTriggerParameter2().split(Trigger.triggerParameter2Split);
|
||||
List<CalendarReceiver.CalendarEvent> calendarEvents = CalendarReceiver.readCalendarEvents(AutomationService.getInstance(), true);
|
||||
List<CalendarReceiver.CalendarEvent> calendarEvents = CalendarReceiver.readCalendarEvents(AutomationService.getInstance(), false);
|
||||
|
||||
/*
|
||||
0 = titleDirection
|
||||
@ -1917,6 +1917,40 @@ public class Trigger
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.eventIsCurrentlyHappening));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.eventIsCurrentlyNotHappening));
|
||||
|
||||
String[] conditions = triggerParameter2.split(triggerParameter2Split, -1);
|
||||
|
||||
if(
|
||||
!StringUtils.isEmpty(conditions[1])
|
||||
||
|
||||
!StringUtils.isEmpty(conditions[3])
|
||||
||
|
||||
!StringUtils.isEmpty(conditions[5])
|
||||
||
|
||||
!StringUtils.isEmpty(conditions[6])
|
||||
||
|
||||
!StringUtils.isEmpty(conditions[7]))
|
||||
{
|
||||
returnString.append(" (");
|
||||
|
||||
if (!StringUtils.isEmpty(conditions[1]))
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.title) + " " + conditions[0] + " " + conditions[1] + ", ");
|
||||
if (!StringUtils.isEmpty(conditions[3]))
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.location) + " " + conditions[2] + " " + conditions[3] + ", ");
|
||||
if (!StringUtils.isEmpty(conditions[5]))
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.calendarDescription) + " " + conditions[4] + " " + conditions[5] + ", ");
|
||||
|
||||
if (!StringUtils.isEmpty(conditions[6]))
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.availabilities) + " " + conditions[6] + ", ");
|
||||
|
||||
if (!StringUtils.isEmpty(conditions[7]))
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.calendars) + " " + conditions[7]);
|
||||
|
||||
if (returnString.toString().endsWith(", "))
|
||||
returnString.delete(returnString.length() - 2, returnString.length());
|
||||
|
||||
returnString.append(")");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
returnString.append("error");
|
||||
|
BIN
app/src/main/res/drawable-hdpi/variable.png
Normal file
BIN
app/src/main/res/drawable-hdpi/variable.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
@ -275,6 +275,13 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvMissingCalendarHint"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
@ -899,6 +899,7 @@
|
||||
<string name="accessibility_service_explanation">Required for certain actions.</string>
|
||||
<string name="noticeRestrictedPermissions">If you fail to grant one the following permission and a system message like \"Restricted permission\" you need to go to Android settings first, then applications, choose Automation. Now there should be 3 dots in the upper right corner. Click \"Allow restricted settings\". After that the necessary permission should be grantable. This should only apply to the APK version of the app, not the ones from F-Droid or Play Store.</string>
|
||||
<string name="setLocationService">set location service</string>
|
||||
<string name="setLocationServiceCapital">Set location service</string>
|
||||
<string name="writeSecureSettingsNotice">Unfortunately the permission WRITE_SECURE_SETTINGS cannot be given directly on your Android device. Instead you need to connect your device to a computer and grant the permission via ADB. Click here to find out how to grant it: https://server47.de/automation/adb_hack.php</string>
|
||||
<string name="actionSetLocationService">Location service</string>
|
||||
<string name="LOCATION_MODE_SENSOR_ONLY" translatable="false">SENSOR_ONLY</string>
|
||||
@ -920,4 +921,7 @@
|
||||
<string name="selectingNoneItemForAllToMatch">Select no item if any will do.</string>
|
||||
<string name="calendars">Calendars</string>
|
||||
<string name="calendarAvailabilityTypesUnsupported">It may be that only the first 3 types are actually working becaue the other types are not part of Google Calendar.</string>
|
||||
<string name="anyCalendar">any calender</string>
|
||||
<string name="availabilities">availabilities</string>
|
||||
<string name="calendarsMissingHint">In this trigger calendars with IDs %1$s have been previously configured, but have been deleted since. With the next save those will be removed from this trigger. Until then this trigger/condition will never be met.</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user