bug manage startOtherActivity

This commit is contained in:
Jens 2022-06-13 23:15:25 +02:00
parent 9c76340f24
commit ce9480d188
4 changed files with 54 additions and 54 deletions

View File

@ -192,9 +192,34 @@ public class ActivityManageActionStartActivity extends Activity
@Override @Override
public void onClick(View v) public void onClick(View v)
{ {
if(saveAction()) if(checkInput())
{ {
ActivityManageActionStartActivity.this.setResult(RESULT_OK); Intent returnData = new Intent();
returnData.putExtra(ActivityManageRule.intentNameActionParameter1, rbStartAppSelectByAction.isChecked());
String parameter2 = "";
if (rbStartAppSelectByActivity.isChecked())
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
else {
if (etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0)
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
else
parameter2 += Actions.dummyPackageString + ";" + etActivityOrActionPath.getText().toString();
}
if (rbStartAppByActivity.isChecked())
parameter2 += ";" + startByActivityString;
else
parameter2 += ";" + startByBroadcastString;
for (String s : intentPairList)
parameter2 += ";" + s;
returnData.putExtra(ActivityManageRule.intentNameActionParameter2, parameter2);
setResult(RESULT_OK, returnData);
finish(); finish();
} }
} }
@ -250,11 +275,8 @@ public class ActivityManageActionStartActivity extends Activity
}); });
Intent i = getIntent(); Intent i = getIntent();
if(i.getBooleanExtra("edit", false) == true) if(i.hasExtra(ActivityManageRule.intentNameActionParameter1))
{ loadValuesIntoGui(i);
edit = true;
loadValuesIntoGui();
}
} }
private class CustomPackageInfo extends PackageInfo implements Comparable<CustomPackageInfo> private class CustomPackageInfo extends PackageInfo implements Comparable<CustomPackageInfo>
@ -281,7 +303,6 @@ public class ActivityManageActionStartActivity extends Activity
} }
private static List<PackageInfo> pInfos = null; private static List<PackageInfo> pInfos = null;
public static Action resultingAction;
private static final String[] supportedIntentTypes = { "boolean", "byte", "char", "double", "float", "int", "long", "short", "String", "Uri" }; private static final String[] supportedIntentTypes = { "boolean", "byte", "char", "double", "float", "int", "long", "short", "String", "Uri" };
private ArrayList<String> intentPairList = new ArrayList<String>(); private ArrayList<String> intentPairList = new ArrayList<String>();
@ -539,13 +560,13 @@ public class ActivityManageActionStartActivity extends Activity
progressDialog = ProgressDialog.show(ActivityManageActionStartActivity.this, "", ActivityManageActionStartActivity.this.getResources().getString(R.string.gettingListOfInstalledApplications)); progressDialog = ProgressDialog.show(ActivityManageActionStartActivity.this, "", ActivityManageActionStartActivity.this.getResources().getString(R.string.gettingListOfInstalledApplications));
} }
private void loadValuesIntoGui() private void loadValuesIntoGui(Intent input)
{ {
boolean selectionByAction = resultingAction.getParameter1(); boolean selectionByAction = input.getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true);
rbStartAppSelectByActivity.setChecked(!selectionByAction); rbStartAppSelectByActivity.setChecked(!selectionByAction);
rbStartAppSelectByAction.setChecked(selectionByAction); rbStartAppSelectByAction.setChecked(selectionByAction);
String[] params = resultingAction.getParameter2().split(";"); String[] params = input.getStringExtra(ActivityManageRule.intentNameActionParameter2).split(";");
rbStartAppByActivity.setChecked(params[2].equals(startByActivityString)); rbStartAppByActivity.setChecked(params[2].equals(startByActivityString));
rbStartAppByBroadcast.setChecked(params[2].equals(startByBroadcastString)); rbStartAppByBroadcast.setChecked(params[2].equals(startByBroadcastString));
@ -591,8 +612,8 @@ public class ActivityManageActionStartActivity extends Activity
intentPairAdapter.notifyDataSetChanged(); intentPairAdapter.notifyDataSetChanged();
} }
private boolean saveAction() boolean checkInput()
{ {
if(rbStartAppSelectByActivity.isChecked()) if(rbStartAppSelectByActivity.isChecked())
{ {
@ -615,36 +636,7 @@ public class ActivityManageActionStartActivity extends Activity
return false; return false;
} }
} }
if(resultingAction == null)
resultingAction = new Action();
resultingAction.setParameter1(rbStartAppSelectByAction.isChecked());
resultingAction.setAction(Action_Enum.startOtherActivity);
String parameter2 = "";
if(rbStartAppSelectByActivity.isChecked())
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
else
{
if(etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0)
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
else
parameter2 += Actions.dummyPackageString + ";" + etActivityOrActionPath.getText().toString();
}
if(rbStartAppByActivity.isChecked())
parameter2 += ";" + startByActivityString;
else
parameter2 += ";" + startByBroadcastString;
for(String s : intentPairList)
parameter2 += ";" + s;
resultingAction.setParameter2(parameter2);
return true; return true;
} }

