Added disabled update notification channel indication

pull/207/head
M66B 4 years ago
parent 3f2a62f8af
commit f68fc11403

@ -20,9 +20,11 @@ package eu.faircode.email;
*/ */
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -112,6 +114,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private TextView tvSdcard; private TextView tvSdcard;
private SwitchCompat swWatchdog; private SwitchCompat swWatchdog;
private SwitchCompat swUpdates; private SwitchCompat swUpdates;
private ImageButton ibChannelUpdated;
private SwitchCompat swCheckWeekly; private SwitchCompat swCheckWeekly;
private SwitchCompat swChangelog; private SwitchCompat swChangelog;
private SwitchCompat swExperiments; private SwitchCompat swExperiments;
@ -270,6 +273,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvSdcard = view.findViewById(R.id.tvSdcard); tvSdcard = view.findViewById(R.id.tvSdcard);
swWatchdog = view.findViewById(R.id.swWatchdog); swWatchdog = view.findViewById(R.id.swWatchdog);
swUpdates = view.findViewById(R.id.swUpdates); swUpdates = view.findViewById(R.id.swUpdates);
ibChannelUpdated = view.findViewById(R.id.ibChannelUpdated);
swCheckWeekly = view.findViewById(R.id.swWeekly); swCheckWeekly = view.findViewById(R.id.swWeekly);
swChangelog = view.findViewById(R.id.swChangelog); swChangelog = view.findViewById(R.id.swChangelog);
swExperiments = view.findViewById(R.id.swExperiments); swExperiments = view.findViewById(R.id.swExperiments);
@ -599,6 +603,18 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
} }
}); });
final Intent channelUpdate = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName())
.putExtra(Settings.EXTRA_CHANNEL_ID, "update");
ibChannelUpdated.setVisibility(View.GONE);
ibChannelUpdated.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
v.getContext().startActivity(channelUpdate);
}
});
swCheckWeekly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swCheckWeekly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1447,6 +1463,18 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
super.onResume(); super.onResume();
resumed = true; resumed = true;
if (!Helper.isPlayStoreInstall() &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager nm = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel notification = nm.getNotificationChannel("update");
if (notification != null) {
boolean disabled = notification.getImportance() == NotificationManager.IMPORTANCE_NONE;
ibChannelUpdated.setImageLevel(disabled ? 0 : 1);
ibChannelUpdated.setVisibility(disabled ? View.VISIBLE : View.GONE);
}
}
View view = getView(); View view = getView();
if (view != null) if (view != null)
view.post(new Runnable() { view.post(new Runnable() {

@ -368,6 +368,17 @@
app:layout_constraintTop_toBottomOf="@id/swWatchdog" app:layout_constraintTop_toBottomOf="@id/swWatchdog"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<eu.faircode.email.FixedImageButton
android:id="@+id/ibChannelUpdated"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/swUpdates"
app:srcCompat="@drawable/switch_off_on" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swWeekly" android:id="@+id/swWeekly"
android:layout_width="0dp" android:layout_width="0dp"
@ -377,7 +388,7 @@
android:text="@string/title_advanced_check_weekly" android:text="@string/title_advanced_check_weekly"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swUpdates" app:layout_constraintTop_toBottomOf="@id/ibChannelUpdated"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

Loading…
Cancel
Save