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:
@@ -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) {
|
||||
|
||||
|
Reference in New Issue
Block a user