Skip to content

Commit 30ac80f

Browse files
Tweak pairing micro:bit wording and adding a step for pin (#57)
- Added enter pin if needed instruction step to pairing flow - Remove 30 sec warning text - Tweaked searching for micro:bit text
1 parent be8e11c commit 30ac80f

12 files changed

+304
-110
lines changed

app/src/main/java/com/samsung/microbit/ui/activity/PairingActivity.java

Lines changed: 45 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import android.content.IntentFilter;
1414
import android.content.pm.PackageManager;
1515
import android.content.res.Configuration;
16-
import android.graphics.Color;
1716
import android.graphics.Typeface;
1817
import android.graphics.drawable.Drawable;
1918
import android.location.LocationManager;
@@ -103,6 +102,7 @@ private enum PAIRING_STATE {
103102
PAIRING_STATE_TRIPLE,
104103
PAIRING_STATE_STEP_1,
105104
PAIRING_STATE_STEP_2,
105+
PAIRING_STATE_ENTER_PIN_IF_NEEDED,
106106
PAIRING_STATE_SEARCHING,
107107
PAIRING_STATE_ERROR
108108
}
@@ -119,6 +119,7 @@ private enum PAIRING_STATE {
119119
LinearLayout pairTipView;
120120
View connectDeviceView;
121121
LinearLayout newDeviceView;
122+
LinearLayout enterPinIfNeededView;
122123
LinearLayout pairSearchView;
123124
LinearLayout bottomPairButton;
124125

@@ -221,7 +222,6 @@ public void run() {
221222
logi("BLEPairResult " + result);
222223
switch ( result) {
223224
case Found:
224-
updateOnScanFound();
225225
// We need to connect even if bonded, to get resultHardwareVersion
226226
// if ( getBLEPair().resultDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
227227
// logi("scan found device already paired");
@@ -235,9 +235,6 @@ public void run() {
235235
popupPairingFailed();
236236
}
237237
break;
238-
case Connected:
239-
updateOnConnected();
240-
break;
241238
case Paired:
242239
handlePairingSuccessful();
243240
break;
@@ -251,6 +248,7 @@ public void run() {
251248
popupPairingFailed();
252249
break;
253250
default:
251+
// Connected and None case are not specifically handled
254252
break;
255253
}
256254
}
@@ -264,10 +262,6 @@ private void stopScanning() {
264262

265263
private void startScanning() {
266264
logi("###>>>>>>>>>>>>>>>>>>>>> startScanning");
267-
268-
((TextView) findViewById(R.id.search_microbit_step_3_title))
269-
.setText(getString(R.string.searchingTitle));
270-
271265
getBLEPair().startScan();
272266
}
273267

@@ -690,7 +684,7 @@ private void setupFontStyle() {
690684
nextPairButton.setTypeface(robotoTypeface);
691685

692686

693-
// Step 2 - Enter Pattern
687+
// Enter Pattern
694688
TextView enterPatternTitle = (TextView) findViewById(R.id.enter_pattern_step_2_title);
695689
enterPatternTitle.setTypeface(boldTypeface);
696690

@@ -706,17 +700,26 @@ private void setupFontStyle() {
706700
Button okEnterPatternButton = (Button) findViewById(R.id.ok_enter_pattern_step_2_btn);
707701
okEnterPatternButton.setTypeface(robotoTypeface);
708702

703+
// Enter pin if needed
704+
TextView enterPinIfNeededTitle = (TextView) findViewById(R.id.enter_pin_if_needed_title);
705+
enterPinIfNeededTitle.setTypeface(boldTypeface);
706+
707+
TextView enterPinIfNeededText = (TextView) findViewById(R.id.enter_pin_if_needed_text);
708+
enterPinIfNeededText.setTypeface(boldTypeface);
709709

710-
// Step 3 - Searching for micro:bit
710+
Button cancelEnterPinIfNeededButton = (Button) findViewById(R.id.cancel_enter_pin_if_needed_btn);
711+
cancelEnterPinIfNeededButton.setTypeface(robotoTypeface);
712+
713+
Button nextEnterPinIfNeededButton = (Button) findViewById(R.id.next_enter_pin_if_needed_btn);
714+
nextEnterPinIfNeededButton.setTypeface(robotoTypeface);
715+
716+
// Searching for micro:bit
711717
TextView searchMicrobitTitle = (TextView) findViewById(R.id.search_microbit_step_3_title);
712718
searchMicrobitTitle.setTypeface(boldTypeface);
713719

714720
TextView stepThreeTitle = (TextView) findViewById(R.id.searching_microbit_step);
715721
stepThreeTitle.setTypeface(boldTypeface);
716722

717-
TextView stepThreeInstructions = (TextView) findViewById(R.id.searching_microbit_step_instructions);
718-
stepThreeInstructions.setTypeface(robotoTypeface);
719-
720723
Button cancelSearchMicroBit = (Button) findViewById(R.id.cancel_search_microbit_step_3_btn);
721724
cancelSearchMicroBit.setTypeface(robotoTypeface);
722725

@@ -739,6 +742,7 @@ private void initViews() {
739742
pairTipView = (LinearLayout) findViewById(R.id.pairTipView);
740743
connectDeviceView = findViewById(R.id.connectDeviceView);
741744
newDeviceView = (LinearLayout) findViewById(R.id.newDeviceView);
745+
enterPinIfNeededView = (LinearLayout) findViewById(R.id.enterPinIfNeededView);
742746
pairSearchView = (LinearLayout) findViewById(R.id.pairSearchView);
743747

744748
//Setup on click listeners.
@@ -751,6 +755,9 @@ private void initViews() {
751755
findViewById(R.id.ok_enter_pattern_step_2_btn).setOnClickListener(this);
752756
findViewById(R.id.cancel_enter_pattern_step_2_btn).setOnClickListener(this);
753757

758+
findViewById(R.id.next_enter_pin_if_needed_btn).setOnClickListener(this);
759+
findViewById(R.id.cancel_enter_pin_if_needed_btn).setOnClickListener(this);
760+
754761
findViewById(R.id.cancel_search_microbit_step_3_btn).setOnClickListener(this);
755762

756763
setupFontStyle();
@@ -764,6 +771,7 @@ private void releaseViews() {
764771
pairTipView = null;
765772
connectDeviceView = null;
766773
newDeviceView = null;
774+
enterPinIfNeededView = null;
767775
pairSearchView = null;
768776
}
769777

@@ -1053,44 +1061,6 @@ private void updatePairedDeviceCard() {
10531061
logi("updatePairedDeviceCard End");
10541062
}
10551063

1056-
private void updateOnScanFound() {
1057-
logi("updateOnScanFound");
1058-
TextView textView = (TextView) findViewById(R.id.search_microbit_step_3_title);
1059-
TextView tvSearchingStep = (TextView) findViewById(R.id.searching_microbit_step);
1060-
TextView tvSearchingInstructions = (TextView) findViewById(R.id.searching_microbit_step_instructions);
1061-
if (textView != null) {
1062-
textView.setText(getString(R.string.searchingTitle));
1063-
//findViewById(R.id.searching_progress_spinner).setVisibility(View.GONE);
1064-
((GifImageView) findViewById(R.id.searching_microbit_found_giffview))
1065-
.setImageResource(R.drawable.emoji_microbit_found);
1066-
// if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
1067-
// tvSearchingStep.setText(R.string.searching_microbit_found_message_one_line);
1068-
// } else {
1069-
// tvSearchingStep.setText(R.string.searching_microbit_found_message);
1070-
// }
1071-
// tvSearchingInstructions.setText(R.string.searching_tip_text_instructions);
1072-
}
1073-
}
1074-
1075-
private void updateOnConnected() {
1076-
logi("updateOnConnected");
1077-
TextView textView = (TextView) findViewById(R.id.search_microbit_step_3_title);
1078-
TextView tvSearchingStep = (TextView) findViewById(R.id.searching_microbit_step);
1079-
TextView tvSearchingInstructions = (TextView) findViewById(R.id.searching_microbit_step_instructions);
1080-
if (textView != null) {
1081-
textView.setText(getString(R.string.searchingTitle));
1082-
findViewById(R.id.searching_progress_spinner).setVisibility(View.GONE);
1083-
((GifImageView) findViewById(R.id.searching_microbit_found_giffview))
1084-
.setImageResource(R.drawable.emoji_microbit_found);
1085-
if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
1086-
tvSearchingStep.setText(R.string.searching_microbit_found_message_one_line);
1087-
} else {
1088-
tvSearchingStep.setText(R.string.searching_microbit_found_message);
1089-
}
1090-
tvSearchingInstructions.setText(R.string.searching_tip_text_instructions);
1091-
}
1092-
}
1093-
10941064
/**
10951065
* Displays needed screen according to a pairing state and
10961066
* allows to navigate through the connection screens.
@@ -1102,6 +1072,7 @@ private void displayScreen(PAIRING_STATE gotoState) {
11021072
//Reset all screens first
11031073
pairTipView.setVisibility(View.GONE);
11041074
newDeviceView.setVisibility(View.GONE);
1075+
enterPinIfNeededView.setVisibility(View.GONE);
11051076
pairSearchView.setVisibility(View.GONE);
11061077
connectDeviceView.setVisibility(View.GONE);
11071078

@@ -1148,25 +1119,13 @@ private void displayScreen(PAIRING_STATE gotoState) {
11481119
displayLedGrid();
11491120
break;
11501121

1122+
case PAIRING_STATE_ENTER_PIN_IF_NEEDED:
1123+
enterPinIfNeededView.setVisibility(View.VISIBLE);
1124+
break;
1125+
11511126
case PAIRING_STATE_SEARCHING:
11521127
if(pairSearchView != null) {
11531128
pairSearchView.setVisibility(View.VISIBLE);
1154-
TextView tvTitle = (TextView) findViewById(R.id.search_microbit_step_3_title);
1155-
TextView tvSearchingStep = (TextView) findViewById(R.id.searching_microbit_step);
1156-
tvSearchingStep.setContentDescription(tvSearchingStep.getText());
1157-
TextView tvSearchingInstructions = (TextView) findViewById(R.id.searching_microbit_step_instructions);
1158-
if(tvTitle != null) {
1159-
tvTitle.setText(R.string.searchingTitle);
1160-
findViewById(R.id.searching_progress_spinner).setVisibility(View.VISIBLE);
1161-
((GifImageView) findViewById(R.id.searching_microbit_found_giffview))
1162-
.setImageResource(R.drawable.pairing_pin_screen_two);
1163-
if(currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
1164-
tvSearchingStep.setText(R.string.searching_tip_step_text_one_line);
1165-
} else {
1166-
tvSearchingStep.setText(R.string.searching_tip_step_text);
1167-
}
1168-
tvSearchingInstructions.setText(R.string.searching_tip_text_instructions);
1169-
}
11701129
justPaired = true;
11711130
} else {
11721131
justPaired = false;
@@ -1394,6 +1353,11 @@ public void onClick(final View v) {
13941353
if(!BluetoothChecker.getInstance().checkBluetoothAndStart()) {
13951354
return;
13961355
}
1356+
displayScreen(PAIRING_STATE.PAIRING_STATE_ENTER_PIN_IF_NEEDED);
1357+
break;
1358+
1359+
case R.id.next_enter_pin_if_needed_btn:
1360+
logi("onClick() :: next_enter_pin_if_needed_btn");
13971361
startScanning();
13981362
displayScreen(PAIRING_STATE.PAIRING_STATE_SEARCHING);
13991363
break;
@@ -1413,6 +1377,12 @@ public void onClick(final View v) {
14131377
onFinish( RESULT_CANCELED);
14141378
break;
14151379

1380+
case R.id.cancel_enter_pin_if_needed_btn:
1381+
logi("onClick() :: cancel_enter_pin_if_needed_btn");
1382+
stopScanning();
1383+
onFinish( RESULT_CANCELED);
1384+
break;
1385+
14161386
case R.id.cancel_search_microbit_step_3_btn:
14171387
logi("onClick() :: cancel_search_button");
14181388
stopScanning();
@@ -1602,6 +1572,7 @@ protected void onDestroy() {
16021572

16031573
pairTipView.setVisibility(View.GONE);
16041574
newDeviceView.setVisibility(View.GONE);
1575+
enterPinIfNeededView.setVisibility(View.GONE);
16051576
pairSearchView.setVisibility(View.GONE);
16061577
connectDeviceView.setVisibility(View.GONE);
16071578

@@ -1630,9 +1601,14 @@ protected void onDestroy() {
16301601
Utils.unbindDrawables(findViewById(R.id.oh_pretty_emoji));
16311602
Utils.unbindDrawables(findViewById(R.id.cancel_enter_pattern_step_2_btn));
16321603
Utils.unbindDrawables(findViewById(R.id.ok_enter_pattern_step_2_btn));
1604+
1605+
Utils.unbindDrawables(findViewById(R.id.enter_pin_if_needed_title));
1606+
Utils.unbindDrawables(findViewById(R.id.enter_pin_if_needed_text));
1607+
Utils.unbindDrawables(findViewById(R.id.cancel_enter_pin_if_needed_btn));
1608+
Utils.unbindDrawables(findViewById(R.id.enterPinIfNeededView));
1609+
16331610
Utils.unbindDrawables(findViewById(R.id.search_microbit_step_3_title));
16341611
Utils.unbindDrawables(findViewById(R.id.searching_microbit_step));
1635-
Utils.unbindDrawables(findViewById(R.id.searching_microbit_step_instructions));
16361612
Utils.unbindDrawables(findViewById(R.id.cancel_search_microbit_step_3_btn));
16371613
Utils.unbindDrawables(findViewById(R.id.searching_progress_spinner));
16381614

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:id="@+id/enterPinIfNeededView"
4+
style="@style/pairing_step_layout_style"
5+
android:orientation="horizontal"
6+
android:keepScreenOn="true">
7+
8+
<LinearLayout
9+
android:layout_width="match_parent"
10+
android:layout_height="wrap_content"
11+
android:layout_gravity="center_vertical"
12+
android:layout_marginTop="@dimen/pairing_step_layout_margin"
13+
android:layout_marginBottom="@dimen/pairing_step_layout_margin"
14+
android:baselineAligned="false"
15+
android:layout_marginStart="@dimen/pairing_step_title_and_gif_layout_margin_start">
16+
17+
<RelativeLayout
18+
android:layout_width="0dp"
19+
android:layout_weight="1"
20+
android:layout_height="wrap_content"
21+
android:gravity="center_horizontal"
22+
android:orientation="vertical">
23+
24+
<!-- Title -->
25+
<TextView
26+
android:id="@+id/enter_pin_if_needed_title"
27+
style="@style/pairing_step_header_style"
28+
android:text="@string/enter_pin_if_needed_title" />
29+
30+
<!--pairing animation-->
31+
<pl.droidsonroids.gif.GifImageView
32+
android:layout_width="@dimen/pairing_step_1_gif_image_width"
33+
android:layout_height="@dimen/pairing_step_1_gif_image_height"
34+
android:layout_below="@id/enter_pin_if_needed_title"
35+
android:src="@drawable/pairing_pin_screen_two" />
36+
</RelativeLayout>
37+
38+
<RelativeLayout
39+
android:layout_width="0dp"
40+
android:layout_height="match_parent"
41+
android:layout_weight="1">
42+
43+
<TextView
44+
android:id="@+id/enter_pin_if_needed_text"
45+
style="@style/pairing_step_tip_text_style"
46+
android:textSize="@dimen/pairing_step_title_text_size"
47+
android:text="@string/enter_pin_if_needed_next_text" />
48+
49+
<RelativeLayout
50+
android:layout_width="match_parent"
51+
android:layout_height="wrap_content"
52+
android:layout_alignStart="@id/enter_pin_if_needed_text"
53+
android:layout_centerInParent="true">
54+
<TextView
55+
style="@style/pairing_step_tip_text_style"
56+
android:layout_width="@dimen/pairing_step_text_width"
57+
android:textSize="@dimen/pairing_step_tip_instruction_text_size"
58+
android:layout_alignBottom="@id/pairing_step_one_image"
59+
android:text="@string/enter_pin_if_needed_text_one_line" />
60+
61+
<ImageView
62+
android:id="@+id/pairing_step_one_image"
63+
style="@style/pairing_step_image_layout_style"
64+
android:layout_alignParentEnd="true"
65+
android:src="@drawable/ic_person_step_1" />
66+
</RelativeLayout>
67+
68+
<!-- Pairing confirmation buttons-->
69+
<LinearLayout
70+
android:id="@+id/enter_pin_if_needed_confirmation_view"
71+
style="@style/pairing_step_buttons_layout_style"
72+
android:layout_alignParentBottom="true"
73+
android:paddingBottom="0dp">
74+
75+
<Button
76+
android:id="@+id/cancel_enter_pin_if_needed_btn"
77+
style="@style/pairing_step_button_style"
78+
android:layout_marginEnd="@dimen/pairing_step_buttons_space_margin"
79+
android:background="@drawable/cancel_btn"
80+
android:drawableEnd="@drawable/cancel_step_pairing_btn"
81+
android:text="@string/txt_cancel_btn" />
82+
83+
<Button
84+
android:id="@+id/next_enter_pin_if_needed_btn"
85+
style="@style/pairing_step_button_style"
86+
android:layout_marginStart="@dimen/pairing_step_buttons_space_margin"
87+
android:background="@drawable/green_btn"
88+
android:drawableEnd="@drawable/ic_done_black"
89+
android:text="@string/txt_how_to_pair_next_btn" />
90+
</LinearLayout>
91+
</RelativeLayout>
92+
</LinearLayout>
93+
</LinearLayout>

app/src/main/res/layout-land/view_pairing_searching.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@
2929

3030
<!--pairing animation-->
3131
<pl.droidsonroids.gif.GifImageView
32-
android:id="@+id/searching_microbit_found_giffview"
3332
android:layout_width="@dimen/pairing_step_1_gif_image_width"
3433
android:layout_height="@dimen/pairing_step_1_gif_image_height"
3534
android:layout_below="@id/search_microbit_step_3_title"
36-
android:src="@drawable/pairing_pin_screen_two" />
35+
android:src="@drawable/emoji_searching_microbit" />
3736
</RelativeLayout>
3837

3938
<RelativeLayout

app/src/main/res/layout-land/view_pairing_searching_step.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
style="@style/pairing_step_tip_text_style"
1414
android:layout_marginBottom="@dimen/pairing_step_tip_title_margin_bottom"
1515
android:textSize="@dimen/pairing_step_title_text_size"
16-
android:text="@string/searching_tip_step_text_one_line" />
16+
android:text="@string/searching_microbit_one_line" />
1717

18-
<TextView
19-
android:id="@+id/searching_microbit_step_instructions"
20-
android:layout_width="wrap_content"
21-
style="@style/pairing_step_tip_text_style"
22-
android:textSize="@dimen/pairing_step_tip_instruction_text_size"
23-
android:contentDescription="@string/desc_searching_tip_text"
24-
android:text="@string/searching_tip_text_instructions" />
2518
</LinearLayout>

0 commit comments

Comments
 (0)