Commit e7084d4a authored by axet's avatar axet 🍄

Merge branch 'smsgate-1.8.23'

parents 25062faa 91fcbd13
Pipeline #34028415 passed with stage
in 34 seconds
......@@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.github.axet.smsgate"
minSdkVersion 9
targetSdkVersion 23
versionCode 206
versionName "1.8.22"
versionCode 207
versionName "1.8.23"
}
packagingOptions {
exclude 'META-INF/LICENSE'
......@@ -39,7 +39,7 @@ android {
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.github.axet:android-library:1.24.51' // implementation project(':android-library')
implementation 'com.github.axet:android-library:1.27.18' // 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'
......
......@@ -72,7 +72,7 @@
<supports-screens android:smallScreens="true" />
<application
android:name=".app.MainApplication"
android:name=".app.SMSApplication"
android:allowBackup="true"
android:backupAgent=".services.PreferenceBackupAgent"
android:description="@string/app_description"
......
......@@ -27,7 +27,7 @@ import android.widget.Toast;
import com.github.axet.androidlibrary.app.Storage;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.dialogs.ShareDialogFragment;
import com.github.axet.smsgate.dialogs.ShareIncomingFragment;
import com.github.axet.smsgate.fragments.SchedulersFragment;
......@@ -102,8 +102,8 @@ public class MainActivity extends AppCompatActivity implements DialogInterface.O
setContentView(R.layout.activity_main);
if (OptimizationPreferenceCompat.needKillWarning(this, MainApplication.PREF_NEXT))
OptimizationPreferenceCompat.buildKilledWarning(this, true).show();
if (OptimizationPreferenceCompat.needKillWarning(this, SMSApplication.PREF_NEXT))
OptimizationPreferenceCompat.buildKilledWarning(this, true, SMSApplication.PREF_OPTIMIZATION).show();
openIntent(getIntent());
......
......@@ -40,7 +40,7 @@ import java.util.Set;
import static com.fsck.k9.mail.internet.MimeMessageHelper.setBody;
public class MainApplication extends App {
public class SMSApplication extends App {
public static final String SCHEDULER_COUNT = "SCHEDULER_COUNT";
public static final String SCHEDULER_ITEM = "SCHEDULER_";
public static final String PUB = "PUB";
......@@ -66,21 +66,15 @@ public class MainApplication extends App {
public static final String APP_SUBJ = "subject";
public static final String APP_BODY = "body";
public static class NotificationInfo extends NotificationService.NotificationInfo {
String pkg;
String nid;
Notification n;
public NotificationInfo(String id) {
super(id);
}
}
SIM sim;
Bitcoin keyPair = null;
Handler handler = new Handler();
NotificationService.NotificationsMap<NotificationInfo> lastId = new NotificationService.NotificationsMap<>(handler);
public static SMSApplication from(Context context) {
return (SMSApplication) App.from(context);
}
public static boolean firebaseEnabled(Context context) {
if (Build.VERSION.SDK_INT < 11) // WebInterface requires P2P encryption API11+ EC KeyFactory
return false;
......@@ -102,6 +96,16 @@ public class MainApplication extends App {
}
}
public static class NotificationInfo extends NotificationService.NotificationInfo {
String pkg;
String nid;
Notification n;
public NotificationInfo(String id) {
super(id);
}
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
......@@ -127,7 +131,6 @@ public class MainApplication extends App {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String sec = prefs.getString(SEC, "");
String pub = prefs.getString(PUB, "");
if (sec.isEmpty() || pub.isEmpty()) {
keyPair.generate();
save();
......@@ -149,9 +152,8 @@ public class MainApplication extends App {
}
public SIM getSIM() {
if (sim == null) {
if (sim == null)
sim = new SIM(this);
}
return sim;
}
......@@ -159,10 +161,6 @@ public class MainApplication extends App {
return keyPair;
}
public static MainApplication getApp(Context context) {
return (MainApplication) context.getApplicationContext();
}
public static List<ScheduleSMS> load(Context context) {
List<ScheduleSMS> items = new ArrayList<>();
......@@ -194,7 +192,7 @@ public class MainApplication extends App {
File outputDir = context.getCacheDir();
File outputFile = File.createTempFile("share", ".tmp", outputDir);
IOUtils.write(buf, new FileOutputStream(outputFile));
return FileProvider.getProvider().getUriForFile(context, type, name, outputFile);
return FileProvider.getProvider().share(type, name, outputFile);
} catch (IOException e) {
throw new RuntimeException(e);
}
......@@ -224,7 +222,7 @@ public class MainApplication extends App {
if (n.priority <= Notification.PRIORITY_LOW)
return; // ignore low priority notifications
}
MainApplication app = (MainApplication) context.getApplicationContext();
SMSApplication app = SMSApplication.from(context);
if (action.equals(NotificationService.REMOVE)) {
app.lastId.remove(pkg);
return;
......@@ -270,7 +268,7 @@ public class MainApplication extends App {
details = "";
}
MainApplication app = (MainApplication) context.getApplicationContext();
SMSApplication app = SMSApplication.from(context);
long now = System.currentTimeMillis();
......@@ -301,7 +299,7 @@ public class MainApplication extends App {
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
Set<String> ss = ApplicationsPreference.load(prefs.getString(MainApplication.PREF_APPS, ""));
Set<String> ss = ApplicationsPreference.load(prefs.getString(SMSApplication.PREF_APPS, ""));
if (!ApplicationsPreference.contains(ss, pkg))
return;
int i = prefs.getInt(APPS_COUNT, 0);
......
......@@ -16,7 +16,7 @@ import com.github.axet.androidlibrary.crypto.Bitcoin;
import com.github.axet.androidlibrary.widgets.OpenFileDialog;
import com.github.axet.androidlibrary.widgets.PopupShareActionProvider;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.services.FirebaseService;
public class FirebaseConnectDialog extends AlertDialog {
......@@ -47,7 +47,7 @@ public class FirebaseConnectDialog extends AlertDialog {
@Override
public void onClick(View v) {
SharedPreferences prefs = android.support.v7.preference.PreferenceManager.getDefaultSharedPreferences(getContext());
boolean c = prefs.getBoolean(MainApplication.PREF_FIREBASE, false);
boolean c = prefs.getBoolean(SMSApplication.PREF_FIREBASE, false);
if (c) {
FirebaseService.stop(getContext());
FirebaseService.reset(getContext());
......@@ -69,8 +69,8 @@ public class FirebaseConnectDialog extends AlertDialog {
refresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MainApplication.getApp(getContext()).getKeyPair().generate();
MainApplication.getApp(getContext()).save();
SMSApplication.from(getContext()).getKeyPair().generate();
SMSApplication.from(getContext()).save();
FirebaseService.reset(getContext());
update();
}
......@@ -81,14 +81,14 @@ public class FirebaseConnectDialog extends AlertDialog {
public void onClick(View v) {
final OpenFileDialog.EditTextDialog editTextDialog = new OpenFileDialog.EditTextDialog(getContext());
editTextDialog.setTitle("PrivateKey");
editTextDialog.setText(MainApplication.getApp(getContext()).getKeyPair().getSec());
editTextDialog.setText(SMSApplication.from(getContext()).getKeyPair().getSec());
editTextDialog.setPositiveButton("OK", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Bitcoin k = MainApplication.getApp(getContext()).getKeyPair();
Bitcoin k = SMSApplication.from(getContext()).getKeyPair();
k.loadSec(editTextDialog.getText());
k.loadPub(k.sec);
MainApplication.getApp(getContext()).save();
SMSApplication.from(getContext()).save();
update();
}
});
......@@ -110,7 +110,7 @@ public class FirebaseConnectDialog extends AlertDialog {
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, "");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "SMSGate PrivateKey");
emailIntent.putExtra(Intent.EXTRA_TEXT, MainApplication.getApp(getContext()).getKeyPair().getSec());
emailIntent.putExtra(Intent.EXTRA_TEXT, SMSApplication.from(getContext()).getKeyPair().getSec());
popup.setShareIntent(emailIntent);
popup.show();
......@@ -130,10 +130,10 @@ public class FirebaseConnectDialog extends AlertDialog {
}
public void update() {
mSyncDetailsLabel.setText(MainApplication.getApp(getContext()).getKeyPair().getSec());
mSyncDetailsLabel.setText(SMSApplication.from(getContext()).getKeyPair().getSec());
SharedPreferences prefs = android.support.v7.preference.PreferenceManager.getDefaultSharedPreferences(getContext());
boolean connected = prefs.getBoolean(MainApplication.PREF_FIREBASE, false);
boolean connected = prefs.getBoolean(SMSApplication.PREF_FIREBASE, false);
if (connected) {
mConnectButton.setText("Disconnect");
......
......@@ -31,7 +31,7 @@ import android.widget.TimePicker;
import com.github.axet.androidlibrary.app.AlarmManager;
import com.github.axet.androidlibrary.app.SuperUser;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.app.ScheduleTime;
import com.github.axet.smsgate.services.CommandsService;
import com.github.axet.androidlibrary.services.DeviceAdmin;
......@@ -51,7 +51,7 @@ public class RebootDialogFragment extends DialogFragment {
public static ScheduleTime getSchedule(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String s = prefs.getString(MainApplication.PREF_REBOOT, "");
String s = prefs.getString(SMSApplication.PREF_REBOOT, "");
if (s.isEmpty()) {
return new ScheduleTime(context);
} else {
......@@ -62,7 +62,7 @@ public class RebootDialogFragment extends DialogFragment {
public static void saveSchedule(Context context, ScheduleTime s) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor edit = prefs.edit();
edit.putString(MainApplication.PREF_REBOOT, s.save().toString());
edit.putString(SMSApplication.PREF_REBOOT, s.save().toString());
edit.commit();
}
......
......@@ -22,7 +22,7 @@ import android.widget.TextView;
import android.widget.TimePicker;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.app.ScheduleSMS;
import com.github.axet.smsgate.app.ScheduleTime;
import com.github.axet.smsgate.providers.SIM;
......@@ -167,7 +167,7 @@ public class ScheduleEditDialogFragment extends DialogFragment {
public View createView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
v = inflater.inflate(R.layout.schedule_edit, container, false);
sm = MainApplication.getApp(getContext()).getSIM();
sm = SMSApplication.from(getContext()).getSIM();
result = new ScheduleResult();
String json = getArguments().getString("sms");
......
......@@ -22,7 +22,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.services.FirebaseService;
import com.github.axet.smsgate.widgets.MultiImageView;
......@@ -181,7 +181,7 @@ public class ShareDialogFragment extends DialogFragment {
filename.setText(name);
if (length != null) {
filesize.setText(MainApplication.formatSize(getContext(), length));
filesize.setText(SMSApplication.formatSize(getContext(), length));
b.putLong("size", length);
}
b.putString("filename", name);
......
......@@ -24,7 +24,7 @@ import android.widget.TextView;
import com.github.axet.androidlibrary.crypto.Bitcoin;
import com.github.axet.androidlibrary.services.FileProvider;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import org.apache.commons.io.output.ByteArrayOutputStream;
......@@ -58,7 +58,7 @@ public class ShareIncomingFragment extends DialogFragment {
protected Intent doInBackground(ArrayList<Bundle>... urls) {
ArrayList<Bundle> uris = urls[0];
Bitcoin key = MainApplication.getApp(getActivity()).getKeyPair();
Bitcoin key = SMSApplication.from(getActivity()).getKeyPair();
Intent intent = new Intent();
ArrayList<Uri> uu = new ArrayList<>();
......@@ -96,7 +96,7 @@ public class ShareIncomingFragment extends DialogFragment {
byte[] bb = output.toByteArray();
byte[] buf = key.decrypt(bb);
Uri s = MainApplication.shareFile(context, type, fn, buf);
Uri s = SMSApplication.shareFile(context, type, fn, buf);
uu.add(s);
}
} catch (Exception e) {
......@@ -254,7 +254,7 @@ public class ShareIncomingFragment extends DialogFragment {
filename.setText(fn);
Long length = new Long(uri.get("filesize").toString());
filesize.setText(MainApplication.formatSize(getContext(), length));
filesize.setText(SMSApplication.formatSize(getContext(), length));
list.addView(v);
}
......@@ -274,7 +274,7 @@ public class ShareIncomingFragment extends DialogFragment {
@Override
public void onResume() {
super.onResume();
MainApplication.shareClear(getActivity());
SMSApplication.shareClear(getActivity());
}
void disable() {
......
......@@ -30,7 +30,7 @@ import android.widget.Toast;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.activities.MainActivity;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.app.ScheduleSMS;
import com.github.axet.smsgate.dialogs.ScheduleEditDialogFragment;
......@@ -44,7 +44,7 @@ public class SchedulersFragment extends Fragment implements DialogInterface.OnDi
Handler handler = new Handler();
FragmentManager fm;
boolean permittedResume = false;
MainApplication app;
SMSApplication app;
RecyclerView list;
ScheduleEditDialogFragment dialog;
Schedulers schedulers;
......@@ -148,7 +148,7 @@ public class SchedulersFragment extends Fragment implements DialogInterface.OnDi
@Override
public void onClick(View v) {
item.enabled = holder.enabled.isChecked();
MainApplication.save(getActivity(), items);
SMSApplication.save(getActivity(), items);
}
});
......@@ -200,11 +200,11 @@ public class SchedulersFragment extends Fragment implements DialogInterface.OnDi
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
fm = ((MainActivity) getActivity()).getSupportFragmentManager();
app = MainApplication.getApp(getActivity());
app = SMSApplication.from(getActivity());
View rootView = inflater.inflate(R.layout.fragment_schedulers, container, false);
schedulers = new Schedulers(MainApplication.load(getActivity()));
schedulers = new Schedulers(SMSApplication.load(getActivity()));
list = (RecyclerView) rootView.findViewById(R.id.section_label);
list.setAdapter(schedulers);
......@@ -298,14 +298,14 @@ public class SchedulersFragment extends Fragment implements DialogInterface.OnDi
ScheduleEditDialogFragment.ScheduleResult r = (ScheduleEditDialogFragment.ScheduleResult) dialog;
if (r.delete) {
schedulers.remove(r.pos);
MainApplication.save(getActivity(), schedulers.items);
SMSApplication.save(getActivity(), schedulers.items);
}
if (r.save) {
if (r.pos == -1)
schedulers.add(r.schedule);
else
schedulers.set(r.pos, r.schedule);
MainApplication.save(getActivity(), schedulers.items);
SMSApplication.save(getActivity(), schedulers.items);
}
}
this.dialog = null;
......@@ -319,7 +319,7 @@ public class SchedulersFragment extends Fragment implements DialogInterface.OnDi
}
void load() {
schedulers.items = MainApplication.load(getActivity());
schedulers.items = SMSApplication.load(getActivity());
schedulers.notifyDataSetChanged();
}
......
......@@ -37,7 +37,6 @@ import android.os.Handler;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.provider.Telephony;
import android.support.v4.app.FragmentManager;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
......@@ -49,16 +48,13 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import com.github.axet.androidlibrary.app.SuperUser;
import com.github.axet.androidlibrary.services.WifiKeepService;
import com.github.axet.androidlibrary.widgets.AboutPreferenceCompat;
import com.github.axet.androidlibrary.widgets.OptimizationPreferenceCompat;
import com.github.axet.smsgate.BuildConfig;
import com.github.axet.smsgate.R;
import com.github.axet.smsgate.activities.MainActivity;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.ScheduleTime;
import com.github.axet.smsgate.dialogs.RebootDialogFragment;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.services.NotificationListener;
import com.github.axet.smsgate.services.NotificationService;
import com.github.axet.smsgate.services.OnBootReceiver;
......@@ -140,10 +136,10 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
preferences = new Preferences(context);
addPreferencesFromResource(R.xml.settings);
if (!MainApplication.firebaseEnabled(context)) {
Preference pref = findPreference(MainApplication.PREF_FIREBASESETTINGS);
if (!SMSApplication.firebaseEnabled(context)) {
Preference pref = findPreference(SMSApplication.PREF_FIREBASESETTINGS);
pref.setVisible(false);
Preference adm = findPreference(MainApplication.PREF_ADMIN);
Preference adm = findPreference(SMSApplication.PREF_ADMIN);
adm.setVisible(false);
}
......@@ -174,7 +170,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
public void onReceive(Context context, Intent intent) {
String a = intent.getAction();
if (a.equals(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED)) {
((AdminPreferenceCompat) findPreference(MainApplication.PREF_ADMIN)).updateAdmin();
((AdminPreferenceCompat) findPreference(SMSApplication.PREF_ADMIN)).updateAdmin();
}
}
};
......@@ -200,19 +196,19 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
updateNotifications();
updateApps();
OptimizationPreferenceCompat optimization = (OptimizationPreferenceCompat) findPreference(MainApplication.PREF_OPTIMIZATION);
OptimizationPreferenceCompat optimization = (OptimizationPreferenceCompat) findPreference(SMSApplication.PREF_OPTIMIZATION);
optimization.onResume();
RebootPreferenceCompat reboot = (RebootPreferenceCompat) findPreference(MainApplication.PREF_REBOOT);
RebootPreferenceCompat reboot = (RebootPreferenceCompat) findPreference(SMSApplication.PREF_REBOOT);
reboot.setFragment(this);
reboot.onResume();
AdminPreferenceCompat admin = ((AdminPreferenceCompat) findPreference(MainApplication.PREF_ADMIN));
AdminPreferenceCompat admin = ((AdminPreferenceCompat) findPreference(SMSApplication.PREF_ADMIN));
admin.setFragment(this, REQUEST_ADMIN);
admin.setMessages(R.string.admin_web_description, AdminPreferenceCompat.ERASE_ALL_DATA, R.string.admin_web_erase, AdminPreferenceCompat.LOCK_SCREEN, R.string.admin_web_lock);
admin.onResume();
DefaultSMSPreferenceCompat sms = (DefaultSMSPreferenceCompat) findPreference(MainApplication.PREF_DEFAULTSMS);
DefaultSMSPreferenceCompat sms = (DefaultSMSPreferenceCompat) findPreference(SMSApplication.PREF_DEFAULTSMS);
sms.onResume();
}
......@@ -611,7 +607,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
}
public CheckBoxPreference updateNotifications() {
CheckBoxPreference notifications = (CheckBoxPreference) findPreference(MainApplication.PREF_NOTIFICATION_LISTENER);
CheckBoxPreference notifications = (CheckBoxPreference) findPreference(SMSApplication.PREF_NOTIFICATION_LISTENER);
if (Build.VERSION.SDK_INT < 18) {
if (notifications.isChecked())
notifications.setChecked(NotificationService.enabled(getActivity()));
......@@ -623,7 +619,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
}
public ApplicationsPreference updateApps() {
ApplicationsPreference notifications = (ApplicationsPreference) findPreference(MainApplication.PREF_APPS);
ApplicationsPreference notifications = (ApplicationsPreference) findPreference(SMSApplication.PREF_APPS);
return notifications;
}
......@@ -857,11 +853,11 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(MainApplication.PREF_REBOOT)) {
((RebootPreferenceCompat) findPreference(MainApplication.PREF_REBOOT)).updateReboot();
if (key.equals(SMSApplication.PREF_REBOOT)) {
((RebootPreferenceCompat) findPreference(SMSApplication.PREF_REBOOT)).updateReboot();
}
if (key.equals(MainApplication.PREF_WIFIRESTART)) {
WifiKeepService.startIfEnabled(getContext(), sharedPreferences.getBoolean(MainApplication.PREF_WIFIRESTART, false));
if (key.equals(SMSApplication.PREF_WIFIRESTART)) {
WifiKeepService.startIfEnabled(getContext(), sharedPreferences.getBoolean(SMSApplication.PREF_WIFIRESTART, false));
}
}
......@@ -877,7 +873,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_ADMIN) {
((AdminPreferenceCompat) findPreference(MainApplication.PREF_ADMIN)).onActivityResult(resultCode, data);
((AdminPreferenceCompat) findPreference(SMSApplication.PREF_ADMIN)).onActivityResult(resultCode, data);
}
}
}
......@@ -12,7 +12,7 @@ import android.provider.Telephony;
import android.telephony.PhoneNumberUtils;
import android.telephony.SmsMessage;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.app.ScheduleSMS;
import java.util.HashMap;
......@@ -86,7 +86,7 @@ public class IncomingPostReceiver extends BroadcastReceiver {
Map<String, Message> map = getMessagesFromIntent(intent);
if (map == null)
return;
List<ScheduleSMS> items = MainApplication.load(context);
List<ScheduleSMS> items = SMSApplication.load(context);
ContentResolver res = context.getContentResolver();
for (String id : map.keySet()) {
Message m = map.get(id);
......
......@@ -13,7 +13,7 @@ import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.util.Log;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.zegoggles.smssync.activity.SMSGateFragment;
@TargetApi(18)
......@@ -36,7 +36,7 @@ public class NotificationListener extends NotificationListenerService {
}
public static String notificationCode(String pkg, String tag, int id) {
return MainApplication.toHexString((pkg + "_" + tag + "_" + id).hashCode());
return SMSApplication.toHexString((pkg + "_" + tag + "_" + id).hashCode());
}
public static boolean enabled(Context context) {
......@@ -141,7 +141,7 @@ public class NotificationListener extends NotificationListenerService {
}
void send(String action, StatusBarNotification n) {
MainApplication.AppsNotification(this, action, n.getPackageName(), notificationCode(n.getPackageName(), n.getTag(), n.getId()), n.getNotification());
SMSApplication.AppsNotification(this, action, n.getPackageName(), notificationCode(n.getPackageName(), n.getTag(), n.getId()), n.getNotification());
SMSGateFragment.checkPermissions(this);
FirebaseService.notification(this, action, n.getPackageName(), notificationCode(n.getPackageName(), n.getTag(), n.getId()), n.getNotification());
}
......
......@@ -10,7 +10,7 @@ import android.os.Handler;
import android.provider.Settings;
import android.view.accessibility.AccessibilityEvent;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.zegoggles.smssync.activity.SMSGateFragment;
import java.util.HashMap;
......@@ -116,8 +116,8 @@ public class NotificationService extends AccessibilityService {
Notification n = (Notification) event.getParcelableData();
if (n == null)
return;
String id = MainApplication.toHexString(event.getPackageName().toString().hashCode());
MainApplication.AppsNotification(this, NotificationService.UPDATE, FirebaseService.toString(event.getPackageName()), id, n);
String id = SMSApplication.toHexString(event.getPackageName().toString().hashCode());
SMSApplication.AppsNotification(this, NotificationService.UPDATE, FirebaseService.toString(event.getPackageName()), id, n);
SMSGateFragment.checkPermissions(this);
FirebaseService.notification(this, NotificationService.UPDATE, FirebaseService.toString(event.getPackageName()), id, n);
}
......
......@@ -24,7 +24,7 @@ import android.preference.PreferenceManager;
import android.util.Log;
import com.github.axet.androidlibrary.services.WifiKeepService;
import com.github.axet.smsgate.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.dialogs.RebootDialogFragment;
import com.zegoggles.smssync.activity.SMSGateFragment;
import com.zegoggles.smssync.service.SmsBackupService;
......@@ -53,7 +53,7 @@ public class OnBootReceiver extends BroadcastReceiver {
NotificationListener.startIfEnabled(context);
NotificationService.startIfEnabled(context);
RebootDialogFragment.schedule(context);
WifiKeepService.startIfEnabled(context, shared.getBoolean(MainApplication.PREF_WIFIRESTART, false));
WifiKeepService.startIfEnabled(context, shared.getBoolean(SMSApplication.PREF_WIFIRESTART, false));
}
public static void fragment(Context context) {
......
......@@ -211,7 +211,7 @@ public class ReplySMSTask extends AsyncTask<BackupConfig, ReplyState, ReplyState
ContentResolver resolver,
Preferences preferences,
TokenRefresher tokenRefresher) {
this.context = service.getApplicationContext();
this.context = service;
this.service = service;
this.resolver = resolver;
this.preferences = preferences;
......
package com.github.axet.smsgate.services;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
......@@ -12,7 +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.app.MainApplication;
import com.github.axet.smsgate.app.SMSApplication;
import com.github.axet.smsgate.app.ScheduleSMS;
import com.github.axet.smsgate.app.ScheduleTime;
import com.github.axet.smsgate.fragments.SchedulersFragment;
......@@ -44,7 +43,7 @@ public class ScheduleService extends Service implements SharedPreferences.OnShar
public void onCreate() {
super.onCreate();
receiver = new OptimizationPreferenceCompat.ServiceReceiver(this, getClass(), MainApplication.PREF_OPTIMIZATION) {
receiver = new OptimizationPreferenceCompat.ServiceReceiver(this, getClass(), SMSApplication.PREF_OPTIMIZATION) {
@Override
public void check() {
}
......@@ -52,13 +51,13 @@ public class ScheduleService extends Service implements SharedPreferences.OnShar
@Override
public void register() {
super.register();
OptimizationPreferenceCompat.setKillCheck(context, next, MainApplication.PREF_NEXT);
OptimizationPreferenceCompat.setKillCheck(context, next, SMSApplication.PREF_NEXT);
}
@Override
public void unregister() {
super.unregister();
OptimizationPreferenceCompat.setKillCheck(context, 0, MainApplication.PREF_NEXT);
OptimizationPreferenceCompat.setKillCheck(context, 0, SMSApplication.PREF_NEXT);
}
};
......@@ -82,7 +81,7 @@ public class ScheduleService extends Service implements SharedPreferences.OnShar
Log.d(TAG, "onStartCommand " + action);
if (action != null) {
if (action.equals(REGISTER)) {
MainApplication.load(this);
SMSApplication.load(this);
registerNextAlarm();
}
if (action.equals(ACTION_SMS)) {
......@@ -99,7 +98,7 @@ public class ScheduleService extends Service implements SharedPreferences.OnShar
public void registerNextAlarm() {
TreeSet<Long> events = new TreeSet<>();