summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortom79 <tschneider.ac@gmail.com>2019-10-21 15:07:16 +0200
committertom79 <tschneider.ac@gmail.com>2019-10-21 15:07:16 +0200
commit3e2a6f057e5efc7b94d7d50d15395a43f591688f (patch)
treeb431bb33bbff9fbfccfcf24f021af323557b064b
parenta7598120c8e27820d751154b11bf808dea5b43ad (diff)
Fix delayed
-rw-r--r--app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java12
-rw-r--r--app/src/main/java/app/fedilab/android/asynctasks/PostStatusAsyncTask.java2
-rw-r--r--app/src/main/java/app/fedilab/android/client/API.java8
-rw-r--r--app/src/main/java/app/fedilab/android/drawers/AccountLiveAdapter.java2
-rw-r--r--app/src/main/java/app/fedilab/android/drawers/ArtListAdapter.java2
-rw-r--r--app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java8
-rw-r--r--app/src/main/java/app/fedilab/android/helper/Helper.java5
-rw-r--r--app/src/main/java/app/fedilab/android/services/LiveNotificationDelayedService.java82
-rw-r--r--app/src/main/java/app/fedilab/android/services/LiveNotificationService.java78
-rw-r--r--app/src/main/java/app/fedilab/android/services/RestartLiveNotificationReceiver.java8
-rw-r--r--app/src/main/java/app/fedilab/android/services/StopDelayedNotificationReceiver.java41
-rw-r--r--app/src/main/java/app/fedilab/android/services/StopLiveNotificationReceiver.java3
12 files changed, 139 insertions, 112 deletions
diff --git a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
index 8e49785d1..d2a62e286 100644
--- a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
@@ -17,8 +17,6 @@ package app.fedilab.android.activities;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
-import android.app.ActivityManager;
-import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -59,9 +57,9 @@ import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SearchView;
-import androidx.appcompat.widget.SwitchCompat;
import androidx.appcompat.widget.Toolbar;
+import android.util.Log;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -69,14 +67,12 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
-import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
-import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@@ -124,10 +120,8 @@ import app.fedilab.android.helper.MenuFloating;
import app.fedilab.android.services.BackupStatusService;
import app.fedilab.android.services.LiveNotificationDelayedService;
import app.fedilab.android.services.LiveNotificationService;
-import app.fedilab.android.services.StopLiveNotificationReceiver;
import app.fedilab.android.sqlite.AccountDAO;
import app.fedilab.android.sqlite.Sqlite;
-import app.fedilab.android.sqlite.StatusCacheDAO;
import app.fedilab.android.sqlite.TempMuteDAO;
import app.fedilab.android.sqlite.TimelineCacheDAO;
import app.fedilab.android.sqlite.TimelinesDAO;
@@ -154,9 +148,6 @@ import me.leolin.shortcutbadger.ShortcutBadger;
import static app.fedilab.android.asynctasks.ManageFiltersAsyncTask.action.GET_ALL_FILTER;
import static app.fedilab.android.helper.Helper.changeDrawableColor;
-import static app.fedilab.android.sqlite.StatusCacheDAO.ARCHIVE_CACHE;
-import static app.fedilab.android.sqlite.StatusCacheDAO.BOOKMARK_CACHE;
-import static app.fedilab.android.sqlite.StatusCacheDAO.NOTIFICATION_CACHE;
public abstract class BaseMainActivity extends BaseActivity
@@ -1357,7 +1348,6 @@ public abstract class BaseMainActivity extends BaseActivity
set_live_type.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener() {
@Override
public void onItemSelected(MaterialSpinner view, int position, long id, Object item) {
- sendBroadcast(new Intent(getApplicationContext(), StopLiveNotificationReceiver.class));
SharedPreferences.Editor editor = sharedpreferences.edit();
switch (position) {
case Helper.NOTIF_LIVE:
diff --git a/app/src/main/java/app/fedilab/android/asynctasks/PostStatusAsyncTask.java b/app/src/main/java/app/fedilab/android/asynctasks/PostStatusAsyncTask.java
index 4eea84e3a..bbc580426 100644
--- a/app/src/main/java/app/fedilab/android/asynctasks/PostStatusAsyncTask.java
+++ b/app/src/main/java/app/fedilab/android/asynctasks/PostStatusAsyncTask.java
@@ -15,7 +15,6 @@
package app.fedilab.android.asynctasks;
import android.content.Context;
-import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
@@ -29,7 +28,6 @@ import app.fedilab.android.client.Entities.Account;
import app.fedilab.android.client.Entities.Error;
import app.fedilab.android.client.GNUAPI;
import app.fedilab.android.helper.Helper;
-import app.fedilab.android.services.StopLiveNotificationReceiver;
import app.fedilab.android.sqlite.Sqlite;
import app.fedilab.android.sqlite.TagsCacheDAO;
import app.fedilab.android.R;
diff --git a/app/src/main/java/app/fedilab/android/client/API.java b/app/src/main/java/app/fedilab/android/client/API.java
index ea5c39641..9609e0e05 100644
--- a/app/src/main/java/app/fedilab/android/client/API.java
+++ b/app/src/main/java/app/fedilab/android/client/API.java
@@ -3539,13 +3539,7 @@ public class API {
notifications = parseNotificationResponse(new JSONArray(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (KeyManagementException e) {
- e.printStackTrace();
- } catch (JSONException e) {
+ } catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) {
e.printStackTrace();
}
if( apiResponse != null) {
diff --git a/app/src/main/java/app/fedilab/android/drawers/AccountLiveAdapter.java b/app/src/main/java/app/fedilab/android/drawers/AccountLiveAdapter.java
index 196be637f..a33095c9e 100644
--- a/app/src/main/java/app/fedilab/android/drawers/AccountLiveAdapter.java
+++ b/app/src/main/java/app/fedilab/android/drawers/AccountLiveAdapter.java
@@ -32,8 +32,6 @@ import app.fedilab.android.R;
import app.fedilab.android.client.Entities.Account;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.services.LiveNotificationDelayedService;
-import app.fedilab.android.services.LiveNotificationService;
-import app.fedilab.android.services.StopLiveNotificationReceiver;
import static android.content.Context.MODE_PRIVATE;
diff --git a/app/src/main/java/app/fedilab/android/drawers/ArtListAdapter.java b/app/src/main/java/app/fedilab/android/drawers/ArtListAdapter.java
index a3d1c5623..77ba3116f 100644
--- a/app/src/main/java/app/fedilab/android/drawers/ArtListAdapter.java
+++ b/app/src/main/java/app/fedilab/android/drawers/ArtListAdapter.java
@@ -211,7 +211,7 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
else if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
attachments.add(status.getMedia_attachments().get(0));
intent.putParcelableArrayListExtra("mediaArray", attachments);
- b.putInt("position", 0);
+ b.putInt("position", 1);
intent.putExtras(b);
context.startActivity(intent);
}
diff --git a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java
index 73dbd0237..1d182419a 100644
--- a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java
+++ b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java
@@ -97,7 +97,7 @@ import app.fedilab.android.helper.Helper;
import app.fedilab.android.interfaces.OnRetrieveRelationshipInterface;
import app.fedilab.android.interfaces.OnRetrieveRemoteAccountInterface;
import app.fedilab.android.services.LiveNotificationDelayedService;
-import app.fedilab.android.services.LiveNotificationService;
+import app.fedilab.android.services.StopDelayedNotificationReceiver;
import app.fedilab.android.services.StopLiveNotificationReceiver;
import app.fedilab.android.sqlite.AccountDAO;
import app.fedilab.android.sqlite.MainMenuDAO;
@@ -1278,7 +1278,6 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (count2 > 0) {
- context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
SharedPreferences.Editor editor = sharedpreferences.edit();
switch (position) {
case Helper.NOTIF_LIVE:
@@ -1286,17 +1285,22 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
live_notif_per_account.setVisibility(View.VISIBLE);
editor.apply();
+ context.sendBroadcast(new Intent(context, StopDelayedNotificationReceiver.class));
break;
case Helper.NOTIF_DELAYED:
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, true);
live_notif_per_account.setVisibility(View.VISIBLE);
+ context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
editor.apply();
break;
case Helper.NOTIF_NONE:
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
live_notif_per_account.setVisibility(View.GONE);
+ context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
+ context.sendBroadcast(new Intent(context, StopDelayedNotificationReceiver.class));
+
editor.apply();
break;
}
diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java
index 705bd84b3..4a2c9eaf0 100644
--- a/app/src/main/java/app/fedilab/android/helper/Helper.java
+++ b/app/src/main/java/app/fedilab/android/helper/Helper.java
@@ -214,12 +214,9 @@ import app.fedilab.android.client.Entities.RemoteInstance;
import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.Tag;
import app.fedilab.android.client.Entities.TagTimeline;
-import app.fedilab.android.client.Entities.Version;
import app.fedilab.android.client.Tls12SocketFactory;
-import app.fedilab.android.fragments.ContentSettingsFragment;
import app.fedilab.android.services.LiveNotificationDelayedService;
import app.fedilab.android.services.LiveNotificationService;
-import app.fedilab.android.services.StopLiveNotificationReceiver;
import app.fedilab.android.sqlite.MainMenuDAO;
import app.fedilab.android.sqlite.StatusCacheDAO;
import app.fedilab.android.sqlite.TimelineCacheDAO;
@@ -4961,8 +4958,8 @@ public class Helper {
}
public static HashMap<String, Integer> sleeps = new HashMap<>();
+
public static void startSreaming(Context context) {
- context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
int liveNotifications = Helper.liveNotifType(context);
switch (liveNotifications){
case Helper.NOTIF_LIVE:
diff --git a/app/src/main/java/app/fedilab/android/services/LiveNotificationDelayedService.java b/app/src/main/java/app/fedilab/android/services/LiveNotificationDelayedService.java
index f4e0f2771..95aceb536 100644
--- a/app/src/main/java/app/fedilab/android/services/LiveNotificationDelayedService.java
+++ b/app/src/main/java/app/fedilab/android/services/LiveNotificationDelayedService.java
@@ -89,59 +89,61 @@ public class LiveNotificationDelayedService extends Service {
public void onCreate() {
super.onCreate();
-
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
-
if (intent == null || intent.getBooleanExtra("stop", false)) {
totalAccount = 0;
+ if (Build.VERSION.SDK_INT >= 26) {
+ stopForeground(true);
+ }
stopSelf();
- }
- if (Build.VERSION.SDK_INT >= 26) {
- channel = new NotificationChannel(CHANNEL_ID,
- "Live notifications",
- NotificationManager.IMPORTANCE_DEFAULT);
+ }else{
+ if (Build.VERSION.SDK_INT >= 26) {
+ channel = new NotificationChannel(CHANNEL_ID,
+ "Live notifications",
+ NotificationManager.IMPORTANCE_DEFAULT);
- ((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
- SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
- totalAccount = 0;
- for (Account account : accountStreams) {
- if (account.getSocial() == null || account.getSocial().equals("MASTODON") || account.getSocial().equals("PLEROMA") || account.getSocial().equals("PIXELFED")) {
- final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
- boolean allowStream = sharedpreferences.getBoolean(Helper.SET_ALLOW_STREAM + account.getId() + account.getInstance(), true);
- if (allowStream) {
- totalAccount++;
+ ((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
+ SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
+ List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
+ totalAccount = 0;
+ for (Account account : accountStreams) {
+ if (account.getSocial() == null || account.getSocial().equals("MASTODON") || account.getSocial().equals("PLEROMA") || account.getSocial().equals("PIXELFED")) {
+ final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+ boolean allowStream = sharedpreferences.getBoolean(Helper.SET_ALLOW_STREAM + account.getId() + account.getInstance(), true);
+ if (allowStream) {
+ totalAccount++;
+ }
}
}
+
}
+ if( totalAccount > 0) {
+ Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
+ PendingIntent pendingIntent = PendingIntent.getActivity(
+ getApplicationContext(),
+ 0,
+ myIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+
+ android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
+ .setShowWhen(false)
+ .setContentIntent(pendingIntent)
+ .setContentTitle(getString(R.string.top_notification))
+ .setSmallIcon(R.drawable.fedilab_notification_icon)
+ .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
+ startForeground(1, notification);
+ }else{
+ stopSelf();
+ }
+ startStream();
}
if( totalAccount > 0) {
- Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
- PendingIntent pendingIntent = PendingIntent.getActivity(
- getApplicationContext(),
- 0,
- myIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
-
- android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
- .setShowWhen(false)
- .setContentIntent(pendingIntent)
- .setContentTitle(getString(R.string.top_notification))
- .setSmallIcon(R.drawable.fedilab_notification_icon)
- .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
-
- startForeground(1, notification);
- }else{
- stopSelf();
- }
- startStream();
- if( totalAccount > 0) {
return START_STICKY;
}
return START_NOT_STICKY;
@@ -236,8 +238,10 @@ public class LiveNotificationDelayedService extends Service {
if( since_ids.containsKey(key) ){
last_notifid = since_ids.get(key);
}
-
- apiResponse = api.getNotificationsSince(DisplayNotificationsFragment.Type.ALL, last_notifid, false);
+ apiResponse = null;
+ try {
+ apiResponse = api.getNotificationsSince(DisplayNotificationsFragment.Type.ALL, last_notifid, false);
+ }catch (Exception ignored){}
if( apiResponse != null && apiResponse.getNotifications() != null && apiResponse.getNotifications().size() > 0){
since_ids.put(key, apiResponse.getNotifications().get(0).getId());
diff --git a/app/src/main/java/app/fedilab/android/services/LiveNotificationService.java b/app/src/main/java/app/fedilab/android/services/LiveNotificationService.java
index 96c667073..0c824faca 100644
--- a/app/src/main/java/app/fedilab/android/services/LiveNotificationService.java
+++ b/app/src/main/java/app/fedilab/android/services/LiveNotificationService.java
@@ -114,43 +114,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
networkStateReceiver = new NetworkStateReceiver();
networkStateReceiver.addListener(this);
registerReceiver(networkStateReceiver, new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION));
- SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
-
- if (Build.VERSION.SDK_INT >= 26) {
- channel = new NotificationChannel(CHANNEL_ID,
- "Live notifications",
- NotificationManager.IMPORTANCE_DEFAULT);
- ((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
- SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
- totalAccount = 0;
- for (Account account : accountStreams) {
- if (account.getSocial() == null || account.getSocial().equals("MASTODON") || account.getSocial().equals("PLEROMA")) {
- boolean allowStream = sharedpreferences.getBoolean(Helper.SET_ALLOW_STREAM + account.getId() + account.getInstance(), true);
- if (allowStream) {
- totalAccount++;
- }
- }
- }
- }
- if( totalAccount > 0) {
- Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
- PendingIntent pendingIntent = PendingIntent.getActivity(
- getApplicationContext(),
- 0,
- myIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
- .setContentTitle(getString(R.string.top_notification))
- .setContentIntent(pendingIntent)
- .setSmallIcon(getNotificationIcon(getApplicationContext()))
- .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
-
- startForeground(1, notification);
- }else{
- stopSelf();
- }
}
private void startStream() {
@@ -175,7 +139,47 @@ public class LiveNotificationService extends Service implements NetworkStateRece
if (intent == null || intent.getBooleanExtra("stop", false)) {
totalAccount = 0;
- stopSelf();
+ if (Build.VERSION.SDK_INT >= 26) {
+ stopForeground(true);
+ }
+ }else{
+ SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+
+ if (Build.VERSION.SDK_INT >= 26) {
+ channel = new NotificationChannel(CHANNEL_ID,
+ "Live notifications",
+ NotificationManager.IMPORTANCE_DEFAULT);
+
+ ((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
+ SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
+ List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
+ totalAccount = 0;
+ for (Account account : accountStreams) {
+ if (account.getSocial() == null || account.getSocial().equals("MASTODON") || account.getSocial().equals("PLEROMA")) {
+ boolean allowStream = sharedpreferences.getBoolean(Helper.SET_ALLOW_STREAM + account.getId() + account.getInstance(), true);
+ if (allowStream) {
+ totalAccount++;
+ }
+ }
+ }
+ }
+ if( totalAccount > 0) {
+ Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
+ PendingIntent pendingIntent = PendingIntent.getActivity(
+ getApplicationContext(),
+ 0,
+ myIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
+ .setContentTitle(getString(R.string.top_notification))
+ .setContentIntent(pendingIntent)
+ .setSmallIcon(getNotificationIcon(getApplicationContext()))
+ .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();
+
+ startForeground(1, notification);
+ }else{
+ stopSelf();
+ }
}
if( totalAccount > 0) {
return START_STICKY;
diff --git a/app/src/main/java/app/fedilab/android/services/RestartLiveNotificationReceiver.java b/app/src/main/java/app/fedilab/android/services/RestartLiveNotificationReceiver.java
index 7a4513517..fb738687f 100644
--- a/app/src/main/java/app/fedilab/android/services/RestartLiveNotificationReceiver.java
+++ b/app/src/main/java/app/fedilab/android/services/RestartLiveNotificationReceiver.java
@@ -33,16 +33,14 @@ public class RestartLiveNotificationReceiver extends BroadcastReceiver {
@SuppressLint("UnsafeProtectedBroadcastReceiver")
@Override
public void onReceive(Context context, Intent intent) {
- SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
- boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
- boolean delayedNotifications = sharedpreferences.getBoolean(Helper.SET_DELAYED_NOTIFICATIONS, true);
- if (delayedNotifications) {
+ int type = Helper.liveNotifType(context);
+ if ( type == Helper.NOTIF_DELAYED) {
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationDelayedService.class);
try {
context.startService(streamingServiceIntent);
} catch (Exception ignored) {
}
- }else if (liveNotifications) {
+ }else if (type == Helper.NOTIF_LIVE) {
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationService.class);
try {
context.startService(streamingServiceIntent);
diff --git a/app/src/main/java/app/fedilab/android/services/StopDelayedNotificationReceiver.java b/app/src/main/java/app/fedilab/android/services/StopDelayedNotificationReceiver.java
new file mode 100644
index 000000000..800456da7
--- /dev/null
+++ b/app/src/main/java/app/fedilab/android/services/StopDelayedNotificationReceiver.java
@@ -0,0 +1,41 @@
+package app.fedilab.android.services;
+/* Copyright 2019 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see <http://www.gnu.org/licenses>. */
+
+import android.annotation.SuppressLint;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+
+/**
+ * Created by Thomas on 18/10/2019.
+ * BroadcastReceiver for restarting delayed notification service
+ */
+
+public class StopDelayedNotificationReceiver extends BroadcastReceiver {
+
+ @SuppressLint("UnsafeProtectedBroadcastReceiver")
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationDelayedService.class);
+ streamingServiceIntent.putExtra("stop", true);
+ try {
+ context.startService(streamingServiceIntent);
+ } catch (Exception ignored) {
+ }
+ }
+
+} \ No newline at end of file
diff --git a/app/src/main/java/app/fedilab/android/services/StopLiveNotificationReceiver.java b/app/src/main/java/app/fedilab/android/services/StopLiveNotificationReceiver.java
index 083bb4ff7..3e837fe3c 100644
--- a/app/src/main/java/app/fedilab/android/services/StopLiveNotificationReceiver.java
+++ b/app/src/main/java/app/fedilab/android/services/StopLiveNotificationReceiver.java
@@ -34,8 +34,7 @@ public class StopLiveNotificationReceiver extends BroadcastReceiver {
streamingServiceIntent.putExtra("stop", true);
try {
context.startService(streamingServiceIntent);
- } catch (Exception ignored) {
- }
+ } catch (Exception ignored) { ignored.printStackTrace();}
}
} \ No newline at end of file