Snap for 7964896 from a0ddbe36d6 to tm-release

Change-Id: I8f9e16dac07d45cf000152b7086b06cb2ae6fb9a
This commit is contained in:
Android Build Coastguard Worker
2021-12-03 02:08:55 +00:00
20 changed files with 346 additions and 62 deletions

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minHeight="@dimen/settingslib_min_switch_bar_height"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="@dimen/settingslib_switchbar_margin"
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
android:paddingEnd="@dimen/settingslib_switchbar_padding_right"
android:background="@drawable/settingslib_switch_bar_bg_on">
<TextView
android:id="@android:id/title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginEnd="@dimen/settingslib_switch_title_margin"
android:layout_marginVertical="@dimen/settingslib_switch_title_margin"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceListItem"
style="@style/MainSwitchText.Settingslib" />
</LinearLayout>

View File

@@ -29,16 +29,11 @@
<FrameLayout <FrameLayout
android:id="@android:id/tabcontent" android:id="@android:id/tabcontent"
android:layout_width="0dip"
android:layout_height="0dip" />
<FrameLayout
android:id="@+id/prefs_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dip" android:layout_height="0dip"
android:layout_weight="1" android:layout_weight="1"
android:clipChildren="false" android:clipChildren="true"
android:clipToPadding="false" android:clipToPadding="true"
android:smoothScrollbar="false" /> android:smoothScrollbar="false" />
</LinearLayout> </LinearLayout>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 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"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/account_dashboard_title"
settings:searchable="false">
</PreferenceScreen>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 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"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/location_category_recent_location_requests"
settings:searchable="false">
</PreferenceScreen>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 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"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/location_services_preference_title"
settings:searchable="false">
</PreferenceScreen>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 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"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/location_settings_title"
settings:searchable="false">
</PreferenceScreen>

View File

