forked from jens/Automation
Calendar trigger
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user