背景切换(按键隐藏)和欢迎界面

pull/9/head
Thinner123 3 years ago
parent fee5ff4369
commit c1d24dda8a

Binary file not shown.

@ -1,113 +0,0 @@
package net.micode.notes.tool;
public class Point {
public static int BITMAP_NORMAL = 0; // 正常
public static int BITMAP_ERROR = 1; // 错误
public static int BITMAP_PRESS = 2; // 按下
//九宫格中的点的下标(即每个点代表一个值)
private String index;
//点的状态
private int state;
//点的坐标
private float x;
private float y;
public Point() {
super();
}
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public String getIndex() {
return index;
}
public int getState() {
return state;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
public void setIndex(String index) {
this.index = index;
}
public void setState(int state) {
this.state = state;
}
public void setX(float x) {
this.x = x;
}
public void setY(float y) {
this.y = y;
}
/**
* 线
*
* @param a
* @param moveX
* @param moveY
* @param radius bitmap
* @return
*/
public boolean isWith(Point a, float moveX, float moveY, float radius) {
float result = (float) Math.sqrt((a.getX() - moveX)
* (a.getX() - moveX) + (a.getY() - moveY)
* (a.getY() - moveY));
if (result < 5 * radius / 4) {
return true;
}
return false;
}
public static float getDegrees(Point a, Point b) {
float degrees = 0;
float ax = a.getX();
float ay = a.getY();
float bx = b.getX();
float by = b.getY();
if (ax == bx) {
if (by > ay) {
degrees = 90;
} else {
degrees = 270;
}
} else if (by == ay) {
if (ax > bx) {
degrees = 180;
} else {
degrees = 0;
}
} else {
if (ax > bx) {
if (ay > by) { // 第三象限
degrees = 180 + (float) (Math.atan2(ay - by, ax - bx) * 180 / Math.PI);
} else { // 第二象限
degrees = 180 - (float) (Math.atan2(by - ay, ax - bx) * 180 / Math.PI);
}
} else {
if (ay > by) { // 第四象限
degrees = 360 - (float) (Math.atan2(ay - by, bx - ax) * 180 / Math.PI);
} else { // 第一象限
degrees = (float) (Math.atan2(by - ay, bx - ax) * 180 / Math.PI);
}
}
}
return degrees;
}
}

@ -1,54 +0,0 @@
package net.micode.notes.ui;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import net.micode.notes.R;
import net.micode.notes.model.WorkingNote;
public class DeletePasscodeActivity extends AppCompatActivity {
private LockPatternView mLockPatternView;
private String mPasswordStr;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lock);
mLockPatternView = (LockPatternView) findViewById(R.id.lockView);
Intent pre = getIntent();
final Long noteId = pre.getLongExtra(Intent.EXTRA_UID, 0);
mLockPatternView.setLockListener(new LockPatternView.OnLockListener() {
WorkingNote mWorkingNote = WorkingNote.load(DeletePasscodeActivity.this,noteId);
String password = mWorkingNote.getPasscode();
@Override
public void getStringPassword(String password) {
mPasswordStr = password;
}
@Override
public boolean isPassword() {
if (mPasswordStr.equals(password)) {
Toast.makeText(DeletePasscodeActivity.this, R.string.note_passcode_deleted, Toast.LENGTH_SHORT).show();
mWorkingNote.setPasscode("");
mWorkingNote.saveNote();
NoteEditActivity Activity = new NoteEditActivity();
Activity.NoteEditActivity.finish();
Intent intent = new Intent(DeletePasscodeActivity.this, NoteEditActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(Intent.EXTRA_UID, noteId);
startActivity(intent);
DeletePasscodeActivity.this.finish();
} else {
Toast.makeText(DeletePasscodeActivity.this, "密码不正确", Toast.LENGTH_SHORT).show();
}
return false;
}
});
}
}

