yzb 4 months ago
parent 8c387a6807
commit 2c7a2f7b82

@ -1,24 +0,0 @@
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Notes-master"
include(":app")

@ -6,7 +6,7 @@
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="gradleJvm" value="jbr-21" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
@ -16,5 +16,6 @@
<option name="resolveExternalAnnotations" value="false" />
</GradleProjectSettings>
</option>
<option name="parallelModelFetch" value="true" />
</component>
</project>

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="resolveExternalAnnotations" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
</set>
</option>
</component>
</project>

@ -36,6 +36,13 @@ android {
resources.excludes.add("META-INF/LICENSE.txt");
resources.excludes.add("META-INF/NOTICE.txt");
}
sourceSets {
getByName("main") {
assets {
srcDirs("src\\main\\assets", "src\\main\\assets")
}
}
}
}
dependencies {

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/main.iml" filepath="$PROJECT_DIR$/main.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/main.iml" filepath="$PROJECT_DIR$/main.iml" />
</modules>
</component>
</project>

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="NONE" />
</component>
<component name="ChangeListManager">
<list default="true" id="95e1fca0-a790-4197-b9e7-c86af8232539" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ClangdSettings">
<option name="formatViaClangd" value="false" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 3
}]]></component>
<component name="ProjectId" id="2x07V1LDH9CbQO4BOYiLgqY4JGo" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"RunOnceActivity.readMode.enableVisualFormatting": "true",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "D:/Code/AndroidCode/Notesmaster/app/src/main"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="95e1fca0-a790-4197-b9e7-c86af8232539" name="Changes" comment="" />
<created>1747063156863</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1747063156863</updated>
</task>
<servers />
</component>
</project>

