diff options
Diffstat (limited to 'java/com/android/dialer')
6 files changed, 147 insertions, 2 deletions
diff --git a/java/com/android/dialer/app/settings/DialerSettingsActivity.java b/java/com/android/dialer/app/settings/DialerSettingsActivity.java index 10ef9ed60..706f0985a 100644 --- a/java/com/android/dialer/app/settings/DialerSettingsActivity.java +++ b/java/com/android/dialer/app/settings/DialerSettingsActivity.java @@ -33,9 +33,12 @@ import android.view.MenuItem; import android.widget.Toast; import com.android.dialer.about.AboutPhoneFragment; import com.android.dialer.app.R; +import com.android.dialer.assisteddialing.ConcreteCreator; +import com.android.dialer.assisteddialing.ui.AssistedDialingSettingFragment; import com.android.dialer.blocking.FilteredNumberCompat; import com.android.dialer.common.LogUtil; import com.android.dialer.compat.telephony.TelephonyManagerCompat; +import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.proguard.UsedByReflection; import com.android.voicemail.VoicemailClient; import com.android.voicemail.VoicemailComponent; @@ -135,6 +138,21 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity { target.add(accessibilitySettingsHeader); } + boolean isAssistedDialingEnabled = + ConcreteCreator.isAssistedDialingEnabled( + ConfigProviderBindings.get(getApplicationContext())); + LogUtil.i( + "DialerSettingsActivity.onBuildHeaders", + "showing assisted dialing header: " + isAssistedDialingEnabled); + if (isAssistedDialingEnabled) { + + Header assistedDialingSettingsHeader = new Header(); + assistedDialingSettingsHeader.titleRes = + com.android.dialer.assisteddialing.ui.R.string.assisted_dialing_setting_title; + assistedDialingSettingsHeader.fragment = AssistedDialingSettingFragment.class.getName(); + target.add(assistedDialingSettingsHeader); + } + if (showAbout()) { Header aboutPhoneHeader = new Header(); aboutPhoneHeader.titleRes = R.string.about_phone_label; diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java index a8a9d2ab3..1790b8f3f 100644 --- a/java/com/android/dialer/assisteddialing/ConcreteCreator.java +++ b/java/com/android/dialer/assisteddialing/ConcreteCreator.java @@ -20,8 +20,10 @@ import android.annotation.TargetApi; import android.content.Context; import android.os.Build; import android.os.Build.VERSION_CODES; +import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.telephony.TelephonyManager; +import com.android.dialer.assisteddialing.ui.R; import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProvider; import com.android.dialer.configprovider.ConfigProviderBindings; @@ -63,8 +65,15 @@ public final class ConcreteCreator { throw new NullPointerException("Provided context was null"); } - if ((Build.VERSION.SDK_INT < BUILD_CODE_FLOOR || Build.VERSION.SDK_INT > BUILD_CODE_CEILING) - || !configProvider.getBoolean("assisted_dialing_enabled", false)) { + if (!isAssistedDialingEnabled(configProvider)) { + LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "feature not enabled"); + return new AssistedDialingMediatorStub(); + } + + if (!PreferenceManager.getDefaultSharedPreferences(context) + .getBoolean(context.getString(R.string.assisted_dialing_setting_toggle_key), false)) { + LogUtil.i("ConcreteCreator.createNewAssistedDialingMediator", "disabled by local setting"); + return new AssistedDialingMediatorStub(); } @@ -74,4 +83,16 @@ public final class ConcreteCreator { return new AssistedDialingMediatorImpl( new LocationDetector(telephonyManager), new NumberTransformer(constraints)); } + + /** Returns a boolean indicating whether or not the assisted dialing feature is enabled. */ + public static boolean isAssistedDialingEnabled(@NonNull ConfigProvider configProvider) { + if (configProvider == null) { + LogUtil.i("ConcreteCreator.isAssistedDialingEnabled", "provided configProvider was null"); + throw new NullPointerException("Provided configProvider was null"); + } + + return (Build.VERSION.SDK_INT >= BUILD_CODE_FLOOR + && Build.VERSION.SDK_INT <= BUILD_CODE_CEILING) + && configProvider.getBoolean("assisted_dialing_enabled", false); + } } diff --git a/java/com/android/dialer/assisteddialing/ui/AndroidManifest.xml b/java/com/android/dialer/assisteddialing/ui/AndroidManifest.xml new file mode 100644 index 000000000..6625dff07 --- /dev/null +++ b/java/com/android/dialer/assisteddialing/ui/AndroidManifest.xml @@ -0,0 +1,22 @@ +<!-- Copyright (C) 2017 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.dialer.assisteddialing"> + + <uses-sdk + android:minSdkVersion="23" + android:targetSdkVersion="24"/> + +</manifest>
\ No newline at end of file diff --git a/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java new file mode 100644 index 000000000..8847448cd --- /dev/null +++ b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +package com.android.dialer.assisteddialing.ui; + +import android.os.Bundle; +import android.preference.PreferenceFragment; + +/** The setting for Assisted Dialing */ +public class AssistedDialingSettingFragment extends PreferenceFragment { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Load the preferences from an XML resource + addPreferencesFromResource(R.xml.assisted_dialing_setting); + } +} diff --git a/java/com/android/dialer/assisteddialing/ui/res/values/string.xml b/java/com/android/dialer/assisteddialing/ui/res/values/string.xml new file mode 100644 index 000000000..cd159bfd5 --- /dev/null +++ b/java/com/android/dialer/assisteddialing/ui/res/values/string.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2017 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> + +<resources> + <!-- Label for a setting enabling assisted dialing [CHAR LIMIT=40]--> + <string name="assisted_dialing_setting_title">Assisted dialing</string> + + <!-- Label for a setting enabling assisted dialing switch preference--> + <string name="assisted_dialing_setting_summary">Automatically correct the phone number prefix when traveling and calling international numbers</string> + + <!-- Key for the assisted dialing setting toggle--> + <string name="assisted_dialing_setting_toggle_key" translatable="false">assisted_dialing_setting_toggle_key</string> +</resources>
\ No newline at end of file diff --git a/java/com/android/dialer/assisteddialing/ui/res/xml/assisted_dialing_setting.xml b/java/com/android/dialer/assisteddialing/ui/res/xml/assisted_dialing_setting.xml new file mode 100644 index 000000000..8e3c62dde --- /dev/null +++ b/java/com/android/dialer/assisteddialing/ui/res/xml/assisted_dialing_setting.xml @@ -0,0 +1,26 @@ +<!-- + ~ Copyright (C) 2017 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<PreferenceScreen + xmlns:android="http://schemas.android.com/apk/res/android"> + + <SwitchPreference + android:defaultValue="false" + android:key="@string/assisted_dialing_setting_toggle_key" + android:title="@string/assisted_dialing_setting_title" + android:summary="@string/assisted_dialing_setting_summary" /> + +</PreferenceScreen>
\ No newline at end of file |