Added a shortcut to call/service notifications channel settings

This commit is contained in:
Sylvain Berfini 2019-11-15 10:24:16 +01:00
parent 10d8eb4d8c
commit 8975920035
2 changed files with 37 additions and 1 deletions

View file

@ -20,9 +20,12 @@
package org.linphone.settings; package org.linphone.settings;
import android.Manifest; import android.Manifest;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.text.InputType; import android.text.InputType;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -54,7 +57,7 @@ public class CallSettingsFragment extends SettingsFragment {
mAutoAnswer; mAutoAnswer;
private ListSetting mMediaEncryption; private ListSetting mMediaEncryption;
private TextSetting mAutoAnswerTime, mIncomingCallTimeout, mVoiceMailUri; private TextSetting mAutoAnswerTime, mIncomingCallTimeout, mVoiceMailUri;
private BasicSetting mDndPermissionSettings; private BasicSetting mDndPermissionSettings, mAndroidNotificationSettings;
@Nullable @Nullable
@Override @Override
@ -90,6 +93,8 @@ public class CallSettingsFragment extends SettingsFragment {
mMediaEncryption = mRootView.findViewById(R.id.pref_media_encryption); mMediaEncryption = mRootView.findViewById(R.id.pref_media_encryption);
initMediaEncryptionList(); initMediaEncryptionList();
mAndroidNotificationSettings = mRootView.findViewById(R.id.pref_android_app_notif_settings);
mAutoAnswerTime = mRootView.findViewById(R.id.pref_auto_answer_time); mAutoAnswerTime = mRootView.findViewById(R.id.pref_auto_answer_time);
mAutoAnswerTime.setInputType(InputType.TYPE_CLASS_NUMBER); mAutoAnswerTime.setInputType(InputType.TYPE_CLASS_NUMBER);
@ -230,6 +235,27 @@ public class CallSettingsFragment extends SettingsFragment {
mPrefs.setMediaEncryptionMandatory(newValue); mPrefs.setMediaEncryptionMandatory(newValue);
} }
}); });
mAndroidNotificationSettings.setListener(
new SettingListenerBase() {
@Override
public void onClicked() {
if (Build.VERSION.SDK_INT >= Version.API26_O_80) {
Context context = getActivity();
Intent i = new Intent();
i.setAction(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
i.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
i.putExtra(
Settings.EXTRA_CHANNEL_ID,
context.getString(R.string.notification_service_channel_id));
i.addCategory(Intent.CATEGORY_DEFAULT);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(i);
}
}
});
} }
private void updateValues() { private void updateValues() {
@ -258,6 +284,10 @@ public class CallSettingsFragment extends SettingsFragment {
mMediaEncryptionMandatory.setChecked(mPrefs.isMediaEncryptionMandatory()); mMediaEncryptionMandatory.setChecked(mPrefs.isMediaEncryptionMandatory());
mMediaEncryptionMandatory.setEnabled(mPrefs.getMediaEncryption() != MediaEncryption.None); mMediaEncryptionMandatory.setEnabled(mPrefs.getMediaEncryption() != MediaEncryption.None);
if (Version.sdkStrictlyBelow(Version.API26_O_80)) {
mAndroidNotificationSettings.setVisibility(View.GONE);
}
setListeners(); setListeners();
} }

View file

@ -54,6 +54,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
linphone:title="@string/pref_rfc2833_dtmf" /> linphone:title="@string/pref_rfc2833_dtmf" />
<org.linphone.settings.widget.BasicSetting
android:id="@+id/pref_android_app_notif_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
linphone:title="@string/pref_android_app_notif_settings_title"/>
<org.linphone.settings.widget.SwitchSetting <org.linphone.settings.widget.SwitchSetting
android:id="@+id/pref_auto_answer" android:id="@+id/pref_auto_answer"
android:layout_width="match_parent" android:layout_width="match_parent"