triggerUrl with POST params

This commit is contained in:
jens 2024-01-02 16:36:10 +01:00
parent 58ec35aae5
commit 8b193aa89c
21 changed files with 424 additions and 205 deletions

View File

@ -18,7 +18,7 @@ public class MyGoogleApiClient
public com.google.android.gms.appindexing.Action getIndexApiAction() public com.google.android.gms.appindexing.Action getIndexApiAction()
{ {
Thing object = new Thing.Builder() Thing object = new Thing.Builder()
.setName("ActivityMainScreen Page") // TODO: Define a title for the content shown. .setName("ActivityMainScreen Page")
// TODO: Make sure this auto-generated URL is correct. // TODO: Make sure this auto-generated URL is correct.
.setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]")) .setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
.build(); .build();

View File

@ -9,7 +9,9 @@ import android.widget.Toast;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
public class Action public class Action
@ -18,6 +20,8 @@ public class Action
public static final String actionParameter2Split = "ap2split"; public static final String actionParameter2Split = "ap2split";
public static final String intentPairSeparator = "intPairSplit"; public static final String intentPairSeparator = "intPairSplit";
public static final String actionParameters2SeparatorInner = "a2splitInner";
public static final String actionParameters2SeparatorOuter = "a2splitOuter";
public static final String vibrateSeparator = ","; public static final String vibrateSeparator = ",";
public enum Action_Enum public enum Action_Enum
@ -683,8 +687,13 @@ public class Action
String password = null; String password = null;
String method = ActivityManageActionTriggerUrl.methodGet; String method = ActivityManageActionTriggerUrl.methodGet;
String url; String url;
String params = null;
String[] components = getParameter2().split(";"); String[] components;
if(getParameter2().contains(Action.actionParameter2Split))
components = getParameter2().split(Action.actionParameter2Split);
else
components = getParameter2().split(";");
if(components.length >= 3) if(components.length >= 3)
{ {
@ -694,6 +703,11 @@ public class Action
if(components.length >= 4) if(components.length >= 4)
method = components[3]; method = components[3];
if(components.length >= 5)
{
params = components[4];
}
} }
else // compatibility for very old versions which haven't upgraded, yet. else // compatibility for very old versions which haven't upgraded, yet.
url = components[0]; url = components[0];
@ -701,15 +715,16 @@ public class Action
try try
{ {
url = Miscellaneous.replaceVariablesInText(url, context); url = Miscellaneous.replaceVariablesInText(url, context);
params = Miscellaneous.replaceVariablesInText(params, context);
Actions myAction = new Actions(); Actions myAction = new Actions();
Miscellaneous.logEvent("i", "HTTP", "Attempting download of " + url, 4); //getResources().getString("attemptingDownloadOf"); Miscellaneous.logEvent("i", "HTTP", "Attempting download of " + url, 4); //getResources().getString("attemptingDownloadOf");
if(this.getParameter1()) // use authentication if(this.getParameter1()) // use authentication
new DownloadTask().execute(url, username, password, method); new DownloadTask().execute(url, username, password, method, params);
else else
new DownloadTask().execute(url, null, null); new DownloadTask().execute(url, null, null, params);
} }
catch(Exception e) catch(Exception e)
{ {
@ -724,12 +739,14 @@ public class Action
{ {
Thread.setDefaultUncaughtExceptionHandler(Miscellaneous.uncaughtExceptionHandler); Thread.setDefaultUncaughtExceptionHandler(Miscellaneous.uncaughtExceptionHandler);
int attempts=1; int attempts = 1;
String urlString=parameters[0]; String urlString=parameters[0];
String urlUsername = null; String urlUsername = null;
String urlPassword = null; String urlPassword = null;
String method = ActivityManageActionTriggerUrl.methodGet; String method = ActivityManageActionTriggerUrl.methodGet;
Map<String,String> httpParams = new HashMap<>();
if(parameters.length >= 3) if(parameters.length >= 3)
{ {
urlUsername = parameters[1]; urlUsername = parameters[1];
@ -737,6 +754,18 @@ public class Action
if(parameters.length >= 4) if(parameters.length >= 4)
method = parameters[3]; method = parameters[3];
empty params are omitted instead of being empty
if(parameters.length >= 5)
{
// has params
String[] paramPairs = parameters[4].split(Action.actionParameters2SeparatorOuter);
for(String pair : paramPairs)
{
String[] pieces = pair.split(Action.actionParameters2SeparatorInner);
httpParams.put(pieces[0], pieces[1]);
}
}
} }
String response = "HTTP_ERROR"; String response = "HTTP_ERROR";
@ -750,9 +779,9 @@ public class Action
// Either thorough checking or no encryption // Either thorough checking or no encryption
if(!Settings.httpAcceptAllCertificates || !urlString.toLowerCase(Locale.getDefault()).contains("https")) if(!Settings.httpAcceptAllCertificates || !urlString.toLowerCase(Locale.getDefault()).contains("https"))
response = Miscellaneous.downloadURL(urlString, urlUsername, urlPassword, method); response = Miscellaneous.downloadURL(urlString, urlUsername, urlPassword, method, httpParams);
else else
response = Miscellaneous.downloadURLwithoutCertificateChecking(urlString, urlUsername, urlPassword, method); response = Miscellaneous.downloadURLwithoutCertificateChecking(urlString, urlUsername, urlPassword, method, httpParams);
try try
{ {

View File

@ -236,8 +236,6 @@ public class ActivityManageActionSendBroadcast extends Activity
@Override @Override
public void onNothingSelected(AdapterView<?> arg0) public void onNothingSelected(AdapterView<?> arg0)
{ {
// TODO Auto-generated method stub
} }
}); });
} }

View File

@ -242,8 +242,7 @@ public class ActivityManageActionStartActivity extends Activity
else else
parameter2 += Actions.dummyPackageString + Action.actionParameter2Split + etActivityOrActionPath.getText().toString(); parameter2 += Actions.dummyPackageString + Action.actionParameter2Split + etActivityOrActionPath.getText().toString();
// if(etClassName.getText().toString().length() > 0) parameter2 += Action.actionParameter2Split + etClassName.getText().toString();
parameter2 += Action.actionParameter2Split + etClassName.getText().toString();
} }
if (rbStartAppByActivity.isChecked()) if (rbStartAppByActivity.isChecked())
@ -292,8 +291,6 @@ public class ActivityManageActionStartActivity extends Activity
@Override @Override
public void onNothingSelected(AdapterView<?> arg0) public void onNothingSelected(AdapterView<?> arg0)
{ {
// TODO Auto-generated method stub
} }
}); });

