Merge lp:~humpolec-team/humpolec/UbuntuInstaller-lp1263583 into lp:humpolec

Proposed by Rex Tsai
Status: Merged
Merge reported by: Rex Tsai
Merged at revision: not available
Proposed branch: lp:~humpolec-team/humpolec/UbuntuInstaller-lp1263583
Merge into: lp:humpolec
Diff against target: 279 lines (+107/-46)
5 files modified
res/layout/ubuntu_dualboot_install.xml (+1/-1)
res/values/strings.xml (+8/-2)
src/com/canonical/ubuntu/installer/InstallActivity.java (+37/-1)
src/com/canonical/ubuntu/installer/LaunchActivity.java (+9/-42)
src/com/canonical/ubuntu/installer/Utils.java (+52/-0)
To merge this branch: bzr merge lp:~humpolec-team/humpolec/UbuntuInstaller-lp1263583
Reviewer Review Type Date Requested Status
Yuan-Chen Cheng Approve
Review via email: mp+200772@code.launchpad.net

Description of the change

Notify user there is no network connection.

    It will check if mobile network or wifi is eanbled,
    if not it will shows a dialog remind the user to enable wifi.

Refined button of installer screen.

    When networking is slow, the installer screen show "Hi" in download
    button, it should show something make sense.

To post a comment you must log in.
Revision history for this message
Yuan-Chen Cheng (ycheng-twn) wrote :

should we also call isNetworkAvailable() as Handle download result ?

other code look good in general.

review: Needs Information
Revision history for this message
Rex Tsai (chihchun) wrote :

So you suggested we should remind the user that he/she turn off network? I feel remind the user once at first time is enough. :-)

Revision history for this message
Yuan-Chen Cheng (ycheng-twn) wrote :

The case that download failed in the middle due to network disappear for any reason, it will be good to show.

I don't insist, since this is more for developer and won't need to be perfect.

review: Approve
57. By Rex Tsai

Notify user there is no network connection.

When the downloaded failed, check the network again.

Revision history for this message
Rex Tsai (chihchun) wrote :

Add checking as yc suggested.

Test procedures
1. Download images from the App
2. adb shell && su && svc wifi disable # turn off wifi
3. The app will received a I/O error exception, and ask user to enable wifi again.

