forked from jens/Automation
intent pairs for sendBroadcast
This commit is contained in:
parent
bb1b3b0149
commit
f5a3636222
@ -5,19 +5,33 @@ import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ActivityManageActionSendBroadcast extends Activity
|
||||
{
|
||||
EditText etBroadcastToSend;
|
||||
Button bBroadcastSendShowSuggestions, bSaveSendBroadcast;
|
||||
Button bBroadcastSendShowSuggestions, bSaveSendBroadcast, bAddIntentPair;
|
||||
ListView lvIntentPairs;
|
||||
EditText etParameterName, etParameterValue;
|
||||
Spinner spinnerParameterType;
|
||||
ArrayAdapter<String> intentTypeSpinnerAdapter, intentPairAdapter;
|
||||
private static final String[] supportedIntentTypes = { "boolean", "byte", "char", "double", "float", "int", "long", "short", "String", "Uri" };
|
||||
private ArrayList<String> intentPairList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
@ -28,6 +42,15 @@ public class ActivityManageActionSendBroadcast extends Activity
|
||||
etBroadcastToSend = (EditText)findViewById(R.id.etBroadcastToSend);
|
||||
bBroadcastSendShowSuggestions = (Button)findViewById(R.id.bBroadcastSendShowSuggestions);
|
||||
bSaveSendBroadcast = (Button)findViewById(R.id.bSaveSendBroadcast);
|
||||
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
|
||||
lvIntentPairs = (ListView) findViewById(R.id.lvIntentPairs);
|
||||
etParameterName = (EditText) findViewById(R.id.etParameterName);
|
||||
etParameterValue = (EditText) findViewById(R.id.etParameterValue);
|
||||
spinnerParameterType = (Spinner) findViewById(R.id.spinnerParameterType);
|
||||
|
||||
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionSendBroadcast.supportedIntentTypes);
|
||||
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
||||
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
||||
|
||||
bSaveSendBroadcast.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@ -37,6 +60,7 @@ public class ActivityManageActionSendBroadcast extends Activity
|
||||
if(checkInput())
|
||||
{
|
||||
Intent answer = new Intent();
|
||||
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, etBroadcastToSend.getText().toString());
|
||||
setResult(RESULT_OK, answer);
|
||||
finish();
|
||||
@ -66,7 +90,120 @@ public class ActivityManageActionSendBroadcast extends Activity
|
||||
Intent input = getIntent();
|
||||
|
||||
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||
{
|
||||
String param2 = input.getStringExtra(ActivityManageRule.intentNameActionParameter2);
|
||||
if(!param2.contains(Action.actionParameter2Split))
|
||||
etBroadcastToSend.setText(input.getStringExtra(ActivityManageRule.intentNameActionParameter2));
|
||||
else
|
||||
{
|
||||
String[] param2Parts = param2.split(Action.actionParameter2Split);
|
||||
etBroadcastToSend.setText(param2Parts[0]);
|
||||
|
||||
String[] params = param2Parts[1].split(";");
|
||||
|
||||
if(startIndex > -1 && params.length > startIndex)
|
||||
{
|
||||
intentPairList.clear();
|
||||
|
||||
for(int i=startIndex; i<params.length; i++)
|
||||
{
|
||||
if(lvIntentPairs.getVisibility() != View.VISIBLE)
|
||||
lvIntentPairs.setVisibility(View.VISIBLE);
|
||||
|
||||
intentPairList.add(params[i]);
|
||||
}
|
||||
|
||||
updateIntentPairList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bAddIntentPair.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
// type;name;value
|
||||
if(spinnerParameterType.getSelectedItem().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.selectTypeOfIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterName.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterValue.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
|
||||
intentPairList.add(param);
|
||||
|
||||
spinnerParameterType.setSelection(0);
|
||||
etParameterName.setText("");
|
||||
etParameterValue.setText("");
|
||||
|
||||
updateIntentPairList();
|
||||
|
||||
if(lvIntentPairs.getVisibility() != View.VISIBLE)
|
||||
lvIntentPairs.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
getIntentPairDialog(arg2).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
spinnerParameterType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
||||
{
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
if(supportedIntentTypes[arg2].equals("double") | supportedIntentTypes[arg2].equals("float") | supportedIntentTypes[arg2].equals("int") | supportedIntentTypes[arg2].equals("long") | supportedIntentTypes[arg2].equals("short"))
|
||||
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
else
|
||||
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean checkInput()
|
||||
@ -80,4 +217,30 @@ public class ActivityManageActionSendBroadcast extends Activity
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateIntentPairList()
|
||||
{
|
||||
if(lvIntentPairs.getAdapter() == null)
|
||||
lvIntentPairs.setAdapter(intentPairAdapter);
|
||||
|
||||
intentPairAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private AlertDialog getIntentPairDialog(final int itemPosition)
|
||||
{
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityManageActionSendBroadcast.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
|
||||
ActivityManageActionSendBroadcast.this.intentPairList.remove(itemPosition);
|
||||
updateIntentPairList();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
return alertDialog;
|
||||
}
|
||||
}
|
@ -61,6 +61,202 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
|
||||
final static int requestCodeForRequestQueryAllPackagesPermission = 4711;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_start_activity);
|
||||
|
||||
lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs);
|
||||
etParameterName = (EditText)findViewById(R.id.etParameterName);
|
||||
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
|
||||
bSelectApp = (Button)findViewById(R.id.bSelectApp);
|
||||
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
|
||||
bSaveActionStartOtherActivity = (Button)findViewById(R.id.bSaveActionStartOtherActivity);
|
||||
spinnerParameterType = (Spinner)findViewById(R.id.spinnerParameterType);
|
||||
etPackageName = (EditText) findViewById(R.id.etPackageName);
|
||||
etActivityOrActionPath = (EditText) findViewById(R.id.etActivityOrActionPath);
|
||||
rbStartAppSelectByActivity = (RadioButton)findViewById(R.id.rbStartAppSelectByActivity);
|
||||
rbStartAppSelectByAction = (RadioButton)findViewById(R.id.rbStartAppSelectByAction);
|
||||
showStartProgramExamples = (Button)findViewById(R.id.showStartProgramExamples);
|
||||
rbStartAppByActivity = (RadioButton)findViewById(R.id.rbStartAppByActivity);
|
||||
rbStartAppByBroadcast = (RadioButton)findViewById(R.id.rbStartAppByBroadcast);
|
||||
|
||||
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionStartActivity.supportedIntentTypes);
|
||||
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
||||
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
||||
|
||||
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
|
||||
|
||||
bSelectApp.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
int targetSdkVersion = getApplicationContext().getApplicationInfo().targetSdkVersion;
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && targetSdkVersion >= 30 && !ActivityPermissions.havePermission(Manifest.permission.QUERY_ALL_PACKAGES, ActivityManageActionStartActivity.this))// && shouldShowRequestPermissionRationale(Manifest.permission.QUERY_ALL_PACKAGES))
|
||||
{
|
||||
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
|
||||
{
|
||||
// This ain't possible anymore.
|
||||
Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.featureNotInGooglePlayVersion) + Miscellaneous.lineSeparator + Miscellaneous.lineSeparator + getResources().getString(R.string.startActivityInsertManually), ActivityManageActionStartActivity.this).show();
|
||||
}
|
||||
else
|
||||
requestPermissions(new String[] {Manifest.permission.QUERY_ALL_PACKAGES}, requestCodeForRequestQueryAllPackagesPermission);
|
||||
}
|
||||
else
|
||||
getAppList();
|
||||
}
|
||||
});
|
||||
|
||||
bAddIntentPair.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
// type;name;value
|
||||
if(spinnerParameterType.getSelectedItem().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.selectTypeOfIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterName.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterValue.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
|
||||
intentPairList.add(param);
|
||||
|
||||
spinnerParameterType.setSelection(0);
|
||||
etParameterName.setText("");
|
||||
etParameterValue.setText("");
|
||||
|
||||
updateIntentPairList();
|
||||
|
||||
if(lvIntentPairs.getVisibility() != View.VISIBLE)
|
||||
lvIntentPairs.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
showStartProgramExamples.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlShowExamples));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnItemLongClickListener(new OnItemLongClickListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
getIntentPairDialog(arg2).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
bSaveActionStartOtherActivity.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if(saveAction())
|
||||
{
|
||||
ActivityManageActionStartActivity.this.setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnTouchListener(new OnTouchListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event)
|
||||
{
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
spinnerParameterType.setOnItemSelectedListener(new OnItemSelectedListener()
|
||||
{
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
if(supportedIntentTypes[arg2].equals("double") | supportedIntentTypes[arg2].equals("float") | supportedIntentTypes[arg2].equals("int") | supportedIntentTypes[arg2].equals("long") | supportedIntentTypes[arg2].equals("short"))
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
else
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
rbStartAppSelectByActivity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if(isChecked)
|
||||
bSelectApp.setEnabled(isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
rbStartAppSelectByAction.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if(isChecked)
|
||||
bSelectApp.setEnabled(!isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
Intent i = getIntent();
|
||||
if(i.getBooleanExtra("edit", false) == true)
|
||||
{
|
||||
edit = true;
|
||||
loadValuesIntoGui();
|
||||
}
|
||||
}
|
||||
|
||||
private class CustomPackageInfo extends PackageInfo implements Comparable<CustomPackageInfo>
|
||||
{
|
||||
@Override
|
||||
@ -82,7 +278,6 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static List<PackageInfo> pInfos = null;
|
||||
@ -344,203 +539,6 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
progressDialog = ProgressDialog.show(ActivityManageActionStartActivity.this, "", ActivityManageActionStartActivity.this.getResources().getString(R.string.gettingListOfInstalledApplications));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_start_activity);
|
||||
|
||||
lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs);
|
||||
etParameterName = (EditText)findViewById(R.id.etParameterName);
|
||||
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
|
||||
bSelectApp = (Button)findViewById(R.id.bSelectApp);
|
||||
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
|
||||
bSaveActionStartOtherActivity = (Button)findViewById(R.id.bSaveActionStartOtherActivity);
|
||||
spinnerParameterType = (Spinner)findViewById(R.id.spinnerParameterType);
|
||||
etPackageName = (EditText) findViewById(R.id.etPackageName);
|
||||
etActivityOrActionPath = (EditText) findViewById(R.id.etActivityOrActionPath);
|
||||
rbStartAppSelectByActivity = (RadioButton)findViewById(R.id.rbStartAppSelectByActivity);
|
||||
rbStartAppSelectByAction = (RadioButton)findViewById(R.id.rbStartAppSelectByAction);
|
||||
showStartProgramExamples = (Button)findViewById(R.id.showStartProgramExamples);
|
||||
|
||||
rbStartAppByActivity = (RadioButton)findViewById(R.id.rbStartAppByActivity);
|
||||
rbStartAppByBroadcast = (RadioButton)findViewById(R.id.rbStartAppByBroadcast);
|
||||
|
||||
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionStartActivity.supportedIntentTypes);
|
||||
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
||||
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
||||
|
||||
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
|
||||
|
||||
bSelectApp.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
int targetSdkVersion = getApplicationContext().getApplicationInfo().targetSdkVersion;
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && targetSdkVersion >= 30 && !ActivityPermissions.havePermission(Manifest.permission.QUERY_ALL_PACKAGES, ActivityManageActionStartActivity.this))// && shouldShowRequestPermissionRationale(Manifest.permission.QUERY_ALL_PACKAGES))
|
||||
{
|
||||
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
|
||||
{
|
||||
// This ain't possible anymore.
|
||||
Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.featureNotInGooglePlayVersion) + Miscellaneous.lineSeparator + Miscellaneous.lineSeparator + getResources().getString(R.string.startActivityInsertManually), ActivityManageActionStartActivity.this).show();
|
||||
}
|
||||
else
|
||||
requestPermissions(new String[] {Manifest.permission.QUERY_ALL_PACKAGES}, requestCodeForRequestQueryAllPackagesPermission);
|
||||
}
|
||||
else
|
||||
getAppList();
|
||||
}
|
||||
});
|
||||
|
||||
bAddIntentPair.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
// type;name;value
|
||||
if(spinnerParameterType.getSelectedItem().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.selectTypeOfIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterName.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterValue.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
|
||||
intentPairList.add(param);
|
||||
|
||||
spinnerParameterType.setSelection(0);
|
||||
etParameterName.setText("");
|
||||
etParameterValue.setText("");
|
||||
|
||||
updateIntentPairList();
|
||||
|
||||
if(lvIntentPairs.getVisibility() != View.VISIBLE)
|
||||
lvIntentPairs.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
showStartProgramExamples.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlShowExamples));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnItemLongClickListener(new OnItemLongClickListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
getIntentPairDialog(arg2).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
bSaveActionStartOtherActivity.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if(saveAction())
|
||||
{
|
||||
ActivityManageActionStartActivity.this.setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnTouchListener(new OnTouchListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event)
|
||||
{
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
spinnerParameterType.setOnItemSelectedListener(new OnItemSelectedListener()
|
||||
{
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
if(supportedIntentTypes[arg2].equals("double") | supportedIntentTypes[arg2].equals("float") | supportedIntentTypes[arg2].equals("int") | supportedIntentTypes[arg2].equals("long") | supportedIntentTypes[arg2].equals("short"))
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
else
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
rbStartAppSelectByActivity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if(isChecked)
|
||||
bSelectApp.setEnabled(isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
rbStartAppSelectByAction.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if(isChecked)
|
||||
bSelectApp.setEnabled(!isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
Intent i = getIntent();
|
||||
if(i.getBooleanExtra("edit", false) == true)
|
||||
{
|
||||
edit = true;
|
||||
loadValuesIntoGui();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadValuesIntoGui()
|
||||
{
|
||||
boolean selectionByAction = resultingAction.getParameter1();
|
||||
|
@ -21,13 +21,19 @@
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/broadcastExplanation" />
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Broadcast:" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etBroadcastToSend"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="@dimen/default_margin"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bBroadcastSendShowSuggestions"
|
||||
@ -36,6 +42,113 @@
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
android:text="@string/broadcastsShowSuggestions" />
|
||||
|
||||
<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="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/intentDataComment" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/parameterType" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinnerParameterType"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCurrentNfcIdValue"
|
||||
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>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bAddIntentPair"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/addIntentValue" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/lvIntentPairs"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="115dp"
|
||||
android:layout_marginBottom="@dimen/default_margin" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveSendBroadcast"
|
||||
android:layout_width="wrap_content"
|
||||
|
Loading…
Reference in New Issue
Block a user