View File

@ -1,6 +1,9 @@
package com.jens.automation2; package com.jens.automation2;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -17,23 +20,28 @@ import android.widget.RadioButton;
import android.widget.TableLayout; import android.widget.TableLayout;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import com.jens.automation2.Action.Action_Enum; import com.jens.automation2.Action.Action_Enum;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Map; import java.util.Map;
public class ActivityManageActionTriggerUrl extends Activity public class ActivityManageActionTriggerUrl extends Activity
{ {
Button bSaveTriggerUrl; Button bSaveTriggerUrl, bAddHttpParam;
EditText etTriggerUrl, etTriggerUrlUsername, etTriggerUrlPassword; EditText etTriggerUrl, etTriggerUrlUsername, etTriggerUrlPassword, etParameterName, etParameterValue;
ListView lvTriggerUrlPostParameters; ListView lvTriggerUrlPostParameters;
CheckBox chkTriggerUrlUseAuthentication; CheckBox chkTriggerUrlUseAuthentication;
RadioButton rbTriggerUrlMethodGet, rbTriggerUrlMethodPost; RadioButton rbTriggerUrlMethodGet, rbTriggerUrlMethodPost;
TableLayout tlTriggerUrlAuthentication; TableLayout tlTriggerUrlAuthentication;
ArrayAdapter<String> httpParametersAdapter;
private ArrayList<String> httpParamsList = new ArrayList<>();
ArrayAdapter<Map<String,String>> lvTriggerUrlPostParametersAdapter; ArrayAdapter<Map<String,String>> lvTriggerUrlPostParametersAdapter;
// private String existingUrl = "";
public static final String methodGet = "GET"; public static final String methodGet = "GET";
public static final String methodPost = "POST"; public static final String methodPost = "POST";
@ -56,6 +64,29 @@ public class ActivityManageActionTriggerUrl extends Activity
bSaveTriggerUrl = (Button)findViewById(R.id.bSaveSpeakText); bSaveTriggerUrl = (Button)findViewById(R.id.bSaveSpeakText);
rbTriggerUrlMethodGet = (RadioButton) findViewById(R.id.rbTriggerUrlMethodGet); rbTriggerUrlMethodGet = (RadioButton) findViewById(R.id.rbTriggerUrlMethodGet);
rbTriggerUrlMethodPost = (RadioButton) findViewById(R.id.rbTriggerUrlMethodPost); rbTriggerUrlMethodPost = (RadioButton) findViewById(R.id.rbTriggerUrlMethodPost);
etTriggerUrl = (EditText) findViewById(R.id.etTriggerUrl);
etParameterName = (EditText) findViewById(R.id.etParameterName);
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
bAddHttpParam = (Button)findViewById(R.id.bAddHttpParam);
etParameterName.setEnabled(false);
etParameterValue.setEnabled(false);
bAddHttpParam.setEnabled(false);
rbTriggerUrlMethodPost.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked)
{
etParameterName.setEnabled(checked);
etParameterValue.setEnabled(checked);
bAddHttpParam.setEnabled(checked);
if(checked)
lvTriggerUrlPostParameters.setVisibility(View.VISIBLE);
}
});
httpParametersAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, httpParamsList);
bSaveTriggerUrl.setOnClickListener(new OnClickListener() bSaveTriggerUrl.setOnClickListener(new OnClickListener()
{ {
@ -65,33 +96,38 @@ public class ActivityManageActionTriggerUrl extends Activity
if(etTriggerUrl.getText().toString().length() > 0) if(etTriggerUrl.getText().toString().length() > 0)
{ {
if(resultingAction == null) if(resultingAction == null)
{
resultingAction = new Action(); resultingAction = new Action();
}
resultingAction.setAction(Action_Enum.triggerUrl); resultingAction.setAction(Action_Enum.triggerUrl);
resultingAction.setParameter1(chkTriggerUrlUseAuthentication.isChecked()); resultingAction.setParameter1(chkTriggerUrlUseAuthentication.isChecked());
String username = etTriggerUrlUsername.getText().toString(); String username = etTriggerUrlUsername.getText().toString();
String password = etTriggerUrlPassword.getText().toString(); String password = etTriggerUrlPassword.getText().toString();
if(username == null) if(username == null)
username = ""; username = "";
if(password == null) if(password == null)
password = ""; password = "";
String method = methodGet; String method = methodGet;
if(rbTriggerUrlMethodPost.isChecked()) if(rbTriggerUrlMethodPost.isChecked())
method = methodPost; method = methodPost;
ActivityManageActionTriggerUrl.resultingAction.setParameter2( String httpParams = "";
username + ";" + for (String s : httpParamsList)
password + ";" + httpParams += Action.actionParameters2SeparatorOuter + s;
etTriggerUrl.getText().toString().trim() + ";" + if(httpParams.length() > 0)
method httpParams = httpParams.substring(Action.actionParameters2SeparatorOuter.length());
);
ActivityManageActionTriggerUrl.resultingAction.setParameter2(
username + Action.actionParameter2Split +
password + Action.actionParameter2Split +
etTriggerUrl.getText().toString().trim() + Action.actionParameter2Split +
method + Action.actionParameter2Split +
httpParams
);
//TODO: Check if http params listview is scrollable
backToRuleManager(); backToRuleManager();
} }
else else
@ -137,8 +173,13 @@ public class ActivityManageActionTriggerUrl extends Activity
ActivityManageActionTriggerUrl.edit = getIntent().getBooleanExtra("edit", false); ActivityManageActionTriggerUrl.edit = getIntent().getBooleanExtra("edit", false);
if(edit) if(edit)
{ {
// username,password,URL // username,password,URL,etc.
String[] components = ActivityManageActionTriggerUrl.resultingAction.getParameter2().split(";"); String[] components;
if(ActivityManageActionTriggerUrl.resultingAction.getParameter2().contains(Action.actionParameter2Split))
components = ActivityManageActionTriggerUrl.resultingAction.getParameter2().split(Action.actionParameter2Split, -1);
else
components = ActivityManageActionTriggerUrl.resultingAction.getParameter2().split(";", -1);
if(components.length >= 3) if(components.length >= 3)
{ {
@ -160,10 +201,54 @@ public class ActivityManageActionTriggerUrl extends Activity
break; break;
} }
} }
if(components.length >= 5)
{
if(!StringUtils.isEmpty(components[4]) && components[4].contains(Action.actionParameters2SeparatorInner))
{
String httpParams[] = components[4].split(Action.actionParameters2SeparatorOuter);
for (String paramPair : httpParams)
httpParamsList.add(paramPair);
updateHttpParamsList();
}
}
} }
else else
etTriggerUrl.setText(components[0]); etTriggerUrl.setText(components[0]);
} }
bAddHttpParam.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
if(StringUtils.isEmpty(etParameterName.getText()) || StringUtils.isEmpty(etParameterValue.getText()))
{
Toast.makeText(ActivityManageActionTriggerUrl.this, getResources().getString(R.string.enterValidDataIntoParametersFields), Toast.LENGTH_SHORT).show();
return;
}
httpParamsList.add(etParameterName.getText() + Action.actionParameters2SeparatorInner + etParameterValue.getText());
updateHttpParamsList();
etParameterName.setText("");
etParameterValue.setText("");
if(lvTriggerUrlPostParameters.getVisibility() != View.VISIBLE)
lvTriggerUrlPostParameters.setVisibility(View.VISIBLE);
}
});
lvTriggerUrlPostParameters.setOnItemLongClickListener(new OnItemLongClickListener()
{
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
getHttpParamsDialog(arg2).show();
return false;
}
});
} }
private void backToRuleManager() private void backToRuleManager()
@ -185,12 +270,20 @@ public class ActivityManageActionTriggerUrl extends Activity
ActivityManageActionTriggerUrl.resultingAction.setParameter1(chkTriggerUrlUseAuthentication.isChecked()); ActivityManageActionTriggerUrl.resultingAction.setParameter1(chkTriggerUrlUseAuthentication.isChecked());
String httpParams = "";
for (String s : httpParamsList)
httpParams += Action.actionParameters2SeparatorOuter + s;
if(httpParams.length() > 0)
httpParams = httpParams.substring(Action.actionParameters2SeparatorOuter.length());
ActivityManageActionTriggerUrl.resultingAction.setParameter2( ActivityManageActionTriggerUrl.resultingAction.setParameter2(
username + ";" + username + Action.actionParameter2Split +
password + ";" + password + Action.actionParameter2Split +
etTriggerUrl.getText().toString() + ";" + etTriggerUrl.getText().toString().trim() + Action.actionParameter2Split +
method method + Action.actionParameter2Split +
); httpParams
);
//TODO:Duplicate code in save routine in onCreate()
} }
setResult(RESULT_OK); setResult(RESULT_OK);
@ -211,4 +304,30 @@ public class ActivityManageActionTriggerUrl extends Activity
catch(NullPointerException e) catch(NullPointerException e)
{} {}
} }
private void updateHttpParamsList()
{
if(lvTriggerUrlPostParameters.getAdapter() == null)
lvTriggerUrlPostParameters.setAdapter(httpParametersAdapter);
httpParametersAdapter.notifyDataSetChanged();
}
private AlertDialog getHttpParamsDialog(final int itemPosition)
{
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityManageActionTriggerUrl.this);
alertDialogBuilder.setTitle(getResources().getString(R.string.whatToDoWithIntentPair));
alertDialogBuilder.setItems(new String[]{getResources().getString(R.string.delete)}, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
// Only 1 choice at the moment, no need to check
ActivityManageActionTriggerUrl.this.httpParamsList.remove(itemPosition);
updateHttpParamsList();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
return alertDialog;
}
} }

