Skip to content

Commit

Permalink
Merge pull request #40 from martinwork/from300
Browse files Browse the repository at this point in the history
Version 3.0.4 (54) - Pairing - Add triple reset method
  • Loading branch information
martinwork authored Mar 26, 2024
2 parents 7f1f74f + 684af7a commit 18328fc
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 32 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="53"
android:versionName="3.0.3">
android:versionCode="54"
android:versionName="3.0.4">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public class PairingActivity extends Activity implements View.OnClickListener, B
*/
private enum PAIRING_STATE {
PAIRING_STATE_CONNECT_BUTTON,
PAIRING_STATE_TRIPLE,
PAIRING_STATE_STEP_1,
PAIRING_STATE_STEP_2,
PAIRING_STATE_SEARCHING,
Expand Down Expand Up @@ -246,7 +247,7 @@ private void proceedAfterBlePermissionGranted() {
return;
}

displayScreen(PAIRING_STATE.PAIRING_STATE_STEP_1);
displayScreen(PAIRING_STATE.PAIRING_STATE_TRIPLE);
}

private boolean havePermission(String permission) {
Expand Down Expand Up @@ -602,8 +603,10 @@ private void setupFontStyle() {
MBApp application = MBApp.getApp();

Typeface defaultTypeface = application.getTypeface();
Typeface robotoTypeface = application.getRobotoTypeface();

deviceConnectionStatusBtn.setTypeface(defaultTypeface);

// Connect Screen
TextView appBarTitle = (TextView) findViewById(R.id.flash_projects_title_txt);
appBarTitle.setTypeface(defaultTypeface);
Expand All @@ -626,38 +629,20 @@ private void setupFontStyle() {
TextView stepOneTitle = (TextView) findViewById(R.id.pair_tip_step_1_step);
stepOneTitle.setTypeface(boldTypeface);

Button cancelPairButton = (Button) findViewById(R.id.cancel_tip_step_1_btn);
cancelPairButton.setTypeface(robotoTypeface);

Button nextPairButton = (Button) findViewById(R.id.ok_tip_step_1_btn);
nextPairButton.setTypeface(robotoTypeface);


// Step 2 - Enter Pattern
TextView enterPatternTitle = (TextView) findViewById(R.id.enter_pattern_step_2_title);
enterPatternTitle.setTypeface(boldTypeface);

TextView stepTwoTitle = (TextView) findViewById(R.id.pair_enter_pattern_step_2);
stepTwoTitle.setTypeface(boldTypeface);


// Step 3 - Searching for micro:bit
TextView searchMicrobitTitle = (TextView) findViewById(R.id.search_microbit_step_3_title);
searchMicrobitTitle.setTypeface(boldTypeface);

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

Typeface robotoTypeface = application.getRobotoTypeface();

TextView descriptionManageMicrobit = (TextView) findViewById(R.id.description_manage_microbit);
descriptionManageMicrobit.setTypeface(robotoTypeface);

TextView problemsMicrobit = (TextView) findViewById(R.id.connect_microbit_problems_message);
problemsMicrobit.setTypeface(robotoTypeface);

TextView stepOneInstructions = (TextView) findViewById(R.id.pair_tip_step_1_instructions);
stepOneInstructions.setTypeface(robotoTypeface);

Button cancelPairButton = (Button) findViewById(R.id.cancel_tip_step_1_btn);
cancelPairButton.setTypeface(robotoTypeface);

Button nextPairButton = (Button) findViewById(R.id.ok_tip_step_1_btn);
nextPairButton.setTypeface(robotoTypeface);

TextView stepTwoInstructions = (TextView) findViewById(R.id.pair_enter_pattern_step_2_instructions);
stepTwoInstructions.setTypeface(robotoTypeface);

Expand All @@ -667,11 +652,26 @@ private void setupFontStyle() {
Button okEnterPatternButton = (Button) findViewById(R.id.ok_enter_pattern_step_2_btn);
okEnterPatternButton.setTypeface(robotoTypeface);


// Step 3 - Searching for micro:bit
TextView searchMicrobitTitle = (TextView) findViewById(R.id.search_microbit_step_3_title);
searchMicrobitTitle.setTypeface(boldTypeface);

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

TextView stepThreeInstructions = (TextView) findViewById(R.id.searching_microbit_step_instructions);
stepThreeInstructions.setTypeface(robotoTypeface);

Button cancelSearchMicroBit = (Button) findViewById(R.id.cancel_search_microbit_step_3_btn);
cancelSearchMicroBit.setTypeface(robotoTypeface);


TextView descriptionManageMicrobit = (TextView) findViewById(R.id.description_manage_microbit);
descriptionManageMicrobit.setTypeface(robotoTypeface);

TextView problemsMicrobit = (TextView) findViewById(R.id.connect_microbit_problems_message);
problemsMicrobit.setTypeface(robotoTypeface);
}

/**
Expand All @@ -690,9 +690,14 @@ private void initViews() {
//Setup on click listeners.
deviceConnectionStatusBtn.setOnClickListener(this);
findViewById(R.id.pairButton).setOnClickListener(this);

findViewById(R.id.viewPairStep1AnotherWay).setOnClickListener(this);
findViewById(R.id.ok_tip_step_1_btn).setOnClickListener(this);
findViewById(R.id.cancel_tip_step_1_btn).setOnClickListener(this);

findViewById(R.id.ok_enter_pattern_step_2_btn).setOnClickListener(this);
findViewById(R.id.cancel_enter_pattern_step_2_btn).setOnClickListener(this);

findViewById(R.id.cancel_search_microbit_step_3_btn).setOnClickListener(this);

setupFontStyle();
Expand Down Expand Up @@ -1097,11 +1102,26 @@ private void displayScreen(PAIRING_STATE gotoState) {
newDeviceCode = "";
break;

case PAIRING_STATE_STEP_1:
case PAIRING_STATE_TRIPLE: {
GifImageView view = (GifImageView) findViewById(R.id.pair_tip_step_1_giff);
view.setImageResource(R.drawable.reset_triple);
TextView prompt = (TextView) findViewById(R.id.pair_tip_step_1_instructions);
prompt.setText(R.string.viewPairTriplePromptText);
prompt.setContentDescription(prompt.getText());
pairTipView.setVisibility(View.VISIBLE);
findViewById(R.id.ok_tip_step_1_btn).setOnClickListener(this);
view.animate();
break;

}
case PAIRING_STATE_STEP_1: {
GifImageView view = (GifImageView) findViewById(R.id.pair_tip_step_1_giff);
view.setImageResource(R.drawable.how_to_pair_microbit);
TextView prompt = (TextView) findViewById(R.id.pair_tip_step_1_instructions);
prompt.setText(R.string.connect_tip_text);
prompt.setContentDescription(prompt.getText());
pairTipView.setVisibility(View.VISIBLE);
view.animate();
break;
}
case PAIRING_STATE_STEP_2:
newDeviceView.setVisibility(View.VISIBLE);
findViewById(R.id.cancel_enter_pattern_step_2_btn).setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -1313,6 +1333,12 @@ public void onClick(final View v) {
checkBluetoothPermissions();
break;

case R.id.viewPairStep1AnotherWay:
logi("onClick() :: viewPairStep1AnotherWay");
displayScreen( pairingState == PAIRING_STATE.PAIRING_STATE_TRIPLE
? PAIRING_STATE.PAIRING_STATE_STEP_1 : PAIRING_STATE.PAIRING_STATE_TRIPLE);
break;

// Proceed to Enter Pattern
case R.id.ok_tip_step_1_btn:
logi("onClick() :: ok_tip_screen_one_button");
Expand Down Expand Up @@ -1483,7 +1509,7 @@ private void popupPairingFailed() {
@Override
public void onClick(View v) {
PopUp.hide();
displayScreen(PAIRING_STATE.PAIRING_STATE_STEP_1);
displayScreen(PAIRING_STATE.PAIRING_STATE_TRIPLE);
}
},//override click listener for ok button
new View.OnClickListener() {
Expand Down Expand Up @@ -1549,6 +1575,7 @@ protected void onDestroy() {

Utils.unbindDrawables(findViewById(R.id.connected_device_status_button));
Utils.unbindDrawables(findViewById(R.id.pairButtonView));

Utils.unbindDrawables(findViewById(R.id.pairTipView));
Utils.unbindDrawables(findViewById(R.id.connectDeviceView));
Utils.unbindDrawables(findViewById(R.id.pairSearchView));
Expand Down
Binary file added app/src/main/res/drawable-mdpi/reset_triple.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/src/main/res/layout-land/view_pairing_step_1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<!-- Step description -->
<include layout="@layout/pair_microbit_step" />

<include layout="@layout/view_pairing_step_1_other" />

<!-- Confirmation buttons -->
<include layout="@layout/pairing_tip_action_buttons"/>
</LinearLayout>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/view_pairing_step_1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<!-- Step description -->
<include layout="@layout/pair_microbit_step" />

<include layout="@layout/view_pairing_step_1_other" />

<!-- Confirmation buttons -->
<include layout="@layout/pairing_tip_action_buttons" />
</LinearLayout>
14 changes: 14 additions & 0 deletions app/src/main/res/layout/view_pairing_step_1_other.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?><!-- Pairing Confirmation buttons -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/viewPairStep1Other"
style="@style/another_way_button_layout_style"
tools:showIn="@layout/view_pairing_step_1">

<Button
android:id="@+id/viewPairStep1AnotherWay"
style="@style/another_way_button_style"
android:background="@drawable/white_btn"
android:drawableEnd="@drawable/next_step_pairing_btn"
android:text="@string/viewPathAntherWay" />
</LinearLayout>
4 changes: 4 additions & 0 deletions app/src/main/res/values-land/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@
<dimen name="pairing_step_buttons_space_margin">4dp</dimen>
<integer name="pairing_searching_step_button_layout_weight_sum">3</integer>
<dimen name="pairing_step_button_height">58dp</dimen>
<dimen name="another_way_button_height">44dp</dimen>
<dimen name="another_way_button_text_size">13sp</dimen>
<dimen name="another_way_button_layout_weightSum">3</dimen>
<dimen name="another_way_button_layout_weight">2</dimen>

<!-- Pattern grid -->
<dimen name="led_gap">4dp</dimen>
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/values-land/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@
<item name="android:layout_width">wrap_content</item>
</style>

<style name="another_way_button_layout_style" parent="match_width_parent_wrap_height_content">
<item name="android:gravity">center</item>
<item name="android:layout_gravity">bottom</item>
<item name="android:padding">@dimen/pairing_step_button_layout_padding</item>
<item name="android:weightSum">@dimen/another_way_button_layout_weightSum</item>
</style>

<style name="another_way_button_style">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">@dimen/another_way_button_height</item>
<item name="android:gravity">center</item>
<item name="android:textSize">@dimen/another_way_button_text_size</item>
<item name="android:textColor">@android:color/black</item>
<item name="android:textAllCaps">true</item>
<item name="android:paddingStart">@dimen/pairing_step_button_padding</item>
<item name="android:paddingEnd">@dimen/pairing_step_button_padding</item>
<item name="android:layout_weight">@dimen/another_way_button_layout_weight</item>
</style>

<style name="pairing_step_buttons_layout_style" parent="match_width_parent_wrap_height_content">
<item name="android:layout_gravity">bottom</item>
<item name="android:paddingStart">@dimen/pairing_step_button_layout_padding</item>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-sw360dp-land/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
<dimen name="pairing_step_1_gif_image_height">230dp</dimen>
<dimen name="pairing_step_button_text_size">16sp</dimen>
<dimen name="pairing_step_cycle_progress_bar_size">80dp</dimen>
<dimen name="another_way_button_height">48dp</dimen>
<dimen name="another_way_button_text_size">14sp</dimen>
<dimen name="another_way_button_layout_weightSum">3</dimen>
<dimen name="another_way_button_layout_weight">2</dimen>


<!-- Popup screen -->
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-sw600dp-land/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
<dimen name="pairing_step_cycle_progress_bar_size">120dp</dimen>
<dimen name="pairing_step_buttons_space_margin">8dp</dimen>
<dimen name="connect_button_height">72dp</dimen>
<dimen name="another_way_button_height">56dp</dimen>
<dimen name="another_way_button_text_size">22sp</dimen>
<dimen name="another_way_button_layout_weightSum">3</dimen>
<dimen name="another_way_button_layout_weight">2</dimen>

<!-- Pattern grid -->
<dimen name="led_gap">15dp</dimen>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-sw600dp-port/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@
<dimen name="pairing_step_button_layout_padding">18dp</dimen>
<dimen name="pairing_step_gif_image_margin">0dp</dimen>
<dimen name="pairing_step_tip_instruction_text_size">22sp</dimen>
<dimen name="another_way_button_height">54dp</dimen>
<dimen name="another_way_button_text_size">22sp</dimen>
<dimen name="another_way_button_layout_weightSum">3</dimen>
<dimen name="another_way_button_layout_weight">2</dimen>

<!-- Popup screens -->
<dimen name="popup_gif_size">200dp</dimen>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
<dimen name="pairing_step_two_tip_layout_margin_top">16dp</dimen>
<dimen name="pairing_step_tip_instruction_text_size">18sp</dimen>
<integer name="pairing_searching_step_button_layout_weight_sum">2</integer>
<dimen name="another_way_button_height">41dp</dimen>
<dimen name="another_way_button_text_size">18sp</dimen>
<dimen name="another_way_button_layout_weightSum">3</dimen>
<dimen name="another_way_button_layout_weight">2</dimen>

<!-- Connect screen -->
<dimen name="connections_container_layout_padding">16dp</dimen>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@
<string name="desc_connectSearchingTitle">Connecting&#8230;</string>
<string name="searchingTitle">Searching for micro:bit</string>
<string name="pairing_msg_1">Found micro:bit</string>
<string name="viewPairTriplePromptText">Press RESET three times</string>
<string name="viewPairTriplePromptTextDesc">Press RESET three times</string>
<string name="viewPathAntherWay">Show another way</string>

<!--Connect Popup messages -->
<string name="pairingErrorTitle">Error</string>
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,25 @@
<item name="android:textColor">@android:color/white</item>
</style>

<style name="another_way_button_layout_style" parent="match_width_parent_wrap_height_content">
<item name="android:gravity">center</item>
<item name="android:layout_gravity">bottom</item>
<item name="android:padding">@dimen/pairing_step_button_layout_padding</item>
<item name="android:weightSum">@dimen/another_way_button_layout_weightSum</item>
</style>

<style name="another_way_button_style">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">@dimen/another_way_button_height</item>
<item name="android:gravity">center</item>
<item name="android:textSize">@dimen/another_way_button_text_size</item>
<item name="android:textColor">@android:color/black</item>
<item name="android:textAllCaps">true</item>
<item name="android:paddingStart">@dimen/pairing_step_button_padding</item>
<item name="android:paddingEnd">@dimen/pairing_step_button_padding</item>
<item name="android:layout_weight">@dimen/another_way_button_layout_weight</item>
</style>

<style name="pairing_step_button_style">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
Expand Down

0 comments on commit 18328fc

Please sign in to comment.