Action to change system settings
This commit is contained in:
@@ -237,6 +237,7 @@
|
|||||||
<activity android:name=".ActivityManageTriggerNotification" />
|
<activity android:name=".ActivityManageTriggerNotification" />
|
||||||
<activity android:name=".ActivityManageTriggerCalendar" />
|
<activity android:name=".ActivityManageTriggerCalendar" />
|
||||||
<activity android:name=".ActivityManageTriggerProximity" />
|
<activity android:name=".ActivityManageTriggerProximity" />
|
||||||
|
<activity android:name=".ActivityManageActionSetSystemSetting" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".receivers.NotificationListener"
|
android:name=".receivers.NotificationListener"
|
||||||
|
|||||||
@@ -235,6 +235,7 @@
|
|||||||
<activity android:name=".ActivityManageTriggerNotification" />
|
<activity android:name=".ActivityManageTriggerNotification" />
|
||||||
<activity android:name=".ActivityManageTriggerCalendar" />
|
<activity android:name=".ActivityManageTriggerCalendar" />
|
||||||
<activity android:name=".ActivityManageTriggerProximity" />
|
<activity android:name=".ActivityManageTriggerProximity" />
|
||||||
|
<activity android:name=".ActivityManageActionSetSystemSetting" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".receivers.NotificationListener"
|
android:name=".receivers.NotificationListener"
|
||||||
|
|||||||
@@ -224,6 +224,7 @@
|
|||||||
<activity android:name=".ActivityManageTriggerNotification" />
|
<activity android:name=".ActivityManageTriggerNotification" />
|
||||||
<activity android:name=".ActivityManageTriggerCalendar" />
|
<activity android:name=".ActivityManageTriggerCalendar" />
|
||||||
<activity android:name=".ActivityManageTriggerProximity" />
|
<activity android:name=".ActivityManageTriggerProximity" />
|
||||||
|
<activity android:name=".ActivityManageActionSetSystemSetting" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".receivers.NotificationListener"
|
android:name=".receivers.NotificationListener"
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ public class Action
|
|||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
setLocationService,
|
setLocationService,
|
||||||
sendTextMessage,
|
sendTextMessage,
|
||||||
takeScreenshot;
|
takeScreenshot,
|
||||||
|
setSystemSetting;
|
||||||
|
|
||||||
public String getFullName(Context context)
|
public String getFullName(Context context)
|
||||||
{
|
{
|
||||||
@@ -130,6 +131,8 @@ public class Action
|
|||||||
return context.getResources().getString(R.string.takeScreenshot);
|
return context.getResources().getString(R.string.takeScreenshot);
|
||||||
case setLocationService:
|
case setLocationService:
|
||||||
return context.getResources().getString(R.string.setLocationServiceCapital);
|
return context.getResources().getString(R.string.setLocationServiceCapital);
|
||||||
|
case setSystemSetting:
|
||||||
|
return context.getResources().getString(R.string.setSystemSettingCapital);
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
@@ -635,6 +638,10 @@ public class Action
|
|||||||
case setLocationService:
|
case setLocationService:
|
||||||
Actions.setLocationService(Integer.parseInt(this.getParameter2()), AutomationService.getInstance());
|
Actions.setLocationService(Integer.parseInt(this.getParameter2()), AutomationService.getInstance());
|
||||||
break;
|
break;
|
||||||
|
case setSystemSetting:
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||||
|
Actions.setSystemSetting(this.getParameter2(), AutomationService.getInstance());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -251,6 +251,23 @@ public class Actions
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||||
|
public static void setSystemSetting(String parameter2, AutomationService instance)
|
||||||
|
{
|
||||||
|
ContentResolver cr = instance.getContentResolver();
|
||||||
|
|
||||||
|
//"String", "Long", "Int", "Float" };
|
||||||
|
String[] parts = parameter2.split(Action.actionParameter2Split);
|
||||||
|
if (parts[0].equalsIgnoreCase("String"))
|
||||||
|
android.provider.Settings.Global.putString(cr, parts[1], parts[2]);
|
||||||
|
else if (parts[0].equalsIgnoreCase("Long"))
|
||||||
|
android.provider.Settings.Global.putLong(cr, parts[1], Long.parseLong(parts[2]));
|
||||||
|
else if (parts[0].equalsIgnoreCase("Int"))
|
||||||
|
android.provider.Settings.Global.putInt(cr, parts[1], Integer.parseInt(parts[2]));
|
||||||
|
else if (parts[0].equalsIgnoreCase("Float"))
|
||||||
|
android.provider.Settings.Global.putFloat(cr, parts[1], Float.parseFloat(parts[2]));
|
||||||
|
}
|
||||||
|
|
||||||
public static class WifiStuff
|
public static class WifiStuff
|
||||||
{
|
{
|
||||||
public static Boolean setWifi(Context context, Boolean desiredState, String parameter2, boolean toggleActionIfPossible)
|
public static Boolean setWifi(Context context, Boolean desiredState, String parameter2, boolean toggleActionIfPossible)
|
||||||
|
|||||||
@@ -0,0 +1,144 @@
|
|||||||
|
package com.jens.automation2;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.InputType;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class ActivityManageActionSetSystemSetting extends Activity
|
||||||
|
{
|
||||||
|
Spinner spinnerSettingDataType;
|
||||||
|
EditText etSettingName, etSettingValue;
|
||||||
|
Button bSaveSetSystemSetting;
|
||||||
|
|
||||||
|
ArrayAdapter<String> settingDataTypeSpinnerAdapter;
|
||||||
|
protected final static String[] dataTypes = { "String", "Long", "Int", "Float" };
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
Miscellaneous.setUiTheme(this);
|
||||||
|
this.setContentView(R.layout.activity_manage_action_set_system_setting);
|
||||||
|
|
||||||
|
spinnerSettingDataType = (Spinner) findViewById(R.id.spinnerSettingDataType);
|
||||||
|
etSettingName = (EditText)findViewById(R.id.etSettingName);
|
||||||
|
etSettingValue = (EditText)findViewById(R.id.etSettingValue);
|
||||||
|
bSaveSetSystemSetting = (Button)findViewById(R.id.bSaveSetSystemSetting);
|
||||||
|
|
||||||
|
settingDataTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, dataTypes);
|
||||||
|
spinnerSettingDataType.setAdapter(settingDataTypeSpinnerAdapter);
|
||||||
|
settingDataTypeSpinnerAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
spinnerSettingDataType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l)
|
||||||
|
{
|
||||||
|
if(dataTypes[i].equalsIgnoreCase("String"))
|
||||||
|
etSettingValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
|
else if(dataTypes[i].equalsIgnoreCase("Float"))
|
||||||
|
etSettingValue.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||||
|
else
|
||||||
|
etSettingValue.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> adapterView)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bSaveSetSystemSetting.setOnClickListener(new OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
if(etSettingName.getText().toString().isEmpty())
|
||||||
|
{
|
||||||
|
Toast.makeText(getBaseContext(), getResources().getString(R.string.enterAname), Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(etSettingValue.getText().toString().isEmpty())
|
||||||
|
{
|
||||||
|
Toast.makeText(getBaseContext(), getResources().getString(R.string.enterAvalue), Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String selectedDataType = dataTypes[spinnerSettingDataType.getSelectedItemPosition()];
|
||||||
|
if(
|
||||||
|
selectedDataType.equalsIgnoreCase("Int")
|
||||||
|
||
|
||||||
|
selectedDataType.equalsIgnoreCase("Long")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if(Miscellaneous.isNumericDecimal(etSettingValue.getText().toString()) || !Miscellaneous.isNumeric(etSettingValue.getText().toString()))
|
||||||
|
{
|
||||||
|
Toast.makeText(ActivityManageActionSetSystemSetting.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(selectedDataType.equalsIgnoreCase("Float"))
|
||||||
|
{
|
||||||
|
if(!Miscellaneous.isNumeric(etSettingValue.getText().toString()))
|
||||||
|
{
|
||||||
|
Toast.makeText(ActivityManageActionSetSystemSetting.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
|
||||||
|
String param2Data = dataTypes[spinnerSettingDataType.getSelectedItemPosition()] + Action.actionParameter2Split + etSettingName.getText().toString() + Action.actionParameter2Split + etSettingValue.getText().toString();
|
||||||
|
|
||||||
|
returnIntent.putExtra(ActivityManageRule.intentNameActionParameter1, false);
|
||||||
|
returnIntent.putExtra(ActivityManageRule.intentNameActionParameter2, param2Data);
|
||||||
|
|
||||||
|
setResult(RESULT_OK, returnIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||||
|
{
|
||||||
|
// dataType, setting name, setting value
|
||||||
|
String[] components = getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2).split(Action.actionParameter2Split);
|
||||||
|
|
||||||
|
int position = Miscellaneous.arraySearchIndexOf(dataTypes, components[0], false, true);
|
||||||
|
|
||||||
|
if(position >= 0)
|
||||||
|
{
|
||||||
|
spinnerSettingDataType.setSelection(position);
|
||||||
|
etSettingName.setText(components[1]);
|
||||||
|
etSettingValue.setText(components[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateListView()
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "ListView", "Attempting to update spinnerSettingDataType", 4);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(spinnerSettingDataType.getAdapter() == null)
|
||||||
|
spinnerSettingDataType.setAdapter(settingDataTypeSpinnerAdapter);
|
||||||
|
|
||||||
|
settingDataTypeSpinnerAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
catch(NullPointerException e)
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -96,8 +96,6 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
||||||
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
// etClassName.setEnabled(false);
|
|
||||||
|
|
||||||
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
|
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
|
||||||
bSelectApp.setOnClickListener(new OnClickListener()
|
bSelectApp.setOnClickListener(new OnClickListener()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,9 +46,6 @@ public class ActivityManageActionTriggerUrl extends Activity
|
|||||||
public static final String methodGet = "GET";
|
public static final String methodGet = "GET";
|
||||||
public static final String methodPost = "POST";
|
public static final String methodPost = "POST";
|
||||||
|
|
||||||
// public static boolean edit = false;
|
|
||||||
// public static Action resultingAction = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ public class ActivityManageRule extends Activity
|
|||||||
final static int requestCodeTriggerChargingEdit = 836;
|
final static int requestCodeTriggerChargingEdit = 836;
|
||||||
final static int requestCodeTriggerProximityAdd = 837;
|
final static int requestCodeTriggerProximityAdd = 837;
|
||||||
final static int requestCodeTriggerProximityEdit = 838;
|
final static int requestCodeTriggerProximityEdit = 838;
|
||||||
|
final static int requestCodeActionSetSystemSettingAdd = 839;
|
||||||
|
final static int requestCodeActionSetSystemSettingEdit = 840;
|
||||||
|
|
||||||
public static ActivityManageRule getInstance()
|
public static ActivityManageRule getInstance()
|
||||||
{
|
{
|
||||||
@@ -166,7 +168,6 @@ public class ActivityManageRule extends Activity
|
|||||||
Miscellaneous.setUiTheme(this);
|
Miscellaneous.setUiTheme(this);
|
||||||
setContentView(R.layout.activity_manage_specific_rule);
|
setContentView(R.layout.activity_manage_specific_rule);
|
||||||
|
|
||||||
|
|
||||||
context = this;
|
context = this;
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
@@ -511,6 +512,12 @@ public class ActivityManageRule extends Activity
|
|||||||
actionSetLocationServiceIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
actionSetLocationServiceIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
startActivityForResult(actionSetLocationServiceIntent, requestCodeActionSetLocationServiceEdit);
|
startActivityForResult(actionSetLocationServiceIntent, requestCodeActionSetLocationServiceEdit);
|
||||||
break;
|
break;
|
||||||
|
case setSystemSetting:
|
||||||
|
Intent actionSetSystemSettingIntent = new Intent(context, ActivityManageActionSetSystemSetting.class);
|
||||||
|
// actionSetSystemSettingIntent.putExtra(intentNameActionParameter1, a.getParameter1());
|
||||||
|
actionSetSystemSettingIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
|
startActivityForResult(actionSetSystemSettingIntent, requestCodeActionSetSystemSettingEdit);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Miscellaneous.logEvent("w", "Edit action", "Editing of action type " + a.getAction().toString() + " not implemented, yet.", 4);
|
Miscellaneous.logEvent("w", "Edit action", "Editing of action type " + a.getAction().toString() + " not implemented, yet.", 4);
|
||||||
break;
|
break;
|
||||||
@@ -2215,6 +2222,32 @@ public class ActivityManageRule extends Activity
|
|||||||
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
|
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeActionSetSystemSettingAdd)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
newAction.setParentRule(ruleToEdit);
|
||||||
|
// newAction.setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
|
||||||
|
newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
ruleToEdit.getActionSet().add(newAction);
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeActionSetSystemSettingEdit)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
|
||||||
|
// ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
|
||||||
|
|
||||||
|
if(data.hasExtra(intentNameActionParameter2))
|
||||||
|
{
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
}
|
||||||
|
|
||||||
this.refreshActionList();
|
this.refreshActionList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2303,6 +2336,9 @@ public class ActivityManageRule extends Activity
|
|||||||
if(ActivityPermissions.isServiceAvailable(Miscellaneous.getAnyContext(), "MyAccessibilityService"))
|
if(ActivityPermissions.isServiceAvailable(Miscellaneous.getAnyContext(), "MyAccessibilityService"))
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.copier));
|
items.add(new Item(typesLong[i].toString(), R.drawable.copier));
|
||||||
}
|
}
|
||||||
|
else if(types[i].toString().equals(Action_Enum.setSystemSetting.toString()))
|
||||||
|
{ items.add(new Item(typesLong[i].toString(), R.drawable.gears_small));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
||||||
}
|
}
|
||||||
@@ -2541,6 +2577,12 @@ public class ActivityManageRule extends Activity
|
|||||||
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionLocationService.class);
|
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionLocationService.class);
|
||||||
startActivityForResult(intent, requestCodeActionSetLocationServiceAdd);
|
startActivityForResult(intent, requestCodeActionSetLocationServiceAdd);
|
||||||
}
|
}
|
||||||
|
else if(actionTypes[which].toString().equals(Action_Enum.setSystemSetting.toString()))
|
||||||
|
{
|
||||||
|
newAction.setAction(Action_Enum.setSystemSetting);
|
||||||
|
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSetSystemSetting.class);
|
||||||
|
startActivityForResult(intent, requestCodeActionSetSystemSettingAdd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -795,6 +795,7 @@ public class ActivityPermissions extends Activity
|
|||||||
addToArrayListUnique(Manifest.permission.BIND_ACCESSIBILITY_SERVICE, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.BIND_ACCESSIBILITY_SERVICE, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case setLocationService:
|
case setLocationService:
|
||||||
|
case setSystemSetting:
|
||||||
addToArrayListUnique(Manifest.permission.WRITE_SECURE_SETTINGS, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.WRITE_SECURE_SETTINGS, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case setScreenBrightness:
|
case setScreenBrightness:
|
||||||
@@ -1038,6 +1039,8 @@ public class ActivityPermissions extends Activity
|
|||||||
case Manifest.permission.WRITE_SECURE_SETTINGS:
|
case Manifest.permission.WRITE_SECURE_SETTINGS:
|
||||||
for(String ruleName : getRulesUsing(Action.Action_Enum.setLocationService))
|
for(String ruleName : getRulesUsing(Action.Action_Enum.setLocationService))
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
|
for(String ruleName : getRulesUsing(Action.Action_Enum.setSystemSetting))
|
||||||
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
break;
|
break;
|
||||||
case Manifest.permission.READ_CALENDAR:
|
case Manifest.permission.READ_CALENDAR:
|
||||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.calendarEvent))
|
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.calendarEvent))
|
||||||
|
|||||||
@@ -2077,6 +2077,50 @@ public class Miscellaneous extends Service
|
|||||||
return formattedDate;
|
return formattedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int arraySearchIndexOf(String[] haystack, String needle, boolean caseSensitive, boolean matchFullLine)
|
||||||
|
{
|
||||||
|
if(matchFullLine)
|
||||||
|
{
|
||||||
|
if(caseSensitive)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < haystack.length; i++)
|
||||||
|
{
|
||||||
|
if (haystack[i].equals(needle))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < haystack.length; i++)
|
||||||
|
{
|
||||||
|
if (haystack[i].toLowerCase().equals(needle.toLowerCase()))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(caseSensitive)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < haystack.length; i++)
|
||||||
|
{
|
||||||
|
if (haystack[i].contains(needle))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < haystack.length; i++)
|
||||||
|
{
|
||||||
|
if (haystack[i].toLowerCase().contains(needle.toLowerCase()))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean arraySearch(String[] haystack, String needle, boolean caseSensitive, boolean matchFullLine)
|
public static boolean arraySearch(String[] haystack, String needle, boolean caseSensitive, boolean matchFullLine)
|
||||||
{
|
{
|
||||||
if(matchFullLine)
|
if(matchFullLine)
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_margin="@dimen/default_margin" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:id="@+id/tlTriggerUrlAuthentication"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/username" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etTriggerUrlUsername"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:enabled="false"
|
||||||
|
android:inputType="text" >
|
||||||
|
|
||||||
|
</EditText>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/password" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etTriggerUrlPassword"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:enabled="false"
|
||||||
|
android:inputType="textPassword" >
|
||||||
|
|
||||||
|
</EditText>
|
||||||
|
</TableRow>
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<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/type" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spinnerSettingDataType"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</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/settingName" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etSettingName"
|
||||||
|
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/settingValue" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etSettingValue"
|
||||||
|
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" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:text="@string/triggerUrlVariableHint" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bSaveSetSystemSetting"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/save" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
@@ -972,4 +972,8 @@
|
|||||||
<string name="proximityText">proximity is between \"%1$s\" and \"%2$s\"</string>
|
<string name="proximityText">proximity is between \"%1$s\" and \"%2$s\"</string>
|
||||||
<string name="pleaseWait">Please wait.</string>
|
<string name="pleaseWait">Please wait.</string>
|
||||||
<string name="permissionRequiredBluetooth">Bluetooth permission required to edit this rule. Request permissions from the main screen first.</string>
|
<string name="permissionRequiredBluetooth">Bluetooth permission required to edit this rule. Request permissions from the main screen first.</string>
|
||||||
|
<string name="settingName">Setting name</string>
|
||||||
|
<string name="settingValue">Setting value</string>
|
||||||
|
<string name="enterAvalue">Enter a value.</string>
|
||||||
|
<string name="setSystemSettingCapital">Set system setting</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
* Fixed: Set-wifi action wasn't correctly pre-filled-out when editing action.
|
* Fixed: Set-wifi action wasn't correctly pre-filled-out when editing action.
|
||||||
* Fixed: Service startup checks improved when no rules with full permissions were present.
|
* Fixed: Service startup checks improved when no rules with full permissions were present.
|
||||||
* Fixed: Editing bluetooth trigger could crash if permissions weren't given.
|
* Fixed: Editing bluetooth trigger could crash if permissions weren't given.
|
||||||
|
* Added: Action to change system settings
|
||||||
Reference in New Issue
Block a user