View File

@ -411,22 +411,16 @@ public class ActivityManagePoi extends Activity
@Override @Override
public void onProviderDisabled(String provider) public void onProviderDisabled(String provider)
{ {
// TODO Auto-generated method stub
} }
@Override @Override
public void onProviderEnabled(String provider) public void onProviderEnabled(String provider)
{ {
// TODO Auto-generated method stub
} }
@Override @Override
public void onStatusChanged(String provider, int status, Bundle extras) public void onStatusChanged(String provider, int status, Bundle extras)
{ {
// TODO Auto-generated method stub
} }
} }
@ -454,22 +448,16 @@ public class ActivityManagePoi extends Activity
@Override @Override
public void onProviderDisabled(String provider) public void onProviderDisabled(String provider)
{ {
// TODO Auto-generated method stub
} }
@Override @Override
public void onProviderEnabled(String provider) public void onProviderEnabled(String provider)
{ {
// TODO Auto-generated method stub
} }
@Override @Override
public void onStatusChanged(String provider, int status, Bundle extras) public void onStatusChanged(String provider, int status, Bundle extras)
{ {
// TODO Auto-generated method stub
} }
} }

View File

@ -1380,6 +1380,7 @@ public class ActivityManageRule extends Activity
if(requestCode == requestCodeActionTriggerUrlAdd) if(requestCode == requestCodeActionTriggerUrlAdd)
{ {
//TODO: Transform into newer and cleaner handover method through intent data
if(resultCode == RESULT_OK) if(resultCode == RESULT_OK)
{ {
//add TriggerUrl //add TriggerUrl

View File

@ -9,6 +9,7 @@ import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.CalendarContract; import android.provider.CalendarContract;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
@ -18,6 +19,7 @@ import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -31,7 +33,7 @@ import java.util.List;
public class ActivityManageTriggerCalendar extends Activity public class ActivityManageTriggerCalendar extends Activity
{ {
CheckBox chkCalendarEventActive, chkCalendarAvailabilityBusy, chkCalendarAvailabilityFree, chkCalendarAvailabilityTentative, chkCalendarAvailabilityOutOfOffice, chkCalendarAvailabilityWorkingElsewhere, chkCalendarAllDayEvent; CheckBox chkCalendarEventActive, chkCalendarAvailabilityBusy, chkCalendarAvailabilityFree, chkCalendarAvailabilityTentative, chkCalendarAvailabilityOutOfOffice, chkCalendarAvailabilityWorkingElsewhere, chkCalendarAllDayEvent, calendarEvaluateAllDayEvent;
Spinner spinnerCalendarTitleDirection, spinnerCalendarLocationDirection, spinnerCalendarDescriptionDirection; Spinner spinnerCalendarTitleDirection, spinnerCalendarLocationDirection, spinnerCalendarDescriptionDirection;
EditText etCalendarTitle, etCalendarLocation, etCalendarDescription; EditText etCalendarTitle, etCalendarLocation, etCalendarDescription;
LinearLayout llCalendarSelection; LinearLayout llCalendarSelection;
@ -51,9 +53,6 @@ public class ActivityManageTriggerCalendar extends Activity
Miscellaneous.setDisplayLanguage(this); Miscellaneous.setDisplayLanguage(this);
setContentView(R.layout.activity_manage_trigger_calendar); setContentView(R.layout.activity_manage_trigger_calendar);
// TODO: calculateNextWakeup() muß neu ausgeführt werden, wenn die Regeln geändert werden.
chkCalendarEventActive = (CheckBox) findViewById(R.id.chkCalendarEventActive); chkCalendarEventActive = (CheckBox) findViewById(R.id.chkCalendarEventActive);
spinnerCalendarTitleDirection = (Spinner)findViewById(R.id.spinnerCalendarTitleDirection); spinnerCalendarTitleDirection = (Spinner)findViewById(R.id.spinnerCalendarTitleDirection);
spinnerCalendarLocationDirection = (Spinner)findViewById(R.id.spinnerCalendarLocationDirection); spinnerCalendarLocationDirection = (Spinner)findViewById(R.id.spinnerCalendarLocationDirection);
@ -64,6 +63,7 @@ public class ActivityManageTriggerCalendar extends Activity
chkCalendarAvailabilityTentative = (CheckBox)findViewById(R.id.chkCalendarAvailabilityTentative); chkCalendarAvailabilityTentative = (CheckBox)findViewById(R.id.chkCalendarAvailabilityTentative);
chkCalendarAvailabilityOutOfOffice = (CheckBox)findViewById(R.id.chkCalendarAvailabilityOutOfOffice); chkCalendarAvailabilityOutOfOffice = (CheckBox)findViewById(R.id.chkCalendarAvailabilityOutOfOffice);
chkCalendarAvailabilityWorkingElsewhere = (CheckBox)findViewById(R.id.chkCalendarAvailabilityWorkingElsewhere); chkCalendarAvailabilityWorkingElsewhere = (CheckBox)findViewById(R.id.chkCalendarAvailabilityWorkingElsewhere);
calendarEvaluateAllDayEvent = (CheckBox)findViewById(R.id.calendarEvaluateAllDayEvent);
tvMissingCalendarHint = (TextView) findViewById(R.id.tvMissingCalendarHint); tvMissingCalendarHint = (TextView) findViewById(R.id.tvMissingCalendarHint);
@ -83,12 +83,23 @@ public class ActivityManageTriggerCalendar extends Activity
getResources().getString(R.string.directionStringEndsWith), getResources().getString(R.string.directionStringEndsWith),
getResources().getString(R.string.directionStringNotEquals) getResources().getString(R.string.directionStringNotEquals)
}; };
directionSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageTriggerCalendar.directions); directionSpinnerAdapter = new ArrayAdapter<>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageTriggerCalendar.directions);
spinnerCalendarTitleDirection.setAdapter(directionSpinnerAdapter); spinnerCalendarTitleDirection.setAdapter(directionSpinnerAdapter);
spinnerCalendarLocationDirection.setAdapter(directionSpinnerAdapter); spinnerCalendarLocationDirection.setAdapter(directionSpinnerAdapter);
spinnerCalendarDescriptionDirection.setAdapter(directionSpinnerAdapter); spinnerCalendarDescriptionDirection.setAdapter(directionSpinnerAdapter);
directionSpinnerAdapter.notifyDataSetChanged(); directionSpinnerAdapter.notifyDataSetChanged();
calendarEvaluateAllDayEvent.setChecked(false);
chkCalendarAllDayEvent.setEnabled(false);
calendarEvaluateAllDayEvent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked)
{
chkCalendarAllDayEvent.setEnabled(checked);
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{ {
if(ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, ActivityManageTriggerCalendar.this) || ActivityPermissions.havePermission(Manifest.permission.WRITE_CALENDAR, ActivityManageTriggerCalendar.this)) if(ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, ActivityManageTriggerCalendar.this) || ActivityPermissions.havePermission(Manifest.permission.WRITE_CALENDAR, ActivityManageTriggerCalendar.this))
@ -186,6 +197,7 @@ public class ActivityManageTriggerCalendar extends Activity
titleDir + Trigger.triggerParameter2Split + title + Trigger.triggerParameter2Split + titleDir + Trigger.triggerParameter2Split + title + Trigger.triggerParameter2Split +
descriptionDir + Trigger.triggerParameter2Split + description + Trigger.triggerParameter2Split + descriptionDir + Trigger.triggerParameter2Split + description + Trigger.triggerParameter2Split +
locationDir + Trigger.triggerParameter2Split + location + Trigger.triggerParameter2Split + locationDir + Trigger.triggerParameter2Split + location + Trigger.triggerParameter2Split +
String.valueOf(calendarEvaluateAllDayEvent.isChecked()) + Trigger.triggerParameter2Split +
String.valueOf(chkCalendarAllDayEvent.isChecked()) + Trigger.triggerParameter2Split + String.valueOf(chkCalendarAllDayEvent.isChecked()) + Trigger.triggerParameter2Split +
Miscellaneous.explode(separator, availabilityList.toArray(new String[availabilityList.size()])) + Trigger.triggerParameter2Split + Miscellaneous.explode(separator, availabilityList.toArray(new String[availabilityList.size()])) + Trigger.triggerParameter2Split +
Miscellaneous.explode(separator, selectedCalendarsIdArray.toArray(new String[selectedCalendarsIdArray.size()])); Miscellaneous.explode(separator, selectedCalendarsIdArray.toArray(new String[selectedCalendarsIdArray.size()]));
@ -230,14 +242,14 @@ public class ActivityManageTriggerCalendar extends Activity
void loadValuesIntoGui(Intent data) void loadValuesIntoGui(Intent data)
{ {
//TODO:try-catch try
if(data.hasExtra(ActivityManageRule.intentNameTriggerParameter1))
chkCalendarEventActive.setChecked(data.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true));
if(data.hasExtra(ActivityManageRule.intentNameTriggerParameter2))
{ {
String input[] = data.getStringExtra(ActivityManageRule.intentNameTriggerParameter2).split(Trigger.triggerParameter2Split, -1); if (data.hasExtra(ActivityManageRule.intentNameTriggerParameter1))
chkCalendarEventActive.setChecked(data.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true));
if (data.hasExtra(ActivityManageRule.intentNameTriggerParameter2))
{
String input[] = data.getStringExtra(ActivityManageRule.intentNameTriggerParameter2).split(Trigger.triggerParameter2Split, -1);
/* /*
0 = titleDir 0 = titleDir
1 = title 1 = title
@ -245,88 +257,96 @@ public class ActivityManageTriggerCalendar extends Activity
3 = description 3 = description
4 = locationDir 4 = locationDir
5 = location 5 = location
6 = all day event 6 = evaluate all day event
7 = availability list 7 = all day event
8 = calendars list 8 = availability list
9 = calendars list
*/ */
for(int i = 0; i < directions.length; i++) for (int i = 0; i < directions.length; i++)
{
if(Trigger.getMatchCode(directions[i]).equalsIgnoreCase(input[0]))
spinnerCalendarTitleDirection.setSelection(i);
if(Trigger.getMatchCode(directions[i]).equalsIgnoreCase(input[2]))
spinnerCalendarDescriptionDirection.setSelection(i);
if(Trigger.getMatchCode(directions[i]).equalsIgnoreCase(input[4]))
spinnerCalendarLocationDirection.setSelection(i);
}
etCalendarTitle.setText(input[1]);
etCalendarDescription.setText(input[3]);
etCalendarLocation.setText(input[5]);
chkCalendarAllDayEvent.setChecked(Boolean.parseBoolean(input[6]));
String[] availabilities = null;
if(!StringUtils.isEmpty(input[7]))
availabilities = input[7].split(separator);
if(availabilities != null)
{
for (String avail : availabilities)
{ {
if (Integer.parseInt(avail) == CalendarContract.Events.AVAILABILITY_BUSY) if (Trigger.getMatchCode(directions[i]).equalsIgnoreCase(input[0]))
chkCalendarAvailabilityBusy.setChecked(true); spinnerCalendarTitleDirection.setSelection(i);
else if (Integer.parseInt(avail) == CalendarContract.Events.AVAILABILITY_FREE)
chkCalendarAvailabilityFree.setChecked(true); if (Trigger.getMatchCode(directions[i]).equalsIgnoreCase(input[2]))
else if (Integer.parseInt(avail) == CalendarContract.Events.AVAILABILITY_TENTATIVE) spinnerCalendarDescriptionDirection.setSelection(i);
chkCalendarAvailabilityTentative.setChecked(true);
else if (Integer.parseInt(avail) == CalendarReceiver.AVAILABILITY_OUT_OF_OFFICE) if (Trigger.getMatchCode(directions[i]).equalsIgnoreCase(input[4]))
chkCalendarAvailabilityOutOfOffice.setChecked(true); spinnerCalendarLocationDirection.setSelection(i);
else if (Integer.parseInt(avail) == CalendarReceiver.AVAILABILITY_WORKING_ELSEWHERE)
chkCalendarAvailabilityWorkingElsewhere.setChecked(true);
} }
}
String[] calendars = null; etCalendarTitle.setText(input[1]);
if(!StringUtils.isEmpty(input[8])) etCalendarDescription.setText(input[3]);
calendars = input[8].split(separator); etCalendarLocation.setText(input[5]);
if(calendars != null) calendarEvaluateAllDayEvent.setChecked(Boolean.parseBoolean(input[6]));
{ chkCalendarAllDayEvent.setChecked(Boolean.parseBoolean(input[7]));
List<String> usedCalendarIDs = new ArrayList<>();
List<String> unusedCalendarIDs = new ArrayList<>(); String[] availabilities = null;
for (CheckBox checkbox : checkboxesCalendars) if (!StringUtils.isEmpty(input[8]))
availabilities = input[8].split(separator);
if (availabilities != null)
{ {
int id = ((CalendarReceiver.AndroidCalendar) checkbox.getTag()).calendarId; for (String avail : availabilities)
for (String calId : calendars)
{ {
if (calId.equals(String.valueOf(id))) if (Integer.parseInt(avail) == CalendarContract.Events.AVAILABILITY_BUSY)
{ chkCalendarAvailabilityBusy.setChecked(true);
usedCalendarIDs.add(String.valueOf(id)); else if (Integer.parseInt(avail) == CalendarContract.Events.AVAILABILITY_FREE)
checkbox.setChecked(true); chkCalendarAvailabilityFree.setChecked(true);
break; else if (Integer.parseInt(avail) == CalendarContract.Events.AVAILABILITY_TENTATIVE)
} chkCalendarAvailabilityTentative.setChecked(true);
else if (Integer.parseInt(avail) == CalendarReceiver.AVAILABILITY_OUT_OF_OFFICE)
chkCalendarAvailabilityOutOfOffice.setChecked(true);
else if (Integer.parseInt(avail) == CalendarReceiver.AVAILABILITY_WORKING_ELSEWHERE)
chkCalendarAvailabilityWorkingElsewhere.setChecked(true);
} }
} }
for (String calId : calendars)
{ String[] calendars = null;
if (!Miscellaneous.arraySearch((ArrayList<String>) usedCalendarIDs, calId, false, true)) if (!StringUtils.isEmpty(input[9]))
unusedCalendarIDs.add(calId); calendars = input[9].split(separator);
}
if (unusedCalendarIDs.size() > 0) if (calendars != null)
{ {
List<String> usedCalendarIDs = new ArrayList<>();
List<String> unusedCalendarIDs = new ArrayList<>();
for (CheckBox checkbox : checkboxesCalendars)
{
int id = ((CalendarReceiver.AndroidCalendar) checkbox.getTag()).calendarId;
for (String calId : calendars)
{
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. 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 It will be removed with the next save, but we should inform this user
of these circumstances. of these circumstances.
*/ */
tvMissingCalendarHint.setText(String.format(getResources().getString(R.string.calendarsMissingHint), Miscellaneous.explode(", ", (ArrayList<String>) unusedCalendarIDs))); tvMissingCalendarHint.setText(String.format(getResources().getString(R.string.calendarsMissingHint), Miscellaneous.explode(", ", (ArrayList<String>) unusedCalendarIDs)));
}
} }
} }
} }
catch (Exception e)
{
Miscellaneous.logEvent("e", "ActivityManagerTriggerCalender", "Error loading values into GUI: " + Log.getStackTraceString(e), 1);
Toast.makeText(ActivityManageTriggerCalendar.this, getResources().getString(R.string.errorLoadingValues), Toast.LENGTH_SHORT).show();
}
} }
@Override @Override

View File

@ -49,20 +49,15 @@ public class ActivityVolumeTest extends Activity
@Override @Override
public void onStopTrackingTouch(SeekBar seekBar) public void onStopTrackingTouch(SeekBar seekBar)
{ {
// TODO Auto-generated method stub
} }
@Override @Override
public void onStartTrackingTouch(SeekBar seekBar) public void onStartTrackingTouch(SeekBar seekBar)
{ {
// TODO Auto-generated method stub
} }
@Override @Override
public void onProgressChanged(SeekBar seekBar, int progress, public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
boolean fromUser)
{ {
etReferenceValue.setText(String.valueOf(sbReferenceValue.getProgress())); etReferenceValue.setText(String.valueOf(sbReferenceValue.getProgress()));
} }

View File

@ -22,7 +22,7 @@ public class AsyncTasks
try try
{ {
String result = Miscellaneous.downloadURL("https://server47.de/automation/?action=getLatestVersionCode", null, null, ActivityManageActionTriggerUrl.methodGet).trim(); String result = Miscellaneous.downloadURL("https://server47.de/automation/?action=getLatestVersionCode", null, null, ActivityManageActionTriggerUrl.methodGet, null).trim();
int latestVersion = Integer.parseInt(result); int latestVersion = Integer.parseInt(result);
// At this point the update check itself has already been successful. // At this point the update check itself has already been successful.

View File

@ -28,6 +28,7 @@ import androidx.core.app.NotificationManagerCompat;
import com.jens.automation2.Trigger.Trigger_Enum; import com.jens.automation2.Trigger.Trigger_Enum;
import com.jens.automation2.location.LocationProvider; import com.jens.automation2.location.LocationProvider;
import com.jens.automation2.receivers.CalendarReceiver;
import com.jens.automation2.receivers.DateTimeListener; import com.jens.automation2.receivers.DateTimeListener;
import com.jens.automation2.receivers.PackageReplacedReceiver; import com.jens.automation2.receivers.PackageReplacedReceiver;
import com.jens.automation2.receivers.PhoneStatusListener; import com.jens.automation2.receivers.PhoneStatusListener;
@ -309,6 +310,7 @@ public class AutomationService extends Service implements OnInitListener
ReceiverCoordinator.applySettingsAndRules(); ReceiverCoordinator.applySettingsAndRules();
DateTimeListener.reloadAlarms(); DateTimeListener.reloadAlarms();
CalendarReceiver.armOrRearmTimer();
} }
@Override @Override
@ -679,8 +681,6 @@ public class AutomationService extends Service implements OnInitListener
@Override @Override
public void onInit(int status) public void onInit(int status)
{ {
// TODO Auto-generated method stub
} }
/** /**

View File

@ -44,10 +44,8 @@ import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion; import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
@ -98,6 +96,7 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.Scanner; import java.util.Scanner;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
@ -124,7 +123,7 @@ public class Miscellaneous extends Service
public static final String lineSeparator = System.getProperty("line.separator"); public static final String lineSeparator = System.getProperty("line.separator");
public static String downloadURL(String url, String username, String password, String method) public static String downloadURL(String url, String username, String password, String method, Map<String, String> httpParams)
{ {
HttpClient httpclient = new DefaultHttpClient(); HttpClient httpclient = new DefaultHttpClient();
StringBuilder responseBody = new StringBuilder(); StringBuilder responseBody = new StringBuilder();
@ -180,7 +179,7 @@ public class Miscellaneous extends Service
} }
} }
public static String downloadURLwithoutCertificateChecking(String url, String username, String password, String method) public static String downloadURLwithoutCertificateChecking(String url, String username, String password, String method, Map<String, String> httpParams)
{ {
try try
{ {

View File

@ -79,7 +79,7 @@ public class News
if (!(new File(filePath)).exists() || Settings.lastNewsPolltime == Settings.default_lastNewsPolltime || now.getTimeInMillis() >= Settings.lastNewsPolltime + (long)(Settings.newsDisplayForXDays * 24 * 60 * 60 * 1000)) if (!(new File(filePath)).exists() || Settings.lastNewsPolltime == Settings.default_lastNewsPolltime || now.getTimeInMillis() >= Settings.lastNewsPolltime + (long)(Settings.newsDisplayForXDays * 24 * 60 * 60 * 1000))
{ {
String newsUrl = "https://server47.de/automation/appNews.php"; String newsUrl = "https://server47.de/automation/appNews.php";
newsContent = Miscellaneous.downloadURL(newsUrl, null, null, ActivityManageActionTriggerUrl.methodGet); newsContent = Miscellaneous.downloadURL(newsUrl, null, null, ActivityManageActionTriggerUrl.methodGet, null);
// Cache content to local storage // Cache content to local storage
if(Miscellaneous.writeStringToFile(filePath, newsContent)) if(Miscellaneous.writeStringToFile(filePath, newsContent))

View File

@ -694,22 +694,16 @@ public class PointOfInterest implements Comparable<PointOfInterest>
@Override @Override
public void onProviderDisabled(String provider) public void onProviderDisabled(String provider)
{ {
// TODO Auto-generated method stub
} }
@Override @Override
public void onProviderEnabled(String provider) public void onProviderEnabled(String provider)
{ {
// TODO Auto-generated method stub
} }
@Override @Override
public void onStatusChanged(String provider, int status, Bundle extras) public void onStatusChanged(String provider, int status, Bundle extras)
{ {
// TODO Auto-generated method stub
} }
} }

View File

@ -149,56 +149,45 @@ public class Settings implements SharedPreferences
@Override @Override
public Editor edit() public Editor edit()
{ {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public Map<String, ?> getAll() public Map<String, ?> getAll()
{ {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public boolean getBoolean(String arg0, boolean arg1) public boolean getBoolean(String arg0, boolean arg1)
{ {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public float getFloat(String arg0, float arg1) public float getFloat(String arg0, float arg1)
{ {
// TODO Auto-generated method stub
return 0; return 0;
} }
@Override @Override
public int getInt(String arg0, int arg1) public int getInt(String arg0, int arg1)
{ {
// TODO Auto-generated method stub
return 0; return 0;
} }
@Override @Override
public long getLong(String arg0, long arg1) public long getLong(String arg0, long arg1)
{ {
// TODO Auto-generated method stub
return 0; return 0;
} }
@Override @Override
public String getString(String arg0, String arg1) public String getString(String arg0, String arg1)
{ {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener arg0) public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener arg0)
{ {
// TODO Auto-generated method stub
} }
@Override @Override
public void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener arg0) public void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener arg0)
{ {
// TODO Auto-generated method stub
} }
public static void readFromPersistentStorage(Context context) public static void readFromPersistentStorage(Context context)
@ -619,7 +608,6 @@ public class Settings implements SharedPreferences
@Override @Override
public Set<String> getStringSet(String arg0, Set<String> arg1) public Set<String> getStringSet(String arg0, Set<String> arg1)
{ {
// TODO Auto-generated method stub
return null; return null;
} }
} }

View File

@ -631,9 +631,10 @@ public class Trigger
3 = description 3 = description
4 = eventLocationDirection 4 = eventLocationDirection
5 = eventLocation 5 = eventLocation
6 = all day event 6 = evaluate all day event
7 = availabilityList 7 = all day event
8 = calendarList 8 = availabilityList
9 = calendarList
*/ */
for(CalendarReceiver.CalendarEvent event : calendarEvents) for(CalendarReceiver.CalendarEvent event : calendarEvents)
@ -677,9 +678,10 @@ public class Trigger
3 = description 3 = description
4 = eventLocationDirection 4 = eventLocationDirection
5 = eventLocation 5 = eventLocation
6 = all day event 6 = evaluate all day event
7 = availabilityList 7 = all day event
8 = calendarList 8 = availabilityList
9 = calendarList
*/ */
@ -717,15 +719,18 @@ public class Trigger
} }
} }
if (Boolean.parseBoolean(conditions[6]) != event.allDay) if (Boolean.parseBoolean(conditions[6]))
{ {
Miscellaneous.logEvent("i", "CalendarCheck", "All day setting does not match.", 5); if (Boolean.parseBoolean(conditions[7]) != event.allDay)
return false; {
Miscellaneous.logEvent("i", "CalendarCheck", "All day setting does not match.", 5);
return false;
}
} }
if (!StringUtils.isEmpty(conditions[7])) if (!StringUtils.isEmpty(conditions[8]))
{ {
String[] availabilities = conditions[7].split(ActivityManageTriggerCalendar.separator); String[] availabilities = conditions[8].split(ActivityManageTriggerCalendar.separator);
if (availabilities.length > 0) if (availabilities.length > 0)
{ {
if (!Miscellaneous.arraySearch(availabilities, event.availability, false, true)) if (!Miscellaneous.arraySearch(availabilities, event.availability, false, true))
@ -736,9 +741,9 @@ public class Trigger
} }
} }
if (!StringUtils.isEmpty(conditions[8])) if (!StringUtils.isEmpty(conditions[9]))
{ {
String[] calendars = conditions[8].split(ActivityManageTriggerCalendar.separator); String[] calendars = conditions[9].split(ActivityManageTriggerCalendar.separator);
if (calendars.length > 0) if (calendars.length > 0)
{ {
if (!Miscellaneous.arraySearch(calendars, String.valueOf(event.calendarId), false, true)) if (!Miscellaneous.arraySearch(calendars, String.valueOf(event.calendarId), false, true))
@ -748,7 +753,7 @@ public class Trigger
} }
} }
} }
//TODO: all-day abwählbar machen
// No contradictions found // No contradictions found
Miscellaneous.logEvent("i", "CalendarCheck", "Event " + event + " matches.", 4); Miscellaneous.logEvent("i", "CalendarCheck", "Event " + event + " matches.", 4);
return true; return true;
@ -1980,15 +1985,18 @@ public class Trigger
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.calendarDescription) + " " + conditions[4] + " " + conditions[5] + ", "); returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.calendarDescription) + " " + conditions[4] + " " + conditions[5] + ", ");
if(Boolean.parseBoolean(conditions[6])) if(Boolean.parseBoolean(conditions[6]))
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.allDayEventTrue) + ", "); {
else if (Boolean.parseBoolean(conditions[7]))
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.allDayEventFalse) + ", "); returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.allDayEventTrue) + ", ");
else
if (!StringUtils.isEmpty(conditions[7])) returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.allDayEventFalse) + ", ");
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.availabilities) + " " + conditions[7] + ", "); }
if (!StringUtils.isEmpty(conditions[8])) if (!StringUtils.isEmpty(conditions[8]))
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.calendars) + " " + conditions[8]); returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.availabilities) + " " + conditions[8] + ", ");
if (!StringUtils.isEmpty(conditions[9]))
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.calendars) + " " + conditions[9]);
if (returnString.toString().endsWith(", ")) if (returnString.toString().endsWith(", "))
returnString.delete(returnString.length() - 2, returnString.length()); returnString.delete(returnString.length() - 2, returnString.length());

