Skip to content

Commit c43aa87

Browse files
committed
07/11/2016
Second Version
1 parent 53c633a commit c43aa87

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

ReadMe.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ This picture will be stored on device temporarily, then uploaded to dropbox, and
1414

1515
The functions of uploading to dropbox and deleting from local device are implemented in Upload.java.
1616

17-
Next version
17+
July 10, 2016 Second version
1818

19-
I plan to jump over the step of storing picture on local device and directly upload it to dropbox after it is taken.
19+
I planned to submit the picture directly to Dropbox without having a local temporary file, but this operation needs Dropbox pro account.
20+
As a result, I decide to give it up.
21+
In this version, I modify the internal folder to the default camera picture folder, which is Environment.DIRECTORY_DCIM. However, we still need to add a subfolder, “100MEDIA” in this sample, to determine which camera folder we want to use.
22+

app/src/main/java/com/example/wenyun/dropboxapp/MainActivity.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public class MainActivity extends AppCompatActivity {
2828
final static private String APP_KEY = "azdrv2epggkccqe";
2929
final static private String APP_SECRET = "0dyrc7s7ogmr7i8";
3030

31-
String folder = "/storage/emulated/0/test/"; //internal folder to store temp image
31+
String folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString()+"/100MEDIA/";
32+
// String folder = "/storage/emulated/0/test/"; //internal folder to store temp image
3233
// String file_name = "/screen.jpg";
3334
// String file_path = Environment.getExternalStorageDirectory()
3435
// .getAbsolutePath() + file_name;
@@ -56,16 +57,16 @@ protected void onResume() {
5657
// Log.i("file", "start resume");
5758
super.onResume();
5859

59-
boolean link = mDBApi.getSession().isLinked();
60-
Log.i("file", "before Resume Linked: "+link);
60+
// boolean link = mDBApi.getSession().isLinked();
61+
// Log.i("file", "before Resume Linked: "+link);
6162

6263
if (mDBApi.getSession().authenticationSuccessful()) {
6364
try {
6465

6566
mDBApi.getSession().finishAuthentication();
6667

6768
String accessToken = mDBApi.getSession().getOAuth2AccessToken();
68-
Log.i("file", "token: " + accessToken);
69+
// Log.i("file", "token: " + accessToken);
6970
//upload pic
7071
if (pic_count != 0) {
7172
new Upload(mDBApi, folder, pic_count).execute();
@@ -104,7 +105,7 @@ public void openCamera(View view) {
104105
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
105106
i.putExtra(MediaStore.EXTRA_OUTPUT, temp_uri);
106107
startActivityForResult(i, 0);
107-
Log.i("Pic", "pic taken");
108+
// Log.i("Pic", "pic taken");
108109
}
109110

110111

app/src/main/java/com/example/wenyun/dropboxapp/Upload.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public class Upload extends AsyncTask<String, Void, String> {
1919
protected void onPreExecute(){}
2020

2121
//remote folder
22-
private String remote_folder="/1/";
22+
private String remote_folder = "/1/"; //Version 1, July 01
23+
// private String remote_folder = "/2/"; //Version 2
2324
private String internal_folder;
2425
private int pic_count;
2526

@@ -55,11 +56,13 @@ protected String doInBackground(String... arg0) {
5556
}
5657

5758
//delete pic in device
59+
Log.i("File", "to be deleted file is:" + internal_folder+pic_count+".jpg");
5860
File todeleteFile = new File(internal_folder + pic_count + ".jpg");
61+
Log.i("File", "is file existing: "+ todeleteFile.exists());
5962
if (todeleteFile != null) {
6063
todeleteFile.delete();
6164
}
62-
Log.i("File", "file deleted"+pic_count);
65+
Log.i("File", "file deleted "+pic_count);
6366
return response.rev;
6467
}
6568

0 commit comments

Comments
 (0)