deep link into FSI setting if not granted
This commit is contained in:
parent
9bf1e51ac4
commit
069b02004f
|
@ -1,11 +1,15 @@
|
||||||
package eu.siacs.conversations.ui.fragment.settings;
|
package eu.siacs.conversations.ui.fragment.settings;
|
||||||
|
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationManager;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Intent;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -56,12 +60,14 @@ public class NotificationsSettingsFragment extends XmppPreferenceFragment {
|
||||||
@Nullable final Bundle savedInstanceState, final @Nullable String rootKey) {
|
@Nullable final Bundle savedInstanceState, final @Nullable String rootKey) {
|
||||||
setPreferencesFromResource(R.xml.preferences_notifications, rootKey);
|
setPreferencesFromResource(R.xml.preferences_notifications, rootKey);
|
||||||
final var messageNotificationSettings = findPreference("message_notification_settings");
|
final var messageNotificationSettings = findPreference("message_notification_settings");
|
||||||
|
final var fullscreenNotification = findPreference("fullscreen_notification");
|
||||||
final var notificationRingtone = findPreference(AppSettings.NOTIFICATION_RINGTONE);
|
final var notificationRingtone = findPreference(AppSettings.NOTIFICATION_RINGTONE);
|
||||||
final var notificationHeadsUp = findPreference(AppSettings.NOTIFICATION_HEADS_UP);
|
final var notificationHeadsUp = findPreference(AppSettings.NOTIFICATION_HEADS_UP);
|
||||||
final var notificationVibrate = findPreference(AppSettings.NOTIFICATION_VIBRATE);
|
final var notificationVibrate = findPreference(AppSettings.NOTIFICATION_VIBRATE);
|
||||||
final var notificationLed = findPreference(AppSettings.NOTIFICATION_LED);
|
final var notificationLed = findPreference(AppSettings.NOTIFICATION_LED);
|
||||||
final var foregroundService = findPreference(AppSettings.KEEP_FOREGROUND_SERVICE);
|
final var foregroundService = findPreference(AppSettings.KEEP_FOREGROUND_SERVICE);
|
||||||
if (messageNotificationSettings == null
|
if (messageNotificationSettings == null
|
||||||
|
|| fullscreenNotification == null
|
||||||
|| notificationRingtone == null
|
|| notificationRingtone == null
|
||||||
|| notificationHeadsUp == null
|
|| notificationHeadsUp == null
|
||||||
|| notificationVibrate == null
|
|| notificationVibrate == null
|
||||||
|
@ -78,6 +84,44 @@ public class NotificationsSettingsFragment extends XmppPreferenceFragment {
|
||||||
} else {
|
} else {
|
||||||
messageNotificationSettings.setVisible(false);
|
messageNotificationSettings.setVisible(false);
|
||||||
}
|
}
|
||||||
|
fullscreenNotification.setOnPreferenceClickListener(this::manageAppUseFullScreen);
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE
|
||||||
|
|| requireContext()
|
||||||
|
.getSystemService(NotificationManager.class)
|
||||||
|
.canUseFullScreenIntent()) {
|
||||||
|
fullscreenNotification.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
final var fullscreenNotification = findPreference("fullscreen_notification");
|
||||||
|
if (fullscreenNotification == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE
|
||||||
|
|| requireContext()
|
||||||
|
.getSystemService(NotificationManager.class)
|
||||||
|
.canUseFullScreenIntent()) {
|
||||||
|
fullscreenNotification.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean manageAppUseFullScreen(final Preference preference) {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final var intent = new Intent(Settings.ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT);
|
||||||
|
intent.setData(Uri.parse(String.format("package:%s", requireContext().getPackageName())));
|
||||||
|
try {
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (final ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(requireContext(), R.string.no_application_found, Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
12
src/main/res/drawable/ic_smartphone_24dp.xml
Normal file
12
src/main/res/drawable/ic_smartphone_24dp.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?colorControlNormal"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M17,1.01L7,1c-1.1,0 -2,0.9 -2,2v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19H7V5h10v14z" />
|
||||||
|
|
||||||
|
</vector>
|
|
@ -1062,5 +1062,7 @@
|
||||||
<string name="pref_backup_summary">Create one-off, Schedule recurring</string>
|
<string name="pref_backup_summary">Create one-off, Schedule recurring</string>
|
||||||
<string name="pref_create_backup_one_off_summary">Create one-off backup</string>
|
<string name="pref_create_backup_one_off_summary">Create one-off backup</string>
|
||||||
<string name="pref_backup_recurring">Recurring backup</string>
|
<string name="pref_backup_recurring">Recurring backup</string>
|
||||||
|
<string name="pref_fullscreen_notification">Full screen notifications</string>
|
||||||
|
<string name="pref_fullscreen_notification_summary">Allow this app to show incoming call notifications that take up the full screen when the device is locked.</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -46,6 +46,11 @@
|
||||||
android:ringtoneType="ringtone"
|
android:ringtoneType="ringtone"
|
||||||
android:summary="@string/pref_call_ringtone_summary"
|
android:summary="@string/pref_call_ringtone_summary"
|
||||||
android:title="@string/pref_ringtone" />
|
android:title="@string/pref_ringtone" />
|
||||||
|
<Preference
|
||||||
|
android:icon="@drawable/ic_smartphone_24dp"
|
||||||
|
android:key="fullscreen_notification"
|
||||||
|
android:summary="@string/pref_fullscreen_notification_summary"
|
||||||
|
android:title="@string/pref_fullscreen_notification" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="@integer/grace_period"
|
android:defaultValue="@integer/grace_period"
|
||||||
android:entries="@array/grace_periods"
|
android:entries="@array/grace_periods"
|
||||||
|
|
Loading…
Reference in a new issue