Merge lp:~karni/ubuntuone-android-files/greendroid into lp:ubuntuone-android-files
- greendroid
- Merge into trunk-2011
Proposed by
Michał Karnicki
Status: | Merged |
---|---|
Merged at revision: | 53 |
Proposed branch: | lp:~karni/ubuntuone-android-files/greendroid |
Merge into: | lp:ubuntuone-android-files |
Diff against target: |
2386 lines (+692/-625) 39 files modified
.classpath (+2/-2) AndroidManifest.xml (+4/-5) README.txt (+23/-0) build.properties (+1/-0) default.properties (+1/-0) res/drawable/action_bar_background.xml (+29/-0) res/drawable/list_selector.xml (+3/-2) res/layout/activity_dashboard.xml (+0/-20) res/layout/activity_list.xml (+13/-32) res/layout/activity_login.xml (+0/-10) res/layout/activity_status.xml (+0/-17) res/layout/row.xml (+1/-1) res/raw/notice (+1/-1) res/values/colors.xml (+4/-2) res/values/ids.xml (+0/-13) res/values/strings.xml (+9/-6) res/values/styles.xml (+0/-80) res/values/themes.xml (+16/-0) setup (+5/-0) src/com/ubuntuone/android/files/Preferences.java (+4/-4) src/com/ubuntuone/android/files/UbuntuOneFiles.java (+28/-18) src/com/ubuntuone/android/files/provider/FilesUtilities.java (+5/-10) src/com/ubuntuone/android/files/syncdaemon/EventQueue.java (+9/-3) src/com/ubuntuone/android/files/syncdaemon/SyncManager.java (+4/-0) src/com/ubuntuone/android/files/syncdaemon/commands/Sync.java (+4/-0) src/com/ubuntuone/android/files/ui/Actionbar.java (+0/-118) src/com/ubuntuone/android/files/ui/CustomListActivity.java (+385/-137) src/com/ubuntuone/android/files/ui/DashboardActivity.java (+75/-45) src/com/ubuntuone/android/files/ui/FilesActivity.java (+1/-8) src/com/ubuntuone/android/files/ui/SharesActivity.java (+0/-9) src/com/ubuntuone/android/files/ui/StatusActivity.java (+36/-23) src/com/ubuntuone/android/files/ui/UdfsActivity.java (+0/-9) src/com/ubuntuone/android/files/util/ConfigUtilities.java (+12/-8) src/com/ubuntuone/android/files/util/CustomListActivityAdapter.java (+8/-5) src/com/ubuntuone/android/files/util/MediaUtilities.java (+1/-0) src/com/ubuntuone/android/files/util/SeekbarPreference.java (+0/-2) src/com/ubuntuone/android/storageprotocol/request/RequestHandler.java (+1/-0) src/com/ubuntuone/android/util/log/ILog.java (+0/-1) src/com/ubuntuone/android/util/log/Log.java (+7/-34) |
To merge this branch: | bzr merge lp:~karni/ubuntuone-android-files/greendroid |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chad Miller | Pending | ||
Review via email: mp+55611@code.launchpad.net |
Commit message
Description of the change
Applied GreenDroid lib to the application UI, see: action bar, quick actions for files and folders, fixed two bugs and few other minor fixes.
I tried to refrain from pending clean up (unrelated string externalization, etc), because the diff is already quite big.
To post a comment you must log in.
- 54. By Michał Karnicki
-
Applied review fixes. Changed e-mail, cleaned up .project and .classpath files.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.classpath' |
2 | --- .classpath 2011-01-29 16:22:20 +0000 |
3 | +++ .classpath 2011-04-04 13:36:49 +0000 |
4 | @@ -6,10 +6,10 @@ |
5 | <classpathentry kind="lib" path="libs/signpost-commonshttp4-1.2.jar"/> |
6 | <classpathentry kind="lib" path="libs/signpost-core-1.2.jar"/> |
7 | <classpathentry kind="lib" path="libs/storageprotocol-1.1.0-20110103.190619-2.jar"/> |
8 | - <classpathentry kind="src" path="src"/> |
9 | - <classpathentry kind="src" path="gen"/> |
10 | <classpathentry kind="lib" path="libs/protobuf-java-2.3.0.jar"/> |
11 | <classpathentry kind="lib" path="libs/netty-3.1.5.GA.jar"/> |
12 | <classpathentry kind="lib" path="libs/commons-codec-1.4.jar"/> |
13 | + <classpathentry kind="src" path="src"/> |
14 | + <classpathentry kind="src" path="gen"/> |
15 | <classpathentry kind="output" path="bin"/> |
16 | </classpath> |
17 | |
18 | === modified file 'AndroidManifest.xml' |
19 | --- AndroidManifest.xml 2011-03-23 13:30:35 +0000 |
20 | +++ AndroidManifest.xml 2011-04-04 13:36:49 +0000 |
21 | @@ -2,8 +2,8 @@ |
22 | <manifest |
23 | xmlns:android="http://schemas.android.com/apk/res/android" |
24 | package="com.ubuntuone.android.files" |
25 | - android:versionCode="48" |
26 | - android:versionName="1.1.48" > |
27 | + android:versionCode="54" |
28 | + android:versionName="1.2.54" > |
29 | |
30 | <uses-sdk |
31 | android:minSdkVersion="6" |
32 | @@ -61,7 +61,7 @@ |
33 | android:name=".ui.DashboardActivity" |
34 | android:launchMode="singleTask" |
35 | android:label="@string/title_text" |
36 | - android:theme="@style/LauncherBackground" > |
37 | + android:theme="@style/Theme.Dashboard" > |
38 | |
39 | <intent-filter |
40 | android:label="@string/app_name" > |
41 | @@ -80,14 +80,13 @@ |
42 | |
43 | <activity |
44 | android:name=".Preferences" |
45 | - android:theme="@android:style/Theme.Light" |
46 | android:configChanges="orientation" |
47 | android:label="@string/title_preferences" > |
48 | </activity> |
49 | |
50 | <activity |
51 | android:name=".StorageManagement" |
52 | - android:theme="@android:style/Theme.Light" |
53 | + android:theme="@style/Theme.U1F" |
54 | android:configChanges="orientation" |
55 | android:label="@string/storage_management_title" > |
56 | </activity> |
57 | |
58 | === modified file 'README.txt' |
59 | --- README.txt 2010-11-23 00:40:34 +0000 |
60 | +++ README.txt 2011-04-04 13:36:49 +0000 |
61 | @@ -1,2 +1,25 @@ |
62 | Run ./setup to download depenencies. |
63 | |
64 | +Then fetch GreenDroid UI library with: |
65 | +git clone http://github.com/cyrilmottier/GreenDroid.git |
66 | +and apply the library as follows. |
67 | + |
68 | +--- ant users --- |
69 | + |
70 | +see: http://developer.android.com/guide/developing/projects/projects-cmdline.html |
71 | + |
72 | +android update project --path path/to/ubuntuone-android-files --library path/to/GreenDroid |
73 | + |
74 | +where path/to/GreenDroid might be ../GreenDroid/GreenDroid if you pulled GD sources |
75 | +into the same folder as u1f sources. |
76 | + |
77 | +Please note that GreenDRoid library folder resides inside the GreenDroid folder created by git. |
78 | + |
79 | +--- eclipse users --- |
80 | + |
81 | +Right-click on the project -> Properties -> Android |
82 | +You'll find the Library list at the bottom. Click Add, and point Eclipse to GreenDroid folder. |
83 | + |
84 | +Eclipse will add an entry to .project file to point to the GreenDroid library project. |
85 | +The entry contains a locationURI, that references a path variable contained in your workspace |
86 | +eclipse-workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs:pathvariable._android_greendroid_ec1dc959=/home/user/greendroid/path/here |
87 | |
88 | === modified file 'build.properties' |
89 | --- build.properties 2010-12-21 15:50:43 +0000 |
90 | +++ build.properties 2011-04-04 13:36:49 +0000 |
91 | @@ -15,3 +15,4 @@ |
92 | # 'key.alias' for the name of the key to use. |
93 | # The password will be asked during the build when you use the 'release' target. |
94 | external.libs.absolute.dir=./libs |
95 | +android.library.reference.1=../GreenDroid/GreenDroid |
96 | |
97 | === modified file 'default.properties' |
98 | --- default.properties 2010-11-23 00:40:34 +0000 |
99 | +++ default.properties 2011-04-04 13:36:49 +0000 |
100 | @@ -9,3 +9,4 @@ |
101 | |
102 | # Project target. |
103 | target=android-6 |
104 | +android.library.reference.1=../GreenDroid/GreenDroid |
105 | |
106 | === added file 'res/drawable-hdpi/action_bar_divider.png' |
107 | Binary files res/drawable-hdpi/action_bar_divider.png 1970-01-01 00:00:00 +0000 and res/drawable-hdpi/action_bar_divider.png 2011-04-04 13:36:49 +0000 differ |
108 | === added file 'res/drawable-mdpi/action_bar_divider.png' |
109 | Binary files res/drawable-mdpi/action_bar_divider.png 1970-01-01 00:00:00 +0000 and res/drawable-mdpi/action_bar_divider.png 2011-04-04 13:36:49 +0000 differ |
110 | === added file 'res/drawable/action_bar_background.xml' |
111 | --- res/drawable/action_bar_background.xml 1970-01-01 00:00:00 +0000 |
112 | +++ res/drawable/action_bar_background.xml 2011-04-04 13:36:49 +0000 |
113 | @@ -0,0 +1,29 @@ |
114 | +<?xml version="1.0" encoding="utf-8"?> |
115 | +<!-- |
116 | +/* |
117 | +** Copyright (C) 2010 Cyril Mottier (http://www.cyrilmottier.com) |
118 | +** |
119 | +** Licensed under the Apache License, Version 2.0 (the "License"); |
120 | +** you may not use this file except in compliance with the License. |
121 | +** You may obtain a copy of the License at |
122 | +** |
123 | +** http://www.apache.org/licenses/LICENSE-2.0 |
124 | +** |
125 | +** Unless required by applicable law or agreed to in writing, software |
126 | +** distributed under the License is distributed on an "AS IS" BASIS, |
127 | +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
128 | +** See the License for the specific language governing permissions and |
129 | +** limitations under the License. |
130 | +*/ |
131 | +--> |
132 | + |
133 | +<shape |
134 | + xmlns:android="http://schemas.android.com/apk/res/android" |
135 | + android:shape="rectangle"> |
136 | + |
137 | + <gradient |
138 | + android:startColor="#817f81" |
139 | + android:endColor="#ccc9cc" |
140 | + android:angle="90" /> |
141 | + |
142 | +</shape> |
143 | |
144 | === modified file 'res/drawable/list_selector.xml' |
145 | --- res/drawable/list_selector.xml 2010-11-23 00:40:34 +0000 |
146 | +++ res/drawable/list_selector.xml 2011-04-04 13:36:49 +0000 |
147 | @@ -3,9 +3,10 @@ |
148 | xmlns:android="http://schemas.android.com/apk/res/android" |
149 | android:shape="rectangle" > |
150 | <corners |
151 | - android:radius="10dp" |
152 | + android:topLeftRadius="10dp" |
153 | android:topRightRadius="1dp" |
154 | - android:bottomRightRadius="1dp" /> |
155 | + android:bottomRightRadius="1dp" |
156 | + android:bottomLeftRadius="10dp" /> |
157 | <gradient |
158 | android:angle="90" |
159 | android:startColor="#f90" |
160 | |
161 | === modified file 'res/layout/activity_dashboard.xml' |
162 | --- res/layout/activity_dashboard.xml 2011-02-21 01:32:08 +0000 |
163 | +++ res/layout/activity_dashboard.xml 2011-04-04 13:36:49 +0000 |
164 | @@ -5,26 +5,6 @@ |
165 | android:layout_width="fill_parent" |
166 | android:layout_height="fill_parent" |
167 | android:background="#FFFFFF" > |
168 | - |
169 | - <LinearLayout style="@style/TitleBar"> |
170 | - <TextView android:id="@id/actionbar_title" |
171 | - style="@style/TitleBarText" |
172 | - android:text="@string/title_text" /> |
173 | - |
174 | - <ProgressBar android:id="@id/actionbar_indeterminate" |
175 | - style="@style/TitleBarProgressIndicator" |
176 | - android:visibility="gone" /> |
177 | - <!-- |
178 | - <ImageView |
179 | - style="@style/TitleBarSeparator" |
180 | - android:visibility="gone" /> |
181 | - --> |
182 | - <ImageButton android:id="@id/actionbar_search" |
183 | - style="@style/TitleBarAction" |
184 | - android:visibility="gone" |
185 | - android:src="@drawable/ic_title_search_default" |
186 | - android:onClick="onSearchClick" /> |
187 | - </LinearLayout> |
188 | |
189 | <LinearLayout |
190 | android:orientation="vertical" |
191 | |
192 | === modified file 'res/layout/activity_list.xml' |
193 | --- res/layout/activity_list.xml 2011-03-24 14:09:46 +0000 |
194 | +++ res/layout/activity_list.xml 2011-04-04 13:36:49 +0000 |
195 | @@ -5,33 +5,6 @@ |
196 | android:layout_width="fill_parent" |
197 | android:layout_height="fill_parent" > |
198 | |
199 | - <LinearLayout style="@style/TitleBar"> |
200 | - <TextView android:id="@id/actionbar_title" |
201 | - style="@style/TitleBarText" |
202 | - android:text="@string/title_files" /> |
203 | - |
204 | - <ProgressBar android:id="@id/actionbar_indeterminate" |
205 | - style="@style/TitleBarProgressIndicator" |
206 | - android:visibility="gone" /> |
207 | - <!-- |
208 | - <ImageView style="@style/TitleBarSeparator" |
209 | - android:id="@+id/btn_title_upload_separator" /> |
210 | - --> |
211 | - <ImageButton android:id="@+id/actionbar_upload" |
212 | - style="@style/TitleBarAction" |
213 | - android:visibility="gone" |
214 | - android:src="@drawable/ic_title_share_default" /> |
215 | - <!-- |
216 | - <ImageView style="@style/TitleBarSeparator" |
217 | - android:id="@+id/btn_title_search_separator" /> |
218 | - --> |
219 | - <ImageButton android:id="@id/actionbar_search" |
220 | - style="@style/TitleBarAction" |
221 | - android:visibility="gone" |
222 | - android:src="@drawable/ic_title_search_default" |
223 | - android:onClick="onSearchClick" /> |
224 | - </LinearLayout> |
225 | - |
226 | <!-- |
227 | We don't use calls to setHeader() of the ListActivity, because |
228 | we show/hide the header during the time the Activity is already visible. |
229 | @@ -41,13 +14,21 @@ |
230 | style="@style/ListHeaderText" |
231 | android:visibility="gone" |
232 | android:text="" /> |
233 | - |
234 | + |
235 | <ListView |
236 | - android:id="@android:id/list" |
237 | + android:id="@id/android:list" |
238 | android:layout_width="fill_parent" |
239 | android:layout_height="wrap_content" |
240 | - android:drawSelectorOnTop="false" |
241 | - android:listSelector="@drawable/list_selector" |
242 | - /> |
243 | + android:fastScrollEnabled="true" /> |
244 | + |
245 | + <TextView |
246 | + android:id="@id/android:empty" |
247 | + android:layout_width="fill_parent" |
248 | + android:layout_height="fill_parent" |
249 | + android:layout_centerInParent="true" |
250 | + android:layout_centerHorizontal="true" |
251 | + android:gravity="center" |
252 | + android:text="@string/no_items" |
253 | + android:textColor="@color/file_text_fg" /> |
254 | |
255 | </LinearLayout> |
256 | |
257 | === modified file 'res/layout/activity_login.xml' |
258 | --- res/layout/activity_login.xml 2011-01-06 23:32:17 +0000 |
259 | +++ res/layout/activity_login.xml 2011-04-04 13:36:49 +0000 |
260 | @@ -3,16 +3,6 @@ |
261 | android:layout_width="wrap_content" |
262 | android:layout_height="wrap_content" |
263 | android:background="#FFFFFF" > |
264 | - |
265 | - <LinearLayout style="@style/TitleBar"> |
266 | - <TextView android:id="@id/actionbar_title" |
267 | - style="@style/TitleBarText" |
268 | - android:text="@string/title_text" /> |
269 | - |
270 | - <ProgressBar android:id="@id/actionbar_indeterminate" |
271 | - style="@style/TitleBarProgressIndicator" |
272 | - android:visibility="gone" /> |
273 | - </LinearLayout> |
274 | |
275 | <ImageView |
276 | android:id="@+id/loginImage" |
277 | |
278 | === modified file 'res/layout/activity_status.xml' |
279 | --- res/layout/activity_status.xml 2011-01-06 23:32:17 +0000 |
280 | +++ res/layout/activity_status.xml 2011-04-04 13:36:49 +0000 |
281 | @@ -5,23 +5,6 @@ |
282 | android:layout_width="fill_parent" |
283 | android:layout_height="fill_parent" > |
284 | |
285 | - <LinearLayout style="@style/TitleBar"> |
286 | - <TextView android:id="@id/actionbar_title" |
287 | - style="@style/TitleBarText" |
288 | - android:text="@string/title_status" /> |
289 | - |
290 | - <ProgressBar android:id="@id/actionbar_indeterminate" |
291 | - style="@style/TitleBarProgressIndicator" |
292 | - android:visibility="gone" /> |
293 | - <!-- |
294 | - <ImageView style="@style/TitleBarSeparator" /> |
295 | - --> |
296 | - <ImageButton android:id="@id/actionbar_refresh" |
297 | - style="@style/TitleBarAction" |
298 | - android:src="@drawable/ic_title_refresh_default" |
299 | - android:onClick="onRefreshClick" /> |
300 | - </LinearLayout> |
301 | - |
302 | <ListView |
303 | android:id="@+id/service_list" |
304 | android:layout_width="fill_parent" |
305 | |
306 | === modified file 'res/layout/row.xml' |
307 | --- res/layout/row.xml 2011-01-12 22:24:37 +0000 |
308 | +++ res/layout/row.xml 2011-04-04 13:36:49 +0000 |
309 | @@ -48,7 +48,7 @@ |
310 | android:singleLine="true" |
311 | android:ellipsize="marquee" |
312 | android:textSize="16dip" |
313 | - android:textColor="#EE0000" |
314 | + android:textColor="@color/file_text_fg" |
315 | |
316 | android:text="filename" /> |
317 | |
318 | |
319 | === modified file 'res/raw/notice' |
320 | --- res/raw/notice 2011-03-01 19:36:58 +0000 |
321 | +++ res/raw/notice 2011-04-04 13:36:49 +0000 |
322 | @@ -61,6 +61,6 @@ |
323 | |
324 | karni |
325 | |
326 | -e-mail: mkarnicki@gmail.com |
327 | +e-mail: michal.karnicki@canonical.com |
328 | irc: karni #ubuntuone @freenode |
329 | </small> |
330 | |
331 | === modified file 'res/values/colors.xml' |
332 | --- res/values/colors.xml 2011-03-24 15:38:17 +0000 |
333 | +++ res/values/colors.xml 2011-04-04 13:36:49 +0000 |
334 | @@ -5,6 +5,8 @@ |
335 | <color name="text_fg_dash_btn">#AAAAAA</color> |
336 | <color name="list_separator">#CCCCCC</color> |
337 | |
338 | - <color name="remote_file_background">#CCDFDFDF</color> |
339 | - <color name="local_file_background">#FFFFFF</color> |
340 | + <color name="remote_file_bg">#CCDFDFDF</color> |
341 | + <color name="local_file_bg">#FFFFFF</color> |
342 | + <color name="file_text_fg">#EE0000</color> |
343 | + <color name="file_published_text_fg">#1157FE</color> |
344 | </resources> |
345 | |
346 | === removed file 'res/values/ids.xml' |
347 | --- res/values/ids.xml 2011-01-06 23:32:17 +0000 |
348 | +++ res/values/ids.xml 1970-01-01 00:00:00 +0000 |
349 | @@ -1,13 +0,0 @@ |
350 | -<?xml version="1.0" encoding="utf-8"?> |
351 | -<resources> |
352 | - <item type="id" name="title_bar" /> |
353 | - <item type="id" name="title_logo" /> |
354 | - <item type="id" name="title_text" /> |
355 | - |
356 | - <!-- Actionbar item ids --> |
357 | - <item type="id" name="actionbar_title" /> |
358 | - <item type="id" name="actionbar_indeterminate" /> |
359 | - <item type="id" name="actionbar_search" /> |
360 | - <item type="id" name="actionbar_refresh" /> |
361 | - <item type="id" name="actionbar_upload" /> |
362 | -</resources> |
363 | |
364 | === modified file 'res/values/strings.xml' |
365 | --- res/values/strings.xml 2011-03-06 03:36:02 +0000 |
366 | +++ res/values/strings.xml 2011-04-04 13:36:49 +0000 |
367 | @@ -19,6 +19,9 @@ |
368 | <string name="pick_image_title">Pick image with</string> |
369 | <string name="pick_video_title">Pick video with</string> |
370 | <string name="pick_audio_title">Pick audio with</string> |
371 | + <string name="action_bar_image">Image</string> |
372 | + <string name="action_bar_video">Video</string> |
373 | + <string name="action_bar_audio">Audio</string> |
374 | |
375 | <!-- Context menus --> |
376 | <string name="context_open">Open</string> |
377 | @@ -27,7 +30,7 @@ |
378 | <string name="context_copy_link">Copy public link</string> |
379 | <string name="context_unpublish">Unpublish</string> |
380 | <string name="context_sync">Sync</string> |
381 | - <string name="context_dont_sync">Dont sync</string> |
382 | + <string name="context_dont_sync">Don\'t sync</string> |
383 | <string name="context_share">Share</string> |
384 | <string name="context_rename">Rename</string> |
385 | <string name="context_remove">Remove</string> |
386 | @@ -46,16 +49,13 @@ |
387 | <string name="option_stop_and_quit_title">Stop sync, too</string> |
388 | |
389 | <!-- Files activity --> |
390 | - <string name="title_files">Files</string> |
391 | + <string name="title_files">Ubuntu One</string> |
392 | |
393 | <!-- UDFs activity --> |
394 | - <string name="title_udfs">UDFs</string> |
395 | + <string name="title_udfs">Synced Folders</string> |
396 | |
397 | <!-- Shares activity --> |
398 | <string name="title_shares">Shares</string> |
399 | - |
400 | - <!-- Published activity --> |
401 | - <string name="title_published">Published</string> |
402 | |
403 | <!-- Status activity --> |
404 | <string name="title_status">Status</string> |
405 | @@ -104,6 +104,9 @@ |
406 | <string name="fetch_token_failed">Failed to receive auth token</string> |
407 | <string name="working_offline">Working off-line</string> |
408 | |
409 | + <string name="please_wait">Please wait</string> |
410 | + <string name="no_items">No items</string> |
411 | + |
412 | <string name="ok_dialog_button_text">OK</string> |
413 | <string name="yes_dialog_button_text">Yes</string> |
414 | <string name="no_dialog_button_text">No</string> |
415 | |
416 | === modified file 'res/values/styles.xml' |
417 | --- res/values/styles.xml 2011-02-25 10:35:51 +0000 |
418 | +++ res/values/styles.xml 2011-04-04 13:36:49 +0000 |
419 | @@ -2,86 +2,6 @@ |
420 | <resources> |
421 | <style name="Theme" parent="android:Theme"></style> |
422 | |
423 | - <style name="Theme.U1F" parent="android:style/Theme.Light"> |
424 | - <item name="android:windowNoTitle">true</item> |
425 | - <item name="android:windowContentOverlay">@null</item> |
426 | - <item name="android:fadeScrollbars">true</item> |
427 | - </style> |
428 | - |
429 | - <style name="LauncherBackground" parent="Theme.U1F"> |
430 | - <item name="android:windowBackground">@drawable/loading</item> |
431 | - |
432 | - </style> |
433 | - |
434 | - <style name="TitleBar"> |
435 | - <item name="android:id">@id/title_bar</item> |
436 | - <item name="android:layout_width">fill_parent</item> |
437 | - <item name="android:layout_height">@dimen/title_height</item> |
438 | - <item name="android:orientation">horizontal</item> |
439 | - <item name="android:background">@drawable/title_gradient</item> |
440 | - </style> |
441 | - |
442 | - <style name="TitleBarAction"> |
443 | - <item name="android:layout_width">@dimen/title_height</item> |
444 | - <item name="android:layout_height">fill_parent</item> |
445 | - <item name="android:background">@drawable/title_button</item> |
446 | - </style> |
447 | - |
448 | - <style |
449 | - name="TitleBarProgressIndicator" |
450 | - parent="@android:style/Widget.ProgressBar.Small"> |
451 | - |
452 | - <item name="android:layout_width">wrap_content</item> |
453 | - <item name="android:layout_height">wrap_content</item> |
454 | - <item name="android:layout_marginLeft">15dip</item> |
455 | - <item name="android:layout_marginRight">15dip</item> |
456 | - <item name="android:layout_marginTop">14dip</item> |
457 | - <item name="android:indeterminate">true</item> |
458 | - </style> |
459 | - |
460 | - <style |
461 | - name="HeaderProgressBar" |
462 | - parent="@android:style/Widget.ProgressBar.Small.Inverse"> |
463 | - |
464 | - <item name="android:layout_width">wrap_content</item> |
465 | - <item name="android:layout_height">wrap_content</item> |
466 | - <item name="android:layout_gravity">center_vertical</item> |
467 | - <item name="android:indeterminate">true</item> |
468 | - <item name="android:layout_marginRight">6dip</item> |
469 | - <item name="android:paddingRight">6dip</item> |
470 | - |
471 | - <item name="android:focusable">false</item> |
472 | - <item name="android:focusableInTouchMode">false</item> |
473 | - </style> |
474 | - |
475 | - <style name="TitleBarSeparator"> |
476 | - <item name="android:layout_width">1px</item> |
477 | - <item name="android:layout_height">@dimen/title_height</item> |
478 | - <item name="android:background">@color/title_separator</item> |
479 | - </style> |
480 | - |
481 | - <style name="TitleBarLogo"> |
482 | - <item name="android:id">@+id/title_logo</item> |
483 | - <item name="android:layout_width">wrap_content</item> |
484 | - <item name="android:layout_height">fill_parent</item> |
485 | - <item name="android:clickable">true</item> |
486 | - </style> |
487 | - |
488 | - <style name="TitleBarText"> |
489 | - <item name="android:id">@+id/title_text</item> |
490 | - <item name="android:layout_width">0dp</item> |
491 | - <item name="android:layout_height">fill_parent</item> |
492 | - <item name="android:layout_weight">1</item> |
493 | - <item name="android:gravity">center_vertical</item> |
494 | - <item name="android:textSize">@dimen/text_size_medium</item> |
495 | - <item name="android:paddingLeft">12dip</item> |
496 | - <item name="android:paddingRight">12dip</item> |
497 | - <item name="android:textStyle">bold</item> |
498 | - <item name="android:textColor">@color/title_text</item> |
499 | - <item name="android:singleLine">true</item> |
500 | - <item name="android:ellipsize">end</item> |
501 | - </style> |
502 | - |
503 | <style name="ListHeaderText"> |
504 | <item name="android:layout_width">fill_parent</item> |
505 | <item name="android:layout_height">wrap_content</item> |
506 | |
507 | === added file 'res/values/themes.xml' |
508 | --- res/values/themes.xml 1970-01-01 00:00:00 +0000 |
509 | +++ res/values/themes.xml 2011-04-04 13:36:49 +0000 |
510 | @@ -0,0 +1,16 @@ |
511 | +<?xml version="1.0" encoding="utf-8"?> |
512 | +<resources> |
513 | + |
514 | + <style name="Theme.U1F" parent="@style/Theme.GreenDroid.NoTitleBar"> |
515 | + <item name="gdActionBarTitleColor">@android:color/white</item> |
516 | + <item name="gdActionBarBackground">@drawable/action_bar_background</item> |
517 | + <item name="gdActionBarDividerDrawable">@drawable/action_bar_divider</item> |
518 | + <item name="gdActionBarDividerWidth">2px</item> |
519 | + <item name="gdActionBarApplicationDrawable">@drawable/launcher</item> |
520 | + </style> |
521 | + |
522 | + <style name="Theme.Dashboard" parent="@style/Theme.U1F"> |
523 | + <item name="android:windowBackground">@drawable/loading</item> |
524 | + </style> |
525 | + |
526 | +</resources> |
527 | |
528 | === modified file 'setup' |
529 | --- setup 2011-02-15 20:06:04 +0000 |
530 | +++ setup 2011-04-04 13:36:49 +0000 |
531 | @@ -24,6 +24,11 @@ |
532 | return 1 |
533 | fi |
534 | |
535 | +GITBIN=$(which git) |
536 | +if test -z "${GITBIN}"; then |
537 | + echo "You need git to download GreenDroid lib." >&2 |
538 | +fi |
539 | + |
540 | trap "echo ' ==== Not Successful. ===='" EXIT |
541 | set -e |
542 | |
543 | |
544 | === modified file 'src/com/ubuntuone/android/files/Preferences.java' |
545 | --- src/com/ubuntuone/android/files/Preferences.java 2011-03-23 13:30:35 +0000 |
546 | +++ src/com/ubuntuone/android/files/Preferences.java 2011-04-04 13:36:49 +0000 |
547 | @@ -101,7 +101,7 @@ |
548 | public static final String DEBUG = "debug"; |
549 | public static final String SEND_LOGS = "send_logs"; |
550 | public static final String CLEAR_LOGS = "clear_logs"; |
551 | - public static final String CRASH_FLAG = "crashed"; |
552 | + public static final String OOPS_FLAG = "oops_flag"; |
553 | } |
554 | |
555 | public interface Url { |
556 | @@ -598,13 +598,13 @@ |
557 | return prefs.getLong(Storage.STORAGE_LIMIT, -1L); |
558 | } |
559 | |
560 | - public static void setCrashFlag(boolean flag) { |
561 | - editor.putBoolean(Debug.CRASH_FLAG, flag); |
562 | + public static void setOopsFlag(boolean flag) { |
563 | + editor.putBoolean(Debug.OOPS_FLAG, flag); |
564 | editor.commit(); |
565 | } |
566 | |
567 | public static boolean getCrashFlag() { |
568 | - return getBoolean(Debug.CRASH_FLAG, false); |
569 | + return getBoolean(Debug.OOPS_FLAG, false); |
570 | } |
571 | |
572 | public static boolean getIsManualLimits() { |
573 | |
574 | === modified file 'src/com/ubuntuone/android/files/UbuntuOneFiles.java' |
575 | --- src/com/ubuntuone/android/files/UbuntuOneFiles.java 2011-03-23 13:30:35 +0000 |
576 | +++ src/com/ubuntuone/android/files/UbuntuOneFiles.java 2011-04-04 13:36:49 +0000 |
577 | @@ -22,12 +22,13 @@ |
578 | |
579 | package com.ubuntuone.android.files; |
580 | |
581 | +import greendroid.app.GDApplication; |
582 | + |
583 | import java.lang.ref.WeakReference; |
584 | import java.util.concurrent.atomic.AtomicInteger; |
585 | |
586 | import android.app.Activity; |
587 | import android.app.AlarmManager; |
588 | -import android.app.Application; |
589 | import android.app.PendingIntent; |
590 | import android.app.Service; |
591 | import android.content.Context; |
592 | @@ -49,25 +50,25 @@ |
593 | import com.ubuntuone.android.files.syncdaemon.SyncDaemon; |
594 | import com.ubuntuone.android.files.syncdaemon.states.Node; |
595 | import com.ubuntuone.android.files.syncdaemon.states.StateManager; |
596 | +import com.ubuntuone.android.files.ui.DashboardActivity; |
597 | import com.ubuntuone.android.files.util.DateUtilities; |
598 | import com.ubuntuone.android.files.util.Util; |
599 | import com.ubuntuone.android.files.util.OAuthUtilities.OAuthClient; |
600 | import com.ubuntuone.android.util.log.Log; |
601 | |
602 | -public final class UbuntuOneFiles extends Application { |
603 | +public final class UbuntuOneFiles extends GDApplication { |
604 | |
605 | private static final String TAG = UbuntuOneFiles.class.getSimpleName(); |
606 | |
607 | private static UbuntuOneFiles sApplicationInstance; |
608 | |
609 | - // TODO Remove this when sync logic moved to commands. |
610 | - public static boolean sSyncInProgress; |
611 | + private Handler mHandler; |
612 | |
613 | private EventQueue mEventQueue; |
614 | |
615 | private StateManager mStateManager; |
616 | |
617 | - private Handler mHandler; |
618 | + public static boolean sSyncInProgress; |
619 | |
620 | @Override |
621 | public void onCreate() { |
622 | @@ -88,7 +89,9 @@ |
623 | } |
624 | Log.d(TAG, "starting application"); |
625 | |
626 | - Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler()); |
627 | + Thread.setDefaultUncaughtExceptionHandler( |
628 | + new UncaughtExceptionHandler( |
629 | + Thread.getDefaultUncaughtExceptionHandler())); |
630 | |
631 | // Initially, set storage limit equal to available SD storage. |
632 | long limit = Preferences.getStorageLimit(); |
633 | @@ -137,6 +140,11 @@ |
634 | return sApplicationInstance; |
635 | } |
636 | |
637 | + @Override |
638 | + public Class<?> getHomeActivityClass() { |
639 | + return DashboardActivity.class; |
640 | + } |
641 | + |
642 | public static EventQueue getEventQueue() { |
643 | return sApplicationInstance.mEventQueue; |
644 | } |
645 | @@ -463,19 +471,16 @@ |
646 | |
647 | private class UncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { |
648 | |
649 | - private void killSelf() { |
650 | - // Run any pending CRUD and close the database. |
651 | - FilesDatabase.performBatchSqlExec(); |
652 | - FilesDatabase.closeDatabase(); |
653 | - // Close the logs cleanly. |
654 | - Log.shutdown(); |
655 | - android.os.Process.killProcess(android.os.Process.myPid()); |
656 | - // TODO Implement re-start? |
657 | + private Thread.UncaughtExceptionHandler mDefaultHandler; |
658 | + |
659 | + public UncaughtExceptionHandler( |
660 | + Thread.UncaughtExceptionHandler defaultHandler) { |
661 | + mDefaultHandler = defaultHandler; |
662 | } |
663 | |
664 | public void uncaughtException(Thread thread, Throwable ex) { |
665 | - // Set the crash flag; |
666 | - Preferences.setCrashFlag(true); |
667 | + // Set the crash flag. |
668 | + Preferences.setOopsFlag(true); |
669 | |
670 | // Log the problem. |
671 | Log.d(TAG, "UNHANDLED exception: " + ex.getMessage()); |
672 | @@ -483,9 +488,14 @@ |
673 | for (StackTraceElement stackTraceElement : stackTrace) { |
674 | Log.d(TAG, stackTraceElement.toString()); |
675 | } |
676 | + // Run any pending CRUD and close the database. |
677 | + FilesDatabase.performBatchSqlExec(); |
678 | + FilesDatabase.closeDatabase(); |
679 | + // Close the logs cleanly. |
680 | + Log.shutdown(); |
681 | |
682 | - // Don't continue, we might be unstable. |
683 | - killSelf(); |
684 | + // Pass it to default uncaught exception handler. |
685 | + mDefaultHandler.uncaughtException(thread, ex); |
686 | } |
687 | } |
688 | |
689 | |
690 | === modified file 'src/com/ubuntuone/android/files/provider/FilesUtilities.java' |
691 | --- src/com/ubuntuone/android/files/provider/FilesUtilities.java 2011-03-10 00:00:57 +0000 |
692 | +++ src/com/ubuntuone/android/files/provider/FilesUtilities.java 2011-04-04 13:36:49 +0000 |
693 | @@ -34,7 +34,6 @@ |
694 | import com.ubuntuone.android.files.provider.FilesContract.Files; |
695 | import com.ubuntuone.android.files.provider.FilesContract.FilesStatus; |
696 | import com.ubuntuone.android.files.syncdaemon.MsgArgs; |
697 | -import com.ubuntuone.android.files.util.PathTool; |
698 | import com.ubuntuone.android.files.util.Util; |
699 | import com.ubuntuone.android.util.log.Log; |
700 | import com.ubuntuone.storageprotocol.StorageProtocol.FileInfo.FileType; |
701 | @@ -213,10 +212,11 @@ |
702 | Cursor c = FilesDatabase.rawQuery("SELECT file_synced FROM files " + |
703 | "WHERE _id=?", new String[]{id.toString()}); |
704 | if (c.moveToFirst()) { |
705 | - syncable = c.getInt(c.getColumnIndex(Files.SYNCED)) != 0 ? true |
706 | - : false; |
707 | + Log.d(TAG, ">>>>>>>>>> " + c.getInt(c.getColumnIndex(Files.SYNCED))); |
708 | + syncable = c.getString(c.getColumnIndex(Files.SYNCED)).equals("true"); |
709 | } |
710 | c.close(); |
711 | + Log.d(TAG, ">>>>>>>>" + syncable); |
712 | return syncable; |
713 | } |
714 | |
715 | @@ -250,13 +250,8 @@ |
716 | } |
717 | |
718 | public static void setPublicUrl(Long id, String url) { |
719 | - if (url != null) { |
720 | - FilesDatabase.execSQL("UPDATE files SET file_url=? WHERE _id=?", |
721 | - new Object[]{url, id.toString()}); |
722 | - } else { |
723 | - FilesDatabase.execSQL("UPDATE files SET file_url=? WHERE _id=?", |
724 | - new Object[]{""}); |
725 | - } |
726 | + FilesDatabase.execSQL("UPDATE files SET file_url=? WHERE _id=?", |
727 | + new Object[] { (url == null) ? "" : url, id.toString() }); |
728 | } |
729 | |
730 | private static final String[] sVolumeTypes = new String[]{ |
731 | |
732 | === modified file 'src/com/ubuntuone/android/files/syncdaemon/EventQueue.java' |
733 | --- src/com/ubuntuone/android/files/syncdaemon/EventQueue.java 2011-03-10 00:00:57 +0000 |
734 | +++ src/com/ubuntuone/android/files/syncdaemon/EventQueue.java 2011-04-04 13:36:49 +0000 |
735 | @@ -80,7 +80,9 @@ |
736 | * @param h |
737 | * the handler object to remove from the queue. |
738 | */ |
739 | - public void unsubscribe(final Handler h) { |
740 | + public synchronized void unsubscribe(final Handler h) { |
741 | + if (h == null) |
742 | + return; |
743 | if (mListeners.contains(h)) { |
744 | mListeners.remove(h); |
745 | Log.v(TAG, "handler unsubscribed from EQ"); |
746 | @@ -95,7 +97,9 @@ |
747 | * @param h |
748 | * the handler object to add to the listener queue. |
749 | */ |
750 | - public void subscribe(final Handler h) { |
751 | + public synchronized void subscribe(final Handler h) { |
752 | + if (h == null) |
753 | + return; |
754 | if (!mListeners.contains(h)) { |
755 | Log.v(TAG, "handler subscribed to EQ"); |
756 | mListeners.add(h); |
757 | @@ -157,9 +161,11 @@ |
758 | * @param event |
759 | * the event to push. |
760 | */ |
761 | - private void dispatch(final Message event) { |
762 | + private synchronized void dispatch(final Message event) { |
763 | Iterator<Handler> iterator = mListeners.iterator(); |
764 | Handler target; |
765 | + if (iterator == null) |
766 | + return; |
767 | while (iterator.hasNext()) { |
768 | target = iterator.next(); |
769 | // Make sure we don't send a message to a dead Thread. |
770 | |
771 | === modified file 'src/com/ubuntuone/android/files/syncdaemon/SyncManager.java' |
772 | --- src/com/ubuntuone/android/files/syncdaemon/SyncManager.java 2011-03-10 00:00:57 +0000 |
773 | +++ src/com/ubuntuone/android/files/syncdaemon/SyncManager.java 2011-04-04 13:36:49 +0000 |
774 | @@ -89,15 +89,19 @@ |
775 | case CanISync.NO_NETWORK: |
776 | args.setError(new Throwable("no network available")); |
777 | sync = false; |
778 | + break; |
779 | case CanISync.NO_PREFERRED: |
780 | args.setError(new Throwable("not preferred sync network")); |
781 | sync = false; |
782 | + break; |
783 | case CanISync.NO_BACKGROUND: |
784 | args.setError(new Throwable("background data disabled")); |
785 | sync = false; |
786 | + break; |
787 | case CanISync.ROAMING: |
788 | args.setError(new Throwable("roaming")); |
789 | sync = false; |
790 | + break; |
791 | } |
792 | |
793 | if (sync == false) { |
794 | |
795 | === modified file 'src/com/ubuntuone/android/files/syncdaemon/commands/Sync.java' |
796 | --- src/com/ubuntuone/android/files/syncdaemon/commands/Sync.java 2011-03-10 00:00:57 +0000 |
797 | +++ src/com/ubuntuone/android/files/syncdaemon/commands/Sync.java 2011-04-04 13:36:49 +0000 |
798 | @@ -54,15 +54,19 @@ |
799 | case CanISync.NO_NETWORK: |
800 | args.setError(new Throwable("no network available")); |
801 | shouldBeQueued = false; |
802 | + break; |
803 | case CanISync.NO_PREFERRED: |
804 | args.setError(new Throwable("not preferred sync network")); |
805 | shouldBeQueued = false; |
806 | + break; |
807 | case CanISync.NO_BACKGROUND: |
808 | args.setError(new Throwable("background data disabled")); |
809 | shouldBeQueued = false; |
810 | + break; |
811 | case CanISync.ROAMING: |
812 | args.setError(new Throwable("roaming")); |
813 | shouldBeQueued = false; |
814 | + break; |
815 | } |
816 | |
817 | // Check if should not be queued because of connectivity/preferences. |
818 | |
819 | === removed file 'src/com/ubuntuone/android/files/ui/Actionbar.java' |
820 | --- src/com/ubuntuone/android/files/ui/Actionbar.java 2011-01-06 23:32:17 +0000 |
821 | +++ src/com/ubuntuone/android/files/ui/Actionbar.java 1970-01-01 00:00:00 +0000 |
822 | @@ -1,118 +0,0 @@ |
823 | -/* |
824 | - * Ubuntu One Files - access Ubuntu One cloud storage on Android platform. |
825 | - * |
826 | - * Copyright (C) 2010 Canonical Ltd. |
827 | - * Author: Michał Karnicki <mkarnicki@gmail.com> |
828 | - * |
829 | - * This file is part of Ubuntu One Files. |
830 | - * |
831 | - * This program is free software: you can redistribute it and/or modify |
832 | - * it under the terms of the GNU Affero General Public License as |
833 | - * published by the Free Software Foundation, either version 3 of the |
834 | - * License, or (at your option) any later version. |
835 | - * |
836 | - * This program is distributed in the hope that it will be useful, |
837 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
838 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
839 | - * GNU Affero General Public License for more details. |
840 | - * |
841 | - * You should have received a copy of the GNU Affero General Public License |
842 | - * along with this program. If not, see http://www.gnu.org/licenses |
843 | - */ |
844 | - |
845 | -package com.ubuntuone.android.files.ui; |
846 | - |
847 | -import android.app.Activity; |
848 | -import android.view.View; |
849 | -import android.widget.ImageButton; |
850 | -import android.widget.ProgressBar; |
851 | -import android.widget.TextView; |
852 | - |
853 | -import com.ubuntuone.android.files.R; |
854 | - |
855 | -public class Actionbar implements IActionbar { |
856 | - |
857 | - private TextView mTitle; |
858 | - |
859 | - private ProgressBar mIndeterminate; |
860 | - |
861 | - private ImageButton mUpload; |
862 | - |
863 | - private ImageButton mSearch; |
864 | - |
865 | - public Actionbar(Activity activity) { |
866 | - mTitle = (TextView) activity.findViewById(R.id.actionbar_title); |
867 | - mIndeterminate = (ProgressBar) activity.findViewById(R.id.actionbar_indeterminate); |
868 | - mUpload = (ImageButton) activity.findViewById(R.id.actionbar_upload); |
869 | - mSearch = (ImageButton) activity.findViewById(R.id.actionbar_search); |
870 | - } |
871 | - |
872 | - // Actionbar title TextView view. |
873 | - |
874 | - public void setActionbarTitle(CharSequence title) { |
875 | - if (mTitle != null) |
876 | - mTitle.setText(title); |
877 | - } |
878 | - |
879 | - public void hideActionbarTitle() { |
880 | - if (mTitle != null) |
881 | - mTitle.setVisibility(View.GONE); |
882 | - } |
883 | - |
884 | - public void showActionbarTitle() { |
885 | - if (mTitle != null) |
886 | - mTitle.setVisibility(View.VISIBLE); |
887 | - } |
888 | - |
889 | - // Actionbar indeterminate ProgressBar view. |
890 | - |
891 | - public void setActionbarIndeterminateVisibility(int visibility) { |
892 | - if (mIndeterminate != null) |
893 | - mIndeterminate.setVisibility(visibility); |
894 | - } |
895 | - |
896 | - public void hideActionbarIndeterminate() { |
897 | - if (mIndeterminate != null) |
898 | - mIndeterminate.setVisibility(View.GONE); |
899 | - } |
900 | - |
901 | - public void showActionbarIndeterminate() { |
902 | - if (mIndeterminate != null) |
903 | - mIndeterminate.setVisibility(View.VISIBLE); |
904 | - } |
905 | - |
906 | - // Actionbar upload ImageButton view. |
907 | - |
908 | - public void setActionbarUploadVisibility(int visibility) { |
909 | - if (mUpload != null) |
910 | - mUpload.setVisibility(visibility); |
911 | - } |
912 | - |
913 | - public void hideActionbarUpload() { |
914 | - if (mUpload != null) |
915 | - mUpload.setVisibility(View.GONE); |
916 | - } |
917 | - |
918 | - public void showActionbarUpload() { |
919 | - if (mUpload != null) |
920 | - mUpload.setVisibility(View.VISIBLE); |
921 | - } |
922 | - |
923 | - // Actionbar search ImageButton view. |
924 | - |
925 | - public void setActionbarSearchVisibility(int visibility) { |
926 | - if (mSearch != null) |
927 | - mSearch.setVisibility(visibility); |
928 | - } |
929 | - |
930 | - public void hideActionbarSearch() { |
931 | - if (mSearch != null) |
932 | - mSearch.setVisibility(View.GONE); |
933 | - } |
934 | - |
935 | - public void showActionbarSearch() { |
936 | - if (mSearch != null) |
937 | - mSearch.setVisibility(View.VISIBLE); |
938 | - } |
939 | - |
940 | -} |
941 | |
942 | === modified file 'src/com/ubuntuone/android/files/ui/CustomListActivity.java' |
943 | --- src/com/ubuntuone/android/files/ui/CustomListActivity.java 2011-03-24 14:09:46 +0000 |
944 | +++ src/com/ubuntuone/android/files/ui/CustomListActivity.java 2011-04-04 13:36:49 +0000 |
945 | @@ -22,12 +22,28 @@ |
946 | |
947 | package com.ubuntuone.android.files.ui; |
948 | |
949 | +import greendroid.app.GDListActivity; |
950 | +import greendroid.widget.ActionBar; |
951 | +import greendroid.widget.ActionBarItem; |
952 | +import greendroid.widget.LoaderActionBarItem; |
953 | +import greendroid.widget.NormalActionBarItem; |
954 | +import greendroid.widget.QuickAction; |
955 | +import greendroid.widget.QuickActionBar; |
956 | +import greendroid.widget.QuickActionGrid; |
957 | +import greendroid.widget.QuickActionWidget; |
958 | +import greendroid.widget.QuickActionWidget.OnQuickActionClickListener; |
959 | + |
960 | import java.io.File; |
961 | |
962 | -import android.app.ListActivity; |
963 | +import android.app.Activity; |
964 | import android.app.ProgressDialog; |
965 | +import android.content.Context; |
966 | import android.content.Intent; |
967 | import android.database.Cursor; |
968 | +import android.graphics.Color; |
969 | +import android.graphics.ColorFilter; |
970 | +import android.graphics.LightingColorFilter; |
971 | +import android.graphics.drawable.Drawable; |
972 | import android.net.Uri; |
973 | import android.os.AsyncTask; |
974 | import android.os.Bundle; |
975 | @@ -40,9 +56,7 @@ |
976 | import android.view.MenuItem; |
977 | import android.view.View; |
978 | import android.view.ContextMenu.ContextMenuInfo; |
979 | -import android.view.View.OnClickListener; |
980 | import android.view.animation.AnimationUtils; |
981 | -import android.widget.ImageButton; |
982 | import android.widget.ListAdapter; |
983 | import android.widget.ListView; |
984 | import android.widget.TextView; |
985 | @@ -71,13 +85,56 @@ |
986 | import com.ubuntuone.storageprotocol.StorageProtocol.FileInfo.FileType; |
987 | import com.ubuntuone.storageprotocol.StorageProtocol.Volumes.VolumeType; |
988 | |
989 | -public abstract class CustomListActivity extends ListActivity implements IActionbar { |
990 | +public class CustomListActivity extends GDListActivity { |
991 | private static final String TAG = CustomListActivity.class.getSimpleName(); |
992 | |
993 | - private Actionbar mActionbar; |
994 | + private LoaderActionBarItem mLoaderItem; |
995 | + |
996 | + private NormalActionBarItem mUploadItem; |
997 | + |
998 | + private QuickActionWidget mUploadGrid; |
999 | + |
1000 | + private QuickActionWidget mQuickActionBar; |
1001 | + |
1002 | + |
1003 | + private static final int ACTION_BAR_SYNC = 0; |
1004 | + |
1005 | + private static final int ACTION_BAR_UPLOAD = 1; |
1006 | + |
1007 | + |
1008 | + private static final int QUICK_ACTION_UPLOAD_IMAGE = 0; |
1009 | + |
1010 | + private static final int QUICK_ACTION_UPLOAD_VIDEO = 1; |
1011 | + |
1012 | + private static final int QUICK_ACTION_UPLOAD_AUDIO = 2; |
1013 | + |
1014 | + |
1015 | + private static final int QUICK_ACTION_DIRECTORY_OPEN = 0; |
1016 | + |
1017 | + private static final int QUICK_ACTION_DIRECTORY_SYNC = 1; |
1018 | + |
1019 | + private static final int QUICK_ACTION_DIRECTORY_DOWNLOAD = 2; |
1020 | + |
1021 | + private static final int QUICK_ACTION_DIRECTORY_SHARE = 3; |
1022 | + |
1023 | + private static final int QUICK_ACTION_DIRECTORY_MANAGE = 4; |
1024 | + |
1025 | + private static final int QUICK_ACTION_FILE_OPEN = 0; |
1026 | + |
1027 | + private static final int QUICK_ACTION_FILE_DOWNLOAD = 1; |
1028 | + |
1029 | + private static final int QUICK_ACTION_FILE_SYNC = 2; |
1030 | + |
1031 | + private static final int QUICK_ACTION_FILE_PUBLISH = 3; |
1032 | + |
1033 | + private static final int QUICK_ACTION_FILE_COPY_URL = 4; |
1034 | + |
1035 | + private ViewHolder mContextMenuSourceViewHolder; |
1036 | + |
1037 | |
1038 | private TextView mListHeader; |
1039 | |
1040 | + private TextView mEmptyTextView; |
1041 | |
1042 | protected CustomListActivityAdapter mAdapter; |
1043 | |
1044 | @@ -89,37 +146,172 @@ |
1045 | @Override |
1046 | protected void onCreate(Bundle savedInstanceState) { |
1047 | super.onCreate(savedInstanceState); |
1048 | - setContentView(R.layout.activity_list); |
1049 | + setActionBarContentView(R.layout.activity_list); |
1050 | + mLoaderItem = (LoaderActionBarItem) addActionBarItem(getActionBar() |
1051 | + .newActionBarItem(LoaderActionBarItem.class) |
1052 | + .setDrawable(R.drawable.gd_action_bar_refresh), |
1053 | + ActionBar.NONE); |
1054 | + mUploadItem = (NormalActionBarItem) addActionBarItem(getActionBar() |
1055 | + .newActionBarItem(NormalActionBarItem.class) |
1056 | + .setDrawable(R.drawable.gd_action_bar_export), |
1057 | + ActionBar.NONE); |
1058 | + prepareUploadQuickActionGrid(); |
1059 | + |
1060 | + mListHeader = (TextView) findViewById(R.id.list_header_text); |
1061 | + mEmptyTextView = (TextView) findViewById(android.R.id.empty); |
1062 | + |
1063 | + ListView listView = getListView(); |
1064 | + listView.setItemsCanFocus(true); |
1065 | + listView.setEmptyView(mEmptyTextView); |
1066 | + listView.setSelector(R.drawable.list_selector); |
1067 | + |
1068 | + registerForContextMenu(getListView()); |
1069 | + |
1070 | mEventQueue = UbuntuOneFiles.getEventQueue(); |
1071 | mHandler = new Handler(mHandlerCallback); |
1072 | - mActionbar = new Actionbar(this); |
1073 | - mActionbar.setActionbarTitle(getActionBarTitle()); |
1074 | - |
1075 | - getListView().setItemsCanFocus(true); |
1076 | - getListView().setFastScrollEnabled(true); |
1077 | - |
1078 | - mListHeader = (TextView) findViewById(R.id.list_header_text); |
1079 | - |
1080 | - registerForContextMenu(getListView()); |
1081 | - |
1082 | - ImageButton upload = (ImageButton) findViewById(R.id.actionbar_upload); |
1083 | - upload.setOnClickListener(new OnClickListener() { |
1084 | - public void onClick(View v) { |
1085 | - // FIXME Execute upload file menu directly. |
1086 | - CustomListActivity.this.openOptionsMenu(); |
1087 | - } |
1088 | - }); |
1089 | - } |
1090 | - |
1091 | + } |
1092 | + |
1093 | + @Override |
1094 | + public boolean onHandleActionBarItemClick(ActionBarItem item, int position) { |
1095 | + switch (position) { |
1096 | + case ACTION_BAR_SYNC: |
1097 | + // TODO karni: sync only currently visible volume |
1098 | + mEventQueue.push(Message.obtain(null, R.string.CMD_SYNC)); |
1099 | + break; |
1100 | + case ACTION_BAR_UPLOAD: |
1101 | + onShowUploadBar(item.getItemView()); |
1102 | + break; |
1103 | + |
1104 | + default: |
1105 | + Log.w(TAG, "unknown action bar action"); |
1106 | + break; |
1107 | + } |
1108 | + return super.onHandleActionBarItemClick(item, position); |
1109 | + } |
1110 | + |
1111 | + private void prepareUploadQuickActionGrid() { |
1112 | + mUploadGrid = new QuickActionGrid(this); |
1113 | + // XXX karni: We need icons for: image, video and audio. |
1114 | + mUploadGrid.addQuickAction(new MyQuickAction(this, |
1115 | + R.drawable.gd_action_bar_gallery, |
1116 | + R.string.action_bar_image)); |
1117 | + mUploadGrid.addQuickAction(new MyQuickAction(this, |
1118 | + R.drawable.gd_action_bar_take_photo, |
1119 | + R.string.action_bar_video)); |
1120 | + mUploadGrid.addQuickAction(new MyQuickAction(this, |
1121 | + R.drawable.gd_action_bar_talk, |
1122 | + R.string.action_bar_image)); |
1123 | + mUploadGrid.setOnQuickActionClickListener(mUploadQuickActionListener); |
1124 | + } |
1125 | + |
1126 | + private void onShowUploadBar(View v) { |
1127 | + mUploadGrid.show(v); |
1128 | + } |
1129 | + |
1130 | + private OnQuickActionClickListener mUploadQuickActionListener = |
1131 | + new OnQuickActionClickListener() { |
1132 | + |
1133 | + public void onQuickActionClicked(QuickActionWidget widget, int position) { |
1134 | + switch (position) { |
1135 | + case QUICK_ACTION_UPLOAD_IMAGE: |
1136 | + onUploadImage(); |
1137 | + break; |
1138 | + case QUICK_ACTION_UPLOAD_VIDEO: |
1139 | + onUploadVideo(); |
1140 | + break; |
1141 | + case QUICK_ACTION_UPLOAD_AUDIO: |
1142 | + onUploadAudio(); |
1143 | + break; |
1144 | + |
1145 | + default: |
1146 | + Log.w(TAG, "unknown upload quick action"); |
1147 | + break; |
1148 | + } |
1149 | + } |
1150 | + |
1151 | + }; |
1152 | + |
1153 | + private OnQuickActionClickListener mOnDirectoryQuickActionBarClickListener = |
1154 | + new OnQuickActionClickListener() { |
1155 | + |
1156 | + public void onQuickActionClicked(QuickActionWidget widget, int position) { |
1157 | + final Activity activity = CustomListActivity.this; |
1158 | + final ViewHolder holder = mContextMenuSourceViewHolder; |
1159 | + |
1160 | + switch (position) { |
1161 | + case QUICK_ACTION_DIRECTORY_OPEN: |
1162 | + mAdapter.cd(activity, holder.id); |
1163 | + break; |
1164 | + case QUICK_ACTION_DIRECTORY_SYNC: |
1165 | + holder.star.performClick(); |
1166 | + break; |
1167 | + case QUICK_ACTION_DIRECTORY_DOWNLOAD: |
1168 | + // TODO karni: implement full folder download |
1169 | + break; |
1170 | + case QUICK_ACTION_DIRECTORY_SHARE: |
1171 | + // TODO karni: impelement folder sharing |
1172 | + break; |
1173 | + case QUICK_ACTION_DIRECTORY_MANAGE: |
1174 | + // TODO karni: implement folder sharing management |
1175 | + break; |
1176 | + |
1177 | + default: |
1178 | + Log.w(TAG, "unknown folder quick action"); |
1179 | + break; |
1180 | + } |
1181 | + } |
1182 | + |
1183 | + }; |
1184 | + |
1185 | + private OnQuickActionClickListener mOnFileQuickActionBarClickListener = |
1186 | + new OnQuickActionClickListener() { |
1187 | + |
1188 | + public void onQuickActionClicked(QuickActionWidget widget, int position) { |
1189 | + final ViewHolder holder = mContextMenuSourceViewHolder; |
1190 | + final long id = holder.id; |
1191 | + |
1192 | + switch (position) { |
1193 | + case QUICK_ACTION_FILE_OPEN: |
1194 | + openFile(id); |
1195 | + break; |
1196 | + case QUICK_ACTION_FILE_DOWNLOAD: |
1197 | + downloadFile(id); |
1198 | + break; |
1199 | + case QUICK_ACTION_FILE_SYNC: |
1200 | + holder.star.performClick(); |
1201 | + break; |
1202 | + case QUICK_ACTION_FILE_PUBLISH: |
1203 | + String url = FilesUtilities.getPublicUrl(id); |
1204 | + if (url == null || "".equals(url)) { |
1205 | + publishFile(id); |
1206 | + } else { |
1207 | + unpublishFile(id); |
1208 | + } |
1209 | + break; |
1210 | + case QUICK_ACTION_FILE_COPY_URL: |
1211 | + copyPublicLink(id); |
1212 | + break; |
1213 | + |
1214 | + default: |
1215 | + Log.w(TAG, "unknown file quick action"); |
1216 | + break; |
1217 | + } |
1218 | + } |
1219 | + |
1220 | + }; |
1221 | + |
1222 | private Handler.Callback mHandlerCallback = new Handler.Callback() { |
1223 | |
1224 | public boolean handleMessage(Message msg) { |
1225 | switch (msg.what) { |
1226 | case R.string.QM_WORKING: |
1227 | - mActionbar.showActionbarIndeterminate(); |
1228 | + showProgress(); |
1229 | + awaitWithListEmptyTextView(); |
1230 | break; |
1231 | case R.string.QM_IDLE: |
1232 | - mActionbar.hideActionbarIndeterminate(); |
1233 | + maybeHideProgress(); |
1234 | + resetListEmptyTextView(); |
1235 | + refreshListAdapter(); |
1236 | break; |
1237 | case R.string.SYS_SYNCING: |
1238 | showHeader(); |
1239 | @@ -127,12 +319,9 @@ |
1240 | case R.string.SYS_SYNC_ERROR: |
1241 | //$FALL-THROUGH$ |
1242 | case R.string.SYS_SYNCED: |
1243 | - // this hide() can cause problems before we move sync to AQ |
1244 | hideHeader(); |
1245 | refreshListAdapter(); |
1246 | break; |
1247 | - case R.string.AQ_UPLOAD_STARTED: |
1248 | - break; |
1249 | case R.string.AQ_UPLOAD_FINISHED: |
1250 | refreshListAdapter(); |
1251 | break; |
1252 | @@ -157,7 +346,6 @@ |
1253 | break; |
1254 | case R.string.AQ_DOWNLOAD_ERROR: |
1255 | refreshListAdapter(); |
1256 | - // TODO Add problem description from msg.obj |
1257 | Util.showLongToast(CustomListActivity.this, |
1258 | "Problem while downloading"); |
1259 | break; |
1260 | @@ -167,32 +355,32 @@ |
1261 | } |
1262 | return false; |
1263 | } |
1264 | + |
1265 | }; |
1266 | |
1267 | - private int mInForeground = -1; |
1268 | + private int mInForegroundToken = -1; |
1269 | |
1270 | @Override |
1271 | protected void onStart() { |
1272 | super.onStart(); |
1273 | mEventQueue.subscribe(mHandler); |
1274 | - mInForeground = UbuntuOneFiles.setForegroundActivity(this); |
1275 | + mInForegroundToken = UbuntuOneFiles.setForegroundActivity(this); |
1276 | } |
1277 | |
1278 | @Override |
1279 | protected void onResume() { |
1280 | - super.onResume(); |
1281 | + super.onResume(); |
1282 | if (UbuntuOneFiles.isQueueWorking()) { |
1283 | - mActionbar.showActionbarIndeterminate(); |
1284 | + showProgress(); |
1285 | } else { |
1286 | - if (!UbuntuOneFiles.sSyncInProgress) |
1287 | - mActionbar.hideActionbarIndeterminate(); |
1288 | + maybeHideProgress(); |
1289 | } |
1290 | } |
1291 | |
1292 | @Override |
1293 | protected void onStop() { |
1294 | mEventQueue.unsubscribe(mHandler); |
1295 | - UbuntuOneFiles.clearForegroundActivity(mInForeground); |
1296 | + UbuntuOneFiles.clearForegroundActivity(mInForegroundToken); |
1297 | super.onStop(); |
1298 | } |
1299 | |
1300 | @@ -203,9 +391,16 @@ |
1301 | |
1302 | // This condition is here, as adapter needs to be set before showHeader() |
1303 | if (UbuntuOneFiles.sSyncInProgress) { |
1304 | - mActionbar.showActionbarIndeterminate(); |
1305 | + showProgress(); |
1306 | showHeader(); |
1307 | } |
1308 | + |
1309 | + if (mAdapter.isAtRoot() && !VolumeType.ROOT.equals( |
1310 | + mAdapter.getPathTool().getType())) { |
1311 | + hideUpload(); |
1312 | + } else { |
1313 | + showUpload(); |
1314 | + } |
1315 | } |
1316 | |
1317 | public void refreshListAdapter() { |
1318 | @@ -226,13 +421,13 @@ |
1319 | |
1320 | @Override |
1321 | public boolean onPrepareOptionsMenu(Menu menu) { |
1322 | - MenuItem upload = menu.findItem(R.id.option_upload); |
1323 | + MenuItem uploadMenuItem = menu.findItem(R.id.option_upload); |
1324 | if (mAdapter.getPathTool().isAtRoot() && |
1325 | !VolumeType.ROOT.equals(mAdapter.getPathTool().getType())) { |
1326 | - upload.setEnabled(false); |
1327 | + uploadMenuItem.setEnabled(false); |
1328 | } else { |
1329 | - // TODO Disable upload in case of no connection. |
1330 | - upload.setEnabled(true); |
1331 | + // TODO karni: disable upload in case of no connection. |
1332 | + uploadMenuItem.setEnabled(true); |
1333 | } |
1334 | return super.onPrepareOptionsMenu(menu); |
1335 | } |
1336 | @@ -242,13 +437,13 @@ |
1337 | Log.d(TAG, "onOptionsItemSelected"); |
1338 | switch (item.getItemId()) { |
1339 | case R.id.option_upload_image: |
1340 | - onMenuUploadImage(); |
1341 | + onUploadImage(); |
1342 | return true; |
1343 | case R.id.option_upload_video: |
1344 | - onMenuUploadVideo(); |
1345 | + onUploadVideo(); |
1346 | return true; |
1347 | case R.id.option_upload_audio: |
1348 | - onMenuUploadAudio(); |
1349 | + onUploadAudio(); |
1350 | return true; |
1351 | |
1352 | default: |
1353 | @@ -256,7 +451,7 @@ |
1354 | } |
1355 | } |
1356 | |
1357 | - public void onMenuUploadImage() { |
1358 | + public void onUploadImage() { |
1359 | Intent intent = new Intent(Intent.ACTION_GET_CONTENT); |
1360 | intent.setType("image/*"); |
1361 | |
1362 | @@ -265,7 +460,7 @@ |
1363 | startActivityForResult(chooser, REQUEST_GET_FILE); |
1364 | } |
1365 | |
1366 | - public void onMenuUploadVideo() { |
1367 | + public void onUploadVideo() { |
1368 | Intent intent = new Intent(Intent.ACTION_GET_CONTENT); |
1369 | intent.setType("video/*"); |
1370 | |
1371 | @@ -274,7 +469,7 @@ |
1372 | startActivityForResult(chooser, REQUEST_GET_FILE); |
1373 | } |
1374 | |
1375 | - public void onMenuUploadAudio() { |
1376 | + public void onUploadAudio() { |
1377 | Intent intent = new Intent(Intent.ACTION_GET_CONTENT); |
1378 | intent.setType("audio/*"); |
1379 | |
1380 | @@ -314,8 +509,6 @@ |
1381 | } |
1382 | } |
1383 | |
1384 | - protected abstract CharSequence getActionBarTitle(); |
1385 | - |
1386 | private void showHeader() { |
1387 | runOnUiThread(new Runnable() { |
1388 | public void run() { |
1389 | @@ -329,7 +522,7 @@ |
1390 | mListHeader.startAnimation(AnimationUtils.makeInAnimation( |
1391 | CustomListActivity.this, false)); |
1392 | mListHeader.setVisibility(View.VISIBLE); |
1393 | - mActionbar.showActionbarIndeterminate(); |
1394 | + showProgress(); |
1395 | } |
1396 | }); |
1397 | } |
1398 | @@ -340,7 +533,7 @@ |
1399 | mListHeader.startAnimation(AnimationUtils.makeOutAnimation( |
1400 | CustomListActivity.this, false)); |
1401 | mListHeader.setVisibility(View.GONE); |
1402 | - mActionbar.hideActionbarIndeterminate(); |
1403 | + hideProgress(); |
1404 | } |
1405 | }); |
1406 | } |
1407 | @@ -416,80 +609,66 @@ |
1408 | break; |
1409 | } |
1410 | } |
1411 | - |
1412 | + |
1413 | @Override |
1414 | public void onCreateContextMenu(ContextMenu menu, View v, |
1415 | ContextMenuInfo menuInfo) { |
1416 | - super.onCreateContextMenu(menu, v, menuInfo); |
1417 | + // Use this method as a hook, but don't show the default context menu. |
1418 | + closeContextMenu(); |
1419 | |
1420 | final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; |
1421 | + mContextMenuSourceViewHolder = (ViewHolder) info.targetView.getTag(); |
1422 | final String type = (String) info.targetView.getTag(R.string.tag_type); |
1423 | - // inflate proper context menu for selected element |
1424 | - MenuInflater inflater = getMenuInflater(); |
1425 | - if (FileType.DIRECTORY.toString().equals(type)) |
1426 | - // It's a directory. |
1427 | - inflater.inflate(R.menu.context_menu_directory, menu); |
1428 | - else { |
1429 | - // It's a file. |
1430 | - inflater.inflate(R.menu.context_menu_file, menu); |
1431 | + |
1432 | + mQuickActionBar = new QuickActionBar(this); |
1433 | + |
1434 | + if (FileType.DIRECTORY.toString().equals(type)) { |
1435 | + mQuickActionBar.addQuickAction(new MyQuickAction(this, |
1436 | + R.drawable.gd_action_bar_list, |
1437 | + R.string.context_open)); |
1438 | + mQuickActionBar.addQuickAction(new MyQuickAction(this, |
1439 | + R.drawable.gd_action_bar_star, |
1440 | + R.string.context_sync)); |
1441 | + |
1442 | + mQuickActionBar.setOnQuickActionClickListener( |
1443 | + mOnDirectoryQuickActionBarClickListener); |
1444 | + } else if (FileType.FILE.toString().equals(type)) { |
1445 | + mQuickActionBar.addQuickAction(new MyQuickAction(this, |
1446 | + R.drawable.gd_action_bar_list, |
1447 | + R.string.context_open)); |
1448 | + mQuickActionBar.addQuickAction(new MyQuickAction(this, |
1449 | + R.drawable.gd_action_bar_info, |
1450 | + R.string.context_download)); |
1451 | |
1452 | if (!FilesUtilities.getIsNodeSyncable(info.id)) { |
1453 | - menu.findItem(R.id.file_sync).setVisible(true); |
1454 | - menu.findItem(R.id.file_dont_sync).setVisible(false); |
1455 | + mQuickActionBar.addQuickAction(new MyQuickAction(this, |
1456 | + R.drawable.gd_action_bar_star, |
1457 | + R.string.context_sync)); |
1458 | } else { |
1459 | - menu.findItem(R.id.file_sync).setVisible(false); |
1460 | - menu.findItem(R.id.file_dont_sync).setVisible(true); |
1461 | + mQuickActionBar.addQuickAction(new MyQuickAction(this, |
1462 | + R.drawable.gd_action_bar_star, |
1463 | + R.string.context_dont_sync)); |
1464 | } |
1465 | |
1466 | String url = FilesUtilities.getPublicUrl(info.id); |
1467 | - if (url != null && !"".equals(url)) { |
1468 | - menu.findItem(R.id.file_publish).setVisible(false); |
1469 | - menu.findItem(R.id.file_copy_link).setVisible(true); |
1470 | - menu.findItem(R.id.file_unpublish).setVisible(true); |
1471 | + if (!(url == null || "".equals(url))) { |
1472 | + mQuickActionBar.addQuickAction(new MyQuickAction(this, |
1473 | + R.drawable.gd_action_bar_star, |
1474 | + R.string.context_unpublish)); |
1475 | + mQuickActionBar.addQuickAction(new MyQuickAction(this, |
1476 | + R.drawable.gd_action_bar_export, |
1477 | + R.string.context_copy_link)); |
1478 | } else { |
1479 | - menu.findItem(R.id.file_publish).setVisible(true); |
1480 | - menu.findItem(R.id.file_copy_link).setVisible(false); |
1481 | - menu.findItem(R.id.file_unpublish).setVisible(false); |
1482 | + mQuickActionBar.addQuickAction(new MyQuickAction(this, |
1483 | + R.drawable.gd_action_bar_star, |
1484 | + R.string.context_publish)); |
1485 | } |
1486 | - } |
1487 | - menu.setHeaderTitle( |
1488 | - (CharSequence) info.targetView.getTag(R.string.tag_filename)); |
1489 | - } |
1490 | - |
1491 | - @Override |
1492 | - public boolean onContextItemSelected(MenuItem item) { |
1493 | - AdapterContextMenuInfo info = |
1494 | - (AdapterContextMenuInfo) item.getMenuInfo(); |
1495 | - ViewHolder holder = (ViewHolder) info.targetView.getTag(); |
1496 | - switch (item.getItemId()) { |
1497 | - case R.id.file_open: |
1498 | - openFile(info.id); |
1499 | - return true; |
1500 | - case R.id.file_download: |
1501 | - downloadFile(info.id); |
1502 | - return true; |
1503 | - case R.id.directory_open: |
1504 | - mAdapter.cd(this, info.id); |
1505 | - return true; |
1506 | - case R.id.file_sync: |
1507 | - holder.star.performClick(); |
1508 | - break; |
1509 | - case R.id.file_dont_sync: |
1510 | - holder.star.performClick(); |
1511 | - break; |
1512 | - case R.id.file_publish: |
1513 | - publishFile(info.id); |
1514 | - break; |
1515 | - case R.id.file_copy_link: |
1516 | - copyPublicLink(info.id); |
1517 | - break; |
1518 | - case R.id.file_unpublish: |
1519 | - unpublishFile(info.id); |
1520 | - break; |
1521 | - default: |
1522 | - break; |
1523 | - } |
1524 | - return super.onContextItemSelected(item); |
1525 | + |
1526 | + mQuickActionBar.setOnQuickActionClickListener( |
1527 | + mOnFileQuickActionBarClickListener); |
1528 | + } |
1529 | + |
1530 | + mQuickActionBar.show(info.targetView); |
1531 | } |
1532 | |
1533 | private void copyPublicLink(final Long id) { |
1534 | @@ -506,8 +685,9 @@ |
1535 | |
1536 | private void publishFile(final Long id) { |
1537 | String volumeId = null, nodeId = null; |
1538 | - Cursor c = FilesDatabase.rawQuery("SELECT file_volume, file_node FROM files " + |
1539 | - "WHERE _id=?", new String[]{id.toString()}); |
1540 | + Cursor c = FilesDatabase.rawQuery( |
1541 | + "SELECT file_volume, file_node FROM files WHERE _id=?", |
1542 | + new String[]{id.toString()}); |
1543 | if (c.moveToFirst()) { |
1544 | volumeId = c.getString(c.getColumnIndex(Files.VOLUME)); |
1545 | nodeId = c.getString(c.getColumnIndex(Files.NODE)); |
1546 | @@ -521,6 +701,7 @@ |
1547 | Util.save2Clipboard(CustomListActivity.this, publicUrl); |
1548 | runOnUiThread(new Runnable() { |
1549 | public void run() { |
1550 | + mAdapter.getCursor().requery(); |
1551 | Toast.makeText(CustomListActivity.this, |
1552 | "Copied to clipboard", Toast.LENGTH_SHORT) |
1553 | .show(); |
1554 | @@ -540,8 +721,9 @@ |
1555 | |
1556 | private void unpublishFile(final Long id) { |
1557 | String volumeId = null, nodeId = null; |
1558 | - Cursor c = FilesDatabase.rawQuery("SELECT file_volume, file_node FROM files " + |
1559 | - "WHERE _id=?", new String[]{id.toString()}); |
1560 | + Cursor c = FilesDatabase.rawQuery( |
1561 | + "SELECT file_volume, file_node FROM files WHERE _id=?", |
1562 | + new String[]{id.toString()}); |
1563 | if (c.moveToFirst()) { |
1564 | volumeId = c.getString(c.getColumnIndex(Files.VOLUME)); |
1565 | nodeId = c.getString(c.getColumnIndex(Files.NODE)); |
1566 | @@ -551,9 +733,10 @@ |
1567 | nodeId, false).getDeferred(); |
1568 | d.addCallbacks(new Callback<String>() { |
1569 | public Object callback(String publicUrl) throws Exception { |
1570 | - FilesUtilities.setPublicUrl(id, ""); |
1571 | + FilesUtilities.setPublicUrl(id, null); |
1572 | runOnUiThread(new Runnable() { |
1573 | public void run() { |
1574 | + mAdapter.getCursor().requery(); |
1575 | Toast.makeText(CustomListActivity.this, "Unpublished", |
1576 | Toast.LENGTH_SHORT).show(); |
1577 | } |
1578 | @@ -573,10 +756,10 @@ |
1579 | @Override |
1580 | protected void onListItemClick(ListView l, View v, int position, long id) { |
1581 | super.onListItemClick(l, v, position, id); |
1582 | - Log.d(TAG, "onListItemClick"); |
1583 | try { |
1584 | if (FilesUtilities.isDirectory(id)) { |
1585 | mAdapter.cd(this, id); |
1586 | + mUploadItem.getItemView().setVisibility(View.VISIBLE); |
1587 | } else { |
1588 | openFile(id); |
1589 | } |
1590 | @@ -630,7 +813,8 @@ |
1591 | |
1592 | @Override |
1593 | protected void onPostExecute(Void result) { |
1594 | - mProgressDialog.dismiss(); |
1595 | + if (mProgressDialog != null && mProgressDialog.isShowing()) |
1596 | + mProgressDialog.dismiss(); |
1597 | if (!mResult) |
1598 | Util.showLongToast(CustomListActivity.this, |
1599 | "Uncheck the parent folder first."); |
1600 | @@ -645,27 +829,91 @@ |
1601 | if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { |
1602 | if (mAdapter.cd(this)) { |
1603 | // but it wasn't at root, so changed to directory up |
1604 | + if (mAdapter.getPathTool().isAtRoot() |
1605 | + && !VolumeType.ROOT.equals(mAdapter.getPathTool() |
1606 | + .getType())) { |
1607 | + hideUpload(); |
1608 | + } else { |
1609 | + // TODO Disable upload in case of no connection. |
1610 | + showUpload(); |
1611 | + } |
1612 | return true; |
1613 | } |
1614 | } |
1615 | return super.onKeyDown(keyCode, event); |
1616 | } |
1617 | |
1618 | - // Action bar stuff: |
1619 | - |
1620 | - public void setActionbarIndeterminateVisibility(int visibility) { |
1621 | - mActionbar.setActionbarIndeterminateVisibility(visibility); |
1622 | - } |
1623 | - |
1624 | - public void setActionbarSearchVisibility(int visibility) { |
1625 | - mActionbar.setActionbarSearchVisibility(visibility); |
1626 | - } |
1627 | - |
1628 | - public void setActionbarTitle(CharSequence title) { |
1629 | - mActionbar.setActionbarTitle(title); |
1630 | - } |
1631 | - |
1632 | - public void setActionbarUploadVisibility(int visibility) { |
1633 | - mActionbar.setActionbarUploadVisibility(visibility); |
1634 | - } |
1635 | + private void showProgress() { |
1636 | + mHandler.post(new Runnable() { |
1637 | + public void run() { |
1638 | + if (mLoaderItem != null) |
1639 | + mLoaderItem.setLoading(true); |
1640 | + } |
1641 | + }); |
1642 | + } |
1643 | + |
1644 | + private void hideProgress() { |
1645 | + mHandler.post(new Runnable() { |
1646 | + public void run() { |
1647 | + if (mLoaderItem != null) |
1648 | + mLoaderItem.setLoading(false); |
1649 | + } |
1650 | + }); |
1651 | + } |
1652 | + |
1653 | + private void maybeHideProgress() { |
1654 | + if (!UbuntuOneFiles.sSyncInProgress) |
1655 | + hideProgress(); |
1656 | + } |
1657 | + |
1658 | + private void showUpload() { |
1659 | + mHandler.post(new Runnable() { |
1660 | + public void run() { |
1661 | + if (mUploadItem != null) |
1662 | + mUploadItem.getItemView().setVisibility(View.VISIBLE); |
1663 | + } |
1664 | + }); |
1665 | + } |
1666 | + |
1667 | + private void hideUpload() { |
1668 | + mHandler.post(new Runnable() { |
1669 | + public void run() { |
1670 | + if (mUploadItem != null) |
1671 | + mUploadItem.getItemView().setVisibility(View.GONE); |
1672 | + } |
1673 | + }); |
1674 | + } |
1675 | + |
1676 | + private void awaitWithListEmptyTextView() { |
1677 | + mHandler.post(new Runnable() { |
1678 | + public void run() { |
1679 | + mEmptyTextView.setText(getString(R.string.please_wait)); |
1680 | + } |
1681 | + }); |
1682 | + } |
1683 | + |
1684 | + private void resetListEmptyTextView() { |
1685 | + mHandler.post(new Runnable() { |
1686 | + public void run() { |
1687 | + mEmptyTextView.setText(getText(R.string.no_items)); |
1688 | + } |
1689 | + }); |
1690 | + } |
1691 | + |
1692 | + private static class MyQuickAction extends QuickAction { |
1693 | + |
1694 | + private static final ColorFilter BLACK_CF = |
1695 | + new LightingColorFilter(Color.BLACK, Color.BLACK); |
1696 | + |
1697 | + public MyQuickAction(Context ctx, int drawableId, int titleId) { |
1698 | + super(ctx, buildDrawable(ctx, drawableId), titleId); |
1699 | + } |
1700 | + |
1701 | + private static Drawable buildDrawable(Context ctx, int drawableId) { |
1702 | + Drawable d = ctx.getResources().getDrawable(drawableId); |
1703 | + d.setColorFilter(BLACK_CF); |
1704 | + return d; |
1705 | + } |
1706 | + |
1707 | + } |
1708 | } |
1709 | |
1710 | === modified file 'src/com/ubuntuone/android/files/ui/DashboardActivity.java' |
1711 | --- src/com/ubuntuone/android/files/ui/DashboardActivity.java 2011-03-08 00:40:29 +0000 |
1712 | +++ src/com/ubuntuone/android/files/ui/DashboardActivity.java 2011-04-04 13:36:49 +0000 |
1713 | @@ -22,7 +22,11 @@ |
1714 | |
1715 | package com.ubuntuone.android.files.ui; |
1716 | |
1717 | -import android.app.Activity; |
1718 | +import greendroid.app.GDActivity; |
1719 | +import greendroid.widget.ActionBar; |
1720 | +import greendroid.widget.ActionBarItem; |
1721 | +import greendroid.widget.LoaderActionBarItem; |
1722 | +import greendroid.widget.ActionBarItem.Type; |
1723 | import android.app.AlertDialog; |
1724 | import android.app.Dialog; |
1725 | import android.content.DialogInterface; |
1726 | @@ -53,7 +57,7 @@ |
1727 | import com.ubuntuone.android.files.util.Util; |
1728 | import com.ubuntuone.android.util.log.Log; |
1729 | |
1730 | -public class DashboardActivity extends Activity implements IActionbar { |
1731 | +public class DashboardActivity extends GDActivity { |
1732 | |
1733 | private static final String TAG = DashboardActivity.class.getSimpleName(); |
1734 | |
1735 | @@ -61,7 +65,13 @@ |
1736 | |
1737 | private Handler mHandler; |
1738 | |
1739 | - private Actionbar mActionbar; |
1740 | + private LoaderActionBarItem mLoaderItem; |
1741 | + |
1742 | + |
1743 | + private static final int ACTION_BAR_SYNC = 0; |
1744 | + |
1745 | + private static final int ACTION_BAR_SETTINGS = 1; |
1746 | + |
1747 | |
1748 | /** Called when the activity is first created. */ |
1749 | @Override |
1750 | @@ -82,16 +92,12 @@ |
1751 | } |
1752 | |
1753 | setTheme(R.style.Theme_U1F); |
1754 | - setContentView(R.layout.activity_dashboard); |
1755 | - mActionbar = new Actionbar(this); |
1756 | - |
1757 | - // XXX Setup onClickListeners for backward compatibility? Now using XML. |
1758 | - Button filesButton = (Button) findViewById(R.id.home_btn_files); |
1759 | - filesButton.setOnClickListener(new OnClickListener() { |
1760 | - public void onClick(View v) { |
1761 | - onFilesClick(v); |
1762 | - } |
1763 | - }); |
1764 | + setActionBarContentView(R.layout.activity_dashboard); |
1765 | + mLoaderItem = (LoaderActionBarItem) addActionBarItem(getActionBar() |
1766 | + .newActionBarItem(LoaderActionBarItem.class) |
1767 | + .setDrawable(R.drawable.gd_action_bar_refresh), |
1768 | + ActionBar.NONE); |
1769 | + addActionBarItem(Type.Settings); |
1770 | } |
1771 | |
1772 | private class DashboardHandlerCallback implements Handler.Callback { |
1773 | @@ -111,20 +117,18 @@ |
1774 | dismissDialog(DIALOG_INIT); |
1775 | break; |
1776 | case R.string.QM_WORKING: |
1777 | - mActionbar.showActionbarIndeterminate(); |
1778 | + showProgress(); |
1779 | break; |
1780 | case R.string.QM_IDLE: |
1781 | - if (!UbuntuOneFiles.sSyncInProgress) |
1782 | - mActionbar.hideActionbarIndeterminate(); |
1783 | + maybeHideProgress(); |
1784 | break; |
1785 | case R.string.SYS_SYNCING: |
1786 | - mActionbar.showActionbarIndeterminate(); |
1787 | + showProgress(); |
1788 | break; |
1789 | case R.string.SYS_SYNC_ERROR: |
1790 | + //$FALL-THROUGH$ |
1791 | case R.string.SYS_SYNCED: |
1792 | - // this hide() can cause problems before we move sync to AQ |
1793 | - if (!UbuntuOneFiles.isQueueWorking()) |
1794 | - mActionbar.hideActionbarIndeterminate(); |
1795 | + maybeHideProgress(); |
1796 | break; |
1797 | default: |
1798 | break; |
1799 | @@ -134,7 +138,25 @@ |
1800 | |
1801 | } |
1802 | |
1803 | - private int mInForeground = -1; |
1804 | + @Override |
1805 | + public boolean onHandleActionBarItemClick(ActionBarItem item, int position) { |
1806 | + switch (position) { |
1807 | + case ACTION_BAR_SYNC: |
1808 | + mEventQueue.push(Message.obtain(null, R.string.CMD_SYNC)); |
1809 | + break; |
1810 | + case ACTION_BAR_SETTINGS: |
1811 | + Intent intent = new Intent(this, Preferences.class); |
1812 | + startActivity(intent); |
1813 | + break; |
1814 | + |
1815 | + default: |
1816 | + Log.w(TAG, "unknown dashboard quick action"); |
1817 | + break; |
1818 | + } |
1819 | + return super.onHandleActionBarItemClick(item, position); |
1820 | + } |
1821 | + |
1822 | + private int mInForegroundToken = -1; |
1823 | |
1824 | @Override |
1825 | protected void onStart() { |
1826 | @@ -143,7 +165,7 @@ |
1827 | && UbuntuOneFiles.hasValidTokens()) { |
1828 | Toast.makeText(this, "Working off-line", Toast.LENGTH_LONG).show(); |
1829 | } |
1830 | - mInForeground = UbuntuOneFiles.setForegroundActivity(this); |
1831 | + mInForegroundToken = UbuntuOneFiles.setForegroundActivity(this); |
1832 | mEventQueue.subscribe(mHandler); |
1833 | |
1834 | handleAnyCrash(); |
1835 | @@ -161,17 +183,17 @@ |
1836 | } |
1837 | |
1838 | if (UbuntuOneFiles.isQueueWorking() || UbuntuOneFiles.sSyncInProgress) { |
1839 | - mActionbar.showActionbarIndeterminate(); |
1840 | + showProgress(); |
1841 | } else { |
1842 | if (!UbuntuOneFiles.sSyncInProgress) |
1843 | - mActionbar.hideActionbarIndeterminate(); |
1844 | + hideProgress(); |
1845 | } |
1846 | } |
1847 | |
1848 | @Override |
1849 | protected void onStop() { |
1850 | mEventQueue.unsubscribe(mHandler); |
1851 | - UbuntuOneFiles.clearForegroundActivity(mInForeground); |
1852 | + UbuntuOneFiles.clearForegroundActivity(mInForegroundToken); |
1853 | super.onStop(); |
1854 | } |
1855 | |
1856 | @@ -269,7 +291,7 @@ |
1857 | Log.submitLogs(DashboardActivity.this); |
1858 | } |
1859 | dialog.dismiss(); |
1860 | - Preferences.setCrashFlag(false); |
1861 | + Preferences.setOopsFlag(false); |
1862 | } |
1863 | }; |
1864 | |
1865 | @@ -328,8 +350,8 @@ |
1866 | |
1867 | if (!tokensAvailable) { |
1868 | // Load login UI. |
1869 | - setContentView(R.layout.activity_login); |
1870 | - mActionbar = new Actionbar(this); |
1871 | + setActionBarContentView(R.layout.activity_login); |
1872 | + |
1873 | Button loginButton = (Button) findViewById(R.id.loginButton); |
1874 | |
1875 | boolean isNetworkAvailable = ConfigUtilities.isNetworkAvailable(this); |
1876 | @@ -353,7 +375,7 @@ |
1877 | } |
1878 | |
1879 | v.setEnabled(false); |
1880 | - setActionbarIndeterminateVisibility(View.VISIBLE); |
1881 | + showProgress(); |
1882 | Toast.makeText(DashboardActivity.this, "Launching browser", |
1883 | Toast.LENGTH_LONG).show(); |
1884 | |
1885 | @@ -392,20 +414,28 @@ |
1886 | } |
1887 | return super.onKeyDown(keyCode, event); |
1888 | } |
1889 | - |
1890 | - public void setActionbarIndeterminateVisibility(int visibility) { |
1891 | - mActionbar.setActionbarIndeterminateVisibility(visibility); |
1892 | - } |
1893 | - |
1894 | - public void setActionbarSearchVisibility(int visibility) { |
1895 | - mActionbar.setActionbarSearchVisibility(visibility); |
1896 | - } |
1897 | - |
1898 | - public void setActionbarTitle(CharSequence title) { |
1899 | - mActionbar.setActionbarTitle(title); |
1900 | - } |
1901 | - |
1902 | - public void setActionbarUploadVisibility(int visibility) { |
1903 | - mActionbar.setActionbarUploadVisibility(visibility); |
1904 | - } |
1905 | + |
1906 | + private void showProgress() { |
1907 | + mHandler.post(new Runnable() { |
1908 | + public void run() { |
1909 | + if (mLoaderItem != null) |
1910 | + mLoaderItem.setLoading(true); |
1911 | + } |
1912 | + }); |
1913 | + } |
1914 | + |
1915 | + private void hideProgress() { |
1916 | + mHandler.post(new Runnable() { |
1917 | + public void run() { |
1918 | + if (mLoaderItem != null) |
1919 | + mLoaderItem.setLoading(false); |
1920 | + } |
1921 | + }); |
1922 | + } |
1923 | + |
1924 | + private void maybeHideProgress() { |
1925 | + if (!UbuntuOneFiles.sSyncInProgress) |
1926 | + hideProgress(); |
1927 | + } |
1928 | + |
1929 | } |
1930 | \ No newline at end of file |
1931 | |
1932 | === modified file 'src/com/ubuntuone/android/files/ui/FilesActivity.java' |
1933 | --- src/com/ubuntuone/android/files/ui/FilesActivity.java 2011-01-29 16:22:20 +0000 |
1934 | +++ src/com/ubuntuone/android/files/ui/FilesActivity.java 2011-04-04 13:36:49 +0000 |
1935 | @@ -23,9 +23,7 @@ |
1936 | package com.ubuntuone.android.files.ui; |
1937 | |
1938 | import android.os.Bundle; |
1939 | -import android.view.View; |
1940 | |
1941 | -import com.ubuntuone.android.files.R; |
1942 | import com.ubuntuone.android.files.util.CustomListActivityAdapter; |
1943 | import com.ubuntuone.storageprotocol.StorageProtocol.Volumes.VolumeType; |
1944 | |
1945 | @@ -34,14 +32,9 @@ |
1946 | @Override |
1947 | protected void onCreate(Bundle savedInstanceState) { |
1948 | super.onCreate(savedInstanceState); |
1949 | - setActionbarUploadVisibility(View.GONE); |
1950 | + // TODO karni AB: setActionbarUploadVisibility(View.GONE); |
1951 | setListAdapter(CustomListActivityAdapter.buildAdapter( |
1952 | this, VolumeType.ROOT)); |
1953 | } |
1954 | - |
1955 | - @Override |
1956 | - protected CharSequence getActionBarTitle() { |
1957 | - return getResources().getText(R.string.title_files); |
1958 | - } |
1959 | |
1960 | } |
1961 | |
1962 | === modified file 'src/com/ubuntuone/android/files/ui/SharesActivity.java' |
1963 | --- src/com/ubuntuone/android/files/ui/SharesActivity.java 2011-01-29 16:22:20 +0000 |
1964 | +++ src/com/ubuntuone/android/files/ui/SharesActivity.java 2011-04-04 13:36:49 +0000 |
1965 | @@ -23,9 +23,7 @@ |
1966 | package com.ubuntuone.android.files.ui; |
1967 | |
1968 | import android.os.Bundle; |
1969 | -import android.view.View; |
1970 | |
1971 | -import com.ubuntuone.android.files.R; |
1972 | import com.ubuntuone.android.files.util.CustomListActivityAdapter; |
1973 | import com.ubuntuone.storageprotocol.StorageProtocol.Volumes.VolumeType; |
1974 | |
1975 | @@ -34,15 +32,8 @@ |
1976 | @Override |
1977 | protected void onCreate(Bundle savedInstanceState) { |
1978 | super.onCreate(savedInstanceState); |
1979 | - // At top level, upload button invisible. |
1980 | - setActionbarUploadVisibility(View.GONE); |
1981 | setListAdapter(CustomListActivityAdapter.buildAdapter( |
1982 | this, VolumeType.SHARE)); |
1983 | } |
1984 | - |
1985 | - @Override |
1986 | - protected CharSequence getActionBarTitle() { |
1987 | - return getResources().getText(R.string.title_shares); |
1988 | - } |
1989 | |
1990 | } |
1991 | |
1992 | === modified file 'src/com/ubuntuone/android/files/ui/StatusActivity.java' |
1993 | --- src/com/ubuntuone/android/files/ui/StatusActivity.java 2011-02-21 01:32:08 +0000 |
1994 | +++ src/com/ubuntuone/android/files/ui/StatusActivity.java 2011-04-04 13:36:49 +0000 |
1995 | @@ -22,12 +22,16 @@ |
1996 | |
1997 | package com.ubuntuone.android.files.ui; |
1998 | |
1999 | +import greendroid.app.GDActivity; |
2000 | +import greendroid.widget.ActionBar; |
2001 | +import greendroid.widget.LoaderActionBarItem; |
2002 | + |
2003 | import java.util.ArrayList; |
2004 | import java.util.HashMap; |
2005 | |
2006 | -import android.app.Activity; |
2007 | import android.os.AsyncTask; |
2008 | import android.os.Bundle; |
2009 | +import android.os.Handler; |
2010 | import android.view.View; |
2011 | import android.widget.ListView; |
2012 | import android.widget.Toast; |
2013 | @@ -39,9 +43,11 @@ |
2014 | import com.ubuntuone.android.files.util.ServicesStatus.ServiceNames; |
2015 | import com.ubuntuone.android.files.util.ServicesStatus.ServiceTags; |
2016 | |
2017 | -public class StatusActivity extends Activity implements IActionbar { |
2018 | - |
2019 | - private Actionbar mActionbar; |
2020 | +public class StatusActivity extends GDActivity { |
2021 | + |
2022 | + private Handler mHandler; |
2023 | + |
2024 | + private LoaderActionBarItem mLoaderItem; |
2025 | |
2026 | private ListView listView; |
2027 | |
2028 | @@ -56,8 +62,13 @@ |
2029 | @Override |
2030 | protected void onCreate(Bundle savedInstanceState) { |
2031 | super.onCreate(savedInstanceState); |
2032 | - setContentView(R.layout.activity_status); |
2033 | - mActionbar = new Actionbar(this); |
2034 | + setActionBarContentView(R.layout.activity_status); |
2035 | + mLoaderItem = (LoaderActionBarItem) addActionBarItem(getActionBar() |
2036 | + .newActionBarItem(LoaderActionBarItem.class) |
2037 | + .setDrawable(R.drawable.gd_action_bar_refresh), |
2038 | + ActionBar.NONE); |
2039 | + |
2040 | + mHandler = new Handler(); |
2041 | |
2042 | services = new ArrayList<ServicesStatus.ServiceStatusRecord>(); |
2043 | listView = (ListView)findViewById(R.id.service_list); |
2044 | @@ -104,7 +115,7 @@ |
2045 | super.onPreExecute(); |
2046 | Toast.makeText(StatusActivity.this, "Refreshing", |
2047 | Toast.LENGTH_SHORT).show(); |
2048 | - setActionbarIndeterminateVisibility(View.VISIBLE); |
2049 | + showProgress(); |
2050 | } |
2051 | |
2052 | @Override |
2053 | @@ -123,7 +134,7 @@ |
2054 | @Override |
2055 | protected void onPostExecute(HashMap<String, Integer> result) { |
2056 | super.onPostExecute(result); |
2057 | - setActionbarIndeterminateVisibility(View.INVISIBLE); |
2058 | + hideProgress(); |
2059 | if (exceptionMsg != null) { |
2060 | Toast.makeText(StatusActivity.this, exceptionMsg, |
2061 | Toast.LENGTH_SHORT).show(); |
2062 | @@ -194,20 +205,22 @@ |
2063 | |
2064 | }; |
2065 | |
2066 | - public void setActionbarIndeterminateVisibility(int visibility) { |
2067 | - mActionbar.setActionbarIndeterminateVisibility(visibility); |
2068 | - } |
2069 | - |
2070 | - public void setActionbarSearchVisibility(int visibility) { |
2071 | - mActionbar.setActionbarSearchVisibility(visibility); |
2072 | - } |
2073 | - |
2074 | - public void setActionbarTitle(CharSequence title) { |
2075 | - mActionbar.setActionbarTitle(title); |
2076 | - } |
2077 | - |
2078 | - public void setActionbarUploadVisibility(int visibility) { |
2079 | - mActionbar.setActionbarUploadVisibility(visibility); |
2080 | - } |
2081 | + private void showProgress() { |
2082 | + mHandler.post(new Runnable() { |
2083 | + public void run() { |
2084 | + if (mLoaderItem != null) |
2085 | + mLoaderItem.setLoading(true); |
2086 | + } |
2087 | + }); |
2088 | + } |
2089 | + |
2090 | + private void hideProgress() { |
2091 | + mHandler.post(new Runnable() { |
2092 | + public void run() { |
2093 | + if (mLoaderItem != null) |
2094 | + mLoaderItem.setLoading(false); |
2095 | + } |
2096 | + }); |
2097 | + } |
2098 | |
2099 | } |
2100 | |
2101 | === modified file 'src/com/ubuntuone/android/files/ui/UdfsActivity.java' |
2102 | --- src/com/ubuntuone/android/files/ui/UdfsActivity.java 2011-01-29 16:22:20 +0000 |
2103 | +++ src/com/ubuntuone/android/files/ui/UdfsActivity.java 2011-04-04 13:36:49 +0000 |
2104 | @@ -23,9 +23,7 @@ |
2105 | package com.ubuntuone.android.files.ui; |
2106 | |
2107 | import android.os.Bundle; |
2108 | -import android.view.View; |
2109 | |
2110 | -import com.ubuntuone.android.files.R; |
2111 | import com.ubuntuone.android.files.util.CustomListActivityAdapter; |
2112 | import com.ubuntuone.storageprotocol.StorageProtocol.Volumes.VolumeType; |
2113 | |
2114 | @@ -34,15 +32,8 @@ |
2115 | @Override |
2116 | protected void onCreate(Bundle savedInstanceState) { |
2117 | super.onCreate(savedInstanceState); |
2118 | - // At top level, upload button invisible. |
2119 | - setActionbarUploadVisibility(View.GONE); |
2120 | setListAdapter(CustomListActivityAdapter.buildAdapter( |
2121 | this, VolumeType.UDF)); |
2122 | } |
2123 | - |
2124 | - @Override |
2125 | - protected CharSequence getActionBarTitle() { |
2126 | - return getResources().getText(R.string.title_udfs); |
2127 | - } |
2128 | |
2129 | } |
2130 | |
2131 | === modified file 'src/com/ubuntuone/android/files/util/ConfigUtilities.java' |
2132 | --- src/com/ubuntuone/android/files/util/ConfigUtilities.java 2011-03-11 00:21:09 +0000 |
2133 | +++ src/com/ubuntuone/android/files/util/ConfigUtilities.java 2011-04-04 13:36:49 +0000 |
2134 | @@ -97,12 +97,18 @@ |
2135 | .isBackgroundDataAllowed(ctx); |
2136 | |
2137 | if (!wifiConnected && !mobileConnected) { |
2138 | + Log.i(TAG, "can not sync, no network"); |
2139 | return CanISync.NO_NETWORK; |
2140 | } |
2141 | |
2142 | + if (!syncInBackground) { |
2143 | + Log.i(TAG, "can not sync, background data disabled"); |
2144 | + return CanISync.NO_BACKGROUND; |
2145 | + } |
2146 | + |
2147 | int preferredNetwork = -1; |
2148 | |
2149 | - if (mobileConnected && syncOnMobile && !isRoaming) |
2150 | + if (mobileConnected && syncOnMobile) |
2151 | preferredNetwork = ConnectivityManager.TYPE_MOBILE; |
2152 | |
2153 | // Prever wifi over mobile. |
2154 | @@ -114,15 +120,13 @@ |
2155 | return CanISync.NO_PREFERRED; |
2156 | } |
2157 | |
2158 | + if (preferredNetwork == ConnectivityManager.TYPE_MOBILE && isRoaming) { |
2159 | + Log.i(TAG, "can not sync, roaming!"); |
2160 | + return CanISync.ROAMING; |
2161 | + } |
2162 | + |
2163 | // We are connected and can sync on preferredNetwork. |
2164 | |
2165 | - if (!syncInBackground) { |
2166 | - Log.i(TAG, "can not sync, background data disabled"); |
2167 | - return CanISync.NO_BACKGROUND; |
2168 | - } |
2169 | - |
2170 | - // Background data is on, so we're safe to continue. |
2171 | - |
2172 | return CanISync.CAN_SYNC; |
2173 | } |
2174 | |
2175 | |
2176 | === modified file 'src/com/ubuntuone/android/files/util/CustomListActivityAdapter.java' |
2177 | --- src/com/ubuntuone/android/files/util/CustomListActivityAdapter.java 2011-03-25 10:22:25 +0000 |
2178 | +++ src/com/ubuntuone/android/files/util/CustomListActivityAdapter.java 2011-04-04 13:36:49 +0000 |
2179 | @@ -59,8 +59,6 @@ |
2180 | |
2181 | private LayoutInflater mInflater; |
2182 | |
2183 | - private static String[] sFilesDefaultProjection; |
2184 | - |
2185 | |
2186 | private static int sRemoteFileBackgroundColor; |
2187 | |
2188 | @@ -95,6 +93,13 @@ |
2189 | holder.icon.setImageResource(R.drawable.file); |
2190 | } |
2191 | |
2192 | + final String url = cursor.getString(cursor.getColumnIndex(Files.URL)); |
2193 | + final boolean isPublished = !(url == null || "".equals(url)); |
2194 | + int filenameColor = isPublished |
2195 | + ? context.getResources().getColor(R.color.file_published_text_fg) |
2196 | + : context.getResources().getColor(R.color.file_text_fg); |
2197 | + holder.filename.setTextColor(filenameColor); |
2198 | + |
2199 | // Filename. |
2200 | final String filename = cursor.getString(cursor.getColumnIndex(Files.NAME)); |
2201 | holder.filename.setText(filename); |
2202 | @@ -227,10 +232,8 @@ |
2203 | public static CustomListActivityAdapter buildAdapter( |
2204 | final Context context, VolumeType type) { |
2205 | Resources r = context.getResources(); |
2206 | - sRemoteFileBackgroundColor = r.getColor(R.color.remote_file_background); |
2207 | + sRemoteFileBackgroundColor = r.getColor(R.color.remote_file_bg); |
2208 | |
2209 | - if (sFilesDefaultProjection == null) |
2210 | - sFilesDefaultProjection = Files.getDefaultProjection(); |
2211 | if (VolumeType.ROOT.equals(type)) { |
2212 | Log.d(TAG, "building ROOT CustomListActivityAdapter"); |
2213 | // Files cursor pointing at the nodes being *content* of Root |
2214 | |
2215 | === modified file 'src/com/ubuntuone/android/files/util/MediaUtilities.java' |
2216 | --- src/com/ubuntuone/android/files/util/MediaUtilities.java 2011-02-25 10:35:51 +0000 |
2217 | +++ src/com/ubuntuone/android/files/util/MediaUtilities.java 2011-04-04 13:36:49 +0000 |
2218 | @@ -43,6 +43,7 @@ |
2219 | return count; |
2220 | } |
2221 | |
2222 | + @SuppressWarnings("unused") |
2223 | private void uploadImages(Context context, EventQueue eventQueue, long since) { |
2224 | uploadMedia(context, eventQueue, since, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); |
2225 | } |
2226 | |
2227 | === modified file 'src/com/ubuntuone/android/files/util/SeekbarPreference.java' |
2228 | --- src/com/ubuntuone/android/files/util/SeekbarPreference.java 2011-03-01 19:36:58 +0000 |
2229 | +++ src/com/ubuntuone/android/files/util/SeekbarPreference.java 2011-04-04 13:36:49 +0000 |
2230 | @@ -8,8 +8,6 @@ |
2231 | import android.widget.SeekBar; |
2232 | import android.widget.SeekBar.OnSeekBarChangeListener; |
2233 | |
2234 | -import com.ubuntuone.android.files.R; |
2235 | - |
2236 | public class SeekbarPreference extends Preference implements |
2237 | OnSeekBarChangeListener { |
2238 | |
2239 | |
2240 | === modified file 'src/com/ubuntuone/android/storageprotocol/request/RequestHandler.java' |
2241 | --- src/com/ubuntuone/android/storageprotocol/request/RequestHandler.java 2011-02-05 19:09:58 +0000 |
2242 | +++ src/com/ubuntuone/android/storageprotocol/request/RequestHandler.java 2011-04-04 13:36:49 +0000 |
2243 | @@ -158,6 +158,7 @@ |
2244 | requests.remove(id); |
2245 | } |
2246 | |
2247 | + @SuppressWarnings("unchecked") |
2248 | public void registerProducer(Callable producer) { |
2249 | this.executor.schedule(producer, 0, TimeUnit.SECONDS); |
2250 | } |
2251 | |
2252 | === modified file 'src/com/ubuntuone/android/util/log/ILog.java' |
2253 | --- src/com/ubuntuone/android/util/log/ILog.java 2010-12-27 14:48:13 +0000 |
2254 | +++ src/com/ubuntuone/android/util/log/ILog.java 2011-04-04 13:36:49 +0000 |
2255 | @@ -27,7 +27,6 @@ |
2256 | public interface ILog { |
2257 | |
2258 | public void init(Context ctx, String... args); |
2259 | - public void register(); |
2260 | public void shutdown(); |
2261 | public void e(final String tag, final String msg); |
2262 | public void e(final String tag, final String msg, final Throwable tr); |
2263 | |
2264 | === modified file 'src/com/ubuntuone/android/util/log/Log.java' |
2265 | --- src/com/ubuntuone/android/util/log/Log.java 2011-02-21 12:49:15 +0000 |
2266 | +++ src/com/ubuntuone/android/util/log/Log.java 2011-04-04 13:36:49 +0000 |
2267 | @@ -25,7 +25,6 @@ |
2268 | import java.io.File; |
2269 | import java.io.FilenameFilter; |
2270 | import java.io.PrintStream; |
2271 | -import java.lang.Thread.UncaughtExceptionHandler; |
2272 | |
2273 | import android.content.Context; |
2274 | import android.content.Intent; |
2275 | @@ -90,10 +89,6 @@ |
2276 | } |
2277 | } |
2278 | |
2279 | - public static void register() { |
2280 | - sLogger.register(); |
2281 | - } |
2282 | - |
2283 | /** |
2284 | * This should be called and the end of Log usage, to properly shut it down. |
2285 | */ |
2286 | @@ -150,8 +145,7 @@ |
2287 | * |
2288 | * It will strip any DEBUG or VERBOSE messages. |
2289 | */ |
2290 | - public static class ProductionLogger |
2291 | - implements ILog, UncaughtExceptionHandler { |
2292 | + public static class ProductionLogger implements ILog { |
2293 | |
2294 | public static final boolean LOGE = |
2295 | android.util.Log.isLoggable(APP_TAG, android.util.Log.ERROR); |
2296 | @@ -160,20 +154,13 @@ |
2297 | public static final boolean LOGI = |
2298 | android.util.Log.isLoggable(APP_TAG, android.util.Log.INFO); |
2299 | |
2300 | - private static UncaughtExceptionHandler uncaughtExceptionHandler; |
2301 | - |
2302 | public void init(Context ctx, String... args) { |
2303 | android.util.Log.i(TAG, "initializing " + |
2304 | this.getClass().getSimpleName()); |
2305 | - uncaughtExceptionHandler = this; |
2306 | - } |
2307 | - |
2308 | - public void register() { |
2309 | - Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler); |
2310 | } |
2311 | |
2312 | public void uncaughtException(Thread thread, Throwable ex) { |
2313 | - e(APP_TAG, "uncaught exception!", ex); |
2314 | + e(APP_TAG, "uncaught exception!!!", ex); |
2315 | } |
2316 | |
2317 | public void shutdown() { |
2318 | @@ -234,8 +221,7 @@ |
2319 | * |
2320 | * It uses static finals to make use of compile time optimization. |
2321 | */ |
2322 | - public static class DebugLogger |
2323 | - implements ILog, UncaughtExceptionHandler { |
2324 | + public static class DebugLogger implements ILog { |
2325 | |
2326 | private static PrintStream sOutput; |
2327 | |
2328 | @@ -245,14 +231,9 @@ |
2329 | public static final boolean LOGD = true; |
2330 | public static final boolean LOGV = true; |
2331 | |
2332 | - private static UncaughtExceptionHandler uncaughtExceptionHandler; |
2333 | - |
2334 | public void init(Context ctx, String... args) { |
2335 | android.util.Log.i(TAG, "initializing " + |
2336 | this.getClass().getSimpleName()); |
2337 | - uncaughtExceptionHandler = this; |
2338 | -// String logsPath = ctx.getFilesDir().getAbsolutePath() |
2339 | -// .concat(LOG_DIR); |
2340 | |
2341 | String dataDir = "/sdcard/Android/data"; |
2342 | android.util.Log.d(TAG, "data dir: " + dataDir); |
2343 | @@ -268,15 +249,7 @@ |
2344 | sOutput = new PrintStream(fout); |
2345 | } catch (Exception e) { |
2346 | android.util.Log.e(TAG, e.getMessage()); |
2347 | - } |
2348 | - } |
2349 | - |
2350 | - public void register() { |
2351 | - Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler); |
2352 | - } |
2353 | - |
2354 | - public void uncaughtException(Thread thread, Throwable ex) { |
2355 | - e(APP_TAG, "uncaught exception!", ex); |
2356 | + } |
2357 | } |
2358 | |
2359 | public void shutdown() { |
2360 | @@ -394,7 +367,7 @@ |
2361 | // Unused. |
2362 | } |
2363 | |
2364 | - private static final String EMAIL_TARGET = "mkarnicki@gmail.com"; |
2365 | + private static final String EMAIL_TARGET = "michal.karnicki@canonical.com"; |
2366 | |
2367 | private static final String EMAIL_SUBJECT = "U1F logs"; |
2368 | |
2369 | @@ -472,7 +445,7 @@ |
2370 | deleteLogs(ctx, true); |
2371 | } |
2372 | |
2373 | - final static long KB_500 = 1024*1024; |
2374 | + final static long MAX_LOG_BYTES = 1024*1024; |
2375 | |
2376 | public static final void deleteLogs(Context ctx, boolean force) { |
2377 | |
2378 | @@ -494,7 +467,7 @@ |
2379 | for (File file : logFiles) |
2380 | size += file.length(); |
2381 | |
2382 | - if (size > KB_500) { |
2383 | + if (size > MAX_LOG_BYTES) { |
2384 | for (File file : logFiles) |
2385 | file.delete(); |
2386 | } |