HCE: Latest UX and strings.

Bug: 10262585
Change-Id: I5473c4d387fed884faf77c7448fab1332f710557
This commit is contained in:
Martijn Coenen
2013-09-05 21:07:23 -07:00
parent e9aa0a94d0
commit da6c0ba382
11 changed files with 94 additions and 58 deletions

View File

@@ -1621,14 +1621,9 @@
android:resource="@id/nfc_payment_settings" /> android:resource="@id/nfc_payment_settings" />
</activity> </activity>
<activity android:name=".nfc.PaymentDefaultDialog" <activity android:name=".nfc.PaymentDefaultDialog"
android:label="@string/nfc_payment_set_default" android:label="@string/nfc_payment_set_default_label"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:theme="@*android:style/Theme.Holo.Light.Dialog.Alert"> android:theme="@*android:style/Theme.Holo.Light.Dialog.Alert">
<intent-filter>
<!-- TODO this filter can be removed -->
<action android:name="android.nfc.cardemulation.ACTION_CHANGE_DEFAULT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT" /> <action android:name="android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -0,0 +1,33 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@+id/nfc_payment_empty_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="24sp"
android:visibility="gone"
android:paddingBottom="16dp"
android:text="@string/nfc_payment_no_apps"/>
<ImageView
android:id="@+id/nfc_payment_tap_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:visibility="gone"
android:src="@drawable/nfc_payment_empty_state"/>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp" />
</FrameLayout>

View File

@@ -13,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
@@ -21,53 +21,24 @@
android:focusable="true" android:focusable="true"
android:clickable="true" android:clickable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:minHeight="?android:attr/listPreferredItemHeight" android:minHeight="?android:attr/listPreferredItemHeight"
android:background="?android:attr/selectableItemBackground"> android:background="?android:attr/selectableItemBackground">
<LinearLayout <FrameLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:minWidth="@*android:dimen/preference_icon_minWidth" android:minWidth="@*android:dimen/preference_icon_minWidth"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+android:id/icon" android:id="@+id/banner"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center" android:layout_gravity="center"
android:minWidth="48dp" android:layout_width="wrap_content"
android:layout_height="96dp"
android:scaleType="centerInside" android:scaleType="centerInside"
android:layout_marginEnd="@*android:dimen/preference_item_padding_inner"
/> />
</LinearLayout> </FrameLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_weight="1">
<TextView
android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:fadingEdge="horizontal"/>
<TextView
android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:paddingBottom="3dip"
android:visibility="gone"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="13sp"
android:textColor="?android:attr/textColorSecondary"
android:focusable="false"
android:maxLines="4" />
</RelativeLayout>
<RadioButton <RadioButton
android:id="@android:id/button1" android:id="@android:id/button1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -77,4 +48,4 @@
android:duplicateParentState="true" android:duplicateParentState="true"
android:clickable="false" android:clickable="false"
android:focusable="false" /> android:focusable="false" />
</LinearLayout> </RelativeLayout>

View File

@@ -4678,13 +4678,13 @@
<!-- NFC payment settings --><skip/> <!-- NFC payment settings --><skip/>
<string name="nfc_payment_settings_title">Payments</string> <string name="nfc_payment_settings_title">Payments</string>
<!-- Option to tell Android to ask the user which payment app to use every time <!-- String shown when there are no NFC payment applications installed -->
a payment terminal is tapped --> <string name="nfc_payment_no_apps">DO NOT TRANSLATE ME</string>
<string name="nfc_payment_ask">Ask every time</string>
<!-- Label for the dialog that is shown when the user is asked to set a <!-- Label for the dialog that is shown when the user is asked to set a
preferred payment application --> preferred payment application -->
<string name="nfc_payment_set_default">Set as your preference?</string> <string name="nfc_payment_set_default_label">Set as your preference?</string>
<string name="nfc_payment_set_default">Always use <xliff:g id="app">%1$s</xliff:g> when you tap and pay?</string>
<string name="nfc_payment_set_default_instead_of">Always use <xliff:g id="app">%1$s</xliff:g> instead of <xliff:g id="app">%2$s</xliff:g> when you tap and pay?</string>
<!-- Restrictions settings --><skip/> <!-- Restrictions settings --><skip/>
<!-- Restriction settings title [CHAR LIMIT=35] --> <!-- Restriction settings title [CHAR LIMIT=35] -->

