Skip to content

Commit ad26c42

Browse files
authored
Fetch MY_DATA (#70)
* Fetch MY_DATA * Put back textAllCaps=false * Fetch BLE updates * Fetch WebView - whitelist URLs * Fetch - remove My Programs device text
1 parent e579722 commit ad26c42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3085
-143
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@
159159
android:label="MakeCode Webview"
160160
android:launchMode="singleTask"
161161
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
162+
<activity
163+
android:name=".ui.activity.FetchActivity"
164+
android:configChanges="orientation|screenSize"
165+
android:label="Fetch MY_DATA"
166+
android:launchMode="singleTask"/>
167+
162168
<service
163169
android:name=".service.DfuService"
164170
android:enabled="true"/>
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package com.samsung.microbit.ui;
2+
3+
import android.content.Context;
4+
import android.util.Log;
5+
import android.view.View;
6+
import com.samsung.microbit.R;
7+
8+
import static com.samsung.microbit.BuildConfig.DEBUG;
9+
10+
public class FetchPopups {
11+
private static final String TAG = FetchPopups.class.getSimpleName();
12+
13+
public void logi(String message) {
14+
if(DEBUG) {
15+
Log.i(TAG, "### " + Thread.currentThread().getId() + " # " + message);
16+
}
17+
}
18+
19+
/**
20+
* Callback interface for client
21+
*/
22+
public interface Client {
23+
Context fetchPopupsContext();
24+
void fetchPopupsCancelled();
25+
void fetchPopupsRequestBluetoothConnectPermissions();
26+
}
27+
28+
Client mClient = null;
29+
30+
public FetchPopups ( Client client) {
31+
mClient = client;
32+
}
33+
34+
View.OnClickListener popupClickActivityCancelled = new View.OnClickListener() {
35+
@Override
36+
public void onClick(View v) {
37+
logi("popupClickActivityCancelled");
38+
PopUp.hide();
39+
mClient.fetchPopupsCancelled();
40+
}
41+
};
42+
43+
public void busy() {
44+
// Another download session is in progress.xml
45+
PopUp.show(mClient.fetchPopupsContext().getString(R.string.multple_flashing_session_msg),
46+
"",
47+
R.drawable.error_face, R.drawable.blue_btn,
48+
PopUp.GIFF_ANIMATION_FLASH,
49+
PopUp.TYPE_ALERT,
50+
popupClickActivityCancelled, popupClickActivityCancelled);
51+
}
52+
53+
public void bluetoothOff() {
54+
PopUp.show(mClient.fetchPopupsContext().getString(R.string.bluetooth_off_cannot_continue), //message
55+
"",
56+
R.drawable.error_face, R.drawable.red_btn,
57+
PopUp.GIFF_ANIMATION_ERROR,
58+
PopUp.TYPE_ALERT,
59+
popupClickActivityCancelled, popupClickActivityCancelled);
60+
}
61+
62+
public void bluetoothConnectPermissionError() {
63+
PopUp.show(mClient.fetchPopupsContext().getString(R.string.ble_permission_connect_error),
64+
mClient.fetchPopupsContext().getString(R.string.permissions_needed_title),
65+
R.drawable.error_face, R.drawable.red_btn,
66+
PopUp.GIFF_ANIMATION_ERROR,
67+
PopUp.TYPE_ALERT,
68+
popupClickActivityCancelled, popupClickActivityCancelled);
69+
}
70+
71+
public void bluetoothConnectRequest() {
72+
PopUp.show(mClient.fetchPopupsContext().getString(R.string.ble_permission_connect),
73+
mClient.fetchPopupsContext().getString(R.string.permissions_needed_title),
74+
R.drawable.message_face, R.drawable.blue_btn, PopUp.GIFF_ANIMATION_NONE,
75+
PopUp.TYPE_CHOICE,
76+
new View.OnClickListener() {
77+
@Override
78+
public void onClick(View v) {
79+
logi("bluetoothPermissionOKHandler");
80+
PopUp.hide();
81+
mClient.fetchPopupsRequestBluetoothConnectPermissions();
82+
}
83+
},
84+
new View.OnClickListener() {
85+
@Override
86+
public void onClick(View v) {
87+
logi("bluetoothPermissionCancelHandler");
88+
PopUp.hide();
89+
bluetoothConnectPermissionError();
90+
}
91+
});
92+
}
93+
94+
public void fetchFailed( String message) {
95+
PopUp.show( message,
96+
mClient.fetchPopupsContext().getString(R.string.fetchFailed),
97+
R.drawable.error_face, R.drawable.red_btn,
98+
PopUp.GIFF_ANIMATION_ERROR,
99+
PopUp.TYPE_ALERT,
100+
popupClickActivityCancelled, popupClickActivityCancelled);
101+
}
102+
103+
public void fetchProgress() {
104+
PopUp.show("",
105+
mClient.fetchPopupsContext().getString(R.string.fetching),
106+
R.drawable.flash_face,
107+
R.drawable.blue_btn,
108+
PopUp.GIFF_ANIMATION_FLASH,
109+
PopUp.TYPE_PROGRESS,
110+
popupClickActivityCancelled, popupClickActivityCancelled);
111+
}
112+
113+
}

0 commit comments

Comments
 (0)