mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-28 03:25:18 +03:00
Store account token in database
This commit is contained in:
parent
1c3db28fc5
commit
cf886e4490
3 changed files with 6 additions and 5 deletions
|
@ -118,7 +118,8 @@ public class NoteSQLiteOpenHelper extends SQLiteOpenHelper {
|
|||
key_url + " TEXT, " +
|
||||
key_username + " TEXT, " +
|
||||
key_account_name + " TEXT UNIQUE, " +
|
||||
key_display_name + " TEXT)");
|
||||
key_display_name + " TEXT, " +
|
||||
key_token + " TEXT)");
|
||||
createAccountIndexes(db);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,12 +79,12 @@ public class NoteServerSyncHelper {
|
|||
public void updateAccount(){
|
||||
try {
|
||||
this.localAccount = dbHelper.getLocalAccountByAccountName(SingleAccountHelper.getCurrentSingleSignOnAccount(appContext).name);
|
||||
notesClient.updateAccount(localAccount.getToken());
|
||||
Log.v("Notes", "NextcloudRequest account: " + localAccount);
|
||||
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.v("Note", "Reinstanziation NotesClient because of SSO acc changed");
|
||||
notesClient.updateAccount();
|
||||
};
|
||||
|
||||
private final BroadcastReceiver networkReceiver = new BroadcastReceiver() {
|
||||
|
@ -112,6 +112,7 @@ public class NoteServerSyncHelper {
|
|||
this.appContext = db.getContext().getApplicationContext();
|
||||
try {
|
||||
this.localAccount = db.getLocalAccountByAccountName(SingleAccountHelper.getCurrentSingleSignOnAccount(appContext).name);
|
||||
notesClient = new NotesClient(appContext, localAccount.getToken());
|
||||
Log.v("Notes", "NextcloudRequest account: " + localAccount);
|
||||
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -120,7 +121,6 @@ public class NoteServerSyncHelper {
|
|||
|
||||
// Registers BroadcastReceiver to track network connection changes.
|
||||
appContext.registerReceiver(networkReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||
notesClient = new NotesClient(appContext);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.appContext);
|
||||
prefs.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class NotesClient {
|
|||
public static final String JSON_MODIFIED = "modified";
|
||||
private static final String application_json = "application/json";
|
||||
|
||||
public NotesClient(Context context) {
|
||||
public NotesClient(Context context, String token) {
|
||||
this.context = context;
|
||||
try {
|
||||
SingleSignOnAccount ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(context);
|
||||
|
@ -95,7 +95,7 @@ public class NotesClient {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateAccount() {
|
||||
public void updateAccount(String token) {
|
||||
if(mNextcloudAPI != null) {
|
||||
mNextcloudAPI.stop();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue