Merge lp:~humpolec-team/humpolec/UbuntuInstaller_lp1263797 into lp:humpolec

Proposed by Yuan-Chen Cheng on 2014-01-02
Status: Merged
Merge reported by: Yuan-Chen Cheng
Merged at revision: not available
Proposed branch: lp:~humpolec-team/humpolec/UbuntuInstaller_lp1263797
Merge into: lp:humpolec
Diff against target: 207 lines (+105/-5)
5 files modified
.project-template (+33/-0)
res/values/strings.xml (+7/-0)
src/com/canonical/ubuntu/installer/InstallActivity.java (+52/-1)
src/com/canonical/ubuntu/installer/UbuntuInstallService.java (+1/-2)
src/com/canonical/ubuntu/installer/Utils.java (+12/-2)
To merge this branch: bzr merge lp:~humpolec-team/humpolec/UbuntuInstaller_lp1263797
Reviewer Review Type Date Requested Status
Rex Tsai Approve on 2014-01-03
Yuan-Chen Cheng Resubmit on 2014-01-03
Review via email: mp+200282@code.launchpad.net

Description of the change

1. add .project-template to make it easier.
2. for unsupported device, show dialog and then exit app.

tested on devices that's not on the supported list.

To post a comment you must log in.
Rex Tsai (chihchun) wrote :

