Skip to content

Commit

Permalink
Added permission for card write access
Browse files Browse the repository at this point in the history
  • Loading branch information
trurlo committed Sep 17, 2011
1 parent cdc5018 commit ee62b58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions AndroidManifest.xml
Expand Up @@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>
<uses-sdk android:minSdkVersion="8" /> <uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission> <uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>


<application android:icon="@drawable/icon" android:label="@string/app_name"> <application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".PimSRS" <activity android:name=".PimSRS"
Expand Down
11 changes: 9 additions & 2 deletions src/net/trurlo/PimSRS/PimSRS.java
Expand Up @@ -203,10 +203,14 @@ protected void toggleAutoPlay() {
} }


private boolean copyFile(String src, String dst){ private boolean copyFile(String src, String dst){
Log.d("PimSRS","copying file");
File srcFile = new File(src); File srcFile = new File(src);
Log.d("PimSRS"," src: "+src);
File dstFile = new File(dst); File dstFile = new File(dst);
Log.d("PimSRS"," dst: "+dst);
if (srcFile.exists()){ if (srcFile.exists()){
try { try {
Log.d("PimSRS"," src exists, copying");
FileChannel srcChannel = new FileInputStream(srcFile).getChannel(); FileChannel srcChannel = new FileInputStream(srcFile).getChannel();
FileChannel dstChannel = new FileOutputStream(dstFile).getChannel(); FileChannel dstChannel = new FileOutputStream(dstFile).getChannel();
dstChannel.transferFrom(srcChannel, 0, srcChannel.size()); dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
Expand All @@ -215,6 +219,7 @@ private boolean copyFile(String src, String dst){
return true; return true;
} }
catch (Exception e){ catch (Exception e){
Log.d("PimSRS"," copying error: "+e.getMessage());
return false; return false;
} }
} }
Expand All @@ -237,8 +242,8 @@ private void addCurrentPair() {
String strA = String.format("[sound:%s_%03d.mp3]",currentCueFileStub,pimLines.get(currentPimLineIndex).index); String strA = String.format("[sound:%s_%03d.mp3]",currentCueFileStub,pimLines.get(currentPimLineIndex).index);
String srcFileQ = String.format("%s_%03d.mp3",currentFullCueFileStub,pimLines.get(currentPimLineIndex-1).index); String srcFileQ = String.format("%s_%03d.mp3",currentFullCueFileStub,pimLines.get(currentPimLineIndex-1).index);
String srcFileA = String.format("%s_%03d.mp3",currentFullCueFileStub,pimLines.get(currentPimLineIndex).index); String srcFileA = String.format("%s_%03d.mp3",currentFullCueFileStub,pimLines.get(currentPimLineIndex).index);
String dstFileQ = String.format("%s\\%s_%03d.mp3",mediaFolder.getPath(),currentCueFileStub,pimLines.get(currentPimLineIndex-1).index); String dstFileQ = String.format("%s/%s_%03d.mp3",mediaFolder.getPath(),currentCueFileStub,pimLines.get(currentPimLineIndex-1).index);
String dstFileA = String.format("%s\\%s_%03d.mp3",mediaFolder.getPath(),currentCueFileStub,pimLines.get(currentPimLineIndex).index); String dstFileA = String.format("%s/%s_%03d.mp3",mediaFolder.getPath(),currentCueFileStub,pimLines.get(currentPimLineIndex).index);
String strNow = Double.toString(System.currentTimeMillis()/1000.0); String strNow = Double.toString(System.currentTimeMillis()/1000.0);


copyFile(srcFileQ,dstFileQ); copyFile(srcFileQ,dstFileQ);
Expand Down Expand Up @@ -673,6 +678,7 @@ public void onClick(DialogInterface dialog, int which) {
} }


private boolean readAnkiFile(String ankiFile){ private boolean readAnkiFile(String ankiFile){
Log.d("PimSRS","reading "+ankiFile);
if ((ankiFile == null)||(ankiFile == "")) return false; if ((ankiFile == null)||(ankiFile == "")) return false;
try try
{ {
Expand All @@ -686,6 +692,7 @@ private boolean readAnkiFile(String ankiFile){
return true; return true;
} }
catch (Exception e){ catch (Exception e){
Log.d("PimSRS"," opening error: "+e.getMessage());
ankiFileRead = false; ankiFileRead = false;
txtAnkiFile.setText("(no .anki opened)"); txtAnkiFile.setText("(no .anki opened)");
this.ankiFileName = ""; this.ankiFileName = "";
Expand Down

0 comments on commit ee62b58

Please sign in to comment.