From f90a247d76d057701ec7e567e2a7861bf6199d08 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 5 Feb 2015 14:07:13 +0100 Subject: Fall back on old file dialog for all file dialogs (fixes Android TV) --- .../de/blinkt/openvpn/views/FileSelectLayout.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'main/src') diff --git a/main/src/main/java/de/blinkt/openvpn/views/FileSelectLayout.java b/main/src/main/java/de/blinkt/openvpn/views/FileSelectLayout.java index 1addd831..401eaa2a 100644 --- a/main/src/main/java/de/blinkt/openvpn/views/FileSelectLayout.java +++ b/main/src/main/java/de/blinkt/openvpn/views/FileSelectLayout.java @@ -32,23 +32,22 @@ public class FileSelectLayout extends LinearLayout implements OnClickListener { public void parseResponse(Intent data, Context c) { - if (VERSION.SDK_INT < VERSION_CODES.KITKAT) { - String fileData = data.getStringExtra(FileSelect.RESULT_DATA); - setData(fileData, c); - } else if (data != null) { + try { String newData = Utils.getFilePickerResult(fileType, data, c); if (newData!=null) setData(newData, c); + if (newData == null) { + String fileData = data.getStringExtra(FileSelect.RESULT_DATA); + setData(fileData, c); + } + } catch (IOException e) { VpnStatus.logException(e); } catch (SecurityException e) { VpnStatus.logException(e); } - - - } } public interface FileSelectCallback { @@ -166,8 +165,12 @@ public class FileSelectLayout extends LinearLayout implements OnClickListener { @Override public void onClick(View v) { if (v == mSelectButton) { + Intent startFilePicker=null; if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { - Intent startFilePicker = Utils.getFilePickerIntent(getContext(),fileType); + startFilePicker = Utils.getFilePickerIntent(getContext(), fileType); + } + + if (startFilePicker != null) { mFragment.startActivityForResult(startFilePicker, mTaskId); } else { getCertificateFileDialog(); -- cgit v1.2.3