diff --git a/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java b/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java index 296f9b85d6..3f2477c8ed 100644 --- a/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java @@ -39,6 +39,9 @@ import android.text.TextWatcher; import android.text.method.LinkMovementMethod; import android.util.Patterns; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Button; @@ -90,6 +93,7 @@ public class FragmentQuickSetup extends FragmentBase { @Nullable public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { setSubtitle(R.string.title_setup); + setHasOptionsMenu(true); view = (ViewGroup) inflater.inflate(R.layout.fragment_quick_setup, container, false); @@ -168,6 +172,34 @@ public class FragmentQuickSetup extends FragmentBase { return view; } + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.menu_quick_setup, menu); + super.onCreateOptionsMenu(menu, inflater); + } + + @Override + public void onPrepareOptionsMenu(Menu menu) { + PackageManager pm = getContext().getPackageManager(); + menu.findItem(R.id.menu_help).setVisible(Helper.getIntentSetupHelp().resolveActivity(pm) != null); + super.onPrepareOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_help: + onMenuHelp(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + private void onMenuHelp() { + startActivity(Helper.getIntentSetupHelp()); + } + private void onSave(boolean check) { Bundle args = new Bundle(); args.putString("name", etName.getText().toString()); diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java index 913070380d..3f4e9ec3dd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java @@ -353,7 +353,7 @@ public class FragmentSetup extends FragmentBase { public void onPrepareOptionsMenu(Menu menu) { PackageManager pm = getContext().getPackageManager(); menu.findItem(R.id.menu_advanced).setVisible(BuildConfig.DEBUG); - menu.findItem(R.id.menu_help).setVisible(getIntentHelp().resolveActivity(pm) != null); + menu.findItem(R.id.menu_help).setVisible(Helper.getIntentSetupHelp().resolveActivity(pm) != null); super.onPrepareOptionsMenu(menu); } @@ -378,13 +378,7 @@ public class FragmentSetup extends FragmentBase { } private void onMenuHelp() { - startActivity(getIntentHelp()); - } - - private Intent getIntentHelp() { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse("https://github.com/M66B/open-source-email/blob/master/SETUP.md#setup-help")); - return intent; + startActivity(Helper.getIntentSetupHelp()); } @Override diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 65a8919fb7..a11c02dfa1 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -180,6 +180,12 @@ public class Helper { return Intent.createChooser(intent, context.getString(R.string.title_select_app)); } + static Intent getIntentSetupHelp() { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://github.com/M66B/open-source-email/blob/master/SETUP.md#setup-help")); + return intent; + } + static Intent getIntentFAQ() { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(Helper.FAQ_URI)); diff --git a/app/src/main/res/menu/menu_quick_setup.xml b/app/src/main/res/menu/menu_quick_setup.xml new file mode 100644 index 0000000000..e1b343d13f --- /dev/null +++ b/app/src/main/res/menu/menu_quick_setup.xml @@ -0,0 +1,9 @@ + +