Added account log

pull/204/head
M66B 4 years ago
parent e050d43fdc
commit 250be4012a

@ -52,6 +52,8 @@ import androidx.annotation.NonNull;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleOwner;
@ -351,8 +353,10 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
if (account.protocol == EntityAccount.TYPE_IMAP && settings) if (account.protocol == EntityAccount.TYPE_IMAP && settings)
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 4, R.string.title_copy); popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 4, R.string.title_copy);
popupMenu.getMenu().add(Menu.NONE, R.string.title_log, 5, R.string.title_log);
if (debug) if (debug)
popupMenu.getMenu().add(Menu.NONE, R.string.title_reset, 5, R.string.title_reset); popupMenu.getMenu().add(Menu.NONE, R.string.title_reset, 6, R.string.title_reset);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
@ -370,6 +374,9 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
} else if (itemId == R.string.title_copy) { } else if (itemId == R.string.title_copy) {
onActionCopy(); onActionCopy();
return true; return true;
} else if (itemId == R.string.title_log) {
onActionLog();
return true;
} else if (itemId == R.string.title_reset) { } else if (itemId == R.string.title_reset) {
onActionReset(); onActionReset();
return true; return true;
@ -473,6 +480,21 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
.putExtra("copy", true)); .putExtra("copy", true));
} }
private void onActionLog() {
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
parentFragment.getParentFragmentManager().popBackStack("logs", FragmentManager.POP_BACK_STACK_INCLUSIVE);
Bundle args = new Bundle();
args.putLong("account", account.id);
Fragment fragment = new FragmentLogs();
fragment.setArguments(args);
FragmentTransaction fragmentTransaction = parentFragment.getParentFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("logs");
fragmentTransaction.commit();
}
private void onActionReset() { private void onActionReset() {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", account.id); args.putLong("id", account.id);

Loading…
Cancel
Save