View File

@ -283,7 +283,7 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
armOrRearmTimer(); armOrRearmTimer();
} }
private static void armOrRearmTimer() public static void armOrRearmTimer()
{ {
PendingIntent pi = null; PendingIntent pi = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
@ -391,19 +391,24 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
Collections.sort(wakeUpCandidatesList); Collections.sort(wakeUpCandidatesList);
if(nextWakeup == null || nextWakeup.getTimeInMillis() != wakeUpCandidatesList.get(0)) if(wakeUpCandidatesList.size() == 0)
{ Miscellaneous.logEvent("i", "calculateNextWakeupForCalendar()", "Not scheduling any calendar related wakeup as there are no future events that might match a configured trigger.", 5);
Calendar newAlarm = Miscellaneous.calendarFromLong(wakeUpCandidatesList.get(0));
if(nextWakeup == null)
Miscellaneous.logEvent("i", "calculateNextWakeupForCalendar()", "Chose " + Miscellaneous.formatDate(newAlarm.getTime()) + " as next wakeup for calendar triggers. Old was null.", 5);
else
Miscellaneous.logEvent("i", "calculateNextWakeupForCalendar()", "Chose " + Miscellaneous.formatDate(newAlarm.getTime()) + " as next wakeup for calendar triggers. Old was " + Miscellaneous.formatDate(nextWakeup.getTime()), 5);
nextWakeup = newAlarm;
if (!wakeupNeedsToBeScheduled)
wakeupNeedsToBeScheduled = true;
}
else else
Miscellaneous.logEvent("i", "calculateNextWakeupForCalendar()", "Alarm " + Miscellaneous.formatDate(nextWakeup.getTime()) + " has been selected as next wakeup, but not rescheduling since this was not a change.", 5); {
if (nextWakeup == null || nextWakeup.getTimeInMillis() != wakeUpCandidatesList.get(0))
{
Calendar newAlarm = Miscellaneous.calendarFromLong(wakeUpCandidatesList.get(0));
if (nextWakeup == null)
Miscellaneous.logEvent("i", "calculateNextWakeupForCalendar()", "Chose " + Miscellaneous.formatDate(newAlarm.getTime()) + " as next wakeup for calendar triggers. Old was null.", 5);
else
Miscellaneous.logEvent("i", "calculateNextWakeupForCalendar()", "Chose " + Miscellaneous.formatDate(newAlarm.getTime()) + " as next wakeup for calendar triggers. Old was " + Miscellaneous.formatDate(nextWakeup.getTime()), 5);
nextWakeup = newAlarm;
if (!wakeupNeedsToBeScheduled)
wakeupNeedsToBeScheduled = true;
}
else
Miscellaneous.logEvent("i", "calculateNextWakeupForCalendar()", "Alarm " + Miscellaneous.formatDate(nextWakeup.getTime()) + " has been selected as next wakeup, but not rescheduling since this was not a change.", 5);
}
} }
} }

