From 0cd1b2d41544ad3e0529f5de67d930420f597e64 Mon Sep 17 00:00:00 2001 From: elelcode Date: Tue, 21 Apr 2026 01:13:56 +0800 Subject: [PATCH 01/17] chore(.gitignore):update .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 7df8dff5..e8bbb61c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ project.properties .settings/ .classpath .project + +# Local agent workspace +.codex +.codex/ From 45923305ad3ed48e5fd23344a2a0f4509e2118f3 Mon Sep 17 00:00:00 2001 From: elelcode Date: Tue, 21 Apr 2026 01:19:00 +0800 Subject: [PATCH 02/17] chore(.gitignore): update .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e8bbb61c..85f97eb0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ project.properties # Local agent workspace .codex .codex/ + +# Local agent instructions +AGENT.md From effd827b4c942164b16af13f7f4c4b4daa228469 Mon Sep 17 00:00:00 2001 From: elel-code Date: Tue, 21 Apr 2026 23:12:09 +0800 Subject: [PATCH 03/17] add export and change share behavior * feat(export): add export to txt * feat(export):Add "Generate Long Image" * feat(share):Added a title for the share panel and a prompt message for when no shareable apps are available. * fix(export): fix export empty txt or long image --- res/menu/call_note_edit.xml | 8 + res/menu/note_edit.xml | 10 +- res/values-zh-rCN/strings.xml | 9 + res/values-zh-rTW/strings.xml | 9 + res/values/strings.xml | 9 + src/net/micode/notes/ui/NoteEditActivity.java | 416 +++++++++++++++++- 6 files changed, 457 insertions(+), 4 deletions(-) diff --git a/res/menu/call_note_edit.xml b/res/menu/call_note_edit.xml index 02c05280..25d42dbb 100644 --- a/res/menu/call_note_edit.xml +++ b/res/menu/call_note_edit.xml @@ -34,6 +34,14 @@ android:id="@+id/menu_share" android:title="@string/menu_share"/> + + + + diff --git a/res/menu/note_edit.xml b/res/menu/note_edit.xml index 35cacd14..ccc38f78 100644 --- a/res/menu/note_edit.xml +++ b/res/menu/note_edit.xml @@ -38,6 +38,14 @@ android:id="@+id/menu_share" android:title="@string/menu_share"/> + + + + @@ -49,4 +57,4 @@ - \ No newline at end of file + diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 09f75ed9..63f71cfd 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -60,6 +60,9 @@ 修改文件夹名称 文件夹 %1$s 已存在,请重新命名 分享 + 分享便签 + 导出为 TXT + 生成长图 发送到桌面 提醒我 删除提醒 @@ -74,10 +77,16 @@ SD卡被占用,不能操作 导出文本时发生错误,请检查SD卡 + 没有可用于分享便签的应用 + 存储权限被拒绝 + 存储权限被拒绝,无法导出 + 保存图片失败 要查看的便签不存在 + 空便签无法导出 不能为空便签设置闹钟提醒 不能将空便签发送到桌面 导出成功 + 已保存到相册 导出失败 已将文本文件(%1$s)输出至SD卡(%2$s)目录 diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 3c418945..3b866d15 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -61,6 +61,9 @@ 修改文件夾名稱 文件夾 %1$s 已存在,請重新命名 分享 + 分享便簽 + 導出為 TXT + 生成長圖 發送到桌面 提醒我 刪除提醒 @@ -73,10 +76,16 @@ 確認刪除檔夾及所包含的便簽嗎? SD卡被佔用,不能操作 導出TXT時發生錯誤,請檢查SD卡 + 沒有可用於分享便簽的應用 + 儲存權限被拒絕 + 儲存權限被拒絕,無法導出 + 保存圖片失敗 要查看的便籤不存在 + 空白便簽無法導出 不能爲空便籤設置鬧鐘提醒 不能將空便籤發送到桌面 導出成功 + 已保存到相冊 導出失敗 已將文本文件(%1$s)導出至SD(%2$s)目錄 diff --git a/res/values/strings.xml b/res/values/strings.xml index 55df8682..85c41d6b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -64,6 +64,9 @@ Change folder name The folder %1$s exist, please rename Share + Share note + Export as TXT + Generate long image Send to home Remind me Delete reminder @@ -78,10 +81,16 @@ SD card busy, not available now Export failed, please check SD card + No app available to share this note + Storage permission denied + Storage permission denied, export unavailable + Save image failed The note is not exist + Cannot export an empty note Sorry, can not set clock on empty note Sorry, can not send and empty note to home Export successful + Image saved to gallery Export fail Export text file (%1$s) to SD (%2$s) directory diff --git a/src/net/micode/notes/ui/NoteEditActivity.java b/src/net/micode/notes/ui/NoteEditActivity.java index 96a9ff89..e4b62f8a 100644 --- a/src/net/micode/notes/ui/NoteEditActivity.java +++ b/src/net/micode/notes/ui/NoteEditActivity.java @@ -22,17 +22,31 @@ import android.app.PendingIntent; import android.app.SearchManager; import android.appwidget.AppWidgetManager; +import android.content.ActivityNotFoundException; import android.content.ContentUris; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.pm.PackageManager; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; import android.content.SharedPreferences; import android.graphics.Paint; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; +import android.os.Environment; import android.preference.PreferenceManager; +import android.text.Layout; import android.text.Spannable; import android.text.SpannableString; +import android.text.StaticLayout; +import android.text.TextPaint; import android.text.TextUtils; +import android.text.format.DateFormat; import android.text.format.DateUtils; import android.text.style.BackgroundColorSpan; import android.util.Log; @@ -65,6 +79,12 @@ import net.micode.notes.widget.NoteWidgetProvider_2x; import net.micode.notes.widget.NoteWidgetProvider_4x; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -140,6 +160,14 @@ private class HeadViewHolder { private static final String PREFERENCE_FONT_SIZE = "pref_font_size"; private static final int SHORTCUT_ICON_TITLE_MAX_LEN = 10; + private static final int REQUEST_CODE_WRITE_EXTERNAL_STORAGE = 1001; + private static final int RUNTIME_PERMISSION_API_LEVEL = 23; + private static final int STORAGE_ACTION_NONE = 0; + private static final int STORAGE_ACTION_EXPORT_AS_TXT = 1; + private static final int STORAGE_ACTION_SAVE_LONG_IMAGE = 2; + private static final int LONG_IMAGE_HORIZONTAL_PADDING_DP = 24; + private static final int LONG_IMAGE_VERTICAL_PADDING_DP = 32; + private static final int LONG_IMAGE_MIN_HEIGHT_DP = 240; public static final String TAG_CHECKED = String.valueOf('\u221A'); public static final String TAG_UNCHECKED = String.valueOf('\u25A1'); @@ -148,6 +176,7 @@ private class HeadViewHolder { private String mUserQuery; private Pattern mPattern; + private int mPendingStorageAction = STORAGE_ACTION_NONE; @Override protected void onCreate(Bundle savedInstanceState) { @@ -535,8 +564,13 @@ public void onClick(DialogInterface dialog, int which) { TextNote.MODE_CHECK_LIST : 0); break; case R.id.menu_share: - getWorkingText(); - sendTo(this, mWorkingNote.getContent()); + shareCurrentNote(); + break; + case R.id.menu_export_as_txt: + exportCurrentNoteAsTxt(); + break; + case R.id.menu_generate_long_image: + saveCurrentNoteAsLongImage(); break; case R.id.menu_send_to_desktop: sendToDesktop(); @@ -567,11 +601,116 @@ public void OnDateTimeSet(AlertDialog dialog, long date) { * Share note to apps that support {@link Intent#ACTION_SEND} action * and {@text/plain} type */ + private void shareCurrentNote() { + sendTo(this, getCurrentNoteTextForShare()); + } + private void sendTo(Context context, String info) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, info); + intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)); intent.setType("text/plain"); - context.startActivity(intent); + try { + context.startActivity(Intent.createChooser(intent, + getString(R.string.share_note_chooser_title))); + } catch (ActivityNotFoundException e) { + Log.e(TAG, "Share note failed", e); + showToast(R.string.error_no_share_app); + } + } + + private void exportCurrentNoteAsTxt() { + ensureStoragePermissionAndRun(STORAGE_ACTION_EXPORT_AS_TXT); + } + + private void saveCurrentNoteAsLongImage() { + ensureStoragePermissionAndRun(STORAGE_ACTION_SAVE_LONG_IMAGE); + } + + private void ensureStoragePermissionAndRun(int storageAction) { + if (TextUtils.isEmpty(getCurrentNoteTextForExport().trim())) { + showToast(R.string.error_note_empty_for_export); + return; + } + + if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { + showToast(R.string.error_sdcard_unmounted); + return; + } + + mPendingStorageAction = storageAction; + if (needsWriteStoragePermission()) { + requestWriteStoragePermission(); + return; + } + + handlePendingStorageAction(); + } + + private void handlePendingStorageAction() { + int storageAction = mPendingStorageAction; + mPendingStorageAction = STORAGE_ACTION_NONE; + switch (storageAction) { + case STORAGE_ACTION_EXPORT_AS_TXT: + doExportCurrentNoteAsTxt(); + break; + case STORAGE_ACTION_SAVE_LONG_IMAGE: + doSaveCurrentNoteAsLongImage(); + break; + default: + break; + } + } + + private void doExportCurrentNoteAsTxt() { + final String noteText = getCurrentNoteTextForExport(); + new AsyncTask() { + @Override + protected Boolean doInBackground(Void... params) { + return writeNoteTextToDownload(noteText); + } + + @Override + protected void onPostExecute(Boolean exported) { + showToast(exported ? R.string.success_sdcard_export : R.string.error_sdcard_export); + } + }.execute(); + } + + private boolean needsWriteStoragePermission() { + return Build.VERSION.SDK_INT >= RUNTIME_PERMISSION_API_LEVEL + && checkCallingOrSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED; + } + + private void requestWriteStoragePermission() { + try { + Method requestPermissions = Activity.class.getMethod("requestPermissions", + String[].class, Integer.TYPE); + requestPermissions.invoke(this, new Object[] { + new String[] { + android.Manifest.permission.WRITE_EXTERNAL_STORAGE + }, + REQUEST_CODE_WRITE_EXTERNAL_STORAGE + }); + } catch (Exception e) { + Log.e(TAG, "Request storage permission failed", e); + mPendingStorageAction = STORAGE_ACTION_NONE; + showToast(R.string.error_storage_permission_denied); + } + } + + public void onRequestPermissionsResult(int requestCode, String[] permissions, + int[] grantResults) { + if (requestCode == REQUEST_CODE_WRITE_EXTERNAL_STORAGE) { + if (grantResults.length > 0 + && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + handlePendingStorageAction(); + } else { + mPendingStorageAction = STORAGE_ACTION_NONE; + showToast(R.string.error_storage_permission_denied); + } + } } private void createNewNote() { @@ -805,6 +944,277 @@ private boolean getWorkingText() { return hasChecked; } + private String getCurrentNoteTextForExport() { + if (mWorkingNote.getCheckListMode() != TextNote.MODE_CHECK_LIST) { + return mNoteEditor.getText().toString(); + } + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < mEditTextList.getChildCount(); i++) { + View view = mEditTextList.getChildAt(i); + NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); + CharSequence itemText = edit.getText(); + if (!TextUtils.isEmpty(itemText)) { + if (sb.length() > 0) { + sb.append('\n'); + } + sb.append(itemText); + } + } + return sb.toString(); + } + + private String getCurrentNoteTextForShare() { + if (mWorkingNote.getCheckListMode() != TextNote.MODE_CHECK_LIST) { + return mNoteEditor.getText().toString(); + } + return getCurrentNoteTextForLongImage(); + } + + private String getCurrentNoteTextForLongImage() { + if (mWorkingNote.getCheckListMode() != TextNote.MODE_CHECK_LIST) { + return mNoteEditor.getText().toString(); + } + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < mEditTextList.getChildCount(); i++) { + View view = mEditTextList.getChildAt(i); + NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); + CharSequence itemText = edit.getText(); + if (!TextUtils.isEmpty(itemText)) { + if (sb.length() > 0) { + sb.append('\n'); + } + sb.append(((CheckBox) view.findViewById(R.id.cb_edit_item)).isChecked() + ? TAG_CHECKED : TAG_UNCHECKED) + .append(" ") + .append(itemText); + } + } + return sb.toString(); + } + + private void doSaveCurrentNoteAsLongImage() { + final String noteText = getCurrentNoteTextForLongImage(); + final float textSize = getCurrentEditorTextSize(); + final int backgroundResId = mWorkingNote.getBgColorResId(); + final int imageWidth = getLongImageWidth(); + + new AsyncTask() { + @Override + protected File doInBackground(Void... params) { + Bitmap bitmap = createLongImageBitmap(noteText, textSize, backgroundResId, + imageWidth); + return saveLongImageBitmap(bitmap); + } + + @Override + protected void onPostExecute(File imageFile) { + if (imageFile != null) { + notifyGallery(imageFile); + showToast(R.string.success_long_image_saved); + } else { + showToast(R.string.error_long_image_save_failed); + } + } + }.execute(); + } + + private float getCurrentEditorTextSize() { + if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST + && mEditTextList.getChildCount() > 0) { + NoteEditText edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById( + R.id.et_edit_text); + if (edit != null && edit.getTextSize() > 0) { + return edit.getTextSize(); + } + } + return mNoteEditor.getTextSize() > 0 ? mNoteEditor.getTextSize() : spToPx(18); + } + + private int getLongImageWidth() { + int width = getResources().getDisplayMetrics().widthPixels; + return width > 0 ? width : dpToPx(360); + } + + private Bitmap createLongImageBitmap(String noteText, float textSize, int backgroundResId, + int imageWidth) { + try { + String content = TextUtils.isEmpty(noteText) ? " " : noteText; + int horizontalPadding = dpToPx(LONG_IMAGE_HORIZONTAL_PADDING_DP); + int verticalPadding = dpToPx(LONG_IMAGE_VERTICAL_PADDING_DP); + int contentWidth = Math.max(imageWidth - horizontalPadding * 2, dpToPx(160)); + + TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + textPaint.setColor(Color.rgb(51, 51, 51)); + textPaint.setTextSize(textSize > 0 ? textSize : spToPx(18)); + + StaticLayout layout = new StaticLayout(content, textPaint, contentWidth, + Layout.Alignment.ALIGN_NORMAL, 1.4f, dpToPx(4), false); + int imageHeight = Math.max(layout.getHeight() + verticalPadding * 2, + dpToPx(LONG_IMAGE_MIN_HEIGHT_DP)); + + Bitmap bitmap = Bitmap.createBitmap(imageWidth, imageHeight, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + drawLongImageBackground(canvas, backgroundResId, imageWidth, imageHeight); + canvas.save(); + canvas.translate(horizontalPadding, verticalPadding); + layout.draw(canvas); + canvas.restore(); + return bitmap; + } catch (OutOfMemoryError e) { + Log.e(TAG, "Create long image bitmap failed", e); + return null; + } + } + + private void drawLongImageBackground(Canvas canvas, int backgroundResId, int width, + int height) { + try { + Drawable background = getResources().getDrawable(backgroundResId); + if (background != null) { + background.setBounds(0, 0, width, height); + background.draw(canvas); + return; + } + } catch (Exception e) { + Log.e(TAG, "Draw long image background failed", e); + } + canvas.drawColor(Color.WHITE); + } + + private File saveLongImageBitmap(Bitmap bitmap) { + if (bitmap == null) { + return null; + } + + File imageFile = createLongImageFile(); + if (imageFile == null) { + bitmap.recycle(); + return null; + } + + FileOutputStream fos = null; + try { + fos = new FileOutputStream(imageFile); + if (!bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos)) { + imageFile.delete(); + return null; + } + fos.flush(); + return imageFile; + } catch (IOException e) { + Log.e(TAG, "Save long image bitmap failed", e); + imageFile.delete(); + return null; + } finally { + bitmap.recycle(); + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + Log.e(TAG, "Close image output stream failed", e); + } + } + } + } + + private File createLongImageFile() { + File picturesDir = Environment.getExternalStoragePublicDirectory( + Environment.DIRECTORY_PICTURES); + if (picturesDir == null) { + Log.e(TAG, "Pictures directory is null"); + return null; + } + + File notesDir = new File(picturesDir, "Notes"); + if (!notesDir.exists() && !notesDir.mkdirs()) { + Log.e(TAG, "Create image export directory failed: " + notesDir.getAbsolutePath()); + return null; + } + + File imageFile = new File(notesDir, "note_long_image_" + + DateFormat.format("yyyyMMdd_HHmmss", System.currentTimeMillis()) + ".png"); + try { + if (!imageFile.exists() && !imageFile.createNewFile()) { + Log.e(TAG, "Create image file failed: " + imageFile.getAbsolutePath()); + return null; + } + } catch (IOException e) { + Log.e(TAG, "Create image file failed", e); + return null; + } + return imageFile; + } + + private void notifyGallery(File imageFile) { + Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + intent.setData(Uri.fromFile(imageFile)); + sendBroadcast(intent); + } + + private int dpToPx(int dp) { + return (int) (dp * getResources().getDisplayMetrics().density + 0.5f); + } + + private float spToPx(int sp) { + return sp * getResources().getDisplayMetrics().scaledDensity; + } + + private boolean writeNoteTextToDownload(String noteText) { + File exportFile = createTxtExportFile(); + if (exportFile == null) { + return false; + } + + BufferedWriter writer = null; + try { + writer = new BufferedWriter(new OutputStreamWriter( + new FileOutputStream(exportFile), "UTF-8")); + writer.write(noteText == null ? "" : noteText); + writer.flush(); + return true; + } catch (IOException e) { + Log.e(TAG, "Export note as txt failed", e); + return false; + } finally { + if (writer != null) { + try { + writer.close(); + } catch (IOException e) { + Log.e(TAG, "Close txt writer failed", e); + } + } + } + } + + private File createTxtExportFile() { + File downloadDir = Environment.getExternalStoragePublicDirectory( + Environment.DIRECTORY_DOWNLOADS); + if (downloadDir == null) { + Log.e(TAG, "Download directory is null"); + return null; + } + + if (!downloadDir.exists() && !downloadDir.mkdirs()) { + Log.e(TAG, "Create download directory failed: " + downloadDir.getAbsolutePath()); + return null; + } + + File exportFile = new File(downloadDir, "note_" + + DateFormat.format("yyyyMMdd_HHmmss", System.currentTimeMillis()) + ".txt"); + try { + if (!exportFile.exists() && !exportFile.createNewFile()) { + Log.e(TAG, "Create txt export file failed: " + exportFile.getAbsolutePath()); + return null; + } + } catch (IOException e) { + Log.e(TAG, "Create txt export file failed", e); + return null; + } + return exportFile; + } + private boolean saveNote() { getWorkingText(); boolean saved = mWorkingNote.saveNote(); From 439d566806f27821bb0c765d80369896529d16c7 Mon Sep 17 00:00:00 2001 From: elel-code Date: Tue, 21 Apr 2026 23:13:15 +0800 Subject: [PATCH 04/17] add search box * feat(search):add search box * feat(search): Supports passing in selection conditions * feat(keyword):Add "Keyword Highlighting" --- res/layout/note_list.xml | 14 ++ .../micode/notes/ui/NotesListActivity.java | 160 +++++++++++++++++- src/net/micode/notes/ui/NotesListAdapter.java | 8 +- src/net/micode/notes/ui/NotesListItem.java | 47 ++++- 4 files changed, 212 insertions(+), 17 deletions(-) diff --git a/res/layout/note_list.xml b/res/layout/note_list.xml index 6b25d38f..5bb16aea 100644 --- a/res/layout/note_list.xml +++ b/res/layout/note_list.xml @@ -37,6 +37,20 @@ android:textColor="#FFEAD1AE" android:textSize="@dimen/text_font_size_medium" /> + + mSelectedIndex; private int mNotesCount; private boolean mChoiceMode; + private String mSearchText; public static class AppWidgetAttribute { public int widgetId; @@ -48,6 +49,7 @@ public NotesListAdapter(Context context) { mSelectedIndex = new HashMap(); mContext = context; mNotesCount = 0; + mSearchText = ""; } @Override @@ -60,10 +62,14 @@ public void bindView(View view, Context context, Cursor cursor) { if (view instanceof NotesListItem) { NoteItemData itemData = new NoteItemData(context, cursor); ((NotesListItem) view).bind(context, itemData, mChoiceMode, - isSelectedItem(cursor.getPosition())); + isSelectedItem(cursor.getPosition()), mSearchText); } } + public void setSearchText(String searchText) { + mSearchText = searchText; + } + public void setCheckedItem(final int position, final boolean checked) { mSelectedIndex.put(position, checked); notifyDataSetChanged(); diff --git a/src/net/micode/notes/ui/NotesListItem.java b/src/net/micode/notes/ui/NotesListItem.java index 1221e808..43992b4e 100644 --- a/src/net/micode/notes/ui/NotesListItem.java +++ b/src/net/micode/notes/ui/NotesListItem.java @@ -17,6 +17,10 @@ package net.micode.notes.ui; import android.content.Context; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.TextUtils; +import android.text.style.BackgroundColorSpan; import android.text.format.DateUtils; import android.view.View; import android.widget.CheckBox; @@ -29,6 +33,8 @@ import net.micode.notes.tool.DataUtils; import net.micode.notes.tool.ResourceParser.NoteItemBgResources; +import java.util.Locale; + public class NotesListItem extends LinearLayout { private ImageView mAlert; @@ -48,7 +54,8 @@ public NotesListItem(Context context) { mCheckBox = (CheckBox) findViewById(android.R.id.checkbox); } - public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) { + public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked, + String searchText) { if (choiceMode && data.getType() == Notes.TYPE_NOTE) { mCheckBox.setVisibility(View.VISIBLE); mCheckBox.setChecked(checked); @@ -61,14 +68,18 @@ public void bind(Context context, NoteItemData data, boolean choiceMode, boolean mCallName.setVisibility(View.GONE); mAlert.setVisibility(View.VISIBLE); mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem); - mTitle.setText(context.getString(R.string.call_record_folder_name) - + context.getString(R.string.format_folder_files_count, data.getNotesCount())); + mTitle.setText(getHighlightedText(context, + context.getString(R.string.call_record_folder_name) + + context.getString(R.string.format_folder_files_count, + data.getNotesCount()), + searchText)); mAlert.setImageResource(R.drawable.call_record); } else if (data.getParentId() == Notes.ID_CALL_RECORD_FOLDER) { mCallName.setVisibility(View.VISIBLE); mCallName.setText(data.getCallName()); mTitle.setTextAppearance(context,R.style.TextAppearanceSecondaryItem); - mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet())); + mTitle.setText(getHighlightedText(context, + DataUtils.getFormattedSnippet(data.getSnippet()), searchText)); if (data.hasAlert()) { mAlert.setImageResource(R.drawable.clock); mAlert.setVisibility(View.VISIBLE); @@ -80,12 +91,14 @@ public void bind(Context context, NoteItemData data, boolean choiceMode, boolean mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem); if (data.getType() == Notes.TYPE_FOLDER) { - mTitle.setText(data.getSnippet() - + context.getString(R.string.format_folder_files_count, - data.getNotesCount())); + mTitle.setText(getHighlightedText(context, + data.getSnippet() + context.getString(R.string.format_folder_files_count, + data.getNotesCount()), + searchText)); mAlert.setVisibility(View.GONE); } else { - mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet())); + mTitle.setText(getHighlightedText(context, + DataUtils.getFormattedSnippet(data.getSnippet()), searchText)); if (data.hasAlert()) { mAlert.setImageResource(R.drawable.clock); mAlert.setVisibility(View.VISIBLE); @@ -119,4 +132,22 @@ private void setBackground(NoteItemData data) { public NoteItemData getItemData() { return mItemData; } + + private CharSequence getHighlightedText(Context context, String fullText, String query) { + SpannableString spannable = new SpannableString(fullText == null ? "" : fullText); + if (TextUtils.isEmpty(fullText) || TextUtils.isEmpty(query)) { + return spannable; + } + + String lowerText = fullText.toLowerCase(Locale.getDefault()); + String lowerQuery = query.toLowerCase(Locale.getDefault()); + int start = lowerText.indexOf(lowerQuery); + while (start >= 0) { + spannable.setSpan(new BackgroundColorSpan(context.getResources().getColor( + R.color.user_query_highlight)), start, start + query.length(), + Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + start = lowerText.indexOf(lowerQuery, start + query.length()); + } + return spannable; + } } From 1be1e3b3443159bf3e16050ab21fccc322f96338 Mon Sep 17 00:00:00 2001 From: elelcode Date: Wed, 22 Apr 2026 16:24:07 +0800 Subject: [PATCH 05/17] refactor(gradle):Migrating to Gradle --- .gitignore | 4 + app/build.gradle | 35 +++++++ app/proguard-rules.pro | 1 + .../src/main/AndroidManifest.xml | 21 ++-- .../java}/net/micode/notes/data/Contact.java | 0 .../java}/net/micode/notes/data/Notes.java | 0 .../notes/data/NotesDatabaseHelper.java | 0 .../net/micode/notes/data/NotesProvider.java | 0 .../net/micode/notes/gtask/data/MetaData.java | 0 .../net/micode/notes/gtask/data/Node.java | 0 .../net/micode/notes/gtask/data/SqlData.java | 0 .../net/micode/notes/gtask/data/SqlNote.java | 0 .../net/micode/notes/gtask/data/Task.java | 0 .../net/micode/notes/gtask/data/TaskList.java | 0 .../exception/ActionFailureException.java | 0 .../exception/NetworkFailureException.java | 0 .../notes/gtask/remote/GTaskASyncTask.java | 62 ++++++++--- .../notes/gtask/remote/GTaskClient.java | 0 .../notes/gtask/remote/GTaskManager.java | 0 .../notes/gtask/remote/GTaskSyncService.java | 0 .../java}/net/micode/notes/model/Note.java | 0 .../net/micode/notes/model/WorkingNote.java | 0 .../net/micode/notes/tool/BackupUtils.java | 0 .../net/micode/notes/tool/DataUtils.java | 0 .../micode/notes/tool/GTaskStringUtils.java | 0 .../notes/tool/PendingIntentCompat.java | 37 +++++++ .../net/micode/notes/tool/ResourceParser.java | 0 .../micode/notes/ui/AlarmAlertActivity.java | 0 .../micode/notes/ui/AlarmInitReceiver.java | 4 +- .../net/micode/notes/ui/AlarmReceiver.java | 0 .../net/micode/notes/ui/DateTimePicker.java | 0 .../micode/notes/ui/DateTimePickerDialog.java | 0 .../net/micode/notes/ui/DropdownMenu.java | 0 .../micode/notes/ui/FoldersListAdapter.java | 0 .../net/micode/notes/ui/NoteEditActivity.java | 86 +++++++--------- .../net/micode/notes/ui/NoteEditText.java | 0 .../net/micode/notes/ui/NoteItemData.java | 0 .../micode/notes/ui/NotesListActivity.java | 97 +++++++----------- .../net/micode/notes/ui/NotesListAdapter.java | 0 .../net/micode/notes/ui/NotesListItem.java | 0 .../notes/ui/NotesPreferenceActivity.java | 0 .../notes/widget/NoteWidgetProvider.java | 6 +- .../notes/widget/NoteWidgetProvider_2x.java | 0 .../notes/widget/NoteWidgetProvider_4x.java | 0 .../src/main/res}/color/primary_text_dark.xml | 0 .../main/res}/color/secondary_text_dark.xml | 0 .../res}/drawable-hdpi/bg_btn_set_color.png | Bin .../res}/drawable-hdpi/bg_color_btn_mask.png | Bin .../main/res}/drawable-hdpi/call_record.png | Bin .../src/main/res}/drawable-hdpi/clock.png | Bin .../src/main/res}/drawable-hdpi/delete.png | Bin .../res}/drawable-hdpi/dropdown_icon.9.png | Bin .../main/res}/drawable-hdpi/edit_blue.9.png | Bin .../main/res}/drawable-hdpi/edit_green.9.png | Bin .../main/res}/drawable-hdpi/edit_red.9.png | Bin .../res}/drawable-hdpi/edit_title_blue.9.png | Bin .../res}/drawable-hdpi/edit_title_green.9.png | Bin .../res}/drawable-hdpi/edit_title_red.9.png | Bin .../res}/drawable-hdpi/edit_title_white.9.png | Bin .../drawable-hdpi/edit_title_yellow.9.png | Bin .../main/res}/drawable-hdpi/edit_white.9.png | Bin .../main/res}/drawable-hdpi/edit_yellow.9.png | Bin .../main/res}/drawable-hdpi/font_large.png | Bin .../main/res}/drawable-hdpi/font_normal.png | Bin .../drawable-hdpi/font_size_selector_bg.9.png | Bin .../main/res}/drawable-hdpi/font_small.png | Bin .../main/res}/drawable-hdpi/font_super.png | Bin .../src/main/res}/drawable-hdpi/icon_app.png | Bin .../res}/drawable-hdpi/list_background.png | Bin .../res}/drawable-hdpi/list_blue_down.9.png | Bin .../res}/drawable-hdpi/list_blue_middle.9.png | Bin .../res}/drawable-hdpi/list_blue_single.9.png | Bin .../res}/drawable-hdpi/list_blue_up.9.png | Bin .../main/res}/drawable-hdpi/list_folder.9.png | Bin .../res}/drawable-hdpi/list_footer_bg.9.png | Bin .../res}/drawable-hdpi/list_green_down.9.png | Bin .../drawable-hdpi/list_green_middle.9.png | Bin .../drawable-hdpi/list_green_single.9.png | Bin .../res}/drawable-hdpi/list_green_up.9.png | Bin .../res}/drawable-hdpi/list_red_down.9.png | Bin .../res}/drawable-hdpi/list_red_middle.9.png | Bin .../res}/drawable-hdpi/list_red_single.9.png | Bin .../main/res}/drawable-hdpi/list_red_up.9.png | Bin .../res}/drawable-hdpi/list_white_down.9.png | Bin .../drawable-hdpi/list_white_middle.9.png | Bin .../drawable-hdpi/list_white_single.9.png | Bin .../res}/drawable-hdpi/list_white_up.9.png | Bin .../res}/drawable-hdpi/list_yellow_down.9.png | Bin .../drawable-hdpi/list_yellow_middle.9.png | Bin .../drawable-hdpi/list_yellow_single.9.png | Bin .../res}/drawable-hdpi/list_yellow_up.9.png | Bin .../main/res}/drawable-hdpi/menu_delete.png | Bin .../src/main/res}/drawable-hdpi/menu_move.png | Bin .../res}/drawable-hdpi/new_note_normal.png | Bin .../res}/drawable-hdpi/new_note_pressed.png | Bin .../note_edit_color_selector_panel.png | Bin .../main/res}/drawable-hdpi/notification.png | Bin .../main/res}/drawable-hdpi/search_result.png | Bin .../src/main/res}/drawable-hdpi/selected.png | Bin .../main/res}/drawable-hdpi/title_alert.png | Bin .../res}/drawable-hdpi/title_bar_bg.9.png | Bin .../res}/drawable-hdpi/widget_2x_blue.png | Bin .../res}/drawable-hdpi/widget_2x_green.png | Bin .../main/res}/drawable-hdpi/widget_2x_red.png | Bin .../res}/drawable-hdpi/widget_2x_white.png | Bin .../res}/drawable-hdpi/widget_2x_yellow.png | Bin .../res}/drawable-hdpi/widget_4x_blue.png | Bin .../res}/drawable-hdpi/widget_4x_green.png | Bin .../main/res}/drawable-hdpi/widget_4x_red.png | Bin .../res}/drawable-hdpi/widget_4x_white.png | Bin .../res}/drawable-hdpi/widget_4x_yellow.png | Bin .../src/main/res}/drawable/new_note.xml | 0 .../main/res}/layout/account_dialog_title.xml | 0 .../src/main/res}/layout/add_account_text.xml | 0 .../src/main/res}/layout/datetime_picker.xml | 0 .../src/main/res}/layout/dialog_edit_text.xml | 0 .../src/main/res}/layout/folder_list_item.xml | 0 .../src/main/res}/layout/note_edit.xml | 0 .../main/res}/layout/note_edit_list_item.xml | 0 .../src/main/res}/layout/note_item.xml | 0 .../src/main/res}/layout/note_list.xml | 0 .../res}/layout/note_list_dropdown_menu.xml | 0 .../src/main/res}/layout/note_list_footer.xml | 0 .../src/main/res}/layout/settings_header.xml | 0 .../src/main/res}/layout/widget_2x.xml | 0 .../src/main/res}/layout/widget_4x.xml | 0 .../src/main/res}/menu/call_note_edit.xml | 0 .../src/main/res}/menu/call_record_folder.xml | 0 {res => app/src/main/res}/menu/note_edit.xml | 0 {res => app/src/main/res}/menu/note_list.xml | 0 .../src/main/res}/menu/note_list_dropdown.xml | 0 .../src/main/res}/menu/note_list_options.xml | 0 {res => app/src/main/res}/menu/sub_folder.xml | 0 .../src/main/res}/raw-zh-rCN/introduction | 0 {res => app/src/main/res}/raw/introduction | 0 .../src/main/res}/values-zh-rCN/arrays.xml | 0 .../src/main/res}/values-zh-rCN/strings.xml | 0 .../src/main/res}/values-zh-rTW/arrays.xml | 0 .../src/main/res}/values-zh-rTW/strings.xml | 0 {res => app/src/main/res}/values/arrays.xml | 0 {res => app/src/main/res}/values/colors.xml | 0 {res => app/src/main/res}/values/dimens.xml | 0 {res => app/src/main/res}/values/strings.xml | 0 {res => app/src/main/res}/values/styles.xml | 0 {res => app/src/main/res}/xml/preferences.xml | 0 {res => app/src/main/res}/xml/searchable.xml | 0 .../src/main/res}/xml/widget_2x_info.xml | 0 .../src/main/res}/xml/widget_4x_info.xml | 0 build.gradle | 3 + settings.gradle | 20 ++++ 150 files changed, 246 insertions(+), 130 deletions(-) create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro rename AndroidManifest.xml => app/src/main/AndroidManifest.xml (92%) rename {src => app/src/main/java}/net/micode/notes/data/Contact.java (100%) rename {src => app/src/main/java}/net/micode/notes/data/Notes.java (100%) rename {src => app/src/main/java}/net/micode/notes/data/NotesDatabaseHelper.java (100%) rename {src => app/src/main/java}/net/micode/notes/data/NotesProvider.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/data/MetaData.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/data/Node.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/data/SqlData.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/data/SqlNote.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/data/Task.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/data/TaskList.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/exception/ActionFailureException.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/exception/NetworkFailureException.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/remote/GTaskASyncTask.java (64%) rename {src => app/src/main/java}/net/micode/notes/gtask/remote/GTaskClient.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/remote/GTaskManager.java (100%) rename {src => app/src/main/java}/net/micode/notes/gtask/remote/GTaskSyncService.java (100%) rename {src => app/src/main/java}/net/micode/notes/model/Note.java (100%) rename {src => app/src/main/java}/net/micode/notes/model/WorkingNote.java (100%) rename {src => app/src/main/java}/net/micode/notes/tool/BackupUtils.java (100%) rename {src => app/src/main/java}/net/micode/notes/tool/DataUtils.java (100%) rename {src => app/src/main/java}/net/micode/notes/tool/GTaskStringUtils.java (100%) create mode 100644 app/src/main/java/net/micode/notes/tool/PendingIntentCompat.java rename {src => app/src/main/java}/net/micode/notes/tool/ResourceParser.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/AlarmAlertActivity.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/AlarmInitReceiver.java (94%) rename {src => app/src/main/java}/net/micode/notes/ui/AlarmReceiver.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/DateTimePicker.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/DateTimePickerDialog.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/DropdownMenu.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/FoldersListAdapter.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/NoteEditActivity.java (95%) rename {src => app/src/main/java}/net/micode/notes/ui/NoteEditText.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/NoteItemData.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/NotesListActivity.java (94%) rename {src => app/src/main/java}/net/micode/notes/ui/NotesListAdapter.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/NotesListItem.java (100%) rename {src => app/src/main/java}/net/micode/notes/ui/NotesPreferenceActivity.java (100%) rename {src => app/src/main/java}/net/micode/notes/widget/NoteWidgetProvider.java (95%) rename {src => app/src/main/java}/net/micode/notes/widget/NoteWidgetProvider_2x.java (100%) rename {src => app/src/main/java}/net/micode/notes/widget/NoteWidgetProvider_4x.java (100%) rename {res => app/src/main/res}/color/primary_text_dark.xml (100%) rename {res => app/src/main/res}/color/secondary_text_dark.xml (100%) rename {res => app/src/main/res}/drawable-hdpi/bg_btn_set_color.png (100%) rename {res => app/src/main/res}/drawable-hdpi/bg_color_btn_mask.png (100%) rename {res => app/src/main/res}/drawable-hdpi/call_record.png (100%) rename {res => app/src/main/res}/drawable-hdpi/clock.png (100%) rename {res => app/src/main/res}/drawable-hdpi/delete.png (100%) rename {res => app/src/main/res}/drawable-hdpi/dropdown_icon.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_blue.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_green.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_red.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_title_blue.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_title_green.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_title_red.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_title_white.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_title_yellow.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_white.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/edit_yellow.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/font_large.png (100%) rename {res => app/src/main/res}/drawable-hdpi/font_normal.png (100%) rename {res => app/src/main/res}/drawable-hdpi/font_size_selector_bg.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/font_small.png (100%) rename {res => app/src/main/res}/drawable-hdpi/font_super.png (100%) rename {res => app/src/main/res}/drawable-hdpi/icon_app.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_background.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_blue_down.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_blue_middle.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_blue_single.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_blue_up.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_folder.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_footer_bg.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_green_down.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_green_middle.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_green_single.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_green_up.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_red_down.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_red_middle.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_red_single.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_red_up.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_white_down.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_white_middle.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_white_single.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_white_up.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_yellow_down.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_yellow_middle.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_yellow_single.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/list_yellow_up.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/menu_delete.png (100%) rename {res => app/src/main/res}/drawable-hdpi/menu_move.png (100%) rename {res => app/src/main/res}/drawable-hdpi/new_note_normal.png (100%) rename {res => app/src/main/res}/drawable-hdpi/new_note_pressed.png (100%) rename {res => app/src/main/res}/drawable-hdpi/note_edit_color_selector_panel.png (100%) rename {res => app/src/main/res}/drawable-hdpi/notification.png (100%) rename {res => app/src/main/res}/drawable-hdpi/search_result.png (100%) rename {res => app/src/main/res}/drawable-hdpi/selected.png (100%) rename {res => app/src/main/res}/drawable-hdpi/title_alert.png (100%) rename {res => app/src/main/res}/drawable-hdpi/title_bar_bg.9.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_2x_blue.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_2x_green.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_2x_red.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_2x_white.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_2x_yellow.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_4x_blue.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_4x_green.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_4x_red.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_4x_white.png (100%) rename {res => app/src/main/res}/drawable-hdpi/widget_4x_yellow.png (100%) rename {res => app/src/main/res}/drawable/new_note.xml (100%) rename {res => app/src/main/res}/layout/account_dialog_title.xml (100%) rename {res => app/src/main/res}/layout/add_account_text.xml (100%) rename {res => app/src/main/res}/layout/datetime_picker.xml (100%) rename {res => app/src/main/res}/layout/dialog_edit_text.xml (100%) rename {res => app/src/main/res}/layout/folder_list_item.xml (100%) rename {res => app/src/main/res}/layout/note_edit.xml (100%) rename {res => app/src/main/res}/layout/note_edit_list_item.xml (100%) rename {res => app/src/main/res}/layout/note_item.xml (100%) rename {res => app/src/main/res}/layout/note_list.xml (100%) rename {res => app/src/main/res}/layout/note_list_dropdown_menu.xml (100%) rename {res => app/src/main/res}/layout/note_list_footer.xml (100%) rename {res => app/src/main/res}/layout/settings_header.xml (100%) rename {res => app/src/main/res}/layout/widget_2x.xml (100%) rename {res => app/src/main/res}/layout/widget_4x.xml (100%) rename {res => app/src/main/res}/menu/call_note_edit.xml (100%) rename {res => app/src/main/res}/menu/call_record_folder.xml (100%) rename {res => app/src/main/res}/menu/note_edit.xml (100%) rename {res => app/src/main/res}/menu/note_list.xml (100%) rename {res => app/src/main/res}/menu/note_list_dropdown.xml (100%) rename {res => app/src/main/res}/menu/note_list_options.xml (100%) rename {res => app/src/main/res}/menu/sub_folder.xml (100%) rename {res => app/src/main/res}/raw-zh-rCN/introduction (100%) rename {res => app/src/main/res}/raw/introduction (100%) rename {res => app/src/main/res}/values-zh-rCN/arrays.xml (100%) rename {res => app/src/main/res}/values-zh-rCN/strings.xml (100%) rename {res => app/src/main/res}/values-zh-rTW/arrays.xml (100%) rename {res => app/src/main/res}/values-zh-rTW/strings.xml (100%) rename {res => app/src/main/res}/values/arrays.xml (100%) rename {res => app/src/main/res}/values/colors.xml (100%) rename {res => app/src/main/res}/values/dimens.xml (100%) rename {res => app/src/main/res}/values/strings.xml (100%) rename {res => app/src/main/res}/values/styles.xml (100%) rename {res => app/src/main/res}/xml/preferences.xml (100%) rename {res => app/src/main/res}/xml/searchable.xml (100%) rename {res => app/src/main/res}/xml/widget_2x_info.xml (100%) rename {res => app/src/main/res}/xml/widget_4x_info.xml (100%) create mode 100644 build.gradle create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore index 85f97eb0..ff3ff8f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,12 @@ # generated files bin/ gen/ +.gradle/ +build/ +app/build/ # Local configuration file (sdk path, etc) +local.properties project.properties .settings/ .classpath diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 00000000..fac39f36 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,35 @@ +plugins { + id 'com.android.application' +} + +android { + namespace 'net.micode.notes' + compileSdk 35 + + defaultConfig { + applicationId "net.micode.notes" + minSdk 14 + targetSdk 29 + versionCode 1 + versionName "0.1" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), + 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + useLibrary 'org.apache.http.legacy' +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 00000000..69dd36cc --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1 @@ +# Project-specific ProGuard rules. diff --git a/AndroidManifest.xml b/app/src/main/AndroidManifest.xml similarity index 92% rename from AndroidManifest.xml rename to app/src/main/AndroidManifest.xml index e5c7d47c..d98d6739 100644 --- a/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,12 +15,7 @@ limitations under the License. --> - - - + @@ -34,10 +29,12 @@ + android:label="@string/app_name" + android:requestLegacyExternalStorage="true" > @@ -87,6 +85,7 @@ @@ -100,6 +99,7 @@ @@ -113,7 +113,9 @@ android:resource="@xml/widget_4x_info" /> - + @@ -121,11 +123,13 @@ @@ -133,6 +137,7 @@ diff --git a/src/net/micode/notes/data/Contact.java b/app/src/main/java/net/micode/notes/data/Contact.java similarity index 100% rename from src/net/micode/notes/data/Contact.java rename to app/src/main/java/net/micode/notes/data/Contact.java diff --git a/src/net/micode/notes/data/Notes.java b/app/src/main/java/net/micode/notes/data/Notes.java similarity index 100% rename from src/net/micode/notes/data/Notes.java rename to app/src/main/java/net/micode/notes/data/Notes.java diff --git a/src/net/micode/notes/data/NotesDatabaseHelper.java b/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java similarity index 100% rename from src/net/micode/notes/data/NotesDatabaseHelper.java rename to app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java diff --git a/src/net/micode/notes/data/NotesProvider.java b/app/src/main/java/net/micode/notes/data/NotesProvider.java similarity index 100% rename from src/net/micode/notes/data/NotesProvider.java rename to app/src/main/java/net/micode/notes/data/NotesProvider.java diff --git a/src/net/micode/notes/gtask/data/MetaData.java b/app/src/main/java/net/micode/notes/gtask/data/MetaData.java similarity index 100% rename from src/net/micode/notes/gtask/data/MetaData.java rename to app/src/main/java/net/micode/notes/gtask/data/MetaData.java diff --git a/src/net/micode/notes/gtask/data/Node.java b/app/src/main/java/net/micode/notes/gtask/data/Node.java similarity index 100% rename from src/net/micode/notes/gtask/data/Node.java rename to app/src/main/java/net/micode/notes/gtask/data/Node.java diff --git a/src/net/micode/notes/gtask/data/SqlData.java b/app/src/main/java/net/micode/notes/gtask/data/SqlData.java similarity index 100% rename from src/net/micode/notes/gtask/data/SqlData.java rename to app/src/main/java/net/micode/notes/gtask/data/SqlData.java diff --git a/src/net/micode/notes/gtask/data/SqlNote.java b/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java similarity index 100% rename from src/net/micode/notes/gtask/data/SqlNote.java rename to app/src/main/java/net/micode/notes/gtask/data/SqlNote.java diff --git a/src/net/micode/notes/gtask/data/Task.java b/app/src/main/java/net/micode/notes/gtask/data/Task.java similarity index 100% rename from src/net/micode/notes/gtask/data/Task.java rename to app/src/main/java/net/micode/notes/gtask/data/Task.java diff --git a/src/net/micode/notes/gtask/data/TaskList.java b/app/src/main/java/net/micode/notes/gtask/data/TaskList.java similarity index 100% rename from src/net/micode/notes/gtask/data/TaskList.java rename to app/src/main/java/net/micode/notes/gtask/data/TaskList.java diff --git a/src/net/micode/notes/gtask/exception/ActionFailureException.java b/app/src/main/java/net/micode/notes/gtask/exception/ActionFailureException.java similarity index 100% rename from src/net/micode/notes/gtask/exception/ActionFailureException.java rename to app/src/main/java/net/micode/notes/gtask/exception/ActionFailureException.java diff --git a/src/net/micode/notes/gtask/exception/NetworkFailureException.java b/app/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java similarity index 100% rename from src/net/micode/notes/gtask/exception/NetworkFailureException.java rename to app/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java diff --git a/src/net/micode/notes/gtask/remote/GTaskASyncTask.java b/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java similarity index 64% rename from src/net/micode/notes/gtask/remote/GTaskASyncTask.java rename to app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java index b3b61e72..b44325c6 100644 --- a/src/net/micode/notes/gtask/remote/GTaskASyncTask.java +++ b/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java @@ -18,20 +18,25 @@ package net.micode.notes.gtask.remote; import android.app.Notification; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.AsyncTask; +import android.os.Build; import net.micode.notes.R; +import net.micode.notes.tool.PendingIntentCompat; import net.micode.notes.ui.NotesListActivity; import net.micode.notes.ui.NotesPreferenceActivity; public class GTaskASyncTask extends AsyncTask { - private static int GTASK_SYNC_NOTIFICATION_ID = 5234235; + private static final int GTASK_SYNC_NOTIFICATION_ID = 5234235; + + private static final String GTASK_SYNC_CHANNEL_ID = "gtask_sync"; public interface OnCompleteListener { void onComplete(); @@ -63,22 +68,53 @@ public void publishProgess(String message) { }); } - private void showNotification(int tickerId, String content) { - Notification notification = new Notification(R.drawable.notification, mContext - .getString(tickerId), System.currentTimeMillis()); - notification.defaults = Notification.DEFAULT_LIGHTS; - notification.flags = Notification.FLAG_AUTO_CANCEL; - PendingIntent pendingIntent; + private void ensureNotificationChannel() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { + return; + } + if (mNotifiManager.getNotificationChannel(GTASK_SYNC_CHANNEL_ID) != null) { + return; + } + NotificationChannel channel = new NotificationChannel(GTASK_SYNC_CHANNEL_ID, + mContext.getString(R.string.app_name), NotificationManager.IMPORTANCE_DEFAULT); + mNotifiManager.createNotificationChannel(channel); + } + + private PendingIntent createNotificationPendingIntent(int tickerId) { + Intent intent; if (tickerId != R.string.ticker_success) { - pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, - NotesPreferenceActivity.class), 0); + intent = new Intent(mContext, NotesPreferenceActivity.class); + } else { + intent = new Intent(mContext, NotesListActivity.class); + } + return PendingIntent.getActivity(mContext, 0, intent, + PendingIntentCompat.updateCurrentImmutableFlag()); + } + + private void showNotification(int tickerId, String content) { + ensureNotificationChannel(); + Notification.Builder builder; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + builder = new Notification.Builder(mContext, GTASK_SYNC_CHANNEL_ID); + } else { + builder = new Notification.Builder(mContext); + } + builder.setSmallIcon(R.drawable.notification) + .setTicker(mContext.getString(tickerId)) + .setWhen(System.currentTimeMillis()) + .setDefaults(Notification.DEFAULT_LIGHTS) + .setAutoCancel(true) + .setContentTitle(mContext.getString(R.string.app_name)) + .setContentText(content) + .setContentIntent(createNotificationPendingIntent(tickerId)); + + Notification notification; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + notification = builder.build(); } else { - pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, - NotesListActivity.class), 0); + notification = builder.getNotification(); } - notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content, - pendingIntent); mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification); } diff --git a/src/net/micode/notes/gtask/remote/GTaskClient.java b/app/src/main/java/net/micode/notes/gtask/remote/GTaskClient.java similarity index 100% rename from src/net/micode/notes/gtask/remote/GTaskClient.java rename to app/src/main/java/net/micode/notes/gtask/remote/GTaskClient.java diff --git a/src/net/micode/notes/gtask/remote/GTaskManager.java b/app/src/main/java/net/micode/notes/gtask/remote/GTaskManager.java similarity index 100% rename from src/net/micode/notes/gtask/remote/GTaskManager.java rename to app/src/main/java/net/micode/notes/gtask/remote/GTaskManager.java diff --git a/src/net/micode/notes/gtask/remote/GTaskSyncService.java b/app/src/main/java/net/micode/notes/gtask/remote/GTaskSyncService.java similarity index 100% rename from src/net/micode/notes/gtask/remote/GTaskSyncService.java rename to app/src/main/java/net/micode/notes/gtask/remote/GTaskSyncService.java diff --git a/src/net/micode/notes/model/Note.java b/app/src/main/java/net/micode/notes/model/Note.java similarity index 100% rename from src/net/micode/notes/model/Note.java rename to app/src/main/java/net/micode/notes/model/Note.java diff --git a/src/net/micode/notes/model/WorkingNote.java b/app/src/main/java/net/micode/notes/model/WorkingNote.java similarity index 100% rename from src/net/micode/notes/model/WorkingNote.java rename to app/src/main/java/net/micode/notes/model/WorkingNote.java diff --git a/src/net/micode/notes/tool/BackupUtils.java b/app/src/main/java/net/micode/notes/tool/BackupUtils.java similarity index 100% rename from src/net/micode/notes/tool/BackupUtils.java rename to app/src/main/java/net/micode/notes/tool/BackupUtils.java diff --git a/src/net/micode/notes/tool/DataUtils.java b/app/src/main/java/net/micode/notes/tool/DataUtils.java similarity index 100% rename from src/net/micode/notes/tool/DataUtils.java rename to app/src/main/java/net/micode/notes/tool/DataUtils.java diff --git a/src/net/micode/notes/tool/GTaskStringUtils.java b/app/src/main/java/net/micode/notes/tool/GTaskStringUtils.java similarity index 100% rename from src/net/micode/notes/tool/GTaskStringUtils.java rename to app/src/main/java/net/micode/notes/tool/GTaskStringUtils.java diff --git a/app/src/main/java/net/micode/notes/tool/PendingIntentCompat.java b/app/src/main/java/net/micode/notes/tool/PendingIntentCompat.java new file mode 100644 index 00000000..ce3bcab3 --- /dev/null +++ b/app/src/main/java/net/micode/notes/tool/PendingIntentCompat.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.micode.notes.tool; + +import android.app.PendingIntent; +import android.os.Build; + +public final class PendingIntentCompat { + + private PendingIntentCompat() { + } + + public static int immutableFlag() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + return PendingIntent.FLAG_IMMUTABLE; + } + return 0; + } + + public static int updateCurrentImmutableFlag() { + return PendingIntent.FLAG_UPDATE_CURRENT | immutableFlag(); + } +} diff --git a/src/net/micode/notes/tool/ResourceParser.java b/app/src/main/java/net/micode/notes/tool/ResourceParser.java similarity index 100% rename from src/net/micode/notes/tool/ResourceParser.java rename to app/src/main/java/net/micode/notes/tool/ResourceParser.java diff --git a/src/net/micode/notes/ui/AlarmAlertActivity.java b/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java similarity index 100% rename from src/net/micode/notes/ui/AlarmAlertActivity.java rename to app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java diff --git a/src/net/micode/notes/ui/AlarmInitReceiver.java b/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java similarity index 94% rename from src/net/micode/notes/ui/AlarmInitReceiver.java rename to app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java index f2212025..1622494d 100644 --- a/src/net/micode/notes/ui/AlarmInitReceiver.java +++ b/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java @@ -26,6 +26,7 @@ import net.micode.notes.data.Notes; import net.micode.notes.data.Notes.NoteColumns; +import net.micode.notes.tool.PendingIntentCompat; public class AlarmInitReceiver extends BroadcastReceiver { @@ -53,7 +54,8 @@ public void onReceive(Context context, Intent intent) { long alertDate = c.getLong(COLUMN_ALERTED_DATE); Intent sender = new Intent(context, AlarmReceiver.class); sender.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, c.getLong(COLUMN_ID))); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, sender, 0); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, sender, + PendingIntentCompat.immutableFlag()); AlarmManager alermManager = (AlarmManager) context .getSystemService(Context.ALARM_SERVICE); alermManager.set(AlarmManager.RTC_WAKEUP, alertDate, pendingIntent); diff --git a/src/net/micode/notes/ui/AlarmReceiver.java b/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java similarity index 100% rename from src/net/micode/notes/ui/AlarmReceiver.java rename to app/src/main/java/net/micode/notes/ui/AlarmReceiver.java diff --git a/src/net/micode/notes/ui/DateTimePicker.java b/app/src/main/java/net/micode/notes/ui/DateTimePicker.java similarity index 100% rename from src/net/micode/notes/ui/DateTimePicker.java rename to app/src/main/java/net/micode/notes/ui/DateTimePicker.java diff --git a/src/net/micode/notes/ui/DateTimePickerDialog.java b/app/src/main/java/net/micode/notes/ui/DateTimePickerDialog.java similarity index 100% rename from src/net/micode/notes/ui/DateTimePickerDialog.java rename to app/src/main/java/net/micode/notes/ui/DateTimePickerDialog.java diff --git a/src/net/micode/notes/ui/DropdownMenu.java b/app/src/main/java/net/micode/notes/ui/DropdownMenu.java similarity index 100% rename from src/net/micode/notes/ui/DropdownMenu.java rename to app/src/main/java/net/micode/notes/ui/DropdownMenu.java diff --git a/src/net/micode/notes/ui/FoldersListAdapter.java b/app/src/main/java/net/micode/notes/ui/FoldersListAdapter.java similarity index 100% rename from src/net/micode/notes/ui/FoldersListAdapter.java rename to app/src/main/java/net/micode/notes/ui/FoldersListAdapter.java diff --git a/src/net/micode/notes/ui/NoteEditActivity.java b/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java similarity index 95% rename from src/net/micode/notes/ui/NoteEditActivity.java rename to app/src/main/java/net/micode/notes/ui/NoteEditActivity.java index e4b62f8a..b212cbd7 100644 --- a/src/net/micode/notes/ui/NoteEditActivity.java +++ b/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -72,6 +72,7 @@ import net.micode.notes.model.WorkingNote; import net.micode.notes.model.WorkingNote.NoteSettingChangedListener; import net.micode.notes.tool.DataUtils; +import net.micode.notes.tool.PendingIntentCompat; import net.micode.notes.tool.ResourceParser; import net.micode.notes.tool.ResourceParser.TextAppearanceResources; import net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener; @@ -536,53 +537,41 @@ public boolean onPrepareOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_new_note: - createNewNote(); - break; - case R.id.menu_delete: - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(getString(R.string.alert_title_delete)); - builder.setIcon(android.R.drawable.ic_dialog_alert); - builder.setMessage(getString(R.string.alert_message_delete_note)); - builder.setPositiveButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - deleteCurrentNote(); - finish(); - } - }); - builder.setNegativeButton(android.R.string.cancel, null); - builder.show(); - break; - case R.id.menu_font_size: - mFontSizeSelector.setVisibility(View.VISIBLE); - findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE); - break; - case R.id.menu_list_mode: - mWorkingNote.setCheckListMode(mWorkingNote.getCheckListMode() == 0 ? - TextNote.MODE_CHECK_LIST : 0); - break; - case R.id.menu_share: - shareCurrentNote(); - break; - case R.id.menu_export_as_txt: - exportCurrentNoteAsTxt(); - break; - case R.id.menu_generate_long_image: - saveCurrentNoteAsLongImage(); - break; - case R.id.menu_send_to_desktop: - sendToDesktop(); - break; - case R.id.menu_alert: - setReminder(); - break; - case R.id.menu_delete_remind: - mWorkingNote.setAlertDate(0, false); - break; - default: - break; + int itemId = item.getItemId(); + if (itemId == R.id.menu_new_note) { + createNewNote(); + } else if (itemId == R.id.menu_delete) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(getString(R.string.alert_title_delete)); + builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setMessage(getString(R.string.alert_message_delete_note)); + builder.setPositiveButton(android.R.string.ok, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + deleteCurrentNote(); + finish(); + } + }); + builder.setNegativeButton(android.R.string.cancel, null); + builder.show(); + } else if (itemId == R.id.menu_font_size) { + mFontSizeSelector.setVisibility(View.VISIBLE); + findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE); + } else if (itemId == R.id.menu_list_mode) { + mWorkingNote.setCheckListMode(mWorkingNote.getCheckListMode() == 0 ? + TextNote.MODE_CHECK_LIST : 0); + } else if (itemId == R.id.menu_share) { + shareCurrentNote(); + } else if (itemId == R.id.menu_export_as_txt) { + exportCurrentNoteAsTxt(); + } else if (itemId == R.id.menu_generate_long_image) { + saveCurrentNoteAsLongImage(); + } else if (itemId == R.id.menu_send_to_desktop) { + sendToDesktop(); + } else if (itemId == R.id.menu_alert) { + setReminder(); + } else if (itemId == R.id.menu_delete_remind) { + mWorkingNote.setAlertDate(0, false); } return true; } @@ -762,7 +751,8 @@ public void onClockAlertChanged(long date, boolean set) { if (mWorkingNote.getNoteId() > 0) { Intent intent = new Intent(this, AlarmReceiver.class); intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId())); - PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); + PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, + PendingIntentCompat.immutableFlag()); AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE)); showAlertHeader(); if(!set) { diff --git a/src/net/micode/notes/ui/NoteEditText.java b/app/src/main/java/net/micode/notes/ui/NoteEditText.java similarity index 100% rename from src/net/micode/notes/ui/NoteEditText.java rename to app/src/main/java/net/micode/notes/ui/NoteEditText.java diff --git a/src/net/micode/notes/ui/NoteItemData.java b/app/src/main/java/net/micode/notes/ui/NoteItemData.java similarity index 100% rename from src/net/micode/notes/ui/NoteItemData.java rename to app/src/main/java/net/micode/notes/ui/NoteItemData.java diff --git a/src/net/micode/notes/ui/NotesListActivity.java b/app/src/main/java/net/micode/notes/ui/NotesListActivity.java similarity index 94% rename from src/net/micode/notes/ui/NotesListActivity.java rename to app/src/main/java/net/micode/notes/ui/NotesListActivity.java index f1eb5557..a5bbf6d5 100644 --- a/src/net/micode/notes/ui/NotesListActivity.java +++ b/app/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -363,28 +363,26 @@ public boolean onMenuItemClick(MenuItem item) { return true; } - switch (item.getItemId()) { - case R.id.delete: - AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); - builder.setTitle(getString(R.string.alert_title_delete)); - builder.setIcon(android.R.drawable.ic_dialog_alert); - builder.setMessage(getString(R.string.alert_message_delete_notes, - mNotesListAdapter.getSelectedCount())); - builder.setPositiveButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - batchDelete(); - } - }); - builder.setNegativeButton(android.R.string.cancel, null); - builder.show(); - break; - case R.id.move: - startQueryDestinationFolders(); - break; - default: - return false; + int itemId = item.getItemId(); + if (itemId == R.id.delete) { + AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); + builder.setTitle(getString(R.string.alert_title_delete)); + builder.setIcon(android.R.drawable.ic_dialog_alert); + builder.setMessage(getString(R.string.alert_message_delete_notes, + mNotesListAdapter.getSelectedCount())); + builder.setPositiveButton(android.R.string.ok, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + batchDelete(); + } + }); + builder.setNegativeButton(android.R.string.cancel, null); + builder.show(); + } else if (itemId == R.id.move) { + startQueryDestinationFolders(); + } else { + return false; } return true; } @@ -702,12 +700,8 @@ private void openFolder(NoteItemData data) { } public void onClick(View v) { - switch (v.getId()) { - case R.id.btn_new_note: - createNewNote(); - break; - default: - break; + if (v.getId() == R.id.btn_new_note) { + createNewNote(); } } @@ -924,40 +918,27 @@ public boolean onPrepareOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_new_folder: { - showCreateOrModifyFolderDialog(true); - break; - } - case R.id.menu_export_text: { - exportNoteToText(); - break; - } - case R.id.menu_sync: { - if (isSyncMode()) { - if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) { - GTaskSyncService.startSync(this); - } else { - GTaskSyncService.cancelSync(this); - } + int itemId = item.getItemId(); + if (itemId == R.id.menu_new_folder) { + showCreateOrModifyFolderDialog(true); + } else if (itemId == R.id.menu_export_text) { + exportNoteToText(); + } else if (itemId == R.id.menu_sync) { + if (isSyncMode()) { + if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) { + GTaskSyncService.startSync(this); } else { - startPreferenceActivity(); + GTaskSyncService.cancelSync(this); } - break; - } - case R.id.menu_setting: { + } else { startPreferenceActivity(); - break; - } - case R.id.menu_new_note: { - createNewNote(); - break; } - case R.id.menu_search: - focusSearchInput(); - break; - default: - break; + } else if (itemId == R.id.menu_setting) { + startPreferenceActivity(); + } else if (itemId == R.id.menu_new_note) { + createNewNote(); + } else if (itemId == R.id.menu_search) { + focusSearchInput(); } return true; } diff --git a/src/net/micode/notes/ui/NotesListAdapter.java b/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java similarity index 100% rename from src/net/micode/notes/ui/NotesListAdapter.java rename to app/src/main/java/net/micode/notes/ui/NotesListAdapter.java diff --git a/src/net/micode/notes/ui/NotesListItem.java b/app/src/main/java/net/micode/notes/ui/NotesListItem.java similarity index 100% rename from src/net/micode/notes/ui/NotesListItem.java rename to app/src/main/java/net/micode/notes/ui/NotesListItem.java diff --git a/src/net/micode/notes/ui/NotesPreferenceActivity.java b/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java similarity index 100% rename from src/net/micode/notes/ui/NotesPreferenceActivity.java rename to app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java diff --git a/src/net/micode/notes/widget/NoteWidgetProvider.java b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java similarity index 95% rename from src/net/micode/notes/widget/NoteWidgetProvider.java rename to app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java index ec6f8193..34af8a96 100644 --- a/src/net/micode/notes/widget/NoteWidgetProvider.java +++ b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java @@ -28,6 +28,7 @@ import net.micode.notes.R; import net.micode.notes.data.Notes; import net.micode.notes.data.Notes.NoteColumns; +import net.micode.notes.tool.PendingIntentCompat; import net.micode.notes.tool.ResourceParser; import net.micode.notes.ui.NoteEditActivity; import net.micode.notes.ui.NotesListActivity; @@ -111,11 +112,12 @@ private void update(Context context, AppWidgetManager appWidgetManager, int[] ap rv.setTextViewText(R.id.widget_text, context.getString(R.string.widget_under_visit_mode)); pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], new Intent( - context, NotesListActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); + context, NotesListActivity.class), + PendingIntentCompat.updateCurrentImmutableFlag()); } else { rv.setTextViewText(R.id.widget_text, snippet); pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], intent, - PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntentCompat.updateCurrentImmutableFlag()); } rv.setOnClickPendingIntent(R.id.widget_text, pendingIntent); diff --git a/src/net/micode/notes/widget/NoteWidgetProvider_2x.java b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_2x.java similarity index 100% rename from src/net/micode/notes/widget/NoteWidgetProvider_2x.java rename to app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_2x.java diff --git a/src/net/micode/notes/widget/NoteWidgetProvider_4x.java b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_4x.java similarity index 100% rename from src/net/micode/notes/widget/NoteWidgetProvider_4x.java rename to app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_4x.java diff --git a/res/color/primary_text_dark.xml b/app/src/main/res/color/primary_text_dark.xml similarity index 100% rename from res/color/primary_text_dark.xml rename to app/src/main/res/color/primary_text_dark.xml diff --git a/res/color/secondary_text_dark.xml b/app/src/main/res/color/secondary_text_dark.xml similarity index 100% rename from res/color/secondary_text_dark.xml rename to app/src/main/res/color/secondary_text_dark.xml diff --git a/res/drawable-hdpi/bg_btn_set_color.png b/app/src/main/res/drawable-hdpi/bg_btn_set_color.png similarity index 100% rename from res/drawable-hdpi/bg_btn_set_color.png rename to app/src/main/res/drawable-hdpi/bg_btn_set_color.png diff --git a/res/drawable-hdpi/bg_color_btn_mask.png b/app/src/main/res/drawable-hdpi/bg_color_btn_mask.png similarity index 100% rename from res/drawable-hdpi/bg_color_btn_mask.png rename to app/src/main/res/drawable-hdpi/bg_color_btn_mask.png diff --git a/res/drawable-hdpi/call_record.png b/app/src/main/res/drawable-hdpi/call_record.png similarity index 100% rename from res/drawable-hdpi/call_record.png rename to app/src/main/res/drawable-hdpi/call_record.png diff --git a/res/drawable-hdpi/clock.png b/app/src/main/res/drawable-hdpi/clock.png similarity index 100% rename from res/drawable-hdpi/clock.png rename to app/src/main/res/drawable-hdpi/clock.png diff --git a/res/drawable-hdpi/delete.png b/app/src/main/res/drawable-hdpi/delete.png similarity index 100% rename from res/drawable-hdpi/delete.png rename to app/src/main/res/drawable-hdpi/delete.png diff --git a/res/drawable-hdpi/dropdown_icon.9.png b/app/src/main/res/drawable-hdpi/dropdown_icon.9.png similarity index 100% rename from res/drawable-hdpi/dropdown_icon.9.png rename to app/src/main/res/drawable-hdpi/dropdown_icon.9.png diff --git a/res/drawable-hdpi/edit_blue.9.png b/app/src/main/res/drawable-hdpi/edit_blue.9.png similarity index 100% rename from res/drawable-hdpi/edit_blue.9.png rename to app/src/main/res/drawable-hdpi/edit_blue.9.png diff --git a/res/drawable-hdpi/edit_green.9.png b/app/src/main/res/drawable-hdpi/edit_green.9.png similarity index 100% rename from res/drawable-hdpi/edit_green.9.png rename to app/src/main/res/drawable-hdpi/edit_green.9.png diff --git a/res/drawable-hdpi/edit_red.9.png b/app/src/main/res/drawable-hdpi/edit_red.9.png similarity index 100% rename from res/drawable-hdpi/edit_red.9.png rename to app/src/main/res/drawable-hdpi/edit_red.9.png diff --git a/res/drawable-hdpi/edit_title_blue.9.png b/app/src/main/res/drawable-hdpi/edit_title_blue.9.png similarity index 100% rename from res/drawable-hdpi/edit_title_blue.9.png rename to app/src/main/res/drawable-hdpi/edit_title_blue.9.png diff --git a/res/drawable-hdpi/edit_title_green.9.png b/app/src/main/res/drawable-hdpi/edit_title_green.9.png similarity index 100% rename from res/drawable-hdpi/edit_title_green.9.png rename to app/src/main/res/drawable-hdpi/edit_title_green.9.png diff --git a/res/drawable-hdpi/edit_title_red.9.png b/app/src/main/res/drawable-hdpi/edit_title_red.9.png similarity index 100% rename from res/drawable-hdpi/edit_title_red.9.png rename to app/src/main/res/drawable-hdpi/edit_title_red.9.png diff --git a/res/drawable-hdpi/edit_title_white.9.png b/app/src/main/res/drawable-hdpi/edit_title_white.9.png similarity index 100% rename from res/drawable-hdpi/edit_title_white.9.png rename to app/src/main/res/drawable-hdpi/edit_title_white.9.png diff --git a/res/drawable-hdpi/edit_title_yellow.9.png b/app/src/main/res/drawable-hdpi/edit_title_yellow.9.png similarity index 100% rename from res/drawable-hdpi/edit_title_yellow.9.png rename to app/src/main/res/drawable-hdpi/edit_title_yellow.9.png diff --git a/res/drawable-hdpi/edit_white.9.png b/app/src/main/res/drawable-hdpi/edit_white.9.png similarity index 100% rename from res/drawable-hdpi/edit_white.9.png rename to app/src/main/res/drawable-hdpi/edit_white.9.png diff --git a/res/drawable-hdpi/edit_yellow.9.png b/app/src/main/res/drawable-hdpi/edit_yellow.9.png similarity index 100% rename from res/drawable-hdpi/edit_yellow.9.png rename to app/src/main/res/drawable-hdpi/edit_yellow.9.png diff --git a/res/drawable-hdpi/font_large.png b/app/src/main/res/drawable-hdpi/font_large.png similarity index 100% rename from res/drawable-hdpi/font_large.png rename to app/src/main/res/drawable-hdpi/font_large.png diff --git a/res/drawable-hdpi/font_normal.png b/app/src/main/res/drawable-hdpi/font_normal.png similarity index 100% rename from res/drawable-hdpi/font_normal.png rename to app/src/main/res/drawable-hdpi/font_normal.png diff --git a/res/drawable-hdpi/font_size_selector_bg.9.png b/app/src/main/res/drawable-hdpi/font_size_selector_bg.9.png similarity index 100% rename from res/drawable-hdpi/font_size_selector_bg.9.png rename to app/src/main/res/drawable-hdpi/font_size_selector_bg.9.png diff --git a/res/drawable-hdpi/font_small.png b/app/src/main/res/drawable-hdpi/font_small.png similarity index 100% rename from res/drawable-hdpi/font_small.png rename to app/src/main/res/drawable-hdpi/font_small.png diff --git a/res/drawable-hdpi/font_super.png b/app/src/main/res/drawable-hdpi/font_super.png similarity index 100% rename from res/drawable-hdpi/font_super.png rename to app/src/main/res/drawable-hdpi/font_super.png diff --git a/res/drawable-hdpi/icon_app.png b/app/src/main/res/drawable-hdpi/icon_app.png similarity index 100% rename from res/drawable-hdpi/icon_app.png rename to app/src/main/res/drawable-hdpi/icon_app.png diff --git a/res/drawable-hdpi/list_background.png b/app/src/main/res/drawable-hdpi/list_background.png similarity index 100% rename from res/drawable-hdpi/list_background.png rename to app/src/main/res/drawable-hdpi/list_background.png diff --git a/res/drawable-hdpi/list_blue_down.9.png b/app/src/main/res/drawable-hdpi/list_blue_down.9.png similarity index 100% rename from res/drawable-hdpi/list_blue_down.9.png rename to app/src/main/res/drawable-hdpi/list_blue_down.9.png diff --git a/res/drawable-hdpi/list_blue_middle.9.png b/app/src/main/res/drawable-hdpi/list_blue_middle.9.png similarity index 100% rename from res/drawable-hdpi/list_blue_middle.9.png rename to app/src/main/res/drawable-hdpi/list_blue_middle.9.png diff --git a/res/drawable-hdpi/list_blue_single.9.png b/app/src/main/res/drawable-hdpi/list_blue_single.9.png similarity index 100% rename from res/drawable-hdpi/list_blue_single.9.png rename to app/src/main/res/drawable-hdpi/list_blue_single.9.png diff --git a/res/drawable-hdpi/list_blue_up.9.png b/app/src/main/res/drawable-hdpi/list_blue_up.9.png similarity index 100% rename from res/drawable-hdpi/list_blue_up.9.png rename to app/src/main/res/drawable-hdpi/list_blue_up.9.png diff --git a/res/drawable-hdpi/list_folder.9.png b/app/src/main/res/drawable-hdpi/list_folder.9.png similarity index 100% rename from res/drawable-hdpi/list_folder.9.png rename to app/src/main/res/drawable-hdpi/list_folder.9.png diff --git a/res/drawable-hdpi/list_footer_bg.9.png b/app/src/main/res/drawable-hdpi/list_footer_bg.9.png similarity index 100% rename from res/drawable-hdpi/list_footer_bg.9.png rename to app/src/main/res/drawable-hdpi/list_footer_bg.9.png diff --git a/res/drawable-hdpi/list_green_down.9.png b/app/src/main/res/drawable-hdpi/list_green_down.9.png similarity index 100% rename from res/drawable-hdpi/list_green_down.9.png rename to app/src/main/res/drawable-hdpi/list_green_down.9.png diff --git a/res/drawable-hdpi/list_green_middle.9.png b/app/src/main/res/drawable-hdpi/list_green_middle.9.png similarity index 100% rename from res/drawable-hdpi/list_green_middle.9.png rename to app/src/main/res/drawable-hdpi/list_green_middle.9.png diff --git a/res/drawable-hdpi/list_green_single.9.png b/app/src/main/res/drawable-hdpi/list_green_single.9.png similarity index 100% rename from res/drawable-hdpi/list_green_single.9.png rename to app/src/main/res/drawable-hdpi/list_green_single.9.png diff --git a/res/drawable-hdpi/list_green_up.9.png b/app/src/main/res/drawable-hdpi/list_green_up.9.png similarity index 100% rename from res/drawable-hdpi/list_green_up.9.png rename to app/src/main/res/drawable-hdpi/list_green_up.9.png diff --git a/res/drawable-hdpi/list_red_down.9.png b/app/src/main/res/drawable-hdpi/list_red_down.9.png similarity index 100% rename from res/drawable-hdpi/list_red_down.9.png rename to app/src/main/res/drawable-hdpi/list_red_down.9.png diff --git a/res/drawable-hdpi/list_red_middle.9.png b/app/src/main/res/drawable-hdpi/list_red_middle.9.png similarity index 100% rename from res/drawable-hdpi/list_red_middle.9.png rename to app/src/main/res/drawable-hdpi/list_red_middle.9.png diff --git a/res/drawable-hdpi/list_red_single.9.png b/app/src/main/res/drawable-hdpi/list_red_single.9.png similarity index 100% rename from res/drawable-hdpi/list_red_single.9.png rename to app/src/main/res/drawable-hdpi/list_red_single.9.png diff --git a/res/drawable-hdpi/list_red_up.9.png b/app/src/main/res/drawable-hdpi/list_red_up.9.png similarity index 100% rename from res/drawable-hdpi/list_red_up.9.png rename to app/src/main/res/drawable-hdpi/list_red_up.9.png diff --git a/res/drawable-hdpi/list_white_down.9.png b/app/src/main/res/drawable-hdpi/list_white_down.9.png similarity index 100% rename from res/drawable-hdpi/list_white_down.9.png rename to app/src/main/res/drawable-hdpi/list_white_down.9.png diff --git a/res/drawable-hdpi/list_white_middle.9.png b/app/src/main/res/drawable-hdpi/list_white_middle.9.png similarity index 100% rename from res/drawable-hdpi/list_white_middle.9.png rename to app/src/main/res/drawable-hdpi/list_white_middle.9.png diff --git a/res/drawable-hdpi/list_white_single.9.png b/app/src/main/res/drawable-hdpi/list_white_single.9.png similarity index 100% rename from res/drawable-hdpi/list_white_single.9.png rename to app/src/main/res/drawable-hdpi/list_white_single.9.png diff --git a/res/drawable-hdpi/list_white_up.9.png b/app/src/main/res/drawable-hdpi/list_white_up.9.png similarity index 100% rename from res/drawable-hdpi/list_white_up.9.png rename to app/src/main/res/drawable-hdpi/list_white_up.9.png diff --git a/res/drawable-hdpi/list_yellow_down.9.png b/app/src/main/res/drawable-hdpi/list_yellow_down.9.png similarity index 100% rename from res/drawable-hdpi/list_yellow_down.9.png rename to app/src/main/res/drawable-hdpi/list_yellow_down.9.png diff --git a/res/drawable-hdpi/list_yellow_middle.9.png b/app/src/main/res/drawable-hdpi/list_yellow_middle.9.png similarity index 100% rename from res/drawable-hdpi/list_yellow_middle.9.png rename to app/src/main/res/drawable-hdpi/list_yellow_middle.9.png diff --git a/res/drawable-hdpi/list_yellow_single.9.png b/app/src/main/res/drawable-hdpi/list_yellow_single.9.png similarity index 100% rename from res/drawable-hdpi/list_yellow_single.9.png rename to app/src/main/res/drawable-hdpi/list_yellow_single.9.png diff --git a/res/drawable-hdpi/list_yellow_up.9.png b/app/src/main/res/drawable-hdpi/list_yellow_up.9.png similarity index 100% rename from res/drawable-hdpi/list_yellow_up.9.png rename to app/src/main/res/drawable-hdpi/list_yellow_up.9.png diff --git a/res/drawable-hdpi/menu_delete.png b/app/src/main/res/drawable-hdpi/menu_delete.png similarity index 100% rename from res/drawable-hdpi/menu_delete.png rename to app/src/main/res/drawable-hdpi/menu_delete.png diff --git a/res/drawable-hdpi/menu_move.png b/app/src/main/res/drawable-hdpi/menu_move.png similarity index 100% rename from res/drawable-hdpi/menu_move.png rename to app/src/main/res/drawable-hdpi/menu_move.png diff --git a/res/drawable-hdpi/new_note_normal.png b/app/src/main/res/drawable-hdpi/new_note_normal.png similarity index 100% rename from res/drawable-hdpi/new_note_normal.png rename to app/src/main/res/drawable-hdpi/new_note_normal.png diff --git a/res/drawable-hdpi/new_note_pressed.png b/app/src/main/res/drawable-hdpi/new_note_pressed.png similarity index 100% rename from res/drawable-hdpi/new_note_pressed.png rename to app/src/main/res/drawable-hdpi/new_note_pressed.png diff --git a/res/drawable-hdpi/note_edit_color_selector_panel.png b/app/src/main/res/drawable-hdpi/note_edit_color_selector_panel.png similarity index 100% rename from res/drawable-hdpi/note_edit_color_selector_panel.png rename to app/src/main/res/drawable-hdpi/note_edit_color_selector_panel.png diff --git a/res/drawable-hdpi/notification.png b/app/src/main/res/drawable-hdpi/notification.png similarity index 100% rename from res/drawable-hdpi/notification.png rename to app/src/main/res/drawable-hdpi/notification.png diff --git a/res/drawable-hdpi/search_result.png b/app/src/main/res/drawable-hdpi/search_result.png similarity index 100% rename from res/drawable-hdpi/search_result.png rename to app/src/main/res/drawable-hdpi/search_result.png diff --git a/res/drawable-hdpi/selected.png b/app/src/main/res/drawable-hdpi/selected.png similarity index 100% rename from res/drawable-hdpi/selected.png rename to app/src/main/res/drawable-hdpi/selected.png diff --git a/res/drawable-hdpi/title_alert.png b/app/src/main/res/drawable-hdpi/title_alert.png similarity index 100% rename from res/drawable-hdpi/title_alert.png rename to app/src/main/res/drawable-hdpi/title_alert.png diff --git a/res/drawable-hdpi/title_bar_bg.9.png b/app/src/main/res/drawable-hdpi/title_bar_bg.9.png similarity index 100% rename from res/drawable-hdpi/title_bar_bg.9.png rename to app/src/main/res/drawable-hdpi/title_bar_bg.9.png diff --git a/res/drawable-hdpi/widget_2x_blue.png b/app/src/main/res/drawable-hdpi/widget_2x_blue.png similarity index 100% rename from res/drawable-hdpi/widget_2x_blue.png rename to app/src/main/res/drawable-hdpi/widget_2x_blue.png diff --git a/res/drawable-hdpi/widget_2x_green.png b/app/src/main/res/drawable-hdpi/widget_2x_green.png similarity index 100% rename from res/drawable-hdpi/widget_2x_green.png rename to app/src/main/res/drawable-hdpi/widget_2x_green.png diff --git a/res/drawable-hdpi/widget_2x_red.png b/app/src/main/res/drawable-hdpi/widget_2x_red.png similarity index 100% rename from res/drawable-hdpi/widget_2x_red.png rename to app/src/main/res/drawable-hdpi/widget_2x_red.png diff --git a/res/drawable-hdpi/widget_2x_white.png b/app/src/main/res/drawable-hdpi/widget_2x_white.png similarity index 100% rename from res/drawable-hdpi/widget_2x_white.png rename to app/src/main/res/drawable-hdpi/widget_2x_white.png diff --git a/res/drawable-hdpi/widget_2x_yellow.png b/app/src/main/res/drawable-hdpi/widget_2x_yellow.png similarity index 100% rename from res/drawable-hdpi/widget_2x_yellow.png rename to app/src/main/res/drawable-hdpi/widget_2x_yellow.png diff --git a/res/drawable-hdpi/widget_4x_blue.png b/app/src/main/res/drawable-hdpi/widget_4x_blue.png similarity index 100% rename from res/drawable-hdpi/widget_4x_blue.png rename to app/src/main/res/drawable-hdpi/widget_4x_blue.png diff --git a/res/drawable-hdpi/widget_4x_green.png b/app/src/main/res/drawable-hdpi/widget_4x_green.png similarity index 100% rename from res/drawable-hdpi/widget_4x_green.png rename to app/src/main/res/drawable-hdpi/widget_4x_green.png diff --git a/res/drawable-hdpi/widget_4x_red.png b/app/src/main/res/drawable-hdpi/widget_4x_red.png similarity index 100% rename from res/drawable-hdpi/widget_4x_red.png rename to app/src/main/res/drawable-hdpi/widget_4x_red.png diff --git a/res/drawable-hdpi/widget_4x_white.png b/app/src/main/res/drawable-hdpi/widget_4x_white.png similarity index 100% rename from res/drawable-hdpi/widget_4x_white.png rename to app/src/main/res/drawable-hdpi/widget_4x_white.png diff --git a/res/drawable-hdpi/widget_4x_yellow.png b/app/src/main/res/drawable-hdpi/widget_4x_yellow.png similarity index 100% rename from res/drawable-hdpi/widget_4x_yellow.png rename to app/src/main/res/drawable-hdpi/widget_4x_yellow.png diff --git a/res/drawable/new_note.xml b/app/src/main/res/drawable/new_note.xml similarity index 100% rename from res/drawable/new_note.xml rename to app/src/main/res/drawable/new_note.xml diff --git a/res/layout/account_dialog_title.xml b/app/src/main/res/layout/account_dialog_title.xml similarity index 100% rename from res/layout/account_dialog_title.xml rename to app/src/main/res/layout/account_dialog_title.xml diff --git a/res/layout/add_account_text.xml b/app/src/main/res/layout/add_account_text.xml similarity index 100% rename from res/layout/add_account_text.xml rename to app/src/main/res/layout/add_account_text.xml diff --git a/res/layout/datetime_picker.xml b/app/src/main/res/layout/datetime_picker.xml similarity index 100% rename from res/layout/datetime_picker.xml rename to app/src/main/res/layout/datetime_picker.xml diff --git a/res/layout/dialog_edit_text.xml b/app/src/main/res/layout/dialog_edit_text.xml similarity index 100% rename from res/layout/dialog_edit_text.xml rename to app/src/main/res/layout/dialog_edit_text.xml diff --git a/res/layout/folder_list_item.xml b/app/src/main/res/layout/folder_list_item.xml similarity index 100% rename from res/layout/folder_list_item.xml rename to app/src/main/res/layout/folder_list_item.xml diff --git a/res/layout/note_edit.xml b/app/src/main/res/layout/note_edit.xml similarity index 100% rename from res/layout/note_edit.xml rename to app/src/main/res/layout/note_edit.xml diff --git a/res/layout/note_edit_list_item.xml b/app/src/main/res/layout/note_edit_list_item.xml similarity index 100% rename from res/layout/note_edit_list_item.xml rename to app/src/main/res/layout/note_edit_list_item.xml diff --git a/res/layout/note_item.xml b/app/src/main/res/layout/note_item.xml similarity index 100% rename from res/layout/note_item.xml rename to app/src/main/res/layout/note_item.xml diff --git a/res/layout/note_list.xml b/app/src/main/res/layout/note_list.xml similarity index 100% rename from res/layout/note_list.xml rename to app/src/main/res/layout/note_list.xml diff --git a/res/layout/note_list_dropdown_menu.xml b/app/src/main/res/layout/note_list_dropdown_menu.xml similarity index 100% rename from res/layout/note_list_dropdown_menu.xml rename to app/src/main/res/layout/note_list_dropdown_menu.xml diff --git a/res/layout/note_list_footer.xml b/app/src/main/res/layout/note_list_footer.xml similarity index 100% rename from res/layout/note_list_footer.xml rename to app/src/main/res/layout/note_list_footer.xml diff --git a/res/layout/settings_header.xml b/app/src/main/res/layout/settings_header.xml similarity index 100% rename from res/layout/settings_header.xml rename to app/src/main/res/layout/settings_header.xml diff --git a/res/layout/widget_2x.xml b/app/src/main/res/layout/widget_2x.xml similarity index 100% rename from res/layout/widget_2x.xml rename to app/src/main/res/layout/widget_2x.xml diff --git a/res/layout/widget_4x.xml b/app/src/main/res/layout/widget_4x.xml similarity index 100% rename from res/layout/widget_4x.xml rename to app/src/main/res/layout/widget_4x.xml diff --git a/res/menu/call_note_edit.xml b/app/src/main/res/menu/call_note_edit.xml similarity index 100% rename from res/menu/call_note_edit.xml rename to app/src/main/res/menu/call_note_edit.xml diff --git a/res/menu/call_record_folder.xml b/app/src/main/res/menu/call_record_folder.xml similarity index 100% rename from res/menu/call_record_folder.xml rename to app/src/main/res/menu/call_record_folder.xml diff --git a/res/menu/note_edit.xml b/app/src/main/res/menu/note_edit.xml similarity index 100% rename from res/menu/note_edit.xml rename to app/src/main/res/menu/note_edit.xml diff --git a/res/menu/note_list.xml b/app/src/main/res/menu/note_list.xml similarity index 100% rename from res/menu/note_list.xml rename to app/src/main/res/menu/note_list.xml diff --git a/res/menu/note_list_dropdown.xml b/app/src/main/res/menu/note_list_dropdown.xml similarity index 100% rename from res/menu/note_list_dropdown.xml rename to app/src/main/res/menu/note_list_dropdown.xml diff --git a/res/menu/note_list_options.xml b/app/src/main/res/menu/note_list_options.xml similarity index 100% rename from res/menu/note_list_options.xml rename to app/src/main/res/menu/note_list_options.xml diff --git a/res/menu/sub_folder.xml b/app/src/main/res/menu/sub_folder.xml similarity index 100% rename from res/menu/sub_folder.xml rename to app/src/main/res/menu/sub_folder.xml diff --git a/res/raw-zh-rCN/introduction b/app/src/main/res/raw-zh-rCN/introduction similarity index 100% rename from res/raw-zh-rCN/introduction rename to app/src/main/res/raw-zh-rCN/introduction diff --git a/res/raw/introduction b/app/src/main/res/raw/introduction similarity index 100% rename from res/raw/introduction rename to app/src/main/res/raw/introduction diff --git a/res/values-zh-rCN/arrays.xml b/app/src/main/res/values-zh-rCN/arrays.xml similarity index 100% rename from res/values-zh-rCN/arrays.xml rename to app/src/main/res/values-zh-rCN/arrays.xml diff --git a/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml similarity index 100% rename from res/values-zh-rCN/strings.xml rename to app/src/main/res/values-zh-rCN/strings.xml diff --git a/res/values-zh-rTW/arrays.xml b/app/src/main/res/values-zh-rTW/arrays.xml similarity index 100% rename from res/values-zh-rTW/arrays.xml rename to app/src/main/res/values-zh-rTW/arrays.xml diff --git a/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml similarity index 100% rename from res/values-zh-rTW/strings.xml rename to app/src/main/res/values-zh-rTW/strings.xml diff --git a/res/values/arrays.xml b/app/src/main/res/values/arrays.xml similarity index 100% rename from res/values/arrays.xml rename to app/src/main/res/values/arrays.xml diff --git a/res/values/colors.xml b/app/src/main/res/values/colors.xml similarity index 100% rename from res/values/colors.xml rename to app/src/main/res/values/colors.xml diff --git a/res/values/dimens.xml b/app/src/main/res/values/dimens.xml similarity index 100% rename from res/values/dimens.xml rename to app/src/main/res/values/dimens.xml diff --git a/res/values/strings.xml b/app/src/main/res/values/strings.xml similarity index 100% rename from res/values/strings.xml rename to app/src/main/res/values/strings.xml diff --git a/res/values/styles.xml b/app/src/main/res/values/styles.xml similarity index 100% rename from res/values/styles.xml rename to app/src/main/res/values/styles.xml diff --git a/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml similarity index 100% rename from res/xml/preferences.xml rename to app/src/main/res/xml/preferences.xml diff --git a/res/xml/searchable.xml b/app/src/main/res/xml/searchable.xml similarity index 100% rename from res/xml/searchable.xml rename to app/src/main/res/xml/searchable.xml diff --git a/res/xml/widget_2x_info.xml b/app/src/main/res/xml/widget_2x_info.xml similarity index 100% rename from res/xml/widget_2x_info.xml rename to app/src/main/res/xml/widget_2x_info.xml diff --git a/res/xml/widget_4x_info.xml b/app/src/main/res/xml/widget_4x_info.xml similarity index 100% rename from res/xml/widget_4x_info.xml rename to app/src/main/res/xml/widget_4x_info.xml diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..50699b6f --- /dev/null +++ b/build.gradle @@ -0,0 +1,3 @@ +plugins { + id 'com.android.application' version '8.6.1' apply false +} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..140719e8 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,20 @@ +import org.gradle.api.initialization.resolve.RepositoriesMode + +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "Notes" +include(":app") From 87558a6a710c94d2c85f67d23c70c882659815b0 Mon Sep 17 00:00:00 2001 From: elelcode Date: Thu, 23 Apr 2026 18:53:05 +0800 Subject: [PATCH 06/17] fix(bug): fix migrating problem and fix UI --- .gitignore | 2 +- .../net/micode/notes/tool/BackupUtils.java | 344 ------------------ .../net/micode/notes/ui/NoteEditActivity.java | 10 + .../micode/notes/ui/NotesListActivity.java | 95 ++--- app/src/main/res/layout/note_list_footer.xml | 30 +- app/src/main/res/menu/note_list.xml | 6 +- app/src/main/res/values-zh-rCN/strings.xml | 11 +- app/src/main/res/values-zh-rTW/strings.xml | 11 +- app/src/main/res/values/arrays.xml | 10 +- app/src/main/res/values/strings.xml | 14 +- app/src/main/res/values/styles.xml | 7 +- build.gradle | 2 +- gradle.properties | 11 + gradle/gradle-daemon-jvm.properties | 13 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 45457 bytes gradle/wrapper/gradle-wrapper.properties | 7 + gradlew | 251 +++++++++++++ gradlew.bat | 94 +++++ settings.gradle | 3 + 19 files changed, 491 insertions(+), 430 deletions(-) delete mode 100644 app/src/main/java/net/micode/notes/tool/BackupUtils.java create mode 100644 gradle.properties create mode 100644 gradle/gradle-daemon-jvm.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat diff --git a/.gitignore b/.gitignore index ff3ff8f9..d0dbb42e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ gen/ .gradle/ build/ app/build/ - +.idea/ # Local configuration file (sdk path, etc) local.properties project.properties diff --git a/app/src/main/java/net/micode/notes/tool/BackupUtils.java b/app/src/main/java/net/micode/notes/tool/BackupUtils.java deleted file mode 100644 index 39f6ec47..00000000 --- a/app/src/main/java/net/micode/notes/tool/BackupUtils.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.micode.notes.tool; - -import android.content.Context; -import android.database.Cursor; -import android.os.Environment; -import android.text.TextUtils; -import android.text.format.DateFormat; -import android.util.Log; - -import net.micode.notes.R; -import net.micode.notes.data.Notes; -import net.micode.notes.data.Notes.DataColumns; -import net.micode.notes.data.Notes.DataConstants; -import net.micode.notes.data.Notes.NoteColumns; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; - - -public class BackupUtils { - private static final String TAG = "BackupUtils"; - // Singleton stuff - private static BackupUtils sInstance; - - public static synchronized BackupUtils getInstance(Context context) { - if (sInstance == null) { - sInstance = new BackupUtils(context); - } - return sInstance; - } - - /** - * Following states are signs to represents backup or restore - * status - */ - // Currently, the sdcard is not mounted - public static final int STATE_SD_CARD_UNMOUONTED = 0; - // The backup file not exist - public static final int STATE_BACKUP_FILE_NOT_EXIST = 1; - // The data is not well formated, may be changed by other programs - public static final int STATE_DATA_DESTROIED = 2; - // Some run-time exception which causes restore or backup fails - public static final int STATE_SYSTEM_ERROR = 3; - // Backup or restore success - public static final int STATE_SUCCESS = 4; - - private TextExport mTextExport; - - private BackupUtils(Context context) { - mTextExport = new TextExport(context); - } - - private static boolean externalStorageAvailable() { - return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()); - } - - public int exportToText() { - return mTextExport.exportToText(); - } - - public String getExportedTextFileName() { - return mTextExport.mFileName; - } - - public String getExportedTextFileDir() { - return mTextExport.mFileDirectory; - } - - private static class TextExport { - private static final String[] NOTE_PROJECTION = { - NoteColumns.ID, - NoteColumns.MODIFIED_DATE, - NoteColumns.SNIPPET, - NoteColumns.TYPE - }; - - private static final int NOTE_COLUMN_ID = 0; - - private static final int NOTE_COLUMN_MODIFIED_DATE = 1; - - private static final int NOTE_COLUMN_SNIPPET = 2; - - private static final String[] DATA_PROJECTION = { - DataColumns.CONTENT, - DataColumns.MIME_TYPE, - DataColumns.DATA1, - DataColumns.DATA2, - DataColumns.DATA3, - DataColumns.DATA4, - }; - - private static final int DATA_COLUMN_CONTENT = 0; - - private static final int DATA_COLUMN_MIME_TYPE = 1; - - private static final int DATA_COLUMN_CALL_DATE = 2; - - private static final int DATA_COLUMN_PHONE_NUMBER = 4; - - private final String [] TEXT_FORMAT; - private static final int FORMAT_FOLDER_NAME = 0; - private static final int FORMAT_NOTE_DATE = 1; - private static final int FORMAT_NOTE_CONTENT = 2; - - private Context mContext; - private String mFileName; - private String mFileDirectory; - - public TextExport(Context context) { - TEXT_FORMAT = context.getResources().getStringArray(R.array.format_for_exported_note); - mContext = context; - mFileName = ""; - mFileDirectory = ""; - } - - private String getFormat(int id) { - return TEXT_FORMAT[id]; - } - - /** - * Export the folder identified by folder id to text - */ - private void exportFolderToText(String folderId, PrintStream ps) { - // Query notes belong to this folder - Cursor notesCursor = mContext.getContentResolver().query(Notes.CONTENT_NOTE_URI, - NOTE_PROJECTION, NoteColumns.PARENT_ID + "=?", new String[] { - folderId - }, null); - - if (notesCursor != null) { - if (notesCursor.moveToFirst()) { - do { - // Print note's last modified date - ps.println(String.format(getFormat(FORMAT_NOTE_DATE), DateFormat.format( - mContext.getString(R.string.format_datetime_mdhm), - notesCursor.getLong(NOTE_COLUMN_MODIFIED_DATE)))); - // Query data belong to this note - String noteId = notesCursor.getString(NOTE_COLUMN_ID); - exportNoteToText(noteId, ps); - } while (notesCursor.moveToNext()); - } - notesCursor.close(); - } - } - - /** - * Export note identified by id to a print stream - */ - private void exportNoteToText(String noteId, PrintStream ps) { - Cursor dataCursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, - DATA_PROJECTION, DataColumns.NOTE_ID + "=?", new String[] { - noteId - }, null); - - if (dataCursor != null) { - if (dataCursor.moveToFirst()) { - do { - String mimeType = dataCursor.getString(DATA_COLUMN_MIME_TYPE); - if (DataConstants.CALL_NOTE.equals(mimeType)) { - // Print phone number - String phoneNumber = dataCursor.getString(DATA_COLUMN_PHONE_NUMBER); - long callDate = dataCursor.getLong(DATA_COLUMN_CALL_DATE); - String location = dataCursor.getString(DATA_COLUMN_CONTENT); - - if (!TextUtils.isEmpty(phoneNumber)) { - ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), - phoneNumber)); - } - // Print call date - ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), DateFormat - .format(mContext.getString(R.string.format_datetime_mdhm), - callDate))); - // Print call attachment location - if (!TextUtils.isEmpty(location)) { - ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), - location)); - } - } else if (DataConstants.NOTE.equals(mimeType)) { - String content = dataCursor.getString(DATA_COLUMN_CONTENT); - if (!TextUtils.isEmpty(content)) { - ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), - content)); - } - } - } while (dataCursor.moveToNext()); - } - dataCursor.close(); - } - // print a line separator between note - try { - ps.write(new byte[] { - Character.LINE_SEPARATOR, Character.LETTER_NUMBER - }); - } catch (IOException e) { - Log.e(TAG, e.toString()); - } - } - - /** - * Note will be exported as text which is user readable - */ - public int exportToText() { - if (!externalStorageAvailable()) { - Log.d(TAG, "Media was not mounted"); - return STATE_SD_CARD_UNMOUONTED; - } - - PrintStream ps = getExportToTextPrintStream(); - if (ps == null) { - Log.e(TAG, "get print stream error"); - return STATE_SYSTEM_ERROR; - } - // First export folder and its notes - Cursor folderCursor = mContext.getContentResolver().query( - Notes.CONTENT_NOTE_URI, - NOTE_PROJECTION, - "(" + NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER + " AND " - + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER + ") OR " - + NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER, null, null); - - if (folderCursor != null) { - if (folderCursor.moveToFirst()) { - do { - // Print folder's name - String folderName = ""; - if(folderCursor.getLong(NOTE_COLUMN_ID) == Notes.ID_CALL_RECORD_FOLDER) { - folderName = mContext.getString(R.string.call_record_folder_name); - } else { - folderName = folderCursor.getString(NOTE_COLUMN_SNIPPET); - } - if (!TextUtils.isEmpty(folderName)) { - ps.println(String.format(getFormat(FORMAT_FOLDER_NAME), folderName)); - } - String folderId = folderCursor.getString(NOTE_COLUMN_ID); - exportFolderToText(folderId, ps); - } while (folderCursor.moveToNext()); - } - folderCursor.close(); - } - - // Export notes in root's folder - Cursor noteCursor = mContext.getContentResolver().query( - Notes.CONTENT_NOTE_URI, - NOTE_PROJECTION, - NoteColumns.TYPE + "=" + +Notes.TYPE_NOTE + " AND " + NoteColumns.PARENT_ID - + "=0", null, null); - - if (noteCursor != null) { - if (noteCursor.moveToFirst()) { - do { - ps.println(String.format(getFormat(FORMAT_NOTE_DATE), DateFormat.format( - mContext.getString(R.string.format_datetime_mdhm), - noteCursor.getLong(NOTE_COLUMN_MODIFIED_DATE)))); - // Query data belong to this note - String noteId = noteCursor.getString(NOTE_COLUMN_ID); - exportNoteToText(noteId, ps); - } while (noteCursor.moveToNext()); - } - noteCursor.close(); - } - ps.close(); - - return STATE_SUCCESS; - } - - /** - * Get a print stream pointed to the file {@generateExportedTextFile} - */ - private PrintStream getExportToTextPrintStream() { - File file = generateFileMountedOnSDcard(mContext, R.string.file_path, - R.string.file_name_txt_format); - if (file == null) { - Log.e(TAG, "create file to exported failed"); - return null; - } - mFileName = file.getName(); - mFileDirectory = mContext.getString(R.string.file_path); - PrintStream ps = null; - try { - FileOutputStream fos = new FileOutputStream(file); - ps = new PrintStream(fos); - } catch (FileNotFoundException e) { - e.printStackTrace(); - return null; - } catch (NullPointerException e) { - e.printStackTrace(); - return null; - } - return ps; - } - } - - /** - * Generate the text file to store imported data - */ - private static File generateFileMountedOnSDcard(Context context, int filePathResId, int fileNameFormatResId) { - StringBuilder sb = new StringBuilder(); - sb.append(Environment.getExternalStorageDirectory()); - sb.append(context.getString(filePathResId)); - File filedir = new File(sb.toString()); - sb.append(context.getString( - fileNameFormatResId, - DateFormat.format(context.getString(R.string.format_date_ymd), - System.currentTimeMillis()))); - File file = new File(sb.toString()); - - try { - if (!filedir.exists()) { - filedir.mkdir(); - } - if (!file.exists()) { - file.createNewFile(); - } - return file; - } catch (SecurityException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - return null; - } -} - - diff --git a/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java index b212cbd7..d5e2a8be 100644 --- a/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java +++ b/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -510,8 +510,17 @@ public void onBackgroundColorChanged() { mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId()); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + return buildOptionsMenu(menu); + } + @Override public boolean onPrepareOptionsMenu(Menu menu) { + return buildOptionsMenu(menu); + } + + private boolean buildOptionsMenu(Menu menu) { if (isFinishing()) { return true; } @@ -548,6 +557,7 @@ public boolean onOptionsItemSelected(MenuItem item) { builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { + setResult(RESULT_OK); deleteCurrentNote(); finish(); } diff --git a/app/src/main/java/net/micode/notes/ui/NotesListActivity.java b/app/src/main/java/net/micode/notes/ui/NotesListActivity.java index a5bbf6d5..733fe24e 100644 --- a/app/src/main/java/net/micode/notes/ui/NotesListActivity.java +++ b/app/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -65,7 +65,6 @@ import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.gtask.remote.GTaskSyncService; import net.micode.notes.model.WorkingNote; -import net.micode.notes.tool.BackupUtils; import net.micode.notes.tool.DataUtils; import net.micode.notes.tool.ResourceParser; import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute; @@ -131,6 +130,10 @@ public NoteListQueryCookie(long folderId, String searchText, String selection, private TextView mTitleBar; + private TextView mFooterTitle; + + private TextView mFooterSummary; + private EditText mSearchEditText; private long mCurrentFolderId; @@ -141,6 +144,8 @@ public NoteListQueryCookie(long folderId, String searchText, String selection, private NoteListQueryCookie mLastNoteListQueryCookie; + private int mFooterItemCount; + private static final String TAG = "NotesListActivity"; public static final int NOTES_LISTVIEW_SCROLL_RATE = 30; @@ -236,8 +241,10 @@ private void initResources() { mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver()); mCurrentFolderId = Notes.ID_ROOT_FOLDER; mNotesListView = (ListView) findViewById(R.id.notes_list); - mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null), - null, false); + View footerView = LayoutInflater.from(this).inflate(R.layout.note_list_footer, null); + mFooterTitle = (TextView) footerView.findViewById(R.id.tv_footer_title); + mFooterSummary = (TextView) footerView.findViewById(R.id.tv_footer_summary); + mNotesListView.addFooterView(footerView, null, false); mNotesListView.setOnItemClickListener(new OnListItemClickListener()); mNotesListView.setOnItemLongClickListener(this); mNotesListAdapter = new NotesListAdapter(this); @@ -270,6 +277,7 @@ public void afterTextChanged(Editable s) { mSearchEditText.clearFocus(); mNotesListView.requestFocus(); mState = ListEditState.NOTE_LIST; + updateFooterInfo(0); } private class ModeCallback implements ListView.MultiChoiceModeListener, OnMenuItemClickListener { @@ -292,6 +300,7 @@ public boolean onCreateActionMode(ActionMode mode, Menu menu) { mNotesListAdapter.setChoiceMode(true); mNotesListView.setLongClickable(false); mAddNewNote.setVisibility(View.GONE); + updateFooterInfo(mFooterItemCount); View customView = LayoutInflater.from(NotesListActivity.this).inflate( R.layout.note_list_dropdown_menu, null); @@ -342,6 +351,7 @@ public void onDestroyActionMode(ActionMode mode) { mNotesListView.setLongClickable(true); mAddNewNote.setVisibility(View.VISIBLE); mActionMode = null; + updateFooterInfo(mFooterItemCount); } public void finishActionMode() { @@ -501,6 +511,7 @@ protected void onQueryComplete(int token, Object cookie, Cursor cursor) { } mNotesListAdapter.setSearchText(((NoteListQueryCookie) cookie).searchText); mNotesListAdapter.changeCursor(cursor); + updateFooterInfo(cursor != null ? cursor.getCount() : 0); break; case FOLDER_LIST_QUERY_TOKEN: if (cursor != null && cursor.getCount() > 0) { @@ -522,6 +533,31 @@ private String getSearchText() { return mSearchEditText.getText().toString().trim(); } + private void updateFooterInfo(int itemCount) { + mFooterItemCount = itemCount; + if (mFooterTitle == null || mFooterSummary == null) { + return; + } + + if (mState == ListEditState.CALL_RECORD_FOLDER) { + if (itemCount > 0) { + mFooterTitle.setText(getString(R.string.footer_call_notes_count, itemCount)); + } else { + mFooterTitle.setText(R.string.footer_call_notes_empty); + } + } else { + if (itemCount > 0) { + mFooterTitle.setText(getString(R.string.footer_items_count, itemCount)); + } else { + mFooterTitle.setText(R.string.footer_items_empty); + } + } + + mFooterSummary.setText(mAddNewNote != null && mAddNewNote.getVisibility() == View.VISIBLE + ? R.string.footer_hint_add_note + : R.string.footer_hint_search); + } + private String[] appendSelectionArgs(String[] baseArgs, String[] extraArgs) { if (extraArgs == null || extraArgs.length == 0) { return baseArgs; @@ -898,8 +934,17 @@ public void onClick(DialogInterface dialog, int which) { return true; } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + return buildOptionsMenu(menu); + } + @Override public boolean onPrepareOptionsMenu(Menu menu) { + return buildOptionsMenu(menu); + } + + private boolean buildOptionsMenu(Menu menu) { menu.clear(); if (mState == ListEditState.NOTE_LIST) { getMenuInflater().inflate(R.menu.note_list, menu); @@ -921,8 +966,6 @@ public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menu_new_folder) { showCreateOrModifyFolderDialog(true); - } else if (itemId == R.id.menu_export_text) { - exportNoteToText(); } else if (itemId == R.id.menu_sync) { if (isSyncMode()) { if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) { @@ -949,48 +992,6 @@ public boolean onSearchRequested() { return true; } - private void exportNoteToText() { - final BackupUtils backup = BackupUtils.getInstance(NotesListActivity.this); - new AsyncTask() { - - @Override - protected Integer doInBackground(Void... unused) { - return backup.exportToText(); - } - - @Override - protected void onPostExecute(Integer result) { - if (result == BackupUtils.STATE_SD_CARD_UNMOUONTED) { - AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); - builder.setTitle(NotesListActivity.this - .getString(R.string.failed_sdcard_export)); - builder.setMessage(NotesListActivity.this - .getString(R.string.error_sdcard_unmounted)); - builder.setPositiveButton(android.R.string.ok, null); - builder.show(); - } else if (result == BackupUtils.STATE_SUCCESS) { - AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); - builder.setTitle(NotesListActivity.this - .getString(R.string.success_sdcard_export)); - builder.setMessage(NotesListActivity.this.getString( - R.string.format_exported_file_location, backup - .getExportedTextFileName(), backup.getExportedTextFileDir())); - builder.setPositiveButton(android.R.string.ok, null); - builder.show(); - } else if (result == BackupUtils.STATE_SYSTEM_ERROR) { - AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); - builder.setTitle(NotesListActivity.this - .getString(R.string.failed_sdcard_export)); - builder.setMessage(NotesListActivity.this - .getString(R.string.error_sdcard_export)); - builder.setPositiveButton(android.R.string.ok, null); - builder.show(); - } - } - - }.execute(); - } - private boolean isSyncMode() { return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0; } diff --git a/app/src/main/res/layout/note_list_footer.xml b/app/src/main/res/layout/note_list_footer.xml index 5ca7b225..38c94842 100644 --- a/app/src/main/res/layout/note_list_footer.xml +++ b/app/src/main/res/layout/note_list_footer.xml @@ -15,10 +15,32 @@ limitations under the License. --> - \ No newline at end of file + android:gravity="center_horizontal" + android:orientation="vertical" + android:paddingTop="18dip" + android:paddingBottom="56dip"> + + + + + diff --git a/app/src/main/res/menu/note_list.xml b/app/src/main/res/menu/note_list.xml index 42ea7363..ac1b99b9 100644 --- a/app/src/main/res/menu/note_list.xml +++ b/app/src/main/res/menu/note_list.xml @@ -19,14 +19,12 @@ xmlns:android="http://schemas.android.com/apk/res/android"> - - 打开地图 新建文件夹 - 导出文本 同步 取消同步 设置 @@ -62,7 +61,7 @@ 分享 分享便签 导出为 TXT - 生成长图 + 保存为图片 发送到桌面 提醒我 删除提醒 @@ -79,7 +78,6 @@ 导出文本时发生错误,请检查SD卡 没有可用于分享便签的应用 存储权限被拒绝 - 存储权限被拒绝,无法导出 保存图片失败 要查看的便签不存在 空便签无法导出 @@ -88,7 +86,6 @@ 导出成功 已保存到相册 导出失败 - 已将文本文件(%1$s)输出至SD卡(%2$s)目录 同步便签... 同步成功 @@ -126,6 +123,12 @@ 搜索便签 便签中的文字 便签 + 这里还没有内容 + 还没有通话便签 + 共 %1$d 项内容 + 共 %1$d 条通话便签 + 轻触底部按钮即可新建便签 + 使用上方搜索可更快找到内容 设置 取消 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 3b866d15..5dce346e 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -38,7 +38,6 @@ 已將所選 %1$d 便籤移到 %2$s 文件夾 新建文件夾 - 導出文本 同步 取消同步 設置 @@ -63,7 +62,7 @@ 分享 分享便簽 導出為 TXT - 生成長圖 + 保存為圖片 發送到桌面 提醒我 刪除提醒 @@ -78,7 +77,6 @@ 導出TXT時發生錯誤,請檢查SD卡 沒有可用於分享便簽的應用 儲存權限被拒絕 - 儲存權限被拒絕,無法導出 保存圖片失敗 要查看的便籤不存在 空白便簽無法導出 @@ -87,7 +85,6 @@ 導出成功 已保存到相冊 導出失敗 - 已將文本文件(%1$s)導出至SD(%2$s)目錄 同步便簽... 同步成功 @@ -127,6 +124,12 @@ 搜索便籤 便籤中的文字 便籤 + 這裡還沒有內容 + 還沒有通話便籤 + 共 %1$d 項內容 + 共 %1$d 條通話便籤 + 輕觸底部按鈕即可新建便簽 + 使用上方搜尋可更快找到內容 設置 取消 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index e00210b5..b4b6ca42 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -16,16 +16,8 @@ --> - - - -%s - --%s - --%s - --%s - - Messaging Email - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 85c41d6b..91b8f183 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -35,13 +35,9 @@ Send email Browse web Open map - - /MIUI/notes/ - notes_%s.txt (%d) New Folder - Export text Sync Cancel syncing Settings @@ -66,7 +62,7 @@ Share Share note Export as TXT - Generate long image + Save as Image Send to home Remind me Delete reminder @@ -83,7 +79,6 @@ Export failed, please check SD card No app available to share this note Storage permission denied - Storage permission denied, export unavailable Save image failed The note is not exist Cannot export an empty note @@ -92,7 +87,6 @@ Export successful Image saved to gallery Export fail - Export text file (%1$s) to SD (%2$s) directory Syncing notes... Sync is successful @@ -133,6 +127,12 @@ Search notes Text in your notes Notes + Nothing here yet + No call notes yet + %1$d items here + %1$d call notes + Tap the bottom button to add a note + Use search above to find notes faster set cancel diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d750e659..fb51efc9 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -62,8 +62,5 @@ @style/NoteActionBarStyle - - \ No newline at end of file + + diff --git a/app/src/main/res/values-zh-rCN/arrays.xml b/app/src/main/res/values-zh-rCN/arrays.xml deleted file mode 100644 index a092386e..00000000 --- a/app/src/main/res/values-zh-rCN/arrays.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - 短信 - 邮件 - - \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index b4175725..1b329ff2 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -21,40 +21,30 @@ 便签2x2 便签4x4 没有关联内容,点击新建便签。 - 访客模式下,便签内容不可见 - ... + 新建便签 - 成功删除提醒 - 创建提醒 - 已过期 - yyyyMMdd - MM月dd日 kk:mm 知道了 查看 - 呼叫电话 - 发送邮件 - 浏览网页 - 打开地图 新建文件夹 同步 取消同步 设置 - 搜索 + 返回 + 更多 + 已开启 + 已关闭 删除 - 移动到文件夹 - 选中了 %d 项 + + 选中了 %d 项 + 没有选中项,操作无效 - 全选 - 取消全选 - 文字大小 + 进入清单模式 + 退出清单模式 正常 超大 - 进入清单模式 - 退出清单模式 - 查看文件夹 刪除文件夹 修改文件夹名称 文件夹 %1$s 已存在,请重新命名 @@ -65,19 +55,16 @@ 发送到桌面 提醒我 删除提醒 - 选择文件夹 - 上一级文件夹 已添加到桌面 删除 - 确认要删除所选的 %d 条便签吗? + + 确认要删除所选的 %d 条便签吗? + 确认要删除该条便签吗? 确认删除文件夹及所包含的便签吗? - 已将所选 %1$d 条便签移到 %2$s 文件夹 - SD卡被占用,不能操作 导出文本时发生错误,请检查SD卡 没有可用于分享便签的应用 - 存储权限被拒绝 保存图片失败 要查看的便签不存在 空便签无法导出 @@ -85,9 +72,8 @@ 不能将空便签发送到桌面 导出成功 已保存到相册 - 导出失败 - 同步便签... + 同步便签… 同步成功 同步失败 同步已取消 @@ -95,9 +81,9 @@ 同步失败,请检查网络和帐号设置 同步失败,发生内部错误 同步已取消 - 登录%1$s... - 正在获取服务器便签列表... - 正在同步本地便签... + 登录%1$s… + 正在获取服务器便签列表… + 正在同步本地便签… 设置 同步账号 @@ -106,7 +92,6 @@ 添加账号 更换账号 删除账号 - 取消 立即同步 取消同步 当前帐号 %1$s @@ -116,23 +101,21 @@ 正在同步中,不能修改同步帐号 同步帐号已设置为%1$s 新建便签背景颜色随机 - 删除 通话便签 请输入名称 正在搜索便签 搜索便签 便签中的文字 - 便签 + 写点什么… + 每行一项… 这里还没有内容 还没有通话便签 - 共 %1$d 项内容 - 共 %1$d 条通话便签 + + 共 %1$d 项内容 + + + 共 %1$d 条通话便签 + 轻触底部按钮即可新建便签 使用上方搜索可更快找到内容 - 设置 - 取消 - - %1$s 条符合“%2$s”的搜索结果 - - diff --git a/app/src/main/res/values-zh-rTW/arrays.xml b/app/src/main/res/values-zh-rTW/arrays.xml deleted file mode 100644 index 52972099..00000000 --- a/app/src/main/res/values-zh-rTW/arrays.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - 短信 - 郵件 - - \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 5dce346e..9c94c92f 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -21,41 +21,30 @@ 便簽2x2 便簽4x4 沒有關聯內容,點擊新建便簽。 - 訪客模式下,便籤內容不可見 - ... + 新建便簽 - 成功刪除提醒 - 創建提醒 - 已過期 - yyyyMMdd - MM月dd日 kk:mm 知道了 查看 - 呼叫電話 - 發送郵件 - 浏覽網頁 - 打開地圖 - 已將所選 %1$d 便籤移到 %2$s 文件夾 新建文件夾 同步 取消同步 設置 - 搜尋 + 返回 + 更多 + 已開啟 + 已關閉 刪除 - 移動到文件夾 - 選中了 %d 項 + + 選中了 %d 項 + 沒有選中項,操作無效 - 全選 - 取消全選 - 文字大小 + 進入清單模式 + 退出清單模式 正常 超大 - 進入清單模式 - 退出清單模式 - 查看文件夾 刪除文件夾 修改文件夾名稱 文件夾 %1$s 已存在,請重新命名 @@ -66,17 +55,15 @@ 發送到桌面 提醒我 刪除提醒 - 選擇文件夾 - 上一級文件夾 已添加到桌面 刪除 - 确认要刪除所選的 %d 條便籤嗎? + + 确认要刪除所選的 %d 條便籤嗎? + 确认要删除該條便籤嗎? 確認刪除檔夾及所包含的便簽嗎? - SD卡被佔用,不能操作 導出TXT時發生錯誤,請檢查SD卡 沒有可用於分享便簽的應用 - 儲存權限被拒絕 保存圖片失敗 要查看的便籤不存在 空白便簽無法導出 @@ -84,9 +71,8 @@ 不能將空便籤發送到桌面 導出成功 已保存到相冊 - 導出失敗 - 同步便簽... + 同步便簽… 同步成功 同步失敗 同步已取消 @@ -94,9 +80,9 @@ 同步失敗,請檢查網絡和帳號設置 同步失敗,發生內部錯誤 同步已取消 - 登陸%1$s... - 正在獲取服務器便籤列表... - 正在同步本地便籤... + 登陸%1$s… + 正在獲取服務器便籤列表… + 正在同步本地便籤… 設置 同步賬號 @@ -105,7 +91,6 @@ 添加賬號 更換賬號 刪除賬號 - 取消 立即同步 取消同步 當前帳號 %1$s @@ -115,25 +100,22 @@ 正在同步中,不能修改同步帳號 同步帳號已設置為%1$s 新建便籤背景顏色隨機 - - 刪除 通話便籤 請輸入名稱 正在搜索便籤 搜索便籤 便籤中的文字 - 便籤 + 寫點什麼… + 每行一項… 這裡還沒有內容 還沒有通話便籤 - 共 %1$d 項內容 - 共 %1$d 條通話便籤 + + 共 %1$d 項內容 + + + 共 %1$d 條通話便籤 + 輕觸底部按鈕即可新建便簽 使用上方搜尋可更快找到內容 - 設置 - 取消 - - %1$s 條符合”%2$s“的搜尋結果 - - diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml deleted file mode 100644 index b4b6ca42..00000000 --- a/app/src/main/res/values/arrays.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - Messaging - Email - - diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml deleted file mode 100644 index 123ffbfb..00000000 --- a/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - #335b5b5b - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml deleted file mode 100644 index 194e84fd..00000000 --- a/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - 33sp - 26sp - 20sp - 17sp - 14sp - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 91b8f183..d0d39fa5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -21,41 +21,32 @@ Notes 2x2 Notes 4x4 No associated note found, click to create associated note. - Privacy mode,can not see note content - ... + Add note - Delete reminder successfully - Set reminder - Expired - yyyyMMdd - MMMd kk:mm Got it Take a look - Call - Send email - Browse web - Open map - (%d) + (%d) New Folder Sync Cancel syncing Settings - Search + Back + More + Enabled + Disabled Delete - Move to folder - %d selected + + %d selected + %d selected + Nothing selected, the operation is invalid - Select all - Deselect all - Font size + Enter check list + Leave check list Small Medium Large Super - Enter check list - Leave check list - View folder Delete folder Change folder name The folder %1$s exist, please rename @@ -66,19 +57,17 @@ Send to home Remind me Delete reminder - Select folder - Parent folder Note added to home Confirm to delete folder and its notes? Delete selected notes - Confirm to delete the selected %d notes? + + Confirm to delete the selected %d note? + Confirm to delete the selected %d notes? + Confirm to delete this note? - Have moved selected %1$d notes to %2$s folder - SD card busy, not available now Export failed, please check SD card No app available to share this note - Storage permission denied Save image failed The note is not exist Cannot export an empty note @@ -86,9 +75,8 @@ Sorry, can not send and empty note to home Export successful Image saved to gallery - Export fail - Syncing notes... + Syncing notes… Sync is successful Sync is failed Sync is canceled @@ -96,19 +84,18 @@ Sync failed, please check network and account settings Sync failed, internal error occurs Sync is canceled - Logging into %1$s... - Getting remote note list... - Synchronize local notes with Google Task... + Logging into %1$s… + Getting remote note list… + Synchronize local notes with Google Task… Settings Sync account Sync notes with google task Last sync time %1$s - yyyy-MM-dd hh:mm:ss + yyyy-MM-dd hh:mm:ss Add account Change sync account Remove sync account - Cancel Sync immediately Cancel syncing Current account %1$s @@ -118,27 +105,24 @@ Cannot change the account because sync is in progress %1$s has been set as the sync account New note background color random - - Delete Call notes Input name Searching Notes Search notes Text in your notes - Notes + Write something… + One item per line… Nothing here yet No call notes yet - %1$d items here - %1$d call notes + + %1$d item here + %1$d items here + + + %1$d call note + %1$d call notes + Tap the bottom button to add a note Use search above to find notes faster - set - cancel - - %1$s result for \"%2$s\" - - %1$s results for \"%2$s\" - - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index fb51efc9..f208e359 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -16,51 +16,8 @@ --> - - - - - - - - - - - - - - - - - + - + + +