View File

@@ -33,7 +33,7 @@ public class PaymentBackend {
public static class PaymentAppInfo { public static class PaymentAppInfo {
CharSequence caption; CharSequence caption;
Drawable icon; Drawable banner;
boolean isDefault; boolean isDefault;
public ComponentName componentName; public ComponentName componentName;
} }
@@ -62,7 +62,7 @@ public class PaymentBackend {
for (ApduServiceInfo service : serviceInfos) { for (ApduServiceInfo service : serviceInfos) {
PaymentAppInfo appInfo = new PaymentAppInfo(); PaymentAppInfo appInfo = new PaymentAppInfo();
appInfo.caption = service.loadLabel(pm); appInfo.caption = service.loadLabel(pm);
appInfo.icon = service.loadIcon(pm); appInfo.banner = service.loadBanner(pm);
appInfo.isDefault = service.getComponent().equals(defaultApp); appInfo.isDefault = service.getComponent().equals(defaultApp);
appInfo.componentName = service.getComponent(); appInfo.componentName = service.getComponent();
appInfos.add(appInfo); appInfos.add(appInfo);

View File

@@ -125,12 +125,15 @@ public final class PaymentDefaultDialog extends AlertActivity implements
// Compose dialog; get // Compose dialog; get
final AlertController.AlertParams p = mAlertParams; 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) { 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 { } else {
p.mMessage = "Always use " + newAppInfo.loadLabel(pm) + " instead of " + String formatString = getString(R.string.nfc_payment_set_default_instead_of);
defaultAppInfo.loadLabel(pm) + " when you tap and pay?"; String msg = String.format(formatString, newAppInfo.loadLabel(pm), defaultAppInfo.loadLabel(pm));
p.mMessage = msg;
} }
p.mPositiveButtonText = getString(R.string.yes); p.mPositiveButtonText = getString(R.string.yes);
p.mNegativeButtonText = getString(R.string.no); p.mNegativeButtonText = getString(R.string.no);

View File

@@ -21,9 +21,14 @@ import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.TextView;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SettingsPreferenceFragment;
@@ -34,14 +39,17 @@ import java.util.List;
public class PaymentSettings extends SettingsPreferenceFragment implements public class PaymentSettings extends SettingsPreferenceFragment implements
OnClickListener { OnClickListener {
public static final String TAG = "PaymentSettings"; public static final String TAG = "PaymentSettings";
private LayoutInflater mInflater;
private PaymentBackend mPaymentBackend; private PaymentBackend mPaymentBackend;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
setHasOptionsMenu(false); setHasOptionsMenu(false);
mPaymentBackend = new PaymentBackend(getActivity()); mPaymentBackend = new PaymentBackend(getActivity());
mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} }
public void refresh() { public void refresh() {
@@ -55,13 +63,36 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
for (PaymentAppInfo appInfo : appInfos) { for (PaymentAppInfo appInfo : appInfos) {
PaymentAppPreference preference = PaymentAppPreference preference =
new PaymentAppPreference(getActivity(), appInfo, this); new PaymentAppPreference(getActivity(), appInfo, this);
preference.setIcon(appInfo.icon);
preference.setTitle(appInfo.caption); preference.setTitle(appInfo.caption);
if (appInfo.banner != null) {
screen.addPreference(preference); screen.addPreference(preference);
} else {
// Ignore, no banner
Log.e(TAG, "Couldn't load banner drawable of service " + appInfo.componentName);
} }
} }
}
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); 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 @Override
public void onClick(View v) { public void onClick(View v) {
@@ -101,6 +132,9 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
RadioButton radioButton = (RadioButton) view.findViewById(android.R.id.button1); RadioButton radioButton = (RadioButton) view.findViewById(android.R.id.button1);
radioButton.setChecked(appInfo.isDefault); radioButton.setChecked(appInfo.isDefault);
ImageView banner = (ImageView) view.findViewById(R.id.banner);
banner.setImageDrawable(appInfo.banner);
} }
} }
} }