mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-08 16:36:10 +00:00
Sync now: add a toast to give feedback about nothing to sync
SmsSyncAdapter: make android studio happy Drop .observers.SmsObserverService which is unused
This commit is contained in:
parent
08b54f8aa0
commit
c934f0deeb
@ -36,9 +36,6 @@
|
||||
android:theme="@style/OcSmsTheme">
|
||||
|
||||
<!-- Related to periodic sync -->
|
||||
<service
|
||||
android:name=".observers.SmsObserverService"
|
||||
android:exported="false"/>
|
||||
<service
|
||||
android:name=".sync_adapters.SmsSyncService"
|
||||
android:exported="true"
|
||||
|
@ -134,7 +134,6 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
Context ctx = getApplicationContext();
|
||||
|
||||
if (MainActivity.mConnectivityMonitor.isValid()) {
|
||||
// Now fetch messages since last stored date
|
||||
JSONArray smsList = new JSONArray();
|
||||
@ -145,6 +144,9 @@ public class MainActivity extends AppCompatActivity
|
||||
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 {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.err_sync_no_connection_available), Toast.LENGTH_SHORT).show();
|
||||
|
@ -36,16 +36,16 @@ import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationUI;
|
||||
|
||||
public class SmsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
|
||||
public SmsSyncAdapter(final Context context, final boolean autoInitialize) {
|
||||
public SmsSyncAdapter(Context context, boolean autoInitialize) {
|
||||
super(context, autoInitialize);
|
||||
_accountMgr = AccountManager.get(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPerformSync(final Account account, final Bundle extras, final String authority,
|
||||
final ContentProviderClient provider, final SyncResult syncResult) {
|
||||
public void onPerformSync(Account account, Bundle extras, String authority,
|
||||
ContentProviderClient provider, SyncResult syncResult) {
|
||||
// Create client
|
||||
final String ocURI = _accountMgr.getUserData(account, "ocURI");
|
||||
String ocURI = _accountMgr.getUserData(account, "ocURI");
|
||||
if (ocURI == null) {
|
||||
OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.fatal_error),
|
||||
getContext().getString(R.string.err_sync_account_unparsable),
|
||||
@ -53,22 +53,22 @@ public class SmsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
return;
|
||||
}
|
||||
|
||||
final Uri serverURI = Uri.parse(ocURI);
|
||||
Uri serverURI = Uri.parse(ocURI);
|
||||
OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.sync_title),
|
||||
getContext().getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal());
|
||||
|
||||
final OCSMSOwnCloudClient _client = new OCSMSOwnCloudClient(getContext(),
|
||||
OCSMSOwnCloudClient _client = new OCSMSOwnCloudClient(getContext(),
|
||||
serverURI, _accountMgr.getUserData(account, "ocLogin"),
|
||||
_accountMgr.getPassword(account));
|
||||
|
||||
try {
|
||||
// getServerAPI version
|
||||
Log.d(TAG, "Server API version: " + _client.getServerAPIVersion());
|
||||
Log.d(SmsSyncAdapter.TAG, "Server API version: " + _client.getServerAPIVersion());
|
||||
|
||||
// and push datas
|
||||
_client.doPushRequest(null);
|
||||
OCSMSNotificationUI.cancel(getContext());
|
||||
} catch (final OCSyncException e) {
|
||||
} catch (OCSyncException e) {
|
||||
OCSMSNotificationUI.cancel(getContext());
|
||||
OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.fatal_error),
|
||||
getContext().getString(e.getErrorId()), OCSMSNotificationType.SYNC_FAILED.ordinal());
|
||||
@ -82,7 +82,7 @@ public class SmsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
syncResult.stats.numAuthExceptions++;
|
||||
}
|
||||
else {
|
||||
// UNHANDLED
|
||||
Log.w(SmsSyncAdapter.TAG, "onPerformSync: unhandled response");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,5 +171,6 @@
|
||||
<string name="restore_all_messages">Restore all messages</string>
|
||||
<string name="account_actions">Account actions</string>
|
||||
<string name="error_connection_failed_not_found">Connection failed, the server returns 404 NOT FOUND. Ensure you set the correct path for your ownCloud instance.</string>
|
||||
<string name="nothing_to_sync">There is nothing to sync.</string>
|
||||
|
||||
</resources>
|
||||
|
@ -158,4 +158,5 @@
|
||||
<string name="restore_all_messages">Restaurer tous les messages</string>
|
||||
<string name="account_actions">Actions du compte</string>
|
||||
<string name="error_connection_failed_not_found">Echec de connexion, le serveur a retourné 404 NON TROUVE. Assurez vous d\'avoir spécifié la bonne URL.</string>
|
||||
<string name="nothing_to_sync">Il n\'y a rien à synchroniser.</string>
|
||||
</resources>
|
||||
|
@ -206,4 +206,5 @@
|
||||
<string name="restore_all_messages">Restore all messages</string>
|
||||
<string name="account_actions">Account actions</string>
|
||||
<string name="error_connection_failed_not_found">Connection failed, the server returns 404 NOT FOUND. Ensure you set the correct path for your ownCloud instance.</string>
|
||||
<string name="nothing_to_sync">There is nothing to sync.</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user