Fix the display abnormal of Tap & pay screen in landscape mode
- Add a new layout for the landscape mode. - Update the logic to show image when has no any visible preference. Bug: 141559275 Test: manual view make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.nfc Change-Id: Ib59ad3347e0635c07d61d557d75f8feaf78ff23c
This commit is contained in:
36
res/layout-land/nfc_payment_empty.xml
Normal file
36
res/layout-land/nfc_payment_empty.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2019 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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical|right"
|
||||
android:src="@drawable/tapandpay_emptystate"/>
|
||||
<TextView
|
||||
android:layout_width="264dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingStart="36dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:text="@string/nfc_payment_no_apps"/>
|
||||
</LinearLayout>
|
@@ -30,6 +30,10 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
@@ -70,10 +74,11 @@ public class PaymentSettings extends DashboardFragment {
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
View emptyView = getActivity().getLayoutInflater().inflate(
|
||||
R.layout.nfc_payment_empty, null, false);
|
||||
((ViewGroup) view.findViewById(android.R.id.list_container)).addView(emptyView);
|
||||
if (isShowEmptyImage(getPreferenceScreen())) {
|
||||
View emptyView = getActivity().getLayoutInflater().inflate(
|
||||
R.layout.nfc_payment_empty, null, false);
|
||||
((ViewGroup) view.findViewById(android.R.id.list_container)).addView(emptyView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,6 +102,17 @@ public class PaymentSettings extends DashboardFragment {
|
||||
menuItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isShowEmptyImage(PreferenceScreen screen) {
|
||||
for (int i = 0; i < screen.getPreferenceCount(); i++) {
|
||||
final Preference preference = screen.getPreference(i);
|
||||
if(preference.isVisible()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.nfc_payment_settings) {
|
||||
|
||||
|
@@ -29,6 +29,10 @@ import android.content.pm.UserInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -113,6 +117,34 @@ public class PaymentSettingsTest {
|
||||
assertThat(niks).containsAllOf(FOREGROUND_KEY, PAYMENT_KEY, PAYMENT_SCREEN_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isShowEmptyImage_hasVisiblePreference_returnFalse() {
|
||||
final PaymentSettings paymentSettings = new PaymentSettings();
|
||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
|
||||
final Preference preference1 = new Preference(mContext);
|
||||
screen.addPreference(preference1);
|
||||
final Preference preference2 = new Preference(mContext);
|
||||
screen.addPreference(preference2);
|
||||
|
||||
assertThat(paymentSettings.isShowEmptyImage(screen)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isShowEmptyImage_hasNoVisiblePreference_returnTrue() {
|
||||
final PaymentSettings paymentSettings = new PaymentSettings();
|
||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
|
||||
final Preference preference1 = new Preference(mContext);
|
||||
preference1.setVisible(false);
|
||||
screen.addPreference(preference1);
|
||||
final Preference preference2 = new Preference(mContext);
|
||||
screen.addPreference(preference2);
|
||||
preference2.setVisible(false);
|
||||
|
||||
assertThat(paymentSettings.isShowEmptyImage(screen)).isTrue();
|
||||
}
|
||||
|
||||
@Implements(PaymentBackend.class)
|
||||
public static class ShadowPaymentBackend {
|
||||
private ArrayList<PaymentBackend.PaymentAppInfo> mAppInfos;
|
||||
|
Reference in New Issue
Block a user