From 86c9023f80bfbda5b557d65eaf2edeeb828c0435 Mon Sep 17 00:00:00 2001 From: jacques Date: Fri, 11 Sep 2020 21:42:11 +0200 Subject: [PATCH] Remove unused files --- .../foucry/pilldroid/NotificationHelper.java | 60 ---------- .../pilldroid/NotificationPublisher.java | 106 ------------------ 2 files changed, 166 deletions(-) delete mode 100644 app/src/main/java/net/foucry/pilldroid/NotificationHelper.java delete mode 100644 app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java diff --git a/app/src/main/java/net/foucry/pilldroid/NotificationHelper.java b/app/src/main/java/net/foucry/pilldroid/NotificationHelper.java deleted file mode 100644 index 41ea026..0000000 --- a/app/src/main/java/net/foucry/pilldroid/NotificationHelper.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.foucry.pilldroid; - -import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; -import android.content.Context; -import android.content.ContextWrapper; -import android.graphics.Color; -import android.os.Build; - -/** - * Created by jfoucry on 6/23/16. - * Publish notification - */ - - -class NotificationHelper extends ContextWrapper { - - private static final String TAG = NotificationHelper.class.getName(); - private NotificationManager notificationManager; - public final String CHANNEL_ID ="net.foucry.pilldroid"; - public final String CHANNEL_ID_NAME = getString(R.string.app_name); - - public NotificationHelper(Context base) { - super(base); - createChannels(); - } - - private void createChannels() { - - String description = getString(R.string.channel_description); - NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_ID_NAME, - NotificationManager.IMPORTANCE_DEFAULT); - channel.setDescription(description); - channel.setLightColor(Color.RED); - channel.enableLights(true); - channel.setShowBadge(true); - channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); - - getManager().createNotificationChannel(channel); - } - public Notification.Builder getNotification(String title, String body) { - return new Notification.Builder(getApplicationContext(), CHANNEL_ID) - .setContentTitle(title) - .setContentText(body) - .setSmallIcon(R.drawable.ic_pill) - .setAutoCancel(true); - } - - public void notify(int id, Notification.Builder notification) { - getManager().notify(id, notification.build()); - } - - private NotificationManager getManager() { - if(notificationManager == null) { - notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - } - return notificationManager; - } -} \ No newline at end of file diff --git a/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java b/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java deleted file mode 100644 index 72ccaf2..0000000 --- a/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java +++ /dev/null @@ -1,106 +0,0 @@ -package net.foucry.pilldroid; - -import android.app.NotificationChannel; -import android.app.NotificationManager; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.media.RingtoneManager; -import android.net.Uri; -import android.util.Log; - -import androidx.core.app.NotificationCompat; -import androidx.core.app.NotificationManagerCompat; - -/** - * Created by jfoucry on 6/23/16. - * Publish notification - */ - -/* TODO: must be remove - -public class NotificationPublisher extends BroadcastReceiver { - - private static final String TAG = NotificationPublisher.class.getName(); - - public static String NOTIFICATION_ID = "notification_id"; - public static String KEY_MESSAGE = "key_message"; - public static String KEY_TITLE = "key_title"; - public static String KEY_EXPAND = "key_expand"; - public static String KEY_SOUND = "key_sound"; - public static String KEY_MULTIPLE = "key_multiple"; - public static String APP_NAME = "PillDroid"; - - /** - * onReceive notification - * @param Context context - * @param Intent intent - */ - @Override - public void onReceive(Context context, Intent intent) { - Log.d(TAG, "Receive notification"); - - int notificationId = intent.getIntExtra(NOTIFICATION_ID, 0); - String message = intent.getStringExtra(KEY_MESSAGE); - String title = intent.getStringExtra(KEY_TITLE); - boolean isEnabledExpand = intent.getBooleanExtra(KEY_EXPAND, false); - boolean isEnableSound = intent.getBooleanExtra(KEY_SOUND, false); - boolean isEnabledMultiple = intent.getBooleanExtra(KEY_MULTIPLE, false); - - String channel_id = createNotificationChannel(context); - NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channel_id) - .setSmallIcon(R.drawable.ic_pill) - .setContentTitle(context.getString(R.string.app_name)) - .setContentText(context.getString(R.string.notification_text)) - .setChannelId(APP_NAME) - .setStyle(new NotificationCompat.BigTextStyle() - .bigText(context.getString(R.string.notification_text))) - .setAutoCancel(true) - .setPriority(NotificationCompat.PRIORITY_DEFAULT); - - if (isEnableSound) { - Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); - builder.setSound(alarmSound); - } - - NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); - - // notificationId is a unique int for each notification that you must define - notificationManager.notify(notificationId, builder.build()); - } - - /** - * createNotificationChannelid for android API >= 28 - * @param Context context - * @return String channel_id - */ - public static String createNotificationChannel(Context context) { - - Log.d(TAG, "start create notification channel"); - // The id of the channel. - String channelId = "Channel_id"; - - // The user-visible name of the channel. - CharSequence channelName = context.getString(R.string.app_name); - // The user-visible description of the channel. - String channelDescription = "Pilldroid Alert"; - int channelImportance = NotificationManager.IMPORTANCE_DEFAULT; - // int channelLockscreenVisibility = Notification.; - - // Initializes NotificationChannel. - NotificationChannel notificationChannel = new NotificationChannel(channelId, channelName, - channelImportance); - notificationChannel.setDescription(channelDescription); - notificationChannel.enableVibration(true); - // notificationChannel.setLockscreenVisibility(channelLockscreenVisibility); - - // Adds NotificationChannel to system. Attempting to create an existing notification - // channel with its original values performs no operation, so it's safe to perform the - // below sequence. - NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - assert notificationManager != null; - notificationManager.createNotificationChannel(notificationChannel); - - return channelId; - } -} \ No newline at end of file