Skip to content

Commit 9a82372

Browse files
authored
Merge pull request #36 from bpmct/feature/showcase-mode-rebased
v0.13.1: WiFi settings dialog + showcase fetch stagger
2 parents a9d7520 + 4c0b595 commit 9a82372

4 files changed

Lines changed: 65 additions & 25 deletions

File tree

AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.bpmct.trmnl_nook_simple_touch"
4-
android:versionCode="130099"
5-
android:versionName="0.13.0" >
4+
android:versionCode="130100"
5+
android:versionName="0.13.1" >
66

77
<uses-permission android:name="android.permission.INTERNET" />
88
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

src/com/bpmct/trmnl_nook_simple_touch/DisplayActivity.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.bpmct.trmnl_nook_simple_touch;
22

33
import android.app.Activity;
4+
import android.app.AlertDialog;
5+
import android.content.DialogInterface;
46
import android.app.AlarmManager;
57
import android.app.PendingIntent;
68
import android.content.BroadcastReceiver;
@@ -1499,13 +1501,22 @@ private void showNoWifiScreen() {
14991501
wifiBtn.setOnTouchListener(new View.OnTouchListener() {
15001502
public boolean onTouch(View v, MotionEvent event) {
15011503
if (event.getAction() == MotionEvent.ACTION_UP) {
1502-
Intent wifiIntent = new Intent();
1503-
wifiIntent.setClassName("com.android.settings", "com.android.settings.wifi.Settings_Wifi_Settings");
1504-
try {
1505-
startActivity(wifiIntent);
1506-
} catch (Throwable t2) {
1507-
try { startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS)); } catch (Throwable t3) {}
1508-
}
1504+
new AlertDialog.Builder(DisplayActivity.this)
1505+
.setTitle("Opening Wi-Fi Settings")
1506+
.setMessage("After connecting, press the Home button on the bottom of this device to return to this app.")
1507+
.setPositiveButton("Open Wi-Fi Settings", new DialogInterface.OnClickListener() {
1508+
public void onClick(DialogInterface dialog, int which) {
1509+
Intent wifiIntent = new Intent();
1510+
wifiIntent.setClassName("com.android.settings", "com.android.settings.wifi.Settings_Wifi_Settings");
1511+
try {
1512+
startActivity(wifiIntent);
1513+
} catch (Throwable t2) {
1514+
try { startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS)); } catch (Throwable t3) {}
1515+
}
1516+
}
1517+
})
1518+
.setNegativeButton("Cancel", null)
1519+
.show();
15091520
}
15101521
return true;
15111522
}

src/com/bpmct/trmnl_nook_simple_touch/SettingsActivity.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.bpmct.trmnl_nook_simple_touch;
22

33
import android.app.Activity;
4+
import android.app.AlertDialog;
5+
import android.content.DialogInterface;
46
import android.os.Bundle;
57
import android.os.Handler;
68
import android.view.Gravity;
@@ -224,13 +226,22 @@ public void onClick(View v) {
224226
Button wifiSettingsButton = createGreyButton("WiFi Settings");
225227
wifiSettingsButton.setOnClickListener(new View.OnClickListener() {
226228
public void onClick(View v) {
227-
Intent wifiIntent = new Intent();
228-
wifiIntent.setClassName("com.android.settings", "com.android.settings.wifi.Settings_Wifi_Settings");
229-
try {
230-
startActivity(wifiIntent);
231-
} catch (Throwable t) {
232-
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
233-
}
229+
new AlertDialog.Builder(SettingsActivity.this)
230+
.setTitle("Opening Wi-Fi Settings")
231+
.setMessage("After connecting, press the Home button on the bottom of this device to return to this app.")
232+
.setPositiveButton("Open Wi-Fi Settings", new DialogInterface.OnClickListener() {
233+
public void onClick(DialogInterface dialog, int which) {
234+
Intent wifiIntent = new Intent();
235+
wifiIntent.setClassName("com.android.settings", "com.android.settings.wifi.Settings_Wifi_Settings");
236+
try {
237+
startActivity(wifiIntent);
238+
} catch (Throwable t) {
239+
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
240+
}
241+
}
242+
})
243+
.setNegativeButton("Cancel", null)
244+
.show();
234245
}
235246
});
236247
LinearLayout.LayoutParams wifiSettBtnParams = new LinearLayout.LayoutParams(

src/com/bpmct/trmnl_nook_simple_touch/ShowcaseActivity.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.bpmct.trmnl_nook_simple_touch;
22

33
import android.app.Activity;
4+
import android.app.AlertDialog;
5+
import android.content.DialogInterface;
46
import android.content.Context;
57
import android.content.Intent;
68
import android.graphics.Bitmap;
@@ -371,7 +373,7 @@ private boolean anyCacheExists() {
371373
private static final long WIFI_WARMUP_MS = 15 * 1000;
372374
private final android.os.Handler handler = new android.os.Handler();
373375

374-
private static final long CELL_FETCH_STAGGER_MS = 1500;
376+
private static final long CELL_FETCH_STAGGER_MS = 8000;
375377

376378
private void startFetchAll() {
377379
if (isConnected()) {
@@ -469,13 +471,22 @@ private void showNoWifiScreen() {
469471
wifiBtn.setOnTouchListener(new View.OnTouchListener() {
470472
public boolean onTouch(View v, android.view.MotionEvent event) {
471473
if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
472-
try {
473-
Intent wi = new Intent();
474-
wi.setClassName("com.android.settings", "com.android.settings.wifi.Settings_Wifi_Settings");
475-
try { startActivity(wi); } catch (Throwable t2) {
476-
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
477-
}
478-
} catch (Throwable t) {}
474+
new AlertDialog.Builder(ShowcaseActivity.this)
475+
.setTitle("Opening Wi-Fi Settings")
476+
.setMessage("After connecting, press the Home button on the bottom of this device to return to this app.")
477+
.setPositiveButton("Open Wi-Fi Settings", new DialogInterface.OnClickListener() {
478+
public void onClick(DialogInterface dialog, int which) {
479+
try {
480+
Intent wi = new Intent();
481+
wi.setClassName("com.android.settings", "com.android.settings.wifi.Settings_Wifi_Settings");
482+
try { startActivity(wi); } catch (Throwable t2) {
483+
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
484+
}
485+
} catch (Throwable t) {}
486+
}
487+
})
488+
.setNegativeButton("Cancel", null)
489+
.show();
479490
}
480491
return true;
481492
}
@@ -510,7 +521,14 @@ public void onReceive(android.content.Context context, Intent intent) {
510521
handler.post(new Runnable() {
511522
public void run() {
512523
hideNoWifiScreen();
513-
for (int i = 0; i < NUM_CELLS; i++) fetchCell(i);
524+
for (int i = 0; i < NUM_CELLS; i++) {
525+
final int cellIdx = i;
526+
handler.postDelayed(new Runnable() {
527+
public void run() {
528+
if (isCellConfigured(ShowcaseActivity.this, cellIdx)) fetchCell(cellIdx);
529+
}
530+
}, cellIdx * CELL_FETCH_STAGGER_MS);
531+
}
514532
}
515533
});
516534
}

0 commit comments

Comments
 (0)