diff --git a/app/SplashActivity b/app/SplashActivity
new file mode 100644
index 0000000..e69de29
diff --git a/app/sonar-project.properties b/app/sonar-project.properties
new file mode 100644
index 0000000..86a5eac
--- /dev/null
+++ b/app/sonar-project.properties
@@ -0,0 +1,7 @@
+sonar.projectKey=test
+sonar.projectName=test
+#sonar.projectVersion=1.0
+#sonar.sources=./src
+sonar.sourceEncoding=UTF-8
+#sonar.language=java
+sonar.java.binaries=.
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a0cf89e..d38b8f6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,14 +1,14 @@
-
-
-
+
-
+ android:versionName="0.1">
+
+
+
-
+
@@ -21,10 +21,34 @@
-
+
+
+
+
+
+ android:windowSoftInputMode="adjustPan" />
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
-
+ android:multiprocess="true" />
+
+
+
+
+
+
-
-
+
+
@@ -103,45 +159,35 @@
+
-
-
-
+
-
-
-
+
-
-
+ android:name=".ui.AlarmReceiver"
+ android:process=":remote" />
-
-
+ android:theme="@android:style/Theme.Holo.Wallpaper.NoTitleBar" />
-
-
+ android:theme="@android:style/Theme.Holo.Light" />
-
-
+ android:name=".gtask.remote.GTaskSyncService"
+ android:exported="false" />
-
+
+
\ No newline at end of file
diff --git a/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java b/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java
index 3c77e81..c8383c7 100644
--- a/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java
+++ b/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java
@@ -47,9 +47,9 @@ import java.io.IOException;
public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener {
// 笔记的ID
private long mNoteId;
- // 笔记内容的简短预览
+ // 笔记内容的简短预览 文本在数据库存储的id号
private String mSnippet;
- // 预览文本的最大长度
+ // 预览文本的最大长度 闹钟提醒时出现的文本片段
private static final int SNIPPET_PREW_MAX_LEN = 60;
// 用于播放提醒声音的MediaPlayer对象
MediaPlayer mPlayer;
@@ -60,6 +60,9 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
+ //Bundle类型的数据与Map类型的数据相似,都是以key-value的形式存储数据的
+ //onsaveInstanceState方法是用来保存Activity的状态的
+ //能从onCreate的参数savedInsanceState中获得状态数据
super.onCreate(savedInstanceState);
// 请求无标题的窗口
requestWindowFeature(Window.FEATURE_NO_TITLE);
@@ -69,9 +72,13 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
if (!isScreenOn()) {
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ //保持窗体点亮
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
+ //将窗体点亮
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
+ //允许窗体点亮时锁屏
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
+ //在手机锁屏后如果到了闹钟提示时间,点亮屏幕
}
// 从Intent中获取笔记ID和简短内容
@@ -79,9 +86,12 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
try {
mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1));
mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId);
+ //根据ID从数据库中获取标签的内容
+ //getContentResolver()是实现数据共享,实例存储
mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0,
SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info)
: mSnippet;
+ //判断标签片段是否达到符合长度
} catch (IllegalArgumentException e) {
e.printStackTrace();
return;
@@ -91,9 +101,12 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
mPlayer = new MediaPlayer();
if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) {
showActionDialog();
+ //弹出对话框
playAlarmSound();
+ //闹钟提示音激发
} else {
finish();
+ //完成闹钟动作
}
}
@@ -103,6 +116,7 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
* @return 如果屏幕已打开则返回true,否则返回false。
*/
private boolean isScreenOn() {
+ //判断屏幕是否锁屏,调用系统函数判断,最后返回值是布尔类型
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
return pm.isScreenOn();
}
@@ -112,8 +126,9 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
* 根据系统设置选择合适的音频流类型,并尝试播放选定的报警声音。
*/
private void playAlarmSound() {
+ //闹钟提示音激发
Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
-
+ //调用系统的铃声管理URI,得到闹钟提示音
// 检查是否在静音模式下影响报警声音
int silentModeStreams = Settings.System.getInt(getContentResolver(),
Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
@@ -125,11 +140,18 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
}
try {
mPlayer.setDataSource(this, url);
+ //方法:setDataSource(Context context, Uri uri)
+ //解释:无返回值,设置多媒体数据来源【根据 Uri】
mPlayer.prepare();
+ //准备同步
mPlayer.setLooping(true);
+ //设置是否循环播放
mPlayer.start();
+ //开始播放
} catch (IllegalArgumentException e) {
e.printStackTrace();
+ //e.printStackTrace()函数功能是抛出异常, 还将显示出更深的调用信息
+ //System.out.println(e),这个方法打印出异常,并且输出在哪里出现的异常
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
@@ -145,12 +167,19 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
*/
private void showActionDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
+ //AlertDialog的构造方法全部是Protected的
+ //所以不能直接通过new一个AlertDialog来创建出一个AlertDialog。
+ //要创建一个AlertDialog,就要用到AlertDialog.Builder中的create()方法
+ //如这里的dialog就是新建了一个AlertDialog
dialog.setTitle(R.string.app_name);
+ //为对话框设置标题
dialog.setMessage(mSnippet);
+ //为对话框设置内容
dialog.setPositiveButton(R.string.notealert_ok, this);
+ //给对话框添加"Yes"按钮
if (isScreenOn()) {
dialog.setNegativeButton(R.string.notealert_enter, this);
- }
+ }//对话框添加"No"按钮
dialog.show().setOnDismissListener(this);
}
@@ -160,12 +189,19 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
*/
public void onClick(DialogInterface dialog, int which) {
switch (which) {
+ //用which来选择click后下一步的操作
case DialogInterface.BUTTON_NEGATIVE:
// 如果点击的是“进入”按钮,则启动笔记编辑活动
+ //这是取消操作
Intent intent = new Intent(this, NoteEditActivity.class);
+ //实现两个类间的数据传输
intent.setAction(Intent.ACTION_VIEW);
+ //设置动作属性
intent.putExtra(Intent.EXTRA_UID, mNoteId);
+ //实现key-value对
+ //EXTRA_UID为key;mNoteId为键
startActivity(intent);
+ //开始动作
break;
default:
// 关闭活动
@@ -178,8 +214,11 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
* 停止播放提醒声音,结束当前活动。
*/
public void onDismiss(DialogInterface dialog) {
+ //忽略
stopAlarmSound();
+ //停止闹钟声音
finish();
+ //完成该动作
}
/*
@@ -189,7 +228,9 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
private void stopAlarmSound() {
if (mPlayer != null) {
mPlayer.stop();
+ //停止播放
mPlayer.release();
+ //释放MediaPlayer对象
mPlayer = null;
}
}
diff --git a/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java b/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java
index 42d7313..d39cf6e 100644
--- a/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java
+++ b/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java
@@ -21,10 +21,15 @@ public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// 设置Intent的类,以便启动AlarmAlertActivity
+ //启动AlarmAlertActivity
intent.setClass(context, AlarmAlertActivity.class);
// 添加标志,表示在一个新的任务中启动Activity
+ //activity要存在于activity的栈中,而非activity的途径启动activity时必然不存在一个activity的栈
+ //所以要新起一个栈装入启动的activity
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// 根据设置的Intent启动Activity
context.startActivity(intent);
}
}
+//这是实现alarm这个功能最接近用户层的包,基于上面的两个包,
+//作用还需要深究但是对于setClass和addFlags的
diff --git a/app/src/main/java/net/micode/notes/ui/ChangePassword.java b/app/src/main/java/net/micode/notes/ui/ChangePassword.java
new file mode 100644
index 0000000..9ecd8ba
--- /dev/null
+++ b/app/src/main/java/net/micode/notes/ui/ChangePassword.java
@@ -0,0 +1,187 @@
+package net.micode.notes.ui;
+
+import android.annotation.SuppressLint;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.WindowInsets;
+
+import net.micode.notes.databinding.ActivityChangePasswordBinding;
+import net.micode.notes.R;
+
+/**
+ * An example full-screen activity that shows and hides the system UI (i.e.
+ * status bar and navigation/system bar) with user interaction.
+ */
+public class ChangePassword extends AppCompatActivity {
+ /**
+ * Whether or not the system UI should be auto-hidden after
+ * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
+ */
+ private static final boolean AUTO_HIDE = true;
+
+ /**
+ * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
+ * user interaction before hiding the system UI.
+ */
+ private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
+
+ /**
+ * Some older devices needs a small delay between UI widget updates
+ * and a change of the status and navigation bar.
+ */
+ private static final int UI_ANIMATION_DELAY = 300;
+ private final Handler mHideHandler = new Handler(Looper.myLooper());
+ private View mContentView;
+ private final Runnable mHidePart2Runnable = new Runnable() {
+ @SuppressLint("InlinedApi")
+ @Override
+ public void run() {
+ // Delayed removal of status and navigation bar
+ if (Build.VERSION.SDK_INT >= 30) {
+ mContentView.getWindowInsetsController().hide(
+ WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
+ } else {
+ // Note that some of these constants are new as of API 16 (Jelly Bean)
+ // and API 19 (KitKat). It is safe to use them, as they are inlined
+ // at compile-time and do nothing on earlier devices.
+ mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
+ }
+ }
+ };
+ private View mControlsView;
+ private final Runnable mShowPart2Runnable = new Runnable() {
+ @Override
+ public void run() {
+ // Delayed display of UI elements
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.show();
+ }
+ mControlsView.setVisibility(View.VISIBLE);
+ }
+ };
+ private boolean mVisible;
+ private final Runnable mHideRunnable = new Runnable() {
+ @Override
+ public void run() {
+ hide();
+ }
+ };
+ /**
+ * Touch listener to use for in-layout UI controls to delay hiding the
+ * system UI. This is to prevent the jarring behavior of controls going away
+ * while interacting with activity UI.
+ */
+ private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View view, MotionEvent motionEvent) {
+ switch (motionEvent.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ if (AUTO_HIDE) {
+ delayedHide(AUTO_HIDE_DELAY_MILLIS);
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ view.performClick();
+ break;
+ default:
+ break;
+ }
+ return false;
+ }
+ };
+ private ActivityChangePasswordBinding binding;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ binding = ActivityChangePasswordBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
+
+ mVisible = true;
+ mControlsView = binding.fullscreenContentControls;
+ mContentView = binding.fullscreenContent;
+
+ // Set up the user interaction to manually show or hide the system UI.
+ mContentView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ toggle();
+ }
+ });
+
+ // Upon interacting with UI controls, delay any scheduled hide()
+ // operations to prevent the jarring behavior of controls going away
+ // while interacting with the UI.
+ binding.dummyButton.setOnTouchListener(mDelayHideTouchListener);
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+
+ // Trigger the initial hide() shortly after the activity has been
+ // created, to briefly hint to the user that UI controls
+ // are available.
+ delayedHide(100);
+ }
+
+ private void toggle() {
+ if (mVisible) {
+ hide();
+ } else {
+ show();
+ }
+ }
+
+ private void hide() {
+ // Hide UI first
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.hide();
+ }
+ mControlsView.setVisibility(View.GONE);
+ mVisible = false;
+
+ // Schedule a runnable to remove the status and navigation bar after a delay
+ mHideHandler.removeCallbacks(mShowPart2Runnable);
+ mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
+ }
+
+ private void show() {
+ // Show the system bar
+ if (Build.VERSION.SDK_INT >= 30) {
+ mContentView.getWindowInsetsController().show(
+ WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
+ } else {
+ mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ }
+ mVisible = true;
+
+ // Schedule a runnable to display UI elements after a delay
+ mHideHandler.removeCallbacks(mHidePart2Runnable);
+ mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
+ }
+
+ /**
+ * Schedules a call to hide() in delay milliseconds, canceling any
+ * previously scheduled calls.
+ */
+ private void delayedHide(int delayMillis) {
+ mHideHandler.removeCallbacks(mHideRunnable);
+ mHideHandler.postDelayed(mHideRunnable, delayMillis);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/net/micode/notes/ui/DeletingPassword.java b/app/src/main/java/net/micode/notes/ui/DeletingPassword.java
new file mode 100644
index 0000000..a05143e
--- /dev/null
+++ b/app/src/main/java/net/micode/notes/ui/DeletingPassword.java
@@ -0,0 +1,187 @@
+package net.micode.notes.ui;
+
+import android.annotation.SuppressLint;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.WindowInsets;
+
+import net.micode.notes.databinding.ActivityDeletePasswordBinding;
+import net.micode.notes.R;
+
+/**
+ * An example full-screen activity that shows and hides the system UI (i.e.
+ * status bar and navigation/system bar) with user interaction.
+ */
+public class DeletingPassword extends AppCompatActivity {
+ /**
+ * Whether or not the system UI should be auto-hidden after
+ * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
+ */
+ private static final boolean AUTO_HIDE = true;
+
+ /**
+ * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
+ * user interaction before hiding the system UI.
+ */
+ private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
+
+ /**
+ * Some older devices needs a small delay between UI widget updates
+ * and a change of the status and navigation bar.
+ */
+ private static final int UI_ANIMATION_DELAY = 300;
+ private final Handler mHideHandler = new Handler(Looper.myLooper());
+ private View mContentView;
+ private final Runnable mHidePart2Runnable = new Runnable() {
+ @SuppressLint("InlinedApi")
+ @Override
+ public void run() {
+ // Delayed removal of status and navigation bar
+ if (Build.VERSION.SDK_INT >= 30) {
+ mContentView.getWindowInsetsController().hide(
+ WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
+ } else {
+ // Note that some of these constants are new as of API 16 (Jelly Bean)
+ // and API 19 (KitKat). It is safe to use them, as they are inlined
+ // at compile-time and do nothing on earlier devices.
+ mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
+ }
+ }
+ };
+ private View mControlsView;
+ private final Runnable mShowPart2Runnable = new Runnable() {
+ @Override
+ public void run() {
+ // Delayed display of UI elements
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.show();
+ }
+ mControlsView.setVisibility(View.VISIBLE);
+ }
+ };
+ private boolean mVisible;
+ private final Runnable mHideRunnable = new Runnable() {
+ @Override
+ public void run() {
+ hide();
+ }
+ };
+ /**
+ * Touch listener to use for in-layout UI controls to delay hiding the
+ * system UI. This is to prevent the jarring behavior of controls going away
+ * while interacting with activity UI.
+ */
+ private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View view, MotionEvent motionEvent) {
+ switch (motionEvent.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ if (AUTO_HIDE) {
+ delayedHide(AUTO_HIDE_DELAY_MILLIS);
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ view.performClick();
+ break;
+ default:
+ break;
+ }
+ return false;
+ }
+ };
+ private ActivityDeletePasswordBinding binding;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ binding = ActivityDeletePasswordBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
+
+ mVisible = true;
+ mControlsView = binding.fullscreenContentControls;
+ mContentView = binding.fullscreenContent;
+
+ // Set up the user interaction to manually show or hide the system UI.
+ mContentView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ toggle();
+ }
+ });
+
+ // Upon interacting with UI controls, delay any scheduled hide()
+ // operations to prevent the jarring behavior of controls going away
+ // while interacting with the UI.
+ binding.dummyButton.setOnTouchListener(mDelayHideTouchListener);
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+
+ // Trigger the initial hide() shortly after the activity has been
+ // created, to briefly hint to the user that UI controls
+ // are available.
+ delayedHide(100);
+ }
+
+ private void toggle() {
+ if (mVisible) {
+ hide();
+ } else {
+ show();
+ }
+ }
+
+ private void hide() {
+ // Hide UI first
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.hide();
+ }
+ mControlsView.setVisibility(View.GONE);
+ mVisible = false;
+
+ // Schedule a runnable to remove the status and navigation bar after a delay
+ mHideHandler.removeCallbacks(mShowPart2Runnable);
+ mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
+ }
+
+ private void show() {
+ // Show the system bar
+ if (Build.VERSION.SDK_INT >= 30) {
+ mContentView.getWindowInsetsController().show(
+ WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
+ } else {
+ mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ }
+ mVisible = true;
+
+ // Schedule a runnable to display UI elements after a delay
+ mHideHandler.removeCallbacks(mHidePart2Runnable);
+ mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
+ }
+
+ /**
+ * Schedules a call to hide() in delay milliseconds, canceling any
+ * previously scheduled calls.
+ */
+ private void delayedHide(int delayMillis) {
+ mHideHandler.removeCallbacks(mHideRunnable);
+ mHideHandler.postDelayed(mHideRunnable, delayMillis);
+ }
+}
\ No newline at end of file
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 76c4c22..3c322ec 100644
--- a/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
+++ b/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
@@ -566,6 +566,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
mFontSizeSelector.setVisibility(View.GONE); // 隐藏字体大小选择器
}
+
+
}
/**
@@ -616,8 +618,11 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* @param menu 选项菜单对象。
* @return 总是返回true。
*/
+ public static int secret_mode = 0;
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
+
+
// 如果Activity正在结束,则不进行任何操作
if (isFinishing()) {
return true;
@@ -715,13 +720,16 @@ public class NoteEditActivity extends Activity implements OnClickListener,
*/
private void setReminder() {
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
+ // 建立修改时间日期的对话框
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
public void OnDateTimeSet(AlertDialog dialog, long date) {
// 用户设定时间后,设置提醒
mWorkingNote.setAlertDate(date, true);
}
});
+ //建立时间日期的监听器
d.show();
+ //显示对话框
}
/**
@@ -804,18 +812,23 @@ public class NoteEditActivity extends Activity implements OnClickListener,
public void onClockAlertChanged(long date, boolean set) {
if (!mWorkingNote.existInDatabase()) {
saveNote();
+ //首先保存已有的便签
}
if (mWorkingNote.getNoteId() > 0) {
Intent intent = new Intent(this, AlarmReceiver.class);
intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId()));
+ //若有有运行的便签就是建立一个链接器将标签id都存在uri中
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE));
+ //设置提醒管理器
showAlertHeader();
if (!set) {
alarmManager.cancel(pendingIntent);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent);
}
+ //没有运行的便签就报错
+ //如果用户设置了时间,就通过提醒管理器设置一个监听事项
} else {
Log.e(TAG, "Clock alert setting error");
showToast(R.string.error_note_empty_for_clock);
@@ -1139,3 +1152,4 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
}
+
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 b53dfee..9ee8422 100644
--- a/app/src/main/java/net/micode/notes/ui/NotesListActivity.java
+++ b/app/src/main/java/net/micode/notes/ui/NotesListActivity.java
@@ -81,6 +81,10 @@ import java.util.HashSet;
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
// 定义文件夹中笔记列表查询的标记
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
+ public static int secret_mode = 0;
+ private int time_mode=1;
+
+ private int mode=-1;
// 定义文件夹列表查询的标记
private static final int FOLDER_LIST_QUERY_TOKEN = 1;
@@ -102,7 +106,6 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER
}
- ;
// 当前编辑状态
private ListEditState mState;
@@ -172,6 +175,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.note_list);
+ getWindow().setBackgroundDrawableResource(R.drawable.day_time);
initResources();
// 用户首次使用时插入介绍信息
@@ -548,14 +552,37 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
* 根据当前文件夹ID选择不同的查询条件,启动一个后台查询处理该查询。
*/
private void startAsyncNotesListQuery() {
- // 根据当前文件夹ID选择查询条件
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");
+ if(secret_mode == 0) {
+ 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");
+ }
+ else{
+ String str1 = "520";
+ String [] PROJECTION = new String [] { //定义一个新的PROJECTION数组,只换掉SNIPPET
+ NoteColumns.ID,
+ NoteColumns.ALERTED_DATE,
+ NoteColumns.BG_COLOR_ID,
+ NoteColumns.CREATED_DATE,
+ NoteColumns.HAS_ATTACHMENT,
+ NoteColumns.MODIFIED_DATE,
+ NoteColumns.NOTES_COUNT,
+ NoteColumns.PARENT_ID,
+// NoteColumns.SNIPPET,
+ str1,
+ NoteColumns.TYPE,
+ NoteColumns.WIDGET_ID,
+ NoteColumns.WIDGET_TYPE,
+ };
+ mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
+ Notes.CONTENT_NOTE_URI, PROJECTION, selection, new String[]{
+ String.valueOf(mCurrentFolderId)
+ }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
+
+ }
}
/**
@@ -1050,10 +1077,17 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
* @param menu 菜单对象。
* @return 总是返回true。
*/
+
+
@Override
+
public boolean onPrepareOptionsMenu(Menu menu) {
+
+
+
menu.clear(); // 清除之前的菜单项
// 根据当前状态加载不同的菜单布局
+
if (mState == ListEditState.NOTE_LIST) {
getMenuInflater().inflate(R.menu.note_list, menu);
// 设置同步或取消同步菜单项的标题
@@ -1066,7 +1100,20 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} else {
Log.e(TAG, "Wrong state:" + mState);
}
+
+ if(mode==-1)
+ {
+ menu.findItem(R.id.menu_girl).setVisible(false);
+ }
+ if(time_mode==1) {
+ menu.findItem(R.id.menu_daytime).setVisible(false);
+ } else {
+ menu.findItem(R.id.menu_night_time).setVisible(false);
+ }
return true;
+
+
+
}
/**
@@ -1075,9 +1122,54 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
* @param item 被选择的菜单项。
* @return 如果事件已成功处理,则返回true;否则如果事件未处理,则返回false。
*/
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
+
switch (item.getItemId()) {
+
+ case R.id.menu_secret: { //进入私密模式
+ secret_mode = 1;
+ 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) {
+ startAsyncNotesListQuery();
+ Toast.makeText(NotesListActivity.this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
+ }
+ });
+ dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which){}
+ });
+ dialog.show();
+ startAsyncNotesListQuery();
+ Toast.makeText(this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
+ break;
+ }
+ case R.id.menu_quit_secret:{ //退出私密模式
+ secret_mode = 0;
+ 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) {
+ startAsyncNotesListQuery();
+ Toast.makeText(NotesListActivity.this,"您已退出私密模式",Toast.LENGTH_SHORT).show();
+ }
+ });
+ dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which){}
+ });
+ dialog.show();
+ break;
+ }
case R.id.menu_new_folder: {
showCreateOrModifyFolderDialog(true); // 显示创建新文件夹的对话框
break;
@@ -1107,11 +1199,35 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
createNewNote(); // 创建新笔记
break;
}
+ case R.id.menu_daytime: {
+ time_mode = 1;
+ getWindow().setBackgroundDrawableResource(R.drawable.day_time);
+ break;
+ }
+ case R.id.menu_night_time: {
+ time_mode=0;
+ getWindow().setBackgroundDrawableResource(R.drawable.night_time);
+ break;
+ }
+
+
+
+
+
+
+
case R.id.menu_search:
onSearchRequested(); // 触发搜索请求
break;
default:
break;
+
+
+
+
+
+
+
}
return true;
}
@@ -1302,4 +1418,8 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
builder.show();
}
+
+
+
+
}
diff --git a/app/src/main/java/net/micode/notes/ui/NotesListItem.java b/app/src/main/java/net/micode/notes/ui/NotesListItem.java
index 1e53b26..91c2067 100644
--- a/app/src/main/java/net/micode/notes/ui/NotesListItem.java
+++ b/app/src/main/java/net/micode/notes/ui/NotesListItem.java
@@ -155,3 +155,5 @@ public class NotesListItem extends LinearLayout {
}
}
+
+
diff --git a/app/src/main/java/net/micode/notes/ui/SettingPassword.java b/app/src/main/java/net/micode/notes/ui/SettingPassword.java
new file mode 100644
index 0000000..129a7d0
--- /dev/null
+++ b/app/src/main/java/net/micode/notes/ui/SettingPassword.java
@@ -0,0 +1,187 @@
+package net.micode.notes.ui;
+
+import android.annotation.SuppressLint;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.WindowInsets;
+
+import net.micode.notes.databinding.ActivitySettingPasswordBinding;
+import net.micode.notes.R;
+
+/**
+ * An example full-screen activity that shows and hides the system UI (i.e.
+ * status bar and navigation/system bar) with user interaction.
+ */
+public class SettingPassword extends AppCompatActivity {
+ /**
+ * Whether or not the system UI should be auto-hidden after
+ * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
+ */
+ private static final boolean AUTO_HIDE = true;
+
+ /**
+ * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
+ * user interaction before hiding the system UI.
+ */
+ private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
+
+ /**
+ * Some older devices needs a small delay between UI widget updates
+ * and a change of the status and navigation bar.
+ */
+ private static final int UI_ANIMATION_DELAY = 300;
+ private final Handler mHideHandler = new Handler(Looper.myLooper());
+ private View mContentView;
+ private final Runnable mHidePart2Runnable = new Runnable() {
+ @SuppressLint("InlinedApi")
+ @Override
+ public void run() {
+ // Delayed removal of status and navigation bar
+ if (Build.VERSION.SDK_INT >= 30) {
+ mContentView.getWindowInsetsController().hide(
+ WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
+ } else {
+ // Note that some of these constants are new as of API 16 (Jelly Bean)
+ // and API 19 (KitKat). It is safe to use them, as they are inlined
+ // at compile-time and do nothing on earlier devices.
+ mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
+ }
+ }
+ };
+ private View mControlsView;
+ private final Runnable mShowPart2Runnable = new Runnable() {
+ @Override
+ public void run() {
+ // Delayed display of UI elements
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.show();
+ }
+ mControlsView.setVisibility(View.VISIBLE);
+ }
+ };
+ private boolean mVisible;
+ private final Runnable mHideRunnable = new Runnable() {
+ @Override
+ public void run() {
+ hide();
+ }
+ };
+ /**
+ * Touch listener to use for in-layout UI controls to delay hiding the
+ * system UI. This is to prevent the jarring behavior of controls going away
+ * while interacting with activity UI.
+ */
+ private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View view, MotionEvent motionEvent) {
+ switch (motionEvent.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ if (AUTO_HIDE) {
+ delayedHide(AUTO_HIDE_DELAY_MILLIS);
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ view.performClick();
+ break;
+ default:
+ break;
+ }
+ return false;
+ }
+ };
+ private ActivitySettingPasswordBinding binding;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ binding = ActivitySettingPasswordBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
+
+ mVisible = true;
+ mControlsView = binding.fullscreenContentControls;
+ mContentView = binding.fullscreenContent;
+
+ // Set up the user interaction to manually show or hide the system UI.
+ mContentView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ toggle();
+ }
+ });
+
+ // Upon interacting with UI controls, delay any scheduled hide()
+ // operations to prevent the jarring behavior of controls going away
+ // while interacting with the UI.
+ binding.dummyButton.setOnTouchListener(mDelayHideTouchListener);
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+
+ // Trigger the initial hide() shortly after the activity has been
+ // created, to briefly hint to the user that UI controls
+ // are available.
+ delayedHide(100);
+ }
+
+ private void toggle() {
+ if (mVisible) {
+ hide();
+ } else {
+ show();
+ }
+ }
+
+ private void hide() {
+ // Hide UI first
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.hide();
+ }
+ mControlsView.setVisibility(View.GONE);
+ mVisible = false;
+
+ // Schedule a runnable to remove the status and navigation bar after a delay
+ mHideHandler.removeCallbacks(mShowPart2Runnable);
+ mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
+ }
+
+ private void show() {
+ // Show the system bar
+ if (Build.VERSION.SDK_INT >= 30) {
+ mContentView.getWindowInsetsController().show(
+ WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
+ } else {
+ mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ }
+ mVisible = true;
+
+ // Schedule a runnable to display UI elements after a delay
+ mHideHandler.removeCallbacks(mHidePart2Runnable);
+ mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
+ }
+
+ /**
+ * Schedules a call to hide() in delay milliseconds, canceling any
+ * previously scheduled calls.
+ */
+ private void delayedHide(int delayMillis) {
+ mHideHandler.removeCallbacks(mHideRunnable);
+ mHideHandler.postDelayed(mHideRunnable, delayMillis);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/net/micode/notes/ui/SplashActivity.java b/app/src/main/java/net/micode/notes/ui/SplashActivity.java
new file mode 100644
index 0000000..9d72812
--- /dev/null
+++ b/app/src/main/java/net/micode/notes/ui/SplashActivity.java
@@ -0,0 +1,4 @@
+package net.micode.notes.ui;
+
+public class SplashActivity {
+}
diff --git a/app/src/main/res/layout/activity_change_password.xml b/app/src/main/res/layout/activity_change_password.xml
new file mode 100644
index 0000000..fc77fc3
--- /dev/null
+++ b/app/src/main/res/layout/activity_change_password.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_delete_password.xml b/app/src/main/res/layout/activity_delete_password.xml
new file mode 100644
index 0000000..bf4c833
--- /dev/null
+++ b/app/src/main/res/layout/activity_delete_password.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_setting_password.xml b/app/src/main/res/layout/activity_setting_password.xml
new file mode 100644
index 0000000..5e27056
--- /dev/null
+++ b/app/src/main/res/layout/activity_setting_password.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/note_edit.xml b/app/src/main/res/layout/note_edit.xml
index 52c884d..b608651 100644
--- a/app/src/main/res/layout/note_edit.xml
+++ b/app/src/main/res/layout/note_edit.xml
@@ -18,7 +18,7 @@
+ android:layout_height="fill_parent">
+
+ android:divider="@null"/>
+
+
diff --git a/app/src/main/res/menu/note_edit.xml b/app/src/main/res/menu/note_edit.xml
index aa8ae0f..3191a2a 100644
--- a/app/src/main/res/menu/note_edit.xml
+++ b/app/src/main/res/menu/note_edit.xml
@@ -48,4 +48,12 @@
+
+
+
+
diff --git a/app/src/main/res/menu/note_list.xml b/app/src/main/res/menu/note_list.xml
index 8fff161..30be117 100644
--- a/app/src/main/res/menu/note_list.xml
+++ b/app/src/main/res/menu/note_list.xml
@@ -15,7 +15,8 @@
不作任何明示或暗示的保证或条件。请参阅许可协议以了解具体权限和限制。
-->
-
diff --git a/app/src/main/res/menu/sub_folder.xml b/app/src/main/res/menu/sub_folder.xml
index faf4844..6f33b88 100644
--- a/app/src/main/res/menu/sub_folder.xml
+++ b/app/src/main/res/menu/sub_folder.xml
@@ -14,8 +14,24 @@
+
+
+
+
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 09f75ed..6135c38 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -123,4 +123,6 @@
- %1$s 条符合“%2$s”的搜索结果
+
+
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index e29b79b..b126086 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -123,5 +123,7 @@
- %1$s 條符合”%2$s“的搜尋結果
+
+
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 3318dd4..e46245c 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -15,5 +15,10 @@
#335b5b5b
+ #FF039BE5
+ #FF01579B
+ #FF40C4FF
+ #FF00B0FF
+ #66000000
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 55df868..91b4a81 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -15,8 +15,7 @@
limitations under the License.
-->
-
+
Notes
Notes 2x2
Notes 4x4
@@ -97,6 +96,14 @@
Getting remote note list...
Synchronize local notes with Google Task...
+
+ Background:girl
+
+ light mode
+ night mode
+
+ secret model
+ quit secret model
Settings
Sync account
Sync notes with google task
@@ -127,9 +134,17 @@
set
cancel
- - %1$s result for \"%2$s\"
+ - %1$s result for \"%2$s\"
- - %1$s results for \"%2$s\"
+ - %1$s results for \"%2$s\"
+ SplashhActivity
+ Dummy Button
+ 记录你的每一天
+ LoginActivity
+ ChangePassword
+ SettingPassword
+ DeletingPassword
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 13cfd4e..06f4dac 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -65,7 +65,18 @@
+
+
+
+
+
+
diff --git a/app/src/source.txt b/app/src/source.txt
new file mode 100644
index 0000000..1d3a065
--- /dev/null
+++ b/app/src/source.txt
@@ -0,0 +1 @@
+source
\ No newline at end of file