Skip to content

Commit ce3064c

Browse files
committed
Improve UX
Improves the UX a little, names, addresses, states and cities are auto-capitalized now. Adds easy switching from one form field to another. The text field before the send button, can now also be used to send the formular, so you don't have to click the send button.
1 parent 62295e4 commit ce3064c

File tree

4 files changed

+45
-11
lines changed

4 files changed

+45
-11
lines changed

android/src/main/java/org/robovm/store/fragments/LoginFragment.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
import android.text.Html;
2525
import android.text.Spanned;
2626
import android.util.TypedValue;
27+
import android.view.KeyEvent;
2728
import android.view.LayoutInflater;
2829
import android.view.View;
2930
import android.view.ViewGroup;
31+
import android.view.inputmethod.EditorInfo;
3032
import android.widget.*;
3133
import org.robovm.store.R;
3234
import org.robovm.store.api.RoboVMWebService;
@@ -81,11 +83,21 @@ private View createLoginView(LayoutInflater inflater, ViewGroup container, Bundl
8183
imageView = (ImageView) view.findViewById(R.id.imageView1);
8284
loadUserImage();
8385

84-
EditText textView = (EditText) view.findViewById(R.id.email);
85-
textView.setEnabled(false);
86-
textView.setText(ROBOVM_ACCOUNT_EMAIL);
86+
EditText email = (EditText) view.findViewById(R.id.email);
87+
email.setEnabled(false);
88+
email.setText(ROBOVM_ACCOUNT_EMAIL);
8789

8890
password = (EditText) view.findViewById(R.id.password);
91+
password.setOnEditorActionListener(new TextView.OnEditorActionListener() {
92+
@Override
93+
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
94+
if (actionId == EditorInfo.IME_ACTION_SEND) {
95+
login(ROBOVM_ACCOUNT_EMAIL, password.getText().toString());
96+
return true;
97+
}
98+
return false;
99+
}
100+
});
89101
login = (Button) view.findViewById(R.id.signInBtn);
90102
login.setText(getLocalizedString(Key.log_in_title));
91103
login.setOnClickListener((b) -> {

android/src/main/java/org/robovm/store/fragments/ShippingDetailsFragment.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import android.app.Fragment;
2020
import android.app.ProgressDialog;
2121
import android.os.Bundle;
22+
import android.view.KeyEvent;
2223
import android.view.LayoutInflater;
2324
import android.view.View;
2425
import android.view.ViewGroup;
26+
import android.view.inputmethod.EditorInfo;
2527
import android.widget.*;
2628
import org.robovm.store.R;
2729
import org.robovm.store.api.RoboVMWebService;
@@ -100,6 +102,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
100102
stateField = (AutoCompleteTextView) shippingDetailsView.findViewById(R.id.state);
101103
stateField.setText(user.getState());
102104
stateField.setHint(getLocalizedString(Key.state));
105+
stateField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
106+
@Override
107+
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
108+
if (actionId == EditorInfo.IME_ACTION_SEND) {
109+
placeOrder();
110+
return true;
111+
}
112+
return false;
113+
}
114+
});
103115

104116

105117
zipCodeField = (EditText) shippingDetailsView.findViewById(R.id.postalCode);

android/src/main/res/layout/login_screen.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
android:id="@+id/password"
2626
android:layout_marginTop="2dp"
2727
android:layout_marginBottom="4dp"
28-
android:singleLine="true"/>
28+
android:singleLine="true"
29+
android:imeOptions="actionSend"/>
2930
<Button
3031
style="@style/RoboButton"
3132
android:layout_width="match_parent"

android/src/main/res/layout/shipping_details.xml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,62 +24,71 @@
2424
android:paddingRight="16dp"
2525
android:paddingLeft="16dp">
2626
<EditText
27-
android:inputType="textPersonName"
27+
android:inputType="textPersonName|textCapWords"
2828
android:layout_width="match_parent"
2929
android:layout_height="wrap_content"
30+
android:imeOptions="actionNext"
3031
android:id="@+id/firstName"/>
3132
<EditText
32-
android:inputType="textPersonName"
33+
android:inputType="textPersonName|textCapWords"
3334
android:layout_width="match_parent"
3435
android:layout_height="wrap_content"
36+
android:imeOptions="actionNext"
3537
android:id="@+id/lastName"/>
3638
<EditText
3739
android:inputType="phone"
3840
android:layout_width="match_parent"
3941
android:layout_height="wrap_content"
42+
android:imeOptions="actionNext"
4043
android:id="@+id/phone"
4144
android:layout_marginTop="4dp"
4245
android:layout_marginBottom="4dp"/>
4346
<EditText
44-
android:inputType="textPostalAddress"
47+
android:inputType="textPostalAddress|textCapWords"
4548
android:layout_width="fill_parent"
4649
android:layout_height="wrap_content"
50+
android:imeOptions="actionNext"
4751
android:id="@+id/streetAddress1"
4852
android:layout_marginTop="4dp"
4953
android:layout_marginBottom="4dp"/>
5054
<EditText
51-
android:inputType="textPostalAddress"
55+
android:inputType="textPostalAddress|textCapWords"
5256
android:layout_width="fill_parent"
5357
android:layout_height="wrap_content"
58+
android:imeOptions="actionNext"
5459
android:id="@+id/streetAddress2"
5560
android:layout_marginTop="4dp"
5661
android:layout_marginBottom="4dp"/>
5762
<EditText
58-
android:inputType="textPostalAddress"
63+
android:inputType="textPostalAddress|textCapWords"
5964
android:layout_width="fill_parent"
6065
android:layout_height="wrap_content"
66+
android:imeOptions="actionNext"
6167
android:id="@+id/city"
6268
android:layout_marginTop="4dp"
6369
android:layout_marginBottom="4dp"/>
6470
<EditText
65-
android:inputType="text"
71+
android:inputType="text|textCapWords"
6672
android:layout_width="fill_parent"
6773
android:layout_height="wrap_content"
74+
android:imeOptions="actionNext"
6875
android:id="@+id/postalCode"
6976
android:layout_marginTop="4dp"
7077
android:layout_marginBottom="4dp"/>
7178
<AutoCompleteTextView
79+
android:inputType="text|textCapWords"
7280
android:layout_width="match_parent"
7381
android:layout_height="wrap_content"
7482
android:id="@+id/country"
7583
android:imeOptions="actionNext"
7684
android:layout_marginTop="4dp"
7785
android:layout_marginBottom="4dp"/>
7886
<AutoCompleteTextView
87+
android:inputType="text|textCapWords"
7988
android:layout_width="match_parent"
8089
android:layout_height="wrap_content"
8190
android:id="@+id/state"
82-
android:imeOptions="actionDone"
91+
android:imeOptions="actionSend"
8392
android:layout_marginTop="4dp"
8493
android:layout_marginBottom="4dp"/>
8594
<Button

0 commit comments

Comments
 (0)