Skip to content

Commit

Permalink
Fix ConvertCSV (openintents#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Behrens committed May 18, 2023
1 parent 5c6fd0e commit c34279f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.preference.PreferenceManager;
import android.provider.OpenableColumns;
import android.support.annotation.RequiresApi;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
Expand Down Expand Up @@ -776,20 +778,32 @@ protected String getSdCardFilename(String filename) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
Log.i(TAG, "onActivityResult");

switch (requestCode) {
case REQUEST_CODE_PICK_FILE:
if (resultCode == RESULT_OK && data != null) {
Uri documentUri = data.getData();
Uri documentUri = null;
if (Build.VERSION.SDK_INT < 19) {
documentUri = data.getData();
} else {
documentUri = data.getData();
final int takeFlags = data.getFlags()
& (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
try {
getContentResolver().takePersistableUriPermission(documentUri, takeFlags);
}
catch (SecurityException e){
e.printStackTrace();
}
}
if (documentUri != null) {
setFileUri(documentUri);
} else {
setFileUriUnknown();
}

}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ public class ShoppingActivity extends DistributionLibraryFragmentActivity
private static final int MENU_ITEM_STORES = Menu.FIRST + 22;
private static final int MENU_UNMARK_ALL_ITEMS = Menu.FIRST + 23;
private static final int MENU_SYNC_WEAR = Menu.FIRST + 25;
private static final int MENU_CONVERT_CSV = Menu.FIRST + 26;
private static final int MENU_DISTRIBUTION_START = Menu.FIRST + 100; // MUST BE LAST
private static final int DIALOG_ABOUT = 1;
// private static final int DIALOG_TEXT_ENTRY = 2;
Expand Down Expand Up @@ -1608,8 +1607,6 @@ public boolean onCreateOptionsMenu(Menu menu) {

menu.add(0, MENU_SYNC_WEAR, 0, R.string.sync_wear);

menu.add(0, MENU_CONVERT_CSV, 0, R.string.convert_csv);

// Add distribution menu items last.
mDistribution.onCreateOptionsMenu(menu);

Expand Down Expand Up @@ -1804,9 +1801,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
case MENU_SYNC_WEAR:
mItemsView.pushItemsToWear();
return true;
case MENU_CONVERT_CSV:
startActivity(new Intent(this, ConvertCsvActivity.class).setData(mListUri));
return true;
default:
break;
}
Expand Down

0 comments on commit c34279f

Please sign in to comment.