Commit 20cf5a9c authored by axet's avatar axet 🍄

Merge branch 'smsgate-1.8.17'

parents 317e9e7b afecc363
Pipeline #19455599 passed with stage
in 16 seconds
......@@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.smsgate"
minSdkVersion 9
targetSdkVersion 23
versionCode 200
versionName "1.8.16"
versionCode 201
versionName "1.8.17"
}
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.13' // compile project(':android-library')
compile 'com.github.axet:android-library:1.22.7' // 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'
......
......@@ -1206,7 +1206,7 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
}
public int messages() {
QueryBuilder b = new QueryBuilder(this);
final QueryBuilder b = new QueryBuilder(this);
BackupItemsFetcher fetcher = new BackupItemsFetcher(this, getContentResolver(), b);
BackupCursors cursors = new BulkFetcher(fetcher).fetch(EnumSet.of(DataType.SMS), -1);
......@@ -1488,28 +1488,53 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
}
void info() {
try {
JSONObject json = new JSONObject();
json.put("uptime", Long.toString(SystemClock.elapsedRealtime()));
json.put("os", Build.BRAND + " " + android.os.Build.VERSION.RELEASE);
json.put("sim", sim.getCount());
json.put("battery", getBatteryLevel());
if (phone.isTelephony())
json.put("signal", getSignalLevel());
info.setValue(new Message(keyPair.encrypt(json.toString()))).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "info updated");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "info failed update");
final QueryBuilder b = new QueryBuilder(this);
info.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Message m = dataSnapshot.getValue(Message.class);
try {
long l = 0;
if (m != null) {
String t = m.getText();
if (t != null) {
String text = keyPair.decrypt(t);
JSONObject obj = new JSONObject(text);
l = obj.optLong("last", 0);
}
}
if (l <= 0) { // force reupload all
b.setLastSMS(l);
messages();
}
final JSONObject json = new JSONObject();
json.put("uptime", Long.toString(SystemClock.elapsedRealtime()));
json.put("os", Build.BRAND + " " + android.os.Build.VERSION.RELEASE);
json.put("sim", sim.getCount());
json.put("battery", getBatteryLevel());
json.put("last", b.getLastSMS());
if (phone.isTelephony())
json.put("signal", getSignalLevel());
info.setValue(new Message(keyPair.encrypt(json.toString()))).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "info updated");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "info failed update");
}
});
} catch (JSONException e) {
throw new RuntimeException(e);
}
});
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
String getBatteryLevel() {
......
......@@ -12,6 +12,7 @@ import android.os.Build;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.EditTextPreference;
import android.support.v7.view.WindowCallbackWrapper;
import android.support.v7.widget.SwitchCompat;
import android.util.AttributeSet;
import android.view.ActionMode;
......@@ -218,132 +219,12 @@ public class ApplicationsPreference extends EditTextPreference {
});
Window w = d.getWindow();
final Window.Callback c = w.getCallback();
w.setCallback(new Window.Callback() {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
return c.dispatchKeyEvent(event);
}
@TargetApi(11)
@Override
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
return c.dispatchKeyShortcutEvent(event);
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
return c.dispatchTouchEvent(event);
}
@Override
public boolean dispatchTrackballEvent(MotionEvent event) {
return c.dispatchTrackballEvent(event);
}
@TargetApi(12)
@Override
public boolean dispatchGenericMotionEvent(MotionEvent event) {
return c.dispatchGenericMotionEvent(event);
}
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
return c.dispatchPopulateAccessibilityEvent(event);
}
@Nullable
@Override
public View onCreatePanelView(int featureId) {
return c.onCreatePanelView(featureId);
}
@Override
public boolean onCreatePanelMenu(int featureId, Menu menu) {
return c.onCreatePanelMenu(featureId, menu);
}
@Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {
return c.onPreparePanel(featureId, view, menu);
}
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
return c.onMenuOpened(featureId, menu);
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
return c.onMenuItemSelected(featureId, item);
}
@Override
public void onWindowAttributesChanged(WindowManager.LayoutParams attrs) {
c.onWindowAttributesChanged(attrs);
}
@Override
public void onContentChanged() {
c.onContentChanged();
}
w.setCallback(new WindowCallbackWrapper(c) {
@Override
public void onWindowFocusChanged(boolean hasFocus) {
c.onWindowFocusChanged(hasFocus);
updateNeutral();
}
@Override
public void onAttachedToWindow() {
c.onAttachedToWindow();
}
@Override
public void onDetachedFromWindow() {
c.onDetachedFromWindow();
}
@Override
public void onPanelClosed(int featureId, Menu menu) {
c.onPanelClosed(featureId, menu);
}
@Override
public boolean onSearchRequested() {
return c.onSearchRequested();
}
@TargetApi(23)
@Override
public boolean onSearchRequested(SearchEvent searchEvent) {
return c.onSearchRequested(searchEvent);
}
@TargetApi(11)
@Nullable
@Override
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
return c.onWindowStartingActionMode(callback);
}
@TargetApi(23)
@Nullable
@Override
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) {
return c.onWindowStartingActionMode(callback, type);
}
@TargetApi(11)
@Override
public void onActionModeStarted(ActionMode mode) {
c.onActionModeStarted(mode);
}
@TargetApi(11)
@Override
public void onActionModeFinished(ActionMode mode) {
c.onActionModeFinished(mode);
}
});
d.show();
}
......
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