Moved manage notifications to tab page

This commit is contained in:
M66B 2019-06-14 19:05:28 +02:00
parent fb1007e9cf
commit 50c3a7b6a9
3 changed files with 36 additions and 22 deletions

View File

@ -40,7 +40,6 @@ import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MenuItem;
@ -187,15 +186,6 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
}
}).setSeparated());
if (getIntentNotifications(this).resolveActivity(pm) != null)
menus.add(new NavMenuItem(R.drawable.baseline_notifications_24, R.string.title_setup_notifications, new Runnable() {
@Override
public void run() {
drawerLayout.closeDrawer(drawerContainer);
onManageNotifications();
}
}));
menus.add(new NavMenuItem(R.drawable.baseline_reorder_24, R.string.title_setup_reorder_accounts, new Runnable() {
@Override
public void run() {
@ -441,10 +431,6 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
.show();
}
private void onManageNotifications() {
startActivity(getIntentNotifications(this));
}
private void onMenuOrder(int title, Class clazz) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getSupportFragmentManager().popBackStack("order", FragmentManager.POP_BACK_STACK_INCLUSIVE);
@ -557,13 +543,6 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
fragmentTransaction.commit();
}
private static Intent getIntentNotifications(Context context) {
return new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
.putExtra("app_package", context.getPackageName())
.putExtra("app_uid", context.getApplicationInfo().uid)
.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
}
private static Intent getIntentExport() {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);

View File

@ -19,12 +19,15 @@ package eu.faircode.email;
Copyright 2018-2019 by Marcel Bokhorst (M66B)
*/
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@ -52,6 +55,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private CheckBox cbNotifyActionReply;
private CheckBox cbNotifyActionFlag;
private CheckBox cbNotifyActionSeen;
private Button btnManage;
private SwitchCompat swLight;
private Button btnSound;
@ -78,6 +82,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
cbNotifyActionReply = view.findViewById(R.id.cbNotifyActionReply);
cbNotifyActionFlag = view.findViewById(R.id.cbNotifyActionFlag);
cbNotifyActionSeen = view.findViewById(R.id.cbNotifyActionSeen);
btnManage = view.findViewById(R.id.btnManage);
swLight = view.findViewById(R.id.swLight);
btnSound = view.findViewById(R.id.btnSound);
@ -138,6 +143,16 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
final Intent manage = getIntentNotifications(getContext());
PackageManager pm = getContext().getPackageManager();
btnManage.setVisibility(manage.resolveActivity(pm) == null ? View.GONE : View.VISIBLE);
btnManage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(manage);
}
});
swLight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -249,4 +264,12 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
prefs.edit().putString("sound", uri.toString()).apply();
}
}
private static Intent getIntentNotifications(Context context) {
return new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
.putExtra("app_package", context.getPackageName())
.putExtra("app_uid", context.getApplicationInfo().uid)
.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
}
}

View File

@ -132,6 +132,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyActionsHint" />
<Button
android:id="@+id/btnManage"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/title_setup_notifications"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyActionsPro" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLight"
android:layout_width="match_parent"
@ -139,7 +151,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_advanced_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyActionsPro"
app:layout_constraintTop_toBottomOf="@id/btnManage"
app:switchPadding="12dp" />
<Button