-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit ensures that we can drop files (photos, videos, and audio) in NoteEditor (FixedEditText). Fix: Handle minSdkVersion conflict with DropHelper and enable file drop in NoteEditor Added DropHelperCompat to handle the incompatibility issue with DropHelper and minSdkVersion 23. The manifest merger failed with the following error: Manifest merger failed: uses-sdk:minSdkVersion 23 cannot be smaller than version 24 declared in library [androidx.draganddrop:draganddrop:1.0.0] /Users/davidallison/.gradle/caches/8.8/transforms/0a1688833d368c1b9b07d2054911030e/transformed/draganddrop-1.0.0/AndroidManifest.xml as the library might be using APIs not available in 23 Suggestion: use a compatible library with a minSdk of at most 23, or increase this project's minSdk version to at least 24, or use tools:overrideLibrary="androidx.draganddrop" to force usage (may lead to runtime failures) To resolve this, the DropHelperCompat class is used to conditionally configure the view for drag and drop operations only when the SDK version is 24 or higher.
- Loading branch information
1 parent
ff89f2f
commit ef425b9
Showing
9 changed files
with
234 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
AnkiDroid/src/main/java/com/ichi2/compat/DropHelperCompat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2024 David Allison <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 3 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.ichi2.compat | ||
|
||
import android.app.Activity | ||
import android.os.Build | ||
import android.view.View | ||
import androidx.core.view.OnReceiveContentListener | ||
import androidx.draganddrop.DropHelper | ||
import com.ichi2.utils.ClipboardUtil.MEDIA_MIME_TYPES | ||
|
||
typealias DropHelperOptionsCompat = DropHelper.Options | ||
typealias DropHelperOptionsBuilder = DropHelper.Options.Builder | ||
|
||
/** | ||
* We have applied `tools:overrideLibrary="androidx.draganddrop"` so we manually need to handle | ||
* compat of [DropHelper] | ||
*/ | ||
object DropHelperCompat { | ||
|
||
/** | ||
* Configures a [View] for drag and drop operations, including the highlighting that | ||
* indicates the view is a drop target. Sets a listener that enables the view to handle dropped | ||
* data. | ||
* | ||
* @see DropHelper.configureView | ||
*/ | ||
fun configureView( | ||
activity: Activity, | ||
view: View, | ||
options: DropHelperOptionsCompat, | ||
onReceiveContentListener: OnReceiveContentListener | ||
) { | ||
// library will fail < API 24 | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return | ||
|
||
DropHelper.configureView( | ||
activity, | ||
view, | ||
MEDIA_MIME_TYPES, | ||
options, | ||
onReceiveContentListener | ||
) | ||
} | ||
} |
Oops, something went wrong.