@@ -21,6 +21,7 @@
<com.android.settings.wifi.calling.ListWithEntrySummaryPreference <com.android.settings.wifi.calling.ListWithEntrySummaryPreference
android:key="wifi_calling_mode" android:key="wifi_calling_mode"
isPreferenceVisible="false"
android:title="@string/wifi_calling_mode_title" android:title="@string/wifi_calling_mode_title"
android:summary="@string/wifi_calling_mode_title" android:summary="@string/wifi_calling_mode_title"
android:entries="@array/wifi_calling_mode_choices" android:entries="@array/wifi_calling_mode_choices"
@@ -30,6 +31,7 @@
<com.android.settings.wifi.calling.ListWithEntrySummaryPreference <com.android.settings.wifi.calling.ListWithEntrySummaryPreference
android:key="wifi_calling_roaming_mode" android:key="wifi_calling_roaming_mode"
isPreferenceVisible="false"
android:title="@string/wifi_calling_roaming_mode_title" android:title="@string/wifi_calling_roaming_mode_title"
android:summary="@string/wifi_calling_roaming_mode_summary" android:summary="@string/wifi_calling_roaming_mode_summary"
android:entries="@array/wifi_calling_mode_choices_v2" android:entries="@array/wifi_calling_mode_choices_v2"
@@ -39,7 +41,12 @@
<Preference <Preference
android:key="emergency_address_key" android:key="emergency_address_key"
isPreferenceVisible="false"
android:title="@string/emergency_address_title" android:title="@string/emergency_address_title"
android:summary="@string/emergency_address_summary" /> android:summary="@string/emergency_address_summary" />
<com.android.settings.wifi.calling.LinkifyDescriptionPreference
android:key="no_options_description"
isPreferenceVisible="false" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -150,6 +150,7 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
private void initLaunchPreference() { private void initLaunchPreference() {
final Preference launchPreference = new Preference(getPrefContext()); final Preference launchPreference = new Preference(getPrefContext());
launchPreference.setLayoutResource(R.layout.accessibility_launch_activity_preference);
launchPreference.setKey(KEY_LAUNCH_PREFERENCE); launchPreference.setKey(KEY_LAUNCH_PREFERENCE);
final AccessibilityShortcutInfo info = getAccessibilityShortcutInfo(); final AccessibilityShortcutInfo info = getAccessibilityShortcutInfo();

View File

@@ -272,8 +272,7 @@ public class ManageApplications extends InstrumentedFragment
Intent intent = activity.getIntent(); Intent intent = activity.getIntent();
Bundle args = getArguments(); Bundle args = getArguments();
int screenTitle = intent.getIntExtra( final int screenTitle = getTitleResId(intent, args);
SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.all_apps);
String className = args != null ? args.getString(EXTRA_CLASSNAME) : null; String className = args != null ? args.getString(EXTRA_CLASSNAME) : null;
if (className == null) { if (className == null) {
className = intent.getComponent().getClassName(); className = intent.getComponent().getClassName();
@@ -290,49 +289,36 @@ public class ManageApplications extends InstrumentedFragment
mSortOrder = R.id.sort_order_size; mSortOrder = R.id.sort_order_size;
} else if (className.equals(UsageAccessSettingsActivity.class.getName())) { } else if (className.equals(UsageAccessSettingsActivity.class.getName())) {
mListType = LIST_TYPE_USAGE_ACCESS; mListType = LIST_TYPE_USAGE_ACCESS;
screenTitle = R.string.usage_access;
} else if (className.equals(HighPowerApplicationsActivity.class.getName())) { } else if (className.equals(HighPowerApplicationsActivity.class.getName())) {
mListType = LIST_TYPE_HIGH_POWER; mListType = LIST_TYPE_HIGH_POWER;
// Default to showing system. // Default to showing system.
mShowSystem = true; mShowSystem = true;
screenTitle = R.string.high_power_apps;
} else if (className.equals(OverlaySettingsActivity.class.getName())) { } else if (className.equals(OverlaySettingsActivity.class.getName())) {
mListType = LIST_TYPE_OVERLAY; mListType = LIST_TYPE_OVERLAY;
screenTitle = R.string.system_alert_window_settings;
reportIfRestrictedSawIntent(intent); reportIfRestrictedSawIntent(intent);
} else if (className.equals(WriteSettingsActivity.class.getName())) { } else if (className.equals(WriteSettingsActivity.class.getName())) {
mListType = LIST_TYPE_WRITE_SETTINGS; mListType = LIST_TYPE_WRITE_SETTINGS;
screenTitle = R.string.write_settings;
} else if (className.equals(ManageExternalSourcesActivity.class.getName())) { } else if (className.equals(ManageExternalSourcesActivity.class.getName())) {
mListType = LIST_TYPE_MANAGE_SOURCES; mListType = LIST_TYPE_MANAGE_SOURCES;
screenTitle = R.string.install_other_apps;
} else if (className.equals(GamesStorageActivity.class.getName())) { } else if (className.equals(GamesStorageActivity.class.getName())) {
mListType = LIST_TYPE_GAMES; mListType = LIST_TYPE_GAMES;
mSortOrder = R.id.sort_order_size; mSortOrder = R.id.sort_order_size;
} else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) { } else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) {
mListType = LIST_TYPE_WIFI_ACCESS; mListType = LIST_TYPE_WIFI_ACCESS;
screenTitle = R.string.change_wifi_state_title;
} else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) { } else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) {
mListType = LIST_MANAGE_EXTERNAL_STORAGE; mListType = LIST_MANAGE_EXTERNAL_STORAGE;
screenTitle = R.string.manage_external_storage_title;
} else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) { } else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) {
mListType = LIST_TYPE_MEDIA_MANAGEMENT_APPS; mListType = LIST_TYPE_MEDIA_MANAGEMENT_APPS;
screenTitle = R.string.media_management_apps_title;
} else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) { } else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) {
mListType = LIST_TYPE_ALARMS_AND_REMINDERS; mListType = LIST_TYPE_ALARMS_AND_REMINDERS;
screenTitle = R.string.alarms_and_reminders_title;
} else if (className.equals(Settings.NotificationAppListActivity.class.getName())) { } else if (className.equals(Settings.NotificationAppListActivity.class.getName())) {
mListType = LIST_TYPE_NOTIFICATION; mListType = LIST_TYPE_NOTIFICATION;
mUsageStatsManager = IUsageStatsManager.Stub.asInterface( mUsageStatsManager = IUsageStatsManager.Stub.asInterface(
ServiceManager.getService(Context.USAGE_STATS_SERVICE)); ServiceManager.getService(Context.USAGE_STATS_SERVICE));
mNotificationBackend = new NotificationBackend(); mNotificationBackend = new NotificationBackend();
mSortOrder = R.id.sort_order_recent_notification; mSortOrder = R.id.sort_order_recent_notification;
screenTitle = R.string.app_notifications_title;
} else { } else {
if (screenTitle == -1) {
screenTitle = R.string.all_apps;
}
mListType = LIST_TYPE_MAIN; mListType = LIST_TYPE_MAIN;
} }
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance(); final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
@@ -881,6 +867,46 @@ public class ManageApplications extends InstrumentedFragment
params.setBehavior(behavior); params.setBehavior(behavior);
} }
/**
* Returns a resource ID of title based on what type of app list is
* @param intent the intent of the activity that might include a specified title
* @param args the args that includes a class name of app list
*/
public static int getTitleResId(@NonNull Intent intent, Bundle args) {
int screenTitle = intent.getIntExtra(
SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.all_apps);
String className = args != null ? args.getString(EXTRA_CLASSNAME) : null;
if (className == null) {
className = intent.getComponent().getClassName();
}
if (className.equals(Settings.UsageAccessSettingsActivity.class.getName())) {
screenTitle = R.string.usage_access;
} else if (className.equals(Settings.HighPowerApplicationsActivity.class.getName())) {
screenTitle = R.string.high_power_apps;
} else if (className.equals(Settings.OverlaySettingsActivity.class.getName())) {
screenTitle = R.string.system_alert_window_settings;
} else if (className.equals(Settings.WriteSettingsActivity.class.getName())) {
screenTitle = R.string.write_settings;
} else if (className.equals(Settings.ManageExternalSourcesActivity.class.getName())) {
screenTitle = R.string.install_other_apps;
} else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) {
screenTitle = R.string.change_wifi_state_title;
} else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) {
screenTitle = R.string.manage_external_storage_title;
} else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) {
screenTitle = R.string.media_management_apps_title;
} else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) {
screenTitle = R.string.alarms_and_reminders_title;
} else if (className.equals(Settings.NotificationAppListActivity.class.getName())) {
screenTitle = R.string.app_notifications_title;
} else {
if (screenTitle == -1) {
screenTitle = R.string.all_apps;
}
}
return screenTitle;
}
static class FilterSpinnerAdapter extends SettingsSpinnerAdapter<CharSequence> { static class FilterSpinnerAdapter extends SettingsSpinnerAdapter<CharSequence> {
private final ManageApplications mManageApplications; private final ManageApplications mManageApplications;

View File

@@ -203,11 +203,15 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
getMoreButtonTextRes(), this::onNextButtonClick); getMoreButtonTextRes(), this::onNextButtonClick);
requireScrollMixin.setOnRequireScrollStateChangedListener( requireScrollMixin.setOnRequireScrollStateChangedListener(
scrollNeeded -> { scrollNeeded -> {
// Update text of primary button from "More" to "Agree".
final int primaryButtonTextRes = scrollNeeded boolean enrollmentCompleted = checkMaxEnrolled() != 0;
? getMoreButtonTextRes() if (!enrollmentCompleted) {
: getAgreeButtonTextRes(); // Update text of primary button from "More" to "Agree".
getPrimaryFooterButton().setText(this, primaryButtonTextRes); final int primaryButtonTextRes = scrollNeeded
? getMoreButtonTextRes()
: getAgreeButtonTextRes();
getPrimaryFooterButton().setText(this, primaryButtonTextRes);
}
// Show secondary button once scroll is completed. // Show secondary button once scroll is completed.
if (!scrollNeeded) { if (!scrollNeeded) {

View File

@@ -17,6 +17,7 @@
package com.android.settings.dashboard.profileselector; package com.android.settings.dashboard.profileselector;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.android.settings.R;
import com.android.settings.accounts.AccountPersonalDashboardFragment; import com.android.settings.accounts.AccountPersonalDashboardFragment;
import com.android.settings.accounts.AccountWorkProfileDashboardFragment; import com.android.settings.accounts.AccountWorkProfileDashboardFragment;
@@ -32,4 +33,9 @@ public class ProfileSelectAccountFragment extends ProfileSelectFragment {
new AccountWorkProfileDashboardFragment() new AccountWorkProfileDashboardFragment()
}; };
} }
@Override
protected int getPreferenceScreenResId() {
return R.xml.accounts_dashboard_settings_header;
}
} }

View File

@@ -107,6 +107,10 @@ public abstract class ProfileSelectFragment extends DashboardFragment {
Bundle savedInstanceState) { Bundle savedInstanceState) {
mContentView = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState); mContentView = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);
final Activity activity = getActivity(); final Activity activity = getActivity();
final int titleResId = getTitleResId();
if (titleResId > 0) {
activity.setTitle(titleResId);
}
final int selectedTab = convertPosition(getTabId(activity, getArguments())); final int selectedTab = convertPosition(getTabId(activity, getArguments()));
final View tabContainer = mContentView.findViewById(R.id.tab_container); final View tabContainer = mContentView.findViewById(R.id.tab_container);
@@ -166,6 +170,14 @@ public abstract class ProfileSelectFragment extends DashboardFragment {
*/ */
public abstract Fragment[] getFragments(); public abstract Fragment[] getFragments();
/**
* Returns a resource ID of the title
* Override this if the title needs to be updated dynamically.
*/
public int getTitleResId() {
return 0;
}
@Override @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.placeholder_preference_screen; return R.xml.placeholder_preference_screen;

View File

@@ -60,4 +60,9 @@ public class ProfileSelectLocationFragment extends ProfileSelectFragment {
workFragment workFragment
}; };
} }
@Override
protected int getPreferenceScreenResId() {
return R.xml.location_settings_header;
}
} }

