diff --git a/app/build.gradle b/app/build.gradle index d557b510..85a9a832 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,3 @@ -import com.google.gms.googleservices.GoogleServicesPlugin - apply plugin: 'com.android.application' android { @@ -73,9 +71,6 @@ dependencies { implementation 'com.github.bumptech.glide:glide:4.11.0' implementation 'com.squareup.okhttp3:okhttp:4.4.1' - implementation 'com.google.firebase:firebase-analytics:17.4.2' - implementation 'com.google.android.gms:play-services-base:17.2.1' - implementation 'com.google.firebase:firebase-messaging:20.2.0' implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.android.exoplayer:exoplayer-core:2.11.4' @@ -105,5 +100,3 @@ dependencies { __64bitImplementation 'io.lbry:lbrysdk64:0.76.0' } -apply plugin: 'com.google.gms.google-services' -GoogleServicesPlugin.config.disableVersionCheck = true diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 28eca8a7..80623d9e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,16 +25,6 @@ - - - - - \ No newline at end of file + diff --git a/app/src/main/java/io/lbry/browser/LbrynetMessagingService.java b/app/src/main/java/io/lbry/browser/LbrynetMessagingService.java deleted file mode 100644 index 62536467..00000000 --- a/app/src/main/java/io/lbry/browser/LbrynetMessagingService.java +++ /dev/null @@ -1,161 +0,0 @@ -package io.lbry.browser; - -import android.app.NotificationChannel; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.media.RingtoneManager; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import androidx.core.app.NotificationCompat; -import androidx.core.content.ContextCompat; -import androidx.preference.PreferenceManager; - -import android.util.Log; - -import com.google.firebase.analytics.FirebaseAnalytics; -import com.google.firebase.messaging.FirebaseMessagingService; -import com.google.firebase.messaging.RemoteMessage; - -import io.lbry.browser.utils.LbryAnalytics; -import io.lbry.lbrysdk.LbrynetService; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class LbrynetMessagingService extends FirebaseMessagingService { - - private static final String TAG = "LbrynetMessagingService"; - private static final String NOTIFICATION_CHANNEL_ID = "io.lbry.browser.LBRY_ENGAGEMENT_CHANNEL"; - private static final String TYPE_SUBSCRIPTION = "subscription"; - private static final String TYPE_REWARD = "reward"; - private static final String TYPE_INTERESTS = "interests"; - private static final String TYPE_CREATOR = "creator"; - private FirebaseAnalytics firebaseAnalytics; - - @Override - public void onMessageReceived(RemoteMessage remoteMessage) { - if (firebaseAnalytics == null) { - firebaseAnalytics = FirebaseAnalytics.getInstance(this); - } - - Map payload = remoteMessage.getData(); - if (payload != null) { - String type = payload.get("type"); - String url = payload.get("target"); - String title = payload.get("title"); - String body = payload.get("body"); - String name = payload.get("name"); // notification name - String contentTitle = payload.get("content_title"); - String channelUrl = payload.get("channel_url"); - //String publishTime = payload.get("publish_time"); - String publishTime = null; - - if (type != null && getEnabledTypes().indexOf(type) > -1 && body != null && body.trim().length() > 0) { - // only log the receive event for valid notifications received - if (firebaseAnalytics != null) { - Bundle bundle = new Bundle(); - bundle.putString("name", name); - firebaseAnalytics.logEvent(LbryAnalytics.EVENT_LBRY_NOTIFICATION_RECEIVE, bundle); - } - - sendNotification(title, body, type, url, name, contentTitle, channelUrl, publishTime); - } - } - } - - @Override - public void onNewToken(String token) { - Log.d(TAG, "Refreshed token: " + token); - - // If you want to send messages to this application instance or - // manage this apps subscriptions on the server side, send the - // Instance ID token to your app server. - sendRegistrationToServer(token); - } - - /** - * Persist token to third-party servers. - * - * Modify this method to associate the user's FCM InstanceID token with any server-side account - * maintained by your application. - * - * @param token The new token. - */ - private void sendRegistrationToServer(String token) { - // TODO: Implement this method to send token to your app server. - } - - /** - * Create and show a simple notification containing the received FCM message. - * - * @param messageBody FCM message body received. - */ - private void sendNotification(String title, String messageBody, String type, String url, String name, - String contentTitle, String channelUrl, String publishTime) { - //Intent intent = new Intent(this, MainActivity.class); - //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - if (url == null) { - if (TYPE_REWARD.equals(type)) { - url = "lbry://?rewards"; - } else { - // default to home page - url = "lbry://?discover"; - } - } - - Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); - launchIntent.putExtra("notification_name", name); - launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); - PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, launchIntent, PendingIntent.FLAG_ONE_SHOT); - - Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); - NotificationCompat.Builder notificationBuilder = - new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID) - .setColor(ContextCompat.getColor(this, R.color.lbryGreen)) - .setSmallIcon(R.drawable.ic_lbry) - .setContentTitle(title) - .setContentText(messageBody) - .setAutoCancel(true) - .setSound(defaultSoundUri) - .setContentIntent(pendingIntent); - - NotificationManager notificationManager = - (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - - // Since android Oreo notification channel is needed. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationChannel channel = new NotificationChannel( - NOTIFICATION_CHANNEL_ID, "LBRY Engagement", NotificationManager.IMPORTANCE_DEFAULT); - notificationManager.createNotificationChannel(channel); - } - - notificationManager.notify(3, notificationBuilder.build()); - } - - public List getEnabledTypes() { - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); - List enabledTypes = new ArrayList(); - - if (sp.getBoolean(MainActivity.PREFERENCE_KEY_NOTIFICATION_SUBSCRIPTIONS, true)) { - enabledTypes.add(TYPE_SUBSCRIPTION); - } - if (sp.getBoolean(MainActivity.PREFERENCE_KEY_NOTIFICATION_REWARDS, true)) { - enabledTypes.add(TYPE_REWARD); - } - if (sp.getBoolean(MainActivity.PREFERENCE_KEY_NOTIFICATION_CONTENT_INTERESTS, true)) { - enabledTypes.add(TYPE_INTERESTS); - } - if (sp.getBoolean(MainActivity.PREFERENCE_KEY_NOTIFICATION_CREATOR, true)) { - enabledTypes.add(TYPE_CREATOR); - } - - return enabledTypes; - } -} \ No newline at end of file diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java index a31597de..53d9f2ed 100644 --- a/app/src/main/java/io/lbry/browser/MainActivity.java +++ b/app/src/main/java/io/lbry/browser/MainActivity.java @@ -60,8 +60,6 @@ import com.google.android.gms.cast.framework.CastContext; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.android.material.snackbar.Snackbar; -import com.google.firebase.iid.FirebaseInstanceId; -import com.google.firebase.iid.InstanceIdResult; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -219,9 +217,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener @Setter private BackPressInterceptor backPressInterceptor; - @Getter - private String firebaseMessagingToken; - private Map openNavFragments; private static final Map fragmentClassNavIdMap = new HashMap<>(); static { @@ -378,20 +373,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener initSpecialRouteMap(); LbryAnalytics.init(this); - try { - FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener() { - @Override - public void onComplete(Task task) { - if (!task.isSuccessful()) { - return; - } - // Get new Instance ID token - firebaseMessagingToken = task.getResult().getToken(); - } - }); - } catch (IllegalStateException ex) { - // pass - } super.onCreate(savedInstanceState); dbHelper = new DatabaseHelper(this);