mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-10 01:16:15 +00:00
Rename SmsFetcher to AndroidSmsFetcher
This commit is contained in:
parent
ce88024258
commit
65c2b9b99f
@ -48,8 +48,8 @@ import org.json.JSONArray;
|
|||||||
import fr.unix_experience.owncloud_sms.R;
|
import fr.unix_experience.owncloud_sms.R;
|
||||||
import fr.unix_experience.owncloud_sms.activities.remote_account.AccountListActivity;
|
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.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.ConnectivityMonitor;
|
||||||
import fr.unix_experience.owncloud_sms.engine.SmsFetcher;
|
|
||||||
import fr.unix_experience.owncloud_sms.enums.OCSMSNotificationType;
|
import fr.unix_experience.owncloud_sms.enums.OCSMSNotificationType;
|
||||||
import fr.unix_experience.owncloud_sms.enums.PermissionID;
|
import fr.unix_experience.owncloud_sms.enums.PermissionID;
|
||||||
import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationUI;
|
import fr.unix_experience.owncloud_sms.notifications.OCSMSNotificationUI;
|
||||||
@ -137,7 +137,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
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();
|
||||||
new SmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
|
new AndroidSmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
|
||||||
|
|
||||||
if (smsList.length() > 0) {
|
if (smsList.length() > 0) {
|
||||||
OCSMSNotificationUI.notify(ctx, ctx.getString(R.string.sync_title),
|
OCSMSNotificationUI.notify(ctx, ctx.getString(R.string.sync_title),
|
||||||
|
@ -31,8 +31,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
|
|
||||||
import fr.unix_experience.owncloud_sms.R;
|
import fr.unix_experience.owncloud_sms.R;
|
||||||
import fr.unix_experience.owncloud_sms.engine.ASyncSMSSync;
|
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.ConnectivityMonitor;
|
||||||
import fr.unix_experience.owncloud_sms.engine.SmsFetcher;
|
|
||||||
import fr.unix_experience.owncloud_sms.enums.PermissionID;
|
import fr.unix_experience.owncloud_sms.enums.PermissionID;
|
||||||
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
|
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
|
||||||
import fr.unix_experience.owncloud_sms.prefs.PermissionChecker;
|
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
|
// Now fetch messages since last stored date
|
||||||
JSONArray smsList = new JSONArray();
|
JSONArray smsList = new JSONArray();
|
||||||
new SmsFetcher(context).bufferMessagesSinceDate(smsList, lastMessageSynced);
|
new AndroidSmsFetcher(context).bufferMessagesSinceDate(smsList, lastMessageSynced);
|
||||||
|
|
||||||
AtomicReference<ConnectivityMonitor> cMon = new AtomicReference<>(new ConnectivityMonitor(context));
|
AtomicReference<ConnectivityMonitor> cMon = new AtomicReference<>(new ConnectivityMonitor(context));
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ import org.json.JSONObject;
|
|||||||
import fr.unix_experience.owncloud_sms.enums.MailboxID;
|
import fr.unix_experience.owncloud_sms.enums.MailboxID;
|
||||||
import fr.unix_experience.owncloud_sms.providers.SmsDataProvider;
|
import fr.unix_experience.owncloud_sms.providers.SmsDataProvider;
|
||||||
|
|
||||||
public class SmsFetcher {
|
public class AndroidSmsFetcher {
|
||||||
public SmsFetcher(Context ct) {
|
public AndroidSmsFetcher(Context ct) {
|
||||||
_lastMsgDate = (long) 0;
|
_lastMsgDate = (long) 0;
|
||||||
_context = ct;
|
_context = ct;
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public class SmsFetcher {
|
|||||||
|
|
||||||
if ((mbID != MailboxID.INBOX) && (mbID != MailboxID.SENT) &&
|
if ((mbID != MailboxID.INBOX) && (mbID != MailboxID.SENT) &&
|
||||||
(mbID != MailboxID.DRAFTS)) {
|
(mbID != MailboxID.DRAFTS)) {
|
||||||
Log.e(SmsFetcher.TAG, "Unhandled MailboxID " + mbID.ordinal());
|
Log.e(AndroidSmsFetcher.TAG, "Unhandled MailboxID " + mbID.ordinal());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,12 +77,12 @@ public class SmsFetcher {
|
|||||||
result.put(entry);
|
result.put(entry);
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} 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());
|
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();
|
c.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ public class SmsFetcher {
|
|||||||
|
|
||||||
results.put(entry);
|
results.put(entry);
|
||||||
} catch (JSONException e) {
|
} 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();
|
c.close();
|
||||||
@ -137,16 +137,16 @@ public class SmsFetcher {
|
|||||||
|
|
||||||
// Used by ConnectivityChanged Event
|
// Used by ConnectivityChanged Event
|
||||||
private void bufferMessagesSinceDate(JSONArray result, MailboxID mbID, Long sinceDate) {
|
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)) {
|
if ((_context == null)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor c = new SmsDataProvider(_context).queryMessagesSinceDate(mbID.getURI(), sinceDate);
|
Cursor c = new SmsDataProvider(_context).queryMessagesSinceDate(mbID.getURI(), sinceDate);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
Log.i(SmsFetcher.TAG, "Retrieved " + c.getCount() + " messages.");
|
Log.i(AndroidSmsFetcher.TAG, "Retrieved " + c.getCount() + " messages.");
|
||||||
} else {
|
} else {
|
||||||
Log.i(SmsFetcher.TAG, "No message retrieved.");
|
Log.i(AndroidSmsFetcher.TAG, "No message retrieved.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,12 +162,12 @@ public class SmsFetcher {
|
|||||||
entry.put("mbox", mbID.ordinal());
|
entry.put("mbox", mbID.ordinal());
|
||||||
result.put(entry);
|
result.put(entry);
|
||||||
} catch (JSONException e) {
|
} 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());
|
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();
|
c.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ public class SmsFetcher {
|
|||||||
return c.getInt(idx);
|
return c.getInt(idx);
|
||||||
/* For debug purpose
|
/* For debug purpose
|
||||||
case "length(address)":
|
case "length(address)":
|
||||||
Log.i(SmsFetcher.TAG, "Column name " + colName + " " + c.getString(idx));
|
Log.i(AndroidSmsFetcher.TAG, "Column name " + colName + " " + c.getString(idx));
|
||||||
break;*/
|
break;*/
|
||||||
// Seen and read must be pseudo boolean
|
// Seen and read must be pseudo boolean
|
||||||
case "read":
|
case "read":
|
||||||
@ -241,10 +241,13 @@ public class SmsFetcher {
|
|||||||
void setExistingInboxMessages(JSONArray inboxMessages) {
|
void setExistingInboxMessages(JSONArray inboxMessages) {
|
||||||
_existingInboxMessages = inboxMessages;
|
_existingInboxMessages = inboxMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setExistingSentMessages(JSONArray sentMessages) {
|
void setExistingSentMessages(JSONArray sentMessages) {
|
||||||
_existingSentMessages = sentMessages;
|
_existingSentMessages = sentMessages;
|
||||||
}
|
}
|
||||||
void setExistingDraftsMessages(JSONArray draftMessages) { _existingDraftsMessages = draftMessages; }
|
void setExistingDraftsMessages(JSONArray draftMessages) {
|
||||||
|
_existingDraftsMessages = draftMessages;
|
||||||
|
}
|
||||||
|
|
||||||
Long getLastMessageDate() {
|
Long getLastMessageDate() {
|
||||||
return _lastMsgDate;
|
return _lastMsgDate;
|
||||||
@ -257,5 +260,5 @@ public class SmsFetcher {
|
|||||||
|
|
||||||
private Long _lastMsgDate;
|
private Long _lastMsgDate;
|
||||||
|
|
||||||
private static final String TAG = SmsFetcher.class.getSimpleName();
|
private static final String TAG = AndroidSmsFetcher.class.getSimpleName();
|
||||||
}
|
}
|
@ -149,7 +149,7 @@ public class OCSMSOwnCloudClient {
|
|||||||
Log.i(OCSMSOwnCloudClient.TAG, "No drafts Sms received from server (doPushRequest, get SMS list)");
|
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.setExistingInboxMessages(inboxSmsList);
|
||||||
fetcher.setExistingSentMessages(sentSmsList);
|
fetcher.setExistingSentMessages(sentSmsList);
|
||||||
fetcher.setExistingDraftsMessages(draftsSmsList);
|
fetcher.setExistingDraftsMessages(draftsSmsList);
|
||||||
|
@ -29,9 +29,9 @@ import org.json.JSONArray;
|
|||||||
|
|
||||||
import fr.unix_experience.owncloud_sms.R;
|
import fr.unix_experience.owncloud_sms.R;
|
||||||
import fr.unix_experience.owncloud_sms.engine.ASyncSMSSync;
|
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.ConnectivityMonitor;
|
||||||
import fr.unix_experience.owncloud_sms.engine.OCSMSOwnCloudClient;
|
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.MailboxID;
|
||||||
import fr.unix_experience.owncloud_sms.enums.PermissionID;
|
import fr.unix_experience.owncloud_sms.enums.PermissionID;
|
||||||
import fr.unix_experience.owncloud_sms.prefs.PermissionChecker;
|
import fr.unix_experience.owncloud_sms.prefs.PermissionChecker;
|
||||||
@ -59,7 +59,7 @@ public class SmsObserver extends ContentObserver implements ASyncSMSSync {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SmsFetcher fetcher = new SmsFetcher(_context);
|
AndroidSmsFetcher fetcher = new AndroidSmsFetcher(_context);
|
||||||
JSONArray smsList = fetcher.getLastMessage(MailboxID.ALL);
|
JSONArray smsList = fetcher.getLastMessage(MailboxID.ALL);
|
||||||
|
|
||||||
ConnectivityMonitor cMon = new ConnectivityMonitor(_context);
|
ConnectivityMonitor cMon = new ConnectivityMonitor(_context);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user