View File

@@ -20,6 +20,7 @@ import android.os.Bundle;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.android.settings.R;
import com.android.settings.location.LocationServices; import com.android.settings.location.LocationServices;
import com.android.settings.location.LocationServicesForWork; import com.android.settings.location.LocationServicesForWork;
@@ -44,4 +45,9 @@ public class ProfileSelectLocationServicesFragment extends ProfileSelectFragment
workFragment workFragment
}; };
} }
@Override
protected int getPreferenceScreenResId() {
return R.xml.location_services_header;
}
} }

View File

@@ -16,6 +16,8 @@
package com.android.settings.dashboard.profileselector; package com.android.settings.dashboard.profileselector;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@@ -43,4 +45,12 @@ public class ProfileSelectManageApplications extends ProfileSelectFragment {
workFragment workFragment
}; };
} }
@Override
public int getTitleResId() {
final Activity activity = getActivity();
final Intent intent = activity.getIntent();
final Bundle args = getArguments();
return ManageApplications.getTitleResId(intent, args);
}
} }

View File

@@ -20,6 +20,7 @@ import android.os.Bundle;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.android.settings.R;
import com.android.settings.location.RecentLocationRequestSeeAllFragment; import com.android.settings.location.RecentLocationRequestSeeAllFragment;
/** /**
@@ -43,4 +44,9 @@ public class ProfileSelectRecentLocationRequestFragment extends ProfileSelectFra
workFragment workFragment
}; };
} }
@Override
protected int getPreferenceScreenResId() {
return R.xml.location_recent_requests_header;
}
} }

View File

@@ -21,6 +21,7 @@ import static android.provider.Settings.Secure.DOZE_TAP_SCREEN_GESTURE;
import android.annotation.UserIdInt; import android.annotation.UserIdInt;
import android.content.Context; import android.content.Context;
import android.hardware.display.AmbientDisplayConfiguration; import android.hardware.display.AmbientDisplayConfiguration;
import android.os.SystemProperties;
import android.os.UserHandle; import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
@@ -74,8 +75,10 @@ public class TapScreenGesturePreferenceController extends GesturePreferenceContr
@Override @Override
public boolean setChecked(boolean isChecked) { public boolean setChecked(boolean isChecked) {
return Settings.Secure.putInt(mContext.getContentResolver(), DOZE_TAP_SCREEN_GESTURE, boolean success = Settings.Secure.putInt(mContext.getContentResolver(),
isChecked ? 1 : 0); DOZE_TAP_SCREEN_GESTURE, isChecked ? 1 : 0);
SystemProperties.set("persist.sys.tap_gesture", isChecked ? "1" : "0");
return success;
} }
private AmbientDisplayConfiguration getAmbientConfig() { private AmbientDisplayConfiguration getAmbientConfig() {

View File

@@ -16,6 +16,8 @@
package com.android.settings.security; package com.android.settings.security;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
@@ -45,6 +47,8 @@ public class InstallCaCertificateWarning extends Activity {
setTheme(SetupWizardUtils.getTheme(this, getIntent())); setTheme(SetupWizardUtils.getTheme(this, getIntent()));
ThemeHelper.trySetDynamicColor(this); ThemeHelper.trySetDynamicColor(this);
setContentView(R.layout.ca_certificate_warning_dialog); setContentView(R.layout.ca_certificate_warning_dialog);
getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
final GlifLayout layout = findViewById(R.id.setup_wizard_layout); final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
layout.setHeaderText(R.string.ca_certificate_warning_title); layout.setHeaderText(R.string.ca_certificate_warning_title);
@@ -57,6 +61,7 @@ public class InstallCaCertificateWarning extends Activity {
.setTheme(R.style.SudGlifButton_Secondary) .setTheme(R.style.SudGlifButton_Secondary)
.build() .build()
); );
mixin.getSecondaryButtonView().setFilterTouchesWhenObscured(true);
mixin.setPrimaryButton( mixin.setPrimaryButton(
new FooterButton.Builder(this) new FooterButton.Builder(this)
@@ -66,6 +71,7 @@ public class InstallCaCertificateWarning extends Activity {
.setTheme(R.style.SudGlifButton_Primary) .setTheme(R.style.SudGlifButton_Primary)
.build() .build()
); );
mixin.getPrimaryButtonView().setFilterTouchesWhenObscured(true);
} }
private View.OnClickListener installCaCertificate() { private View.OnClickListener installCaCertificate() {

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2021 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.settings.wifi.calling;
import android.content.Context;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.util.Linkify;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
import androidx.core.text.util.LinkifyCompat;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
/** A preference which supports linkify text as a description in the summary **/
public class LinkifyDescriptionPreference extends Preference {
public LinkifyDescriptionPreference(Context context) {
this(context, null);
}
public LinkifyDescriptionPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
if (summaryView == null || summaryView.getVisibility() != View.VISIBLE) {
return;
}
final CharSequence summary = getSummary();
if (TextUtils.isEmpty(summary)) {
return;
}
summaryView.setMaxLines(Integer.MAX_VALUE);
final SpannableString spannableSummary = new SpannableString(summary);
if (spannableSummary.getSpans(0, spannableSummary.length(), ClickableSpan.class)
.length > 0) {
summaryView.setMovementMethod(LinkMovementMethod.getInstance());
}
LinkifyCompat.addLinks(summaryView,
Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS);
}
}

