第一次维护以及报告的合并

master
eazzy 11 months ago committed by SheYu
parent cf6a8efe75
commit e1917b50e2

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package net.micode.notes.data;//属于data这个包 package net.micode.notes.data;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
@ -25,64 +25,63 @@ import android.util.Log;
import java.util.HashMap; import java.util.HashMap;
/** /**
* @Package: net.micode.notes.data * @Package: net.micode.notes.data
* @ClassName: Contact * @ClassName: Contact
* @Description: * @Description:
* Contact * @Author: WUSHUXIAN
* HashMap * @CreateDate: 2023/12/20 23:26
* getContact * @Version: 1.0
*
* SQL
* 线线使
* @Author: YangYizhe
* @CreateDate: 12/17/2023 10:10 AM
* @Version: 1.0
*/ */
public class Contact { public class Contact {
/**
* ,
*/
private static HashMap<String, String> sContactCache; private static HashMap<String, String> sContactCache;
private static final String TAG = "Contact";//设置日志TAG标签 private static final String TAG = "Contact";
//查询联系人的SQL筛选语句
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'" + ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
+ " AND " + Data.RAW_CONTACT_ID + " IN " + " AND " + Data.RAW_CONTACT_ID + " IN "
+ "(SELECT raw_contact_id " + "(SELECT raw_contact_id "
+ " FROM phone_lookup" + " FROM phone_lookup"
+ " WHERE min_match = '+')"; + " WHERE min_match = '+')";
//获取联系人 /**
* @method getContact
* @description:
* @date: 2023/12/21 19:18
* @author: WuShuxian
* @param: context
* @param: phoneNumber
* @return: String
*/
public static String getContact(Context context, String phoneNumber) { public static String getContact(Context context, String phoneNumber) {
if(sContactCache == null) {/*如果缓存为空,就新建一个*/ //
if(sContactCache == null) {
sContactCache = new HashMap<String, String>(); sContactCache = new HashMap<String, String>();
} }
if(sContactCache.containsKey(phoneNumber)) {/*如果缓存中已经有该电话号码对应的联系人名字,就直接返回*/ if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber); return sContactCache.get(phoneNumber);
} }
String selection = CALLER_ID_SELECTION.replace("+", String selection = CALLER_ID_SELECTION.replace("+",
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));//将电话号码转换为最小匹配模式,用于筛选 PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
Cursor cursor = context.getContentResolver().query( Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI, Data.CONTENT_URI,
new String [] { Phone.DISPLAY_NAME }, new String [] { Phone.DISPLAY_NAME },
selection,//使用筛选条件 selection,
new String[] { phoneNumber }, new String[] { phoneNumber },
null); null);
if (cursor != null && cursor.moveToFirst()) {//如果找到了符合条件的联系人 if (cursor != null && cursor.moveToFirst()) {
try { try {
String name = cursor.getString(0);//获取联系人名字 String name = cursor.getString(0);
sContactCache.put(phoneNumber, name);//将电话号码和联系人名字添加到缓存中 sContactCache.put(phoneNumber, name);
return name;//返回联系人名字 return name;
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
Log.e(TAG, " Cursor get string error " + e.toString()); Log.e(TAG, " Cursor get string error " + e.toString());
return null; return null;
} finally { } finally {
cursor.close();//关闭游标 cursor.close();
} }
} else {/*没找到*/ } else {
Log.d(TAG, "No contact matched with number:" + phoneNumber); Log.d(TAG, "No contact matched with number:" + phoneNumber);
return null; return null;
} }