View File

@ -293,7 +293,6 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/tvCurrentNfcIdValue"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/parameterName" /> android:text="@string/parameterName" />

View File

@ -118,12 +118,88 @@
</RadioGroup> </RadioGroup>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:stretchColumns="1"
android:shrinkColumns="1" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:textSize="25dp"
android:textStyle="bold"
android:layout_marginBottom="@dimen/default_margin"
android:text="@string/addParameters" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/parameterName" />
<EditText
android:id="@+id/etParameterName"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/parameterValue" />
<EditText
android:id="@+id/etParameterValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#aa000000" />
<ListView
android:id="@+id/lvHttpParams"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="115dp"
android:layout_marginBottom="@dimen/default_margin" />
<Button
android:id="@+id/bAddHttpParam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/addParameters" />
<ListView <ListView
android:id="@+id/lvTriggerUrlPostParameters" android:id="@+id/lvTriggerUrlPostParameters"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone"> android:minHeight="100dp"
</ListView> android:visibility="gone" />
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -176,11 +176,11 @@
android:background="#aa000000" /> android:background="#aa000000" />
<CheckBox <CheckBox
android:id="@+id/careAboutAllDayEvent" android:id="@+id/calendarEvaluateAllDayEvent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/evaluate" android:text="@string/evaluate"
android:checked="true"/> android:checked="false"/>
<TableRow <TableRow
android:layout_marginBottom="@dimen/activity_vertical_margin"> android:layout_marginBottom="@dimen/activity_vertical_margin">
@ -194,6 +194,7 @@
<CheckBox <CheckBox
android:id="@+id/chkCalendarAllDayEvent" android:id="@+id/chkCalendarAllDayEvent"
android:checked="false" android:checked="false"
android:text="@string/allDayEventFalse"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />

View File

@ -934,4 +934,6 @@
<string name="android.permission.SCHEDULE_EXACT_ALARM">Schedule exact alarms</string> <string name="android.permission.SCHEDULE_EXACT_ALARM">Schedule exact alarms</string>
<string name="alarmsPermissionHint">After clicking OK a window will open. Please select Automation there and allow the app to schedule exact alarms.</string> <string name="alarmsPermissionHint">After clicking OK a window will open. Please select Automation there and allow the app to schedule exact alarms.</string>
<string name="evaluate">Evaluate</string> <string name="evaluate">Evaluate</string>
<string name="errorLoadingValues">An error occur occured while loading values.</string>
<string name="enterValidDataIntoParametersFields">Enter valid data into the parameter fields.</string>
</resources> </resources>