Skip to content

Commit

Permalink
Migrate to FCM, AndroidX, and newer Gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
eladnava committed Sep 16, 2020
1 parent 8491bb3 commit b03c9c8
Show file tree
Hide file tree
Showing 38 changed files with 368 additions and 380 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/captures
output.json

.idea/caches
.idea/codeStyles
.idea/workspace.xml
.idea/libraries
.idea/dictionaries
Expand Down
40 changes: 40 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

133 changes: 73 additions & 60 deletions app/app.iml

Large diffs are not rendered by default.

32 changes: 8 additions & 24 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,48 +1,32 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
dexOptions {
preDexLibraries = false
}

compileSdkVersion 26
useLibrary 'org.apache.http.legacy'
compileSdkVersion 28

defaultConfig {
applicationId "com.red.alert"
minSdkVersion 14
targetSdkVersion 26
minSdkVersion 16
targetSdkVersion 28
versionCode 10099
versionName "1.0.9.9"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

// Fixes "Duplicate files copied in APK" build bug
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}

dependencies {
// Pushy SDK
compile 'me.pushy:sdk:1.0.51'

// AppCompat v7 Dependency
compile 'com.android.support:appcompat-v7:26.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'

// Firebase Cloud Messaging
implementation "com.google.firebase:firebase-messaging:20.2.4"

// Google Play Services Dependencies
//noinspection GradleCompatible
Expand Down
40 changes: 40 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"project_info": {
"project_number": "23150228579",
"firebase_url": "https://redalert-api.firebaseio.com",
"project_id": "redalert-api",
"storage_bucket": "redalert-api.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:23150228579:android:44c53eddc1bb72f6",
"android_client_info": {
"package_name": "com.red.alert"
}
},
"oauth_client": [
{
"client_id": "23150228579-60doeebh24udmpb2t3aq7672c2a5edsd.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCoL_3SJ4Vlp7lP777Kp9pc1LIchdGM3og"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "23150228579-60doeebh24udmpb2t3aq7672c2a5edsd.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
55 changes: 5 additions & 50 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@

<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />

<!-- Google Cloud Messaging -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

<!-- GCM App-Specific Declaration -->
<permission
android:name="com.red.alert.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>

<!-- Google Play Services Feature Declarations -->
<uses-feature
android:name="android.hardware.location"
Expand Down Expand Up @@ -130,54 +122,18 @@
</intent-filter>
</receiver>

<!-- App Updated Receiver -->
<receiver android:name=".receivers.UpdateReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<data android:path="com.red.alert" android:scheme="package"/>
</intent-filter>
</receiver>

<!-- Location Polling Service -->
<service android:name=".services.location.LocationService"/>

<!-- GCM Declarations -->

<!-- Internal GCM Receiver -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.red.alert"/>
</intent-filter>
</receiver>

<!-- GCM Push Receiver -->
<!-- FCM Push Receiver -->
<service
android:name=".services.gcm.GCMPushReceiverService"
android:name=".services.fcm.FirebaseService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<!-- GCM InstanceID Service -->
<service
android:name=".services.gcm.GCMInstanceIDService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>

<!-- GCM Registration Service -->
<service android:name=".services.gcm.GCMRegistrationService" android:exported="false"></service>

<!-- End GCM Declarations -->

<!-- Pushy Declarations -->

<!-- Pushy Notification Receiver -->
Expand All @@ -193,8 +149,7 @@
<!-- Do not modify - internal BroadcastReceiver that restarts the listener service -->
<receiver android:name="me.pushy.sdk.receivers.PushyUpdateReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>

Expand All @@ -214,7 +169,7 @@
<!-- Do not modify - internal service -->
<service android:name="me.pushy.sdk.services.PushyJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true" />
android:exported="false" />

<!-- End Pushy Declarations -->
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import java.util.HashMap;
import java.util.Map;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/red/alert/activities/AlertPopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/red/alert/activities/AlertView.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.ActivityCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.view.MenuItemCompat;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;

Expand Down Expand Up @@ -164,7 +164,7 @@ private String getShareMessage() {
String cityName = LocationData.getLocalizedCityName(mAlertCity, this);

// Construct share message
return getString(R.string.alertSoundedAt) + cityName + " (" + LocationData.getLocalizedZoneByCityName(mAlertCity, this) + ") " + getString(R.string.atTime) + " " + mAlertDateString + " " + getString(R.string.alertSentVia);
return getString(R.string.alertSoundedAt) + " " + cityName + " (" + LocationData.getLocalizedZoneByCityName(mAlertCity, this) + ") " + getString(R.string.atTime) + " " + mAlertDateString + " " + getString(R.string.alertSentVia);
}

void initializeShareButton(Menu OptionsMenu) {
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/com/red/alert/activities/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import androidx.core.view.MenuItemCompat;
import androidx.appcompat.app.AppCompatActivity;


import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -26,13 +28,11 @@
import com.red.alert.config.Integrations;
import com.red.alert.config.Logging;
import com.red.alert.config.RecentAlerts;
import com.red.alert.logic.alerts.AlertLogic;
import com.red.alert.logic.communication.broadcasts.SettingsEvents;
import com.red.alert.logic.communication.intents.AlertViewParameters;
import com.red.alert.logic.communication.intents.MainActivityParameters;
import com.red.alert.logic.integration.BluetoothIntegration;
import com.red.alert.logic.notifications.RocketNotifications;
import com.red.alert.logic.push.GCMRegistration;
import com.red.alert.logic.push.FCMRegistration;
import com.red.alert.logic.push.PushyRegistration;
import com.red.alert.logic.services.ServiceManager;
import com.red.alert.logic.settings.AppPreferences;
Expand Down Expand Up @@ -270,8 +270,8 @@ protected void onPause() {
}

void showImportantDialogs() {
// Do we need to register for GCM or Pushy?
if (!GCMRegistration.isRegistered(this) || !PushyRegistration.isRegistered(this)) {
// Do we need to register for FCM or Pushy?
if (!FCMRegistration.isRegistered(this) || !PushyRegistration.isRegistered(this)) {
// Register async
new RegisterPushAsync().execute();

Expand Down Expand Up @@ -625,8 +625,8 @@ protected Exception doInBackground(Integer... Parameter) {
// Make sure we have Google Play Services installed
if (GooglePlayServices.isAvailable(Main.this)) {
try {
// Register for GCM push notifications
GCMRegistration.registerForPushNotifications(Main.this);
// Register for FCM push notifications
FCMRegistration.registerForPushNotifications(Main.this);
}
catch (Exception exc) {
error = exc;
Expand Down Expand Up @@ -694,4 +694,4 @@ protected void onPostExecute(String newVersion) {
}
}
}
}
}
Loading

0 comments on commit b03c9c8

Please sign in to comment.