diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 493d7f4d626..c2afb23eeec 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1621,14 +1621,9 @@ android:resource="@id/nfc_payment_settings" /> - - - - - diff --git a/res/drawable-hdpi/nfc_payment_empty_state.png b/res/drawable-hdpi/nfc_payment_empty_state.png new file mode 100644 index 00000000000..69b22f26557 Binary files /dev/null and b/res/drawable-hdpi/nfc_payment_empty_state.png differ diff --git a/res/drawable-mdpi/nfc_payment_empty_state.png b/res/drawable-mdpi/nfc_payment_empty_state.png new file mode 100644 index 00000000000..1ab71871f91 Binary files /dev/null and b/res/drawable-mdpi/nfc_payment_empty_state.png differ diff --git a/res/drawable-xhdpi/nfc_payment_empty_state.png b/res/drawable-xhdpi/nfc_payment_empty_state.png new file mode 100644 index 00000000000..3951c8230e7 Binary files /dev/null and b/res/drawable-xhdpi/nfc_payment_empty_state.png differ diff --git a/res/drawable-xxhdpi/nfc_payment_empty_state.png b/res/drawable-xxhdpi/nfc_payment_empty_state.png new file mode 100644 index 00000000000..914021a941e Binary files /dev/null and b/res/drawable-xxhdpi/nfc_payment_empty_state.png differ diff --git a/res/layout/nfc_payment.xml b/res/layout/nfc_payment.xml new file mode 100644 index 00000000000..92fe86f4e54 --- /dev/null +++ b/res/layout/nfc_payment.xml @@ -0,0 +1,33 @@ + + + + + + + + diff --git a/res/layout/nfc_payment_option.xml b/res/layout/nfc_payment_option.xml index 122e04154ff..04fdc076c35 100644 --- a/res/layout/nfc_payment_option.xml +++ b/res/layout/nfc_payment_option.xml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - - - - - + - + diff --git a/res/values/strings.xml b/res/values/strings.xml index 492697d1891..d316609eadb 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4678,13 +4678,13 @@ Payments - - Ask every time + + DO NOT TRANSLATE ME - Set as your preference? - + Set as your preference? + Always use %1$s when you tap and pay? + Always use %1$s instead of %2$s when you tap and pay? diff --git a/src/com/android/settings/nfc/PaymentBackend.java b/src/com/android/settings/nfc/PaymentBackend.java index e2f110faf2e..59f4ddfb3f3 100644 --- a/src/com/android/settings/nfc/PaymentBackend.java +++ b/src/com/android/settings/nfc/PaymentBackend.java @@ -33,7 +33,7 @@ public class PaymentBackend { public static class PaymentAppInfo { CharSequence caption; - Drawable icon; + Drawable banner; boolean isDefault; public ComponentName componentName; } @@ -62,7 +62,7 @@ public class PaymentBackend { for (ApduServiceInfo service : serviceInfos) { PaymentAppInfo appInfo = new PaymentAppInfo(); appInfo.caption = service.loadLabel(pm); - appInfo.icon = service.loadIcon(pm); + appInfo.banner = service.loadBanner(pm); appInfo.isDefault = service.getComponent().equals(defaultApp); appInfo.componentName = service.getComponent(); appInfos.add(appInfo); diff --git a/src/com/android/settings/nfc/PaymentDefaultDialog.java b/src/com/android/settings/nfc/PaymentDefaultDialog.java index ae2f4c1b340..538af2e3a44 100644 --- a/src/com/android/settings/nfc/PaymentDefaultDialog.java +++ b/src/com/android/settings/nfc/PaymentDefaultDialog.java @@ -125,12 +125,15 @@ public final class PaymentDefaultDialog extends AlertActivity implements // Compose dialog; get final AlertController.AlertParams p = mAlertParams; - p.mTitle = getString(R.string.nfc_payment_set_default); + p.mTitle = getString(R.string.nfc_payment_set_default_label); if (defaultAppInfo == null) { - p.mMessage = "Always use " + newAppInfo.loadLabel(pm) + " when you tap and pay?"; + String formatString = getString(R.string.nfc_payment_set_default); + String msg = String.format(formatString, newAppInfo.loadLabel(pm)); + p.mMessage = msg; } else { - p.mMessage = "Always use " + newAppInfo.loadLabel(pm) + " instead of " + - defaultAppInfo.loadLabel(pm) + " when you tap and pay?"; + String formatString = getString(R.string.nfc_payment_set_default_instead_of); + String msg = String.format(formatString, newAppInfo.loadLabel(pm), defaultAppInfo.loadLabel(pm)); + p.mMessage = msg; } p.mPositiveButtonText = getString(R.string.yes); p.mNegativeButtonText = getString(R.string.no); diff --git a/src/com/android/settings/nfc/PaymentSettings.java b/src/com/android/settings/nfc/PaymentSettings.java index af569ac1061..d3ccbaf42b3 100644 --- a/src/com/android/settings/nfc/PaymentSettings.java +++ b/src/com/android/settings/nfc/PaymentSettings.java @@ -21,9 +21,14 @@ import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceManager; import android.preference.PreferenceScreen; +import android.util.Log; +import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.RadioButton; +import android.widget.TextView; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; @@ -34,14 +39,17 @@ import java.util.List; public class PaymentSettings extends SettingsPreferenceFragment implements OnClickListener { public static final String TAG = "PaymentSettings"; + private LayoutInflater mInflater; private PaymentBackend mPaymentBackend; + @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setHasOptionsMenu(false); mPaymentBackend = new PaymentBackend(getActivity()); + mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public void refresh() { @@ -55,12 +63,35 @@ public class PaymentSettings extends SettingsPreferenceFragment implements for (PaymentAppInfo appInfo : appInfos) { PaymentAppPreference preference = new PaymentAppPreference(getActivity(), appInfo, this); - preference.setIcon(appInfo.icon); preference.setTitle(appInfo.caption); - screen.addPreference(preference); + if (appInfo.banner != null) { + screen.addPreference(preference); + } else { + // Ignore, no banner + Log.e(TAG, "Couldn't load banner drawable of service " + appInfo.componentName); + } } } - setPreferenceScreen(screen); + TextView emptyText = (TextView) getView().findViewById(R.id.nfc_payment_empty_text); + ImageView emptyImage = (ImageView) getView().findViewById(R.id.nfc_payment_tap_image); + if (screen.getPreferenceCount() == 0) { + emptyText.setVisibility(View.VISIBLE); + emptyImage.setVisibility(View.VISIBLE); + } else { + emptyText.setVisibility(View.GONE); + emptyImage.setVisibility(View.GONE); + setPreferenceScreen(screen); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + super.onCreateView(inflater, container, savedInstanceState); + + View v = mInflater.inflate(R.layout.nfc_payment, container, false); + + return v; } @Override @@ -101,6 +132,9 @@ public class PaymentSettings extends SettingsPreferenceFragment implements RadioButton radioButton = (RadioButton) view.findViewById(android.R.id.button1); radioButton.setChecked(appInfo.isDefault); + + ImageView banner = (ImageView) view.findViewById(R.id.banner); + banner.setImageDrawable(appInfo.banner); } } } \ No newline at end of file