Commit 4466ef89 authored by axet's avatar axet 🍄

Merge branch 'smsgate-1.8.24'

parents d839eecf 23b68703
Pipeline #35751077 passed with stage
in 1 minute and 5 seconds
......@@ -7,9 +7,9 @@ android {
defaultConfig {
applicationId "com.github.axet.smsgate"
minSdkVersion 9
targetSdkVersion 23
versionCode 207
versionName "1.8.23"
targetSdkVersion 26
versionCode 208
versionName "1.8.24"
}
packagingOptions {
exclude 'META-INF/LICENSE'
......@@ -39,7 +39,7 @@ android {
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.github.axet:android-library:1.27.18' // implementation project(':android-library')
implementation 'com.github.axet:android-library:1.27.21' // implementation project(':android-library')
implementation 'com.android.support:design:25.3.1'
implementation 'com.intellij:annotations:12.0'
implementation 'com.beetstra.jutf7:jutf7:1.0.0'
......@@ -50,12 +50,12 @@ dependencies {
exclude group: 'org.apache.httpcomponents', module: 'httpcore'
}
implementation 'org.apache.james:apache-mime4j-core:0.7.2'
implementation 'jp.wasabeef:recyclerview-animators:2.2.3'
implementation 'jp.wasabeef:recyclerview-animators:2.2.3' // API11+
// implementation project(':android-firebase-fake') // implementation 'com.github.axet:firebase-fake:0.0.4'
implementation 'com.google.firebase:firebase-database:11.0.0'
implementation 'com.google.firebase:firebase-storage:11.0.0'
implementation 'com.google.firebase:firebase-auth:11.0.0'
implementation 'com.google.firebase:firebase-messaging:11.0.0'
implementation 'com.google.firebase:firebase-database:9.8.0'
implementation 'com.google.firebase:firebase-storage:9.8.0'
implementation 'com.google.firebase:firebase-auth:9.8.0'
implementation 'com.google.firebase:firebase-messaging:9.8.0'
}
apply plugin: 'com.google.gms.google-services'
......@@ -32,35 +32,7 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-sdk tools:overrideLibrary="jp.wasabeef.recyclerview,
com.android.support.transition,
com.google.firebase.firebase_core,
com.google.firebase.database,
com.google.firebase.database.connection,
com.google.firebase.database.connection.license,
com.google.firebase.firebase.database.connection.license,
com.google.firebase.firebase.database.license,
com.google.firebase.messaging,
com.google.firebase.firebase.messaging.license,
com.google.firebase.iid,
com.google.firebase.firebase.iid.license,
com.google.firebase.storage,
com.google.firebase.firebase.storage.api.license,
com.google.firebase.firebase.storage.common.license,
com.google.firebase.firebase.common.license,
com.google.firebase,
com.google.firebase.auth.api,
com.google.firebase.firebase.auth.api.license,
com.google.firebase.measurement.license,
com.google.firebase.measurement.impl.license,
com.google.android.gms,
com.google.android.gms.common.license,
com.google.android.gms.base,
com.google.android.gms.base.license,
com.google.android.gms.tasks,
com.google.android.gms.tasks.license,
com.google.android.gms.measurement,
com.google.android.gms.measurement.impl" />
<uses-sdk tools:overrideLibrary="jp.wasabeef.recyclerview" />
<uses-feature
android:name="android.hardware.telephony"
......
......@@ -17,6 +17,8 @@ import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.internet.TextBody;
import com.github.axet.androidlibrary.crypto.Bitcoin;
import com.github.axet.androidlibrary.services.FileProvider;
import com.github.axet.androidlibrary.services.WifiKeepService;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.providers.SIM;
import com.github.axet.smsgate.services.FirebaseService;
import com.github.axet.smsgate.services.NotificationService;
......@@ -139,6 +141,8 @@ public class SMSApplication extends App {
keyPair.loadPub(pub);
}
}
WifiKeepService.DESCRIPTION = "WifiService";
WifiKeepService.ICON = R.drawable.ic_sms;
}
public void save() {
......
......@@ -11,6 +11,7 @@ import android.util.Log;
import com.github.axet.androidlibrary.app.AlarmManager;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.app.ScheduleSMS;
import com.github.axet.smsgate.app.ScheduleTime;
......@@ -24,6 +25,7 @@ import java.util.TreeSet;
public class ScheduleService extends Service implements SharedPreferences.OnSharedPreferenceChangeListener {
public static final String TAG = ScheduleService.class.getSimpleName();
public static int NOTIFICATION_ICON = 201;
// upcoming noticiation alarm action. triggers notification upcoming.
public static final String REGISTER = ScheduleService.class.getCanonicalName() + ".REGISTER";
......@@ -32,11 +34,12 @@ public class ScheduleService extends Service implements SharedPreferences.OnShar
List<ScheduleSMS> items;
OptimizationPreferenceCompat.ServiceReceiver receiver;
OptimizationPreferenceCompat.NotificationIcon icon;
public static void start(Context context) {
Intent intent = new Intent(context, ScheduleService.class);
intent.setAction(REGISTER);
context.startService(intent);
OptimizationPreferenceCompat.startService(context, intent);
}
@Override
......@@ -61,6 +64,11 @@ public class ScheduleService extends Service implements SharedPreferences.OnShar
}
};
icon = new OptimizationPreferenceCompat.NotificationIcon(this, NOTIFICATION_ICON, "status", "ScheduleService");
icon.icon = R.drawable.ic_sms;
icon.description = icon.text;
icon.onCreate();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
}
......@@ -71,6 +79,7 @@ public class ScheduleService extends Service implements SharedPreferences.OnShar
receiver.close();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.unregisterOnSharedPreferenceChangeListener(this);
icon.onDestroy();
}
@Override
......
......@@ -36,6 +36,7 @@ import com.fsck.k9.mail.internet.BinaryTempFileBody;
import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.store.imap.XOAuth2AuthenticationFailedException;
import com.github.axet.androidlibrary.app.AlarmManager;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.smsgate.R;
import com.squareup.otto.Produce;
import com.squareup.otto.Subscribe;
......@@ -83,8 +84,10 @@ import static com.zegoggles.smssync.service.state.SmsSyncState.FINISHED_BACKUP;
import static com.zegoggles.smssync.service.state.SmsSyncState.INITIAL;
public class SmsReplyService extends ServiceBase {
public static int NOTIFICATION_ICON = 202;
@Nullable
private static SmsReplyService service;
private SmsReplyService service;
@NotNull
private ReplyState mState = new ReplyState();
Handler handler;
......@@ -103,8 +106,7 @@ public class SmsReplyService extends ServiceBase {
@Override
public void messagesArrived(Folder folder, List<Message> list) {
final Intent intent1 = new Intent(service, SmsReplyService.class);
startService(intent1);
start(context);
}
@Override
......@@ -145,10 +147,11 @@ public class SmsReplyService extends ServiceBase {
Pusher pusher;
Thread thread;
TokenRefresher tokenRefresher;
OptimizationPreferenceCompat.NotificationIcon icon;
public static void start(Context context) {
Intent intent = new Intent(context, SmsReplyService.class);
context.startService(intent);
OptimizationPreferenceCompat.startService(context, intent);
scheduleReplyBackup(context);
}
......@@ -184,6 +187,11 @@ public class SmsReplyService extends ServiceBase {
service = this;
context = this;
icon = new OptimizationPreferenceCompat.NotificationIcon(this, NOTIFICATION_ICON, "status", "ReplyService");
icon.icon = R.drawable.ic_sms;
icon.description = icon.text;
icon.onCreate();
SmsBackupService.clearTempFiles(this);
BinaryTempFileBody.setTempDirectory(getCacheDir());
......@@ -203,6 +211,8 @@ public class SmsReplyService extends ServiceBase {
if (LOCAL_LOGV) Log.v(TAG, "SmsReplyService#onDestroy(state=" + getState() + ")");
service = null;
stop();
icon.onDestroy();
}
void connect() {
......@@ -311,7 +321,7 @@ public class SmsReplyService extends ServiceBase {
appLog(R.string.app_log_backup_requested, getString(backupType.resId));
// Only start a backup if there's no other operation going on at this time.
if (!isWorking() && !SmsReplyService.isServiceWorking()) {
if (!isWorking() && !isServiceWorking()) {
backup(backupType, intent.getBooleanExtra(Consts.KEY_SKIP_MESSAGES, false));
} else {
appLog(R.string.app_log_skip_backup_already_running);
......@@ -509,7 +519,7 @@ public class SmsReplyService extends ServiceBase {
return new Alarms(this);
}
public static boolean isServiceWorking() {
public boolean isServiceWorking() {
return service != null && service.isWorking();
}
......
......@@ -29,6 +29,7 @@ import android.util.Log;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.BinaryTempFileBody;
import com.github.axet.androidlibrary.app.AlarmManager;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.smsgate.R;
import com.squareup.otto.Produce;
import com.squareup.otto.Subscribe;
......@@ -68,11 +69,13 @@ import static com.zegoggles.smssync.service.state.SmsSyncState.FINISHED_BACKUP;
import static com.zegoggles.smssync.service.state.SmsSyncState.INITIAL;
public class SmsBackupService extends ServiceBase {
public static int NOTIFICATION_ICON = 203;
@Nullable
private static SmsBackupService service;
@NotNull
private BackupState mState = new BackupState();
Handler handler;
OptimizationPreferenceCompat.NotificationIcon icon;
public static void startIfEnabled(Context context) {
if (shouldSchedule(context)) {
......@@ -83,7 +86,7 @@ public class SmsBackupService extends ServiceBase {
public static void start(Context context) {
final Intent intent = new Intent(context, SmsBackupService.class);
intent.putExtra(BackupType.EXTRA, BackupType.REGULAR.name());
context.startService(intent);
OptimizationPreferenceCompat.startService(context, intent);
scheduleRegularBackup(context);
}
......@@ -94,7 +97,7 @@ public class SmsBackupService extends ServiceBase {
}
// start backup service
intent.putExtra(BackupType.EXTRA, BackupType.MANUAL.name());
context.startService(intent);
OptimizationPreferenceCompat.startService(context, intent);
scheduleRegularBackup(context);
}
......@@ -213,6 +216,11 @@ public class SmsBackupService extends ServiceBase {
BinaryTempFileBody.setTempDirectory(getCacheDir());
start();
icon = new OptimizationPreferenceCompat.NotificationIcon(this, NOTIFICATION_ICON, "status", "BackupService");
icon.icon = R.drawable.ic_sms;
icon.description = icon.text;
icon.onCreate();
}
@Override
......@@ -222,6 +230,7 @@ public class SmsBackupService extends ServiceBase {
getNotifier().cancel(BACKUP_ID);
service = null;
stop();
icon.onDestroy();
}
synchronized void start() {
......
# FCM messaging
Http POST request
```javascript
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to" : "/topics/foo-bar",
"priority" : "high",
"notification" : {
"body" : "This is a Firebase Cloud Messaging Topic Message!",
"title" : "FCM Message",
}
}
```
* https://firebase.google.com/docs/cloud-messaging/js/topic-messaging
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment