mirror of
				https://github.com/nerzhul/ownCloud-SMS-App.git
				synced 2025-10-29 17:37:33 +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"> |         android:theme="@style/OcSmsTheme"> | ||||||
| 
 | 
 | ||||||
|         <!-- Related to periodic sync --> |         <!-- Related to periodic sync --> | ||||||
|         <service |  | ||||||
|             android:name=".observers.SmsObserverService" |  | ||||||
|             android:exported="false"/> |  | ||||||
|         <service |         <service | ||||||
|             android:name=".sync_adapters.SmsSyncService" |             android:name=".sync_adapters.SmsSyncService" | ||||||
|             android:exported="true" |             android:exported="true" | ||||||
|  | |||||||
| @ -134,7 +134,6 @@ public class MainActivity extends AppCompatActivity | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 		Context ctx = getApplicationContext(); | 		Context ctx = getApplicationContext(); | ||||||
| 
 |  | ||||||
| 		if (MainActivity.mConnectivityMonitor.isValid()) { | 		if (MainActivity.mConnectivityMonitor.isValid()) { | ||||||
| 			// Now fetch messages since last stored date | 			// Now fetch messages since last stored date | ||||||
| 			JSONArray smsList = new JSONArray(); | 			JSONArray smsList = new JSONArray(); | ||||||
| @ -145,6 +144,9 @@ public class MainActivity extends AppCompatActivity | |||||||
|                         ctx.getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal()); |                         ctx.getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal()); | ||||||
| 				new SyncTask(getApplicationContext(), smsList).execute(); | 				new SyncTask(getApplicationContext(), smsList).execute(); | ||||||
| 			} | 			} | ||||||
|  |             else { | ||||||
|  |                 Toast.makeText(ctx, ctx.getString(R.string.nothing_to_sync), Toast.LENGTH_SHORT).show(); | ||||||
|  |             } | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			Toast.makeText(ctx, ctx.getString(R.string.err_sync_no_connection_available), Toast.LENGTH_SHORT).show(); | 			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 class SmsSyncAdapter extends AbstractThreadedSyncAdapter { | ||||||
| 
 | 
 | ||||||
| 	public SmsSyncAdapter(final Context context, final boolean autoInitialize) { | 	public SmsSyncAdapter(Context context, boolean autoInitialize) { | ||||||
| 		super(context, autoInitialize); | 		super(context, autoInitialize); | ||||||
| 		_accountMgr = AccountManager.get(context); | 		_accountMgr = AccountManager.get(context); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public void onPerformSync(final Account account, final Bundle extras, final String authority, | 	public void onPerformSync(Account account, Bundle extras, String authority, | ||||||
| 			final ContentProviderClient provider, final SyncResult syncResult) { |                               ContentProviderClient provider, SyncResult syncResult) { | ||||||
| 		// Create client | 		// Create client | ||||||
| 		final String ocURI = _accountMgr.getUserData(account, "ocURI"); | 		String ocURI = _accountMgr.getUserData(account, "ocURI"); | ||||||
| 		if (ocURI == null) { | 		if (ocURI == null) { | ||||||
|             OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.fatal_error), |             OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.fatal_error), | ||||||
|                      getContext().getString(R.string.err_sync_account_unparsable), |                      getContext().getString(R.string.err_sync_account_unparsable), | ||||||
| @ -53,22 +53,22 @@ public class SmsSyncAdapter extends AbstractThreadedSyncAdapter { | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		final Uri serverURI = Uri.parse(ocURI); | 		Uri serverURI = Uri.parse(ocURI); | ||||||
|         OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.sync_title), |         OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.sync_title), | ||||||
|                 getContext().getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal()); |                 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"), | 				serverURI, _accountMgr.getUserData(account, "ocLogin"), | ||||||
| 				_accountMgr.getPassword(account)); | 				_accountMgr.getPassword(account)); | ||||||
| 
 | 
 | ||||||
| 		try { | 		try { | ||||||
| 			// getServerAPI version | 			// getServerAPI version | ||||||
| 			Log.d(TAG, "Server API version: " + _client.getServerAPIVersion()); | 			Log.d(SmsSyncAdapter.TAG, "Server API version: " + _client.getServerAPIVersion()); | ||||||
| 
 | 
 | ||||||
| 			// and push datas | 			// and push datas | ||||||
| 			_client.doPushRequest(null); | 			_client.doPushRequest(null); | ||||||
|             OCSMSNotificationUI.cancel(getContext()); |             OCSMSNotificationUI.cancel(getContext()); | ||||||
| 		} catch (final OCSyncException e) { | 		} catch (OCSyncException e) { | ||||||
|             OCSMSNotificationUI.cancel(getContext()); |             OCSMSNotificationUI.cancel(getContext()); | ||||||
|             OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.fatal_error), |             OCSMSNotificationUI.notify(getContext(), getContext().getString(R.string.fatal_error), | ||||||
|                     getContext().getString(e.getErrorId()), OCSMSNotificationType.SYNC_FAILED.ordinal()); |                     getContext().getString(e.getErrorId()), OCSMSNotificationType.SYNC_FAILED.ordinal()); | ||||||
| @ -82,7 +82,7 @@ public class SmsSyncAdapter extends AbstractThreadedSyncAdapter { | |||||||
| 				syncResult.stats.numAuthExceptions++; | 				syncResult.stats.numAuthExceptions++; | ||||||
| 			} | 			} | ||||||
| 			else { | 			else { | ||||||
| 				// UNHANDLED | 				Log.w(SmsSyncAdapter.TAG, "onPerformSync: unhandled response"); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -171,5 +171,6 @@ | |||||||
|     <string name="restore_all_messages">Restore all messages</string> |     <string name="restore_all_messages">Restore all messages</string> | ||||||
|     <string name="account_actions">Account actions</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="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> | </resources> | ||||||
|  | |||||||
| @ -158,4 +158,5 @@ | |||||||
|     <string name="restore_all_messages">Restaurer tous les messages</string> |     <string name="restore_all_messages">Restaurer tous les messages</string> | ||||||
|     <string name="account_actions">Actions du compte</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="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> | </resources> | ||||||
|  | |||||||
| @ -206,4 +206,5 @@ | |||||||
|     <string name="restore_all_messages">Restore all messages</string> |     <string name="restore_all_messages">Restore all messages</string> | ||||||
|     <string name="account_actions">Account actions</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="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> | </resources> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user