合并了zhy的代码

master
CYZ 2 years ago
commit 2cd46aacdf

@ -1,45 +0,0 @@
apply plugin: 'com.android.application'
android {
compileSdk 30
buildToolsVersion '30.0.3'
useLibrary'org.apache.http.legacy'
defaultConfig {
applicationId "net.micode.notes"
minSdkVersion 22
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 30
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets{
main(){
jniLibs.srcDirs = ['libs']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
implementation files('libs\\Msc.jar')
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
implementation 'com.android.support:design:29.1.1'
implementation 'com.zhihu.android:matisse:0.5.2-beta4'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.simple:spiderman:1.0.2'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

@ -84,6 +84,9 @@
android:resource="@xml/searchable" /> android:resource="@xml/searchable" />
</activity> </activity>
<activity android:name=".ui.DrawActivity"
/>
<provider <provider
android:authorities="com.example.cameraalbumtest.fileprovider" android:authorities="com.example.cameraalbumtest.fileprovider"
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"

@ -0,0 +1,117 @@
package net.micode.notes.ui;
import static net.micode.notes.tool.DataUtils.TAG;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import net.micode.notes.R;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class DrawActivity extends Activity {
private ImageView img;
private Bitmap mBitmap;
private Canvas canvas;
private Paint paint;
// 重置按钮
private Button reset_btn;
private Button save_paint;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
img = (ImageView) findViewById(R.id.draw);
reset_btn = (Button) findViewById(R.id.reset);
reset_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
img.setImageBitmap(null);
showImage();
}
});
save_paint = (Button)findViewById(R.id.save);
save_paint.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//save();
finish();
}
});
// 绘图
showImage();
}
private void showImage() {
// 创建一张空白图片
mBitmap = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);
// 创建一张画布
canvas = new Canvas(mBitmap);
// 画布背景为白色
canvas.drawColor(Color.WHITE);
// 创建画笔
paint = new Paint();
// 画笔颜色为蓝色
paint.setColor(Color.BLUE);
// 宽度5个像素
paint.setStrokeWidth(5);
// 先将白色背景画上
canvas.drawBitmap(mBitmap, new Matrix(), paint);
img.setImageBitmap(mBitmap);
img.setOnTouchListener(new View.OnTouchListener() {
int startX;
int startY;
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// 获取手按下时的坐标
startX = (int) event.getX();
startY = (int) event.getY();
break;
case MotionEvent.ACTION_MOVE:
// 获取手移动后的坐标
int endX = (int) event.getX();
int endY = (int) event.getY();
// 在开始和结束坐标间画一条线
canvas.drawLine(startX, startY, endX, endY, paint);
// 刷新开始坐标
startX = (int) event.getX();
startY = (int) event.getY();
img.setImageBitmap(mBitmap);
break;
}
return true;
}
});
}
public void save() {
File file = new File(Environment.getExternalStorageDirectory(),
System.currentTimeMillis() + ".jpg");
OutputStream stream;
Log.i(TAG, Environment.getExternalStorageDirectory().toString());
try {
stream = new FileOutputStream(file);
mBitmap.compress(Bitmap.CompressFormat.JPEG, 200, stream);
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -40,9 +40,11 @@ import android.location.LocationListener;
import android.location.LocationManager; import android.location.LocationManager;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.text.style.BackgroundColorSpan; import android.text.style.BackgroundColorSpan;
import android.util.Log; import android.util.Log;
@ -59,15 +61,21 @@ import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import net.micode.notes.R; import net.micode.notes.R;
import net.micode.notes.data.Notes; import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.TextNote; import net.micode.notes.data.Notes.TextNote;
import net.micode.notes.gtask.data.Task;
import net.micode.notes.gtask.data.TaskList;
import net.micode.notes.model.WorkingNote; import net.micode.notes.model.WorkingNote;
import net.micode.notes.model.WorkingNote.NoteSettingChangedListener; import net.micode.notes.model.WorkingNote.NoteSettingChangedListener;
import net.micode.notes.tool.DataUtils; import net.micode.notes.tool.DataUtils;
@ -91,15 +99,18 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Stack;
import java.util.Vector;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class NoteEditActivity extends Activity implements OnClickListener, public class NoteEditActivity extends Activity implements OnClickListener,
NoteSettingChangedListener, OnTextViewChangeListener { NoteSettingChangedListener, OnTextViewChangeListener {
public static final int LOCATION_CODE = 301; public static final int LOCATION_CODE = 301;
private LocationManager locationManager; private LocationManager locationManager;
private String locationProvider = null; private String locationProvider = null;
private class HeadViewHolder { private static class HeadViewHolder {
public TextView tvModified; public TextView tvModified;
public ImageView ivAlertIcon; public ImageView ivAlertIcon;
@ -107,6 +118,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
public TextView tvAlertDate; public TextView tvAlertDate;
public ImageView ibSetBgColor; public ImageView ibSetBgColor;
public ImageView startDraw;
public ImageButton note_Read;
public Button note_revote;
} }
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>(); private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
@ -153,14 +170,22 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private View mNoteBgColorSelector; private View mNoteBgColorSelector;
//private View mDraw = findViewById(R.id.img);
private View mFontSizeSelector; private View mFontSizeSelector;
private EditText mNoteEditor; private EditText mNoteEditor;
private Vector<SpannableString> mHistory = new Vector<SpannableString>(10);
private View mNoteEditorPanel; private View mNoteEditorPanel;
//private final static int REQUEST_CODE_NEW_NODE = 103;
private WorkingNote mWorkingNote; private WorkingNote mWorkingNote;
private boolean mIsRevort;
private SharedPreferences mSharedPrefs; private SharedPreferences mSharedPrefs;
private int mFontSizeId; private int mFontSizeId;
@ -174,8 +199,11 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private LinearLayout mEditTextList; private LinearLayout mEditTextList;
private String mUserQuery; private String mUserQuery;
private Pattern mPattern; private Pattern mPattern;
private TextToSpeech mTTS;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -398,8 +426,56 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon); mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon);
mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date); mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date);
mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color); mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
mNoteHeaderHolder.startDraw = (ImageButton) findViewById(R.id.imageButton2);
mNoteHeaderHolder.note_Read = (ImageButton) findViewById(R.id.menu_note_read);
mNoteHeaderHolder.note_revote = (Button) findViewById(R.id.action_undo);
mNoteHeaderHolder.note_revote.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
backTrack();
}
});
mNoteHeaderHolder.note_Read.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
readText();
}
});
mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this); mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
mNoteHeaderHolder.startDraw.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
{
saveNote();
Intent intent = new Intent();
intent.setClass(NoteEditActivity.this, DrawActivity.class);
startActivity(intent);
}
}
});
mNoteEditor = (EditText) findViewById(R.id.note_edit_view); mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
mNoteEditor.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (!mIsRevort){
saveHistory();
}else{
mIsRevort = false;
}
}
});
mNoteEditorPanel = findViewById(R.id.sv_note_edit); mNoteEditorPanel = findViewById(R.id.sv_note_edit);
mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector); mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector);
for (int id : sBgSelectorBtnsMap.keySet()) { for (int id : sBgSelectorBtnsMap.keySet()) {
@ -423,6 +499,20 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE; mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE;
} }
mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list); mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list);
mTTS = new TextToSpeech(this, new OnInitListener() {
@Override
public void onInit(int i) {
if (i == TextToSpeech.SUCCESS){
int result = mTTS.setLanguage(Locale.US);
if (result != TextToSpeech.LANG_COUNTRY_AVAILABLE
&& result != TextToSpeech.LANG_AVAILABLE){
//Toast.makeText(NoteEditActivity.this,"暂不支持此种语言", Toast.LENGTH_LONG);
return;
}
}
}
});
} }
@Override @Override
@ -434,6 +524,33 @@ public class NoteEditActivity extends Activity implements OnClickListener,
clearSettingState(); clearSettingState();
} }
private void saveHistory(){
SpannableString input_text = new SpannableString(mNoteEditor.getText());
if (mHistory.size() >= 10){
mHistory.removeElementAt(0);
mHistory.add(input_text);
}else{
mHistory.add(input_text);
}
mNoteHeaderHolder.note_revote.setEnabled(true);
}
private void backTrack(){
int stack_size = mHistory.size();
mIsRevort = true;
if (stack_size <= 1){
mNoteHeaderHolder.note_revote.setEnabled(false);
return;
}else{
mNoteEditor.setText((CharSequence) mHistory.elementAt(stack_size - 2));
mHistory.removeElementAt(stack_size - 1);
if (stack_size == 2){
mNoteHeaderHolder.note_revote.setEnabled(false);
}
}
}
private void updateWidget() { private void updateWidget() {
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) { if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) {
@ -478,6 +595,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} }
mFontSizeSelector.setVisibility(View.GONE); mFontSizeSelector.setVisibility(View.GONE);
} }
if (id == R.id.imageButton2){
//mDraw.setVisibility(View.VISIBLE);
}
} }
@Override @Override
@ -622,6 +743,11 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}); });
} }
public void readText(){
mTTS.speak(mNoteEditor.getText().toString(), TextToSpeech.QUEUE_FLUSH, null);
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/draw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
tools:src="@tools:sample/backgrounds/scenic" />
<Button
android:id="@+id/reset"
android:layout_width="200dp"
android:layout_height="129dp"
android:layout_weight="1"
android:text="Button"
android:layout_gravity="center|center_vertical"/>
<Button
android:id="@+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Button" />
</LinearLayout>

@ -15,7 +15,8 @@
limitations under the License. limitations under the License.
--> -->
<FrameLayout <FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/list_background" android:background="@drawable/list_background"
@ -33,19 +34,41 @@
<TextView <TextView
android:id="@+id/tv_modified_date" android:id="@+id/tv_modified_date"
android:layout_width="0dip" android:layout_width="73dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="left|center_vertical" android:layout_gravity="left|center_vertical"
android:layout_marginRight="8dip" android:layout_marginRight="8dip"
android:layout_weight="1"
android:textAppearance="@style/TextAppearanceSecondaryItem" /> android:textAppearance="@style/TextAppearanceSecondaryItem" />
<Button
android:id="@+id/action_undo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Button" />
<ImageButton
android:id="@+id/menu_note_read"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:src="@android:drawable/ic_notification_overlay" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="67dp"
android:layout_height="88dp"
android:layout_weight="0"
tools:src="@tools:sample/avatars" />
<ImageView <ImageView
android:id="@+id/iv_alert_icon" android:id="@+id/iv_alert_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:background="@drawable/title_alert" /> android:background="@drawable/title_alert"
/>
<TextView <TextView
android:id="@+id/tv_alert_date" android:id="@+id/tv_alert_date"
@ -60,7 +83,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/bg_btn_set_color" /> android:background="@drawable/bg_btn_set_color" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -92,13 +117,13 @@
android:id="@+id/note_edit_view" android:id="@+id/note_edit_view"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="left|top"
android:background="@null"
android:autoLink="all" android:autoLink="all"
android:background="@null"
android:gravity="left|top"
android:lineSpacingMultiplier="1.2"
android:linksClickable="false" android:linksClickable="false"
android:minLines="12" android:minLines="12"
android:textAppearance="@style/TextAppearancePrimaryItem" android:textAppearance="@style/TextAppearancePrimaryItem" />
android:lineSpacingMultiplier="1.2" />
<LinearLayout <LinearLayout
android:id="@+id/note_edit_list" android:id="@+id/note_edit_list"
@ -119,10 +144,10 @@
<ImageView <ImageView
android:id="@+id/btn_set_bg_color" android:id="@+id/btn_set_bg_color"
android:layout_height="43dip"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:background="@drawable/bg_color_btn_mask" android:layout_height="wrap_content"
android:layout_gravity="top|right" /> android:layout_gravity="top|right"
android:background="@drawable/bg_color_btn_mask" />
<LinearLayout <LinearLayout
android:id="@+id/note_bg_color_selector" android:id="@+id/note_bg_color_selector"

Loading…
Cancel
Save