notification action
This commit is contained in:
parent
9b8ae2271b
commit
246a02371a
@ -147,6 +147,7 @@
|
||||
<activity android:name=".ActivityDisplayLongMessage" />
|
||||
<activity android:name=".ActivityManageActionSendTextMessage" />
|
||||
<activity android:name=".ActivityManageActionPlaySound" />
|
||||
<activity android:name=".ActivityManageActionCloseNotification"
|
||||
<activity android:name=".ActivityManageTriggerProfile" />
|
||||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityMaintenance" />
|
||||
|
@ -150,6 +150,7 @@
|
||||
<activity android:name=".ActivityMaintenance" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
|
@ -144,6 +144,7 @@
|
||||
<activity android:name=".ActivityMaintenance" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
|
@ -45,6 +45,7 @@ public class Action
|
||||
playSound,
|
||||
vibrate,
|
||||
createNotification,
|
||||
closeNotification,
|
||||
sendTextMessage;
|
||||
|
||||
public String getFullName(Context context)
|
||||
@ -243,6 +244,9 @@ public class Action
|
||||
case createNotification:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.createNotification));
|
||||
break;
|
||||
case closeNotification:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.closeNotifications));
|
||||
break;
|
||||
default:
|
||||
returnString.append(action.toString());
|
||||
}
|
||||
@ -460,6 +464,9 @@ public class Action
|
||||
case createNotification:
|
||||
Actions.createNotification(this);
|
||||
break;
|
||||
case closeNotification:
|
||||
Actions.closeNotification(this);
|
||||
break;
|
||||
default:
|
||||
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
||||
break;
|
||||
|
@ -3,6 +3,7 @@ package com.jens.automation2;
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
@ -23,6 +24,7 @@ import android.os.PowerManager.WakeLock;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.MediaStore;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.telephony.SmsManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
@ -98,7 +100,17 @@ public class Actions
|
||||
}
|
||||
}
|
||||
|
||||
public static class WifiStuff
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public static void closeNotification(Action action)
|
||||
{
|
||||
NotificationManager nm = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
for(StatusBarNotification n : nm.getActiveNotifications())
|
||||
{
|
||||
n.
|
||||
}
|
||||
}
|
||||
|
||||
public static class WifiStuff
|
||||
{
|
||||
public static Boolean setWifi(Context context, Boolean desiredState, boolean toggleActionIfPossible)
|
||||
{
|
||||
|
@ -0,0 +1,405 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import static com.jens.automation2.Trigger.triggerParameter2Split;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class ActivityManageActionCloseNotification extends Activity
|
||||
{
|
||||
public static final String intentNameNotificationApp = "app";
|
||||
public static final String intentNameNotificationTitleDir = "titleDir";
|
||||
public static final String intentNameNotificationTitle = "title";
|
||||
public static final String intentNameNotificationTextDir = "textDir";
|
||||
public static final String intentNameNotificationText = "text";
|
||||
public static final String intentNameNotificationDirection = "direction";
|
||||
|
||||
public static Trigger editedNotificationTrigger;
|
||||
boolean edit = false;
|
||||
ProgressDialog progressDialog = null;
|
||||
|
||||
EditText etNotificationTitle, etNotificationText;
|
||||
Button bSelectApp, bSaveTriggerNotification;
|
||||
Spinner spinnerTitleDirection, spinnerTextDirection;
|
||||
TextView tvSelectedApplication;
|
||||
CheckBox chkNotificationDirection;
|
||||
|
||||
private static List<PackageInfo> pInfos = null;
|
||||
public static Trigger resultingTrigger;
|
||||
|
||||
private static String[] directions;
|
||||
|
||||
ArrayAdapter<String> directionSpinnerAdapter;
|
||||
|
||||
public static void getActivityList(final Context context)
|
||||
{
|
||||
if(pInfos == null)
|
||||
{
|
||||
pInfos = context.getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);
|
||||
Collections.sort(pInfos, new Comparator<PackageInfo>()
|
||||
{
|
||||
public int compare(PackageInfo obj1, PackageInfo obj2)
|
||||
{
|
||||
String name1 = "";
|
||||
String name2 = "";
|
||||
|
||||
ApplicationInfo aInfo1 = obj1.applicationInfo;
|
||||
if (aInfo1 != null)
|
||||
{
|
||||
name1 = (String) context.getPackageManager().getApplicationLabel(aInfo1);
|
||||
}
|
||||
ApplicationInfo aInfo2 = obj2.applicationInfo;
|
||||
if (aInfo2 != null)
|
||||
{
|
||||
name2 = (String) context.getPackageManager().getApplicationLabel(aInfo2);
|
||||
}
|
||||
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] getApplicationNameListString(Context myContext)
|
||||
{
|
||||
// Generate the actual list
|
||||
getActivityList(myContext);
|
||||
|
||||
ArrayList<String> returnList = new ArrayList<String>();
|
||||
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
ApplicationInfo aInfo = pInfo.applicationInfo;
|
||||
if (aInfo != null)
|
||||
{
|
||||
String aLabel;
|
||||
|
||||
aLabel = (String) myContext.getPackageManager().getApplicationLabel(aInfo);
|
||||
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null && aInfos.length > 0) // Only put Applications into the list that have packages.
|
||||
{
|
||||
if(!returnList.contains(aLabel))
|
||||
returnList.add(aLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnList.toArray(new String[returnList.size()]);
|
||||
}
|
||||
|
||||
public static String[] getPackageListString(Context myContext, String applicationLabel)
|
||||
{
|
||||
// Generate the actual list
|
||||
getActivityList(myContext);
|
||||
|
||||
ArrayList<String> returnList = new ArrayList<String>();
|
||||
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
if(myContext.getPackageManager().getApplicationLabel(pInfo.applicationInfo).equals(applicationLabel))
|
||||
{
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null && aInfos.length > 0)
|
||||
{
|
||||
returnList.add(pInfo.packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnList.toArray(new String[returnList.size()]);
|
||||
}
|
||||
|
||||
public static String[] getPackageListString(Context myContext)
|
||||
{
|
||||
// Generate the actual list
|
||||
getActivityList(myContext);
|
||||
|
||||
ArrayList<String> returnList = new ArrayList<String>();
|
||||
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null && aInfos.length > 0)
|
||||
{
|
||||
returnList.add(pInfo.packageName);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("w", "Empty Application", "Application " + myContext.getPackageManager().getApplicationLabel(pInfo.applicationInfo) + " doesn\'t have packages.", 5);
|
||||
}
|
||||
|
||||
return returnList.toArray(new String[returnList.size()]);
|
||||
}
|
||||
|
||||
public static String[] getActivityListForPackageName(String packageName)
|
||||
{
|
||||
ArrayList<String> returnList = new ArrayList<String>();
|
||||
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
if(pInfo.packageName.equals(packageName))
|
||||
{
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null)
|
||||
{
|
||||
for (ActivityInfo activityInfo : aInfos)
|
||||
{
|
||||
returnList.add(activityInfo.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnList.toArray(new String[returnList.size()]);
|
||||
}
|
||||
|
||||
public static ActivityInfo getActivityInfoForPackageNameAndActivityName(String packageName, String activityName)
|
||||
{
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
if(pInfo.packageName.equals(packageName))
|
||||
{
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null)
|
||||
{
|
||||
for (ActivityInfo activityInfo : aInfos)
|
||||
{
|
||||
if(activityInfo.name.equals(activityName))
|
||||
return activityInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private AlertDialog getActionStartActivityDialog1()
|
||||
{
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||
alertDialogBuilder.setTitle(getResources().getString(R.string.selectApplication));
|
||||
final String[] applicationArray = ActivityManageActionCloseNotification.getApplicationNameListString(this);
|
||||
alertDialogBuilder.setItems(applicationArray, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.dismiss();
|
||||
getActionStartActivityDialog2(applicationArray[which]).show();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
private AlertDialog getActionStartActivityDialog2(String applicationName)
|
||||
{
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||
alertDialogBuilder.setTitle(getResources().getString(R.string.selectPackageOfApplication));
|
||||
final String[] packageArray = ActivityManageActionCloseNotification.getPackageListString(this, applicationName);
|
||||
alertDialogBuilder.setItems(packageArray, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
//getActionStartActivityDialog3(packageArray[which]).show();
|
||||
//Miscellaneous.messageBox(getResources().getString(R.string.hint), getResources().getString(R.string.chooseActivityHint), ActivityManageNotificationTrigger.this).show();
|
||||
tvSelectedApplication.setText(packageArray[which]);
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
private AlertDialog getActionStartActivityDialog3(final String packageName)
|
||||
{
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||
alertDialogBuilder.setTitle(getResources().getString(R.string.selectActivityToBeStarted));
|
||||
final String activityArray[] = ActivityManageActionCloseNotification.getActivityListForPackageName(packageName);
|
||||
alertDialogBuilder.setItems(activityArray, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
ActivityInfo ai = ActivityManageActionCloseNotification.getActivityInfoForPackageNameAndActivityName(packageName, activityArray[which]);
|
||||
tvSelectedApplication.setText(ai.packageName + ";" + ai.name);
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_trigger_notification);
|
||||
|
||||
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
|
||||
etNotificationText = (EditText)findViewById(R.id.etNotificationText);
|
||||
bSelectApp = (Button)findViewById(R.id.bSelectApp);
|
||||
bSaveTriggerNotification = (Button)findViewById(R.id.bSaveTriggerNotification);
|
||||
spinnerTitleDirection = (Spinner)findViewById(R.id.spinnerTitleDirection);
|
||||
spinnerTextDirection = (Spinner)findViewById(R.id.spinnerTextDirection);
|
||||
tvSelectedApplication = (TextView)findViewById(R.id.etActivityOrActionPath);
|
||||
chkNotificationDirection = (CheckBox)findViewById(R.id.chkNotificationDirection);
|
||||
|
||||
directions = new String[] {
|
||||
getResources().getString(R.string.directionStringEquals),
|
||||
getResources().getString(R.string.directionStringContains),
|
||||
getResources().getString(R.string.directionStringStartsWith),
|
||||
getResources().getString(R.string.directionStringEndsWith),
|
||||
getResources().getString(R.string.directionStringNotEquals)
|
||||
};
|
||||
|
||||
directionSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionCloseNotification.directions);
|
||||
spinnerTitleDirection.setAdapter(directionSpinnerAdapter);
|
||||
spinnerTextDirection.setAdapter(directionSpinnerAdapter);
|
||||
directionSpinnerAdapter.notifyDataSetChanged();
|
||||
|
||||
bSelectApp.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
GetActivityListTask getActivityListTask = new GetActivityListTask();
|
||||
getActivityListTask.execute();
|
||||
progressDialog = ProgressDialog.show(ActivityManageActionCloseNotification.this, "", ActivityManageActionCloseNotification.this.getResources().getString(R.string.gettingListOfInstalledApplications));
|
||||
}
|
||||
});
|
||||
|
||||
chkNotificationDirection.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if(isChecked)
|
||||
chkNotificationDirection.setText(getResources().getString(R.string.notificationAppears));
|
||||
else
|
||||
chkNotificationDirection.setText(getResources().getString(R.string.notificationDisappears));
|
||||
}
|
||||
});
|
||||
|
||||
bSaveTriggerNotification.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
String app;
|
||||
if(tvSelectedApplication.getText().toString().equalsIgnoreCase(getResources().getString(R.string.anyApp)))
|
||||
app = "-1";
|
||||
else
|
||||
app = tvSelectedApplication.getText().toString();
|
||||
|
||||
String titleDir = Trigger.getMatchCode(spinnerTitleDirection.getSelectedItem().toString());
|
||||
String title = etNotificationTitle.getText().toString();
|
||||
String textDir = Trigger.getMatchCode(spinnerTextDirection.getSelectedItem().toString());
|
||||
String text = etNotificationText.getText().toString();
|
||||
|
||||
if(edit)
|
||||
{
|
||||
editedNotificationTrigger.setTriggerParameter(chkNotificationDirection.isChecked());
|
||||
editedNotificationTrigger.setTriggerParameter2(app + triggerParameter2Split + titleDir + triggerParameter2Split + title + triggerParameter2Split + textDir + triggerParameter2Split + text);
|
||||
ActivityManageActionCloseNotification.this.setResult(RESULT_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
Intent data = new Intent();
|
||||
data.putExtra(intentNameNotificationDirection, chkNotificationDirection.isChecked());
|
||||
data.putExtra(intentNameNotificationApp, app);
|
||||
data.putExtra(intentNameNotificationTitleDir, titleDir);
|
||||
data.putExtra(intentNameNotificationTitle, title);
|
||||
data.putExtra(intentNameNotificationTextDir, textDir);
|
||||
data.putExtra(intentNameNotificationText, text);
|
||||
ActivityManageActionCloseNotification.this.setResult(RESULT_OK, data);
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
Intent i = getIntent();
|
||||
if(i.getBooleanExtra("edit", false) == true)
|
||||
{
|
||||
edit = true;
|
||||
loadValuesIntoGui();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadValuesIntoGui()
|
||||
{
|
||||
chkNotificationDirection.setChecked(editedNotificationTrigger.getTriggerParameter());
|
||||
|
||||
String[] params = editedNotificationTrigger.getTriggerParameter2().split(triggerParameter2Split);
|
||||
|
||||
String app = params[0];
|
||||
String titleDir = params[1];
|
||||
String title = params[2];
|
||||
String textDir = params[3];
|
||||
String text;
|
||||
if (params.length >= 5)
|
||||
text = params[4];
|
||||
else
|
||||
text = "";
|
||||
|
||||
if(!app.equals("-1"))
|
||||
tvSelectedApplication.setText(app);
|
||||
|
||||
for(int i = 0; i < directions.length; i++)
|
||||
{
|
||||
if(Trigger.getMatchCode(directions[i]).equalsIgnoreCase(titleDir))
|
||||
spinnerTitleDirection.setSelection(i);
|
||||
|
||||
if(Trigger.getMatchCode(directions[i]).equalsIgnoreCase(textDir))
|
||||
spinnerTextDirection.setSelection(i);
|
||||
}
|
||||
|
||||
if(title.length() > 0)
|
||||
etNotificationTitle.setText(title);
|
||||
|
||||
if(text.length() > 0)
|
||||
etNotificationText.setText(text);
|
||||
}
|
||||
|
||||
private class GetActivityListTask extends AsyncTask<Void, Void, Void>
|
||||
{
|
||||
@Override
|
||||
protected Void doInBackground(Void... params)
|
||||
{
|
||||
getActivityList(ActivityManageActionCloseNotification.this);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result)
|
||||
{
|
||||
progressDialog.dismiss();
|
||||
getActionStartActivityDialog1().show();
|
||||
}
|
||||
}
|
||||
}
|
@ -102,7 +102,7 @@ public class ActivityManageRule extends Activity
|
||||
final static int requestCodeTriggerDeviceOrientationAdd = 301;
|
||||
final static int requestCodeTriggerDeviceOrientationEdit = 302;
|
||||
final static int requestCodeTriggerNotificationAdd = 8000;
|
||||
final static int requestCodeTriggerNfcNotificationEdit = 8001;
|
||||
final static int requestCodeTriggerNotificationEdit = 8001;
|
||||
final static int requestCodeActionPlaySoundAdd = 501;
|
||||
final static int requestCodeActionPlaySoundEdit = 502;
|
||||
final static int requestCodeTriggerPhoneCallAdd = 601;
|
||||
@ -117,6 +117,8 @@ public class ActivityManageRule extends Activity
|
||||
final static int requestCodeActionVibrateEdit = 802;
|
||||
final static int requestCodeActionCreateNotificationAdd = 803;
|
||||
final static int requestCodeActionCreateNotificationEdit = 804;
|
||||
final static int requestCodeActionCloseNotificationAdd = 805;
|
||||
final static int requestCodeActionCloseNotificationEdit = 806;
|
||||
|
||||
public static ActivityManageRule getInstance()
|
||||
{
|
||||
@ -268,7 +270,7 @@ public class ActivityManageRule extends Activity
|
||||
ActivityManageTriggerNotification.editedNotificationTrigger = selectedTrigger;
|
||||
Intent notificationEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerNotification.class);
|
||||
notificationEditor.putExtra("edit", true);
|
||||
startActivityForResult(notificationEditor, requestCodeTriggerNfcNotificationEdit);
|
||||
startActivityForResult(notificationEditor, requestCodeTriggerNotificationEdit);
|
||||
break;
|
||||
case phoneCall:
|
||||
ActivityManageTriggerPhoneCall.editedPhoneCallTrigger = selectedTrigger;
|
||||
@ -371,6 +373,11 @@ public class ActivityManageRule extends Activity
|
||||
activityEditCreateNotificationIntent.putExtra(ActivityManageActionCreateNotification.intentNameNotificationText, elements[1]);
|
||||
startActivityForResult(activityEditCreateNotificationIntent, requestCodeActionCreateNotificationEdit);
|
||||
break;
|
||||
case closeNotification:
|
||||
Intent activityEditCloseNotificationIntent = new Intent(ActivityManageRule.this, ActivityManageActionCloseNotification.class);
|
||||
activityEditCloseNotificationIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||
startActivityForResult(activityEditCloseNotificationIntent, requestCodeActionCloseNotificationEdit);
|
||||
break;
|
||||
case playSound:
|
||||
Intent actionPlaySoundIntent = new Intent(context, ActivityManageActionPlaySound.class);
|
||||
actionPlaySoundIntent.putExtra("edit", true);
|
||||
@ -1269,7 +1276,7 @@ public class ActivityManageRule extends Activity
|
||||
this.refreshTriggerList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeTriggerNfcNotificationEdit)
|
||||
else if(requestCode == requestCodeTriggerNotificationEdit)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
@ -1390,6 +1397,16 @@ public class ActivityManageRule extends Activity
|
||||
this.refreshActionList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeActionCloseNotificationAdd)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
newAction.setParentRule(ruleToEdit);
|
||||
newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||
ruleToEdit.getActionSet().add(newAction);
|
||||
this.refreshActionList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeActionVibrateEdit)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
@ -1418,6 +1435,18 @@ public class ActivityManageRule extends Activity
|
||||
this.refreshActionList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeActionCloseNotificationEdit)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
|
||||
|
||||
if(data.hasExtra(intentNameActionParameter2))
|
||||
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||
|
||||
this.refreshActionList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeActionPlaySoundAdd)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
@ -1728,6 +1757,12 @@ public class ActivityManageRule extends Activity
|
||||
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCreateNotification.class);
|
||||
startActivityForResult(intent, requestCodeActionCreateNotificationAdd);
|
||||
}
|
||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.closeNotification.toString()))
|
||||
{
|
||||
newAction.setAction(Action_Enum.closeNotification);
|
||||
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCloseNotification.class);
|
||||
startActivityForResult(intent, requestCodeActionCloseNotificationAdd);
|
||||
}
|
||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setScreenBrightness.toString()))
|
||||
{
|
||||
newAction.setAction(Action_Enum.setScreenBrightness);
|
||||
|
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/default_margin" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/closeNotifications"
|
||||
android:textSize="25dp"
|
||||
android:layout_marginBottom="@dimen/default_margin" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/notificationCloseActionExplanation" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:shrinkColumns="1"
|
||||
android:stretchColumns="1">
|
||||
|
||||
<TableRow
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/application" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_marginHorizontal="@dimen/default_margin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/etActivityOrActionPath"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/anyApp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSelectApp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/selectApplication" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<TableRow
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/title" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinnerTitleDirection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etNotificationTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<TableRow
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/text" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinnerTextDirection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etNotificationText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</TableRow>>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveTriggerNotification"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -760,4 +760,6 @@
|
||||
<string name="enterText">Enter a text.</string>
|
||||
<string name="info">Info</string>
|
||||
<string name="profileWasNotFound">The profile used in this rule doesn\'t seem to exist anymore. The alphabetically first one has been selected.</string>
|
||||
<string name="notificationCloseActionExplanation">If you don\'t specify any criteria this action will close ALL applicable notifications. So it\'s advised to at least specify criteria for at least 1 of application, title or text.</string>
|
||||
<string name="closeNotifications">Close notification(s)</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user