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 {
|
||||
|
||||
private String TAG = this.getClass().getSimpleName();
|
||||
private SharedPreferences settings;
|
||||
|
||||
@Override
|
||||
@ -38,7 +37,6 @@ public class AntsNotificationsService extends NotificationListenerService {
|
||||
public void onNotificationPosted(StatusBarNotification sbn) {
|
||||
if (settings.getBoolean("enable", false)) {
|
||||
if (sbn.getPackageName().equals("com.ants360.yicamera")) {
|
||||
//Log.i(TAG, sbn.getNotification().extras.getString("android.title"));
|
||||
Intent dialogIntent = new Intent(this, AlarmActivity.class);
|
||||
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
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;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Switch;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private SharedPreferences settings;
|
||||
SharedPreferences.Editor editor;
|
||||
private Switch enableSwitch;
|
||||
private Switch removeNotiSwitch;
|
||||
private Switch vibrateSwitch;
|
||||
private Switch swEnableService;
|
||||
private Switch swRemoveNotification;
|
||||
private Switch swVibrate;
|
||||
private Button btnTest;
|
||||
private Intent dialogIntent;
|
||||
|
||||
@ -31,9 +25,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
btnTest = (Button)findViewById(R.id.btnTestAlarm);
|
||||
enableSwitch = (Switch)findViewById(R.id.switch1);
|
||||
removeNotiSwitch = (Switch)findViewById(R.id.switch2);
|
||||
vibrateSwitch = (Switch)findViewById(R.id.switch3);
|
||||
swEnableService = (Switch)findViewById(R.id.switch1);
|
||||
swRemoveNotification = (Switch)findViewById(R.id.switch2);
|
||||
swVibrate = (Switch)findViewById(R.id.switch3);
|
||||
|
||||
settings = getApplicationContext().getSharedPreferences("settings", 0);
|
||||
editor = settings.edit();
|
||||
@ -42,21 +36,21 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
btnTest.setOnClickListener(onClickListener);
|
||||
|
||||
enableSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
swEnableService.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
editor.putBoolean("enable", isChecked);
|
||||
editor.apply();
|
||||
}
|
||||
});
|
||||
|
||||
removeNotiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
swRemoveNotification.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
editor.putBoolean("removeNotification", isChecked);
|
||||
editor.apply();
|
||||
}
|
||||
});
|
||||
|
||||
vibrateSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
swVibrate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
editor.putBoolean("vibrate", isChecked);
|
||||
editor.apply();
|
||||
@ -67,9 +61,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
enableSwitch.setChecked(settings.getBoolean("enable", false));
|
||||
removeNotiSwitch.setChecked(settings.getBoolean("removeNotification", false));
|
||||
vibrateSwitch.setChecked(settings.getBoolean("vibrate", false));
|
||||
swEnableService.setChecked(settings.getBoolean("enable", false));
|
||||
swRemoveNotification.setChecked(settings.getBoolean("removeNotification", false));
|
||||
swVibrate.setChecked(settings.getBoolean("vibrate", false));
|
||||
}
|
||||
|
||||
private View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
|
Reference in New Issue
Block a user