@ -17,6 +17,8 @@
package net.micode.notes.data;
import android.net.Uri;
import android.provider.BaseColumns;
public class Notes {
public static final String AUTHORITY = "micode_notes";
public static final String TAG = "Notes";
@ -62,6 +64,9 @@ public class Notes {
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
public interface NoteColumns {
/**
* The unique ID for a row
* <P> Type: INTEGER (long) </P>
@ -276,4 +281,5 @@ public class Notes {
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");
}
}

@ -16,10 +16,13 @@
package net.micode.notes.model;
import android.annotation.SuppressLint;
import android.appwidget.AppWidgetManager;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
@ -33,6 +36,12 @@ import net.micode.notes.tool.ResourceParser.NoteBgResources;
public class WorkingNote {
private String mFontType; // 添加字体类型字段
// Note for the working note
private Note mNote;
// Note Id
@ -146,6 +155,7 @@ public class WorkingNote {
loadNoteData();
}
@SuppressLint("Range")
private void loadNoteData() {
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
DataColumns.NOTE_ID + "=?", new String[] {
@ -166,6 +176,7 @@ public class WorkingNote {
Log.d(TAG, "Wrong note type with type:" + type);
}
} while (cursor.moveToNext());
}
cursor.close();
} else {
@ -188,6 +199,7 @@ public class WorkingNote {
}
public synchronized boolean saveNote() {
// 保存字体类型
if (isWorthSaving()) {
if (!existInDatabase()) {
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
@ -212,6 +224,10 @@ public class WorkingNote {
}
}
public boolean existInDatabase() {
return mNoteId > 0;
}
@ -364,5 +380,12 @@ public class WorkingNote {
* @param newMode is new mode
*/
void onCheckListModeChanged(int oldMode, int newMode);
}
public void setFontType(String fontType) {
mFontType = fontType;
}
public String getFontType() {
return mFontType;
}
}

@ -15,7 +15,7 @@
*/
package net.micode.notes.ui;
import android.graphics.Typeface;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
@ -547,12 +547,64 @@ public class NoteEditActivity extends Activity implements OnClickListener,
case R.id.menu_delete_remind:
mWorkingNote.setAlertDate(0, false);
break;
case R.id.menu_font_select:
showSingleAlertDiglog();
default:
break;
}
return true;
}
/**
*
*/
public void showSingleAlertDiglog() {
// 字体选项,"默认" 放在第一个
final String[] items = {"默认", "行楷", "新魏"};
// 创建对话框
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder.setTitle("选择字体");
// 使用单选框列出字体选项,默认选中第一个选项
alertBuilder.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch (i) {
case 0: // 默认
// 恢复为默认字体
mNoteEditor.setTypeface(Typeface.DEFAULT);
break;
case 1: // 行楷
mNoteEditor.setTypeface(Typeface.createFromAsset(getAssets(), "font/STXINGKA.ttf"));
break;
case 2: // 新魏
mNoteEditor.setTypeface(Typeface.createFromAsset(getAssets(), "font/STXINWEI.ttf"));
break;
}
// 显示选中的字体名称
Toast.makeText(NoteEditActivity.this, "选择字体: " + items[i], Toast.LENGTH_SHORT).show();
}
});
// 设置确定按钮,点击后关闭对话框
alertBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
// 设置取消按钮,点击后关闭对话框
alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
// 创建并显示对话框
alertBuilder.create().show();
}
private void setReminder() {
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
@ -808,6 +860,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private boolean saveNote() {
getWorkingText();
boolean saved = mWorkingNote.saveNote();
if (saved) {
/**
* There are two modes from List view to edit view, open one note,

@ -79,6 +79,10 @@ import java.io.InputStreamReader;
import java.util.HashSet;
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
private static final int SORT_BY_MODIFIED_DATE = 0;
private static final int SORT_BY_CREATED_DATE = 1;
private static final int SORT_BY_TITLE = 2;
private int mCurrentSortBy = SORT_BY_MODIFIED_DATE;
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
private static final int FOLDER_LIST_QUERY_TOKEN = 1;
@ -409,12 +413,33 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
};
private void startAsyncNotesListQuery() {
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
: NORMAL_SELECTION;
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {
String.valueOf(mCurrentFolderId)
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ?
ROOT_FOLDER_SELECTION : NORMAL_SELECTION;
String orderBy;
switch (mCurrentSortBy) {
case SORT_BY_CREATED_DATE:
orderBy = NoteColumns.CREATED_DATE + " DESC";
break;
case SORT_BY_TITLE:
orderBy = NoteColumns.SNIPPET + " ASC";
break;
case SORT_BY_MODIFIED_DATE:
default:
orderBy = NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC";
break;
}
mBackgroundQueryHandler.startQuery(
FOLDER_NOTE_LIST_QUERY_TOKEN,
null,
Notes.CONTENT_NOTE_URI,
NoteItemData.PROJECTION,
selection,
new String[] { String.valueOf(mCurrentFolderId) },
orderBy
);
updateNoteCount();
}
private final class BackgroundQueryHandler extends AsyncQueryHandler {
@ -427,6 +452,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
switch (token) {
case FOLDER_NOTE_LIST_QUERY_TOKEN:
mNotesListAdapter.changeCursor(cursor);
updateNoteCount();
break;
case FOLDER_LIST_QUERY_TOKEN:
if (cursor != null && cursor.getCount() > 0) {
@ -467,6 +493,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId);
this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE);
updateNoteCount();
}
private void batchDelete() {
@ -502,10 +529,38 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
}
mModeCallBack.finishActionMode();
updateNoteCount();
}
}.execute();
}
private void updateNoteCount() {
if (mNotesListAdapter != null) {
int count = mNotesListAdapter.getCount();
// 根据当前状态设置不同的标题
String title;
switch (mState) {
case SUB_FOLDER:
title = mTitleBar.getText() + " (" + count + ")";
break;
case CALL_RECORD_FOLDER:
title = getString(R.string.call_record_folder_name) + " (" + count + ")";
break;
default:
title = getString(R.string.note_count_format, count);
break;
}
mTitleBar.setText(title);
}
}
@Override
protected void onResume() {
super.onResume();
updateNoteCount();
}
private void deleteFolder(long folderId) {
if (folderId == Notes.ID_ROOT_FOLDER) {
Log.e(TAG, "Wrong folder id, should not happen " + folderId);
@ -777,10 +832,62 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
return true;
}
private void showSortingDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.menu_sort);
String[] sortOptions = {
getString(R.string.sort_by_modified_date),
getString(R.string.sort_by_created_date),
getString(R.string.sort_by_title)
};
builder.setSingleChoiceItems(sortOptions, mCurrentSortBy,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mCurrentSortBy = which;
updateSortOrder();
dialog.dismiss();
}
});
builder.show();
}
private void updateSortOrder() {
String orderBy;
switch (mCurrentSortBy) {
case SORT_BY_CREATED_DATE:
orderBy = NoteColumns.CREATED_DATE + " DESC";
break;
case SORT_BY_TITLE:
orderBy = NoteColumns.SNIPPET + " ASC";
break;
case SORT_BY_MODIFIED_DATE:
default:
orderBy = NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC";
break;
}
// 使用新的排序方式重新查询数据
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ?
ROOT_FOLDER_SELECTION : NORMAL_SELECTION;
mBackgroundQueryHandler.startQuery(
FOLDER_NOTE_LIST_QUERY_TOKEN,
null,
Notes.CONTENT_NOTE_URI,
NoteItemData.PROJECTION,
selection,
new String[] { String.valueOf(mCurrentFolderId) },
orderBy
);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_sort:
showSortingDialog();
break;
case R.id.menu_new_folder: {
showCreateOrModifyFolderDialog(true);
break;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save