mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-05 08:33:37 +02:00
Added disabled update notification channel indication
This commit is contained in:
@@ -20,9 +20,11 @@ package eu.faircode.email;
|
||||
*/
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -112,6 +114,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
private TextView tvSdcard;
|
||||
private SwitchCompat swWatchdog;
|
||||
private SwitchCompat swUpdates;
|
||||
private ImageButton ibChannelUpdated;
|
||||
private SwitchCompat swCheckWeekly;
|
||||
private SwitchCompat swChangelog;
|
||||
private SwitchCompat swExperiments;
|
||||
@@ -270,6 +273,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
tvSdcard = view.findViewById(R.id.tvSdcard);
|
||||
swWatchdog = view.findViewById(R.id.swWatchdog);
|
||||
swUpdates = view.findViewById(R.id.swUpdates);
|
||||
ibChannelUpdated = view.findViewById(R.id.ibChannelUpdated);
|
||||
swCheckWeekly = view.findViewById(R.id.swWeekly);
|
||||
swChangelog = view.findViewById(R.id.swChangelog);
|
||||
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() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
@@ -1447,6 +1463,18 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
super.onResume();
|
||||
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();
|
||||
if (view != null)
|
||||
view.post(new Runnable() {
|
||||
|
||||
Reference in New Issue
Block a user