allow to schedule with another account
This commit is contained in:
parent
ffcb75cc74
commit
4edaa45986
|
@ -1878,16 +1878,18 @@ public abstract class BasePixelfedComposeActivity extends BaseActivity implement
|
|||
|
||||
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String userId = accountReply!=null?accountReply.getId():account.getId();
|
||||
String instance = accountReply!=null?accountReply.getInstance():account.getInstance();
|
||||
try {
|
||||
if (currentToId == -1) {
|
||||
currentToId = new StatusStoredDAO(BasePixelfedComposeActivity.this, db).insertStatus(toot, null);
|
||||
currentToId = new StatusStoredDAO(BasePixelfedComposeActivity.this, db).insertStatus(toot, null, userId, instance);
|
||||
|
||||
} else {
|
||||
StoredStatus storedStatus = new StatusStoredDAO(BasePixelfedComposeActivity.this, db).getStatus(currentToId);
|
||||
if (storedStatus != null) {
|
||||
new StatusStoredDAO(BasePixelfedComposeActivity.this, db).updateStatus(currentToId, toot);
|
||||
} else { //Might have been deleted, so it needs insertion
|
||||
new StatusStoredDAO(BasePixelfedComposeActivity.this, db).insertStatus(toot, null);
|
||||
new StatusStoredDAO(BasePixelfedComposeActivity.this, db).insertStatus(toot, null, userId, instance);
|
||||
}
|
||||
}
|
||||
if (message)
|
||||
|
|
|
@ -2051,7 +2051,7 @@ public abstract class BaseTootActivity extends BaseActivity implements UploadSta
|
|||
}
|
||||
else {
|
||||
toot.setScheduled_at(timestamp);
|
||||
new PostStatusAsyncTask(BaseTootActivity.this, social, account, toot, BaseTootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new PostStatusAsyncTask(BaseTootActivity.this, social, accountReply!=null?accountReply:account, toot, BaseTootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2126,9 +2126,6 @@ public abstract class BaseTootActivity extends BaseActivity implements UploadSta
|
|||
MenuItem itemRestore = menu.findItem(R.id.action_restore);
|
||||
if (itemRestore != null)
|
||||
itemRestore.setVisible(false);
|
||||
MenuItem itemSchedule = menu.findItem(R.id.action_schedule);
|
||||
if (itemSchedule != null)
|
||||
itemSchedule.setVisible(false);
|
||||
MenuItem itemStore = menu.findItem(R.id.action_store);
|
||||
if (itemStore != null)
|
||||
itemStore.setVisible(false);
|
||||
|
@ -3478,16 +3475,18 @@ public abstract class BaseTootActivity extends BaseActivity implements UploadSta
|
|||
if (tootReply != null)
|
||||
toot.setIn_reply_to_id(tootReply.getId());
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
//TODO: insert should be done with connected account
|
||||
String userId = accountReply!=null?accountReply.getId():account.getId();
|
||||
String instance = accountReply!=null?accountReply.getInstance():account.getInstance();
|
||||
try {
|
||||
if (currentToId == -1) {
|
||||
currentToId = new StatusStoredDAO(BaseTootActivity.this, db).insertStatus(toot, tootReply);
|
||||
|
||||
currentToId = new StatusStoredDAO(BaseTootActivity.this, db).insertStatus(toot, tootReply, userId, instance);
|
||||
} else {
|
||||
StoredStatus storedStatus = new StatusStoredDAO(BaseTootActivity.this, db).getStatus(currentToId);
|
||||
if (storedStatus != null) {
|
||||
new StatusStoredDAO(BaseTootActivity.this, db).updateStatus(currentToId, toot);
|
||||
} else { //Might have been deleted, so it needs insertion
|
||||
new StatusStoredDAO(BaseTootActivity.this, db).insertStatus(toot, tootReply);
|
||||
new StatusStoredDAO(BaseTootActivity.this, db).insertStatus(toot, tootReply, userId, instance);
|
||||
}
|
||||
}
|
||||
if (message)
|
||||
|
|
|
@ -45,6 +45,9 @@ public class StatusStoredDAO {
|
|||
this.db = db;
|
||||
}
|
||||
|
||||
public long insertStatus(Status status, Status statusReply) {
|
||||
return insertStatus(status, statusReply, null, null);
|
||||
}
|
||||
|
||||
//------- INSERTIONS -------
|
||||
|
||||
|
@ -54,13 +57,15 @@ public class StatusStoredDAO {
|
|||
* @param status Status
|
||||
* @return boolean
|
||||
*/
|
||||
public long insertStatus(Status status, Status statusReply) {
|
||||
public long insertStatus(Status status, Status statusReply, String userId, String instance) {
|
||||
ContentValues values = new ContentValues();
|
||||
String serializedStatus = Helper.statusToStringStorage(status);
|
||||
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = Helper.getLiveInstance(context);
|
||||
if( instance == null || userId == null) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
instance = Helper.getLiveInstance(context);
|
||||
}
|
||||
if (userId == null || instance == null)
|
||||
return -1;
|
||||
if (statusReply != null) {
|
||||
|
|
Loading…
Reference in New Issue