@ -27,6 +27,7 @@ import net.micode.notes.tool.DataUtils;
public class NoteItemData { public class NoteItemData {
// 用于定义查询操作中要返回的列
static final String [] PROJECTION = new String [] { static final String [] PROJECTION = new String [] {
NoteColumns.ID, NoteColumns.ID,
NoteColumns.ALERTED_DATE, NoteColumns.ALERTED_DATE,

@ -85,6 +85,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private static final String PREFERENCE_ADD_INTRODUCTION = "net.micode.notes.introduction"; private static final String PREFERENCE_ADD_INTRODUCTION = "net.micode.notes.introduction";
/**三个状态,主页面,文件夹,通话记录文件夹*/
private enum ListEditState { private enum ListEditState {
NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER
}; };
@ -100,6 +101,8 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private Button mAddNewNote; private Button mAddNewNote;
private boolean mDispatch; private boolean mDispatch;
// 控制背景颜色,初始为亮
private int mBackgroundColor = 1;
private int mOriginY; private int mOriginY;
@ -117,6 +120,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
public static final int NOTES_LISTVIEW_SCROLL_RATE = 30; public static final int NOTES_LISTVIEW_SCROLL_RATE = 30;
/** 私密模式,初始为 0 开启为 1*/
public static int mSecretMode = 0;
private NoteItemData mFocusNoteDataItem; private NoteItemData mFocusNoteDataItem;
private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?"; private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?";
@ -140,6 +146,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); // 调用父类的onCreate函数 super.onCreate(savedInstanceState); // 调用父类的onCreate函数
setContentView(R.layout.note_list); setContentView(R.layout.note_list);
getWindow().setBackgroundDrawableResource(R.drawable.bg_light);
initResources(); initResources();
setAppInfoFromRawRes(); setAppInfoFromRawRes();
} }
@ -463,10 +470,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
* @return * @return
*/ */
private void startAsyncNotesListQuery() { private void startAsyncNotesListQuery() {
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION : NORMAL_SELECTION; String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
: NORMAL_SELECTION;
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null, mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {String.valueOf(mCurrentFolderId)}, Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[]{
NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC"); String.valueOf(mCurrentFolderId)
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
} }
/** /**
* @Package: net.micode.notes.ui * @Package: net.micode.notes.ui
@ -530,6 +539,98 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}); });
builder.show(); builder.show();
} }
/**
* @method switchBackground
* @description
* @date: 1/3/2024 3:41 PM
* @author: YangYizhe
*/
private void switchBackground(){
mBackgroundColor = (mBackgroundColor + 1) % 2;
View frameLayout = findViewById(R.id.frame_layout_id);
if (mBackgroundColor == 1){
frameLayout.setBackgroundResource(R.drawable.bg_light);
} else{
frameLayout.setBackgroundResource(R.drawable.bg_dark);
}
}
private boolean isSecretMode(){
if(mSecretMode == 1){
return true;
}else {
return false;
}
}
/**
* @method enterSecertMode
* @description
* @date: 1/2/2024 8:18 PM
* @author: YangYizhe
*/
private void enterSecretMode(){
AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
dialog.setTitle("重要提醒");
dialog.setMessage("您确认进入隐私模式吗?");
dialog.setCancelable(false);
dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mSecretMode = 1;
startAsyncNotesListQuery();
Toast.makeText(NotesListActivity.this,"您已进入隐私模式",Toast.LENGTH_SHORT).show();
}
});
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which){}
});
dialog.show();
}
/**
* @method quitSecretMode
* @description 退
* @date: 1/2/2024 8:20 PM
* @author: YangYizhe
*/
private void quitSecretMode(){
AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
dialog.setTitle("重要提醒");
dialog.setMessage("您确认退出隐私模式吗?");
dialog.setCancelable(false);
dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mSecretMode = 0;
startAsyncNotesListQuery();
Toast.makeText(NotesListActivity.this,"您已退出隐私模式",Toast.LENGTH_SHORT).show();
}
});
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which){}
});
dialog.show();
}
/**
* @method restoreDeletedNodes
* @description
* @date: 1/3/2024 8:11 PM
* @author: YangYizhe
*/
private void restoreDeletedNodes(){
mState = ListEditState.SUB_FOLDER;
mCurrentFolderId = Notes.ID_TRASH_FOLER;
startAsyncNotesListQuery();
mTitleBar.setText("回收站");
mTitleBar.setVisibility(View.VISIBLE);
}
/** /**
* @method createNewNote * @method createNewNote
* @description 便 * @description 便
@ -544,6 +645,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId); intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId);
this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE); this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE);
} }
/** /**
* @method batchDelete * @method batchDelete
* @description: * @description:
@ -558,15 +660,15 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
new AsyncTask<Void, Void, HashSet<AppWidgetAttribute>>() { new AsyncTask<Void, Void, HashSet<AppWidgetAttribute>>() {
protected HashSet<AppWidgetAttribute> doInBackground(Void... unused) { protected HashSet<AppWidgetAttribute> doInBackground(Void... unused) {
HashSet<AppWidgetAttribute> widgets = mNotesListAdapter.getSelectedWidget(); HashSet<AppWidgetAttribute> widgets = mNotesListAdapter.getSelectedWidget();
//如果没有同步,直接删除 // 如果是回收站中的,直接删除
if (!isSyncMode()) { if (mCurrentFolderId == Notes.ID_TRASH_FOLER) {
if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter
.getSelectedItemIds())) { .getSelectedItemIds())) {
} else { } else {
Log.e(TAG, "Delete notes error, should not happens"); Log.e(TAG, "Delete notes error, should not happens");
} }
} }
//已同步,将删除的便签移到垃圾桶 // 将删除的便签移到回收站
else { else {
if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter
.getSelectedItemIds(), Notes.ID_TRASH_FOLER)) { .getSelectedItemIds(), Notes.ID_TRASH_FOLER)) {
@ -891,6 +993,14 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} }
@Override @Override
/**
* @method onPrepareOptionsMenu
* @description menuAndroid
* @date: 1/2/2024 7:40 PM
* @author: YangYizhe
* @param [menu]
* @return boolean
*/
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
menu.clear(); menu.clear();
if (mState == ListEditState.NOTE_LIST) { if (mState == ListEditState.NOTE_LIST) {
@ -905,10 +1015,29 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} else { } else {
Log.e(TAG, "Wrong state:" + mState); Log.e(TAG, "Wrong state:" + mState);
} }
// 若在隐私模式之中,则不显示进入隐私模式的选项,不在隐私模式之中,则不显示退出隐私模式选项
if(isSecretMode()){
menu.findItem(R.id.menu_secret).setVisible(false);
} else {
menu.findItem(R.id.menu_quit_secret).setVisible(false);
}
if(mBackgroundColor==1) {
menu.findItem(R.id.menu_light_mode).setVisible(false);
} else {
menu.findItem(R.id.menu_dark_mode).setVisible(false);
}
return true; return true;
} }
@Override @Override
/**
* @method onOptionsItemSelected
* @description
* @date: 1/2/2024 7:41 PM
* @author: YangYizhe
* @param [item]
* @return boolean
*/
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); int itemId = item.getItemId();
if (itemId == R.id.menu_new_folder) { if (itemId == R.id.menu_new_folder) {
@ -931,6 +1060,16 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
createNewNote(); createNewNote();
} else if (itemId == R.id.menu_search) { } else if (itemId == R.id.menu_search) {
onSearchRequested(); onSearchRequested();
} else if (itemId == R.id.menu_secret) {
enterSecretMode();
} else if (itemId == R.id.menu_quit_secret){
quitSecretMode();
} else if(itemId == R.id.menu_light_mode) {
switchBackground();
} else if(itemId == R.id.menu_dark_mode) {
switchBackground();
} else if (itemId == R.id.menu_restore) {
restoreDeletedNodes();
} }
return true; return true;
} }

