Added setup menu

pull/147/head
M66B 6 years ago
parent 4457f7fa3f
commit 0ce9427788

@ -34,6 +34,9 @@ import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.provider.Settings; import android.provider.Settings;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
@ -72,6 +75,8 @@ public class FragmentSetup extends FragmentEx {
private int colorWarning; private int colorWarning;
private Drawable check; private Drawable check;
private boolean inbox = false;
private static final String[] permissions = new String[]{ private static final String[] permissions = new String[]{
Manifest.permission.READ_CONTACTS Manifest.permission.READ_CONTACTS
}; };
@ -80,6 +85,7 @@ public class FragmentSetup extends FragmentEx {
@Nullable @Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
setSubtitle(R.string.title_setup); setSubtitle(R.string.title_setup);
setHasOptionsMenu(true);
textColorPrimary = Helper.resolveColor(getContext(), android.R.attr.textColorPrimary); textColorPrimary = Helper.resolveColor(getContext(), android.R.attr.textColorPrimary);
colorWarning = Helper.resolveColor(getContext(), R.attr.colorWarning); colorWarning = Helper.resolveColor(getContext(), R.attr.colorWarning);
@ -251,6 +257,9 @@ public class FragmentSetup extends FragmentEx {
public void onChanged(@Nullable List<EntityAccount> accounts) { public void onChanged(@Nullable List<EntityAccount> accounts) {
done = (accounts != null && accounts.size() > 0); done = (accounts != null && accounts.size() > 0);
inbox = done;
getActivity().invalidateOptionsMenu();
btnIdentity.setEnabled(done); btnIdentity.setEnabled(done);
tvAccountDone.setText(done ? R.string.title_setup_done : R.string.title_setup_to_do); tvAccountDone.setText(done ? R.string.title_setup_done : R.string.title_setup_to_do);
tvAccountDone.setTextColor(done ? textColorPrimary : colorWarning); tvAccountDone.setTextColor(done ? textColorPrimary : colorWarning);
@ -323,6 +332,29 @@ public class FragmentSetup extends FragmentEx {
} }
} }
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_setup, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.menu_inbox).setVisible(inbox);
super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_inbox:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == ActivitySetup.REQUEST_PERMISSION) if (requestCode == ActivitySetup.REQUEST_PERMISSION)

@ -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_inbox"
android:icon="@drawable/baseline_mail_24"
android:title="@string/title_folder_unified"
app:showAsAction="always" />
</menu>
Loading…
Cancel
Save