@ -1,385 +0,0 @@
package net.micode.notes.ui;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import net.micode.notes.R;
import net.micode.notes.tool.Point;
import java.util.ArrayList;
import java.util.List;
public class LockPatternView extends View {
//判断线的状态
private static boolean isLineState = true;
//判断点是否被实例化了
private static boolean isInitPoint = false;
//判断手指是否离开屏幕
private static boolean isFinish = false;
//判断手指点击屏幕时是否选中了九宫格中的点
private static boolean isSelect = false;
// 创建MyPoint的数组
private Point[][] mPoints = new Point[3][3];
// 声明屏幕的宽和高
private int mScreenHeight;
private int mScreenWidth;
// 声明点线的图片的半径
private float mPointRadius;
// 声明线的图片的高(即是半径)
private float mLineHeight;
// 声明鼠标移动的xy坐标
private float mMoveX, mMoveY;
// 声明屏幕上的宽和高的偏移量
private int mScreenHeightOffSet = 0;
private int mScreenWidthOffSet = 0;
// 创建一个画笔
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
// 声明资源图片
private Bitmap mBitmapNormal;
private Bitmap mBitmapPressed;
private Bitmap mBitmapError;
private Bitmap mLinePressed;
private Bitmap mLineError;
// 创建一个矩阵
private Matrix mMatrix = new Matrix();
// 创建MyPoint的列表
private List<Point> mPointList = new ArrayList<Point>();
// 实例化鼠标点
private Point mMousePoint = new Point();
// 用获取从activity中传过来的密码字符串
private String mPassword = "";
private final static String TAG = "LockPatternView";
private Context mContext;
private OnLockListener mListener;
public LockPatternView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mContext = context;
}
public LockPatternView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public LockPatternView(Context context) {
super(context);
}
/**
* 线
*/
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (!isInitPoint) {
initPoint(); // 先初始化
}
canvasPoint(canvas); // 开始画点
// 开始画线
if (mPointList.size() > 0) {
Point b = null;
Point a = mPointList.get(0);
for (int i = 1; i < mPointList.size(); i++) {
b = mPointList.get(i);
canvasLine(a, b, canvas);
a = b;
}
if (!isFinish) {
canvasLine(a, mMousePoint, canvas);
}
}
}
/**
*
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
mMoveX = event.getX();
mMoveY = event.getY();
// 设置移动点的坐标
mMousePoint.setX(mMoveX);
mMousePoint.setY(mMoveY);
Point mPoint = null;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
isLineState = true;
isFinish = false;
// 每次点击时就会将pointList中元素设置转化成正常状态
for (int i = 0; i < mPointList.size(); i++) {
mPointList.get(i).setState(Point.BITMAP_NORMAL);
}
// 将pointList中的元素清除掉
mPointList.clear();
// 判断是否点中了九宫格中的点
mPoint = getIsSelectedPoint(mMoveX, mMoveY);
if (mPoint != null) {
isSelect = true;
}
break;
case MotionEvent.ACTION_MOVE:
if (isSelect == true) {
mPoint = getIsSelectedPoint(mMoveX, mMoveY);
}
break;
case MotionEvent.ACTION_UP:
isFinish = true;
isSelect = false;
// 规定至少要有4个点被连线才有可能是正确
// 其他种情况都是错误的
if (mPointList.size() >= 4) {// 正确情况
for (int j = 0; j < mPointList.size(); j++) {
mPassword += mPointList.get(j).getIndex();
}
//将连线后得到的密码传给activity
mListener.getStringPassword(mPassword);
mPassword = "";
//经过activity判断传过来是否正确
if (mListener.isPassword()) {
for (int i = 0; i < mPointList.size(); i++) {
mPointList.get(i).setState(Point.BITMAP_PRESS);
}
} else {
for (int i = 0; i < mPointList.size(); i++) {
mPointList.get(i).setState(Point.BITMAP_ERROR);
}
isLineState = false;
}
// 错误情况
} else if (mPointList.size() < 4 && mPointList.size() > 1) {
for (int i = 0; i < mPointList.size(); i++) {
mPointList.get(i).setState(Point.BITMAP_ERROR);
}
isLineState = false;
// 如果只有一个点被点中时为正常情况
} else if (mPointList.size() == 1) {
for (int i = 0; i < mPointList.size(); i++) {
mPointList.get(i).setState(Point.BITMAP_NORMAL);
}
}
break;
}
// 将mPoint添加到pointList中
if (isSelect && mPoint != null) {
if (mPoint.getState() == Point.BITMAP_NORMAL) {
mPoint.setState(Point.BITMAP_PRESS);
mPointList.add(mPoint);
}
}
// 每次发生OnTouchEvent()后都刷新View
postInvalidate();
return true;
}
/**
* 线
*
* @param moveX
* @param moveY
* @return
*/
private Point getIsSelectedPoint(float moveX, float moveY) {
Point myPoint = null;
for (int i = 0; i < mPoints.length; i++) {
for (int j = 0; j < mPoints[i].length; j++) {
if (mPoints[i][j].isWith(mPoints[i][j], moveX, moveY,
mPointRadius)) {
myPoint = mPoints[i][j];
}
}
}
return myPoint;
}
/**
* 线
*
* @param a
* @param b
* @param canvas
*/
private void canvasLine(Point a, Point b, Canvas canvas) {
// Math.sqrt(平方+平方)
float abInstance = (float) Math.sqrt(
(a.getX() - b.getX()) * (a.getX() - b.getX())
+ (a.getY() - b.getY()) * (a.getY() - b.getY())
);
canvas.rotate(Point.getDegrees(a, b), a.getX(), a.getY());
mMatrix.setScale(abInstance / mLineHeight, 1);
mMatrix.postTranslate(a.getX(), a.getY());
if (isLineState) {
canvas.drawBitmap(mLinePressed, mMatrix, mPaint);
} else {
canvas.drawBitmap(mLineError, mMatrix, mPaint);
}
canvas.rotate(-Point.getDegrees(a, b), a.getX(), a.getY());
}
/**
*
*
* @param canvas
*/
private void canvasPoint(Canvas canvas) {
for (int i = 0; i < mPoints.length; i++) {
for (int j = 0; j < mPoints[i].length; j++) {
if (mPoints[i][j]==null) {
//重启view时new的变量被销毁其他未被销毁导致设置一次开启app第二次进入时
//isinitpoint 变量已为true可是点实例未初始化
initPoint();
}
if (mPoints[i][j].getState() == Point.BITMAP_NORMAL) {
canvas.drawBitmap(mBitmapNormal,
mPoints[i][j].getX() - mPointRadius,
mPoints[i][j].getY() - mPointRadius, mPaint);
} else if (mPoints[i][j].getState() == Point.BITMAP_PRESS) {
canvas.drawBitmap(mBitmapPressed,
mPoints[i][j].getX() - mPointRadius,
mPoints[i][j].getY() - mPointRadius, mPaint);
} else {
canvas.drawBitmap(mBitmapError,
mPoints[i][j].getX() - mPointRadius,
mPoints[i][j].getY() - mPointRadius, mPaint);
}
}
}
}
private void minitPoint(){
/**
*
*/
mPoints[0][0] = new Point(mScreenWidthOffSet + mScreenWidth / 4,
mScreenHeightOffSet + mScreenHeight / 4);
mPoints[0][1] = new Point(mScreenWidthOffSet + mScreenWidth / 2,
mScreenHeightOffSet + mScreenHeight / 4);
mPoints[0][2] = new Point(mScreenWidthOffSet + mScreenWidth * 3 / 4,
mScreenHeightOffSet + mScreenHeight / 4);
mPoints[1][0] = new Point(mScreenWidthOffSet + mScreenWidth / 4,
mScreenHeightOffSet + mScreenHeight / 2);
mPoints[1][1] = new Point(mScreenWidthOffSet + mScreenWidth / 2,
mScreenHeightOffSet + mScreenHeight / 2);
mPoints[1][2] = new Point(mScreenWidthOffSet + mScreenWidth * 3 / 4,
mScreenHeightOffSet + mScreenHeight / 2);
mPoints[2][0] = new Point(mScreenWidthOffSet + mScreenWidth / 4,
mScreenHeightOffSet + mScreenHeight * 3 / 4);
mPoints[2][1] = new Point(mScreenWidthOffSet + mScreenWidth / 2,
mScreenHeightOffSet + mScreenHeight * 3 / 4);
mPoints[2][2] = new Point(mScreenWidthOffSet + mScreenWidth * 3 / 4,
mScreenHeightOffSet + mScreenHeight * 3 / 4);
// 设置九宫格中的各个index
int index = 1;
for (int i = 0; i < mPoints.length; i++) {
for (int j = 0; j < mPoints[i].length; j++) {
mPoints[i][j].setIndex(index + "");
// 在没有任何操作的情况下默認点的状态
mPoints[i][j].setState(Point.BITMAP_NORMAL);
index++;
}
}
}
/**
*
*/
private void initPoint() {
// 获取View的宽高
mScreenWidth = getWidth();
mScreenHeight = getHeight();
if (mScreenHeight > mScreenWidth) {
// 获取y轴上的偏移量
mScreenHeightOffSet = (mScreenHeight - mScreenWidth) / 2;
// 将屏幕高的变量设置成与宽相等目的是为了new Point(x,y)时方便操作
mScreenHeight = mScreenWidth;
} else {
// 获取x轴上的偏移量
mScreenWidthOffSet = (mScreenWidth - mScreenHeight) / 2;
// 将屏幕宽的变量设置成与高相等目的是为了new Point(x,y)时方便操作
mScreenWidth = mScreenHeight;
}
/**
*
*/
mBitmapError = BitmapFactory.decodeResource(getResources(), R.drawable.bitmap_error);
mBitmapNormal = BitmapFactory.decodeResource(getResources(), R.drawable.bitmap_normal);
mBitmapPressed = BitmapFactory.decodeResource(getResources(), R.drawable.bitmap_pressed);
mLineError = BitmapFactory.decodeResource(getResources(), R.drawable.line_error);
mLinePressed = BitmapFactory.decodeResource(getResources(), R.drawable.line_pressed);
mPointRadius = mBitmapNormal.getWidth() / 2;
mLineHeight = mLinePressed.getHeight();
/**
*
*/
mPoints[0][0] = new Point(mScreenWidthOffSet + mScreenWidth / 4,
mScreenHeightOffSet + mScreenHeight / 4);
mPoints[0][1] = new Point(mScreenWidthOffSet + mScreenWidth / 2,
mScreenHeightOffSet + mScreenHeight / 4);
mPoints[0][2] = new Point(mScreenWidthOffSet + mScreenWidth * 3 / 4,
mScreenHeightOffSet + mScreenHeight / 4);
mPoints[1][0] = new Point(mScreenWidthOffSet + mScreenWidth / 4,
mScreenHeightOffSet + mScreenHeight / 2);
mPoints[1][1] = new Point(mScreenWidthOffSet + mScreenWidth / 2,
mScreenHeightOffSet + mScreenHeight / 2);
mPoints[1][2] = new Point(mScreenWidthOffSet + mScreenWidth * 3 / 4,
mScreenHeightOffSet + mScreenHeight / 2);
mPoints[2][0] = new Point(mScreenWidthOffSet + mScreenWidth / 4,
mScreenHeightOffSet + mScreenHeight * 3 / 4);
mPoints[2][1] = new Point(mScreenWidthOffSet + mScreenWidth / 2,
mScreenHeightOffSet + mScreenHeight * 3 / 4);
mPoints[2][2] = new Point(mScreenWidthOffSet + mScreenWidth * 3 / 4,
mScreenHeightOffSet + mScreenHeight * 3 / 4);
// 设置九宫格中的各个index
int index = 1;
for (int i = 0; i < mPoints.length; i++) {
for (int j = 0; j < mPoints[i].length; j++) {
mPoints[i][j].setIndex(index + "");
// 在没有任何操作的情况下默認点的状态
mPoints[i][j].setState(Point.BITMAP_NORMAL);
index++;
}
}
// 将isInitPoint设置为true
isInitPoint = true;
}
public interface OnLockListener {
public void getStringPassword(String password);
public boolean isPassword();
}
public void setLockListener(OnLockListener listener) {
this.mListener = listener;
}
}

