Show if primary account is connected

pull/145/head
M66B 6 years ago
parent b87389f4bd
commit 13ed886739

@ -80,6 +80,7 @@ public class FragmentMessages extends FragmentEx {
private String search = null;
private long primary = -1;
private boolean connected = false;
private AdapterMessage adapter;
private AdapterMessage.ViewType viewType;
@ -400,6 +401,7 @@ public class FragmentMessages extends FragmentEx {
@Override
public void onChanged(EntityAccount account) {
primary = (account == null ? -1 : account.id);
connected = (account != null && "connected".equals(account.state));
getActivity().invalidateOptionsMenu();
}
});
@ -587,6 +589,7 @@ public class FragmentMessages extends FragmentEx {
menu.findItem(R.id.menu_search).setVisible(folder >= 0 && search == null);
menu.findItem(R.id.menu_sort_on).setVisible(TextUtils.isEmpty(search));
menu.findItem(R.id.menu_folders).setVisible(primary >= 0);
menu.findItem(R.id.menu_folders).setIcon(connected ? R.drawable.baseline_folder_24 : R.drawable.baseline_folder_open_24);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String sort = prefs.getString("sort", "time");

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,6h-8l-2,-2L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM20,18L4,18L4,8h16v10z"/>
</vector>

@ -31,7 +31,7 @@
<item
android:id="@+id/menu_folders"
android:icon="@drawable/baseline_folder_24"
android:icon="@drawable/baseline_folder_open_24"
android:title="@string/title_folder_primary"
app:showAsAction="ifRoom" />
</menu>

Loading…
Cancel
Save