Do not test it with UI, because it check networking when you return to the app from wifi config screen.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'res/layout/ubuntu_dualboot_install.xml'
2--- res/layout/ubuntu_dualboot_install.xml 2014-01-02 07:59:35 +0000
3+++ res/layout/ubuntu_dualboot_install.xml 2014-01-09 08:42:26 +0000
4@@ -18,7 +18,7 @@
5 android:layout_alignParentBottom="true"
6 android:layout_gravity="center_horizontal"
7 android:adjustViewBounds="true"
8- android:text="hi"
9+ android:text="@string/downloading_index"
10 android:textColor="@color/text"
11 u1f:customFont="Ubuntu-R.ttf" />
12
13
14=== modified file 'res/values/strings.xml'
15--- res/values/strings.xml 2014-01-07 02:18:17 +0000
16+++ res/values/strings.xml 2014-01-09 08:42:26 +0000
17@@ -4,6 +4,7 @@
18 <string name="no">No</string>
19 <string name="ok">OK</string>
20
21+ <!-- string for InstallActivity -->
22 <string name="app_name">Ubuntu Dual Boot</string>
23 <string name="action_settings">Settings</string>
24 <string name="action_detele_download">Delete download</string>
25@@ -26,6 +27,7 @@
26 <string name="bootstrap_check">bootstrap</string>
27 <string name="latest_check">latest version</string>
28 <string name="downloading_release">Downloading Ubuntu</string>
29+ <string name="downloading_index">Downloading images data</string>
30 <string name="downloading_starting">Starting download</string>
31 <string name="installing_release">Installing Ubuntu</string>
32 <string name="uninstall_dialog_title">Uninstall Ubuntu?</string>
33@@ -41,14 +43,18 @@
34 <string name="not_supported_title">Not supported</string>
35 <string name="not_supported_message_fmt">It appears that your device (%s) is not on the supported list of Ubuntu for Phone dual boot installer. Visit <a href="https://wiki.ubuntu.com/Touch/DualBootInstallation">https://wiki.ubuntu.com/Touch/DualBootInstallation</a> to see phones that is supported.</string>
36
37- <!-- Strings for Launch screen -->
38+ <string name="no_network_dialog_title">Network not available</string>
39+ <string name="enable_network">Enable WiFi</string>
40+
41+ <!-- Strings for LaunchActivity screen -->
42 <string name="launch_title">Ubuntu</string>
43 <string name="label_channel">Channel:</string>
44 <string name="label_version">Version:</string>
45 <string name="label_description">Description:</string>
46 <string name="reboot_button_label">Reboot to Ubuntu</string>
47-
48+
49 <string-array name="uninstall_options">
50 <item>Delete user data</item>
51 </string-array>
52 </resources>
53+
54
55=== modified file 'src/com/canonical/ubuntu/installer/InstallActivity.java'
56--- src/com/canonical/ubuntu/installer/InstallActivity.java 2014-01-07 02:18:17 +0000
57+++ src/com/canonical/ubuntu/installer/InstallActivity.java 2014-01-09 08:42:26 +0000
58@@ -16,6 +16,9 @@
59 import com.canonical.ubuntu.installer.VersionInfo.ReleaseType;
60 import com.canonical.ubuntu.widget.UbuntuButton;
61
62+import android.net.ConnectivityManager;
63+import android.net.NetworkInfo;
64+import android.net.wifi.WifiManager;
65 import android.os.Build;
66 import android.os.Bundle;
67 import android.os.Environment;
68@@ -83,7 +86,7 @@
69 SharedPreferences pref = getSharedPreferences(UbuntuInstallService.SHARED_PREF, Context.MODE_PRIVATE);
70 pref.edit().putBoolean(UbuntuInstallService.PREF_KEY_DEVELOPER, true).commit();
71 }
72-
73+
74 @Override
75 public void onResume() {
76 super.onResume();
77@@ -91,6 +94,9 @@
78 checkIfUbuntuIsInstalled();
79 if (isFinishing()) return;
80
81+ // verify if network is available for download.
82+ isNetworkAvailable();
83+
84 mInstallButton.setOnClickListener(mInstallButtonListener);
85 IntentFilter filter = new IntentFilter();
86 filter.addAction(UbuntuInstallService.AVAILABLE_CHANNELS);
87@@ -468,6 +474,10 @@
88 reason = "Download failed: " + reason;
89 }
90 Utils.showToast(context, reason);
91+
92+ // check if network is available for download.
93+ // isNetworkAvailable();
94+
95 updateInfoOnUiThread(reason);
96 requestChannelList();
97 }
98@@ -491,6 +501,32 @@
99 }
100 };
101
102+ /**
103+ * Check if network connection is available,
104+ * if not, pop up a dialog ask user to enable networking.
105+ *
106+ * @return true if network is available
107+ */
108+ private boolean isNetworkAvailable () {
109+ final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
110+ final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
111+ if (activeNetwork != null && activeNetwork.isConnected()) {
112+ return true;
113+ }
114+
115+ Utils.createConfirmationDialog(this,
116+ R.string.no_network_dialog_title,
117+ R.string.enable_network,
118+ R.string.cancel,
119+ new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK),
120+ -1, // toastText
121+ -1, // choiceItemsArray
122+ null, // defaultChoiceValues
123+ null // choiceClickListener
124+ ).show();
125+ return false;
126+ }
127+
128 // code for display dialog for not compatible device and exits app.
129 private static final String DIALOG_NOT_SUPPORTED = "not_supported_dialog";
130
131
132=== modified file 'src/com/canonical/ubuntu/installer/LaunchActivity.java'
133--- src/com/canonical/ubuntu/installer/LaunchActivity.java 2013-12-26 07:08:52 +0000
134+++ src/com/canonical/ubuntu/installer/LaunchActivity.java 2014-01-09 08:42:26 +0000
135@@ -87,7 +87,8 @@
136 case R.id.action_uninstall:
137 // show dialog
138 final Intent uninstall = new Intent(UbuntuInstallService.UNINSTALL_UBUNTU);
139- createConfirmationDialog(R.string.uninstall_dialog_title,
140+ Utils.createConfirmationDialog(this,
141+ R.string.uninstall_dialog_title,
142 R.string.action_uninstall_button,
143 R.string.cancel,
144 uninstall,
145@@ -95,16 +96,17 @@
146 R.array.uninstall_options,
147 new boolean[]{UbuntuInstallService.DEFAULT_UNINSTALL_DEL_USER_DATA},
148 new DialogInterface.OnMultiChoiceClickListener() {
149- @Override
150- public void onClick(DialogInterface dialog, int which, boolean isChecked) {
151- // we have only one option here
152- uninstall.putExtra(UbuntuInstallService.UNINSTALL_UBUNTU_EXTRA_REMOVE_USER_DATA, isChecked);
153- }
154+ @Override
155+ public void onClick(DialogInterface dialog, int which, boolean isChecked) {
156+ // we have only one option here
157+ uninstall.putExtra(UbuntuInstallService.UNINSTALL_UBUNTU_EXTRA_REMOVE_USER_DATA, isChecked);
158+ }
159 }).show();
160 break;
161 case R.id.action_del_user_data:
162 Intent action = new Intent(UbuntuInstallService.DELETE_UBUNTU_USER_DATA);
163- createConfirmationDialog(R.string.action_delete_user_data,
164+ Utils.createConfirmationDialog(this,
165+ R.string.action_delete_user_data,
166 R.string.action_delete_udata_button,
167 R.string.cancel,
168 action,
169@@ -117,41 +119,6 @@
170 return super.onOptionsItemSelected(item);
171 }
172
173- /**
174- * Create a dialog for confirmation.
175- * @param title
176- * @param positiveButton
177- * @param negativeButton
178- * @param action
179- * @param toastText
180- * @param choiceItemsArray
181- * @param defaultChoiceValues
182- * @param choiceClickListener
183- * @return AlertDialog
184- */
185- private AlertDialog createConfirmationDialog(final int title,
186- final int positiveButton,
187- final int negativeButton,
188- final Intent action,
189- final int toastText,
190- final int choiceItemsArray,
191- final boolean[] defaultChoiceValues,
192- final DialogInterface.OnMultiChoiceClickListener choiceClickListener ){
193- AlertDialog.Builder builder = new AlertDialog.Builder(this);
194- builder.setTitle(title);
195- builder.setPositiveButton(positiveButton, new DialogInterface.OnClickListener() {
196- public void onClick(DialogInterface dialog, int id) {
197- startService(action);
198- Utils.showToast(getApplicationContext(), toastText);
199- }
200- });
201- if (choiceItemsArray != -1) {
202- builder.setMultiChoiceItems(choiceItemsArray, defaultChoiceValues, choiceClickListener);
203- }
204- builder.setNegativeButton(negativeButton, null);
205- return builder.create();
206- }
207-
208 public static void startFrom(Context context) {
209 Intent intent = new Intent(context, LaunchActivity.class);
210 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
211
212=== modified file 'src/com/canonical/ubuntu/installer/Utils.java'
213--- src/com/canonical/ubuntu/installer/Utils.java 2014-01-03 06:42:51 +0000
214+++ src/com/canonical/ubuntu/installer/Utils.java 2014-01-09 08:42:26 +0000
215@@ -1,7 +1,11 @@
216 package com.canonical.ubuntu.installer;
217
218+import android.app.AlertDialog;
219 import android.content.Context;
220+import android.content.DialogInterface;
221+import android.content.Intent;
222 import android.content.res.AssetManager;
223+import android.net.wifi.WifiManager;
224 import android.os.Build;
225 import android.os.StatFs;
226 import android.util.Log;
227@@ -268,4 +272,52 @@
228
229 return sum;
230 }
231+
232+ /**
233+ * Create a dialog for confirmation.
234+ *
235+ * @param context Activity context.
236+ * @param title title of dialog.
237+ * @param positiveButton
238+ * @param negativeButton
239+ * @param action
240+ * @param toastText
241+ * @param choiceItemsArray
242+ * @param defaultChoiceValues
243+ * @param choiceClickListener
244+ * @return AlertDialog
245+ */
246+ public static AlertDialog createConfirmationDialog(
247+ final Context context,
248+ final int title,
249+ final int positiveButton,
250+ final int negativeButton,
251+ final Intent action,
252+ final int toastText,
253+ final int choiceItemsArray,
254+ final boolean[] defaultChoiceValues,
255+ final DialogInterface.OnMultiChoiceClickListener choiceClickListener ){
256+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
257+ builder.setTitle(title);
258+ builder.setPositiveButton(positiveButton, new DialogInterface.OnClickListener() {
259+ public void onClick(DialogInterface dialog, int id) {
260+ if(action.getAction().startsWith(WifiManager.ACTION_PICK_WIFI_NETWORK)) {
261+ context.startActivity(action);
262+ } else {
263+ // expected for
264+ // UbuntuInstallService.UNINSTALL_UBUNTU
265+ // UbuntuInstallService.DELETE_UBUNTU_USER_DATA
266+ context.startService(action);
267+ }
268+ if(toastText > 0)
269+ Utils.showToast(context.getApplicationContext(), toastText);
270+ }
271+ });
272+ if (choiceItemsArray != -1) {
273+ builder.setMultiChoiceItems(choiceItemsArray, defaultChoiceValues, choiceClickListener);
274+ }
275+ builder.setNegativeButton(negativeButton, null);
276+ return builder.create();
277+ }
278+
279 }

Subscribers

People subscribed via source and target branches

to all changes: