mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-26 01:06:34 +00:00
Add prefs class to manage shared preferences
This commit is contained in:
parent
504eb1baca
commit
63bdbf35fd
@ -43,6 +43,7 @@ import com.owncloud.android.lib.common.OwnCloudCredentialsFactory;
|
|||||||
import fr.unix_experience.owncloud_sms.R;
|
import fr.unix_experience.owncloud_sms.R;
|
||||||
import fr.unix_experience.owncloud_sms.enums.OCSyncErrorType;
|
import fr.unix_experience.owncloud_sms.enums.OCSyncErrorType;
|
||||||
import fr.unix_experience.owncloud_sms.exceptions.OCSyncException;
|
import fr.unix_experience.owncloud_sms.exceptions.OCSyncException;
|
||||||
|
import fr.unix_experience.owncloud_sms.prefs.OCSMSSharedPrefs;
|
||||||
|
|
||||||
public class OCSMSOwnCloudClient {
|
public class OCSMSOwnCloudClient {
|
||||||
|
|
||||||
@ -172,10 +173,7 @@ public class OCSMSOwnCloudClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Push was OK, we can save the lastMessageDate which was saved to server
|
// Push was OK, we can save the lastMessageDate which was saved to server
|
||||||
SharedPreferences sharedPref = _context.getSharedPreferences(_context.getString(R.string.shared_preference_file), Context.MODE_PRIVATE);
|
(new OCSMSSharedPrefs(_context)).setLastMessageDate(lastMsgDate);
|
||||||
SharedPreferences.Editor editor = sharedPref.edit();
|
|
||||||
editor.putLong(_context.getString(R.string.pref_lastmsgdate), lastMsgDate);
|
|
||||||
editor.commit();
|
|
||||||
|
|
||||||
Log.d(TAG, "SMS Push request said: status " + pushStatus + " - " + pushMessage);
|
Log.d(TAG, "SMS Push request said: status " + pushStatus + " - " + pushMessage);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package fr.unix_experience.owncloud_sms.prefs;
|
||||||
|
|
||||||
|
import fr.unix_experience.owncloud_sms.R;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
public class OCSMSSharedPrefs {
|
||||||
|
|
||||||
|
public OCSMSSharedPrefs(Context context) {
|
||||||
|
_context = context;
|
||||||
|
|
||||||
|
_sPrefs = _context.getSharedPreferences(_context.getString(R.string.shared_preference_file), Context.MODE_PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastMessageDate(Long msgDate) {
|
||||||
|
SharedPreferences.Editor editor = _sPrefs.edit();
|
||||||
|
editor.putLong(_context.getString(R.string.pref_lastmsgdate), msgDate);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLastMessageDate() {
|
||||||
|
return _sPrefs.getLong(_context.getString(R.string.pref_lastmsgdate), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SharedPreferences _sPrefs;
|
||||||
|
private Context _context;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user