Commit 1356b90d authored by axet's avatar axet 🍄

Merge branch 'smsgate-1.9.2'

parents d2b66c68 fae9acfe
Pipeline #35888060 passed with stage
in 27 seconds
......@@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.smsgate"
minSdkVersion 9
targetSdkVersion 26
versionCode 210
versionName "1.9.1"
versionCode 211
versionName "1.9.2"
}
packagingOptions {
exclude 'META-INF/LICENSE'
......
......@@ -10,6 +10,7 @@ import android.os.Build;
import android.os.Handler;
import android.support.v7.preference.PreferenceManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
......@@ -134,8 +135,8 @@ public class Storage extends com.github.axet.androidlibrary.app.Storage {
return name;
}
public static String formatBody(SMSMessage sms) {
String body = SIMPLE.format(sms.sent);
public static String formatBody(String from, SMSMessage sms) {
String body = from + " " + SIMPLE.format(sms.sent);
if (!sms.type.isEmpty())
body += " " + (sms.type.equals("IN") ? "↓" : "↑");
body += " " + PhoneNumberUtils.formatNumber(sms.threadPhone);
......@@ -313,6 +314,8 @@ public class Storage extends com.github.axet.androidlibrary.app.Storage {
BackupItemsFetcher fetcher = new BackupItemsFetcher(context, context.getContentResolver(), b);
BackupCursors cursors = new BulkFetcher(fetcher).fetch(EnumSet.of(DataType.SMS), -1);
String from = Build.DEVICE;
int count = 0;
while (cursors.hasNext()) {
BackupCursors.CursorAndType cursor = cursors.next();
......@@ -322,7 +325,7 @@ public class Storage extends com.github.axet.androidlibrary.app.Storage {
Map<String, String> map = getMessageMap(cursor.cursor);
SMSMessage sms = messageFromMapSms(mPersonLookup, map);
String name = formatName(sms);
String text = formatBody(sms);
String text = formatBody(from, sms);
Uri uri = getStoragePath();
String s = uri.getScheme();
if (s.equals(ContentResolver.SCHEME_FILE)) {
......
......@@ -27,7 +27,7 @@ import com.zegoggles.smssync.service.SmsBackupService;
import static com.zegoggles.smssync.App.LOCAL_LOGV;
import static com.zegoggles.smssync.App.TAG;
public class IncomingPeekReceiver extends BroadcastReceiver {
public class IncomingPeekReceiver extends BroadcastReceiver { // sms received notification
public static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
@Override
......@@ -39,9 +39,8 @@ public class IncomingPeekReceiver extends BroadcastReceiver {
if (a == null)
return;
if (SMS_RECEIVED.equals(a)) {
if (a.equals(SMS_RECEIVED))
incomingSMS(context);
}
}
public void incomingSMS(Context context) {
......
......@@ -20,7 +20,7 @@ import java.util.List;
import java.util.Map;
@TargetApi(19) // SMS_DELIVER is API19+
public class IncomingPostReceiver extends BroadcastReceiver { // sms deliver handler (we have to handle storage as well)
public class IncomingPostReceiver extends BroadcastReceiver { // sms deliver handler (we have to handle storage)
public static class Message {
public String phone;
......
......@@ -76,7 +76,6 @@ public class ReplySMSTask extends AsyncTask<BackupConfig, ReplyState, ReplyState
private final TokenRefresher tokenRefresher;
Preferences preferences;
static class RefMap {
// message id
public String id;
......
......@@ -3,6 +3,7 @@ package com.github.axet.smsgate.widgets;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.net.Uri;
import android.util.AttributeSet;
......@@ -10,7 +11,6 @@ import android.widget.Toast;
import com.github.axet.androidlibrary.widgets.OpenFileDialog;
import com.github.axet.androidlibrary.widgets.OpenStorageChoicer;
import com.github.axet.smsgate.R;
import java.io.File;
......@@ -68,6 +68,10 @@ public class StoragePathPreferenceCompat extends com.github.axet.androidlibrary.
};
choicer.setTitle(getTitle().toString());
choicer.setContext(getContext());
PackageManager pm = getContext().getPackageManager();
if (!pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY))
setVisible(false);
}
@Override
......
......@@ -23,14 +23,17 @@ import android.net.NetworkInfo;
import android.os.Build;
import android.os.Handler;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.text.format.DateFormat;
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.NotificationChannelCompat;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.app.SMSApplication;
import com.squareup.otto.Produce;
import com.squareup.otto.Subscribe;
import com.zegoggles.smssync.App;
......@@ -69,13 +72,11 @@ 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)) {
......@@ -216,11 +217,6 @@ 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
......@@ -230,7 +226,6 @@ public class SmsBackupService extends ServiceBase {
getNotifier().cancel(BACKUP_ID);
service = null;
stop();
icon.onDestroy();
}
synchronized void start() {
......@@ -456,6 +451,8 @@ public class SmsBackupService extends ServiceBase {
builder.setContentIntent(getPendingIntent());
builder.setContentTitle(getString(R.string.status_backup));
builder.setContentText(state.getNotificationLabel(getResources()));
NotificationChannelCompat channel = new NotificationChannelCompat(this, "status", "BackupService", NotificationManagerCompat.IMPORTANCE_LOW);
channel.apply(builder);
notification = builder.build();
startForeground(BACKUP_ID, notification);
}
......@@ -480,6 +477,8 @@ public class SmsBackupService extends ServiceBase {
builder.setContentIntent(getPendingIntent());
builder.setContentTitle(title);
builder.setContentText(text);
NotificationChannelCompat channel = new NotificationChannelCompat(this, "status", "BackupService", NotificationManagerCompat.IMPORTANCE_LOW);
channel.apply(builder);
getNotifier().notify(BACKUP_USER, builder.build());
}
......
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