Merge pull request 'Dairy' (#11) from p87350214/ShowMe:master into master
@ -0,0 +1,48 @@
|
|||||||
|
package com.diary.showme.diary.bean;
|
||||||
|
|
||||||
|
public class DiaryBean {
|
||||||
|
private String date;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private String tag;
|
||||||
|
|
||||||
|
public DiaryBean(String date, String title, String content, String tagz) {
|
||||||
|
this.date = date;
|
||||||
|
this.title = title;
|
||||||
|
this.content = content;
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
public String getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(String tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(String date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.diary.showme.diary.db;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
public class DiaryDatabaseHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
public static final String CREATE_DIARY = "create table Diary("
|
||||||
|
+ "id integer primary key autoincrement, "
|
||||||
|
+ "date text, "
|
||||||
|
+ "title text, "
|
||||||
|
+ "tag text, "
|
||||||
|
+ "content text)";
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
public DiaryDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
|
||||||
|
super(context, name, factory, version);
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
db.execSQL(CREATE_DIARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
|
||||||
|
db.execSQL("drop table if exists Diary");
|
||||||
|
onCreate(db);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.diary.showme.diary.event;
|
||||||
|
|
||||||
|
public class StartUpdateDiaryEvent {
|
||||||
|
|
||||||
|
private int position;
|
||||||
|
|
||||||
|
public StartUpdateDiaryEvent(int position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(int position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,502 @@
|
|||||||
|
package com.diary.showme.diary.ui;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
|
|
||||||
|
import com.diary.showme.diary.db.DiaryDatabaseHelper;
|
||||||
|
import com.diary.showme.diary.utils.AppManager;
|
||||||
|
import com.diary.showme.diary.utils.GetDate;
|
||||||
|
import com.diary.showme.diary.utils.StatusBarCompat;
|
||||||
|
import com.diary.showme.diary.widget.LinedEditText;
|
||||||
|
import com.diary.showme.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
|
|
||||||
|
import cc.trity.floatingactionbutton.FloatingActionButton;
|
||||||
|
import cc.trity.floatingactionbutton.FloatingActionsMenu;
|
||||||
|
public class AddDiaryActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@BindView(R.id.add_diary_tv_date)
|
||||||
|
TextView mAddDiaryTvDate;
|
||||||
|
@BindView(R.id.add_diary_et_title)
|
||||||
|
EditText mAddDiaryEtTitle;
|
||||||
|
@BindView(R.id.add_diary_et_content)
|
||||||
|
LinedEditText mAddDiaryEtContent;
|
||||||
|
@BindView(R.id.add_diary_fab_back)
|
||||||
|
FloatingActionButton mAddDiaryFabBack;
|
||||||
|
@BindView(R.id.add_diary_fab_add)
|
||||||
|
FloatingActionButton mAddDiaryFabAdd;
|
||||||
|
@BindView(R.id.add_diary_fab_picture)
|
||||||
|
FloatingActionButton mAddDiaryPicture;
|
||||||
|
@BindView(R.id.picture1)
|
||||||
|
ImageView mPicture1;
|
||||||
|
|
||||||
|
|
||||||
|
@BindView(R.id.right_labels)
|
||||||
|
FloatingActionsMenu mRightLabels;
|
||||||
|
@BindView(R.id.common_tv_title)
|
||||||
|
TextView mCommonTvTitle;
|
||||||
|
@BindView(R.id.common_title_ll)
|
||||||
|
LinearLayout mCommonTitleLl;
|
||||||
|
@BindView(R.id.common_iv_back)
|
||||||
|
ImageView mCommonIvBack;
|
||||||
|
@BindView(R.id.common_iv_test)
|
||||||
|
ImageView mCommonIvTest;
|
||||||
|
|
||||||
|
private DiaryDatabaseHelper mHelper;
|
||||||
|
private AlertDialog.Builder builder;
|
||||||
|
private AlertDialog dialog;
|
||||||
|
public static final int NONE = 0;
|
||||||
|
public static final int CAMERA = 11;// 拍照
|
||||||
|
public static final int PHOTO =22;
|
||||||
|
public static final int CAMERAZOOM = 33; // 相机拍照缩放
|
||||||
|
public static final int PHOTOZOOM = 44;//照片缩放
|
||||||
|
public static final int PHOTORESOULT = 55;// 结果
|
||||||
|
public static final String IMAGE_UNSPECIFIED = "image/*";
|
||||||
|
private static final String TAG = "AddM1Activity";
|
||||||
|
|
||||||
|
private static final int WRITE_PERMISSION = 0x01;
|
||||||
|
private Uri uritempFile=null;
|
||||||
|
|
||||||
|
|
||||||
|
private String cameraSavePath=null;
|
||||||
|
|
||||||
|
String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA,Manifest.permission.READ_EXTERNAL_STORAGE};
|
||||||
|
List<String> mPermissionList = new ArrayList<>();
|
||||||
|
private static final int PERMISSION_REQUEST = 1010;
|
||||||
|
|
||||||
|
|
||||||
|
private void initPermission(){
|
||||||
|
mPermissionList.clear();
|
||||||
|
/**
|
||||||
|
* 判断哪些权限未授予
|
||||||
|
*/
|
||||||
|
for (int i = 0; i < permissions.length; i++) {
|
||||||
|
if (ContextCompat.checkSelfPermission(this, permissions[i]) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
mPermissionList.add(permissions[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 判断是否为空
|
||||||
|
*/
|
||||||
|
if (mPermissionList.isEmpty()) {//未授予的权限为空,表示都授予了
|
||||||
|
} else {//请求权限方法
|
||||||
|
String[] permissions = mPermissionList.toArray(new String[mPermissionList.size()]);//将List转为数组
|
||||||
|
ActivityCompat.requestPermissions(this, permissions, PERMISSION_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Message message = null;
|
||||||
|
private Handler handler = new Handler() {
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
switch (msg.what) {
|
||||||
|
case 1000:
|
||||||
|
Bitmap bitmap = (Bitmap) msg.obj;
|
||||||
|
|
||||||
|
mPicture1.setImageBitmap(bitmap);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 1001:
|
||||||
|
mPicture1.setImageBitmap(BitmapFactory.decodeResource(
|
||||||
|
getResources(), R.mipmap.ic_add_contact_holo_light));
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
public static void startActivity(Context context) {
|
||||||
|
Intent intent = new Intent(context, AddDiaryActivity.class);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startActivity(Context context, String title, String content) {
|
||||||
|
Intent intent = new Intent(context, AddDiaryActivity.class);
|
||||||
|
intent.putExtra("title", title);
|
||||||
|
intent.putExtra("content", content);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_add_diary);
|
||||||
|
AppManager.getAppManager().addActivity(this);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
// ActionBar actionBar = getSupportActionBar();
|
||||||
|
// actionBar.hide();
|
||||||
|
Intent intent = getIntent();
|
||||||
|
mAddDiaryEtTitle.setText(intent.getStringExtra("title"));
|
||||||
|
StatusBarCompat.compat(this, Color.parseColor("#161414"));
|
||||||
|
mCommonTvTitle.setText("添加日记");
|
||||||
|
mAddDiaryTvDate.setText("今天," + GetDate.getDate());
|
||||||
|
mAddDiaryEtContent.setText(intent.getStringExtra("content"));
|
||||||
|
mHelper = new DiaryDatabaseHelper(this, "Diary.db", null, 1);
|
||||||
|
initPermission();
|
||||||
|
File f = new File(Environment.getExternalStorageDirectory()
|
||||||
|
, "qwert.jpg");
|
||||||
|
if (f.exists()) {
|
||||||
|
// Bitmap bitmap=BitmapFactory.decodeFile(f.getPath());
|
||||||
|
// icon.setImageBitmap(bitmap);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OnClick({R.id.common_iv_back, R.id.add_diary_et_title, R.id.add_diary_et_content, R.id.add_diary_fab_back, R.id.add_diary_fab_add, R.id.add_diary_fab_picture})
|
||||||
|
public void onClick(View view) {
|
||||||
|
switch (view.getId()) {
|
||||||
|
case R.id.common_iv_back:
|
||||||
|
DiaryActivity.startActivity(this);
|
||||||
|
case R.id.add_diary_et_title:
|
||||||
|
break;
|
||||||
|
case R.id.add_diary_et_content:
|
||||||
|
break;
|
||||||
|
case R.id.add_diary_fab_back:
|
||||||
|
String date = GetDate.getDate().toString();
|
||||||
|
String tag = String.valueOf(System.currentTimeMillis());
|
||||||
|
String title = mAddDiaryEtTitle.getText().toString() + "";
|
||||||
|
String content = mAddDiaryEtContent.getText().toString() + "";
|
||||||
|
if (!title.equals("") || !content.equals("")) {
|
||||||
|
SQLiteDatabase db = mHelper.getWritableDatabase();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("date", date);
|
||||||
|
values.put("title", title);
|
||||||
|
values.put("content", content);
|
||||||
|
values.put("tag", tag);
|
||||||
|
db.insert("Diary", null, values);
|
||||||
|
values.clear();
|
||||||
|
}
|
||||||
|
DiaryActivity.startActivity(this);
|
||||||
|
break;
|
||||||
|
case R.id.add_diary_fab_add:
|
||||||
|
final String dateBack = GetDate.getDate().toString();
|
||||||
|
final String titleBack = mAddDiaryEtTitle.getText().toString();
|
||||||
|
final String contentBack = mAddDiaryEtContent.getText().toString();
|
||||||
|
if(!titleBack.isEmpty() || !contentBack.isEmpty()){
|
||||||
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||||
|
alertDialogBuilder.setMessage("是否保存日记内容?").setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
SQLiteDatabase db = mHelper.getWritableDatabase();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("date", dateBack);
|
||||||
|
values.put("title", titleBack);
|
||||||
|
values.put("content", contentBack);
|
||||||
|
db.insert("Diary", null, values);
|
||||||
|
values.clear();
|
||||||
|
DiaryActivity.startActivity(AddDiaryActivity.this);
|
||||||
|
}
|
||||||
|
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
DiaryActivity.startActivity(AddDiaryActivity.this);
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
}else{
|
||||||
|
DiaryActivity.startActivity(this);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.add_diary_fab_picture:
|
||||||
|
selectOperator();// 拍照或者调用图库
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveimage(Bitmap bmp){
|
||||||
|
File f = new File(Environment.getExternalStorageDirectory()
|
||||||
|
, "qwert.jpg");
|
||||||
|
try {
|
||||||
|
FileOutputStream fos = new FileOutputStream(f);
|
||||||
|
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
|
||||||
|
fos.flush();
|
||||||
|
fos.close();
|
||||||
|
System.out.println("111111111111111111==="+f.length());
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onResume();
|
||||||
|
Intent intent =getIntent();
|
||||||
|
String action=intent.getStringExtra("android_manage_type");
|
||||||
|
|
||||||
|
if(action!=null)
|
||||||
|
{
|
||||||
|
if(action.equals("add"))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onPause();
|
||||||
|
if(dialog!=null){
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void openCamera(){
|
||||||
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
cameraSavePath =Environment.getExternalStorageDirectory()+ File.separator + "Android"+File.separator+"xx.jpg";
|
||||||
|
File f_camera =new File(cameraSavePath);
|
||||||
|
Uri uri_camera;
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
//test.xxx.com.myapplication.fileprovider 是在清单文件配置的 android:authorities
|
||||||
|
uri_camera = FileProvider.getUriForFile(this, "com.example.dairyexanple.fileprovider", f_camera);
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
System.out.println("openCamera cameraSavePath length=="+f_camera.length());
|
||||||
|
}else {
|
||||||
|
uri_camera = Uri.fromFile(f_camera);
|
||||||
|
}
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri_camera);
|
||||||
|
startActivityForResult(intent, CAMERA);
|
||||||
|
}
|
||||||
|
private void choosePhoto() {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||||
|
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||||
|
IMAGE_UNSPECIFIED);
|
||||||
|
startActivityForResult(intent, PHOTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case PERMISSION_REQUEST:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
|
}
|
||||||
|
private void startPhotoZoom2(Uri uri) {
|
||||||
|
// 调用系统中自带的图片剪裁
|
||||||
|
Intent intent = new Intent("com.android.camera.action.CROP");
|
||||||
|
intent.setDataAndType(uri, "image/*");
|
||||||
|
|
||||||
|
uritempFile = Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory()+ File.separator + "Android" + "/icon_temp1.jpg");
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, uritempFile);
|
||||||
|
|
||||||
|
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
||||||
|
intent.putExtra("noFaceDetection", true);
|
||||||
|
|
||||||
|
intent.putExtra("crop", "true");
|
||||||
|
// aspectX aspectY 是宽高的比例
|
||||||
|
intent.putExtra("aspectX", 1);
|
||||||
|
intent.putExtra("aspectY", 1);
|
||||||
|
// outputX outputY 是裁剪图片宽高
|
||||||
|
intent.putExtra("outputX", 250);
|
||||||
|
intent.putExtra("outputY", 250);
|
||||||
|
intent.putExtra("return-data", true);
|
||||||
|
startActivityForResult(intent, PHOTOZOOM);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 调用系统裁剪的方法
|
||||||
|
*/
|
||||||
|
private void startPhoneZoom(Uri uri) {
|
||||||
|
Intent intent = new Intent("com.android.camera.action.CROP");
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
}
|
||||||
|
intent.setDataAndType(uri, "image/*");
|
||||||
|
//是否可裁剪
|
||||||
|
intent.putExtra("corp", "true");
|
||||||
|
//裁剪器高宽比
|
||||||
|
intent.putExtra("aspectY", 1);
|
||||||
|
intent.putExtra("aspectX", 1);
|
||||||
|
//设置裁剪框高宽
|
||||||
|
intent.putExtra("outputX", 150);
|
||||||
|
intent.putExtra("outputY", 150);
|
||||||
|
|
||||||
|
|
||||||
|
// Uri temp =Uri.parse(cameraSavePath); //Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath() + "/" + System.currentTimeMillis() + ".jpg");
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
|
||||||
|
Uri temp =Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath()+ File.separator + "Android"+File.separator+"xx.jpg");
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
||||||
|
intent.putExtra("noFaceDetection", true);
|
||||||
|
//返回数据
|
||||||
|
intent.putExtra("return-data", true);
|
||||||
|
startActivityForResult(intent, CAMERAZOOM);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
System.out.println("onActivityResult== requestCode="+requestCode+" data ="+data);
|
||||||
|
// 读取相册缩放图片
|
||||||
|
if (requestCode == PHOTO) {
|
||||||
|
startPhotoZoom2(data.getData());
|
||||||
|
}else if(requestCode==PHOTOZOOM){
|
||||||
|
File file = null;
|
||||||
|
try {
|
||||||
|
file = new File(new URI(uritempFile.toString()));
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println("uritempFile.toString()=="+uritempFile.toString()+" "+file.length());
|
||||||
|
Bitmap photo = BitmapFactory.decodeFile(file.toString());
|
||||||
|
saveimage(photo);
|
||||||
|
|
||||||
|
message =new Message();
|
||||||
|
message.what=1000;
|
||||||
|
message.obj =photo;
|
||||||
|
handler.sendMessageDelayed(message, 100);
|
||||||
|
}else if(requestCode==CAMERAZOOM){
|
||||||
|
Bitmap photo=null;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
|
||||||
|
File file = null;
|
||||||
|
Uri temp =Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath()+ File.separator + "Android"+File.separator+"xx.jpg");
|
||||||
|
try {
|
||||||
|
file = new File(new URI(temp.toString()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
photo = BitmapFactory.decodeFile(file.toString());
|
||||||
|
|
||||||
|
}else{
|
||||||
|
File f =new File(cameraSavePath);
|
||||||
|
System.out.println("文件大小 =="+f.length());
|
||||||
|
photo = BitmapFactory.decodeFile(f.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
saveimage(photo);
|
||||||
|
message =new Message();
|
||||||
|
message.what=1000;
|
||||||
|
message.obj =photo;
|
||||||
|
handler.sendMessageDelayed(message, 100);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("qqqqqqqqqq =");
|
||||||
|
|
||||||
|
|
||||||
|
}else if(requestCode==CAMERA){
|
||||||
|
//相机返回结果
|
||||||
|
File mAvatarFile = new File(cameraSavePath);
|
||||||
|
Uri uri;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
//test.xxx.com.myapplication.fileprovider 是在清单文件配置的 android:authorities
|
||||||
|
uri = FileProvider.getUriForFile(this, "com.example.dairyexanple.fileprovider", mAvatarFile);
|
||||||
|
|
||||||
|
System.out.println("open camera 2222222 mAvatarFile length=="+mAvatarFile.length());
|
||||||
|
}else {
|
||||||
|
uri = Uri.fromFile(mAvatarFile);
|
||||||
|
}
|
||||||
|
startPhoneZoom(uri);
|
||||||
|
System.out.println("uritempFile.toString()==");
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
private void selectOperator(){
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
list.add(0, "从相册中选择");
|
||||||
|
list.add(1, "相机");
|
||||||
|
builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("请选择获取图片的方式");
|
||||||
|
builder.setItems(list.toArray(new String[list.size()]), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (which == 0) {
|
||||||
|
|
||||||
|
choosePhoto();
|
||||||
|
} else if (which == 1) {
|
||||||
|
openCamera();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
/*new Utils(AddM1Activity.this)
|
||||||
|
.deleteIcon_temp_01();
|
||||||
|
//deleteIcon_temp();
|
||||||
|
|
||||||
|
message =new Message();
|
||||||
|
message.what=1001;
|
||||||
|
handler.sendMessageDelayed(message, 100);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setCancelable(true);
|
||||||
|
builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||||
|
System.out.println("clicked----"+keyCode);
|
||||||
|
dialog.dismiss();
|
||||||
|
// finish();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
System.out.println("click onCancel");
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
super.onBackPressed();
|
||||||
|
DiaryActivity.startActivity(this);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,260 @@
|
|||||||
|
package com.diary.showme.diary.ui;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.diary.showme.diary.bean.DiaryBean;
|
||||||
|
import com.diary.showme.diary.db.DiaryDatabaseHelper;
|
||||||
|
import com.diary.showme.diary.event.StartUpdateDiaryEvent;
|
||||||
|
import com.diary.showme.diary.utils.AppManager;
|
||||||
|
import com.diary.showme.diary.utils.GetDate;
|
||||||
|
import com.diary.showme.diary.utils.SpHelper;
|
||||||
|
import com.diary.showme.diary.utils.StatusBarCompat;
|
||||||
|
import com.diary.showme.R;
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
|
|
||||||
|
public class DiaryActivity extends AppCompatActivity implements View.OnClickListener{
|
||||||
|
|
||||||
|
@BindView(R.id.common_iv_back)
|
||||||
|
ImageView mCommonIvBack;
|
||||||
|
@BindView(R.id.common_tv_title)
|
||||||
|
TextView mCommonTvTitle;
|
||||||
|
@BindView(R.id.common_iv_test)
|
||||||
|
ImageView mCommonIvTest;
|
||||||
|
@BindView(R.id.common_title_ll)
|
||||||
|
LinearLayout mCommonTitleLl;
|
||||||
|
@BindView(R.id.main_iv_circle)
|
||||||
|
ImageView mMainIvCircle;
|
||||||
|
@BindView(R.id.main_tv_date)
|
||||||
|
TextView mMainTvDate;
|
||||||
|
@BindView(R.id.main_tv_content)
|
||||||
|
TextView mMainTvContent;
|
||||||
|
@BindView(R.id.item_ll_control)
|
||||||
|
LinearLayout mItemLlControl;
|
||||||
|
|
||||||
|
@BindView(R.id.main_rv_show_diary)
|
||||||
|
RecyclerView mMainRvShowDiary;
|
||||||
|
@BindView(R.id.main_pause)
|
||||||
|
FloatingActionButton mMainpause;
|
||||||
|
@BindView(R.id.main_play)
|
||||||
|
FloatingActionButton mMainplay;
|
||||||
|
@BindView(R.id.main_stop)
|
||||||
|
FloatingActionButton mMainstop;
|
||||||
|
@BindView(R.id.main_fab_enter_edit)
|
||||||
|
FloatingActionButton mMainFabEnterEdit;
|
||||||
|
@BindView(R.id.main_rl_main)
|
||||||
|
RelativeLayout mMainRlMain;
|
||||||
|
@BindView(R.id.item_first)
|
||||||
|
LinearLayout mItemFirst;
|
||||||
|
@BindView(R.id.main_ll_main)
|
||||||
|
LinearLayout mMainLlMain;
|
||||||
|
private List<DiaryBean> mDiaryBeanList;
|
||||||
|
|
||||||
|
private DiaryDatabaseHelper mHelper;
|
||||||
|
|
||||||
|
private static String IS_WRITE = "true";
|
||||||
|
|
||||||
|
private int mEditPosition = -1;
|
||||||
|
|
||||||
|
private MediaPlayer mediaPlayer = new MediaPlayer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标识今天是否已经写了日记
|
||||||
|
*/
|
||||||
|
private boolean isWrite = false;
|
||||||
|
private static TextView mTvTest;
|
||||||
|
|
||||||
|
public static void startActivity(Context context) {
|
||||||
|
Intent intent = new Intent(context, DiaryActivity.class);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_diary);
|
||||||
|
AppManager.getAppManager().addActivity(this);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
StatusBarCompat.compat(this, Color.parseColor("#161414"));
|
||||||
|
mHelper = new DiaryDatabaseHelper(this, "Diary.db", null, 1);
|
||||||
|
// ActionBar actionBar = getSupportActionBar();
|
||||||
|
// actionBar.hide();
|
||||||
|
EventBus.getDefault().register(this);
|
||||||
|
SpHelper spHelper = SpHelper.getInstance(this);
|
||||||
|
getDiaryBeanList();
|
||||||
|
initTitle();
|
||||||
|
mMainRvShowDiary.setLayoutManager(new LinearLayoutManager(this));
|
||||||
|
mMainRvShowDiary.setAdapter(new DiaryAdapter(this, mDiaryBeanList));
|
||||||
|
mTvTest = new TextView(this);
|
||||||
|
mTvTest.setText("hello world");
|
||||||
|
mMainplay.setOnClickListener(this);
|
||||||
|
mMainpause.setOnClickListener(this);
|
||||||
|
mMainstop.setOnClickListener(this);
|
||||||
|
//权限判断,如果没有权限就请求权限
|
||||||
|
if (ContextCompat.checkSelfPermission(DiaryActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
ActivityCompat.requestPermissions(DiaryActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
||||||
|
} else {
|
||||||
|
initMediaPlayer();//初始化播放器 MediaPlayer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initTitle() {
|
||||||
|
mMainTvDate.setText("今天," + GetDate.getDate());
|
||||||
|
mCommonTvTitle.setText("日记");
|
||||||
|
mCommonIvBack.setVisibility(View.INVISIBLE);
|
||||||
|
mCommonIvTest.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DiaryBean> getDiaryBeanList() {
|
||||||
|
|
||||||
|
mDiaryBeanList = new ArrayList<>();
|
||||||
|
List<DiaryBean> diaryList = new ArrayList<>();
|
||||||
|
SQLiteDatabase sqLiteDatabase = mHelper.getWritableDatabase();
|
||||||
|
Cursor cursor = sqLiteDatabase.query("Diary", null, null, null, null, null, null);
|
||||||
|
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
String date = cursor.getString(cursor.getColumnIndex("date"));
|
||||||
|
String dateSystem = GetDate.getDate().toString();
|
||||||
|
if (date.equals(dateSystem)) {
|
||||||
|
mMainLlMain.removeView(mItemFirst);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
String date = cursor.getString(cursor.getColumnIndex("date"));
|
||||||
|
String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||||
|
String content = cursor.getString(cursor.getColumnIndex("content"));
|
||||||
|
String tag = cursor.getString(cursor.getColumnIndex("tag"));
|
||||||
|
mDiaryBeanList.add(new DiaryBean(date, title, content, tag));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
|
||||||
|
for (int i = mDiaryBeanList.size() - 1; i >= 0; i--) {
|
||||||
|
diaryList.add(mDiaryBeanList.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
mDiaryBeanList = diaryList;
|
||||||
|
return mDiaryBeanList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initMediaPlayer() {
|
||||||
|
try {
|
||||||
|
File file = new File(Environment.getExternalStorageDirectory(), "music.mp3");
|
||||||
|
mediaPlayer.setDataSource(file.getPath());//指定音频文件路径
|
||||||
|
mediaPlayer.setLooping(true);//设置为循环播放
|
||||||
|
mediaPlayer.prepare();//初始化播放器MediaPlayer
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
|
switch (requestCode){
|
||||||
|
case 1:
|
||||||
|
if(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
|
||||||
|
initMediaPlayer();
|
||||||
|
}else{
|
||||||
|
Toast.makeText(this, "拒绝权限,将无法使用程序。", Toast.LENGTH_LONG).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick({R.id.main_play, R.id.main_pause, R.id.main_stop, R.id.main_fab_enter_edit})
|
||||||
|
public void onClick(View view) {
|
||||||
|
switch (view.getId()) {
|
||||||
|
case R.id.main_play:
|
||||||
|
//如果没在播放中,立刻开始播放。
|
||||||
|
if(!mediaPlayer.isPlaying()){
|
||||||
|
mediaPlayer.start();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.main_pause:
|
||||||
|
//如果在播放中,立刻暂停。
|
||||||
|
if(mediaPlayer.isPlaying()){
|
||||||
|
mediaPlayer.pause();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.main_stop:
|
||||||
|
//如果在播放中,立刻停止。
|
||||||
|
if(mediaPlayer.isPlaying()){
|
||||||
|
mediaPlayer.reset();
|
||||||
|
initMediaPlayer();//初始化播放器 MediaPlayer
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.main_fab_enter_edit:
|
||||||
|
AddDiaryActivity.startActivity(this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void startUpdateDiaryActivity(StartUpdateDiaryEvent event) {
|
||||||
|
String title = mDiaryBeanList.get(event.getPosition()).getTitle();
|
||||||
|
String content = mDiaryBeanList.get(event.getPosition()).getContent();
|
||||||
|
String tag = mDiaryBeanList.get(event.getPosition()).getTag();
|
||||||
|
UpdateDiaryActivity.startActivity(this, title, content, tag);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
EventBus.getDefault().unregister(this);
|
||||||
|
if(mediaPlayer != null){
|
||||||
|
mediaPlayer.stop();
|
||||||
|
mediaPlayer.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
super.onBackPressed();
|
||||||
|
AppManager.getAppManager().AppExit(this);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package com.diary.showme.diary.ui;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.diary.showme.diary.bean.DiaryBean;
|
||||||
|
import com.diary.showme.diary.event.StartUpdateDiaryEvent;
|
||||||
|
import com.diary.showme.diary.utils.GetDate;
|
||||||
|
import com.diary.showme.R;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DiaryAdapter extends RecyclerView.Adapter<DiaryAdapter.DiaryViewHolder> {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private LayoutInflater mLayoutInflater;
|
||||||
|
private List<DiaryBean> mDiaryBeanList;
|
||||||
|
private int mEditPosition = -1;
|
||||||
|
|
||||||
|
public DiaryAdapter(Context context, List<DiaryBean> mDiaryBeanList){
|
||||||
|
mContext = context;
|
||||||
|
this.mLayoutInflater = LayoutInflater.from(context);
|
||||||
|
this.mDiaryBeanList = mDiaryBeanList;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public DiaryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
return new DiaryViewHolder(mLayoutInflater.inflate(R.layout.item_rv_diary, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(final DiaryViewHolder holder, final int position) {
|
||||||
|
|
||||||
|
String dateSystem = GetDate.getDate().toString();
|
||||||
|
if(mDiaryBeanList.get(position).getDate().equals(dateSystem)){
|
||||||
|
holder.mIvCircle.setImageResource(R.drawable.circle_orange);
|
||||||
|
}
|
||||||
|
holder.mTvDate.setText(mDiaryBeanList.get(position).getDate());
|
||||||
|
holder.mTvTitle.setText(mDiaryBeanList.get(position).getTitle());
|
||||||
|
holder.mTvContent.setText(" " + mDiaryBeanList.get(position).getContent());
|
||||||
|
holder.mIvEdit.setVisibility(View.INVISIBLE);
|
||||||
|
if(mEditPosition == position){
|
||||||
|
holder.mIvEdit.setVisibility(View.VISIBLE);
|
||||||
|
}else {
|
||||||
|
holder.mIvEdit.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
holder.mLl.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if(holder.mIvEdit.getVisibility() == View.VISIBLE){
|
||||||
|
holder.mIvEdit.setVisibility(View.GONE);
|
||||||
|
}else {
|
||||||
|
holder.mIvEdit.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
if(mEditPosition != position){
|
||||||
|
notifyItemChanged(mEditPosition);
|
||||||
|
}
|
||||||
|
mEditPosition = position;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
holder.mIvEdit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
EventBus.getDefault().post(new StartUpdateDiaryEvent(position));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mDiaryBeanList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DiaryViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
|
||||||
|
TextView mTvDate;
|
||||||
|
TextView mTvTitle;
|
||||||
|
TextView mTvContent;
|
||||||
|
ImageView mIvEdit;
|
||||||
|
LinearLayout mLlTitle;
|
||||||
|
LinearLayout mLl;
|
||||||
|
ImageView mIvCircle;
|
||||||
|
LinearLayout mLlControl;
|
||||||
|
RelativeLayout mRlEdit;
|
||||||
|
|
||||||
|
DiaryViewHolder(View view){
|
||||||
|
super(view);
|
||||||
|
mIvCircle = (ImageView) view.findViewById(R.id.main_iv_circle);
|
||||||
|
mTvDate = (TextView) view.findViewById(R.id.main_tv_date);
|
||||||
|
mTvTitle = (TextView) view.findViewById(R.id.main_tv_title);
|
||||||
|
mTvContent = (TextView) view.findViewById(R.id.main_tv_content);
|
||||||
|
mIvEdit = (ImageView) view.findViewById(R.id.main_iv_edit);
|
||||||
|
mLlTitle = (LinearLayout) view.findViewById(R.id.main_ll_title);
|
||||||
|
mLl = (LinearLayout) view.findViewById(R.id.item_ll);
|
||||||
|
mLlControl = (LinearLayout) view.findViewById(R.id.item_ll_control);
|
||||||
|
mRlEdit = (RelativeLayout) view.findViewById(R.id.item_rl_edit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,496 @@
|
|||||||
|
package com.diary.showme.diary.ui;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
|
import com.diary.showme.diary.db.DiaryDatabaseHelper;
|
||||||
|
import com.diary.showme.diary.utils.AppManager;
|
||||||
|
import com.diary.showme.diary.utils.GetDate;
|
||||||
|
import com.diary.showme.diary.utils.StatusBarCompat;
|
||||||
|
import com.diary.showme.diary.widget.LinedEditText;
|
||||||
|
import com.diary.showme.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
|
import butterknife.BindView;
|
||||||
|
|
||||||
|
import cc.trity.floatingactionbutton.FloatingActionButton;
|
||||||
|
import cc.trity.floatingactionbutton.FloatingActionsMenu;
|
||||||
|
|
||||||
|
public class UpdateDiaryActivity extends AppCompatActivity {
|
||||||
|
@BindView(R.id.picture2)
|
||||||
|
ImageView mPicture2;
|
||||||
|
@BindView(R.id.update_diary_fab_picture)
|
||||||
|
FloatingActionButton mUpdateDiaryPicture;
|
||||||
|
@BindView(R.id.update_diary_tv_date)
|
||||||
|
TextView mUpdateDiaryTvDate;
|
||||||
|
@BindView(R.id.update_diary_et_title)
|
||||||
|
EditText mUpdateDiaryEtTitle;
|
||||||
|
@BindView(R.id.update_diary_et_content)
|
||||||
|
LinedEditText mUpdateDiaryEtContent;
|
||||||
|
@BindView(R.id.update_diary_fab_back)
|
||||||
|
FloatingActionButton mUpdateDiaryFabBack;
|
||||||
|
@BindView(R.id.update_diary_fab_add)
|
||||||
|
FloatingActionButton mUpdateDiaryFabAdd;
|
||||||
|
@BindView(R.id.update_diary_fab_delete)
|
||||||
|
FloatingActionButton mUpdateDiaryFabDelete;
|
||||||
|
@BindView(R.id.right_labels)
|
||||||
|
FloatingActionsMenu mRightLabels;
|
||||||
|
@BindView(R.id.common_tv_title)
|
||||||
|
TextView mCommonTvTitle;
|
||||||
|
@BindView(R.id.common_title_ll)
|
||||||
|
LinearLayout mCommonTitleLl;
|
||||||
|
@BindView(R.id.common_iv_back)
|
||||||
|
ImageView mCommonIvBack;
|
||||||
|
@BindView(R.id.common_iv_test)
|
||||||
|
ImageView mCommonIvTest;
|
||||||
|
@BindView(R.id.update_diary_tv_tag)
|
||||||
|
TextView mTvTag;
|
||||||
|
private AlertDialog.Builder builder;
|
||||||
|
private AlertDialog dialog;
|
||||||
|
public static final int NONE = 0;
|
||||||
|
public static final int CAMERA = 11;// 拍照
|
||||||
|
public static final int PHOTO =22;
|
||||||
|
public static final int CAMERAZOOM = 33; // 相机拍照缩放
|
||||||
|
public static final int PHOTOZOOM = 44;//照片缩放
|
||||||
|
public static final int PHOTORESOULT = 55;// 结果
|
||||||
|
public static final String IMAGE_UNSPECIFIED = "image/*";
|
||||||
|
private static final String TAG = "AddM1Activity";
|
||||||
|
|
||||||
|
private static final int WRITE_PERMISSION = 0x01;
|
||||||
|
private Uri uritempFile=null;
|
||||||
|
|
||||||
|
private String cameraSavePath=null;
|
||||||
|
|
||||||
|
String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA,Manifest.permission.READ_EXTERNAL_STORAGE};
|
||||||
|
List<String> mPermissionList = new ArrayList<>();
|
||||||
|
private static final int PERMISSION_REQUEST = 1010;
|
||||||
|
|
||||||
|
|
||||||
|
private void initPermission(){
|
||||||
|
mPermissionList.clear();
|
||||||
|
/**
|
||||||
|
* 判断哪些权限未授予
|
||||||
|
*/
|
||||||
|
for (int i = 0; i < permissions.length; i++) {
|
||||||
|
if (ContextCompat.checkSelfPermission(this, permissions[i]) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
mPermissionList.add(permissions[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 判断是否为空
|
||||||
|
*/
|
||||||
|
if (mPermissionList.isEmpty()) {//未授予的权限为空,表示都授予了
|
||||||
|
} else {//请求权限方法
|
||||||
|
String[] permissions = mPermissionList.toArray(new String[mPermissionList.size()]);//将List转为数组
|
||||||
|
ActivityCompat.requestPermissions(this, permissions, PERMISSION_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Message message = null;
|
||||||
|
private Handler handler = new Handler() {
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
switch (msg.what) {
|
||||||
|
case 1000:
|
||||||
|
Bitmap bitmap = (Bitmap) msg.obj;
|
||||||
|
|
||||||
|
mPicture2.setImageBitmap(bitmap);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 1001:
|
||||||
|
mPicture2.setImageBitmap(BitmapFactory.decodeResource(
|
||||||
|
getResources(), R.mipmap.ic_add_contact_holo_light));
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
private DiaryDatabaseHelper mHelper;
|
||||||
|
|
||||||
|
public static void startActivity(Context context, String title, String content, String tag) {
|
||||||
|
Intent intent = new Intent(context, UpdateDiaryActivity.class);
|
||||||
|
intent.putExtra("title", title);
|
||||||
|
intent.putExtra("content", content);
|
||||||
|
intent.putExtra("tag", tag);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_update_diary);
|
||||||
|
AppManager.getAppManager().addActivity(this);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
mHelper = new DiaryDatabaseHelper(this, "Diary.db", null, 1);
|
||||||
|
initTitle();
|
||||||
|
StatusBarCompat.compat(this, Color.parseColor("#161414"));
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
mUpdateDiaryTvDate.setText("今天," + GetDate.getDate());
|
||||||
|
mUpdateDiaryEtTitle.setText(intent.getStringExtra("title"));
|
||||||
|
mUpdateDiaryEtContent.setText(intent.getStringExtra("content"));
|
||||||
|
mTvTag.setText(intent.getStringExtra("tag"));
|
||||||
|
initPermission();
|
||||||
|
File f = new File(Environment.getExternalStorageDirectory()
|
||||||
|
, "qwert.jpg");
|
||||||
|
if (f.exists()) {
|
||||||
|
// Bitmap bitmap=BitmapFactory.decodeFile(f.getPath());
|
||||||
|
// icon.setImageBitmap(bitmap);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initTitle() {
|
||||||
|
// ActionBar actionBar = getSupportActionBar();
|
||||||
|
// actionBar.hide();
|
||||||
|
mCommonTvTitle.setText("修改日记");
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick({R.id.common_iv_back, R.id.update_diary_tv_date, R.id.update_diary_et_title, R.id.update_diary_et_content, R.id.update_diary_fab_back, R.id.update_diary_fab_add, R.id.update_diary_fab_delete, R.id.update_diary_fab_picture})
|
||||||
|
public void onClick(View view) {
|
||||||
|
switch (view.getId()) {
|
||||||
|
case R.id.common_iv_back:
|
||||||
|
DiaryActivity.startActivity(this);
|
||||||
|
case R.id.update_diary_tv_date:
|
||||||
|
break;
|
||||||
|
case R.id.update_diary_et_title:
|
||||||
|
break;
|
||||||
|
case R.id.update_diary_et_content:
|
||||||
|
break;
|
||||||
|
case R.id.update_diary_fab_back:
|
||||||
|
androidx.appcompat.app.AlertDialog.Builder alertDialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(this);
|
||||||
|
alertDialogBuilder.setMessage("确定要删除该日记吗?").setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
// String title = mUpdateDiaryEtTitle.getText().toString();
|
||||||
|
String tag = mTvTag.getText().toString();
|
||||||
|
SQLiteDatabase dbDelete = mHelper.getWritableDatabase();
|
||||||
|
dbDelete.delete("Diary", "tag = ?", new String[]{tag});
|
||||||
|
DiaryActivity.startActivity(UpdateDiaryActivity.this);
|
||||||
|
}
|
||||||
|
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
break;
|
||||||
|
case R.id.update_diary_fab_add:
|
||||||
|
SQLiteDatabase dbUpdate = mHelper.getWritableDatabase();
|
||||||
|
ContentValues valuesUpdate = new ContentValues();
|
||||||
|
String title = mUpdateDiaryEtTitle.getText().toString();
|
||||||
|
String content = mUpdateDiaryEtContent.getText().toString();
|
||||||
|
valuesUpdate.put("title", title);
|
||||||
|
valuesUpdate.put("content", content);
|
||||||
|
dbUpdate.update("Diary", valuesUpdate, "title = ?", new String[]{title});
|
||||||
|
dbUpdate.update("Diary", valuesUpdate, "content = ?", new String[]{content});
|
||||||
|
DiaryActivity.startActivity(this);
|
||||||
|
break;
|
||||||
|
case R.id.update_diary_fab_delete:
|
||||||
|
DiaryActivity.startActivity(this);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case R.id.update_diary_fab_picture:
|
||||||
|
selectOperator();// 拍照或者调用图库
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void saveimage(Bitmap bmp){
|
||||||
|
File f = new File(Environment.getExternalStorageDirectory()
|
||||||
|
, "qwert.jpg");
|
||||||
|
try {
|
||||||
|
FileOutputStream fos = new FileOutputStream(f);
|
||||||
|
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
|
||||||
|
fos.flush();
|
||||||
|
fos.close();
|
||||||
|
System.out.println("111111111111111111==="+f.length());
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onResume();
|
||||||
|
Intent intent =getIntent();
|
||||||
|
String action=intent.getStringExtra("android_manage_type");
|
||||||
|
|
||||||
|
if(action!=null)
|
||||||
|
{
|
||||||
|
if(action.equals("add"))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onPause();
|
||||||
|
if(dialog!=null){
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void openCamera(){
|
||||||
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
cameraSavePath =Environment.getExternalStorageDirectory()+ File.separator + "Android"+File.separator+"xx.jpg";
|
||||||
|
File f_camera =new File(cameraSavePath);
|
||||||
|
Uri uri_camera;
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
//test.xxx.com.myapplication.fileprovider 是在清单文件配置的 android:authorities
|
||||||
|
uri_camera = FileProvider.getUriForFile(this, "com.example.dairyexanple.fileprovider", f_camera);
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
System.out.println("openCamera cameraSavePath length=="+f_camera.length());
|
||||||
|
}else {
|
||||||
|
uri_camera = Uri.fromFile(f_camera);
|
||||||
|
}
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri_camera);
|
||||||
|
startActivityForResult(intent, CAMERA);
|
||||||
|
}
|
||||||
|
private void choosePhoto() {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||||
|
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||||
|
IMAGE_UNSPECIFIED);
|
||||||
|
startActivityForResult(intent, PHOTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case PERMISSION_REQUEST:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
|
}
|
||||||
|
private void startPhotoZoom2(Uri uri) {
|
||||||
|
// 调用系统中自带的图片剪裁
|
||||||
|
Intent intent = new Intent("com.android.camera.action.CROP");
|
||||||
|
intent.setDataAndType(uri, "image/*");
|
||||||
|
|
||||||
|
uritempFile = Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory()+ File.separator + "Android" + "/icon_temp1.jpg");
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, uritempFile);
|
||||||
|
|
||||||
|
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
||||||
|
intent.putExtra("noFaceDetection", true);
|
||||||
|
|
||||||
|
intent.putExtra("crop", "true");
|
||||||
|
// aspectX aspectY 是宽高的比例
|
||||||
|
intent.putExtra("aspectX", 1);
|
||||||
|
intent.putExtra("aspectY", 1);
|
||||||
|
// outputX outputY 是裁剪图片宽高
|
||||||
|
intent.putExtra("outputX", 250);
|
||||||
|
intent.putExtra("outputY", 250);
|
||||||
|
intent.putExtra("return-data", true);
|
||||||
|
startActivityForResult(intent, PHOTOZOOM);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 调用系统裁剪的方法
|
||||||
|
*/
|
||||||
|
private void startPhoneZoom(Uri uri) {
|
||||||
|
Intent intent = new Intent("com.android.camera.action.CROP");
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
}
|
||||||
|
intent.setDataAndType(uri, "image/*");
|
||||||
|
//是否可裁剪
|
||||||
|
intent.putExtra("corp", "true");
|
||||||
|
//裁剪器高宽比
|
||||||
|
intent.putExtra("aspectY", 1);
|
||||||
|
intent.putExtra("aspectX", 1);
|
||||||
|
//设置裁剪框高宽
|
||||||
|
intent.putExtra("outputX", 150);
|
||||||
|
intent.putExtra("outputY", 150);
|
||||||
|
|
||||||
|
|
||||||
|
// Uri temp =Uri.parse(cameraSavePath); //Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath() + "/" + System.currentTimeMillis() + ".jpg");
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
|
||||||
|
Uri temp =Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath()+ File.separator + "Android"+File.separator+"xx.jpg");
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
||||||
|
intent.putExtra("noFaceDetection", true);
|
||||||
|
//返回数据
|
||||||
|
intent.putExtra("return-data", true);
|
||||||
|
startActivityForResult(intent, CAMERAZOOM);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
System.out.println("onActivityResult== requestCode="+requestCode+" data ="+data);
|
||||||
|
// 读取相册缩放图片
|
||||||
|
if (requestCode == PHOTO) {
|
||||||
|
startPhotoZoom2(data.getData());
|
||||||
|
}else if(requestCode==PHOTOZOOM){
|
||||||
|
File file = null;
|
||||||
|
try {
|
||||||
|
file = new File(new URI(uritempFile.toString()));
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println("uritempFile.toString()=="+uritempFile.toString()+" "+file.length());
|
||||||
|
Bitmap photo = BitmapFactory.decodeFile(file.toString());
|
||||||
|
saveimage(photo);
|
||||||
|
|
||||||
|
message =new Message();
|
||||||
|
message.what=1000;
|
||||||
|
message.obj =photo;
|
||||||
|
handler.sendMessageDelayed(message, 100);
|
||||||
|
}else if(requestCode==CAMERAZOOM){
|
||||||
|
Bitmap photo=null;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
|
||||||
|
File file = null;
|
||||||
|
Uri temp =Uri.parse("file://" + "/" + Environment.getExternalStorageDirectory().getPath()+ File.separator + "Android"+File.separator+"xx.jpg");
|
||||||
|
try {
|
||||||
|
file = new File(new URI(temp.toString()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
photo = BitmapFactory.decodeFile(file.toString());
|
||||||
|
|
||||||
|
}else{
|
||||||
|
File f =new File(cameraSavePath);
|
||||||
|
System.out.println("文件大小 =="+f.length());
|
||||||
|
photo = BitmapFactory.decodeFile(f.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
saveimage(photo);
|
||||||
|
message =new Message();
|
||||||
|
message.what=1000;
|
||||||
|
message.obj =photo;
|
||||||
|
handler.sendMessageDelayed(message, 100);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("qqqqqqqqqq =");
|
||||||
|
|
||||||
|
|
||||||
|
}else if(requestCode==CAMERA){
|
||||||
|
//相机返回结果
|
||||||
|
File mAvatarFile = new File(cameraSavePath);
|
||||||
|
Uri uri;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
//test.xxx.com.myapplication.fileprovider 是在清单文件配置的 android:authorities
|
||||||
|
uri = FileProvider.getUriForFile(this, "com.example.dairyexanple.fileprovider", mAvatarFile);
|
||||||
|
|
||||||
|
System.out.println("open camera 2222222 mAvatarFile length=="+mAvatarFile.length());
|
||||||
|
}else {
|
||||||
|
uri = Uri.fromFile(mAvatarFile);
|
||||||
|
}
|
||||||
|
startPhoneZoom(uri);
|
||||||
|
System.out.println("uritempFile.toString()==");
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
private void selectOperator(){
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
list.add(0, "从相册中选择");
|
||||||
|
list.add(1, "相机");
|
||||||
|
builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("请选择获取图片的方式");
|
||||||
|
builder.setItems(list.toArray(new String[list.size()]), new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (which == 0) {
|
||||||
|
|
||||||
|
choosePhoto();
|
||||||
|
} else if (which == 1) {
|
||||||
|
openCamera();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
/*new Utils(AddM1Activity.this)
|
||||||
|
.deleteIcon_temp_01();
|
||||||
|
//deleteIcon_temp();
|
||||||
|
|
||||||
|
message =new Message();
|
||||||
|
message.what=1001;
|
||||||
|
handler.sendMessageDelayed(message, 100);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setCancelable(true);//
|
||||||
|
builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||||
|
System.out.println("clicked----"+keyCode);
|
||||||
|
dialog.dismiss();
|
||||||
|
// finish();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
System.out.println("click onCancel");
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
@OnClick(R.id.common_tv_title)
|
||||||
|
public void onClick() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
super.onBackPressed();
|
||||||
|
DiaryActivity.startActivity(this);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
package com.diary.showme.diary.utils;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
|
|
||||||
|
public class AppManager {
|
||||||
|
private static Stack<AppCompatActivity> activityStack;
|
||||||
|
private static AppManager instance;
|
||||||
|
|
||||||
|
private AppManager(){}
|
||||||
|
|
||||||
|
public static AppManager getAppManager(){
|
||||||
|
if(instance == null){
|
||||||
|
synchronized (AppManager.class){
|
||||||
|
if(instance == null){
|
||||||
|
instance = new AppManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addActivity(AppCompatActivity activity){
|
||||||
|
if(activityStack == null){
|
||||||
|
activityStack = new Stack<>();
|
||||||
|
}
|
||||||
|
activityStack.add(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public AppCompatActivity currentActivity(){
|
||||||
|
|
||||||
|
if(activityStack == null || activityStack.isEmpty()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
AppCompatActivity acitivity = activityStack.lastElement();
|
||||||
|
return acitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppCompatActivity findActivity(Class<?> cls){
|
||||||
|
AppCompatActivity activity = null;
|
||||||
|
for (AppCompatActivity appCompatActivity : activityStack) {
|
||||||
|
if(appCompatActivity.getClass().equals(cls)){
|
||||||
|
activity = appCompatActivity;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishActivity(){
|
||||||
|
AppCompatActivity activity = activityStack.lastElement();
|
||||||
|
finishActivity(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishActivity(AppCompatActivity activity){
|
||||||
|
if(activity != null){
|
||||||
|
activityStack.remove(activity);
|
||||||
|
activity.finish();
|
||||||
|
activity = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishActivity(Class<?> cls){
|
||||||
|
for (AppCompatActivity activity : activityStack) {
|
||||||
|
if(activity.getClass().equals(cls)){
|
||||||
|
finishActivity(activity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishAllActivity(){
|
||||||
|
for (int i = 0, size = activityStack.size(); i < size; i++) {
|
||||||
|
if (null != activityStack.get(i)) {
|
||||||
|
activityStack.get(i).finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
activityStack.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AppExit(Context context){
|
||||||
|
try{
|
||||||
|
finishAllActivity();
|
||||||
|
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
activityManager.killBackgroundProcesses(context.getPackageName());
|
||||||
|
System.exit(0);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.diary.showme.diary.utils;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
public class GetDate {
|
||||||
|
|
||||||
|
public static StringBuilder getDate(){
|
||||||
|
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
Calendar now = Calendar.getInstance();
|
||||||
|
stringBuilder.append(now.get(Calendar.YEAR) + "年");
|
||||||
|
stringBuilder.append((int)(now.get(Calendar.MONTH) + 1) + "月");
|
||||||
|
stringBuilder.append(now.get(Calendar.DAY_OF_MONTH) + "日");
|
||||||
|
return stringBuilder;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.diary.showme.diary.utils;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
public class SpHelper {
|
||||||
|
|
||||||
|
private static final String SP_NAME = "sp_name";
|
||||||
|
private static SpHelper mSpHelper;
|
||||||
|
private Context mAppContext;
|
||||||
|
private SharedPreferences mSharedPreferences;
|
||||||
|
private String info;
|
||||||
|
|
||||||
|
private SpHelper(Context context){
|
||||||
|
mAppContext = context.getApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取SpHelper的实例
|
||||||
|
public static SpHelper getInstance(Context context){
|
||||||
|
if(mSpHelper == null){
|
||||||
|
synchronized (SpHelper.class){
|
||||||
|
if(mSpHelper == null){
|
||||||
|
mSpHelper = new SpHelper(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mSpHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("WrongConstant")
|
||||||
|
private SharedPreferences getSharePreferences(){
|
||||||
|
if(mSharedPreferences == null){
|
||||||
|
mSharedPreferences = mAppContext.getSharedPreferences(SP_NAME, Context.MODE_APPEND);
|
||||||
|
}
|
||||||
|
return mSharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInfo(String info){
|
||||||
|
this.info = info;
|
||||||
|
getSharePreferences().edit().putString("info", info).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInfo(){
|
||||||
|
if(info.equals("") || info.length() == 0){
|
||||||
|
info = getSharePreferences().getString("info", "");
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.diary.showme.diary.utils;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 用于修改标题栏的颜色
|
||||||
|
*/
|
||||||
|
public class StatusBarCompat
|
||||||
|
{
|
||||||
|
private static final int INVALID_VAL = -1;
|
||||||
|
private static final int COLOR_DEFAULT = Color.parseColor("#20000000");
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
public static void compat(Activity activity, int statusColor)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
{
|
||||||
|
if (statusColor != INVALID_VAL)
|
||||||
|
{
|
||||||
|
activity.getWindow().setStatusBarColor(statusColor);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
{
|
||||||
|
int color = COLOR_DEFAULT;
|
||||||
|
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
|
||||||
|
if (statusColor != INVALID_VAL)
|
||||||
|
{
|
||||||
|
color = statusColor;
|
||||||
|
}
|
||||||
|
View statusBarView = contentView.getChildAt(0);
|
||||||
|
//改变颜色时避免重复添加statusBarView
|
||||||
|
if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity))
|
||||||
|
{
|
||||||
|
statusBarView.setBackgroundColor(color);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
statusBarView = new View(activity);
|
||||||
|
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
getStatusBarHeight(activity));
|
||||||
|
statusBarView.setBackgroundColor(color);
|
||||||
|
contentView.addView(statusBarView, lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void compat(Activity activity)
|
||||||
|
{
|
||||||
|
compat(activity, INVALID_VAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static int getStatusBarHeight(Context context)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||||
|
if (resourceId > 0)
|
||||||
|
{
|
||||||
|
result = context.getResources().getDimensionPixelSize(resourceId);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
package com.diary.showme.diary.widget;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.DashPathEffect;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PathEffect;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint({ "ResourceAsColor", "DrawAllocation" })
|
||||||
|
|
||||||
|
public class LinedEditText extends androidx.appcompat.widget.AppCompatEditText {
|
||||||
|
|
||||||
|
public LinedEditText(Context context) {
|
||||||
|
super(context);
|
||||||
|
initPaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinedEditText(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
initPaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinedEditText(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
initPaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initPaint() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
|
||||||
|
Paint mPaint = new Paint();
|
||||||
|
|
||||||
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
|
|
||||||
|
mPaint.setColor(Color.LTGRAY);
|
||||||
|
|
||||||
|
PathEffect effects = new DashPathEffect(new float[]{5, 5, 5, 5}, 5);
|
||||||
|
|
||||||
|
mPaint.setPathEffect(effects);
|
||||||
|
|
||||||
|
int left = getLeft();
|
||||||
|
|
||||||
|
int right = getRight();
|
||||||
|
|
||||||
|
int paddingTop = getPaddingTop();
|
||||||
|
|
||||||
|
int paddingBottom = getPaddingBottom();
|
||||||
|
|
||||||
|
int paddingLeft = getPaddingLeft();
|
||||||
|
|
||||||
|
int paddingRight = getPaddingRight();
|
||||||
|
|
||||||
|
int height = getHeight();
|
||||||
|
|
||||||
|
int lineHeight = getLineHeight();
|
||||||
|
|
||||||
|
int spcingHeight = (int) getLineSpacingExtra();
|
||||||
|
|
||||||
|
int count = (height - paddingTop - paddingBottom) / lineHeight;
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
|
||||||
|
int baseline = lineHeight * (i + 1) + paddingTop - spcingHeight / 2;
|
||||||
|
|
||||||
|
canvas.drawLine(paddingLeft, (int) (baseline * 1.0), right - paddingRight * (int) 1.8, (int) (baseline * 1.0), mPaint);
|
||||||
|
|
||||||
|
}
|
||||||
|
super.onDraw(canvas);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 210 B |
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector android:alpha="0.8" android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal" android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||||
|
</vector>
|
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- 边框颜色值 --><item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#a3a8a4" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<!-- 主体背景颜色值 -->
|
||||||
|
<item android:right="1dp">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#ffffff" />
|
||||||
|
<padding android:bottom="10dp"
|
||||||
|
android:left="10dp"
|
||||||
|
android:right="10dp"
|
||||||
|
android:top="10dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 29 KiB |
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<solid android:color="#FFFFFF"/>
|
||||||
|
|
||||||
|
<stroke
|
||||||
|
android:width="0.5dp"
|
||||||
|
android:color="#dddddd"/>
|
||||||
|
|
||||||
|
<padding
|
||||||
|
android:bottom="10dp"
|
||||||
|
android:left="10dp"
|
||||||
|
android:right="10dp"
|
||||||
|
android:top="10dp"/>
|
||||||
|
|
||||||
|
<corners android:radius="10dp"/>
|
||||||
|
|
||||||
|
</shape>
|
After Width: | Height: | Size: 53 KiB |
@ -0,0 +1,200 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
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/main_rl_main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#ffffff"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
|
tools:context=".diary.ui.DiaryActivity"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/main_ll_main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/part_common_title"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="20dp"/>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/item_first"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#ffffff"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:background="#ffffff"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="10.8dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/main_iv_circle"
|
||||||
|
android:layout_width="22dp"
|
||||||
|
android:layout_height="22dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingTop="2dp"
|
||||||
|
android:src="@drawable/circle_orange"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/main_tv_date"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingLeft="4dp"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:text="2017年01月18日"
|
||||||
|
android:textSize="14sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="23dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/linear_style"
|
||||||
|
>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/item_ll_control"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/main_tv_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:background="#ffffff"
|
||||||
|
android:lineSpacingExtra="4dp"
|
||||||
|
android:paddingLeft="33dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:text="今天,你什么都没写下..."
|
||||||
|
android:textColor="@color/gray"
|
||||||
|
android:textSize="16sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/main_rv_show_diary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/main_fab_enter_edit"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_marginBottom="36dp"
|
||||||
|
android:layout_marginLeft="30dp"
|
||||||
|
android:layout_marginStart="30dp"
|
||||||
|
android:src="@drawable/add"
|
||||||
|
app:backgroundTint="#ee722f"
|
||||||
|
app:borderWidth="0dp"
|
||||||
|
app:elevation="6dp"
|
||||||
|
app:fabSize="normal"
|
||||||
|
app:layout_anchorGravity="bottom|right"
|
||||||
|
app:pressedTranslationZ="12dp"
|
||||||
|
app:rippleColor="#a6a6a6"/>
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/main_play"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_marginBottom="36dp"
|
||||||
|
android:layout_marginLeft="30dp"
|
||||||
|
android:layout_marginStart="150dp"
|
||||||
|
android:layout_toRightOf="@id/main_fab_enter_edit"
|
||||||
|
android:src="@drawable/play"
|
||||||
|
app:backgroundTint="#ffffff"
|
||||||
|
app:borderWidth="0dp"
|
||||||
|
app:elevation="6dp"
|
||||||
|
app:fabSize="normal"
|
||||||
|
app:layout_anchorGravity="bottom|right"
|
||||||
|
app:pressedTranslationZ="12dp"
|
||||||
|
app:rippleColor="#a6a6a6"/>
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/main_pause"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_marginBottom="36dp"
|
||||||
|
android:layout_marginLeft="30dp"
|
||||||
|
android:layout_marginStart="220dp"
|
||||||
|
android:layout_toRightOf="@id/main_fab_enter_edit"
|
||||||
|
android:src="@drawable/pause"
|
||||||
|
app:backgroundTint="#ffffff"
|
||||||
|
app:borderWidth="0dp"
|
||||||
|
app:elevation="6dp"
|
||||||
|
app:fabSize="normal"
|
||||||
|
app:layout_anchorGravity="bottom|right"
|
||||||
|
app:pressedTranslationZ="12dp"
|
||||||
|
app:rippleColor="#a6a6a6"/>
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/main_stop"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_marginBottom="36dp"
|
||||||
|
android:layout_marginLeft="30dp"
|
||||||
|
android:layout_marginStart="290dp"
|
||||||
|
android:layout_toRightOf="@id/main_fab_enter_edit"
|
||||||
|
android:src="@drawable/stop"
|
||||||
|
app:backgroundTint="#ffffff"
|
||||||
|
|
||||||
|
app:borderWidth="0dp"
|
||||||
|
app:elevation="6dp"
|
||||||
|
app:fabSize="normal"
|
||||||
|
app:layout_anchorGravity="bottom|right"
|
||||||
|
app:pressedTranslationZ="12dp"
|
||||||
|
app:rippleColor="#a6a6a6"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -0,0 +1,162 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/item_ll"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:background="@color/white"
|
||||||
|
tools:ignore="MissingDefaultResource">
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="10.8dp"
|
||||||
|
android:background="#ffffff"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/main_iv_circle"
|
||||||
|
android:paddingTop="2dp"
|
||||||
|
android:layout_width="22dp"
|
||||||
|
android:layout_height="22dp"
|
||||||
|
android:src="@drawable/circle"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/main_tv_date"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingLeft="4dp"
|
||||||
|
android:paddingTop="1dp"
|
||||||
|
android:text="2017年01月18日"
|
||||||
|
android:textSize="14sp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="23dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/linear_style"
|
||||||
|
>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/item_ll_control"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/main_ll_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="#ffffff"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingTop="3dp"
|
||||||
|
android:background="#ffffff"
|
||||||
|
android:id="@+id/main_tv_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:text="哈哈哈今天傻逼了"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="19sp"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingTop="2dp"
|
||||||
|
android:background="#ffffff"
|
||||||
|
android:id="@+id/main_tv_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:lineSpacingExtra="4dp"
|
||||||
|
android:paddingLeft="33dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
|
android:text=" 在这里写些什么在这里写些什么在这里写些什么在这里写些什么在这里写些什么在这里写些什么在这里写些什么在这里写些什么在这里写些什么在这里 写些什么在这里写些什么在这里写些什么在这里写些什么在这里写些什么在这里写些什么在这里写些什么"
|
||||||
|
android:textColor="#1d1c1c"
|
||||||
|
android:textSize="16sp"
|
||||||
|
|
||||||
|
/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/item_rl_edit"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:background="#ffffff"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/main_iv_edit"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:src="@drawable/edit"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:background="#ffffff"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="20dp">
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|