mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-05 19:41:57 +02:00
allow to "move to top" accounts in the account selector
This commit is contained in:
parent
15ed570dce
commit
1d7d0dd329
3 changed files with 35 additions and 0 deletions
|
@ -164,6 +164,10 @@ public class Rpc {
|
|||
return gson.fromJson(getResult("create_broadcast", accountId, chatName), Integer.class);
|
||||
}
|
||||
|
||||
public void setAccountsOrder(List<Integer> order) throws RpcException {
|
||||
getResult("set_accounts_order", order);
|
||||
}
|
||||
|
||||
private static class Request {
|
||||
private final String jsonrpc = "2.0";
|
||||
public final String method;
|
||||
|
|
|
@ -41,6 +41,8 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
|||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AccountSelectionListFragment extends DialogFragment implements DcEventCenter.DcEventDelegate
|
||||
{
|
||||
private static final String TAG = AccountSelectionListFragment.class.getSimpleName();
|
||||
|
@ -134,9 +136,35 @@ public class AccountSelectionListFragment extends DialogFragment implements DcEv
|
|||
onToggleMute(accountId);
|
||||
} else if (itemId == R.id.menu_set_tag) {
|
||||
onSetTag(accountId);
|
||||
} else if (itemId == R.id.menu_move_to_top) {
|
||||
onMoveToTop(accountId);
|
||||
}
|
||||
}
|
||||
|
||||
private void onMoveToTop(int accountId) {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
|
||||
int[] accountIds = DcHelper.getAccounts(activity).getAll();
|
||||
Integer[] ids = new Integer[accountIds.length];
|
||||
ids[0] = accountId;
|
||||
int j = 1;
|
||||
for (int accId : accountIds) {
|
||||
if (accId != accountId) {
|
||||
ids[j++] = accId;
|
||||
}
|
||||
}
|
||||
|
||||
Rpc rpc = DcHelper.getRpc(activity);
|
||||
try {
|
||||
rpc.setAccountsOrder(Arrays.asList(ids));
|
||||
} catch (RpcException e) {
|
||||
Log.e(TAG, "Error calling rpc.setAccountsOrder()", e);
|
||||
}
|
||||
|
||||
refreshData();
|
||||
}
|
||||
|
||||
private void onSetTag(int accountId) {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
<item android:title="@string/profile_tag"
|
||||
android:id="@+id/menu_set_tag"/>
|
||||
|
||||
<item android:title="@string/move_to_top"
|
||||
android:id="@+id/menu_move_to_top"/>
|
||||
|
||||
<item android:title="@string/delete"
|
||||
android:id="@+id/delete"/>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue