Skip to content

Commit fb8d2f4

Browse files
committed
Improved the drone's nickname design
1 parent f765738 commit fb8d2f4

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

app/src/main/java/com/fewlaps/flone/view/dialog/ChooseDeviceNickNameDialog.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.support.v4.app.DialogFragment;
99
import android.support.v4.app.FragmentActivity;
1010
import android.view.LayoutInflater;
11+
import android.view.View;
1112
import android.widget.EditText;
1213

1314
import com.fewlaps.flone.R;
@@ -23,20 +24,19 @@ public static void showDialog(FragmentActivity a) {
2324
new ChooseDeviceNickNameDialog().show(a.getSupportFragmentManager(), "ChooseDeviceNickNameDialog");
2425
}
2526

26-
EditText etNickName = null;
27-
OnDeviceNickNameSetListener listener = null;
27+
private OnDeviceNickNameSetListener listener = null;
2828

2929
@Override
3030
public Dialog onCreateDialog(Bundle savedInstanceState) {
3131
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
3232
LayoutInflater inflater = getActivity().getLayoutInflater();
3333

34-
etNickName = (EditText) inflater.inflate(R.layout.dialog_choose_nick, null);
35-
36-
builder.setView(etNickName).setPositiveButton(R.string.action_ok, new DialogInterface.OnClickListener() {
34+
final View root = inflater.inflate(R.layout.dialog_choose_nick, null);
35+
builder.setView(root).setPositiveButton(R.string.action_ok, new DialogInterface.OnClickListener() {
3736
@Override
3837
public void onClick(DialogInterface dialog, int id) {
39-
listener.onDeviceNickNameSetListener(etNickName.getText().toString());
38+
EditText nickNameET = (EditText) root.findViewById(R.id.et_nickname);
39+
listener.onDeviceNickNameSetListener(nickNameET.getText().toString());
4040
}
4141
});
4242
return builder.create();
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
2-
android:id="@+id/et_nickname"
1+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
32
android:layout_width="match_parent"
43
android:layout_height="wrap_content"
5-
android:layout_margin="@dimen/gapMedium"
6-
android:hint="@string/add_drone_nickname_hint"
7-
android:padding="@dimen/gapMedium"
8-
android:singleLine="true" />
4+
android:padding="@dimen/gapMedium">
5+
6+
<EditText
7+
android:id="@+id/et_nickname"
8+
android:layout_width="match_parent"
9+
android:layout_height="wrap_content"
10+
android:hint="@string/add_drone_nickname_hint"
11+
android:singleLine="true" />
12+
</FrameLayout>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<string name="add_drone_launch_bt_screen">Pair the drone with the phone</string>
2323
<string name="add_drone_zero1">There isn\'t any paired bluetooth device</string>
2424
<string name="add_drone_zero2">Did you tried to switch on the drone?</string>
25-
<string name="add_drone_nickname_hint">Write a friendly name for this drone...</string>
25+
<string name="add_drone_nickname_hint">Drone\'s nickname</string>
2626

2727
<!-- Remove a drone -->
2828
<string name="remove_drone_confirmation">Are you sure you want to remove the drone %1$s?</string>

0 commit comments

Comments
 (0)