@ -1,106 +0,0 @@
package net.micode.notes.ui;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import net.micode.notes.model.WorkingNote;
import net.micode.notes.R;
import net.micode.notes.ui.LockPatternView;
public class SetLockActivity extends AppCompatActivity {
private TextView mTitleTv;
private LockPatternView mLockPatternView;
// private LinearLayout mBottomLayout;
private Button mClearBtn;
// private Button mConfirmBtn;
private String mPassword;
/**
*
*/
private boolean isFirst = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_set_lock);
initViews();
initEvents();
}
public void onBackPressed() {
super.onBackPressed();//注释掉这行,back键不退出activity
Intent pre = getIntent();
//将密码写入数据库
long noteId = pre.getLongExtra(Intent.EXTRA_UID, 0);
Intent intent = new Intent(SetLockActivity.this, NoteEditActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("lock",0);
intent.putExtra(Intent.EXTRA_UID, noteId);
startActivity(intent);
}
private void initEvents() {
mLockPatternView.setLockListener(new LockPatternView.OnLockListener() {
@Override
public void getStringPassword(String password) {
if (isFirst) {
mPassword = password;
mTitleTv.setText("再次输入手势密码");
isFirst = false;
mClearBtn.setVisibility(View.VISIBLE);
} else {
if (password.equals(mPassword)) {
Intent pre = getIntent();
//将密码写入数据库
long noteId = pre.getLongExtra(Intent.EXTRA_UID, 0);
WorkingNote mWorkingNote = WorkingNote.load(SetLockActivity.this,noteId);
mWorkingNote.setPasscode(password);
boolean saved = mWorkingNote.saveNote();//保存便签
Intent intent = new Intent(SetLockActivity.this, NoteEditActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("lock",0);
intent.putExtra(Intent.EXTRA_UID, noteId);
startActivity(intent);
SetLockActivity.this.finish();
}else {
Toast.makeText(SetLockActivity.this,"两次密码不一致,请重新设置",Toast.LENGTH_SHORT).show();
mPassword = "";
mTitleTv.setText("设置手势密码");
isFirst = true;
mClearBtn.setVisibility(View.GONE);
}
}
}
@Override
public boolean isPassword() {
return false;
}
});
mClearBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPassword = "";
isFirst = true;
mClearBtn.setVisibility(View.GONE);
}
});
}
private void initViews() {
mTitleTv = (TextView) findViewById(R.id.tv_activity_set_lock_title);
mLockPatternView = (LockPatternView) findViewById(R.id.lockView);
mClearBtn = (Button) findViewById(R.id.btn_password_clear);
}
}

