Notification listener started.

This commit is contained in:
jens 2021-03-27 19:57:39 +01:00
parent 80f8f9cfe2
commit 712a374adb
7 changed files with 74 additions and 60 deletions

View File

@ -289,7 +289,7 @@ public class ActivityManageStartActivity extends Activity
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
bSaveActionStartOtherActivity = (Button)findViewById(R.id.bSaveActionStartOtherActivity);
spinnerParameterType = (Spinner)findViewById(R.id.spinnerParameterType);
tvSelectedActivity = (TextView)findViewById(R.id.tvSelectedActivity);
tvSelectedActivity = (TextView)findViewById(R.id.tvSelectedApplication);
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageStartActivity.supportedIntentTypes);
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);

View File

@ -16,10 +16,11 @@ 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 android.widget.Toast;
import com.jens.automation2.Action.Action_Enum;
@ -33,12 +34,13 @@ public class ActivityManageTriggerNotification extends Activity
EditText etNotificationTitle, etNotificationText;
Button bSelectApp, bSaveTriggerNotification;
Spinner spinnerTitleDirection, spinnerTextDirection;
TextView tvSelectedActivity;
TextView tvSelectedApplication;
CheckBox chkNotificationDirection;
boolean edit = false;
ProgressDialog progressDialog = null;
private static List<PackageInfo> pInfos = null;
public static Action resultingAction;
public static Trigger resultingTrigger;
private static String[] directions;
@ -217,7 +219,7 @@ public class ActivityManageTriggerNotification extends Activity
{
//getActionStartActivityDialog3(packageArray[which]).show();
//Miscellaneous.messageBox(getResources().getString(R.string.hint), getResources().getString(R.string.chooseActivityHint), ActivityManageNotificationTrigger.this).show();
tvSelectedActivity.setText(packageArray[which]);
tvSelectedApplication.setText(packageArray[which]);
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
@ -235,7 +237,7 @@ public class ActivityManageTriggerNotification extends Activity
public void onClick(DialogInterface dialog, int which)
{
ActivityInfo ai = ActivityManageTriggerNotification.getActivityInfoForPackageNameAndActivityName(packageName, activityArray[which]);
tvSelectedActivity.setText(ai.packageName + ";" + ai.name);
tvSelectedApplication.setText(ai.packageName + ";" + ai.name);
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
@ -255,7 +257,8 @@ public class ActivityManageTriggerNotification extends Activity
bSaveTriggerNotification = (Button)findViewById(R.id.bSaveTriggerNotification);
spinnerTitleDirection = (Spinner)findViewById(R.id.spinnerTitleDirection);
spinnerTextDirection = (Spinner)findViewById(R.id.spinnerTextDirection);
tvSelectedActivity = (TextView)findViewById(R.id.tvSelectedActivity);
tvSelectedApplication = (TextView)findViewById(R.id.tvSelectedApplication);
chkNotificationDirection = (CheckBox)findViewById(R.id.chkNotificationDirection);
directions = new String[] {
getResources().getString(R.string.directionStringEquals),
@ -281,18 +284,28 @@ public class ActivityManageTriggerNotification extends Activity
}
});
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)
{
if(saveAction())
{
String app;
if(tvSelectedActivity.getText().toString().equalsIgnoreCase(getResources().getString(R.string.anyApp)))
if(tvSelectedApplication.getText().toString().equalsIgnoreCase(getResources().getString(R.string.anyApp)))
app = "-1";
else
app = tvSelectedActivity.getText().toString();
app = tvSelectedApplication.getText().toString();
String titleDir = Trigger.getMatchCode(spinnerTitleDirection.getSelectedItem().toString());
String title = etNotificationTitle.getText().toString();
@ -300,6 +313,7 @@ public class ActivityManageTriggerNotification extends Activity
String text = etNotificationText.getText().toString();
Intent data = new Intent();
data.putExtra("direction", chkNotificationDirection.isChecked());
data.putExtra("app", app);
data.putExtra("titleDir", titleDir);
data.putExtra("title", title);
@ -309,7 +323,6 @@ public class ActivityManageTriggerNotification extends Activity
ActivityManageTriggerNotification.this.setResult(RESULT_OK, data);
finish();
}
}
});
Intent i = getIntent();
@ -341,32 +354,6 @@ public class ActivityManageTriggerNotification extends Activity
// }
}
private boolean saveAction()
{
if(tvSelectedActivity.getText().toString().length() == 0)
{
Toast.makeText(ActivityManageTriggerNotification.this, getResources().getString(R.string.selectApplication), Toast.LENGTH_LONG).show();
return false;
}
if(tvSelectedActivity.getText().toString().equals(getResources().getString(R.string.selectApplication)))
{
Toast.makeText(this, getResources().getString(R.string.selectApplication), Toast.LENGTH_LONG).show();
return false;
}
if(resultingAction == null)
resultingAction = new Action();
resultingAction.setAction(Action_Enum.startOtherActivity);
String parameter2 = tvSelectedActivity.getText().toString();
resultingAction.setParameter2(parameter2);
return true;
}
private class GetActivityListTask extends AsyncTask<Void, Void, Void>
{
@Override

View File

@ -461,7 +461,11 @@ public class Trigger
String titleDir = params[1];
String title = params[2];
String textDir = params[3];
String text = params[4];
String text;
if(params.length >=5)
text = params[4];
else
text = "";
StringBuilder triggerBuilder = new StringBuilder();
String appString;

View File

@ -21,7 +21,7 @@
android:text="@string/selectApplication" />
<TextView
android:id="@+id/tvSelectedActivity"
android:id="@+id/tvSelectedApplication"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""

View File

@ -17,7 +17,7 @@
android:background="@color/barBackgroundColor" >
<TextView
android:id="@+id/tvSelectedActivity"
android:id="@+id/tvSelectedApplication"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/general"

View File

@ -20,7 +20,25 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow>
<TableRow
android:layout_marginBottom="@dimen/activity_vertical_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/direction"/>
<CheckBox
android:id="@+id/chkNotificationDirection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/notificationAppears"
android:checked="true"/>
</TableRow>
<TableRow
android:layout_marginBottom="@dimen/activity_vertical_margin">
<TextView
android:layout_gravity="center_vertical"
@ -34,7 +52,7 @@
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvSelectedActivity"
android:id="@+id/tvSelectedApplication"
android:layout_marginHorizontal="@dimen/default_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -51,7 +69,8 @@
</TableRow>
<TableRow>
<TableRow
android:layout_marginBottom="@dimen/activity_vertical_margin">
<TextView
android:layout_width="wrap_content"
@ -79,7 +98,8 @@
</TableRow>
<TableRow>
<TableRow
android:layout_marginBottom="@dimen/activity_vertical_margin">
<TextView
android:layout_width="wrap_content"

View File

@ -622,4 +622,7 @@
<string name="anyApp">Any app</string>
<string name="notificationTriggerExplanation">This trigger will respond to other applications opening notifications in the notification area. You can specify another application from which the notification has to come from. If you don\'t the notifications from any other application will count.\nYou can also specify strings that must be or must not be in the notification title or notification body.</string>
<string name="postsNotification">%1$s posts notification</string>
<string name="notificationAppears">Notification appears</string>
<string name="notificationDisappears">Notification disappears</string>
<string name="direction">Direction</string>
</resources>