@ -26,7 +26,7 @@ public class NotesListItem extends LinearLayout {
private ImageView mAlert;//闹钟图片 private ImageView mAlert;//闹钟图片
private TextView mTitle; //标题 private TextView mTitle; //标题
private TextView mTime; //时间 private TextView mTime; //时间
private TextView mCallName; // private TextView mCallName;
private NoteItemData mItemData; //标签数据 private NoteItemData mItemData; //标签数据
private CheckBox mCheckBox; //打钩框 private CheckBox mCheckBox; //打钩框

@ -17,9 +17,10 @@
<FrameLayout <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame_layout_id"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/list_background"> android:background="@drawable/bg_light">
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"

@ -36,4 +36,24 @@
<item <item
android:id="@+id/menu_search" android:id="@+id/menu_search"
android:title="@string/menu_search"/> android:title="@string/menu_search"/>
<item
android:id="@+id/menu_light_mode"
android:title="@string/light_mode"/>
<item
android:id="@+id/menu_dark_mode"
android:title="@string/dark_mode"/>
<item
android:id="@+id/menu_secret"
android:title="@string/menu_secret"/>
<item
android:id="@+id/menu_quit_secret"
android:title="@string/menu_quit_secret"/>
<item
android:id="@+id/menu_restore"
android:title="@string/menu_restore"/>
</menu> </menu>

@ -21,4 +21,20 @@
<item <item
android:id="@+id/menu_new_note" android:id="@+id/menu_new_note"
android:title="@string/notelist_menu_new"/> android:title="@string/notelist_menu_new"/>
<item
android:id="@+id/menu_light_mode"
android:title="@string/light_mode"/>
<item
android:id="@+id/menu_dark_mode"
android:title="@string/dark_mode"/>
<item
android:id="@+id/menu_secret"
android:title="@string/menu_secret"/>
<item
android:id="@+id/menu_quit_secret"
android:title="@string/menu_quit_secret"/>
</menu> </menu>

@ -119,6 +119,14 @@
<string name="search">便签</string> <string name="search">便签</string>
<string name="datetime_dialog_ok">设置</string> <string name="datetime_dialog_ok">设置</string>
<string name="datetime_dialog_cancel">取消</string> <string name="datetime_dialog_cancel">取消</string>
<string name="light_mode">亮背景</string>
<string name="dark_mode">暗背景</string>
<string name="menu_secret">私密模式</string>
<string name="menu_quit_secret">退出私密模式</string>
<string name="note_length">字符数</string>
<string name="menu_restore">恢复</string>
<string name="title_activity_splash">欢迎页面</string>
<string name="eazzy_note">EAZZY\nNOTE</string>
<plurals name="search_results_title"> <plurals name="search_results_title">
<item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 条符合“<xliff:g id="SEARCH">%2$s</xliff:g>”的搜索结果</item> <item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 条符合“<xliff:g id="SEARCH">%2$s</xliff:g>”的搜索结果</item>
</plurals> </plurals>

@ -120,6 +120,14 @@
<string name="search">便籤</string> <string name="search">便籤</string>
<string name="datetime_dialog_ok">設置</string> <string name="datetime_dialog_ok">設置</string>
<string name="datetime_dialog_cancel">取消</string> <string name="datetime_dialog_cancel">取消</string>
<string name="light_mode">亮背景</string>
<string name="dark_mode">暗背景</string>
<string name="menu_secret">私密模式</string>
<string name="menu_quit_secret">退出私密模式</string>
<string name="note_length">字符数</string>
<string name="menu_restore">恢复</string>
<string name="title_activity_splash">欢迎页面</string>
<string name="eazzy_note">EAZZY\nNOTE</string>
<plurals name="search_results_title"> <plurals name="search_results_title">
<item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 條符合”<xliff:g id="SEARCH">%2$s</xliff:g>“的搜尋結果</item> <item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 條符合”<xliff:g id="SEARCH">%2$s</xliff:g>“的搜尋結果</item>
</plurals> </plurals>

@ -17,4 +17,9 @@
<resources> <resources>
<color name="user_query_highlight">#335b5b5b</color> <color name="user_query_highlight">#335b5b5b</color>
<color name="light_blue_600">#FF039BE5</color>
<color name="light_blue_900">#FF01579B</color>
<color name="light_blue_A200">#FF40C4FF</color>
<color name="light_blue_A400">#FF00B0FF</color>
<color name="black_overlay">#66000000</color>
</resources> </resources>

@ -190,8 +190,8 @@
<item name="android:textColor">@android:color/black</item> <item name="android:textColor">@android:color/black</item>
</style> </style>
<plurals name="search_results_title"> <plurals name="search_results_title">
<item quantity="one"><xliff:g id="number" example="1">%1$s</xliff:g> result for \"<xliff:g id="search" example="???">%2$s</xliff:g>\"</item> <item quantity="one"><xliff:g example="1" id="number">%1$s</xliff:g> result for \"<xliff:g example="???" id="search">%2$s</xliff:g>\"</item>
<!-- Case of 0 or 2 or more results. --> <!-- Case of 0 or 2 or more results. -->
<item quantity="other"><xliff:g id="number" example="15">%1$s</xliff:g> results for \"<xliff:g id="search" example="???">%2$s</xliff:g>\"</item> <item quantity="other"><xliff:g example="15" id="number">%1$s</xliff:g> results for \"<xliff:g example="???" id="search">%2$s</xliff:g>\"</item>
</plurals> </plurals>
</resources> </resources>

@ -16,7 +16,6 @@
--> -->
<resources> <resources>
<style name="TextAppearanceSuper"> <style name="TextAppearanceSuper">
<item name="android:textSize">@dimen/text_font_size_super</item> <item name="android:textSize">@dimen/text_font_size_super</item>
<item name="android:textColorLink">#0000ff</item> <item name="android:textColorLink">#0000ff</item>
@ -25,12 +24,10 @@
<item name="android:textSize">@dimen/text_font_size_large</item> <item name="android:textSize">@dimen/text_font_size_large</item>
<item name="android:textColorLink">#0000ff</item> <item name="android:textColorLink">#0000ff</item>
</style> </style>
<style name="TextAppearanceMedium"> <style name="TextAppearanceMedium">
<item name="android:textSize">@dimen/text_font_size_medium</item> <item name="android:textSize">@dimen/text_font_size_medium</item>
<item name="android:textColorLink">#0000ff</item> <item name="android:textColorLink">#0000ff</item>
</style> </style>
<style name="TextAppearanceNormal"> <style name="TextAppearanceNormal">
<item name="android:textSize">@dimen/text_font_size_normal</item> <item name="android:textSize">@dimen/text_font_size_normal</item>
<item name="android:textColorLink">#0000ff</item> <item name="android:textColorLink">#0000ff</item>
@ -52,7 +49,7 @@
</style> </style>
<style name="HighlightTextAppearancePrimary"> <style name="HighlightTextAppearancePrimary">
<item name="android:textSize">@dimen/text_font_size_normal</item> <item name="android:textSize">@dimen/text_font_size_normal</item>
<item name="android:textColor">@color/primary_text_dark</item> <item name="android:textColor">@color/primary_text_dark</item>
</style> </style>

Loading…
Cancel
Save