Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions TeaLeaf/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<!--START_PLUGINS_MANIFEST-->
Expand Down
3 changes: 1 addition & 2 deletions TeaLeaf/src/com/tealeaf/Overlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.tealeaf;


import android.os.Environment;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
Expand All @@ -35,7 +34,7 @@ public Overlay(TeaLeaf context) {
getSettings().setJavaScriptEnabled(true);
getSettings().setDomStorageEnabled(true);
getSettings().setDatabaseEnabled(true);
getSettings().setDatabasePath(Environment.getExternalStorageDirectory().getPath());
getSettings().setDatabasePath(context.getExternalFilesDir(null).getPath());

browserInterface = new BrowserInterface();
addJavascriptInterface(browserInterface, "tealeaf");
Expand Down
8 changes: 4 additions & 4 deletions TeaLeaf/src/com/tealeaf/PhotoPicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.CompressFormat;
import android.os.Environment;
import android.provider.MediaStore;

import java.io.File;
Expand All @@ -30,6 +29,7 @@ public class PhotoPicker {
private Activity activity;
private ResourceManager resourceManager;
private Settings settings;

public PhotoPicker(Activity context, Settings settings, ResourceManager manager) {
this.activity = context;
this.settings = settings;
Expand All @@ -54,7 +54,7 @@ public void moveNextGalleryId() {

public void take(int id) {
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File largeFile = getCaptureImageTmpFile();
File largeFile = getCaptureImageTmpFile(this.activity);
if (largeFile != null) {
camera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(largeFile));
}
Expand Down Expand Up @@ -106,10 +106,10 @@ public Bitmap getResult(String type, int id) {
}

private static File captureImageTmpFile = null;
public static File getCaptureImageTmpFile() {
public static File getCaptureImageTmpFile(Activity context) {
if (captureImageTmpFile == null) {
try {
captureImageTmpFile = File.createTempFile(".gc_tmpfile", ".jpg", Environment.getExternalStorageDirectory());
captureImageTmpFile = File.createTempFile(".gc_tmpfile", ".jpg", context.getExternalCacheDir());
} catch(Exception e) {
logger.log(e);
}
Expand Down
8 changes: 4 additions & 4 deletions TeaLeaf/src/com/tealeaf/ResourceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public String getCacheDirectory() {
}
}
public String getExternalCacheDirectory() {
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmp/";
return context.getExternalCacheDir().getAbsolutePath();
}

public void clearCacheDirectory() {
Expand Down Expand Up @@ -190,7 +190,7 @@ private File getBaseStorageDirectory() {
if (!canUseExternalStorage() || ONLY_USE_INTERNAL_STORAGE) {
storageDir = context.getFilesDir();
} else {
storageDir = Environment.getExternalStorageDirectory();
storageDir = context.getExternalFilesDir(null);
}
return storageDir;
}
Expand All @@ -199,7 +199,7 @@ public boolean writeToExternalStorage(String filename, String contents) {
if (!canUseExternalStorage()) {
return false;
}
File storageDir = Environment.getExternalStorageDirectory();
File storageDir = context.getExternalFilesDir(null);
File file = new File(storageDir.getAbsolutePath() + File.separator + filename);
if (file.exists()) {
logger.log("{resource} ERROR: External storage file exists");
Expand All @@ -221,7 +221,7 @@ public String readFromExternalStorage(String filename) {
if (!canUseExternalStorage()) {
return null;
}
File storageDir = Environment.getExternalStorageDirectory();
File storageDir = context.getExternalFilesDir(null);
File file = new File(storageDir.getAbsolutePath() + File.separator + filename);
if (!file.exists()) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion TeaLeaf/src/com/tealeaf/TeaLeaf.java
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ protected void onActivityResult(int request, int result, Intent data) {
}

//try the large file on disk
final File f = PhotoPicker.getCaptureImageTmpFile();
final File f = PhotoPicker.getCaptureImageTmpFile(this);
if (f != null && f.exists()) {
new Thread(new Runnable() {
public void run(){
Expand Down