@ -1,55 +0,0 @@
package net.micode.notes.ui;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.Toast;
import net.micode.notes.model.WorkingNote;
import net.micode.notes.R;
import net.micode.notes.ui.LockPatternView;
public class UnlockActivity extends AppCompatActivity {
private LockPatternView mLockPatternView;
private String mPasswordStr;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lock);
mLockPatternView = (LockPatternView) findViewById(R.id.lockView);
Intent pre = getIntent();
final Long noteId = pre.getLongExtra(Intent.EXTRA_UID, 0);
mLockPatternView.setLockListener(new LockPatternView.OnLockListener() {
WorkingNote mWorkingNote = WorkingNote.load(UnlockActivity.this,noteId);
String password = mWorkingNote.getPasscode();
@Override
public void getStringPassword(String password) {
mPasswordStr = password;
}
@Override
public boolean isPassword() {
if (mPasswordStr.equals(password)) {
Toast.makeText(UnlockActivity.this, "密码正确", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(UnlockActivity.this,NoteEditActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("lock",0);
intent.putExtra(Intent.EXTRA_UID, noteId);
startActivity(intent);
UnlockActivity.this.finish();
//TODO comment or not
//return true;
} else {
Toast.makeText(UnlockActivity.this, "密码不正确", Toast.LENGTH_SHORT).show();
}
return false;
}
});
}
}

@ -1,26 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.micode.notes"
android:versionCode="1"
android:versionName="0.1" >
<uses-sdk android:minSdkVersion="14" />
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
@ -33,16 +17,22 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:icon="@drawable/icon_app"
android:icon="@drawable/app1"
android:label="@string/app_name" >
<activity
android:name=".ui.NotesListActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/NoteTheme"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
android:uiOptions="splitActionBarWhenNarrow"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".ui.SplashActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/Theme.Notemaster2.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -53,24 +43,26 @@
android:name=".ui.NoteEditActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
android:theme="@style/NoteTheme" >
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/text_note" />
<data android:mimeType="vnd.android.cursor.item/call_note" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.INSERT_OR_EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/text_note" />
<data android:mimeType="vnd.android.cursor.item/call_note" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
@ -80,7 +72,7 @@
</activity>
<provider
android:name="net.micode.notes.data.NotesProvider"
android:name=".data.NotesProvider"
android:authorities="micode_notes"
android:multiprocess="true" />
@ -100,7 +92,6 @@
<receiver
android:name=".widget.NoteWidgetProvider_4x"
android:label="@string/app_widget4x4" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="android.appwidget.action.APPWIDGET_DELETED" />
@ -111,15 +102,13 @@
android:name="android.appwidget.provider"
android:resource="@xml/widget_4x_info" />
</receiver>
<receiver android:name=".ui.AlarmInitReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver
android:name="net.micode.notes.ui.AlarmReceiver"
android:name=".ui.AlarmReceiver"
android:process=":remote" >
</receiver>
@ -129,18 +118,15 @@
android:launchMode="singleInstance"
android:theme="@android:style/Theme.Holo.Wallpaper.NoTitleBar" >
</activity>
<activity android:name=".ui.UnlockActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar"> </activity>
<activity android:name=".ui.SetLockActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar"> </activity>
<activity android:name=".ui.DeletePasscodeActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar"> </activity>
<activity
android:name="net.micode.notes.ui.NotesPreferenceActivity"
android:name=".ui.NotesPreferenceActivity"
android:label="@string/preferences_title"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Holo.Light" >
</activity>
<service
android:name="net.micode.notes.gtask.remote.GTaskSyncService"
android:name=".gtask.remote.GTaskSyncService"
android:exported="false" >
</service>
@ -148,4 +134,5 @@
android:name="android.app.default_searchable"
android:value=".ui.NoteEditActivity" />
</application>
</manifest>
</manifest>

@ -165,12 +165,6 @@ public class Notes {
* <P> Type : INTEGER (long) </P>
*/
public static final String VERSION = "version";
public static final String TOP = "top";
public static final String STAR = "star";
public static final String PASSCODE = "passcode";
}
public interface DataColumns {

@ -59,11 +59,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.SYNC_ID + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT 1," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.TOP + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.STAR + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.PASSCODE + " TEXT NOT NULL DEFAULT ''"+
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
")";
private static final String CREATE_DATA_TABLE_SQL =
@ -325,16 +322,6 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
oldVersion++;
}
if (oldVersion == 4) {
upgradeToV5(db);
oldVersion++;
}
if (oldVersion == 5) {
upgradeToV6(db);
oldVersion++;
}
if (reCreateTriggers) {
reCreateNoteTableTriggers(db);
reCreateDataTableTriggers(db);
@ -372,14 +359,4 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0");
}
private void upgradeToV5(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TOP
+ " INTEGER NOT NULL DEFAULT 0");
}
private void upgradeToV6(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.STAR
+ " INTEGER NOT NULL DEFAULT 0");
}
}

@ -33,13 +33,12 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper.TABLE;
import net.micode.notes.gtask.data.SqlNote;
public class NotesProvider extends ContentProvider {
private static final UriMatcher mMatcher;
private static NotesDatabaseHelper mHelper;
private NotesDatabaseHelper mHelper;
private static final String TAG = "NotesProvider";
@ -303,85 +302,4 @@ public class NotesProvider extends ContentProvider {
return null;
}
public static boolean isStarNote(Long id) {
SQLiteDatabase db;
db = mHelper.getReadableDatabase();
Cursor cursor = null;
cursor = db.query(NotesDatabaseHelper.TABLE.NOTE, null, null, null, null, null, null);
//判断游标是否为空
if (cursor.moveToFirst()) {
//遍历游标
for (int index = 1; index < cursor.getCount(); index++) {
cursor.moveToNext();
if (cursor.getLong(SqlNote.ID_COLUMN) == id && !cursor.getString(SqlNote.STAR_COLUMN).equals("0")) {
cursor.close();
return true;
}
}
}
cursor.close();
return false;
}
public static boolean isLockedNote(Long id) {
SQLiteDatabase db;
db = mHelper.getReadableDatabase();
Cursor cursor = null;
cursor = db.query(NotesDatabaseHelper.TABLE.NOTE, null, null, null, null, null, null);
//判断游标是否为空
if (cursor.moveToFirst()) {
//遍历游标
for (int index = 1; index < cursor.getCount(); index++) {
cursor.moveToNext();
if (cursor.getLong(SqlNote.ID_COLUMN) == id && !cursor.getString(SqlNote.PASSCODE_COLUMN).equals("")) {
cursor.close();
return true;
}
}
}
cursor.close();
return false;
}
public static boolean isStarFolder(long NoteId, long FolderId, boolean setStar){
if(setStar){
return true;
}
SQLiteDatabase db;
db = mHelper.getWritableDatabase();
Cursor cursor = null;
cursor = db.query(NotesDatabaseHelper.TABLE.NOTE, null, null, null, null, null, null);
//判断游标是否为空
if (cursor.moveToFirst()) {
//遍历游标
for (int index = 1; index < cursor.getCount(); index++) {
cursor.moveToNext();
if (cursor.getLong(SqlNote.ID_COLUMN) == NoteId && !setStar){
continue;
}
if (cursor.getLong(1) == FolderId){
if (cursor.getString(SqlNote.STAR_COLUMN).equals("1")){
cursor.close();
return true;
}
}
}
}
cursor.close();
return false;
}
public static void setStarFolder(long FolderId, boolean isStarFolder){
SQLiteDatabase db;
db = mHelper.getWritableDatabase();
ContentValues values = new ContentValues();
if(isStarFolder){
values.put(NoteColumns.STAR,"1");
} else{
values.put(NoteColumns.STAR,"0");
}
String condition = NoteColumns.ID + " = ?";
String[] args = {String.valueOf(FolderId)};
db.update(NotesDatabaseHelper.TABLE.NOTE, values, condition, args);
}
}

@ -49,7 +49,7 @@ public class SqlNote {
NoteColumns.NOTES_COUNT, NoteColumns.PARENT_ID, NoteColumns.SNIPPET, NoteColumns.TYPE,
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE, NoteColumns.SYNC_ID,
NoteColumns.LOCAL_MODIFIED, NoteColumns.ORIGIN_PARENT_ID, NoteColumns.GTASK_ID,
NoteColumns.VERSION,NoteColumns.TOP,NoteColumns.STAR,NoteColumns.PASSCODE,
NoteColumns.VERSION
};
public static final int ID_COLUMN = 0;
@ -86,12 +86,6 @@ public class SqlNote {
public static final int VERSION_COLUMN = 16;
public static final int Top_COLUMN = 17;
public static final int STAR_COLUMN = 18;
public static final int PASSCODE_COLUMN = 19;
private Context mContext;
private ContentResolver mContentResolver;
@ -124,12 +118,6 @@ public class SqlNote {
private long mVersion;
private String mTop;
private String mStar;
private String mPasscode;
private ContentValues mDiffNoteValues;
private ArrayList<SqlData> mDataList;
@ -151,9 +139,6 @@ public class SqlNote {
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
mOriginParent = 0;
mVersion = 0;
mTop = getmTop();
mStar = getmStar();
mPasscode = getmPasscode();
mDiffNoteValues = new ContentValues();
mDataList = new ArrayList<SqlData>();
}
@ -167,9 +152,6 @@ public class SqlNote {
if (mType == Notes.TYPE_NOTE)
loadDataContent();
mDiffNoteValues = new ContentValues();
mTop = getmTop();
mStar = getmStar();
mPasscode = getmPasscode();
}
public SqlNote(Context context, long id) {
@ -181,21 +163,7 @@ public class SqlNote {
if (mType == Notes.TYPE_NOTE)
loadDataContent();
mDiffNoteValues = new ContentValues();
mTop = getmTop();
mStar = getmStar();
mPasscode = getmPasscode();
}
public String getmTop(){
return mTop;
}
public String getmStar(){
return mStar;
}
public String getmPasscode(){
return mPasscode;
}
private void loadFromCursor(long id) {
@ -230,9 +198,6 @@ public class SqlNote {
mWidgetId = c.getInt(WIDGET_ID_COLUMN);
mWidgetType = c.getInt(WIDGET_TYPE_COLUMN);
mVersion = c.getLong(VERSION_COLUMN);
mTop = c.getString(Top_COLUMN);
mStar = c.getString(STAR_COLUMN);
mPasscode = c.getString(PASSCODE_COLUMN);
}
private void loadDataContent() {

@ -59,7 +59,7 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
public void publishProgess(String message) {
publishProgress(new String[] {
message
message
});
}
@ -77,7 +77,17 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesListActivity.class), 0);
}
// notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
// pendingIntent);
notification = new Notification.Builder(mContext)
.setContentIntent(pendingIntent)
.setTicker(mContext.getString(R.string.app_name))
.setContentTitle(mContext.getString(R.string.app_name))
.setContentText(content)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.icon_app)
.build();
notification.icon = R.drawable.icon_app;
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
}

