实现更换背景、画板保存路径可以找到

ChiYanZhen_branch
CYZ 2 years ago
parent ca2c910289
commit a955b95a2b

@ -52,7 +52,9 @@ public class DrawActivity extends Activity {
@Override
public void onClick(View view) {
String path = saveBitmap();
Log.i(TAG, path);
getIntent().putExtra("path", path);
setResult(1, getIntent());
Log.i(null, path);
finish();
}
});
@ -105,20 +107,6 @@ public class DrawActivity extends Activity {
});
}
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();
}
}
public String saveBitmap(){
//获得系统当前时间,并以该时间作为文件名
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
@ -153,7 +141,8 @@ public class DrawActivity extends Activity {
// TODO Auto-generated catch block
e.printStackTrace();
}
return paintPath;
}
}

@ -202,6 +202,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private Pattern mPattern;
private String DrawPath;
private TextToSpeech mTTS;
@Override
@ -234,6 +236,17 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
}
//新activity回传数据
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0 && resultCode == 1) {
//对数据进行处理
DrawPath = data.getStringExtra("path");
Log.i(TAG, "onActivityResult: 11111111111111111111111");
}
}
private boolean initActivityState(Intent intent) {
/**
* If the user specified the {@link Intent#ACTION_VIEW} but not provided with id,
@ -462,8 +475,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
saveNote();
Intent intent = new Intent();
intent.setClass(NoteEditActivity.this, DrawActivity.class);
startActivity(intent);
startActivityForResult(intent, 0);
}
}
});
@ -730,8 +742,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
String saved_password=load("data.txt");
Log.i(TAG,saved_password);
if(entered_password.equals(saved_password)){
//noteMoveToPF();
//Log.i(TAG, "22222");
Toast.makeText(NoteEditActivity.this, "Note has moved to Private Folder", Toast.LENGTH_LONG).show();
noteMoveToPF();
}else{

@ -174,10 +174,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
context = NotesListActivity.this;
switch (requestCode) {
case 1:
case 3:
if (resultCode == RESULT_OK) {
if (Build.VERSION.SDK_INT >= 19) {
handeImage(data);
handelImage(data);
} else {
handleImageBefor(data);
}
@ -586,7 +586,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private void openFolder(NoteItemData data) {
mCurrentFolderId = data.getId();
String iddd = Long.toString(mCurrentFolderId);
Log.i(TAG, iddd);
//Log.i(TAG, iddd);
startAsyncNotesListQuery();
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
mState = ListEditState.CALL_RECORD_FOLDER;
@ -840,7 +840,6 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
public void ResetPassword(){
String if_now_create = "true";
enterPrivateFolder(if_now_create);
Log.i(TAG, "ResetPassword: 11111111111111111111111111111");
}
@Override
@ -1015,7 +1014,6 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
showSoftInput();
if (create.equals("false")){
builder.setTitle("enter the password");
//Log.i(TAG, "enterPrivateFolder: 111");
}
else{
builder.setTitle("set the password for the Private Folder");
@ -1107,7 +1105,6 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
if (item.getType() == Notes.TYPE_FOLDER
|| item.getType() == Notes.TYPE_SYSTEM) {
openFolder(item);
Log.i(TAG, "onItemClick: 1");
} else if (item.getType() == Notes.TYPE_NOTE) {
openNode(item);
} else {
@ -1198,7 +1195,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
private void handeImage(Intent data) {
private void handelImage(Intent data) {
String imagePath = null;
Uri uri2 = data.getData();
if (DocumentsContract.isDocumentUri(this, uri2)) {
@ -1216,13 +1213,13 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} else if ("file".equalsIgnoreCase(uri2.getScheme())) {
imagePath = uri2.getPath();
}
displayIaage(imagePath);
displayImage(imagePath);
}
private void handleImageBefor(Intent data) {
Uri uri = data.getData();
String imagePath = getImagePath(uri, null);
displayIaage(imagePath);
displayImage(imagePath);
}
private String getImagePath(Uri uri, String selection) {
@ -1237,10 +1234,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
return path;
}
private void displayIaage(String path) {
private void displayImage(String path) {
if (path != null) {
Bitmap bitmap = BitmapFactory.decodeFile(path);
//imageView.setImageBitmap(bitmap);
Drawable drawable = new BitmapDrawable(bitmap);
Toast.makeText(context, " 获取图片", Toast.LENGTH_SHORT).show();
getWindow().setBackgroundDrawable(drawable);

@ -18,8 +18,8 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/list_background">
android:layout_height="fill_parent">
<!--android:background="@drawable/list_background"-->
<LinearLayout
android:layout_width="fill_parent"

Loading…
Cancel
Save