|
|
@ -44,6 +44,7 @@ import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.appcompat.widget.PopupMenu;
|
|
|
|
import androidx.appcompat.widget.PopupMenu;
|
|
|
|
import androidx.constraintlayout.widget.Group;
|
|
|
|
import androidx.constraintlayout.widget.Group;
|
|
|
|
|
|
|
|
import androidx.core.view.MenuCompat;
|
|
|
|
import androidx.fragment.app.FragmentTransaction;
|
|
|
|
import androidx.fragment.app.FragmentTransaction;
|
|
|
|
import androidx.lifecycle.Lifecycle;
|
|
|
|
import androidx.lifecycle.Lifecycle;
|
|
|
|
import androidx.lifecycle.Observer;
|
|
|
|
import androidx.lifecycle.Observer;
|
|
|
@ -67,6 +68,7 @@ public class FragmentAccounts extends FragmentBase {
|
|
|
|
private boolean settings;
|
|
|
|
private boolean settings;
|
|
|
|
|
|
|
|
|
|
|
|
private boolean cards;
|
|
|
|
private boolean cards;
|
|
|
|
|
|
|
|
private boolean compact;
|
|
|
|
|
|
|
|
|
|
|
|
private ViewGroup view;
|
|
|
|
private ViewGroup view;
|
|
|
|
private SwipeRefreshLayout swipeRefresh;
|
|
|
|
private SwipeRefreshLayout swipeRefresh;
|
|
|
@ -91,6 +93,7 @@ public class FragmentAccounts extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
cards = prefs.getBoolean("cards", true);
|
|
|
|
cards = prefs.getBoolean("cards", true);
|
|
|
|
|
|
|
|
compact = prefs.getBoolean("compact_accounts", false) && !settings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -212,7 +215,7 @@ public class FragmentAccounts extends FragmentBase {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
rvAccount.addItemDecoration(categoryDecorator);
|
|
|
|
rvAccount.addItemDecoration(categoryDecorator);
|
|
|
|
|
|
|
|
|
|
|
|
adapter = new AdapterAccount(this, settings);
|
|
|
|
adapter = new AdapterAccount(this, settings, compact);
|
|
|
|
rvAccount.setAdapter(adapter);
|
|
|
|
rvAccount.setAdapter(adapter);
|
|
|
|
|
|
|
|
|
|
|
|
fab.setOnClickListener(new View.OnClickListener() {
|
|
|
|
fab.setOnClickListener(new View.OnClickListener() {
|
|
|
@ -348,6 +351,7 @@ public class FragmentAccounts extends FragmentBase {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
|
inflater.inflate(R.menu.menu_accounts, menu);
|
|
|
|
inflater.inflate(R.menu.menu_accounts, menu);
|
|
|
|
|
|
|
|
MenuCompat.setGroupDividerEnabled(menu, true);
|
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -355,6 +359,8 @@ public class FragmentAccounts extends FragmentBase {
|
|
|
|
public void onPrepareOptionsMenu(Menu menu) {
|
|
|
|
public void onPrepareOptionsMenu(Menu menu) {
|
|
|
|
menu.findItem(R.id.menu_search).setVisible(!settings);
|
|
|
|
menu.findItem(R.id.menu_search).setVisible(!settings);
|
|
|
|
menu.findItem(R.id.menu_unified).setVisible(!settings);
|
|
|
|
menu.findItem(R.id.menu_unified).setVisible(!settings);
|
|
|
|
|
|
|
|
menu.findItem(R.id.menu_compact).setChecked(compact);
|
|
|
|
|
|
|
|
menu.findItem(R.id.menu_compact).setVisible(!settings);
|
|
|
|
menu.findItem(R.id.menu_theme).setVisible(!settings);
|
|
|
|
menu.findItem(R.id.menu_theme).setVisible(!settings);
|
|
|
|
menu.findItem(R.id.menu_force_sync).setVisible(!settings);
|
|
|
|
menu.findItem(R.id.menu_force_sync).setVisible(!settings);
|
|
|
|
|
|
|
|
|
|
|
@ -370,6 +376,9 @@ public class FragmentAccounts extends FragmentBase {
|
|
|
|
} else if (itemId == R.id.menu_unified) {
|
|
|
|
} else if (itemId == R.id.menu_unified) {
|
|
|
|
onMenuUnified();
|
|
|
|
onMenuUnified();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else if (itemId == R.id.menu_compact) {
|
|
|
|
|
|
|
|
onMenuCompact();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else if (itemId == R.id.menu_theme) {
|
|
|
|
} else if (itemId == R.id.menu_theme) {
|
|
|
|
onMenuTheme();
|
|
|
|
onMenuTheme();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -397,6 +406,26 @@ public class FragmentAccounts extends FragmentBase {
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuCompact() {
|
|
|
|
|
|
|
|
compact = !compact;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
|
|
|
prefs.edit().putBoolean("compact_accounts", compact).apply();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
invalidateOptionsMenu();
|
|
|
|
|
|
|
|
adapter.setCompact(compact);
|
|
|
|
|
|
|
|
rvAccount.post(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuTheme() {
|
|
|
|
private void onMenuTheme() {
|
|
|
|
new FragmentDialogTheme().show(getParentFragmentManager(), "messages:theme");
|
|
|
|
new FragmentDialogTheme().show(getParentFragmentManager(), "messages:theme");
|
|
|
|
}
|
|
|
|
}
|
|
|
|