* Please split changes into different commit for tracking.
* "".equals(Utils.getBootPartitionPath() is hackly, could we have Utils.isSupported() ? Also, even when the device is not supported, we should log the device model and name in logcat or something else, for trouble shooting.

50. By Yuan-Chen Cheng on 2014-01-03

1. use Utils.isDeviceSupported(), 2. refine diaglog naming

51. By Yuan-Chen Cheng on 2014-01-03

1. refactor getDeviceModel()
2. add missint not logic

52. By Yuan-Chen Cheng on 2014-01-03

also show device name on message inside dialog

Yuan-Chen Cheng (ycheng-twn) wrote :

1. use isDeviceSupported()
2. refactor getDeviceMode()
3. show device name in debug message. (rev 51)
4. show device name in dialog message.

review: Resubmit
Rex Tsai (chihchun) wrote :

LGTM +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.project-template'
2--- .project-template 1970-01-01 00:00:00 +0000
3+++ .project-template 2014-01-03 05:53:58 +0000
4@@ -0,0 +1,33 @@
5+<?xml version="1.0" encoding="UTF-8"?>
6+<projectDescription>
7+ <name>UbuntuInstaller</name>
8+ <comment></comment>
9+ <projects>
10+ </projects>
11+ <buildSpec>
12+ <buildCommand>
13+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
14+ <arguments>
15+ </arguments>
16+ </buildCommand>
17+ <buildCommand>
18+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
19+ <arguments>
20+ </arguments>
21+ </buildCommand>
22+ <buildCommand>
23+ <name>org.eclipse.jdt.core.javabuilder</name>
24+ <arguments>
25+ </arguments>
26+ </buildCommand>
27+ <buildCommand>
28+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
29+ <arguments>
30+ </arguments>
31+ </buildCommand>
32+ </buildSpec>
33+ <natures>
34+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
35+ <nature>org.eclipse.jdt.core.javanature</nature>
36+ </natures>
37+</projectDescription>
38
39=== modified file 'res/values/strings.xml'
40--- res/values/strings.xml 2013-12-25 03:13:44 +0000
41+++ res/values/strings.xml 2014-01-03 05:53:58 +0000
42@@ -1,5 +1,8 @@
43 <?xml version="1.0" encoding="utf-8"?>
44 <resources>
45+ <string name="yes">Yes</string>
46+ <string name="no">No</string>
47+ <string name="ok">OK</string>
48
49 <string name="app_name">Ubuntu Dual Boot</string>
50 <string name="action_settings">Settings</string>
51@@ -34,6 +37,10 @@
52 <string name="terminal_dump_succ">Dump Terminal to file success</string>
53 <string name="terminal_dump_fail">Dump Terminal to file fail</string>
54 <string name="external_storage_unavailable">External Storage is not available</string>
55+
56+ <string name="not_supported_title">Not supported</string>
57+ <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>
58+
59 <!-- Strings for Launch screen -->
60 <string name="launch_title">Ubuntu</string>
61 <string name="label_channel">Channel:</string>
62
63=== modified file 'src/com/canonical/ubuntu/installer/InstallActivity.java'
64--- src/com/canonical/ubuntu/installer/InstallActivity.java 2013-12-26 06:53:14 +0000
65+++ src/com/canonical/ubuntu/installer/InstallActivity.java 2014-01-03 05:53:58 +0000
66@@ -16,18 +16,25 @@
67 import com.canonical.ubuntu.installer.VersionInfo.ReleaseType;
68 import com.canonical.ubuntu.widget.UbuntuButton;
69
70+import android.os.Build;
71 import android.os.Bundle;
72 import android.os.Environment;
73 import android.app.Activity;
74+import android.app.AlertDialog;
75+import android.app.Dialog;
76+import android.app.DialogFragment;
77+import android.app.FragmentTransaction;
78 import android.app.ProgressDialog;
79 import android.content.BroadcastReceiver;
80 import android.content.Context;
81+import android.content.DialogInterface;
82 import android.content.Intent;
83 import android.content.IntentFilter;
84 import android.content.SharedPreferences;
85 import android.content.pm.PackageInfo;
86 import android.content.pm.PackageManager;
87 import android.text.Html;
88+import android.text.method.LinkMovementMethod;
89 import android.text.method.ScrollingMovementMethod;
90 import android.util.Log;
91 import android.view.Menu;
92@@ -55,10 +62,15 @@
93 @Override
94 protected void onCreate(Bundle savedInstanceState) {
95 super.onCreate(savedInstanceState);
96+ if (! Utils.isDeviceSupported()) {
97+ Log.d(TAG, "Device is not supported: " + Build.DEVICE);
98+ showNotCompatibleDialog();
99+ }
100+
101 // check is there is already Ubuntu installed
102 checkIfUbuntuIsInstalled();
103 if (isFinishing()) return;
104-
105+
106 setContentView(R.layout.ubuntu_dualboot_install);
107 mInstallButton = (UbuntuButton) findViewById(R.id.download);
108 mProgressBar = (ProgressBar) findViewById(R.id.progress);
109@@ -478,5 +490,44 @@
110 }
111 }
112 };
113+
114+ // code for display dialog for not compatible device and exits app.
115+ private static final String DIALOG_NOT_SUPPORTED = "not_supported_dialog";
116+
117+ public void showDialogFragment(DialogFragment frag, String tag) {
118+ FragmentTransaction ft = getFragmentManager().beginTransaction();
119+ frag.setCancelable(false);
120+ ft.add(frag, tag);
121+ ft.commitAllowingStateLoss();
122+ }
123+
124+ public void showNotCompatibleDialog() {
125+ showDialogFragment(new NotCompatibleDialogFragment(), DIALOG_NOT_SUPPORTED);
126+ }
127+
128+ public static class NotCompatibleDialogFragment extends DialogFragment {
129+ @Override
130+ public Dialog onCreateDialog(Bundle savedInstanceState) {
131+ String msg_fmt = getResources().getString(R.string.not_supported_message_fmt);
132+ String msg = String.format(msg_fmt, Build.DEVICE);
133+ AlertDialog dialog = new AlertDialog.Builder(getActivity())
134+ .setTitle(R.string.not_supported_title)
135+ .setMessage(msg)
136+ .setPositiveButton(R.string.ok,
137+ new DialogInterface.OnClickListener() {
138+ public void onClick(DialogInterface dialog, int whichButton) {
139+ ((InstallActivity) getActivity()).onFinishButtonClick();
140+ }
141+ }).create();
142+ dialog.show();
143+ ((TextView) dialog.findViewById(android.R.id.message))
144+ .setMovementMethod(LinkMovementMethod.getInstance());
145+ return dialog;
146+ }
147+ }
148+
149+ private void onFinishButtonClick() {
150+ finish();
151+ }
152 }
153
154
155=== modified file 'src/com/canonical/ubuntu/installer/UbuntuInstallService.java'
156--- src/com/canonical/ubuntu/installer/UbuntuInstallService.java 2013-12-27 07:11:23 +0000
157+++ src/com/canonical/ubuntu/installer/UbuntuInstallService.java 2014-01-03 05:53:58 +0000
158@@ -28,7 +28,6 @@
159 import android.content.Context;
160 import android.content.Intent;
161 import android.content.SharedPreferences;
162-import android.os.Build;
163 import android.os.PowerManager;
164 import android.util.Log;
165 import android.webkit.URLUtil;
166@@ -331,7 +330,7 @@
167
168 HashMap<String, String> channels= new HashMap<String, String>();
169 boolean includeHidden = getSharedPreferences( SHARED_PREF, Context.MODE_PRIVATE).getBoolean(PREF_KEY_DEVELOPER, false);
170- String deviceModel = Build.DEVICE.toLowerCase(Locale.US);
171+ String deviceModel = Utils.getDeviceModel();
172 String channelJsonStr = Utils.httpDownload(BASE_URL + CHANNELS_JSON);
173 if (channelJsonStr != null) {
174 JSONObject list;
175
176=== modified file 'src/com/canonical/ubuntu/installer/Utils.java'
177--- src/com/canonical/ubuntu/installer/Utils.java 2013-12-24 03:37:53 +0000
178+++ src/com/canonical/ubuntu/installer/Utils.java 2014-01-03 05:53:58 +0000
179@@ -186,8 +186,18 @@
180 return freeSpaceInBytes;
181 }
182
183+ public static String getDeviceModel() {
184+ return Build.DEVICE.toLowerCase(Locale.US);
185+ }
186+
187+ public static boolean isDeviceSupported() {
188+ String path = getBootPartitionPath();
189+ if ("".equals(path)) return false;
190+ return true;
191+ }
192+
193 public static String getBootPartitionPath() {
194- String deviceModel = Build.DEVICE.toLowerCase(Locale.US);
195+ String deviceModel = getDeviceModel();
196 if ("flo".equals(deviceModel)) {
197 return UbuntuInstallService.FLO_PARTITION_BOOT;
198 } else if ("grouper".equals(deviceModel)) {
199@@ -206,7 +216,7 @@
200 }
201
202 public static String getRecoveryPartitionPath() {
203- String deviceModel = Build.DEVICE.toLowerCase(Locale.US);
204+ String deviceModel = getDeviceModel();
205 if ("flo".equals(deviceModel)) {
206 return UbuntuInstallService.FLO_PARTITION_RECOVERY;
207 } else if ("grouper".equals(deviceModel)) {

Subscribers

People subscribed via source and target branches

to all changes: