Browse Source

chore(android): disable sticky notification

pull/8/head
isra el 2 years ago
parent
commit
dd4e9f8038
  1. 12
      android/app/src/main/java/com/vernu/sms/activities/MainActivity.java
  2. 6
      android/app/src/main/java/com/vernu/sms/receivers/BootCompletedReceiver.java
  3. 16
      android/app/src/main/java/com/vernu/sms/services/StickyNotificationService.java

12
android/app/src/main/java/com/vernu/sms/activities/MainActivity.java

@ -90,7 +90,7 @@ public class MainActivity extends AppCompatActivity {
grantSMSPermissionBtn.setOnClickListener(this::handleRequestPermissions); grantSMSPermissionBtn.setOnClickListener(this::handleRequestPermissions);
} }
TextBeeUtils.startStickyNotificationService(mContext);
// TextBeeUtils.startStickyNotificationService(mContext);
copyDeviceIdImgBtn.setOnClickListener(view -> { copyDeviceIdImgBtn.setOnClickListener(view -> {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
@ -125,11 +125,11 @@ public class MainActivity extends AppCompatActivity {
SharedPreferenceHelper.setSharedPreferenceBoolean(mContext, AppConstants.SHARED_PREFS_GATEWAY_ENABLED_KEY, isCheked); SharedPreferenceHelper.setSharedPreferenceBoolean(mContext, AppConstants.SHARED_PREFS_GATEWAY_ENABLED_KEY, isCheked);
boolean enabled = Boolean.TRUE.equals(Objects.requireNonNull(response.body()).data.get("enabled")); boolean enabled = Boolean.TRUE.equals(Objects.requireNonNull(response.body()).data.get("enabled"));
compoundButton.setChecked(enabled); compoundButton.setChecked(enabled);
if (enabled) {
TextBeeUtils.startStickyNotificationService(mContext);
} else {
TextBeeUtils.stopStickyNotificationService(mContext);
}
// if (enabled) {
// TextBeeUtils.startStickyNotificationService(mContext);
// } else {
// TextBeeUtils.stopStickyNotificationService(mContext);
// }
compoundButton.setEnabled(true); compoundButton.setEnabled(true);
} }
@Override @Override

6
android/app/src/main/java/com/vernu/sms/receivers/BootCompletedReceiver.java

@ -13,9 +13,9 @@ public class BootCompletedReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
if(TextBeeUtils.isPermissionGranted(context, Manifest.permission.RECEIVE_SMS)){
TextBeeUtils.startStickyNotificationService(context);
}
// if(TextBeeUtils.isPermissionGranted(context, Manifest.permission.RECEIVE_SMS)){
// TextBeeUtils.startStickyNotificationService(context);
// }
} }
} }
} }

16
android/app/src/main/java/com/vernu/sms/services/StickyNotificationService.java

@ -33,13 +33,13 @@ public class StickyNotificationService extends Service {
Log.i(TAG, "Service Started"); Log.i(TAG, "Service Started");
IntentFilter filter = new IntentFilter();
filter.addAction(Telephony.Sms.Intents.SMS_RECEIVED_ACTION);
filter.addAction(android.telephony.TelephonyManager.ACTION_PHONE_STATE_CHANGED);
registerReceiver(receiver, filter);
Notification notification = createNotification();
startForeground(1, notification);
// IntentFilter filter = new IntentFilter();
// filter.addAction(Telephony.Sms.Intents.SMS_RECEIVED_ACTION);
// filter.addAction(android.telephony.TelephonyManager.ACTION_PHONE_STATE_CHANGED);
// registerReceiver(receiver, filter);
//
// Notification notification = createNotification();
// startForeground(1, notification);
} }
@ -54,7 +54,7 @@ public class StickyNotificationService extends Service {
super.onDestroy(); super.onDestroy();
// unregisterReceiver(receiver); // unregisterReceiver(receiver);
Log.i(TAG, "StickyNotificationService destroyed"); Log.i(TAG, "StickyNotificationService destroyed");
Toast.makeText(this, "Service destroyed", Toast.LENGTH_SHORT).show();
// Toast.makeText(this, "Service destroyed", Toast.LENGTH_SHORT).show();
} }
private Notification createNotification() { private Notification createNotification() {

Loading…
Cancel
Save