Simple Notepad Application for Android OS
Revisión | 91d9ea4f4f7c493fff5661f38b8fa551c3f82358 (tree) |
---|---|
Tiempo | 2016-05-03 16:44:28 |
Autor | Masahiko, SAWAI <say@user...> |
Commiter | Masahiko, SAWAI |
Added copy to clipboard function
@@ -6,7 +6,7 @@ | ||
6 | 6 | android:versionName="1.0.8" |
7 | 7 | android:installLocation="auto" |
8 | 8 | > |
9 | - <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="11" /> | |
9 | + <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="23" /> | |
10 | 10 | |
11 | 11 | <uses-feature android:name="android.hardware.touchscreen" android:required="false" /> |
12 | 12 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
@@ -20,9 +20,9 @@ | ||
20 | 20 | <dependencies> |
21 | 21 | |
22 | 22 | <dependency> |
23 | - <groupId>android</groupId> | |
23 | + <groupId>com.google.android</groupId> | |
24 | 24 | <artifactId>android</artifactId> |
25 | - <version>3.0_r2</version> | |
25 | + <version>4.1.1.4</version> | |
26 | 26 | <!-- |
27 | 27 | <version>1.5_r3</version> |
28 | 28 | <version>1.5_r4</version> |
@@ -60,7 +60,7 @@ | ||
60 | 60 | <sdk> |
61 | 61 | <path>${env.ANDROID_HOME}</path> |
62 | 62 | <!-- <path>C:/Java/android-sdk</path> --> |
63 | - <platform>11</platform> | |
63 | + <platform>23</platform> | |
64 | 64 | </sdk> |
65 | 65 | <release>false</release> |
66 | 66 | <proguard> |
@@ -21,4 +21,16 @@ | ||
21 | 21 | android:numericShortcut="3" |
22 | 22 | android:alphabeticShortcut="s" |
23 | 23 | /> |
24 | + <item | |
25 | + android:id="@+id/copy_note_title_menuitem" | |
26 | + android:title="@string/copy_note_title" | |
27 | + android:numericShortcut="4" | |
28 | + android:alphabeticShortcut="t" | |
29 | + /> | |
30 | + <item | |
31 | + android:id="@+id/copy_note_content_menuitem" | |
32 | + android:title="@string/copy_note_content" | |
33 | + android:numericShortcut="5" | |
34 | + android:alphabeticShortcut="c" | |
35 | + /> | |
24 | 36 | </menu> |
\ No newline at end of file |
@@ -4,7 +4,7 @@ | ||
4 | 4 | android:id="@+id/copy_note_title_menuitem" |
5 | 5 | android:title="@string/copy_note_title" |
6 | 6 | android:numericShortcut="1" |
7 | - android:alphabeticShortcut="c" | |
7 | + android:alphabeticShortcut="t" | |
8 | 8 | /> |
9 | 9 | <item |
10 | 10 | android:id="@+id/edit_note_menuitem" |
@@ -60,6 +60,8 @@ | ||
60 | 60 | |
61 | 61 | <string name="copy_note_title">タイトルをコピー</string> |
62 | 62 | <string name="copy_note_content">本文をコピー</string> |
63 | + <string name="copy_note_title_done">タイトルをコピーしました。</string> | |
64 | + <string name="copy_note_content_done">本文をコピーしました。</string> | |
63 | 65 | |
64 | 66 | <string name="templates">テンプレート</string> |
65 | 67 | <string name="add_new_note_template">追加</string> |
@@ -60,6 +60,8 @@ | ||
60 | 60 | |
61 | 61 | <string name="copy_note_title">Copy Title</string> |
62 | 62 | <string name="copy_note_content">Copy Text</string> |
63 | + <string name="copy_note_title_done">The title has copied.</string> | |
64 | + <string name="copy_note_content_done">The text has copied.</string> | |
63 | 65 | |
64 | 66 | <string name="templates">Templates</string> |
65 | 67 | <string name="add_new_note_template">Add</string> |
@@ -45,6 +45,7 @@ import android.view.ViewGroup; | ||
45 | 45 | import android.widget.AbsListView; |
46 | 46 | import android.widget.AdapterView.AdapterContextMenuInfo; |
47 | 47 | import android.widget.ListView; |
48 | +import android.widget.Toast; | |
48 | 49 | import java.util.Arrays; |
49 | 50 | import org.routine_work.notepad.R; |
50 | 51 | import org.routine_work.notepad.prefs.NotepadPreferenceUtils; |
@@ -54,37 +55,32 @@ import org.routine_work.notepad.utils.NotepadConstants; | ||
54 | 55 | import org.routine_work.utils.Log; |
55 | 56 | |
56 | 57 | public class NoteListFragment extends ListFragment |
57 | - implements NotepadConstants, | |
58 | - LoaderManager.LoaderCallbacks<Cursor>, | |
59 | - AbsListView.MultiChoiceModeListener | |
60 | -{ | |
58 | + implements NotepadConstants, | |
59 | + LoaderManager.LoaderCallbacks<Cursor>, | |
60 | + AbsListView.MultiChoiceModeListener { | |
61 | 61 | |
62 | 62 | private static final String LOG_TAG = "simple-notepad"; |
63 | 63 | private NoteCursorAdapter listAdapter; |
64 | 64 | private Uri contentUri; |
65 | 65 | private NoteControlCallback noteControlCallback; |
66 | 66 | |
67 | - public NoteListFragment() | |
68 | - { | |
67 | + public NoteListFragment() { | |
69 | 68 | this.contentUri = NoteStore.Note.CONTENT_URI; |
70 | 69 | } |
71 | 70 | |
72 | 71 | @Override |
73 | - public void onAttach(Activity activity) | |
74 | - { | |
72 | + public void onAttach(Activity activity) { | |
75 | 73 | Log.v(LOG_TAG, "Hello"); |
76 | 74 | super.onAttach(activity); |
77 | 75 | |
78 | - if (activity instanceof NoteControlCallback) | |
79 | - { | |
76 | + if (activity instanceof NoteControlCallback) { | |
80 | 77 | noteControlCallback = (NoteControlCallback) activity; |
81 | 78 | } |
82 | 79 | Log.v(LOG_TAG, "Bye"); |
83 | 80 | } |
84 | 81 | |
85 | 82 | @Override |
86 | - public void onCreate(Bundle savedInstanceState) | |
87 | - { | |
83 | + public void onCreate(Bundle savedInstanceState) { | |
88 | 84 | Log.v(LOG_TAG, "Hello"); |
89 | 85 | |
90 | 86 | super.onCreate(savedInstanceState); |
@@ -95,8 +91,7 @@ public class NoteListFragment extends ListFragment | ||
95 | 91 | |
96 | 92 | @Override |
97 | 93 | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
98 | - Bundle savedInstanceState) | |
99 | - { | |
94 | + Bundle savedInstanceState) { | |
100 | 95 | Log.v(LOG_TAG, "Hello"); |
101 | 96 | |
102 | 97 | View v = inflater.inflate(R.layout.note_list_fragment, container, false); |
@@ -106,8 +101,7 @@ public class NoteListFragment extends ListFragment | ||
106 | 101 | } |
107 | 102 | |
108 | 103 | @Override |
109 | - public void onActivityCreated(Bundle savedInstanceState) | |
110 | - { | |
104 | + public void onActivityCreated(Bundle savedInstanceState) { | |
111 | 105 | Log.v(LOG_TAG, "Hello"); |
112 | 106 | super.onActivityCreated(savedInstanceState); |
113 | 107 |
@@ -127,8 +121,7 @@ public class NoteListFragment extends ListFragment | ||
127 | 121 | } |
128 | 122 | |
129 | 123 | @Override |
130 | - public void onDestroy() | |
131 | - { | |
124 | + public void onDestroy() { | |
132 | 125 | Log.v(LOG_TAG, "Hello"); |
133 | 126 | |
134 | 127 | super.onDestroy(); |
@@ -138,13 +131,11 @@ public class NoteListFragment extends ListFragment | ||
138 | 131 | |
139 | 132 | @Override |
140 | 133 | public void onCreateContextMenu(ContextMenu menu, View v, |
141 | - ContextMenuInfo menuInfo) | |
142 | - { | |
134 | + ContextMenuInfo menuInfo) { | |
143 | 135 | Log.v(LOG_TAG, "Hello"); |
144 | 136 | |
145 | 137 | super.onCreateContextMenu(menu, v, menuInfo); |
146 | - if (v == getListView()) | |
147 | - { | |
138 | + if (v == getListView()) { | |
148 | 139 | MenuInflater menuInflater = getActivity().getMenuInflater(); |
149 | 140 | menuInflater.inflate(R.menu.note_list_context_menu, menu); |
150 | 141 | } |
@@ -153,16 +144,13 @@ public class NoteListFragment extends ListFragment | ||
153 | 144 | } |
154 | 145 | |
155 | 146 | @Override |
156 | - public boolean onContextItemSelected(MenuItem item) | |
157 | - { | |
147 | + public boolean onContextItemSelected(MenuItem item) { | |
158 | 148 | boolean result = false; |
159 | 149 | Log.v(LOG_TAG, "Hello"); |
160 | 150 | |
161 | 151 | AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); |
162 | - if (menuInfo != null) | |
163 | - { | |
164 | - switch (item.getItemId()) | |
165 | - { | |
152 | + if (menuInfo != null) { | |
153 | + switch (item.getItemId()) { | |
166 | 154 | case R.id.delete_note_menuitem: |
167 | 155 | deleteNote(menuInfo.id); |
168 | 156 | result = true; |
@@ -173,12 +161,18 @@ public class NoteListFragment extends ListFragment | ||
173 | 161 | case R.id.share_note_menuitem: |
174 | 162 | NoteUtils.shareNote(getActivity(), menuInfo.id); |
175 | 163 | break; |
164 | + case R.id.copy_note_title_menuitem: | |
165 | + NoteUtils.copyNoteTitleToClipboard(getActivity(), menuInfo.id); | |
166 | + Toast.makeText(getActivity(), R.string.copy_note_title_done, Toast.LENGTH_SHORT).show(); | |
167 | + break; | |
168 | + case R.id.copy_note_content_menuitem: | |
169 | + NoteUtils.copyNoteContentToClipboard(getActivity(), menuInfo.id); | |
170 | + Toast.makeText(getActivity(), R.string.copy_note_content_done, Toast.LENGTH_SHORT).show(); | |
171 | + break; | |
176 | 172 | default: |
177 | 173 | result = super.onContextItemSelected(item); |
178 | 174 | } |
179 | - } | |
180 | - else | |
181 | - { | |
175 | + } else { | |
182 | 176 | result = super.onContextItemSelected(item); |
183 | 177 | } |
184 | 178 |
@@ -187,8 +181,7 @@ public class NoteListFragment extends ListFragment | ||
187 | 181 | } |
188 | 182 | |
189 | 183 | @Override |
190 | - public void onListItemClick(ListView l, View v, int position, long id) | |
191 | - { | |
184 | + public void onListItemClick(ListView l, View v, int position, long id) { | |
192 | 185 | Log.v(LOG_TAG, "Hello"); |
193 | 186 | |
194 | 187 | super.onListItemClick(l, v, position, id); |
@@ -199,35 +192,32 @@ public class NoteListFragment extends ListFragment | ||
199 | 192 | } |
200 | 193 | |
201 | 194 | // BEGIN ---------- LoaderManager.LoaderCallbacks<Cursor> ---------- |
202 | - public Loader<Cursor> onCreateLoader(int id, Bundle bundle) | |
203 | - { | |
195 | + public Loader<Cursor> onCreateLoader(int id, Bundle bundle) { | |
204 | 196 | Log.v(LOG_TAG, "Hello"); |
205 | 197 | Log.d(LOG_TAG, "this.contentUri => " + this.contentUri); |
206 | 198 | |
207 | 199 | String where = NoteStore.Note.Columns.ENABLED + " = ?"; |
208 | - String[] whereArgs = | |
209 | - { | |
210 | - "1" | |
211 | - }; | |
200 | + String[] whereArgs | |
201 | + = { | |
202 | + "1" | |
203 | + }; | |
212 | 204 | String sortOrder = NotepadPreferenceUtils.getNoteListSortOrder(getActivity()); |
213 | 205 | Log.d(LOG_TAG, String.format("where => %s, whereArgs => %s, sortOrder => %s", where, Arrays.toString(whereArgs), sortOrder)); |
214 | 206 | CursorLoader cursorLoader = new CursorLoader(getActivity(), |
215 | - contentUri, null, where, whereArgs, sortOrder); | |
207 | + contentUri, null, where, whereArgs, sortOrder); | |
216 | 208 | |
217 | 209 | Log.v(LOG_TAG, "Bye"); |
218 | 210 | return cursorLoader; |
219 | 211 | } |
220 | 212 | |
221 | - public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) | |
222 | - { | |
213 | + public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { | |
223 | 214 | Log.v(LOG_TAG, "Hello"); |
224 | 215 | Log.d(LOG_TAG, "cursor => " + cursor); |
225 | 216 | listAdapter.swapCursor(cursor); |
226 | 217 | Log.v(LOG_TAG, "Bye"); |
227 | 218 | } |
228 | 219 | |
229 | - public void onLoaderReset(Loader<Cursor> loader) | |
230 | - { | |
220 | + public void onLoaderReset(Loader<Cursor> loader) { | |
231 | 221 | Log.v(LOG_TAG, "Hello"); |
232 | 222 | listAdapter.swapCursor(null); |
233 | 223 | Log.v(LOG_TAG, "Bye"); |
@@ -235,14 +225,12 @@ public class NoteListFragment extends ListFragment | ||
235 | 225 | // END ---------- LoaderManager.LoaderCallbacks<Cursor> ---------- |
236 | 226 | |
237 | 227 | // BEGIN ---------- AbsListView.MultiChoiceModeListener |
238 | - public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean checked) | |
239 | - { | |
228 | + public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean checked) { | |
240 | 229 | Log.v(LOG_TAG, "Hello"); |
241 | 230 | Log.v(LOG_TAG, "Bye"); |
242 | 231 | } |
243 | 232 | |
244 | - public boolean onCreateActionMode(ActionMode actionMode, Menu menu) | |
245 | - { | |
233 | + public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { | |
246 | 234 | Log.v(LOG_TAG, "Hello"); |
247 | 235 | |
248 | 236 | MenuInflater menuInflater = getActivity().getMenuInflater(); |
@@ -253,8 +241,7 @@ public class NoteListFragment extends ListFragment | ||
253 | 241 | return true; |
254 | 242 | } |
255 | 243 | |
256 | - public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) | |
257 | - { | |
244 | + public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { | |
258 | 245 | boolean result = false; |
259 | 246 | Log.v(LOG_TAG, "Hello"); |
260 | 247 | listAdapter.setCheckable(true); |
@@ -262,13 +249,11 @@ public class NoteListFragment extends ListFragment | ||
262 | 249 | return result; |
263 | 250 | } |
264 | 251 | |
265 | - public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) | |
266 | - { | |
252 | + public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { | |
267 | 253 | boolean result = true; |
268 | 254 | Log.v(LOG_TAG, "Hello"); |
269 | 255 | |
270 | - switch (menuItem.getItemId()) | |
271 | - { | |
256 | + switch (menuItem.getItemId()) { | |
272 | 257 | case R.id.delete_note_menuitem: |
273 | 258 | deleteCheckedNotes(); |
274 | 259 | actionMode.finish(); |
@@ -282,16 +267,14 @@ public class NoteListFragment extends ListFragment | ||
282 | 267 | return result; |
283 | 268 | } |
284 | 269 | |
285 | - public void onDestroyActionMode(ActionMode actionMode) | |
286 | - { | |
270 | + public void onDestroyActionMode(ActionMode actionMode) { | |
287 | 271 | Log.v(LOG_TAG, "Hello"); |
288 | 272 | listAdapter.setCheckable(false); |
289 | 273 | Log.v(LOG_TAG, "Bye"); |
290 | 274 | } |
291 | 275 | // END ---------- AbsListView.MultiChoiceModeListener |
292 | 276 | |
293 | - public void setContentUri(Uri contentUri) | |
294 | - { | |
277 | + public void setContentUri(Uri contentUri) { | |
295 | 278 | Log.v(LOG_TAG, "Hello"); |
296 | 279 | Log.d(LOG_TAG, "contentUri => " + contentUri); |
297 | 280 |
@@ -301,8 +284,7 @@ public class NoteListFragment extends ListFragment | ||
301 | 284 | Log.v(LOG_TAG, "Bye"); |
302 | 285 | } |
303 | 286 | |
304 | - public void reload() | |
305 | - { | |
287 | + public void reload() { | |
306 | 288 | Log.v(LOG_TAG, "Hello"); |
307 | 289 | |
308 | 290 | getLoaderManager().restartLoader(NOTE_LOADER_ID, null, this); |
@@ -310,25 +292,21 @@ public class NoteListFragment extends ListFragment | ||
310 | 292 | Log.v(LOG_TAG, "Bye"); |
311 | 293 | } |
312 | 294 | |
313 | - private void deleteNote(long id) | |
314 | - { | |
295 | + private void deleteNote(long id) { | |
315 | 296 | Log.v(LOG_TAG, "Hello"); |
316 | 297 | |
317 | 298 | Uri noteUri = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, id); |
318 | - if (noteControlCallback != null) | |
319 | - { | |
299 | + if (noteControlCallback != null) { | |
320 | 300 | noteControlCallback.startDeleteNote(noteUri); |
321 | 301 | } |
322 | 302 | |
323 | 303 | Log.v(LOG_TAG, "Bye"); |
324 | 304 | } |
325 | 305 | |
326 | - private void showNoteDetail(long id) | |
327 | - { | |
306 | + private void showNoteDetail(long id) { | |
328 | 307 | Log.v(LOG_TAG, "Hello"); |
329 | 308 | |
330 | - if (noteControlCallback != null) | |
331 | - { | |
309 | + if (noteControlCallback != null) { | |
332 | 310 | Uri noteUri = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, id); |
333 | 311 | noteControlCallback.startViewNote(noteUri); |
334 | 312 | } |
@@ -336,28 +314,24 @@ public class NoteListFragment extends ListFragment | ||
336 | 314 | Log.v(LOG_TAG, "Bye"); |
337 | 315 | } |
338 | 316 | |
339 | - private void editNote(long id) | |
340 | - { | |
317 | + private void editNote(long id) { | |
341 | 318 | Log.v(LOG_TAG, "Hello"); |
342 | 319 | |
343 | 320 | Uri noteUri = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, id); |
344 | - if (noteControlCallback != null) | |
345 | - { | |
321 | + if (noteControlCallback != null) { | |
346 | 322 | noteControlCallback.startEditNote(noteUri); |
347 | 323 | } |
348 | 324 | |
349 | 325 | Log.v(LOG_TAG, "Bye"); |
350 | 326 | } |
351 | 327 | |
352 | - private void deleteCheckedNotes() | |
353 | - { | |
328 | + private void deleteCheckedNotes() { | |
354 | 329 | Log.v(LOG_TAG, "Hello"); |
355 | 330 | |
356 | 331 | ContentResolver cr = getActivity().getContentResolver(); |
357 | 332 | ListView listView = getListView(); |
358 | 333 | long[] checkItemIds = listView.getCheckItemIds(); |
359 | - for (int i = checkItemIds.length - 1; i >= 0; i--) | |
360 | - { | |
334 | + for (int i = checkItemIds.length - 1; i >= 0; i--) { | |
361 | 335 | long id = checkItemIds[i]; |
362 | 336 | Log.d(LOG_TAG, "delete note. i => " + i + ", id => " + id); |
363 | 337 | Uri noteUri = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, id); |
@@ -61,7 +61,7 @@ | ||
61 | 61 | <sdk> |
62 | 62 | <path>${env.ANDROID_HOME}</path> |
63 | 63 | <!-- <path>C:/Java/android-sdk</path> --> |
64 | - <platform>10</platform> | |
64 | + <platform>23</platform> | |
65 | 65 | </sdk> |
66 | 66 | <release>false</release> |
67 | 67 | <proguard> |
@@ -28,4 +28,16 @@ | ||
28 | 28 | android:numericShortcut="4" |
29 | 29 | android:alphabeticShortcut="s" |
30 | 30 | /> |
31 | + <item | |
32 | + android:id="@+id/copy_note_title_menuitem" | |
33 | + android:title="@string/copy_note_title" | |
34 | + android:numericShortcut="5" | |
35 | + android:alphabeticShortcut="t" | |
36 | + /> | |
37 | + <item | |
38 | + android:id="@+id/copy_note_content_menuitem" | |
39 | + android:title="@string/copy_note_content" | |
40 | + android:numericShortcut="5" | |
41 | + android:alphabeticShortcut="c" | |
42 | + /> | |
31 | 43 | </menu> |
\ No newline at end of file |
@@ -4,7 +4,7 @@ | ||
4 | 4 | android:id="@+id/copy_note_title_menuitem" |
5 | 5 | android:title="@string/copy_note_title" |
6 | 6 | android:numericShortcut="1" |
7 | - android:alphabeticShortcut="c" | |
7 | + android:alphabeticShortcut="t" | |
8 | 8 | /> |
9 | 9 | <item |
10 | 10 | android:id="@+id/edit_note_menuitem" |
@@ -65,6 +65,8 @@ | ||
65 | 65 | |
66 | 66 | <string name="copy_note_title">タイトルをコピー</string> |
67 | 67 | <string name="copy_note_content">本文をコピー</string> |
68 | + <string name="copy_note_title_done">タイトルをコピーしました。</string> | |
69 | + <string name="copy_note_content_done">本文をコピーしました。</string> | |
68 | 70 | |
69 | 71 | <string name="templates">テンプレート</string> |
70 | 72 | <string name="add_new_note_template">追加</string> |
@@ -65,6 +65,8 @@ | ||
65 | 65 | |
66 | 66 | <string name="copy_note_title">Copy Title</string> |
67 | 67 | <string name="copy_note_content">Copy Text</string> |
68 | + <string name="copy_note_title_done">The title has copied.</string> | |
69 | + <string name="copy_note_content_done">The text has copied.</string> | |
68 | 70 | |
69 | 71 | <string name="templates">Templates</string> |
70 | 72 | <string name="add_new_note_template">Add</string> |
@@ -62,11 +62,10 @@ import org.routine_work.utils.Log; | ||
62 | 62 | * @author Masahiko, SAWAI <masahiko.sawai@gmail.com> |
63 | 63 | */ |
64 | 64 | public class NotepadActivity extends ListActivity |
65 | - implements View.OnClickListener, OnItemClickListener, | |
66 | - TextView.OnEditorActionListener, OnFocusChangeListener, | |
67 | - SharedPreferences.OnSharedPreferenceChangeListener, | |
68 | - NotepadConstants | |
69 | -{ | |
65 | + implements View.OnClickListener, OnItemClickListener, | |
66 | + TextView.OnEditorActionListener, OnFocusChangeListener, | |
67 | + SharedPreferences.OnSharedPreferenceChangeListener, | |
68 | + NotepadConstants { | |
70 | 69 | |
71 | 70 | private static final String LOG_TAG = "simple-notepad"; |
72 | 71 | private static final String ACTION_QUIT = NotepadConstants.class.getPackage().getName() + ".QUIT"; |
@@ -74,31 +73,24 @@ public class NotepadActivity extends ListActivity | ||
74 | 73 | private static final int ACTION_MODE_NORMAL = 0; |
75 | 74 | private static final int ACTION_MODE_SEARCH = 1; |
76 | 75 | private static final int DIALOG_ID_NOTE_TEMPLATE_PICKER = 0; |
77 | - private static final int[][][] ACTION_ITEM_VISIBILITY = | |
78 | - { | |
79 | - { // ACTION_MODE_NORMAL | |
80 | - { // GONE | |
81 | - R.id.search_edittext, | |
82 | - R.id.cancel_search_button, | |
83 | - }, | |
84 | - { // VISIBLE | |
85 | - R.id.title_textview, | |
86 | - R.id.add_new_note_button, | |
87 | - R.id.search_button, | |
88 | - }, | |
89 | - }, | |
90 | - { // ACTION_MODE_SEARCH | |
91 | - { // GONE | |
92 | - R.id.title_textview, | |
93 | - R.id.add_new_note_button, | |
94 | - R.id.search_button, | |
95 | - }, | |
96 | - { // VISIBLE | |
97 | - R.id.search_edittext, | |
98 | - R.id.cancel_search_button, | |
99 | - }, | |
100 | - }, | |
101 | - }; | |
76 | + private static final int[][][] ACTION_ITEM_VISIBILITY | |
77 | + = { | |
78 | + { // ACTION_MODE_NORMAL | |
79 | + { // GONE | |
80 | + R.id.search_edittext, | |
81 | + R.id.cancel_search_button,}, | |
82 | + { // VISIBLE | |
83 | + R.id.title_textview, | |
84 | + R.id.add_new_note_button, | |
85 | + R.id.search_button,},}, | |
86 | + { // ACTION_MODE_SEARCH | |
87 | + { // GONE | |
88 | + R.id.title_textview, | |
89 | + R.id.add_new_note_button, | |
90 | + R.id.search_button,}, | |
91 | + { // VISIBLE | |
92 | + R.id.search_edittext, | |
93 | + R.id.cancel_search_button,},},}; | |
102 | 94 | // instances |
103 | 95 | private int actionMode = -1; |
104 | 96 | private NoteCursorAdapter listAdapter; |
@@ -106,22 +98,19 @@ public class NotepadActivity extends ListActivity | ||
106 | 98 | private EditText searchEditText; |
107 | 99 | private NoteTemplatePickerDialog noteTemplatePickerDialog; |
108 | 100 | |
109 | - static | |
110 | - { | |
101 | + static { | |
111 | 102 | Log.setOutputLevel(Log.VERBOSE); |
112 | 103 | Log.setTraceMode(true); |
113 | 104 | Log.setIndentMode(true); |
114 | 105 | } |
115 | 106 | |
116 | - public static void goHomeActivity(Context context) | |
117 | - { | |
107 | + public static void goHomeActivity(Context context) { | |
118 | 108 | Intent homeIntent = new Intent(Intent.ACTION_VIEW, NoteStore.Note.CONTENT_URI); |
119 | 109 | homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
120 | 110 | context.startActivity(homeIntent); |
121 | 111 | } |
122 | 112 | |
123 | - public static void quitApplication(Context context) | |
124 | - { | |
113 | + public static void quitApplication(Context context) { | |
125 | 114 | Intent quitIntent = new Intent(context, NotepadActivity.class); |
126 | 115 | quitIntent.setAction(ACTION_QUIT); |
127 | 116 | quitIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
@@ -129,8 +118,7 @@ public class NotepadActivity extends ListActivity | ||
129 | 118 | } |
130 | 119 | |
131 | 120 | @Override |
132 | - protected void onCreate(Bundle savedInstanceState) | |
133 | - { | |
121 | + protected void onCreate(Bundle savedInstanceState) { | |
134 | 122 | Log.v(LOG_TAG, "Hello"); |
135 | 123 | |
136 | 124 | setTheme(NotepadPreferenceUtils.getTheme(this)); |
@@ -155,17 +143,13 @@ public class NotepadActivity extends ListActivity | ||
155 | 143 | listView.setOnItemClickListener(this); |
156 | 144 | registerForContextMenu(listView); |
157 | 145 | |
158 | - if (savedInstanceState == null) | |
159 | - { | |
146 | + if (savedInstanceState == null) { | |
160 | 147 | initializeWithIntent(getIntent()); |
161 | - } | |
162 | - else | |
163 | - { | |
148 | + } else { | |
164 | 149 | initializeWithSavedInstance(savedInstanceState); |
165 | 150 | } |
166 | 151 | |
167 | - if (isFinishing() == false) | |
168 | - { | |
152 | + if (isFinishing() == false) { | |
169 | 153 | ImageButton homeImageButton = (ImageButton) findViewById(R.id.home_button); |
170 | 154 | homeImageButton.setOnClickListener(this); |
171 | 155 | ImageButton addImageButton = (ImageButton) findViewById(R.id.add_new_note_button); |
@@ -183,8 +167,7 @@ public class NotepadActivity extends ListActivity | ||
183 | 167 | } |
184 | 168 | |
185 | 169 | @Override |
186 | - protected void onNewIntent(Intent intent) | |
187 | - { | |
170 | + protected void onNewIntent(Intent intent) { | |
188 | 171 | Log.v(LOG_TAG, "Hello"); |
189 | 172 | |
190 | 173 | super.onNewIntent(intent); |
@@ -194,35 +177,30 @@ public class NotepadActivity extends ListActivity | ||
194 | 177 | } |
195 | 178 | |
196 | 179 | @Override |
197 | - protected void onResume() | |
198 | - { | |
180 | + protected void onResume() { | |
199 | 181 | Log.v(LOG_TAG, "Hello"); |
200 | 182 | super.onResume(); |
201 | 183 | Log.v(LOG_TAG, "Bye"); |
202 | 184 | } |
203 | 185 | |
204 | 186 | @Override |
205 | - protected void onPause() | |
206 | - { | |
187 | + protected void onPause() { | |
207 | 188 | Log.v(LOG_TAG, "Hello"); |
208 | 189 | super.onPause(); |
209 | 190 | Log.v(LOG_TAG, "Bye"); |
210 | 191 | } |
211 | 192 | |
212 | 193 | @Override |
213 | - protected void onDestroy() | |
214 | - { | |
194 | + protected void onDestroy() { | |
215 | 195 | Log.v(LOG_TAG, "Hello"); |
216 | 196 | |
217 | - if (cursor != null) | |
218 | - { | |
197 | + if (cursor != null) { | |
219 | 198 | cursor.close(); |
220 | 199 | cursor = null; |
221 | 200 | } |
222 | 201 | |
223 | 202 | int quitCount = NotepadPreferenceUtils.incrementQuitCount(this); |
224 | - if (quitCount % 64 == 0) | |
225 | - { | |
203 | + if (quitCount % 64 == 0) { | |
226 | 204 | Intent noteDBOptimizerIntent = new Intent(this, NoteDBOptimizer.class); |
227 | 205 | startService(noteDBOptimizerIntent); |
228 | 206 | } |
@@ -233,8 +211,7 @@ public class NotepadActivity extends ListActivity | ||
233 | 211 | } |
234 | 212 | |
235 | 213 | @Override |
236 | - protected void onSaveInstanceState(Bundle outState) | |
237 | - { | |
214 | + protected void onSaveInstanceState(Bundle outState) { | |
238 | 215 | Log.v(LOG_TAG, "Hello"); |
239 | 216 | |
240 | 217 | super.onSaveInstanceState(outState); |
@@ -287,8 +264,7 @@ public class NotepadActivity extends ListActivity | ||
287 | 264 | } |
288 | 265 | */ |
289 | 266 | @Override |
290 | - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) | |
291 | - { | |
267 | + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { | |
292 | 268 | Log.v(LOG_TAG, "Hello"); |
293 | 269 | super.onCreateContextMenu(menu, v, menuInfo); |
294 | 270 |
@@ -299,39 +275,45 @@ public class NotepadActivity extends ListActivity | ||
299 | 275 | } |
300 | 276 | |
301 | 277 | @Override |
302 | - public boolean onContextItemSelected(MenuItem item) | |
303 | - { | |
278 | + public boolean onContextItemSelected(MenuItem item) { | |
304 | 279 | boolean result = true; |
280 | + Log.v(LOG_TAG, "Hello"); | |
281 | + Log.v(LOG_TAG, "Bye"); | |
305 | 282 | |
306 | 283 | AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); |
307 | - Log.v(LOG_TAG, "list item position => " + menuInfo.position); | |
308 | - Log.v(LOG_TAG, "list item id => " + menuInfo.id); | |
309 | - Log.v(LOG_TAG, "list item targetView => " + menuInfo.targetView); | |
310 | - | |
311 | - int itemId = item.getItemId(); | |
312 | - switch (itemId) | |
313 | - { | |
314 | - case R.id.view_note_menuitem: | |
315 | - startViewNoteActivityById(menuInfo.id); | |
316 | - break; | |
317 | - case R.id.edit_note_menuitem: | |
318 | - startEditNoteActivityById(menuInfo.id); | |
319 | - break; | |
320 | - case R.id.delete_note_menuitem: | |
321 | - startDeleteNoteActivityById(menuInfo.id); | |
322 | - break; | |
323 | - case R.id.share_note_menuitem: | |
324 | - NoteUtils.shareNote(this, menuInfo.id); | |
325 | - break; | |
326 | - default: | |
327 | - result = super.onContextItemSelected(item); | |
284 | + if (menuInfo != null) { | |
285 | + switch (item.getItemId()) { | |
286 | + case R.id.view_note_menuitem: | |
287 | + startViewNoteActivityById(menuInfo.id); | |
288 | + break; | |
289 | + case R.id.edit_note_menuitem: | |
290 | + startEditNoteActivityById(menuInfo.id); | |
291 | + break; | |
292 | + case R.id.delete_note_menuitem: | |
293 | + startDeleteNoteActivityById(menuInfo.id); | |
294 | + break; | |
295 | + case R.id.share_note_menuitem: | |
296 | + NoteUtils.shareNote(this, menuInfo.id); | |
297 | + break; | |
298 | + case R.id.copy_note_title_menuitem: | |
299 | + NoteUtils.copyNoteTitleToClipboard(this, menuInfo.id); | |
300 | + Toast.makeText(this, R.string.copy_note_title_done, Toast.LENGTH_SHORT).show(); | |
301 | + break; | |
302 | + case R.id.copy_note_content_menuitem: | |
303 | + NoteUtils.copyNoteContentToClipboard(this, menuInfo.id); | |
304 | + Toast.makeText(this, R.string.copy_note_content_done, Toast.LENGTH_SHORT).show(); | |
305 | + break; | |
306 | + default: | |
307 | + result = super.onContextItemSelected(item); | |
308 | + } | |
309 | + } else { | |
310 | + result = super.onContextItemSelected(item); | |
328 | 311 | } |
329 | 312 | |
330 | 313 | return result; |
331 | 314 | } |
332 | 315 | |
333 | - public void onItemClick(AdapterView<?> parentView, View view, int position, long id) | |
334 | - { | |
316 | + public void onItemClick(AdapterView<?> parentView, View view, int position, long id) { | |
335 | 317 | Log.v(LOG_TAG, "Hello"); |
336 | 318 | |
337 | 319 | Log.d(LOG_TAG, "clicked item position => " + position); |
@@ -343,8 +325,7 @@ public class NotepadActivity extends ListActivity | ||
343 | 325 | } |
344 | 326 | |
345 | 327 | @Override |
346 | - public boolean onCreateOptionsMenu(Menu menu) | |
347 | - { | |
328 | + public boolean onCreateOptionsMenu(Menu menu) { | |
348 | 329 | Log.v(LOG_TAG, "Hello"); |
349 | 330 | |
350 | 331 | MenuInflater menuInflater = getMenuInflater(); |
@@ -360,14 +341,12 @@ public class NotepadActivity extends ListActivity | ||
360 | 341 | } |
361 | 342 | |
362 | 343 | @Override |
363 | - public boolean onOptionsItemSelected(MenuItem item) | |
364 | - { | |
344 | + public boolean onOptionsItemSelected(MenuItem item) { | |
365 | 345 | boolean result = true; |
366 | 346 | Log.v(LOG_TAG, "Hello"); |
367 | 347 | |
368 | 348 | int itemId = item.getItemId(); |
369 | - switch (itemId) | |
370 | - { | |
349 | + switch (itemId) { | |
371 | 350 | case R.id.add_new_note_menuitem: |
372 | 351 | Log.d(LOG_TAG, "add_new_note_menuitem is selected."); |
373 | 352 | addNewNote(); |
@@ -400,13 +379,11 @@ public class NotepadActivity extends ListActivity | ||
400 | 379 | return result; |
401 | 380 | } |
402 | 381 | |
403 | - public void onClick(View view) | |
404 | - { | |
382 | + public void onClick(View view) { | |
405 | 383 | Log.v(LOG_TAG, "Hello"); |
406 | 384 | |
407 | 385 | int viewId = view.getId(); |
408 | - switch (viewId) | |
409 | - { | |
386 | + switch (viewId) { | |
410 | 387 | case R.id.home_button: |
411 | 388 | Log.d(LOG_TAG, "home_button is clicked."); |
412 | 389 | cancelSearchMode(); |
@@ -429,19 +406,15 @@ public class NotepadActivity extends ListActivity | ||
429 | 406 | } |
430 | 407 | |
431 | 408 | @Override |
432 | - public boolean onKeyDown(int keyCode, KeyEvent event) | |
433 | - { | |
409 | + public boolean onKeyDown(int keyCode, KeyEvent event) { | |
434 | 410 | boolean result; |
435 | 411 | Log.v(LOG_TAG, "Hello"); |
436 | 412 | |
437 | 413 | if ((keyCode == KeyEvent.KEYCODE_BACK) |
438 | - && (actionMode != ACTION_MODE_NORMAL)) | |
439 | - { | |
414 | + && (actionMode != ACTION_MODE_NORMAL)) { | |
440 | 415 | cancelSearchMode(); |
441 | 416 | result = true; |
442 | - } | |
443 | - else | |
444 | - { | |
417 | + } else { | |
445 | 418 | result = super.onKeyDown(keyCode, event); |
446 | 419 | } |
447 | 420 |
@@ -450,13 +423,11 @@ public class NotepadActivity extends ListActivity | ||
450 | 423 | } |
451 | 424 | |
452 | 425 | @Override |
453 | - protected Dialog onCreateDialog(int id) | |
454 | - { | |
426 | + protected Dialog onCreateDialog(int id) { | |
455 | 427 | Dialog dialog = null; |
456 | 428 | Log.v(LOG_TAG, "Hello"); |
457 | 429 | |
458 | - switch (id) | |
459 | - { | |
430 | + switch (id) { | |
460 | 431 | case DIALOG_ID_NOTE_TEMPLATE_PICKER: |
461 | 432 | dialog = getNoteTemplatePickerDialog(); |
462 | 433 | break; |
@@ -468,28 +439,21 @@ public class NotepadActivity extends ListActivity | ||
468 | 439 | } |
469 | 440 | |
470 | 441 | // TextView.OnEditorActionListener |
471 | - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) | |
472 | - { | |
473 | - if (actionId == EditorInfo.IME_ACTION_SEARCH) | |
474 | - { | |
442 | + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { | |
443 | + if (actionId == EditorInfo.IME_ACTION_SEARCH) { | |
475 | 444 | IMEUtils.hideSoftKeyboardWindow(this, v); |
476 | 445 | } |
477 | 446 | return true; |
478 | 447 | } |
479 | 448 | |
480 | - public void onFocusChange(View v, boolean hasFocus) | |
481 | - { | |
449 | + public void onFocusChange(View v, boolean hasFocus) { | |
482 | 450 | Log.v(LOG_TAG, "Hello"); |
483 | 451 | |
484 | - if (v.getId() == R.id.search_edittext) | |
485 | - { | |
486 | - if (hasFocus) | |
487 | - { | |
452 | + if (v.getId() == R.id.search_edittext) { | |
453 | + if (hasFocus) { | |
488 | 454 | Log.d(LOG_TAG, "search_edittext has focus."); |
489 | 455 | IMEUtils.showSoftKeyboardWindow(this, v); |
490 | - } | |
491 | - else | |
492 | - { | |
456 | + } else { | |
493 | 457 | Log.d(LOG_TAG, "search_edittext has focus."); |
494 | 458 | IMEUtils.hideSoftKeyboardWindow(this, v); |
495 | 459 | } |
@@ -498,14 +462,12 @@ public class NotepadActivity extends ListActivity | ||
498 | 462 | Log.v(LOG_TAG, "Bye"); |
499 | 463 | } |
500 | 464 | |
501 | - public void onSharedPreferenceChanged(SharedPreferences prefs, String key) | |
502 | - { | |
465 | + public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { | |
503 | 466 | Log.v(LOG_TAG, "Hello"); |
504 | 467 | Log.d(LOG_TAG, "shared preference " + key + " is changed."); |
505 | 468 | |
506 | 469 | String noteListSortOrderKey = getString(R.string.note_list_sort_order_key); |
507 | - if (noteListSortOrderKey.equals(key)) | |
508 | - { | |
470 | + if (noteListSortOrderKey.equals(key)) { | |
509 | 471 | Log.d(LOG_TAG, "sort order is changed, update note list with new sort order."); |
510 | 472 | String queryString = searchEditText.getText().toString(); |
511 | 473 | updateContentWithQuery(queryString); |
@@ -514,8 +476,7 @@ public class NotepadActivity extends ListActivity | ||
514 | 476 | Log.v(LOG_TAG, "Bye"); |
515 | 477 | } |
516 | 478 | |
517 | - private void initializeWithIntent(Intent intent) | |
518 | - { | |
479 | + private void initializeWithIntent(Intent intent) { | |
519 | 480 | Log.v(LOG_TAG, "Hello"); |
520 | 481 | |
521 | 482 | Log.d(LOG_TAG, "------------------------------"); |
@@ -527,31 +488,23 @@ public class NotepadActivity extends ListActivity | ||
527 | 488 | |
528 | 489 | String queryString = null; |
529 | 490 | String action = intent.getAction(); |
530 | - if (ACTION_QUIT.equals(action)) | |
531 | - { | |
491 | + if (ACTION_QUIT.equals(action)) { | |
532 | 492 | finish(); |
533 | - } | |
534 | - else if (Intent.ACTION_SEARCH.equals(action)) | |
535 | - { | |
493 | + } else if (Intent.ACTION_SEARCH.equals(action)) { | |
536 | 494 | queryString = intent.getStringExtra(SearchManager.QUERY); |
537 | - } | |
538 | - else if (Intent.ACTION_VIEW.equals(action)) | |
539 | - { | |
495 | + } else if (Intent.ACTION_VIEW.equals(action)) { | |
540 | 496 | int flags = intent.getFlags(); |
541 | 497 | Log.v(LOG_TAG, "flags => 0x" + Integer.toHexString(flags)); |
542 | 498 | |
543 | - if ((flags & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) | |
544 | - { | |
499 | + if ((flags & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { | |
545 | 500 | Log.d(LOG_TAG, "flags includes FLAG_ACTIVITY_NEW_TASK"); |
546 | 501 | |
547 | 502 | boolean processed = false; |
548 | 503 | Uri data = intent.getData(); |
549 | - if (data != null) | |
550 | - { | |
504 | + if (data != null) { | |
551 | 505 | ContentResolver contentResolver = getContentResolver(); |
552 | 506 | String type = contentResolver.getType(data); |
553 | - if (NoteStore.Note.NOTE_ITEM_CONTENT_TYPE.equals(type)) | |
554 | - { | |
507 | + if (NoteStore.Note.NOTE_ITEM_CONTENT_TYPE.equals(type)) { | |
555 | 508 | Log.d(LOG_TAG, "open note : data => " + data); |
556 | 509 | String idString = data.getLastPathSegment(); |
557 | 510 | queryString = "id:" + idString; |
@@ -559,27 +512,20 @@ public class NotepadActivity extends ListActivity | ||
559 | 512 | } |
560 | 513 | } |
561 | 514 | |
562 | - if (!processed) | |
563 | - { | |
515 | + if (!processed) { | |
564 | 516 | queryString = intent.getStringExtra(SearchManager.QUERY); |
565 | 517 | } |
566 | 518 | } |
567 | 519 | } |
568 | 520 | |
569 | - if (queryString != null) | |
570 | - { | |
521 | + if (queryString != null) { | |
571 | 522 | enterSearchMode(); |
572 | - if (TextUtils.isEmpty(queryString.trim())) | |
573 | - { | |
523 | + if (TextUtils.isEmpty(queryString.trim())) { | |
574 | 524 | searchEditText.setText(null); |
575 | - } | |
576 | - else | |
577 | - { | |
525 | + } else { | |
578 | 526 | searchEditText.setText(queryString); |
579 | 527 | } |
580 | - } | |
581 | - else | |
582 | - { | |
528 | + } else { | |
583 | 529 | setActionMode(ACTION_MODE_NORMAL); |
584 | 530 | searchEditText.setText(null); |
585 | 531 | } |
@@ -587,8 +533,7 @@ public class NotepadActivity extends ListActivity | ||
587 | 533 | Log.v(LOG_TAG, "Bye"); |
588 | 534 | } |
589 | 535 | |
590 | - private void initializeWithSavedInstance(Bundle savedInstanceState) | |
591 | - { | |
536 | + private void initializeWithSavedInstance(Bundle savedInstanceState) { | |
592 | 537 | Log.v(LOG_TAG, "Hello"); |
593 | 538 | |
594 | 539 | int savedActionMode = savedInstanceState.getInt(SAVE_KEY_ACTION_MODE); |
@@ -597,29 +542,22 @@ public class NotepadActivity extends ListActivity | ||
597 | 542 | Log.v(LOG_TAG, "Bye"); |
598 | 543 | } |
599 | 544 | |
600 | - private void addNewNote() | |
601 | - { | |
545 | + private void addNewNote() { | |
602 | 546 | Log.v(LOG_TAG, "Hello"); |
603 | 547 | |
604 | 548 | int noteTemplateCount = NoteStore.getNoteTemplateCount(getContentResolver()); |
605 | - if (noteTemplateCount >= 2) | |
606 | - { | |
549 | + if (noteTemplateCount >= 2) { | |
607 | 550 | showDialog(DIALOG_ID_NOTE_TEMPLATE_PICKER); |
608 | - } | |
609 | - else if (noteTemplateCount == 1) | |
610 | - { | |
551 | + } else if (noteTemplateCount == 1) { | |
611 | 552 | NoteUtils.startActivityToAddNewNoteWithFirstTemplate(this); |
612 | - } | |
613 | - else if (noteTemplateCount == 0) | |
614 | - { | |
553 | + } else if (noteTemplateCount == 0) { | |
615 | 554 | NoteUtils.startActivityToAddNewBlankNote(this); |
616 | 555 | } |
617 | 556 | |
618 | 557 | Log.v(LOG_TAG, "Bye"); |
619 | 558 | } |
620 | 559 | |
621 | - private void startViewNoteActivityById(long id) | |
622 | - { | |
560 | + private void startViewNoteActivityById(long id) { | |
623 | 561 | Log.v(LOG_TAG, "Hello"); |
624 | 562 | |
625 | 563 | Uri uri = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, id); |
@@ -629,8 +567,7 @@ public class NotepadActivity extends ListActivity | ||
629 | 567 | Log.v(LOG_TAG, "Bye"); |
630 | 568 | } |
631 | 569 | |
632 | - private void startEditNoteActivityById(long id) | |
633 | - { | |
570 | + private void startEditNoteActivityById(long id) { | |
634 | 571 | Log.v(LOG_TAG, "Hello"); |
635 | 572 | |
636 | 573 | Uri uri = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, id); |
@@ -640,8 +577,7 @@ public class NotepadActivity extends ListActivity | ||
640 | 577 | Log.v(LOG_TAG, "Bye"); |
641 | 578 | } |
642 | 579 | |
643 | - private void startDeleteNoteActivityById(long id) | |
644 | - { | |
580 | + private void startDeleteNoteActivityById(long id) { | |
645 | 581 | Log.v(LOG_TAG, "Hello"); |
646 | 582 | |
647 | 583 | Uri uri = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, id); |
@@ -651,8 +587,7 @@ public class NotepadActivity extends ListActivity | ||
651 | 587 | Log.v(LOG_TAG, "Bye"); |
652 | 588 | } |
653 | 589 | |
654 | - private void startDeleteNotesActivity() | |
655 | - { | |
590 | + private void startDeleteNotesActivity() { | |
656 | 591 | Log.v(LOG_TAG, "Hello"); |
657 | 592 | |
658 | 593 | Intent intent = new Intent(this, DeleteNotesActivity.class); |
@@ -661,8 +596,7 @@ public class NotepadActivity extends ListActivity | ||
661 | 596 | Log.v(LOG_TAG, "Bye"); |
662 | 597 | } |
663 | 598 | |
664 | - private void startPreferencesActivity() | |
665 | - { | |
599 | + private void startPreferencesActivity() { | |
666 | 600 | Log.v(LOG_TAG, "Hello"); |
667 | 601 | |
668 | 602 | Intent intent = new Intent(this, NotepadPreferenceActivity.class); |
@@ -671,8 +605,7 @@ public class NotepadActivity extends ListActivity | ||
671 | 605 | Log.v(LOG_TAG, "Bye"); |
672 | 606 | } |
673 | 607 | |
674 | - private void startTemplateListActivity() | |
675 | - { | |
608 | + private void startTemplateListActivity() { | |
676 | 609 | Log.v(LOG_TAG, "Hello"); |
677 | 610 | |
678 | 611 | Intent intent = new Intent(Intent.ACTION_VIEW, NoteStore.NoteTemplate.CONTENT_URI); |
@@ -681,29 +614,23 @@ public class NotepadActivity extends ListActivity | ||
681 | 614 | Log.v(LOG_TAG, "Bye"); |
682 | 615 | } |
683 | 616 | |
684 | - private void setActionMode(int newActionMode) | |
685 | - { | |
617 | + private void setActionMode(int newActionMode) { | |
686 | 618 | Log.v(LOG_TAG, "Hello"); |
687 | 619 | |
688 | - if (actionMode != newActionMode) | |
689 | - { | |
620 | + if (actionMode != newActionMode) { | |
690 | 621 | actionMode = newActionMode; |
691 | 622 | Log.d(LOG_TAG, "update actionMode => " + actionMode); |
692 | 623 | int[] goneViewIds = ACTION_ITEM_VISIBILITY[actionMode][0]; |
693 | - for (int i = 0; i < goneViewIds.length; i++) | |
694 | - { | |
624 | + for (int i = 0; i < goneViewIds.length; i++) { | |
695 | 625 | View view = findViewById(goneViewIds[i]); |
696 | - if (view != null) | |
697 | - { | |
626 | + if (view != null) { | |
698 | 627 | view.setVisibility(View.GONE); |
699 | 628 | } |
700 | 629 | } |
701 | 630 | int[] visibleViewIds = ACTION_ITEM_VISIBILITY[actionMode][1]; |
702 | - for (int i = 0; i < visibleViewIds.length; i++) | |
703 | - { | |
631 | + for (int i = 0; i < visibleViewIds.length; i++) { | |
704 | 632 | View view = findViewById(visibleViewIds[i]); |
705 | - if (view != null) | |
706 | - { | |
633 | + if (view != null) { | |
707 | 634 | view.setVisibility(View.VISIBLE); |
708 | 635 | } |
709 | 636 | } |
@@ -713,40 +640,35 @@ public class NotepadActivity extends ListActivity | ||
713 | 640 | Log.v(LOG_TAG, "Bye"); |
714 | 641 | } |
715 | 642 | |
716 | - private void updateContentWithQuery(String queryString) | |
717 | - { | |
643 | + private void updateContentWithQuery(String queryString) { | |
718 | 644 | Log.v(LOG_TAG, "Hello"); |
719 | 645 | Log.v(LOG_TAG, "queryString => " + queryString); |
720 | 646 | |
721 | 647 | Uri contentUri = NoteSearchQueryParser.parseQuery(queryString); |
722 | 648 | Log.v(LOG_TAG, "contentUri => " + contentUri); |
723 | 649 | |
724 | - if (contentUri != null) | |
725 | - { | |
650 | + if (contentUri != null) { | |
726 | 651 | updateContentWithUri(contentUri); |
727 | 652 | } |
728 | 653 | |
729 | 654 | Log.v(LOG_TAG, "Bye"); |
730 | 655 | } |
731 | 656 | |
732 | - private void updateContentWithUri(Uri contentUri) | |
733 | - { | |
657 | + private void updateContentWithUri(Uri contentUri) { | |
734 | 658 | Log.v(LOG_TAG, "Hello"); |
735 | 659 | Log.v(LOG_TAG, "contentUri => " + contentUri); |
736 | 660 | |
737 | 661 | String where = NoteStore.Note.Columns.ENABLED + " = ?"; |
738 | - String[] whereArgs = | |
739 | - { | |
740 | - "1", | |
741 | - }; | |
662 | + String[] whereArgs | |
663 | + = { | |
664 | + "1",}; | |
742 | 665 | String sortOrder = NotepadPreferenceUtils.getNoteListSortOrder(this); |
743 | 666 | Log.d(LOG_TAG, String.format("where => %s, whereArgs => %s, sortOrder => %s", where, Arrays.toString(whereArgs), sortOrder)); |
744 | 667 | ContentResolver cr = getContentResolver(); |
745 | 668 | Cursor newCursor = cr.query(contentUri, null, where, whereArgs, sortOrder); |
746 | 669 | listAdapter.changeCursor(newCursor); |
747 | 670 | |
748 | - if (cursor != null) | |
749 | - { | |
671 | + if (cursor != null) { | |
750 | 672 | cursor.close(); |
751 | 673 | } |
752 | 674 | cursor = newCursor; |
@@ -754,44 +676,35 @@ public class NotepadActivity extends ListActivity | ||
754 | 676 | Log.v(LOG_TAG, "Bye"); |
755 | 677 | } |
756 | 678 | |
757 | - private void cancelSearchMode() | |
758 | - { | |
759 | - if (actionMode != ACTION_MODE_NORMAL) | |
760 | - { | |
679 | + private void cancelSearchMode() { | |
680 | + if (actionMode != ACTION_MODE_NORMAL) { | |
761 | 681 | searchEditText.setText(null); |
762 | 682 | getListView().requestFocus(); |
763 | 683 | setActionMode(ACTION_MODE_NORMAL); |
764 | 684 | } |
765 | 685 | } |
766 | 686 | |
767 | - private void enterSearchMode() | |
768 | - { | |
769 | - if (actionMode != ACTION_MODE_SEARCH) | |
770 | - { | |
687 | + private void enterSearchMode() { | |
688 | + if (actionMode != ACTION_MODE_SEARCH) { | |
771 | 689 | setActionMode(ACTION_MODE_SEARCH); |
772 | 690 | IMEUtils.requestKeyboardFocus(searchEditText); |
773 | 691 | // searchEditText.requestFocus(); |
774 | 692 | } |
775 | 693 | } |
776 | 694 | |
777 | - private Dialog getNoteTemplatePickerDialog() | |
778 | - { | |
779 | - if (noteTemplatePickerDialog == null) | |
780 | - { | |
695 | + private Dialog getNoteTemplatePickerDialog() { | |
696 | + if (noteTemplatePickerDialog == null) { | |
781 | 697 | noteTemplatePickerDialog = new NoteTemplatePickerDialog(this); |
782 | 698 | } |
783 | 699 | return noteTemplatePickerDialog; |
784 | 700 | } |
785 | 701 | |
786 | - private void initializeNoteTemplateData() | |
787 | - { | |
788 | - if (NotepadPreferenceUtils.isTemplateDataInitialized(this) == false) | |
789 | - { | |
702 | + private void initializeNoteTemplateData() { | |
703 | + if (NotepadPreferenceUtils.isTemplateDataInitialized(this) == false) { | |
790 | 704 | NotepadPreferenceUtils.setTemplateDataInitialized(this, true); |
791 | 705 | int noteTemplateCount = NoteStore.getNoteTemplateCount(getContentResolver()); |
792 | 706 | Log.d(LOG_TAG, "noteTemplateCount => " + noteTemplateCount); |
793 | - if (noteTemplateCount == 0) | |
794 | - { | |
707 | + if (noteTemplateCount == 0) { | |
795 | 708 | Log.d(LOG_TAG, "start NoteTemplateInitializer"); |
796 | 709 | Intent noteTeplateInitializerIntent = new Intent(this, NoteTemplateInitializer.class); |
797 | 710 | startService(noteTeplateInitializerIntent); |
@@ -799,17 +712,14 @@ public class NotepadActivity extends ListActivity | ||
799 | 712 | } |
800 | 713 | } |
801 | 714 | |
802 | - class SearchEditTextWatcher implements TextWatcher | |
803 | - { | |
715 | + class SearchEditTextWatcher implements TextWatcher { | |
804 | 716 | |
805 | - public void beforeTextChanged(CharSequence s, int start, int count, int after) | |
806 | - { | |
717 | + public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |
807 | 718 | Log.v(LOG_TAG, "Hello"); |
808 | 719 | Log.v(LOG_TAG, "Bye"); |
809 | 720 | } |
810 | 721 | |
811 | - public void onTextChanged(CharSequence s, int start, int before, int count) | |
812 | - { | |
722 | + public void onTextChanged(CharSequence s, int start, int before, int count) { | |
813 | 723 | Log.v(LOG_TAG, "Hello"); |
814 | 724 | |
815 | 725 | updateContentWithQuery(s.toString()); |
@@ -817,8 +727,7 @@ public class NotepadActivity extends ListActivity | ||
817 | 727 | Log.v(LOG_TAG, "Bye"); |
818 | 728 | } |
819 | 729 | |
820 | - public void afterTextChanged(Editable s) | |
821 | - { | |
730 | + public void afterTextChanged(Editable s) { | |
822 | 731 | Log.v(LOG_TAG, "Hello"); |
823 | 732 | Log.v(LOG_TAG, "Bye"); |
824 | 733 | } |
@@ -11,11 +11,13 @@ import android.content.Context; | ||
11 | 11 | import android.content.Intent; |
12 | 12 | import android.database.Cursor; |
13 | 13 | import android.net.Uri; |
14 | +import android.text.ClipboardManager; | |
14 | 15 | import android.text.TextUtils; |
15 | 16 | import android.text.format.DateFormat; |
16 | 17 | import java.util.Date; |
17 | 18 | import java.util.HashMap; |
18 | 19 | import java.util.Map; |
20 | +import org.routine_work.notepad.model.Note; | |
19 | 21 | import org.routine_work.notepad.provider.NoteStore; |
20 | 22 | import org.routine_work.utils.Log; |
21 | 23 |
@@ -23,13 +25,11 @@ import org.routine_work.utils.Log; | ||
23 | 25 | * |
24 | 26 | * @author sawai |
25 | 27 | */ |
26 | -public class NoteUtils implements NotepadConstants | |
27 | -{ | |
28 | +public class NoteUtils implements NotepadConstants { | |
28 | 29 | |
29 | 30 | private static final String LOG_TAG = "simple-notepad"; |
30 | 31 | |
31 | - public static void shareNote(Context context, long noteId) | |
32 | - { | |
32 | + public static void shareNote(Context context, long noteId) { | |
33 | 33 | Log.v(LOG_TAG, "Hello"); |
34 | 34 | Log.d(LOG_TAG, "noteId"); |
35 | 35 |
@@ -39,40 +39,19 @@ public class NoteUtils implements NotepadConstants | ||
39 | 39 | Log.v(LOG_TAG, "Bye"); |
40 | 40 | } |
41 | 41 | |
42 | - public static void shareNote(Context context, Uri noteUri) | |
43 | - { | |
42 | + public static void shareNote(Context context, Uri noteUri) { | |
44 | 43 | Log.v(LOG_TAG, "Hello"); |
45 | 44 | Log.d(LOG_TAG, "noteUri => " + noteUri); |
46 | 45 | |
47 | - if (NoteStore.isNoteItemUri(context, noteUri)) | |
48 | - { | |
49 | - ContentResolver contentResolver = context.getContentResolver(); | |
50 | - Cursor cursor = contentResolver.query(noteUri, null, null, null, null); | |
51 | - if (cursor != null) | |
52 | - { | |
53 | - try | |
54 | - { | |
55 | - if (cursor.moveToFirst()) | |
56 | - { | |
57 | - int titleIndex = cursor.getColumnIndex(NoteStore.Note.Columns.TITLE); | |
58 | - int contentIndex = cursor.getColumnIndex(NoteStore.Note.Columns.CONTENT); | |
59 | - String noteTitle = cursor.getString(titleIndex); | |
60 | - String noteContent = cursor.getString(contentIndex); | |
61 | - shareNote(context, noteTitle, noteContent); | |
62 | - } | |
63 | - } | |
64 | - finally | |
65 | - { | |
66 | - cursor.close(); | |
67 | - } | |
68 | - } | |
46 | + Note note = loadNoteData(context, noteUri); | |
47 | + if (note != null) { | |
48 | + shareNote(context, note.getTitle(), note.getContent()); | |
69 | 49 | } |
70 | 50 | |
71 | 51 | Log.v(LOG_TAG, "Bye"); |
72 | 52 | } |
73 | 53 | |
74 | - public static void shareNote(Context context, String noteTitle, String noteContent) | |
75 | - { | |
54 | + public static void shareNote(Context context, String noteTitle, String noteContent) { | |
76 | 55 | Log.v(LOG_TAG, "Hello"); |
77 | 56 | Log.d(LOG_TAG, "titile => " + noteTitle); |
78 | 57 | Log.d(LOG_TAG, "content => " + noteContent); |
@@ -87,6 +66,50 @@ public class NoteUtils implements NotepadConstants | ||
87 | 66 | Log.v(LOG_TAG, "Bye"); |
88 | 67 | } |
89 | 68 | |
69 | + public static void copyNoteTitleToClipboard(Context context, long id) { | |
70 | + Log.v(LOG_TAG, "Hello"); | |
71 | + | |
72 | + Uri noteUri = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, id); | |
73 | + copyNoteTitleToClipboard(context, noteUri); | |
74 | + | |
75 | + Log.v(LOG_TAG, "Bye"); | |
76 | + } | |
77 | + | |
78 | + public static void copyNoteTitleToClipboard(Context context, Uri noteUri) { | |
79 | + Log.v(LOG_TAG, "Hello"); | |
80 | + Log.d(LOG_TAG, "noteUri => " + noteUri); | |
81 | + | |
82 | + Note note = loadNoteData(context, noteUri); | |
83 | + if (note != null) { | |
84 | + ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); | |
85 | + clipboardManager.setText(note.getTitle()); | |
86 | + } | |
87 | + | |
88 | + Log.v(LOG_TAG, "Bye"); | |
89 | + } | |
90 | + | |
91 | + public static void copyNoteContentToClipboard(Context context, long id) { | |
92 | + Log.v(LOG_TAG, "Hello"); | |
93 | + | |
94 | + Uri noteUri = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, id); | |
95 | + copyNoteContentToClipboard(context, noteUri); | |
96 | + | |
97 | + Log.v(LOG_TAG, "Bye"); | |
98 | + } | |
99 | + | |
100 | + public static void copyNoteContentToClipboard(Context context, Uri noteUri) { | |
101 | + Log.v(LOG_TAG, "Hello"); | |
102 | + Log.d(LOG_TAG, "noteUri => " + noteUri); | |
103 | + | |
104 | + Note note = loadNoteData(context, noteUri); | |
105 | + if (note != null) { | |
106 | + ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); | |
107 | + clipboardManager.setText(note.getContent()); | |
108 | + } | |
109 | + | |
110 | + Log.v(LOG_TAG, "Bye"); | |
111 | + } | |
112 | + | |
90 | 113 | /** |
91 | 114 | * Start NoteDetailActivity without note template |
92 | 115 | * |
@@ -94,8 +117,7 @@ public class NoteUtils implements NotepadConstants | ||
94 | 117 | * |
95 | 118 | * @param activity |
96 | 119 | */ |
97 | - public static void startActivityToAddNewBlankNote(Activity activity) | |
98 | - { | |
120 | + public static void startActivityToAddNewBlankNote(Activity activity) { | |
99 | 121 | Log.v(LOG_TAG, "Hello"); |
100 | 122 | |
101 | 123 | Intent intent = new Intent(Intent.ACTION_INSERT, NoteStore.Note.CONTENT_URI); |
@@ -105,33 +127,27 @@ public class NoteUtils implements NotepadConstants | ||
105 | 127 | Log.v(LOG_TAG, "Bye"); |
106 | 128 | } |
107 | 129 | |
108 | - public static void startActivityToAddNewNoteWithTemplate(Activity activity, long noteTemplateId) | |
109 | - { | |
130 | + public static void startActivityToAddNewNoteWithTemplate(Activity activity, long noteTemplateId) { | |
110 | 131 | Uri noteTemplateUri = ContentUris.withAppendedId(NoteStore.NoteTemplate.CONTENT_URI, noteTemplateId); |
111 | 132 | NoteUtils.startActivityToAddNewNoteWithTemplate(activity, noteTemplateUri); |
112 | 133 | } |
113 | 134 | |
114 | - public static void startActivityToAddNewNoteWithTemplate(Activity activity, Uri noteTemplateUri) | |
115 | - { | |
135 | + public static void startActivityToAddNewNoteWithTemplate(Activity activity, Uri noteTemplateUri) { | |
116 | 136 | Log.v(LOG_TAG, "Hello"); |
117 | 137 | |
118 | 138 | String where = null; |
119 | 139 | String[] whereArgs = null; |
120 | - if (NoteStore.NoteTemplate.CONTENT_URI.equals(noteTemplateUri)) | |
121 | - { | |
140 | + if (NoteStore.NoteTemplate.CONTENT_URI.equals(noteTemplateUri)) { | |
122 | 141 | where = NoteStore.Note.Columns.ENABLED + " = ?"; |
123 | - whereArgs = new String[] | |
124 | - { | |
142 | + whereArgs = new String[]{ | |
125 | 143 | "1" |
126 | 144 | }; |
127 | 145 | } |
128 | 146 | |
129 | 147 | Cursor cursor = activity.getContentResolver().query(noteTemplateUri, |
130 | - null, where, whereArgs, null); | |
131 | - try | |
132 | - { | |
133 | - if (cursor != null && cursor.moveToFirst()) | |
134 | - { | |
148 | + null, where, whereArgs, null); | |
149 | + try { | |
150 | + if (cursor != null && cursor.moveToFirst()) { | |
135 | 151 | int titleIndex = cursor.getColumnIndex(NoteStore.NoteTemplate.Columns.TITLE); |
136 | 152 | int contentIndex = cursor.getColumnIndex(NoteStore.NoteTemplate.Columns.CONTENT); |
137 | 153 | int titleLockedIndex = cursor.getColumnIndex(NoteStore.NoteTemplate.Columns.TITLE_LOCKED); |
@@ -151,23 +167,19 @@ public class NoteUtils implements NotepadConstants | ||
151 | 167 | String content = expandTemplate(contentTemplate, templateContextMap); |
152 | 168 | |
153 | 169 | Uri noteUri = null; |
154 | - if (editSameTitle) | |
155 | - { | |
170 | + if (editSameTitle) { | |
156 | 171 | noteUri = searchNoteByTitle(activity, title); |
157 | 172 | } |
158 | 173 | Log.d(LOG_TAG, "noteUri => " + noteUri); |
159 | 174 | |
160 | - if (noteUri != null) | |
161 | - { | |
175 | + if (noteUri != null) { | |
162 | 176 | Log.d(LOG_TAG, "note is already exist."); |
163 | 177 | // if note is already exist |
164 | 178 | Intent intent = new Intent(Intent.ACTION_EDIT, noteUri); |
165 | 179 | intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
166 | 180 | intent.putExtra(EXTRA_TEXT, content); |
167 | 181 | activity.startActivityForResult(intent, REQUEST_CODE_EDIT_NOTE); |
168 | - } | |
169 | - else | |
170 | - { | |
182 | + } else { | |
171 | 183 | Log.d(LOG_TAG, "note is not found."); |
172 | 184 | // if not found, insert new note |
173 | 185 | Intent intent = new Intent(Intent.ACTION_INSERT, NoteStore.Note.CONTENT_URI); |
@@ -178,54 +190,42 @@ public class NoteUtils implements NotepadConstants | ||
178 | 190 | activity.startActivityForResult(intent, REQUEST_CODE_ADD_NOTE); |
179 | 191 | } |
180 | 192 | } |
181 | - } | |
182 | - finally | |
183 | - { | |
184 | - if (cursor != null) | |
185 | - { | |
193 | + } finally { | |
194 | + if (cursor != null) { | |
186 | 195 | cursor.close(); |
187 | 196 | } |
188 | 197 | } |
189 | 198 | Log.v(LOG_TAG, "Bye"); |
190 | 199 | } |
191 | 200 | |
192 | - public static void startActivityToAddNewNoteWithFirstTemplate(Activity activity) | |
193 | - { | |
201 | + public static void startActivityToAddNewNoteWithFirstTemplate(Activity activity) { | |
194 | 202 | NoteUtils.startActivityToAddNewNoteWithTemplate(activity, NoteStore.NoteTemplate.CONTENT_URI); |
195 | 203 | } |
196 | 204 | |
197 | - public static Uri searchNoteByTitle(Context context, String title) | |
198 | - { | |
205 | + public static Uri searchNoteByTitle(Context context, String title) { | |
199 | 206 | Uri result = null; |
200 | 207 | Log.v(LOG_TAG, "Hello"); |
201 | 208 | Log.d(LOG_TAG, "title => " + title); |
202 | 209 | |
203 | - if (!TextUtils.isEmpty(title)) | |
204 | - { | |
210 | + if (!TextUtils.isEmpty(title)) { | |
205 | 211 | ContentResolver contentResolver = context.getContentResolver(); |
206 | 212 | final String selection = NoteStore.Note.Columns.TITLE + " = ? " |
207 | - + " AND " | |
208 | - + NoteStore.Note.Columns.ENABLED + " = ? "; | |
209 | - final String[] selectionArgs = new String[] | |
210 | - { | |
213 | + + " AND " | |
214 | + + NoteStore.Note.Columns.ENABLED + " = ? "; | |
215 | + final String[] selectionArgs = new String[]{ | |
211 | 216 | title, |
212 | 217 | "1" |
213 | 218 | }; |
214 | 219 | Cursor cursor = contentResolver.query(NoteStore.Note.CONTENT_URI, null, |
215 | - selection, selectionArgs, null); | |
216 | - if (cursor != null) | |
217 | - { | |
218 | - try | |
219 | - { | |
220 | - if (cursor.moveToFirst()) | |
221 | - { | |
220 | + selection, selectionArgs, null); | |
221 | + if (cursor != null) { | |
222 | + try { | |
223 | + if (cursor.moveToFirst()) { | |
222 | 224 | int idColumnIndex = cursor.getColumnIndex(NoteStore.Note.Columns._ID); |
223 | 225 | long noteId = cursor.getLong(idColumnIndex); |
224 | 226 | result = ContentUris.withAppendedId(NoteStore.Note.CONTENT_URI, noteId); |
225 | 227 | } |
226 | - } | |
227 | - finally | |
228 | - { | |
228 | + } finally { | |
229 | 229 | cursor.close(); |
230 | 230 | } |
231 | 231 | } |
@@ -235,12 +235,10 @@ public class NoteUtils implements NotepadConstants | ||
235 | 235 | return result; |
236 | 236 | } |
237 | 237 | |
238 | - public static String expandTemplate(String template, Map<String, String> templateContextMap) | |
239 | - { | |
238 | + public static String expandTemplate(String template, Map<String, String> templateContextMap) { | |
240 | 239 | String text = template; |
241 | 240 | |
242 | - for (String key : templateContextMap.keySet()) | |
243 | - { | |
241 | + for (String key : templateContextMap.keySet()) { | |
244 | 242 | String value = templateContextMap.get(key); |
245 | 243 | Log.d(LOG_TAG, "key => " + key); |
246 | 244 | Log.d(LOG_TAG, "value => " + value); |
@@ -251,4 +249,34 @@ public class NoteUtils implements NotepadConstants | ||
251 | 249 | |
252 | 250 | return text; |
253 | 251 | } |
252 | + | |
253 | + private static Note loadNoteData(Context context, Uri noteUri) { | |
254 | + Note note = null; | |
255 | + | |
256 | + Log.v(LOG_TAG, "Hello"); | |
257 | + Log.d(LOG_TAG, "noteUri => " + noteUri); | |
258 | + | |
259 | + if (NoteStore.isNoteItemUri(context, noteUri)) { | |
260 | + ContentResolver contentResolver = context.getContentResolver(); | |
261 | + Cursor cursor = contentResolver.query(noteUri, null, null, null, null); | |
262 | + if (cursor != null) { | |
263 | + try { | |
264 | + if (cursor.moveToFirst()) { | |
265 | + int titleIndex = cursor.getColumnIndex(NoteStore.Note.Columns.TITLE); | |
266 | + int contentIndex = cursor.getColumnIndex(NoteStore.Note.Columns.CONTENT); | |
267 | + String noteTitle = cursor.getString(titleIndex); | |
268 | + String noteContent = cursor.getString(contentIndex); | |
269 | + note = new Note(); | |
270 | + note.setTitle(noteTitle); | |
271 | + note.setContent(noteContent); | |
272 | + } | |
273 | + } finally { | |
274 | + cursor.close(); | |
275 | + } | |
276 | + } | |
277 | + } | |
278 | + | |
279 | + Log.v(LOG_TAG, "Bye"); | |
280 | + return note; | |
281 | + } | |
254 | 282 | } |
@@ -32,17 +32,24 @@ | ||
32 | 32 | <pluginManagement> |
33 | 33 | <plugins> |
34 | 34 | <plugin> |
35 | + <!-- | |
35 | 36 | <groupId>com.jayway.maven.plugins.android.generation2</groupId> |
36 | 37 | <artifactId>android-maven-plugin</artifactId> |
37 | - <version>3.8.2</version> | |
38 | + <version>3.9.0-rc.3</version> | |
39 | + --> | |
40 | + <groupId>com.simpligility.maven.plugins</groupId> | |
41 | + <artifactId>android-maven-plugin</artifactId> | |
42 | + <version>4.4.1</version> <!-- use latest release --> | |
43 | + <extensions>true</extensions> | |
38 | 44 | <dependencies> |
39 | 45 | <dependency> |
40 | 46 | <groupId>net.sf.proguard</groupId> |
41 | 47 | <artifactId>proguard-base</artifactId> |
42 | - <version>4.11</version> | |
48 | + <version>5.2.1</version> | |
43 | 49 | </dependency> |
44 | 50 | </dependencies> |
45 | 51 | </plugin> |
52 | + | |
46 | 53 | |
47 | 54 | <!-- mvn compile --> |
48 | 55 | <plugin> |