Code cleaning
This commit is contained in:
parent
b584bec3f3
commit
72ea89b5f6
BIN
app/app-release.apk
Normal file
BIN
app/app-release.apk
Normal file
Binary file not shown.
@ -20,7 +20,6 @@ import java.util.GregorianCalendar;
|
|||||||
|
|
||||||
public class AntsNotificationsService extends NotificationListenerService {
|
public class AntsNotificationsService extends NotificationListenerService {
|
||||||
|
|
||||||
private String TAG = this.getClass().getSimpleName();
|
|
||||||
private SharedPreferences settings;
|
private SharedPreferences settings;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,7 +37,6 @@ public class AntsNotificationsService extends NotificationListenerService {
|
|||||||
public void onNotificationPosted(StatusBarNotification sbn) {
|
public void onNotificationPosted(StatusBarNotification sbn) {
|
||||||
if (settings.getBoolean("enable", false)) {
|
if (settings.getBoolean("enable", false)) {
|
||||||
if (sbn.getPackageName().equals("com.ants360.yicamera")) {
|
if (sbn.getPackageName().equals("com.ants360.yicamera")) {
|
||||||
//Log.i(TAG, sbn.getNotification().extras.getString("android.title"));
|
|
||||||
Intent dialogIntent = new Intent(this, AlarmActivity.class);
|
Intent dialogIntent = new Intent(this, AlarmActivity.class);
|
||||||
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
@ -52,14 +50,5 @@ public class AntsNotificationsService extends NotificationListenerService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNotificationRemoved(StatusBarNotification sbn) {
|
|
||||||
/* Log.i(TAG,"********** onNOtificationRemoved");
|
|
||||||
Log.i(TAG, "ID :" + sbn.getId() + "\t" + sbn.getNotification().tickerText + "\t" + sbn.getPackageName());
|
|
||||||
Intent i = new Intent("com.keyboard_crumbs.xiaomiantsalarmservice.NOTIFICATION_LISTENER_SERVICE");
|
|
||||||
i.putExtra("notification_event", "onNotificationRemoved :" + sbn.getPackageName() + "\n");*/
|
|
||||||
|
|
||||||
//sendBroadcast(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,27 +1,21 @@
|
|||||||
package com.keyboard_crumbs.xiaomiantsalarmservice;
|
package com.keyboard_crumbs.xiaomiantsalarmservice;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private SharedPreferences settings;
|
private SharedPreferences settings;
|
||||||
SharedPreferences.Editor editor;
|
SharedPreferences.Editor editor;
|
||||||
private Switch enableSwitch;
|
private Switch swEnableService;
|
||||||
private Switch removeNotiSwitch;
|
private Switch swRemoveNotification;
|
||||||
private Switch vibrateSwitch;
|
private Switch swVibrate;
|
||||||
private Button btnTest;
|
private Button btnTest;
|
||||||
private Intent dialogIntent;
|
private Intent dialogIntent;
|
||||||
|
|
||||||
@ -31,9 +25,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
btnTest = (Button)findViewById(R.id.btnTestAlarm);
|
btnTest = (Button)findViewById(R.id.btnTestAlarm);
|
||||||
enableSwitch = (Switch)findViewById(R.id.switch1);
|
swEnableService = (Switch)findViewById(R.id.switch1);
|
||||||
removeNotiSwitch = (Switch)findViewById(R.id.switch2);
|
swRemoveNotification = (Switch)findViewById(R.id.switch2);
|
||||||
vibrateSwitch = (Switch)findViewById(R.id.switch3);
|
swVibrate = (Switch)findViewById(R.id.switch3);
|
||||||
|
|
||||||
settings = getApplicationContext().getSharedPreferences("settings", 0);
|
settings = getApplicationContext().getSharedPreferences("settings", 0);
|
||||||
editor = settings.edit();
|
editor = settings.edit();
|
||||||
@ -42,21 +36,21 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
btnTest.setOnClickListener(onClickListener);
|
btnTest.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
enableSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swEnableService.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
editor.putBoolean("enable", isChecked);
|
editor.putBoolean("enable", isChecked);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
removeNotiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swRemoveNotification.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
editor.putBoolean("removeNotification", isChecked);
|
editor.putBoolean("removeNotification", isChecked);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
vibrateSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swVibrate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
editor.putBoolean("vibrate", isChecked);
|
editor.putBoolean("vibrate", isChecked);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
@ -67,9 +61,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
enableSwitch.setChecked(settings.getBoolean("enable", false));
|
swEnableService.setChecked(settings.getBoolean("enable", false));
|
||||||
removeNotiSwitch.setChecked(settings.getBoolean("removeNotification", false));
|
swRemoveNotification.setChecked(settings.getBoolean("removeNotification", false));
|
||||||
vibrateSwitch.setChecked(settings.getBoolean("vibrate", false));
|
swVibrate.setChecked(settings.getBoolean("vibrate", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener onClickListener = new View.OnClickListener() {
|
private View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
|
Reference in New Issue
Block a user