View File

@@ -35,9 +35,7 @@ import android.telephony.ims.ImsManager;
import android.telephony.ims.ImsMmTelManager; import android.telephony.ims.ImsMmTelManager;
import android.telephony.ims.ProvisioningManager; import android.telephony.ims.ProvisioningManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.util.Linkify;
import android.util.Log; import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -59,8 +57,11 @@ import com.android.settings.Utils;
import com.android.settings.core.SubSettingLauncher; import com.android.settings.core.SubSettingLauncher;
import com.android.settings.network.ims.WifiCallingQueryImsState; import com.android.settings.network.ims.WifiCallingQueryImsState;
import com.android.settings.widget.SettingsMainSwitchBar; import com.android.settings.widget.SettingsMainSwitchBar;
import com.android.settings.wifi.calling.LinkifyDescriptionPreference;
import com.android.settingslib.widget.OnMainSwitchChangeListener; import com.android.settingslib.widget.OnMainSwitchChangeListener;
import java.util.List;
/** /**
* This is the inner class of {@link WifiCallingSettings} fragment. * This is the inner class of {@link WifiCallingSettings} fragment.
* The preference screen lets you enable/disable Wi-Fi Calling and change Wi-Fi Calling mode. * The preference screen lets you enable/disable Wi-Fi Calling and change Wi-Fi Calling mode.
@@ -74,6 +75,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
private static final String BUTTON_WFC_MODE = "wifi_calling_mode"; private static final String BUTTON_WFC_MODE = "wifi_calling_mode";
private static final String BUTTON_WFC_ROAMING_MODE = "wifi_calling_roaming_mode"; private static final String BUTTON_WFC_ROAMING_MODE = "wifi_calling_roaming_mode";
private static final String PREFERENCE_EMERGENCY_ADDRESS = "emergency_address_key"; private static final String PREFERENCE_EMERGENCY_ADDRESS = "emergency_address_key";
private static final String PREFERENCE_NO_OPTIONS_DESC = "no_options_description";
@VisibleForTesting @VisibleForTesting
static final int REQUEST_CHECK_WFC_EMERGENCY_ADDRESS = 1; static final int REQUEST_CHECK_WFC_EMERGENCY_ADDRESS = 1;
@@ -93,7 +95,6 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
private ListWithEntrySummaryPreference mButtonWfcMode; private ListWithEntrySummaryPreference mButtonWfcMode;
private ListWithEntrySummaryPreference mButtonWfcRoamingMode; private ListWithEntrySummaryPreference mButtonWfcRoamingMode;
private Preference mUpdateAddress; private Preference mUpdateAddress;
private TextView mEmptyView;
private boolean mValidListener = false; private boolean mValidListener = false;
private boolean mEditableWfcMode = true; private boolean mEditableWfcMode = true;
@@ -187,15 +188,6 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
mEmptyView = getView().findViewById(android.R.id.empty);
setEmptyView(mEmptyView);
mEmptyView.setAutoLinkMask(Linkify.WEB_URLS);
final Resources res = getResourcesForSubId();
final String emptyViewText = res.getString(R.string.wifi_calling_off_explanation,
res.getString(R.string.wifi_calling_off_explanation_2));
mEmptyView.setText(emptyViewText);
mEmptyView.setGravity(Gravity.TOP | Gravity.LEFT);
mSwitchBar = getView().findViewById(R.id.switch_bar); mSwitchBar = getView().findViewById(R.id.switch_bar);
mSwitchBar.show(); mSwitchBar.show();
} }
@@ -311,6 +303,9 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
mIntentFilter = new IntentFilter(); mIntentFilter = new IntentFilter();
mIntentFilter.addAction(ImsManager.ACTION_WFC_IMS_REGISTRATION_ERROR); mIntentFilter.addAction(ImsManager.ACTION_WFC_IMS_REGISTRATION_ERROR);
updateDescriptionForOptions(
List.of(mButtonWfcMode, mButtonWfcRoamingMode, mUpdateAddress));
} }
@Override @Override
@@ -326,7 +321,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
final View view = inflater.inflate( final View view = inflater.inflate(
R.layout.wifi_calling_settings_preferences, container, false); R.layout.wifi_calling_settings_preferences, container, false);
final ViewGroup prefs_container = view.findViewById(R.id.prefs_container); final ViewGroup prefs_container = view.findViewById(android.R.id.tabcontent);
Utils.prepareCustomPreferencesList(container, view, prefs_container, false); Utils.prepareCustomPreferencesList(container, view, prefs_container, false);
final View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState); final View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState);
prefs_container.addView(prefs); prefs_container.addView(prefs);
@@ -575,28 +570,35 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
final PreferenceScreen preferenceScreen = getPreferenceScreen(); final PreferenceScreen preferenceScreen = getPreferenceScreen();
final boolean updateAddressEnabled = (getCarrierActivityIntent() != null); final boolean updateAddressEnabled = (getCarrierActivityIntent() != null);
if (wfcEnabled) { if (wfcEnabled) {
if (mEditableWfcMode) { // Don't show WFC (home) preference if it's not editable.
preferenceScreen.addPreference(mButtonWfcMode); mButtonWfcMode.setVisible(mEditableWfcMode);
} else { // Don't show WFC roaming preference if it's not editable.
// Don't show WFC (home) preference if it's not editable. mButtonWfcRoamingMode.setVisible(
preferenceScreen.removePreference(mButtonWfcMode); mEditableWfcRoamingMode && !mUseWfcHomeModeForRoaming);
} mUpdateAddress.setVisible(updateAddressEnabled);
if (mEditableWfcRoamingMode && !mUseWfcHomeModeForRoaming) {
preferenceScreen.addPreference(mButtonWfcRoamingMode);
} else {
// Don't show WFC roaming preference if it's not editable.
preferenceScreen.removePreference(mButtonWfcRoamingMode);
}
if (updateAddressEnabled) {
preferenceScreen.addPreference(mUpdateAddress);
} else {
preferenceScreen.removePreference(mUpdateAddress);
}
} else { } else {
preferenceScreen.removePreference(mButtonWfcMode); mButtonWfcMode.setVisible(false);
preferenceScreen.removePreference(mButtonWfcRoamingMode); mButtonWfcRoamingMode.setVisible(false);
preferenceScreen.removePreference(mUpdateAddress); mUpdateAddress.setVisible(false);
} }
updateDescriptionForOptions(
List.of(mButtonWfcMode, mButtonWfcRoamingMode, mUpdateAddress));
}
private void updateDescriptionForOptions(List<Preference> visibleOptions) {
LinkifyDescriptionPreference pref = findPreference(PREFERENCE_NO_OPTIONS_DESC);
if (pref == null) {
return;
}
boolean optionsAvailable = visibleOptions.stream().anyMatch(Preference::isVisible);
if (!optionsAvailable) {
final Resources res = getResourcesForSubId();
String emptyViewText = res.getString(R.string.wifi_calling_off_explanation,
res.getString(R.string.wifi_calling_off_explanation_2));
pref.setSummary(emptyViewText);
}
pref.setVisible(!optionsAvailable);
} }
@Override @Override