Added quick setup help

pull/148/head
M66B 6 years ago
parent a07bc15f38
commit 9831a3ccd4

@ -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());

@ -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

@ -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));

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_help"
android:icon="@drawable/baseline_help_24"
android:title="@string/title_setup_help"
app:showAsAction="always" />
</menu>
Loading…
Cancel
Save