1
0
mirror of https://github.com/nerzhul/ownCloud-SMS-App.git synced 2025-06-07 16:06:18 +00:00

Rename SmsFetcher to AndroidSmsFetcher

This commit is contained in:
Loic Blot 2016-12-06 20:37:22 +01:00
parent ce88024258
commit 65c2b9b99f
5 changed files with 24 additions and 21 deletions

View File

@ -48,8 +48,8 @@ import org.json.JSONArray;
import fr.unix_experience.owncloud_sms.R;
import fr.unix_experience.owncloud_sms.activities.remote_account.AccountListActivity;
import fr.unix_experience.owncloud_sms.engine.ASyncSMSSync.SyncTask;
import fr.unix_experience.owncloud_sms.engine.AndroidSmsFetcher;
import fr.unix_experience.owncloud_sms.engine.ConnectivityMonitor;
import fr.unix_experience.owncloud_sms.engine.SmsFetcher;
import fr.unix_experience.owncloud_sms.enums.OCSMSNotificationType;
import fr.unix_experience.owncloud_sms.enums.PermissionID;
import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationUI;
@ -137,7 +137,7 @@ public class MainActivity extends AppCompatActivity
if (MainActivity.mConnectivityMonitor.isValid()) {
// Now fetch messages since last stored date
JSONArray smsList = new JSONArray();
new SmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
new AndroidSmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
if (smsList.length() > 0) {
OCSMSNotificationUI.notify(ctx, ctx.getString(R.string.sync_title),

View File

@ -31,8 +31,8 @@ import java.util.concurrent.atomic.AtomicReference;
import fr.unix_experience.owncloud_sms.R;
import fr.unix_experience.owncloud_sms.engine.ASyncSMSSync;
import fr.unix_experience.owncloud_sms.engine.AndroidSmsFetcher;
import fr.unix_experience.owncloud_sms.engine.ConnectivityMonitor;
import fr.unix_experience.owncloud_sms.engine.SmsFetcher;
import fr.unix_experience.owncloud_sms.enums.PermissionID;
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
import fr.unix_experience.owncloud_sms.prefs.PermissionChecker;
@ -83,7 +83,7 @@ public class ConnectivityChanged extends BroadcastReceiver implements ASyncSMSSy
// Now fetch messages since last stored date
JSONArray smsList = new JSONArray();
new SmsFetcher(context).bufferMessagesSinceDate(smsList, lastMessageSynced);
new AndroidSmsFetcher(context).bufferMessagesSinceDate(smsList, lastMessageSynced);
AtomicReference<ConnectivityMonitor> cMon = new AtomicReference<>(new ConnectivityMonitor(context));

View File

@ -28,8 +28,8 @@ import org.json.JSONObject;
import fr.unix_experience.owncloud_sms.enums.MailboxID;
import fr.unix_experience.owncloud_sms.providers.SmsDataProvider;
public class SmsFetcher {
public SmsFetcher(Context ct) {
public class AndroidSmsFetcher {
public AndroidSmsFetcher(Context ct) {
_lastMsgDate = (long) 0;
_context = ct;
@ -51,7 +51,7 @@ public class SmsFetcher {
if ((mbID != MailboxID.INBOX) && (mbID != MailboxID.SENT) &&
(mbID != MailboxID.DRAFTS)) {
Log.e(SmsFetcher.TAG, "Unhandled MailboxID " + mbID.ordinal());
Log.e(AndroidSmsFetcher.TAG, "Unhandled MailboxID " + mbID.ordinal());
return;
}
@ -77,12 +77,12 @@ public class SmsFetcher {
result.put(entry);
} catch (JSONException e) {
Log.e(SmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e);
Log.e(AndroidSmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e);
}
}
while (c.moveToNext());
Log.i(SmsFetcher.TAG, c.getCount() + " messages read from " + mbID.getURI());
Log.i(AndroidSmsFetcher.TAG, c.getCount() + " messages read from " + mbID.getURI());
c.close();
}
@ -120,7 +120,7 @@ public class SmsFetcher {
results.put(entry);
} catch (JSONException e) {
Log.e(SmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e);
Log.e(AndroidSmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e);
}
c.close();
@ -137,16 +137,16 @@ public class SmsFetcher {
// Used by ConnectivityChanged Event
private void bufferMessagesSinceDate(JSONArray result, MailboxID mbID, Long sinceDate) {
Log.i(SmsFetcher.TAG, "bufferMessagesSinceDate for " + mbID.toString() + " sinceDate " + sinceDate.toString());
Log.i(AndroidSmsFetcher.TAG, "bufferMessagesSinceDate for " + mbID.toString() + " sinceDate " + sinceDate.toString());
if ((_context == null)) {
return;
}
Cursor c = new SmsDataProvider(_context).queryMessagesSinceDate(mbID.getURI(), sinceDate);
if (c != null) {
Log.i(SmsFetcher.TAG, "Retrieved " + c.getCount() + " messages.");
Log.i(AndroidSmsFetcher.TAG, "Retrieved " + c.getCount() + " messages.");
} else {
Log.i(SmsFetcher.TAG, "No message retrieved.");
Log.i(AndroidSmsFetcher.TAG, "No message retrieved.");
return;
}
@ -162,12 +162,12 @@ public class SmsFetcher {
entry.put("mbox", mbID.ordinal());
result.put(entry);
} catch (JSONException e) {
Log.e(SmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e);
Log.e(AndroidSmsFetcher.TAG, "JSON Exception when reading SMS Mailbox", e);
}
}
while (c.moveToNext());
Log.i(SmsFetcher.TAG, c.getCount() + " messages read from " + mbID.getURI());
Log.i(AndroidSmsFetcher.TAG, c.getCount() + " messages read from " + mbID.getURI());
c.close();
}
@ -184,7 +184,7 @@ public class SmsFetcher {
return c.getInt(idx);
/* For debug purpose
case "length(address)":
Log.i(SmsFetcher.TAG, "Column name " + colName + " " + c.getString(idx));
Log.i(AndroidSmsFetcher.TAG, "Column name " + colName + " " + c.getString(idx));
break;*/
// Seen and read must be pseudo boolean
case "read":
@ -241,10 +241,13 @@ public class SmsFetcher {
void setExistingInboxMessages(JSONArray inboxMessages) {
_existingInboxMessages = inboxMessages;
}
void setExistingSentMessages(JSONArray sentMessages) {
_existingSentMessages = sentMessages;
}
void setExistingDraftsMessages(JSONArray draftMessages) { _existingDraftsMessages = draftMessages; }
void setExistingDraftsMessages(JSONArray draftMessages) {
_existingDraftsMessages = draftMessages;
}
Long getLastMessageDate() {
return _lastMsgDate;
@ -257,5 +260,5 @@ public class SmsFetcher {
private Long _lastMsgDate;
private static final String TAG = SmsFetcher.class.getSimpleName();
private static final String TAG = AndroidSmsFetcher.class.getSimpleName();
}

View File

@ -149,7 +149,7 @@ public class OCSMSOwnCloudClient {
Log.i(OCSMSOwnCloudClient.TAG, "No drafts Sms received from server (doPushRequest, get SMS list)");
}
SmsFetcher fetcher = new SmsFetcher(_context);
AndroidSmsFetcher fetcher = new AndroidSmsFetcher(_context);
fetcher.setExistingInboxMessages(inboxSmsList);
fetcher.setExistingSentMessages(sentSmsList);
fetcher.setExistingDraftsMessages(draftsSmsList);

View File

@ -29,9 +29,9 @@ import org.json.JSONArray;
import fr.unix_experience.owncloud_sms.R;
import fr.unix_experience.owncloud_sms.engine.ASyncSMSSync;
import fr.unix_experience.owncloud_sms.engine.AndroidSmsFetcher;
import fr.unix_experience.owncloud_sms.engine.ConnectivityMonitor;
import fr.unix_experience.owncloud_sms.engine.OCSMSOwnCloudClient;
import fr.unix_experience.owncloud_sms.engine.SmsFetcher;
import fr.unix_experience.owncloud_sms.enums.MailboxID;
import fr.unix_experience.owncloud_sms.enums.PermissionID;
import fr.unix_experience.owncloud_sms.prefs.PermissionChecker;
@ -59,7 +59,7 @@ public class SmsObserver extends ContentObserver implements ASyncSMSSync {
return;
}
SmsFetcher fetcher = new SmsFetcher(_context);
AndroidSmsFetcher fetcher = new AndroidSmsFetcher(_context);
JSONArray smsList = fetcher.getLastMessage(MailboxID.ALL);
ConnectivityMonitor cMon = new ConnectivityMonitor(_context);