diff --git a/src/main/java/org/billthefarmer/editor/Editor.java b/src/main/java/org/billthefarmer/editor/Editor.java index bdb1883..3129258 100644 --- a/src/main/java/org/billthefarmer/editor/Editor.java +++ b/src/main/java/org/billthefarmer/editor/Editor.java @@ -1147,7 +1147,7 @@ private void readFile(Uri uri) if (uri.getScheme().equalsIgnoreCase(CONTENT)) uri = resolveContent(uri); - // Read using ContentResolver + // Read into default file if (uri.getScheme().equalsIgnoreCase(CONTENT)) { file = getDefaultFile(); @@ -1156,11 +1156,6 @@ private void readFile(Uri uri) String title = defaultUri.getLastPathSegment(); setTitle(title); - - textView.setText(R.string.loading); - - ReadUriTask read = new ReadUriTask(); - read.execute(uri); } // Read file @@ -1171,12 +1166,12 @@ private void readFile(Uri uri) String title = uri.getLastPathSegment(); setTitle(title); + } - textView.setText(R.string.loading); + textView.setText(R.string.loading); - ReadFileTask read = new ReadFileTask(); - read.execute(file); - } + ReadTask read = new ReadTask(); + read.execute(uri); dirty = false; modified = file.lastModified(); @@ -1355,8 +1350,8 @@ public boolean onQueryTextSubmit (String query) } } - // ReadUriTask - private class ReadUriTask + // ReadTask + private class ReadTask extends AsyncTask { // doInBackground @@ -1429,76 +1424,4 @@ public void run() invalidateOptionsMenu(); } } - - // ReadFileTask - private class ReadFileTask - extends AsyncTask - { - // doInBackground - @Override - protected String doInBackground(File... params) - { - StringBuilder stringBuilder = new StringBuilder(); - try - { - FileReader fileReader = new FileReader(params[0]); - BufferedReader reader = new BufferedReader(fileReader); - - String line; - while ((line = reader.readLine()) != null) - { - stringBuilder.append(line); - stringBuilder.append(System.getProperty("line.separator")); - } - - fileReader.close(); - } - - catch (Exception e) {} - - return stringBuilder.toString(); - } - - // onPostExecute - @Override - protected void onPostExecute(String result) - { - if (textView != null) - textView.setText(result); - - if (toAppend != null) - { - textView.append(toAppend); - toAppend = null; - dirty = true; - } - - else - dirty = false; - - // Check for saved position - if (pathMap.containsKey(path)) - { - textView.postDelayed(new Runnable() - { - // run - @Override - public void run() - { - scrollView.smoothScrollTo(0, pathMap.get(path)); - } - }, POSN_DELAY); - } - - // Set read only - textView.setRawInputType(InputType.TYPE_NULL); - textView.clearFocus(); - - // Update boolean - edit = false; - - // Update menu - invalidateOptionsMenu(); - } - } } diff --git a/src/main/java/org/billthefarmer/editor/FileUtils.java b/src/main/java/org/billthefarmer/editor/FileUtils.java index 72e597b..c9b47fc 100644 --- a/src/main/java/org/billthefarmer/editor/FileUtils.java +++ b/src/main/java/org/billthefarmer/editor/FileUtils.java @@ -340,7 +340,7 @@ public static String getPath(final Context context, final Uri uri) { if (BuildConfig.DEBUG) - Log.d(TAG + " File -", + Log.d(TAG + " File", "Authority: " + uri.getAuthority() + ", Fragment: " + uri.getFragment() + ", Port: " + uri.getPort() + @@ -427,6 +427,25 @@ else if ("audio".equals(type)) // MediaStore (and general) else if ("content".equalsIgnoreCase(uri.getScheme())) { + if (BuildConfig.DEBUG) + { + Cursor cursor = null; + try + { + cursor = context.getContentResolver() + .query(uri, null, null, null, null); + if (cursor != null && cursor.moveToFirst()) + DatabaseUtils.dumpCursor(cursor); + } + + catch (Exception e) {} + + finally + { + if (cursor != null) + cursor.close(); + } + } // Return the remote address if (isGooglePhotosUri(uri))