@ -47,7 +47,6 @@ public class Note {
long createdTime = System.currentTimeMillis();
values.put(NoteColumns.CREATED_DATE, createdTime);
values.put(NoteColumns.MODIFIED_DATE, createdTime);
//values.put(NoteColumns.TOP,"1");
values.put(NoteColumns.TYPE, Notes.TYPE_NOTE);
values.put(NoteColumns.LOCAL_MODIFIED, 1);
values.put(NoteColumns.PARENT_ID, folderId);
@ -77,15 +76,6 @@ public class Note {
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
public void setTopValue(String key, String value) {
mNoteDiffValues.put(key, value);
}
public void setStarValue(String key, String value) {
mNoteDiffValues.put(key, value);
}
public void setTextData(String key, String value) {
mNoteData.setTextData(key, value);
}
@ -145,8 +135,6 @@ public class Note {
private ContentValues mTextDataValues;
private ContentValues mTopValues;
private long mCallDataId;
private ContentValues mCallDataValues;
@ -156,7 +144,6 @@ public class Note {
public NoteData() {
mTextDataValues = new ContentValues();
mCallDataValues = new ContentValues();
mTopValues = new ContentValues();
mTextDataId = 0;
mCallDataId = 0;
}
@ -191,7 +178,6 @@ public class Note {
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
Uri pushIntoContentResolver(Context context, long noteId) {
/**
* Check for safety

@ -29,7 +29,6 @@ import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.DataConstants;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.Notes.TextNote;
import net.micode.notes.data.NotesProvider;
import net.micode.notes.tool.ResourceParser.NoteBgResources;
@ -61,18 +60,6 @@ public class WorkingNote {
private boolean mIsDeleted;
/**记录便签已设置密码*/
private String mPasscode = "";
/**记录已置顶便签*/
private String mTop = "0";
/**记录便签所属类别*/
private int mClass;
private String mStar = "0";
private NoteSettingChangedListener mNoteSettingStatusListener;
public static final String[] DATA_PROJECTION = new String[] {
@ -91,10 +78,7 @@ public class WorkingNote {
NoteColumns.BG_COLOR_ID,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
NoteColumns.MODIFIED_DATE,
NoteColumns.TOP,
NoteColumns.STAR,
NoteColumns.PASSCODE,
NoteColumns.MODIFIED_DATE
};
private static final int DATA_ID_COLUMN = 0;
@ -117,12 +101,6 @@ public class WorkingNote {
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
private static final int NOTE_TOP_COLUMN = 6;
private static final int NOTE_STAR_COLUMN = 7;
private static final int NOTE_PASSCODE_COLUMN = 8;
// New note construct
private WorkingNote(Context context, long folderId) {
mContext = context;
@ -134,9 +112,6 @@ public class WorkingNote {
mIsDeleted = false;
mMode = 0;
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
mTop = String.valueOf(getTopId());
mStar = String.valueOf(getStarId());
mPasscode = String.valueOf(getPasscode());
}
// Existing note construct
@ -162,16 +137,12 @@ public class WorkingNote {
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
mTop = cursor.getString(NOTE_TOP_COLUMN);
mStar = cursor.getString(NOTE_STAR_COLUMN);
mPasscode = cursor.getString(NOTE_PASSCODE_COLUMN);
}
cursor.close();
} else {
Log.e(TAG, "No note with id:" + mNoteId);
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
}
loadNoteData();
}
@ -258,30 +229,6 @@ public class WorkingNote {
mNoteSettingStatusListener = l;
}
public void setTop(String Top){
if (!mTop.equals(Top)) {
mTop = Top;
mNote.setTopValue(NoteColumns.TOP,mTop);
}
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onTopChanged(Top);
}
}
public void setStar(String Star){
if (!mStar.equals(Star)){
mStar = Star;
mNote.setStarValue(NoteColumns.STAR,mStar);
NotesProvider.setStarFolder(mFolderId, NotesProvider.isStarFolder(mNoteId, mFolderId,Star.equals("1")));
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onStarChanged(Star);
}
}
}
public void setAlertDate(long date, boolean set) {
if (date != mAlertDate) {
mAlertDate = date;
@ -351,38 +298,6 @@ public class WorkingNote {
return (mAlertDate > 0 ? true : false);
}
/**判断是否已经设置密码*/
public boolean hasPasscode() {
return !mPasscode.equals("");
}
/**设置便签访问密码,并存入数据库*/
public void setPasscode(String passcode) {
mPasscode = passcode;
mNote.setNoteValue(NoteColumns.PASSCODE, passcode);
}
/**获取设置的密码*/
public String getPasscode() {
return mPasscode;
}
public int getTopId() {
if (mTop.equals("1")) {
return 1;
} else {
return 0;
}
}
public int getStarId() {
if (mStar.equals("1")) {
return 1;
} else {
return 0;
}
}
public String getContent() {
return mContent;
}
@ -433,16 +348,6 @@ public class WorkingNote {
*/
void onBackgroundColorChanged();
/**
* Called when user set top
*/
void onTopChanged(String Top);
/**
* Called when user set star
*/
void onStarChanged(String Star);
/**
* Called when user set clock
*/

@ -16,7 +16,6 @@
package net.micode.notes.tool;
import android.app.Activity;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentResolver;
@ -26,23 +25,14 @@ import android.content.OperationApplicationException;
import android.database.Cursor;
import android.os.RemoteException;
import android.util.Log;
import android.database.sqlite.SQLiteDatabase;
import android.widget.Toast;
import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.CallNote;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper;
import net.micode.notes.data.NotesProvider;
import net.micode.notes.gtask.data.SqlNote;
import net.micode.notes.model.Note;
import net.micode.notes.ui.NoteEditActivity;
import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.TreeSet;
public class DataUtils {
@ -56,18 +46,13 @@ public class DataUtils {
Log.d(TAG, "no id is in the hashset");
return true;
}
ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();
for (long id : ids) {
if(id == Notes.ID_ROOT_FOLDER) {
Log.e(TAG, "Don't delete system folder root");
continue;
}
/**
* if can delete
*/
if (NotesProvider.isStarNote(id) || NotesProvider.isLockedNote(id)){
continue;
}
ContentProviderOperation.Builder builder = ContentProviderOperation
.newDelete(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));
operationList.add(builder.build());

@ -30,9 +30,12 @@ import android.content.SharedPreferences;
import android.graphics.Paint;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.format.DateUtils;
import android.text.style.BackgroundColorSpan;
import android.util.Log;
@ -72,20 +75,72 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class NoteEditActivity extends Activity implements OnClickListener,
public class NoteEditActivity extends AppCompatActivity implements OnClickListener,
NoteSettingChangedListener, OnTextViewChangeListener {
private class HeadViewHolder {
public TextView tvModified;
public ImageView ivAlertIcon;
public TextView tvToptext;
public TextView tvAlertDate;
public ImageView ibSetBgColor;
}
private EditText editText;
private TextView textView;
private String Textchange(String oriText){
StringBuffer stringBuffer = new StringBuffer(oriText);
int Flag1 = -1;
int Flag2 = -1;
do {//不计入表示图片的字符
Flag1 = stringBuffer.indexOf("<img");
Flag2 = stringBuffer.indexOf(">");
if (Flag1 != -1 && Flag2 != -1) {
stringBuffer = stringBuffer.replace(Flag1, Flag2+1, "");
}
} while (Flag1 != -1 && Flag2 != -1);
do {//不计入换行字符
Flag1 = stringBuffer.indexOf("\n");
if (Flag1 != -1){
stringBuffer = stringBuffer.replace(Flag1, Flag1+1, "");
}
} while (Flag1 != -1);
do {//不计入空格字符
Flag1 = stringBuffer.indexOf(" ");
if (Flag1 != -1) {
stringBuffer = stringBuffer.replace(Flag1, Flag1+1, "");
}
} while (Flag1 != -1);
return stringBuffer.toString();
}
private void count()
{
editText = (EditText) findViewById(R.id.note_edit_view);
textView = (TextView) findViewById(R.id.text_num);
editText.addTextChangedListener(new TextWatcher() {
int currentLength = 0;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
textView.setText("Number of characters" + currentLength);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
currentLength = Textchange(mNoteEditor.getText().toString()).length();
}
@Override
public void afterTextChanged(Editable s) {
textView.setText("Number of characters" + currentLength);
}
});
}
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
static {
sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW);
@ -143,9 +198,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private static final int SHORTCUT_ICON_TITLE_MAX_LEN = 10;
private static final int REQUEST_SET_PASSCODE = 0;
private static final int REQUEST_UNLOCK = 1;
public static final String TAG_CHECKED = String.valueOf('\u221A');
public static final String TAG_UNCHECKED = String.valueOf('\u25A1');
@ -154,20 +206,17 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private String mUserQuery;
private Pattern mPattern;
private boolean Locked; /* 用以判断是否已解锁 */
static Activity NoteEditActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.note_edit);
NoteEditActivity = this;
if (savedInstanceState == null && !initActivityState(getIntent())) {
finish();
return;
}
initResources();
count();
}
/**
@ -268,11 +317,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return false;
}
mWorkingNote.setOnSettingStatusChangedListener(this);
Locked = mWorkingNote.hasPasscode();//设置便签解锁状态;
if (intent.hasExtra("lock")) {
Locked = false;
}
return true;
}
@ -307,22 +351,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* is not ready
*/
showAlertHeader();
showTopHeader();
unlockNote();
}
private void unlockNote(){
//如果设置了密码,启动输入密码页面
if (mWorkingNote.hasPasscode() && Locked) {
saveNote();
Intent intent = new Intent(this,UnlockActivity.class);
intent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId());
startActivityForResult(intent,REQUEST_SET_PASSCODE);
finish();
}
}
private void showAlertHeader() {
if (mWorkingNote.hasClockAlert()) {
long time = System.currentTimeMillis();
@ -337,16 +367,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} else {
mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE);
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE);
}
}
private void showTopHeader(){
mNoteHeaderHolder.tvToptext.setText(R.string.menu_set_top);
if(mWorkingNote.getTopId()==1){
mNoteHeaderHolder.tvToptext.setVisibility(View.VISIBLE);
} else{
mNoteHeaderHolder.tvToptext.setVisibility(View.GONE);
}
};
}
@Override
@ -406,7 +427,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mNoteHeaderHolder.tvModified = (TextView) findViewById(R.id.tv_modified_date);
mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon);
mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date);
mNoteHeaderHolder.tvToptext = (TextView) findViewById(R.id.tv_set_top);
mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
@ -468,7 +488,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
if (id == R.id.btn_set_bg_color) {
mNoteBgColorSelector.setVisibility(View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.VISIBLE);
- View.VISIBLE);
} else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.GONE);
@ -530,14 +550,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} else {
getMenuInflater().inflate(R.menu.note_edit, menu);
}
if (mWorkingNote.getTopId() == 1 ) {
menu.findItem(R.id.menu_set_top).setVisible(false);
} else if(mWorkingNote.getTopId() == 0){
menu.findItem(R.id.menu_cancel_top).setVisible(false);
}
if (mWorkingNote.getStarId() == 1){
menu.findItem(R.id.menu_set_star).setTitle(R.string.menu_delete_star);
}
if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_normal_mode);
} else {
@ -548,12 +560,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} else {
menu.findItem(R.id.menu_delete_remind).setVisible(false);
}
//如果一设置密码,显示删除密码选项,否则,显示设置密码选项
if (mWorkingNote.hasPasscode()) {
menu.findItem(R.id.menu_set_passcode).setVisible(false);
} else {
menu.findItem(R.id.menu_delete_passcode).setVisible(false);
}
return true;
}
@ -563,25 +569,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
case R.id.menu_new_note:
createNewNote();
break;
case R.id.menu_set_top:
mWorkingNote.setTop((mWorkingNote.getTopId())==1 ? "0" : "1");
break;
case R.id.menu_cancel_top:
mWorkingNote.setTop((mWorkingNote.getTopId())==0 ? "1" : "0");
break;
case R.id.menu_set_star:
mWorkingNote.setStar(mWorkingNote.getStarId()==1? "0" : "1");
System.out.println(mWorkingNote.hasPasscode());
break;
//设置密码
case R.id.menu_set_passcode:
setPasscode();
break;
//删除密码
case R.id.menu_delete_passcode:
System.out.println(mWorkingNote.hasPasscode());
deletePasscode();
break;
case R.id.menu_delete:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.alert_title_delete));
@ -590,15 +577,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if(mWorkingNote.getStarId()==0 && !mWorkingNote.hasPasscode()) {
deleteCurrentNote();
finish();
} else if(mWorkingNote.getStarId()==1){
showToast(R.string.error_delete_star_note);
} else if(mWorkingNote.hasPasscode()){
showToast(R.string.error_delete_locked_note);
}
//finish();
deleteCurrentNote();
finish();
}
});
builder.setNegativeButton(android.R.string.cancel, null);
@ -631,7 +611,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return true;
}
private void setReminder() {
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
@ -691,33 +670,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
}
public void onTopChanged(String Top){
/**
* User could set clock to an unsaved note, so before setting the
* alert clock, we should save the note first
*/
saveNote();
if (mWorkingNote.getNoteId() > 0) {
showTopHeader();
} else {
/**
* There is the condition that user has input nothing (the note is
* not worthy saving), we have no note id, remind the user that he
* should input something
*/
Log.e(TAG, "Top setting error");
showToast(R.string.error_note_empty_for_top);
}
}
public void onStarChanged(String Star){
/**
* User could set clock to an unsaved note, so before setting the
* alert clock, we should save the note first
*/
saveNote();
}
public void onClockAlertChanged(long date, boolean set) {
/**
* User could set clock to an unsaved note, so before setting the
@ -927,36 +879,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return saved;
}
/**
*
*/
private void setPasscode() {
//确保笔记已写入数据库
saveNote();
//初始化一个新的意图,用以跳转至设置密码界面
Intent intent = new Intent(this,SetLockActivity.class);
//给意图传入当前便签的id参数便于从设置密码活动中跳转回编辑便签活动
intent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId());
startActivity(intent);
finish();
}
/**
* 便
*/
private void deletePasscode() {
//验证密码
if (mWorkingNote.hasPasscode()) {
saveNote();
Intent intent = new Intent(this,DeletePasscodeActivity.class);
intent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId());
startActivity(intent);
//finish();
saveNote();
}
saveNote();
}
private void sendToDesktop() {
/**
* Before send message to home, we should make sure that current

@ -40,9 +40,6 @@ public class NoteItemData {
NoteColumns.TYPE,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
NoteColumns.TOP,
NoteColumns.STAR,
NoteColumns.PASSCODE,
};
private static final int ID_COLUMN = 0;
@ -57,9 +54,6 @@ public class NoteItemData {
private static final int TYPE_COLUMN = 9;
private static final int WIDGET_ID_COLUMN = 10;
private static final int WIDGET_TYPE_COLUMN = 11;
private static final int TOP_ID_COLUMN = 12;
private static final int STAR_ID_COLUMN = 13;
private static final int PASSCODE_COLUMN = 14;
private long mId;
private long mAlertDate;
@ -75,9 +69,6 @@ public class NoteItemData {
private int mWidgetType;
private String mName;
private String mPhoneNumber;
private String mTop;
private String mStar;
private String mPasscode;
private boolean mIsLastItem;
private boolean mIsFirstItem;
@ -100,9 +91,6 @@ public class NoteItemData {
mType = cursor.getInt(TYPE_COLUMN);
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
mTop = cursor.getString(TOP_ID_COLUMN);
mStar = cursor.getString(STAR_ID_COLUMN);
mPasscode = cursor.getString(PASSCODE_COLUMN);
mPhoneNumber = "";
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
@ -146,22 +134,6 @@ public class NoteItemData {
}
}
public boolean isTOP() {
if(mTop.equals("1")) {
return true;
}else {
return false;
}
}
public boolean isSTAR() {
if(mStar.equals("0")) {
return false;
}else {
return true;
}
}
public boolean isOneFollowingFolder() {
return mIsOneNoteFollowingFolder;
}
@ -190,8 +162,6 @@ public class NoteItemData {
return mId;
}
public boolean hasLock() { return !mPasscode.equals(""); }
public long getAlertDate() {
return mAlertDate;
}

@ -31,6 +31,7 @@ import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@ -78,7 +79,11 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
public class NotesListActivity extends AppCompatActivity implements OnClickListener, OnItemLongClickListener {
/* 首页背景切换 */
private int mode = -1;
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
private static final int FOLDER_LIST_QUERY_TOKEN = 1;
@ -93,7 +98,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private enum ListEditState {
NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER
};
}
private ListEditState mState;
@ -139,6 +144,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.grassland);
initResources();
/**
@ -414,7 +420,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {
String.valueOf(mCurrentFolderId)
}, NoteColumns.TOP+ " DESC,"+ NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
}
private final class BackgroundQueryHandler extends AsyncQueryHandler {
@ -775,12 +781,36 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} else {
Log.e(TAG, "Wrong state:" + mState);
}
if (mode == -1) {
menu.findItem(R.id.menu_grassland).setVisible(false);
} else if (mode == 0){
menu.findItem(R.id.menu_magma).setVisible(false);
} else if(mode == 1){
menu.findItem(R.id.menu_water).setVisible(false);
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_water: {
mode = 1;
getWindow().setBackgroundDrawableResource(R.drawable.water);
break;
}
case R.id.menu_magma: {
mode = 0;
getWindow().setBackgroundDrawableResource(R.drawable.magma);
break;
}
case R.id.menu_grassland: {
mode = -1;
getWindow().setBackgroundDrawableResource(R.drawable.grassland);
break;
}
case R.id.menu_new_folder: {
showCreateOrModifyFolderDialog(true);
break;

@ -37,9 +37,6 @@ public class NotesListItem extends LinearLayout {
private TextView mCallName;
private NoteItemData mItemData;
private CheckBox mCheckBox;
private ImageView mTop;
private ImageView mStar;
private ImageView mLock;
public NotesListItem(Context context) {
super(context);
@ -49,9 +46,6 @@ public class NotesListItem extends LinearLayout {
mTime = (TextView) findViewById(R.id.tv_time);
mCallName = (TextView) findViewById(R.id.tv_name);
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
mTop = (ImageView) findViewById(R.id.iv_top_icon);
mStar =(ImageView) findViewById(R.id.iv_star_icon);
mLock = (ImageView) findViewById(R.id.iv_lock);
}
public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) {
@ -61,6 +55,7 @@ public class NotesListItem extends LinearLayout {
} else {
mCheckBox.setVisibility(View.GONE);
}
mItemData = data;
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
mCallName.setVisibility(View.GONE);
@ -83,6 +78,7 @@ public class NotesListItem extends LinearLayout {
} else {
mCallName.setVisibility(View.GONE);
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
if (data.getType() == Notes.TYPE_FOLDER) {
mTitle.setText(data.getSnippet()
+ context.getString(R.string.format_folder_files_count,
@ -97,26 +93,6 @@ public class NotesListItem extends LinearLayout {
mAlert.setVisibility(View.GONE);
}
}
if(data.isTOP()){
mTop.setImageResource(R.drawable.menu_top);
mTop.setVisibility(View.VISIBLE);
} else{
mTop.setVisibility((View.GONE));
}
if(data.isSTAR()){
mStar.setImageResource(R.drawable.star);
mStar.setVisibility(View.VISIBLE);
} else{
mStar.setVisibility(View.GONE);
}
if (data.hasLock()) {
mLock.setImageResource(R.drawable.lock);
mLock.setVisibility(View.VISIBLE);
String text = "已加密";
mTitle.setText(text);
} else {
mLock.setVisibility(View.GONE);
}
}
mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));

@ -0,0 +1,34 @@
package net.micode.notes.ui;
import android.annotation.SuppressLint;
import android.content.Intent;
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.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
import net.micode.notes.R;
public class SplashActivity extends AppCompatActivity {
Handler mHandler=new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); //加载启动界面
setContentView(R.layout.activity_splash); //加载启动图片
// 当计时结束时跳转至NotesListActivity
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent=new Intent();
intent.setClass(SplashActivity.this, NotesListActivity.class);
startActivity(intent);
finish(); //销毁欢迎页面
}
}, 2000); // 2 秒后跳转
}
}

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Before

Width:  |  Height:  |  Size: 443 B

After

Width:  |  Height:  |  Size: 443 B

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Before

Width:  |  Height:  |  Size: 554 KiB

After

Width:  |  Height:  |  Size: 554 KiB

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

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

Loading…
Cancel
Save