diff options
author | stefan-niedermann <info@niedermann.it> | 2020-03-18 11:01:31 +0300 |
---|---|---|
committer | stefan-niedermann <info@niedermann.it> | 2020-03-18 11:01:31 +0300 |
commit | 0f8c57633e75c898276ea74bc703fb4c68fb069e (patch) | |
tree | e23635f3423bfc9896a56f9ada9d4bb12e035402 /app/src/main | |
parent | 417ec6cfbf38fe5370f745c81a4b820ba71745f4 (diff) |
📎 Temporarily fix uploading attachments for Android 10
and catch some nasty cases where sharing from 3rd-party-apps won't work yet.
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/AndroidManifest.xml | 5 | ||||
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/SelectCardActivity.java | 39 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 2 |
3 files changed, 30 insertions, 16 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 97c90204c..2fd1423b1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,14 +11,17 @@ <application android:name="it.niedermann.nextcloud.deck.Application" android:allowBackup="true" + android:fullBackupContent="false" android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" + android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" - tools:ignore="GoogleAppIndexingWarning"> + tools:ignore="GoogleAppIndexingWarning" + tools:targetApi="q"> <activity android:name=".ui.MainActivity" diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/SelectCardActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/SelectCardActivity.java index c2733cf7f..05b1cdd75 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/SelectCardActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/SelectCardActivity.java @@ -43,22 +43,31 @@ public class SelectCardActivity extends MainActivity implements CardAdapter.Sele @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - receivedIntent = getIntent(); - receivedAction = receivedIntent.getAction(); - receivedType = receivedIntent.getType(); - DeckLog.info(receivedAction); - DeckLog.info(receivedType); try { + receivedIntent = getIntent(); + receivedAction = receivedIntent.getAction(); + receivedType = receivedIntent.getType(); + DeckLog.info(receivedAction); + DeckLog.info(receivedType); isFile = !receivedType.startsWith("text/"); if (isFile) { receivedUri = receivedIntent.getParcelableExtra(Intent.EXTRA_STREAM); if (receivedUri != null) { - String path = FileUtils.getPath(this, receivedUri); - if (path != null) { - uploadFile = new File(path); - binding.toolbar.setSubtitle(uploadFile.getName()); - } else { - throw new IllegalArgumentException("Could not find path for given Uri " + receivedUri.toString()); + try { + String path = FileUtils.getPath(this, receivedUri); + if (path != null) { + uploadFile = new File(path); + binding.toolbar.setSubtitle(uploadFile.getName()); + } else { + throw new IllegalArgumentException("Could not find path for given Uri " + receivedUri.toString()); + } + } catch (IllegalArgumentException e) { + DeckLog.logError(e); + new AlertDialog.Builder(this) + .setTitle(R.string.error) + .setMessage(R.string.operation_not_yet_supported) + .setPositiveButton(R.string.simple_close, (a, b) -> finish()) + .create().show(); } } else { throw new IllegalArgumentException("Could not find any file for receivedUri = " + receivedUri); @@ -67,8 +76,8 @@ public class SelectCardActivity extends MainActivity implements CardAdapter.Sele receivedText = receivedIntent.getStringExtra(Intent.EXTRA_TEXT); binding.toolbar.setSubtitle(receivedText); } - } catch (Exception e) { - handleException(e); + } catch (Throwable throwable) { + handleException(throwable); } } @@ -82,8 +91,8 @@ public class SelectCardActivity extends MainActivity implements CardAdapter.Sele } syncManager.updateCard(fullCard); finish(); - } catch (Exception e) { - handleException(e); + } catch (Throwable throwable) { + handleException(throwable); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 452969b1e..cf1e9be4c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -80,6 +80,7 @@ <string name="label_add">Add %1$s</string> <string name="error">An error appeared</string> + <string name="operation_not_yet_supported">Not yet supported</string> <string name="simple_copy">copy</string> <string name="simple_exception">Exception</string> <string name="copied_to_clipboard">Copied to clipboard</string> @@ -162,4 +163,5 @@ <string name="share_add_to_card">Add to card</string> <string name="share_success">Successfully added %1$s to %2$s</string> <string name="could_not_copy_to_clipboard">Could not copy to clipboard</string> + <string name="shared_error">Sharing content from 3rd-party apps is not yet fully supported. Please try to download it first and then share it from you native file manager or gallery.</string> </resources> |