mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-19 13:56:28 +00:00
parent
ceba0324e1
commit
1d45d0a318
@ -54,6 +54,7 @@ import fr.unix_experience.owncloud_sms.engine.ConnectivityMonitor;
|
||||
import fr.unix_experience.owncloud_sms.enums.OCSMSNotificationType;
|
||||
import fr.unix_experience.owncloud_sms.enums.PermissionID;
|
||||
import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationUI;
|
||||
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
|
||||
import fr.unix_experience.owncloud_sms.prefs.PermissionChecker;
|
||||
|
||||
import static fr.unix_experience.owncloud_sms.enums.PermissionID.REQUEST_MAX;
|
||||
@ -204,21 +205,27 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
Context ctx = getApplicationContext();
|
||||
if (_ConnectivityMonitor.isValid()) {
|
||||
// Now fetch messages since last stored date
|
||||
JSONArray smsList = new JSONArray();
|
||||
new AndroidSmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
|
||||
|
||||
if (smsList.length() > 0) {
|
||||
OCSMSNotificationUI.notify(ctx, ctx.getString(R.string.sync_title),
|
||||
ctx.getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal());
|
||||
new SyncTask(getApplicationContext(), smsList).execute();
|
||||
} else {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.nothing_to_sync), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
if (!_ConnectivityMonitor.isValid()) {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.err_sync_no_connection_available), Toast.LENGTH_SHORT).show();
|
||||
Log.v(MainActivity.TAG, "Finish syncAllMessages(): invalid connection");
|
||||
return;
|
||||
}
|
||||
|
||||
// Now fetch messages since last stored date
|
||||
JSONArray smsList = new JSONArray();
|
||||
new AndroidSmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
|
||||
|
||||
if (smsList.length() == 0) {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.nothing_to_sync), Toast.LENGTH_SHORT).show();
|
||||
Log.v(MainActivity.TAG, "Finish syncAllMessages(): no sms");
|
||||
return;
|
||||
}
|
||||
|
||||
if (new OCSMSSharedPrefs(this).showSyncNotifications()) {
|
||||
OCSMSNotificationUI.notify(ctx, ctx.getString(R.string.sync_title),
|
||||
ctx.getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal());
|
||||
}
|
||||
new SyncTask(getApplicationContext(), smsList).execute();
|
||||
Log.v(MainActivity.TAG, "Finish syncAllMessages()");
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,7 @@ public class OCSMSSettingsActivity extends VirtualSettingsActivity {
|
||||
|
||||
// Bind our boolean preferences
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("push_on_receive", DefaultPrefs.pushOnReceive));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("show_sync_notifications", DefaultPrefs.showSyncNotifications));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_wifi", DefaultPrefs.syncWifi));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_4g", DefaultPrefs.sync4G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_3g", DefaultPrefs.sync3G));
|
||||
@ -95,7 +96,7 @@ public class OCSMSSettingsActivity extends VirtualSettingsActivity {
|
||||
|
||||
protected void handleCheckboxPreference(String key, Boolean value) {
|
||||
// Network types allowed for sync
|
||||
if ("push_on_receive".equals(key) ||
|
||||
if ("push_on_receive".equals(key) || "show_sync_notifications".equals(key) ||
|
||||
"sync_wifi".equals(key) || "sync_2g".equals(key) ||
|
||||
"sync_3g".equals(key) || "sync_gprs".equals(key) ||
|
||||
"sync_4g".equals(key) || "sync_others".equals(key)) {
|
||||
|
@ -4,6 +4,7 @@ public class DefaultPrefs {
|
||||
public final static Integer syncInterval = 15;
|
||||
public final static Integer minimumCharsForSync = 0;
|
||||
public final static Boolean pushOnReceive = true;
|
||||
public final static Boolean showSyncNotifications = true;
|
||||
|
||||
public final static Boolean syncWifi = true;
|
||||
public final static Boolean sync2G = true;
|
||||
|
@ -43,6 +43,10 @@ public class OCSMSSharedPrefs extends SharedPrefs {
|
||||
return _sPrefs.getBoolean("push_on_receive", DefaultPrefs.pushOnReceive);
|
||||
}
|
||||
|
||||
public Boolean showSyncNotifications() {
|
||||
return _sPrefs.getBoolean("show_sync_notifications", DefaultPrefs.showSyncNotifications);
|
||||
}
|
||||
|
||||
public Boolean syncInWifi() {
|
||||
return _sPrefs.getBoolean("sync_wifi", DefaultPrefs.syncWifi);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import fr.unix_experience.owncloud_sms.enums.OCSMSNotificationType;
|
||||
import fr.unix_experience.owncloud_sms.enums.OCSyncErrorType;
|
||||
import fr.unix_experience.owncloud_sms.exceptions.OCSyncException;
|
||||
import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationUI;
|
||||
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
|
||||
|
||||
class SmsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
|
||||
@ -41,8 +42,11 @@ class SmsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
@Override
|
||||
public void onPerformSync(Account account, Bundle extras, String authority,
|
||||
ContentProviderClient provider, SyncResult syncResult) {
|
||||
OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.sync_title),
|
||||
getContext().getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal());
|
||||
|
||||
if (new OCSMSSharedPrefs(getContext()).showSyncNotifications()) {
|
||||
OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.sync_title),
|
||||
getContext().getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal());
|
||||
}
|
||||
|
||||
try {
|
||||
OCSMSOwnCloudClient _client = new OCSMSOwnCloudClient(getContext(), account);
|
||||
|
@ -181,4 +181,5 @@
|
||||
<string name="reinit_sync_cursor_confirm">Are you sure you want to reinitialise the synchronisation cursor ? This can slowdown the next synchronisation if we found many old messages not synced with server.</string>
|
||||
<string name="yes_confirm">Yes</string>
|
||||
<string name="no_confirm">No</string>
|
||||
<string name="pref_show_sync_notifications">Show sync notifications</string>
|
||||
</resources>
|
||||
|
@ -157,5 +157,6 @@
|
||||
<string name="reinit_sync_cursor_confirm">Are you sure you want to reinitialize the synchronization cursor ? This can slowdown the next synchronisation if we found many old messages not synced with server.</string>
|
||||
<string name="yes_confirm">Yes</string>
|
||||
<string name="no_confirm">No</string>
|
||||
<string name="pref_show_sync_notifications">Show sync notifications</string>
|
||||
|
||||
</resources>
|
||||
|
@ -181,4 +181,5 @@
|
||||
<string name="reinit_sync_cursor_confirm">Êtes-vous sûr de vouloir réinitialiser le curseur de synchronisation ? Cela peut ralentir la prochaine synchronisation si nous trouvons de nombreux anciens messages non synchronisés avec le serveur.</string>
|
||||
<string name="yes_confirm">Oui</string>
|
||||
<string name="no_confirm">Non</string>
|
||||
<string name="pref_show_sync_notifications">Afficher les notifications de synchronisation</string>
|
||||
</resources>
|
||||
|
@ -258,4 +258,5 @@
|
||||
<string name="reinit_sync_cursor_confirm">Are you sure you want to reinitialize the synchronization cursor ? This can slowdown the next synchronisation if we found many old messages not synced with server.</string>
|
||||
<string name="yes_confirm">Yes</string>
|
||||
<string name="no_confirm">No</string>
|
||||
<string name="pref_show_sync_notifications">Show sync notifications</string>
|
||||
</resources>
|
||||
|
@ -31,6 +31,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:key="push_on_receive"
|
||||
android:title="@string/pref_push_on_receive" />
|
||||
<CheckBoxPreference android:id="@+id/checkbox_show_sync_notifications"
|
||||
android:defaultValue="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:key="show_sync_notifications"
|
||||
android:title="@string/pref_show_sync_notifications" />
|
||||
<CheckBoxPreference android:id="@+id/checkbox_sync_wifi"
|
||||
android:defaultValue="true"
|
||||
android:layout_width="wrap_content"
|
||||
|
Loading…
x
Reference in New Issue
Block a user