Commit f4a7222c authored by axet's avatar axet 🍄

Merge branch 'smsgate-1.8.15'

parents 56747f4c 0a5ed11b
Pipeline #15516570 passed with stage
in 25 seconds
......@@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.smsgate"
minSdkVersion 9
targetSdkVersion 23
versionCode 198
versionName "1.8.14"
versionCode 199
versionName "1.8.15"
}
packagingOptions {
exclude 'META-INF/LICENSE'
......@@ -40,7 +40,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.github.axet:android-library:1.17.1' // compile project(':android-library')
compile 'com.github.axet:android-library:1.17.10' // compile project(':android-library')
compile 'com.android.support:design:25.3.1'
compile 'com.intellij:annotations:12.0'
compile 'com.beetstra.jutf7:jutf7:1.0.0'
......
......@@ -61,24 +61,25 @@ public class MainApplication extends App {
public static final String SEC = "SEC";
public static final String SMS_LAST = "SMS_LAST";
public static final String MMS_LAST = "MMS_LAST";
public static final String FIREBASE = "firebase";
public static final String NOTIFICATION_LISTENER = "notification_listener";
public static final String REBOOT = "reboot";
public static final String WIFI = "wifi_restart";
public static final String PREFERENCE_WIFI = "wifi_only";
public static final String ADMIN = "admin";
public static final String PREFERENCE_OPTIMIZATION = "optimization";
public static final String PREFERENCE_DEFAULTSMS = "defaultsms";
public static final String APPS = "applications"; // enabled
public static final String PREF_FIREBASE = "firebase";
public static final String PREF_NOTIFICATION_LISTENER = "notification_listener";
public static final String PREF_WIFIRESTART = "wifi_restart";
public static final String PREF_WIFI = "wifi_only";
public static final String PREF_ADMIN = "admin";
public static final String PREF_OPTIMIZATION = "optimization";
public static final String PREF_DEFAULTSMS = "defaultsms";
public static final String PREF_FIREBASESETTINGS = "firebase_settings";
public static final String PREF_REBOOT = "reboot";
public static final String PREF_APPS = "applications"; // enabled
public static final String APPS_INDEX = "APPS_";
public static final String APPS_COUNT = "APPS_COUNT";
public static final String BIN_PING = "/system/bin/ping";
public static final String BIN_PING = SuperUser.path("ping");
public static String APP_FROM = "from";
public static String APP_SUBJ = "subject";
public static String APP_BODY = "body";
public static final String APP_FROM = "from";
public static final String APP_SUBJ = "subject";
public static final String APP_BODY = "body";
public static class NotificationInfo extends NotificationService.NotificationInfo {
String pkg;
......@@ -235,7 +236,7 @@ public class MainApplication extends App {
public static void wipe(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean w = prefs.getBoolean(ADMIN, false);
boolean w = prefs.getBoolean(PREF_ADMIN, false);
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName c = new ComponentName(context, DeviceAdmin.class);
if (w && dpm.isAdminActive(c)) {
......@@ -245,7 +246,7 @@ public class MainApplication extends App {
public static void lock(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean w = prefs.getBoolean(ADMIN, false);
boolean w = prefs.getBoolean(PREF_ADMIN, false);
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName c = new ComponentName(context, DeviceAdmin.class);
if (w && dpm.isAdminActive(c)) {
......@@ -303,7 +304,7 @@ public class MainApplication extends App {
public static void wifi(final Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean wifi = prefs.getBoolean(WIFI, false);
boolean wifi = prefs.getBoolean(PREF_WIFIRESTART, false);
Intent intent = (new Intent(context, CommandsService.class));
intent.setAction(CommandsService.WIFI);
if (wifi) {
......@@ -461,7 +462,7 @@ public class MainApplication extends App {
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
Set<String> ss = ApplicationsPreference.load(prefs.getString(MainApplication.APPS, ""));
Set<String> ss = ApplicationsPreference.load(prefs.getString(MainApplication.PREF_APPS, ""));
if (!ApplicationsPreference.contains(ss, pkg))
return;
int i = prefs.getInt(APPS_COUNT, 0);
......
......@@ -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.FIREBASE, false);
boolean c = prefs.getBoolean(MainApplication.PREF_FIREBASE, false);
if (c) {
FirebaseService.stop(getContext());
FirebaseService.reset(getContext());
......@@ -133,7 +133,7 @@ public class FirebaseConnectDialog extends AlertDialog {
mSyncDetailsLabel.setText(MainApplication.getApp(getContext()).getKeyPair().getSec());
SharedPreferences prefs = android.support.v7.preference.PreferenceManager.getDefaultSharedPreferences(getContext());
boolean connected = prefs.getBoolean(MainApplication.FIREBASE, false);
boolean connected = prefs.getBoolean(MainApplication.PREF_FIREBASE, false);
if (connected) {
mConnectButton.setText("Disconnect");
......
......@@ -37,8 +37,6 @@ import com.github.axet.smsgate.services.CommandsService;
import java.util.Calendar;
import static com.github.axet.smsgate.app.MainApplication.REBOOT;
public class RebootDialogFragment extends DialogFragment {
View v;
......@@ -52,7 +50,7 @@ public class RebootDialogFragment extends DialogFragment {
public static ScheduleTime getSchedule(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String s = prefs.getString(REBOOT, "");
String s = prefs.getString(MainApplication.PREF_REBOOT, "");
if (s.isEmpty()) {
return new ScheduleTime(context);
} else {
......@@ -63,7 +61,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(REBOOT, s.save().toString());
edit.putString(MainApplication.PREF_REBOOT, s.save().toString());
edit.commit();
}
......
......@@ -60,7 +60,6 @@ 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.services.DeviceAdmin;
import com.github.axet.smsgate.services.FirebaseService;
import com.github.axet.smsgate.services.NotificationListener;
import com.github.axet.smsgate.services.NotificationService;
import com.github.axet.smsgate.services.OnBootReceiver;
......@@ -142,9 +141,9 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
addPreferencesFromResource(R.xml.settings);
if (!MainApplication.firebaseEnabled(context)) {
Preference pref = findPreference("firebase_settings");
Preference pref = findPreference(MainApplication.PREF_FIREBASESETTINGS);
pref.setVisible(false);
Preference adm = findPreference(MainApplication.ADMIN);
Preference adm = findPreference(MainApplication.PREF_ADMIN);
adm.setVisible(false);
}
......@@ -281,10 +280,10 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
}
});
OptimizationPreferenceCompat optimization = (OptimizationPreferenceCompat) findPreference(MainApplication.PREFERENCE_OPTIMIZATION);
OptimizationPreferenceCompat optimization = (OptimizationPreferenceCompat) findPreference(MainApplication.PREF_OPTIMIZATION);
optimization.onResume();
DefaultSMSPreferenceCompat defsms = (DefaultSMSPreferenceCompat) findPreference(MainApplication.PREFERENCE_DEFAULTSMS);
DefaultSMSPreferenceCompat defsms = (DefaultSMSPreferenceCompat) findPreference(MainApplication.PREF_DEFAULTSMS);
defsms.onResume();
}
......@@ -683,7 +682,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
}
public CheckBoxPreference updateNotifications() {
CheckBoxPreference notifications = (CheckBoxPreference) findPreference(MainApplication.NOTIFICATION_LISTENER);
CheckBoxPreference notifications = (CheckBoxPreference) findPreference(MainApplication.PREF_NOTIFICATION_LISTENER);
if (Build.VERSION.SDK_INT < 18) {
if (notifications.isChecked())
notifications.setChecked(NotificationService.enabled(getActivity()));
......@@ -695,7 +694,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
}
public ApplicationsPreference updateApps() {
ApplicationsPreference notifications = (ApplicationsPreference) findPreference(MainApplication.APPS);
ApplicationsPreference notifications = (ApplicationsPreference) findPreference(MainApplication.PREF_APPS);
return notifications;
}
......@@ -928,7 +927,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
}
public CheckBoxPreference updateReboot() {
CheckBoxPreference connected = (CheckBoxPreference) findPreference("reboot");
CheckBoxPreference connected = (CheckBoxPreference) findPreference(MainApplication.PREF_REBOOT);
ScheduleTime schedule = RebootDialogFragment.getSchedule(getActivity());
connected.setChecked(schedule.enabled);
......@@ -951,7 +950,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
public CheckBoxPreference updateAdmin() {
Context context = getActivity();
CheckBoxPreference connected = (CheckBoxPreference) findPreference(MainApplication.ADMIN);
CheckBoxPreference connected = (CheckBoxPreference) findPreference(MainApplication.PREF_ADMIN);
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName c = new ComponentName(context, DeviceAdmin.class);
......@@ -985,10 +984,10 @@ public class SettingsFragment extends PreferenceFragmentCompat implements MainAc
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(MainApplication.REBOOT)) {
if (key.equals(MainApplication.PREF_REBOOT)) {
updateReboot();
}
if (key.equals(MainApplication.WIFI)) {
if (key.equals(MainApplication.PREF_WIFIRESTART)) {
MainApplication.wifi(getActivity());
}
}
......
......@@ -587,7 +587,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
public static void start(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(MainApplication.FIREBASE, true);
edit.putBoolean(MainApplication.PREF_FIREBASE, true);
edit.commit();
firebase(context);
......@@ -598,7 +598,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
public static void notification(Context context, String action, String pkg, String id, Notification n) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (!prefs.getBoolean(MainApplication.NOTIFICATION_LISTENER, false)) {
if (!prefs.getBoolean(MainApplication.PREF_NOTIFICATION_LISTENER, false)) {
return;
}
......@@ -670,7 +670,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
public static void intent(Context context, Bundle args) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(MainApplication.FIREBASE, true);
edit.putBoolean(MainApplication.PREF_FIREBASE, true);
edit.commit();
firebase(context);
......@@ -683,13 +683,13 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
public static void startIfEnabled(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean(MainApplication.FIREBASE, false))
if (prefs.getBoolean(MainApplication.PREF_FIREBASE, false))
start(context);
}
public static void incoming(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean(MainApplication.FIREBASE, false)) {
if (prefs.getBoolean(MainApplication.PREF_FIREBASE, false)) {
Intent intent = new Intent(context, FirebaseService.class);
intent.setAction(INCOMING);
context.startService(intent);
......@@ -715,7 +715,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
public static void command(Context context, String enc) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(MainApplication.FIREBASE, true);
edit.putBoolean(MainApplication.PREF_FIREBASE, true);
edit.commit();
Intent intent = new Intent(context, FirebaseService.class);
......@@ -727,7 +727,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
public static void stop(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(MainApplication.FIREBASE, false);
edit.putBoolean(MainApplication.PREF_FIREBASE, false);
edit.commit();
firebase(context);
......@@ -740,7 +740,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
public static boolean isConnected(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getBoolean(MainApplication.FIREBASE, false);
return prefs.getBoolean(MainApplication.PREF_FIREBASE, false);
}
public static boolean isConnectedWifi(Context context) {
......@@ -787,7 +787,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
ff.addAction(NOTIFICATION);
registerReceiver(receiver, ff);
boolean wifi = prefs.getBoolean(MainApplication.PREFERENCE_WIFI, false);
boolean wifi = prefs.getBoolean(MainApplication.PREF_WIFI, false);
if (wifi && !isConnectedWifi(this)) {
pause();
......@@ -799,7 +799,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
wifiReciver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
boolean wifi = prefs.getBoolean(MainApplication.PREFERENCE_WIFI, false);
boolean wifi = prefs.getBoolean(MainApplication.PREF_WIFI, false);
final String action = intent.getAction();
Log.d(TAG, intent.toString() + " " + action);
if (action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) {
......@@ -991,7 +991,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
public static boolean isPause(Context context) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean wifi = prefs.getBoolean(MainApplication.PREFERENCE_WIFI, false);
boolean wifi = prefs.getBoolean(MainApplication.PREF_WIFI, false);
if (wifi) {
return !isConnectedWifi(context);
} else {
......@@ -1233,8 +1233,8 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
if (key.equals(MainApplication.PUB)) {
reload();
}
if (key.equals(MainApplication.PREFERENCE_WIFI)) {
if (prefs.getBoolean(MainApplication.FIREBASE, false) && !isPause(this)) {
if (key.equals(MainApplication.PREF_WIFI)) {
if (prefs.getBoolean(MainApplication.PREF_FIREBASE, false) && !isPause(this)) {
resume();
} else {
pause();
......
......@@ -608,14 +608,14 @@ public class SMSGateFragment extends PreferenceFragmentCompat implements MainAct
firebase.update();
}
CheckBoxPreference connected = (CheckBoxPreference) findPreference(MainApplication.FIREBASE);
CheckBoxPreference connected = (CheckBoxPreference) findPreference(MainApplication.PREF_FIREBASE);
if (!MainApplication.firebaseEnabled(getContext())) {
connected.setVisible(false);
}
SharedPreferences prefs = android.support.v7.preference.PreferenceManager.getDefaultSharedPreferences(getActivity());
connected.setChecked(prefs.getBoolean(MainApplication.FIREBASE, false));
connected.setChecked(prefs.getBoolean(MainApplication.PREF_FIREBASE, false));
String summary;
......@@ -835,7 +835,7 @@ public class SMSGateFragment extends PreferenceFragmentCompat implements MainAct
SharedPreferences prefs = android.support.v7.preference.PreferenceManager.getDefaultSharedPreferences(context);
if (!Storage.permitted(context, PERMISSIONS)) {
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(MainApplication.FIREBASE, false);
edit.putBoolean(MainApplication.PREF_FIREBASE, false);
edit.putBoolean(CONNECTED.key, false);
edit.commit();
AuthPreferences authPreferences = new AuthPreferences(context);
......@@ -853,7 +853,7 @@ public class SMSGateFragment extends PreferenceFragmentCompat implements MainAct
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(MainApplication.PREFERENCE_WIFI)) {
if (key.equals(MainApplication.PREF_WIFI)) {
updateFirebase();
}
}
......
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