diff --git a/app/src/main/java/app/fedilab/android/mastodon/services/PushServiceImpl.java b/app/src/main/java/app/fedilab/android/mastodon/services/PushServiceImpl.java index a028ac06..34633fc7 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/services/PushServiceImpl.java +++ b/app/src/main/java/app/fedilab/android/mastodon/services/PushServiceImpl.java @@ -1,22 +1,14 @@ package app.fedilab.android.mastodon.services; -import static app.fedilab.android.mastodon.helper.Helper.TAG; - - -import android.content.SharedPreferences; - +import android.content.Context; import androidx.annotation.NonNull; -import androidx.preference.PreferenceManager; - import org.unifiedpush.android.connector.FailedReason; import org.unifiedpush.android.connector.PushService; import org.unifiedpush.android.connector.data.PushEndpoint; import org.unifiedpush.android.connector.data.PushMessage; -import app.fedilab.android.R; - import app.fedilab.android.mastodon.helper.NotificationsHelper; import app.fedilab.android.mastodon.helper.PushNotifications; @@ -49,17 +41,11 @@ public class PushServiceImpl extends PushService { @Override public void onNewEndpoint(@NonNull PushEndpoint pushEndpoint, @NonNull String slug) { - if (getApplicationContext() != null) { + Context context = getApplicationContext(); + if (context != null) { synchronized (this) { - SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); - String storedEnpoint = sharedpreferences.getString(getApplicationContext().getString(R.string.SET_STORED_ENDPOINT) + slug, null); - if (storedEnpoint == null || !storedEnpoint.equals(pushEndpoint.getUrl())) { - PushNotifications - .registerPushNotifications(getApplicationContext(), pushEndpoint, slug); - SharedPreferences.Editor editor = sharedpreferences.edit(); - editor.putString(getApplicationContext().getString(R.string.SET_STORED_ENDPOINT) + slug, pushEndpoint.getUrl()); - editor.commit(); - } + PushNotifications + .registerPushNotifications(context, pushEndpoint, slug); } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 63f0a810..08a64db8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1169,7 +1169,6 @@ lingva.ml SET_TRANSLATOR_DOMAIN SET_TRANSLATOR - SET_STORED_ENDPOINT SET_TRANSLATOR_VERSION SET_TRANSLATOR_API_KEY