Fix issue with unique id
This commit is contained in:
parent
1694fb63a1
commit
1cb3e414b6
|
@ -1210,12 +1210,13 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
Bundle extras = intent.getExtras();
|
||||
String userIdIntent;
|
||||
String userIdIntent, instanceIntent;
|
||||
if( extras != null && extras.containsKey(Helper.INTENT_ACTION) ){
|
||||
final NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
userIdIntent = extras.getString(Helper.PREF_KEY_ID); //Id of the account in the intent
|
||||
instanceIntent = extras.getString(Helper.PREF_INSTANCE);
|
||||
if (extras.getInt(Helper.INTENT_ACTION) == Helper.NOTIFICATION_INTENT){
|
||||
Helper.changeUser(BaseMainActivity.this, userIdIntent, true); //Connects the account which is related to the notification
|
||||
Helper.changeUser(BaseMainActivity.this, userIdIntent, instanceIntent,true); //Connects the account which is related to the notification
|
||||
Helper.unCheckAllMenuItems(navigationView);
|
||||
notificationChecked = true;
|
||||
if( extras.getString(Helper.INTENT_TARGETED_ACCOUNT) != null ){
|
||||
|
@ -1263,7 +1264,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
tabLayout.setVisibility(View.GONE);
|
||||
toolbarTitle.setText(instance);
|
||||
}else if( extras.getInt(Helper.INTENT_ACTION) == Helper.HOME_TIMELINE_INTENT){
|
||||
Helper.changeUser(BaseMainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
|
||||
Helper.changeUser(BaseMainActivity.this, userIdIntent, instanceIntent,false); //Connects the account which is related to the notification
|
||||
}else if( extras.getInt(Helper.INTENT_ACTION) == Helper.BACK_TO_SETTINGS){
|
||||
Helper.unCheckAllMenuItems(navigationView);
|
||||
navigationView.setCheckedItem(R.id.nav_settings);
|
||||
|
@ -1736,7 +1737,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
finish();
|
||||
}else {
|
||||
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
Helper.updateHeaderAccountInfo(activity, account, headerLayout);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,8 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
|
|||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(getApplicationContext(),db).getUniqAccount(userId, instance);
|
||||
String url = account.getAvatar();
|
||||
if( url.startsWith("/") ){
|
||||
url = Helper.getLiveInstanceWithProtocol(getApplicationContext()) + account.getAvatar();
|
||||
|
|
|
@ -153,7 +153,8 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(getApplicationContext(),db).getUniqAccount(userId, instance);
|
||||
String url = account.getAvatar();
|
||||
if( url.startsWith("/") ){
|
||||
url = Helper.getLiveInstanceWithProtocol(getApplicationContext()) + account.getAvatar();
|
||||
|
@ -172,7 +173,6 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
|||
set_header_picture_overlay = findViewById(R.id.set_header_picture_overlay);
|
||||
set_lock_account = findViewById(R.id.set_lock_account);
|
||||
set_sensitive_content = findViewById(R.id.set_sensitive_content);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
||||
String instanceVersion = sharedpreferences.getString(Helper.INSTANCE_VERSION + userId + instance, null);
|
||||
Version currentVersion = new Version(instanceVersion);
|
||||
Version minVersion = new Version("2.3");
|
||||
|
|
|
@ -163,6 +163,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
boolean isOnWifi = Helper.isOnWIFI(OwnerStatusActivity.this);
|
||||
lv_status.addItemDecoration(new DividerItemDecoration(OwnerStatusActivity.this, DividerItemDecoration.VERTICAL));
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
statusListAdapter = new StatusListAdapter(OwnerStatusActivity.this, RetrieveFeedsAsyncTask.Type.CACHE_STATUS, userId, isOnWifi, this.statuses);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
mLayoutManager = new LinearLayoutManager(OwnerStatusActivity.this);
|
||||
|
@ -176,7 +177,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
|
|||
}
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(OwnerStatusActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(OwnerStatusActivity.this,db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(OwnerStatusActivity.this,db).getUniqAccount(userId, instance);
|
||||
String url = account.getAvatar();
|
||||
if( url.startsWith("/") ){
|
||||
url = Helper.getLiveInstanceWithProtocol(OwnerStatusActivity.this) + account.getAvatar();
|
||||
|
|
|
@ -360,8 +360,9 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
});
|
||||
//Timed muted account
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
final Account authenticatedAccount = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
||||
final Account authenticatedAccount = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
boolean isTimedMute = new TempMuteDAO(getApplicationContext(), db).isTempMuted(authenticatedAccount, accountId);
|
||||
if( isTimedMute){
|
||||
String date_mute = new TempMuteDAO(getApplicationContext(), db).getMuteDateByID(authenticatedAccount, accountId);
|
||||
|
|
|
@ -221,7 +221,8 @@ public class ShowConversationActivity extends BaseActivity implements OnRetriev
|
|||
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(getApplicationContext(),db).getUniqAccount(userId, instance);
|
||||
if( account.getAvatar() == null){
|
||||
Toasty.error(ShowConversationActivity.this,getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
|
|
|
@ -397,13 +397,16 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
|||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
String userIdReply;
|
||||
if (accountReply == null)
|
||||
String userIdReply, instanceReply;
|
||||
if (accountReply == null) {
|
||||
userIdReply = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
else
|
||||
instanceReply = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
}else {
|
||||
userIdReply = accountReply.getId();
|
||||
instanceReply = accountReply.getInstance();
|
||||
}
|
||||
if (accountReply == null)
|
||||
account = new AccountDAO(getApplicationContext(), db).getAccountByID(userIdReply);
|
||||
account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userIdReply, instanceReply);
|
||||
else
|
||||
account = accountReply;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ManagePlaylistsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(contextReference.get()));
|
||||
SQLiteDatabase db = Sqlite.getInstance(contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(contextReference.get(), db).getAccountByUserIDInstance(userId, instance);
|
||||
Account account = new AccountDAO(contextReference.get(), db).getUniqAccount(userId, instance);
|
||||
if (apiAction == action.GET_PLAYLIST) {
|
||||
apiResponse = new PeertubeAPI(contextReference.get()).getPlayists(account.getUsername());
|
||||
}else if(apiAction == action.GET_LIST_VIDEOS){
|
||||
|
|
|
@ -85,7 +85,8 @@ public class RetrieveAccountsForReplyAsyncTask extends AsyncTask<Void, Void, Voi
|
|||
final SharedPreferences sharedpreferences = this.contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account currentAccount = new AccountDAO(this.contextReference.get(), db).getAccountByID(userId);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account currentAccount = new AccountDAO(this.contextReference.get(), db).getUniqAccount(userId, instance);
|
||||
return acct != null && !acct.equals(currentAccount.getAcct()) && !addedAccounts.contains(acct);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public class UpdateAccountInfoByIDAsyncTask extends AsyncTask<Void, Void, Void>
|
|||
|
||||
SharedPreferences sharedpreferences = this.contextReference.get().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = null;
|
||||
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
|
||||
account = new API(this.contextReference.get()).verifyCredentials();
|
||||
|
@ -71,7 +72,7 @@ public class UpdateAccountInfoByIDAsyncTask extends AsyncTask<Void, Void, Void>
|
|||
SQLiteDatabase db = Sqlite.getInstance(this.contextReference.get(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
boolean userExists = new AccountDAO(this.contextReference.get(), db).userExist(account);
|
||||
if( userExists) {
|
||||
Account accountDb = new AccountDAO(this.contextReference.get(), db).getAccountByID(userId);
|
||||
Account accountDb = new AccountDAO(this.contextReference.get(), db).getUniqAccount(userId, instance);
|
||||
|
||||
if( accountDb != null){
|
||||
account.setInstance(accountDb.getInstance());
|
||||
|
|
|
@ -1443,7 +1443,7 @@ public class GNUAPI {
|
|||
//Current user
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account currentAccount = new AccountDAO(context, db).getAccountByUserIDInstance(userId, Helper.getLiveInstance(context));
|
||||
Account currentAccount = new AccountDAO(context, db).getUniqAccount(userId, Helper.getLiveInstance(context));
|
||||
params.put("user_id", currentAccount.getId());
|
||||
params.put("screen_name", currentAccount.getAcct());
|
||||
|
||||
|
|
|
@ -112,8 +112,9 @@ public class AccountsSearchAdapter extends ArrayAdapter<Account> implements Filt
|
|||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account currentAccount = new AccountDAO(context, db).getAccountByID(userId);
|
||||
String instance = (account.getInstance() !=null)?account.getInstance():currentAccount.getInstance();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account currentAccount = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
instance = (account.getInstance() !=null)?account.getInstance():currentAccount.getInstance();
|
||||
holder.account_un.setText(String.format("@%s", account.getUsername() + "@" + instance));
|
||||
holder.account_dn.setVisibility(View.GONE);
|
||||
}else {
|
||||
|
|
|
@ -1273,7 +1273,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
if (status.getAccount() == null) {
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
status.setAccount(account);
|
||||
}
|
||||
//Displays name & emoji in toot header
|
||||
|
@ -2438,7 +2439,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
String targeted_id = status.getAccount().getId();
|
||||
Date date_mute = new Date(time);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
new TempMuteDAO(context, db).insert(account, targeted_id, new Date(time));
|
||||
if (timedMute != null && !timedMute.contains(account.getId()))
|
||||
timedMute.add(targeted_id);
|
||||
|
|
|
@ -190,7 +190,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
nextElementLoader.setVisibility(View.GONE);
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, context!=null?Helper.getLiveInstance(context):null);
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
mutedAccount = new TempMuteDAO(context, db).getAllTimeMuted(account);
|
||||
|
||||
//For Home timeline, fetch stored values for bookmark and last read toot
|
||||
|
|
|
@ -72,7 +72,8 @@ public class CrossActions {
|
|||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<Account> accountstmp = new AccountDAO(context, db).getAllAccountCrossAction();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Account currentAccount = new AccountDAO(context, db).getAccountByID(userId);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account currentAccount = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
List<Account> accounts = new ArrayList<>();
|
||||
if( accountstmp != null && !limitedToOwner && accountstmp.size() > 1 ){
|
||||
//It's for a reply
|
||||
|
@ -111,7 +112,7 @@ public class CrossActions {
|
|||
return accounts;
|
||||
}else {
|
||||
List<Account> oneAccount = new ArrayList<>();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
oneAccount.add(account);
|
||||
return oneAccount;
|
||||
}
|
||||
|
@ -141,8 +142,9 @@ public class CrossActions {
|
|||
confirmation = false;
|
||||
if(type != null && type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && limitedToOwner){
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account currentAccount = new AccountDAO(context, db).getAccountByID(userId);
|
||||
Account currentAccount = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
if (confirmation)
|
||||
displayConfirmationDialogCrossAction(context, currentAccount, doAction, status, onPostActionInterface, baseAdapter);
|
||||
else {
|
||||
|
@ -232,8 +234,9 @@ public class CrossActions {
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
Account selectedAccount = accountArray[which];
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account loggedAccount = new AccountDAO(context, db).getAccountByID(userId);
|
||||
Account loggedAccount = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
if( targetedAccount == null){
|
||||
if(loggedAccount.getInstance().equals(selectedAccount.getInstance())){
|
||||
new PostActionAsyncTask(context, selectedAccount, doAction, status.getId(), onPostActionInterface).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -308,8 +311,9 @@ public class CrossActions {
|
|||
public static void doCrossProfile(final Context context, Account remoteAccount){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private WeakReference<Context> contextReference = new WeakReference<>(context);
|
||||
|
@ -357,8 +361,9 @@ public class CrossActions {
|
|||
public static void doCrossConversation(final Context context, Status remoteStatus){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private WeakReference<Context> contextReference = new WeakReference<>(context);
|
||||
|
@ -397,8 +402,9 @@ public class CrossActions {
|
|||
public static void doCrossConversation(final Context context, String url){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private WeakReference<Context> contextReference = new WeakReference<>(context);
|
||||
|
@ -632,8 +638,9 @@ public class CrossActions {
|
|||
}else{
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(context, db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private List<app.fedilab.android.client.Entities.Status> remoteStatuses;
|
||||
|
|
|
@ -1344,9 +1344,8 @@ public class Helper {
|
|||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if( ! activity.isFinishing() ) {
|
||||
menuAccountsOpened = false;
|
||||
String userId = account.getId();
|
||||
Toasty.info(activity, activity.getString(R.string.toast_account_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_LONG).show();
|
||||
changeUser(activity, userId, false);
|
||||
changeUser(activity, account.getId(), account.getInstance(), false);
|
||||
arrow.setImageResource(R.drawable.ic_arrow_drop_down);
|
||||
return true;
|
||||
}
|
||||
|
@ -1477,7 +1476,7 @@ public class Helper {
|
|||
* @param activity Activity
|
||||
* @param userID String - the new user id
|
||||
*/
|
||||
public static void changeUser(Activity activity, String userID, boolean notificationIntent) {
|
||||
public static void changeUser(Activity activity, String userID, String instance, boolean notificationIntent) {
|
||||
|
||||
|
||||
final NavigationView navigationView = activity.findViewById(R.id.nav_view);
|
||||
|
@ -1488,7 +1487,7 @@ public class Helper {
|
|||
hideMenuItem(navigationView.getMenu());
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(activity,db).getAccountByID(userID);
|
||||
Account account = new AccountDAO(activity,db).getUniqAccount(userID, instance);
|
||||
//Can happen when an account has been deleted and there is a click on an old notification
|
||||
if( account == null)
|
||||
return;
|
||||
|
@ -2874,8 +2873,9 @@ public class Helper {
|
|||
final NavigationView navigationView = activity.findViewById(R.id.nav_view);
|
||||
android.support.design.widget.TabLayout tableLayout = activity.findViewById(R.id.tabLayout);
|
||||
String userID = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(activity,db).getAccountByID(userID);
|
||||
Account account = new AccountDAO(activity,db).getUniqAccount(userID, instance);
|
||||
if( account != null) {
|
||||
if (account.isLocked()) {
|
||||
if( navigationView.getMenu().findItem(R.id.nav_follow_request) != null)
|
||||
|
@ -2886,8 +2886,6 @@ public class Helper {
|
|||
}
|
||||
|
||||
}
|
||||
//Check instance release for lists
|
||||
String instance = Helper.getLiveInstance(activity);
|
||||
String instanceVersion = sharedpreferences.getString(Helper.INSTANCE_VERSION + userID + instance, null);
|
||||
if (instanceVersion != null && navigationView.getMenu().findItem(R.id.nav_list) != null) {
|
||||
Version currentVersion = new Version(instanceVersion);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ScheduledBoostsSyncJob extends Job {
|
|||
String userId = storedStatus.getUserId();
|
||||
String instance = storedStatus.getInstance();
|
||||
if( instance != null && userId != null){
|
||||
Account account = new AccountDAO(getContext(), db).getAccountByUserIDInstance(userId, instance);
|
||||
Account account = new AccountDAO(getContext(), db).getUniqAccount(userId, instance);
|
||||
if( account != null){
|
||||
//Retrieves the linked status to toot
|
||||
Status status = storedStatus.getStatus();
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ScheduledTootsSyncJob extends Job {
|
|||
String userId = storedStatus.getUserId();
|
||||
String instance = storedStatus.getInstance();
|
||||
if( instance != null && userId != null){
|
||||
Account account = new AccountDAO(getContext(), db).getAccountByUserIDInstance(userId, instance);
|
||||
Account account = new AccountDAO(getContext(), db).getUniqAccount(userId, instance);
|
||||
if( account != null){
|
||||
//Retrieves the linked status to toot
|
||||
Status status = storedStatus.getStatus();
|
||||
|
|
|
@ -94,8 +94,9 @@ public class BackupStatusInDataBaseService extends IntentService {
|
|||
String message;
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(BackupStatusInDataBaseService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
API api = new API(getApplicationContext(), account.getInstance(), account.getToken());
|
||||
try {
|
||||
//Starts from the last recorded ID
|
||||
|
|
|
@ -101,8 +101,9 @@ public class BackupStatusService extends IntentService {
|
|||
String message;
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
SQLiteDatabase db = Sqlite.getInstance(BackupStatusService.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
||||
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
API api = new API(getApplicationContext(), account.getInstance(), account.getToken());
|
||||
try {
|
||||
String fullPath;
|
||||
|
|
|
@ -389,6 +389,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT);
|
||||
intent.putExtra(Helper.PREF_KEY_ID, account.getId());
|
||||
intent.putExtra(Helper.PREF_INSTANCE, account.getInstance());
|
||||
if (targeted_account != null) {
|
||||
intent.putExtra(Helper.INTENT_TARGETED_ACCOUNT, targeted_account);
|
||||
}
|
||||
|
|
|
@ -93,10 +93,11 @@ public class StreamingFederatedTimelineService extends IntentService {
|
|||
protected void onHandleIntent(@Nullable Intent intent) {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account accountStream = null;
|
||||
if( userId != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
||||
accountStream = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
}
|
||||
if( accountStream != null) {
|
||||
Headers headers = new Headers();
|
||||
|
|
|
@ -93,10 +93,11 @@ public class StreamingHomeTimelineService extends IntentService {
|
|||
protected void onHandleIntent(@Nullable Intent intent) {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account accountStream = null;
|
||||
if( userId != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
||||
accountStream = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
}
|
||||
if( accountStream != null) {
|
||||
Headers headers = new Headers();
|
||||
|
|
|
@ -93,10 +93,11 @@ public class StreamingLocalTimelineService extends IntentService {
|
|||
protected void onHandleIntent(@Nullable Intent intent) {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account accountStream = null;
|
||||
if( userId != null) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
accountStream = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
||||
accountStream = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
|
||||
}
|
||||
|
||||
if( accountStream != null) {
|
||||
|
|
|
@ -86,7 +86,7 @@ public class AccountDAO {
|
|||
values.put(Sqlite.COL_PRIVACY, account.getPrivacy());
|
||||
//Inserts account
|
||||
try{
|
||||
db.insert(Sqlite.TABLE_USER_ACCOUNT, null, values);
|
||||
db.insertOrThrow(Sqlite.TABLE_USER_ACCOUNT, null, values);
|
||||
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -120,7 +120,6 @@ public class AccountDAO {
|
|||
values.put(Sqlite.COL_HEADER,account.getHeader());
|
||||
values.put(Sqlite.COL_HEADER_STATIC,account.getHeader_static());
|
||||
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreated_at()));
|
||||
values.put(Sqlite.COL_INSTANCE, account.getInstance());
|
||||
values.put(Sqlite.COL_EMOJIS, Helper.emojisToStringStorage(account.getEmojis()));
|
||||
values.put(Sqlite.COL_SOCIAL, account.getSocial());
|
||||
if( account.getClient_id() != null && account.getClient_secret() != null && account.getRefresh_token() != null) {
|
||||
|
@ -131,8 +130,8 @@ public class AccountDAO {
|
|||
if( account.getToken() != null)
|
||||
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
|
||||
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
||||
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_USERNAME + " =?",
|
||||
new String[]{account.getId(), account.getUsername()});
|
||||
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =?",
|
||||
new String[]{account.getId(), account.getInstance()});
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,7 +160,6 @@ public class AccountDAO {
|
|||
values.put(Sqlite.COL_HEADER,account.getHeader());
|
||||
values.put(Sqlite.COL_HEADER_STATIC,account.getHeader_static());
|
||||
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreated_at()));
|
||||
values.put(Sqlite.COL_INSTANCE, account.getInstance());
|
||||
values.put(Sqlite.COL_EMOJIS, Helper.emojisToStringStorage(account.getEmojis()));
|
||||
values.put(Sqlite.COL_SOCIAL, account.getSocial());
|
||||
if( account.getClient_id() != null && account.getClient_secret() != null && account.getRefresh_token() != null) {
|
||||
|
@ -174,30 +172,16 @@ public class AccountDAO {
|
|||
values.put(Sqlite.COL_SENSITIVE, account.isSensitive());
|
||||
values.put(Sqlite.COL_PRIVACY, account.getPrivacy());
|
||||
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
||||
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_USERNAME + " =?",
|
||||
new String[]{account.getId(), account.getUsername()});
|
||||
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =?",
|
||||
new String[]{account.getId(), account.getInstance()});
|
||||
}
|
||||
|
||||
|
||||
public int removeUser(Account account){
|
||||
return db.delete(Sqlite.TABLE_USER_ACCOUNT, Sqlite.COL_USER_ID + " = '" +account.getId() +
|
||||
"' AND " + Sqlite.COL_USERNAME + " = '" + account.getUsername()+ "'", null);
|
||||
"' AND " + Sqlite.COL_INSTANCE + " = '" + account.getInstance()+ "'", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Account by id
|
||||
* @param accountId String
|
||||
* @return Account
|
||||
*/
|
||||
public Account getAccountByID(String accountId){
|
||||
|
||||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, Sqlite.COL_USER_ID + " = '" + accountId + "'", null, null, null, null, "1");
|
||||
return cursorToUser(c);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last used account
|
||||
|
@ -228,20 +212,7 @@ public class AccountDAO {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Account by id and instance
|
||||
* @param accountId String
|
||||
* @param instance String
|
||||
* @return Account
|
||||
*/
|
||||
public Account getAccountByUserIDInstance(String accountId, String instance){
|
||||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, Sqlite.COL_USER_ID + " = '" + accountId + "' AND " + Sqlite.COL_INSTANCE + "= '"+ instance +"'", null, null, null, null, "1");
|
||||
return cursorToUser(c);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all Account in db
|
||||
|
@ -316,6 +287,7 @@ public class AccountDAO {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the current user is already stored in data base
|
||||
* @param account Account
|
||||
|
|
|
@ -45,7 +45,7 @@ import app.fedilab.android.R;
|
|||
|
||||
public class Sqlite extends SQLiteOpenHelper {
|
||||
|
||||
public static final int DB_VERSION = 31;
|
||||
public static final int DB_VERSION = 32;
|
||||
public static final String DB_NAME = "mastodon_etalab_db";
|
||||
public static SQLiteDatabase db;
|
||||
private static Sqlite sInstance;
|
||||
|
@ -55,6 +55,7 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
*/
|
||||
//Table of owned accounts
|
||||
static final String TABLE_USER_ACCOUNT = "USER_ACCOUNT";
|
||||
private static final String TABLE_USER_ACCOUNT_TEMP = "USER_ACCOUNT_TEMP";
|
||||
//Table of stored status
|
||||
static final String TABLE_STATUSES_STORED = "STATUSES_STORED";
|
||||
//Table for custom emoji
|
||||
|
@ -122,7 +123,7 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
static final String COL_SENSITIVE = "SENSITIVE";
|
||||
|
||||
private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " ("
|
||||
+ COL_USER_ID + " TEXT PRIMARY KEY, " + COL_USERNAME + " TEXT NOT NULL, " + COL_ACCT + " TEXT NOT NULL, "
|
||||
+ COL_USER_ID + " TEXT, " + COL_USERNAME + " TEXT NOT NULL, " + COL_ACCT + " TEXT NOT NULL, "
|
||||
+ COL_DISPLAYED_NAME + " TEXT NOT NULL, " + COL_LOCKED + " INTEGER NOT NULL, "
|
||||
+ COL_FOLLOWERS_COUNT + " INTEGER NOT NULL, " + COL_FOLLOWING_COUNT + " INTEGER NOT NULL, " + COL_STATUSES_COUNT + " INTEGER NOT NULL, "
|
||||
+ COL_NOTE + " TEXT NOT NULL, "+ COL_URL + " TEXT NOT NULL, "
|
||||
|
@ -421,6 +422,39 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
db.execSQL("ALTER TABLE " + TABLE_INSTANCES + " ADD COLUMN " + COL_TAGS + " TEXT");
|
||||
db.execSQL("ALTER TABLE " + TABLE_INSTANCES + " ADD COLUMN " + COL_FILTERED_WITH + " TEXT");
|
||||
}
|
||||
case 31:
|
||||
String CREATE_TABLE_USER_ACCOUNT_TEMP = "CREATE TABLE " + TABLE_USER_ACCOUNT_TEMP + " ("
|
||||
+ COL_USER_ID + " TEXT, " + COL_USERNAME + " TEXT NOT NULL, " + COL_ACCT + " TEXT NOT NULL, "
|
||||
+ COL_DISPLAYED_NAME + " TEXT NOT NULL, " + COL_LOCKED + " INTEGER NOT NULL, "
|
||||
+ COL_FOLLOWERS_COUNT + " INTEGER NOT NULL, " + COL_FOLLOWING_COUNT + " INTEGER NOT NULL, " + COL_STATUSES_COUNT + " INTEGER NOT NULL, "
|
||||
+ COL_NOTE + " TEXT NOT NULL, "+ COL_URL + " TEXT NOT NULL, "
|
||||
+ COL_AVATAR + " TEXT NOT NULL, "+ COL_AVATAR_STATIC + " TEXT NOT NULL, "
|
||||
+ COL_HEADER + " TEXT NOT NULL, "+ COL_HEADER_STATIC + " TEXT NOT NULL, "
|
||||
+ COL_EMOJIS + " TEXT, "
|
||||
+ COL_SOCIAL + " TEXT, "
|
||||
+ COL_IS_MODERATOR + " INTEGER DEFAULT 0, "
|
||||
+ COL_IS_ADMIN + " INTEGER DEFAULT 0, "
|
||||
+ COL_CLIENT_ID + " TEXT, " + COL_CLIENT_SECRET + " TEXT, " + COL_REFRESH_TOKEN + " TEXT,"
|
||||
+ COL_UPDATED_AT + " TEXT, "
|
||||
+ COL_PRIVACY + " TEXT, "
|
||||
+ COL_SENSITIVE + " INTEGER DEFAULT 0, "
|
||||
+ COL_INSTANCE + " TEXT NOT NULL, " + COL_OAUTHTOKEN + " TEXT NOT NULL, " + COL_CREATED_AT + " TEXT NOT NULL)";
|
||||
db.execSQL(CREATE_TABLE_USER_ACCOUNT_TEMP);
|
||||
|
||||
String insert = "INSERT INTO "+TABLE_USER_ACCOUNT_TEMP+" ("
|
||||
+COL_USER_ID+", "+COL_USERNAME+", "+COL_ACCT+", "+COL_DISPLAYED_NAME+", "+COL_LOCKED+", "+COL_FOLLOWERS_COUNT+", "
|
||||
+COL_FOLLOWING_COUNT+", "+COL_STATUSES_COUNT+", "+COL_NOTE+", "+COL_URL+", "+COL_AVATAR+", "+COL_AVATAR_STATIC+", "
|
||||
+COL_HEADER+", "+COL_HEADER_STATIC+", "+COL_EMOJIS+", "+COL_SOCIAL+", "+COL_IS_MODERATOR+", "+COL_IS_ADMIN+", "
|
||||
+COL_CLIENT_ID+", "+COL_CLIENT_SECRET+", "+COL_REFRESH_TOKEN+", "+COL_UPDATED_AT+", "+COL_PRIVACY+", "+COL_SENSITIVE+", "
|
||||
+COL_INSTANCE+", "+COL_OAUTHTOKEN+", "+COL_CREATED_AT+") "
|
||||
+" SELECT "+COL_USER_ID+", "+COL_USERNAME+", "+COL_ACCT+", "+COL_DISPLAYED_NAME+", "+COL_LOCKED+", "+COL_FOLLOWERS_COUNT+", "
|
||||
+COL_FOLLOWING_COUNT+", "+COL_STATUSES_COUNT+", "+COL_NOTE+", "+COL_URL+", "+COL_AVATAR+", "+COL_AVATAR_STATIC+", "
|
||||
+COL_HEADER+", "+COL_HEADER_STATIC+", "+COL_EMOJIS+", "+COL_SOCIAL+", "+COL_IS_MODERATOR+", "+COL_IS_ADMIN+", "
|
||||
+COL_CLIENT_ID+", "+COL_CLIENT_SECRET+", "+COL_REFRESH_TOKEN+", "+COL_UPDATED_AT+", "+COL_PRIVACY+", "+COL_SENSITIVE+", "
|
||||
+COL_INSTANCE+", "+COL_OAUTHTOKEN+", "+COL_CREATED_AT+ " FROM " + TABLE_USER_ACCOUNT;
|
||||
db.execSQL(insert);
|
||||
db.execSQL("DROP TABLE "+TABLE_USER_ACCOUNT);
|
||||
db.execSQL("ALTER TABLE "+TABLE_USER_ACCOUNT_TEMP + " RENAME TO "+ TABLE_USER_ACCOUNT);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue