Support further schemes to enter the license

Most of  the app doesn't allow custom scheme URLs. Now we support the following schemes: 
* https://android.cryptomator.org/app/license#foo (preferred)
* https://android.cryptomator.org/app/license/foo
* cryptomator://license/foo (legacy)
This commit is contained in:
Julian Raufelder 2021-01-20 16:32:28 +01:00
parent 527dde9304
commit 0c04d16df0
No known key found for this signature in database
GPG Key ID: 17EE71F6634E381D
2 changed files with 20 additions and 9 deletions

View File

@ -28,10 +28,10 @@
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<!-- Necessary for OneDrive https://stackoverflow.com/a/50779232/825532 --> <!-- Necessary for OneDrive https://stackoverflow.com/a/50779232/825532 -->
<uses-library <uses-library
android:name="org.apache.http.legacy" android:name="org.apache.http.legacy"
@ -67,8 +67,8 @@
<activity <activity
android:name=".ui.activity.SharedFilesActivity" android:name=".ui.activity.SharedFilesActivity"
android:taskAffinity=".share"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:taskAffinity=".share"
android:windowSoftInputMode="stateHidden|adjustPan"> android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter android:label="@string/share_with_label"> <intent-filter android:label="@string/share_with_label">
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
@ -122,15 +122,26 @@
<activity <activity
android:name=".ui.activity.LicenseCheckActivity" android:name=".ui.activity.LicenseCheckActivity"
android:launchMode="singleTask"> android:launchMode="singleTask">
<intent-filter android:label="@string/fab_transformation_scrim_behavior"> <intent-filter android:label="@string/dialog_enter_license_title">
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data <data
android:scheme="cryptomator" android:host="*"
android:host="*" /> android:scheme="cryptomator" />
</intent-filter>
<intent-filter android:label="@string/dialog_enter_license_title">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="android.cryptomator.org"
android:pathPrefix="/app/license"
android:scheme="https" />
</intent-filter> </intent-filter>
</activity> </activity>

View File

@ -16,8 +16,8 @@ class LicenseCheckPresenter @Inject internal constructor(
private val sharedPreferencesHandler: SharedPreferencesHandler) : Presenter<UpdateLicenseView>(exceptionHandlers) { private val sharedPreferencesHandler: SharedPreferencesHandler) : Presenter<UpdateLicenseView>(exceptionHandlers) {
fun validate(data: Uri?) { fun validate(data: Uri?) {
if (data != null) { data?.let {
val license = data.lastPathSegment ?: "" val license = it.fragment ?: it.lastPathSegment ?: ""
view?.showOrUpdateLicenseDialog(license) view?.showOrUpdateLicenseDialog(license)
doLicenseCheckUsecase doLicenseCheckUsecase
.withLicense(license) .withLicense(license)