mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
show currently selected account in switch menu
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
<string name="def">Default</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="none">None</string>
|
||||
<string name="current">Current</string>
|
||||
<string name="automatic">Automatic</string>
|
||||
<string name="strict">Strict</string>
|
||||
<string name="open">Open</string>
|
||||
|
||||
@@ -268,7 +268,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
// build menu
|
||||
ArrayList<String> menu = new ArrayList<>();
|
||||
for (AccountManager.Account account : accounts) {
|
||||
menu.add(account.getDescr());
|
||||
menu.add(account.getDescr(this));
|
||||
}
|
||||
|
||||
int addAccount = menu.size();
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.annotation.Nullable;
|
||||
import com.b44t.messenger.DcContext;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -22,7 +23,8 @@ public class AccountManager {
|
||||
private String displayname;
|
||||
private String addr;
|
||||
private boolean configured;
|
||||
public String getDescr() {
|
||||
private boolean current;
|
||||
public String getDescr(Context context) {
|
||||
String ret = "";
|
||||
if (!displayname.isEmpty() && !addr.isEmpty()) {
|
||||
ret = String.format("%s (%s)", displayname, addr);
|
||||
@@ -34,6 +36,9 @@ public class AccountManager {
|
||||
if (!configured) {
|
||||
ret += " (not configured)";
|
||||
}
|
||||
if (current) {
|
||||
ret += " (" + context.getString(R.string.current) + ")";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
@@ -90,12 +95,18 @@ public class AccountManager {
|
||||
public ArrayList<Account> getAccounts(Context context) {
|
||||
ArrayList<Account> result = new ArrayList<>();
|
||||
|
||||
String dbName = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getString("curr_account_db_name", "messenger.db");
|
||||
|
||||
try {
|
||||
File dir = context.getFilesDir();
|
||||
File[] files = dir.listFiles();
|
||||
for (File file : files) {
|
||||
Account account = maybeGetAccount(file);
|
||||
if (account!=null) {
|
||||
if (account.dbName.equals(dbName)) {
|
||||
account.current = true;
|
||||
}
|
||||
result.add(account);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user