Commit e91668ee authored by axet's avatar axet 🍄

Merge branch 'smsgate-1.9.6'

parents 7d937228 bac68307
Pipeline #40248328 (#199) passed with stage
in 24 seconds
......@@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.smsgate"
minSdkVersion 9
targetSdkVersion 26
versionCode 214
versionName "1.9.5"
versionCode 215
versionName "1.9.6"
}
packagingOptions {
exclude 'META-INF/LICENSE'
......@@ -39,7 +39,7 @@ android {
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.github.axet:android-library:1.28.16' // implementation project(':android-library')
implementation 'com.github.axet:android-library:1.28.30' // 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'
......
......@@ -13,8 +13,6 @@ import android.os.Bundle;
import android.provider.Telephony;
import android.telephony.SmsMessage;
import com.zegoggles.smssync.SmsConsts;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
......@@ -199,6 +197,8 @@ public class SmsStorage {
}
}
c.close();
if (ids.isEmpty())
return null;
return ids;
}
return null;
......@@ -216,6 +216,8 @@ public class SmsStorage {
ids.add(id);
}
c.close();
if (ids.isEmpty())
return null;
return ids;
}
return null;
......
......@@ -328,7 +328,7 @@ public class Storage extends com.github.axet.androidlibrary.app.Storage {
while (cursor.moveToNext()) {
count++;
SmsStorage.Message m = SmsStorage.getMessage(cursor);
if (Storage.filter(context, m) == 0)
if (Storage.filter(context, m) != 0)
continue;
SMSMessage sms = getMessage(mPersonLookup, m);
String ff = shared.getString(SMSApplication.PREF_NAMEFORMAT, "%d %t (%m) %p");
......@@ -350,7 +350,7 @@ public class Storage extends com.github.axet.androidlibrary.app.Storage {
return 0;
}
} else if (Build.VERSION.SDK_INT >= 21 && s.equals(ContentResolver.SCHEME_CONTENT)) {
Uri file = createFile(uri, name);
Uri file = createFile(context, uri, name);
ContentResolver resolver = context.getContentResolver();
try {
OutputStream os = resolver.openOutputStream(file);
......
......@@ -28,7 +28,6 @@ import android.os.SystemClock;
import android.provider.Telephony;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v7.preference.PreferenceManager;
import android.telephony.CellSignalStrength;
import android.telephony.PhoneStateListener;
......@@ -40,6 +39,7 @@ import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.github.axet.androidlibrary.app.NotificationManagerCompat;
import com.github.axet.androidlibrary.crypto.Bitcoin;
import com.github.axet.androidlibrary.net.HttpClient;
import com.github.axet.androidlibrary.services.DeviceAdmin;
......@@ -1082,7 +1082,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
Log.d(TAG, "Delete SMS" + id);
messages.child(String.valueOf(id)).removeValue();
}
return; // do not delete thread manually
return; // do not delete thread manually
}
messages.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
......
......@@ -18,6 +18,7 @@ package com.github.axet.smsgate.services;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Telephony;
import android.util.Log;
import com.github.axet.smsgate.app.Storage;
......@@ -28,8 +29,6 @@ import static com.zegoggles.smssync.App.LOCAL_LOGV;
import static com.zegoggles.smssync.App.TAG;
public class IncomingPeekReceiver extends BroadcastReceiver { // sms received notification
public static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
@Override
public void onReceive(Context context, Intent intent) {
if (LOCAL_LOGV) Log.v(TAG, "onReceive(" + context + "," + intent + ")");
......@@ -39,7 +38,7 @@ public class IncomingPeekReceiver extends BroadcastReceiver { // sms received no
if (a == null)
return;
if (a.equals(SMS_RECEIVED))
if (a.equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION))
incomingSMS(context);
}
......
......@@ -2,29 +2,24 @@ package com.github.axet.smsgate.services;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.provider.Telephony;
import android.telephony.PhoneNumberUtils;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.app.ScheduleSMS;
import com.github.axet.smsgate.app.SmsStorage;
import com.github.axet.smsgate.app.Storage;
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)
@Override
public void onReceive(Context context, Intent intent) {
String a = intent.getAction();
if (a == null)
return;
if (Telephony.Sms.Intents.SMS_DELIVER_ACTION.equals(a)) {
if (a.equals(Telephony.Sms.Intents.SMS_DELIVER_ACTION)) {
Map<String, SmsStorage.Message> map = SmsStorage.getMessagesFromIntent(intent);
if (map == null)
return;
......@@ -35,6 +30,7 @@ public class IncomingPostReceiver extends BroadcastReceiver { // sms deliver han
continue;
storage.add(m);
}
context.sendBroadcast(new Intent(Telephony.Sms.Intents.SMS_RECEIVED_ACTION).putExtra("pdus", intent.getSerializableExtra("pdus")));
}
}
}
......@@ -2,6 +2,7 @@ package com.github.axet.smsgate.services;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
......@@ -18,13 +19,15 @@ import com.zegoggles.smssync.activity.SMSGateFragment;
@TargetApi(18)
public class NotificationListener extends NotificationListenerService {
public static String TAG = NotificationListener.class.getSimpleName();
public static final String TAG = NotificationListener.class.getSimpleName();
public static String REFRESH = NotificationListener.class.getCanonicalName() + ".REFRESH";
public static String CANCEL = NotificationListener.class.getCanonicalName() + ".CANCEL";
public static final String REFRESH = NotificationListener.class.getCanonicalName() + ".REFRESH";
public static final String CANCEL = NotificationListener.class.getCanonicalName() + ".CANCEL";
// 21+ Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS
public static String ACTION_NOTIFICATION_LISTENER_SETTINGS = "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS";
public static final String ACTION_NOTIFICATION_LISTENER_SETTINGS = "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS";
BroadcastReceiver receiver;
public static void refresh(Context context) {
Intent intent = new Intent(REFRESH);
......@@ -47,9 +50,8 @@ public class NotificationListener extends NotificationListenerService {
}
public static void startIfEnabled(Context context) {
if (enabled(context)) {
if (enabled(context))
refresh(context);
}
}
public static void cancel(Context context, String id) {
......@@ -58,7 +60,10 @@ public class NotificationListener extends NotificationListenerService {
context.sendBroadcast(intent);
}
BroadcastReceiver receiver;
public static void requestRebind(Context context) {
if (Build.VERSION.SDK_INT >= 24)
NotificationListenerService.requestRebind(new ComponentName(context, NotificationListener.class));
}
@Override
public void onCreate() {
......
......@@ -3,10 +3,13 @@ package com.github.axet.smsgate.services;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
public class OnUpgradeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
OnBootReceiver.start(context);
if (Build.VERSION.SDK_INT >= 18)
NotificationListener.requestRebind(context);
}
}
......@@ -22,7 +22,6 @@ import android.content.Intent;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Handler;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v7.app.NotificationCompat;
import android.text.format.DateFormat;
import android.util.Log;
......@@ -37,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.app.NotificationManagerCompat;
import com.github.axet.androidlibrary.widgets.NotificationChannelCompat;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.smsgate.R;
......
......@@ -11,6 +11,7 @@ import android.widget.Toast;
import com.github.axet.androidlibrary.widgets.OpenFileDialog;
import com.github.axet.androidlibrary.widgets.OpenStorageChoicer;
import com.github.axet.smsgate.app.Storage;
import java.io.File;
......@@ -89,7 +90,7 @@ public class StoragePathPreferenceCompat extends com.github.axet.androidlibrary.
Uri u = storage.getStoragePath(v);
if (u != null) {
setText(u.toString());
setSummary(storage.getDisplayName(u));
setSummary(Storage.getDisplayName(getContext(), u));
}
}
......
......@@ -17,7 +17,6 @@ package com.zegoggles.smssync.service;
import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
......@@ -31,6 +30,7 @@ import android.text.format.DateFormat;
import android.util.Log;
import com.fsck.k9.mail.MessagingException;
import com.github.axet.androidlibrary.app.NotificationManagerCompat;
import com.github.axet.smsgate.R;
import com.zegoggles.smssync.App;
import com.zegoggles.smssync.activity.SMSGateFragment;
......@@ -181,8 +181,8 @@ public abstract class ServiceBase extends Service {
}
}
protected NotificationManager getNotifier() {
return (NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
protected NotificationManagerCompat getNotifier() {
return NotificationManagerCompat.from(this);
}
protected ConnectivityManager getConnectivityManager() {
......
......@@ -23,13 +23,13 @@ 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.app.NotificationManagerCompat;
import com.github.axet.androidlibrary.widgets.NotificationChannelCompat;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.smsgate.R;
......
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