View File

@ -354,8 +354,8 @@ public class ActivityManageRule extends Activity
{ {
case startOtherActivity: case startOtherActivity:
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionStartActivity.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionStartActivity.class);
ActivityManageActionStartActivity.resultingAction = a; intent.putExtra(intentNameActionParameter1, a.getParameter1());
intent.putExtra("edit", true); intent.putExtra(intentNameActionParameter2, a.getParameter2());
startActivityForResult(intent, requestCodeActionStartActivityEdit); startActivityForResult(intent, requestCodeActionStartActivityEdit);
break; break;
case triggerUrl: case triggerUrl:
@ -1357,8 +1357,10 @@ public class ActivityManageRule extends Activity
// manage start of other activity // manage start of other activity
if(resultCode == RESULT_OK) if(resultCode == RESULT_OK)
{ {
newAction = ActivityManageActionStartActivity.resultingAction;
newAction.setParentRule(ruleToEdit); newAction.setParentRule(ruleToEdit);
newAction.setAction(Action_Enum.startOtherActivity);
newAction.setParameter1(data.getBooleanExtra(intentNameActionParameter1, true));
newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
ruleToEdit.getActionSet().add(newAction); ruleToEdit.getActionSet().add(newAction);
this.refreshActionList(); this.refreshActionList();
} }
@ -1368,9 +1370,14 @@ public class ActivityManageRule extends Activity
// manage start of other activity // manage start of other activity
if(resultCode == RESULT_OK) if(resultCode == RESULT_OK)
{ {
newAction = ActivityManageActionStartActivity.resultingAction; ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
newAction.setParentRule(ruleToEdit);
// ruleToEdit.getActionSet().add(newAction); if(data.hasExtra(intentNameActionParameter1))
ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra(intentNameActionParameter1, true));
if(data.hasExtra(intentNameActionParameter2))
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
this.refreshActionList(); this.refreshActionList();
} }
} }
@ -1502,11 +1509,11 @@ public class ActivityManageRule extends Activity
{ {
if(resultCode == RESULT_OK) if(resultCode == RESULT_OK)
{ {
if(data.hasExtra("autoBrightness")) if(data.hasExtra(ActivityManageActionBrightnessSetting.intentNameAutoBrightness))
ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra("autoBrightness", false)); ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra(ActivityManageActionBrightnessSetting.intentNameAutoBrightness, false));
if(data.hasExtra("brightnessValue")) if(data.hasExtra(ActivityManageActionBrightnessSetting.intentNameBrightnessValue))
ruleToEdit.getActionSet().get(editIndex).setParameter2(String.valueOf(data.getIntExtra("brightnessValue", 0))); ruleToEdit.getActionSet().get(editIndex).setParameter2(String.valueOf(data.getIntExtra(ActivityManageActionBrightnessSetting.intentNameBrightnessValue, 0)));
ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit); ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);

View File

@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.2.0' classpath 'com.android.tools.build:gradle:7.2.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

View File

@ -4,4 +4,5 @@
* New parameter for trigger Screen state: New state "locked" * New parameter for trigger Screen state: New state "locked"
* New action: Send broadcasts * New action: Send broadcasts
* Fixed: Crash when editing notification trigger * Fixed: Crash when editing notification trigger
* Fixed: TimeFrame trigger - time may have changed when crossing timezones or daylight saving changes * Fixed: TimeFrame trigger - time may have changed when crossing timezones or daylight saving changes
* Fixed: Bug when adding more than one startOtherActivity action