From 59fde090adb775412e8c3bbd3a43db9585610f09 Mon Sep 17 00:00:00 2001 From: blank X Date: Fri, 29 Apr 2022 23:13:06 +0700 Subject: [PATCH] Fix moreee bugs --- .../com/blankie/fileify/PickActivity.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/blankie/fileify/PickActivity.java b/app/src/main/java/com/blankie/fileify/PickActivity.java index abd8b8b..36fe3c1 100644 --- a/app/src/main/java/com/blankie/fileify/PickActivity.java +++ b/app/src/main/java/com/blankie/fileify/PickActivity.java @@ -1,6 +1,7 @@ package com.blankie.fileify; import android.app.Activity; +import android.widget.Toast; import android.content.Intent; import android.content.ActivityNotFoundException; import android.util.Log; @@ -10,12 +11,6 @@ import com.blankie.fileify.R; public class PickActivity extends Activity { public static final String TAG = "fileify"; - private void logAndToast(int priority, String msg) { - Log.println(priority, TAG, msg); - Toast.makeText(getApplicationContext(), msg, Toast.LENGH_SHORT) - .show(); - } - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -41,8 +36,10 @@ public class PickActivity extends Activity { try { startActivityForResult(newIntent, 0); } catch (ActivityNotFoundException e) { - logAndToast(Log.ERROR, R.string.no_activity); - setResult(RESULT_CANCELLED); + Log.e(TAG, getString(R.string.no_activity)); + Toast.makeText(getApplicationContext(), msg, Toast.LENGH_SHORT) + .show(); + setResult(Activity.RESULT_CANCELLED); finish(); } } @@ -55,13 +52,13 @@ public class PickActivity extends Activity { if (resultCode != RESULT_OK) { Log.d(TAG, "Received resultCode = " + resultCode); - setResult(RESULT_CANCELLED); + setResult(Activity.RESULT_CANCELLED); finish(); // probably not necessary but just in case or something return; } else if (data == null) { Log.d(TAG, "Received data = null"); - setResult(RESULT_CANCELLED); + setResult(Activity.RESULT_CANCELLED); finish(); return; } @@ -70,14 +67,14 @@ public class PickActivity extends Activity { intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); if (data.getData() != null) { intent.setData(data.getData()); - setResult(RESULT_OK, intent); + setResult(Activity.RESULT_OK, intent); } else if (data.getClipData() != null) { // unsafe? intent.setClipData(data.getClipData()); - setResult(RESULT_OK, intent); + setResult(Activity.RESULT_OK, intent); } else { Log.d(TAG, "Received data.getData() = null and data.getClipData() = null"); - setResult(RESULT_CANCELLED); + setResult(Activity.RESULT_CANCELLED); } finish(); }