0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 03:52:15 +02:00
Anki-Android/api
David Allison ff72a861be ci: debug identifier -> 'com.ichi2.anki.debug'
Since we're moving to scoped storage, uninstalling the app will very likely
delete user data.

In Debug/Dev, we want this to impact the dev's workflow as little as possible
So we change the applicationId. This relays the expectation that a 'stable'
anki should be using 'com.ichi2.anki' and an 'unstable/dev' AnkiDroid should be
'com.ichi2.anki.debug'. A developer should have two copies of the app, each with
their own storage location.

API:

As previously, define the API permissions/authority using the applicationId:
permission: 'com.ichi2.anki.debug.permission'
authority: 'com.ichi2.anki.debug.flashcards'

androidTest needs to access 'com.ichi2.anki.debug.flashcards' and have
'com.ichi2.anki.debug.permission'.

To resolve this, if the API is built in debug mode, the constants are modified:

(api/build.gradle)
* AUTHORITY = "com.ichi2.anki.debug.flashcards"
* READ_WRITE_PERMISSION = "com.ichi2.anki.debug.permission.READ_WRITE_DATABASE"

Implementation:

High level:
* Define variables in build.gradle
* Handle modifying them via parallel-package-name.sh

Low level:
* Use 'applicationIdSuffix' for this

* Modifies '<provider android:authorities>' in AndroidManifest.xml
  * Required for installation on device
  * Use 'applicationId'
* Modifies '<permission android:name' in AndroidManifest.xml
  * Not required - cleanup on parallel-package-name.sh
* Modifies preferences_sync.xml
  * via resValue in build.gradle
  * Fixes crash

Source for both: https://developer.android.com/studio/build/build-variants#build-types

applicationIdSuffix:
https://developer.android.com/reference/tools/gradle-api/7.3/com/android/build/api/dsl/ApplicationVariantDimension#applicationIdSuffix()

@string/applicationId
* syntax ref: https://stackoverflow.com/questions/27954215/changing-resvalue-in-variant

manifestPlaceholders/${applicationId}
https://developer.android.com/studio/build/manage-manifests

Learning:
> By default, the build tools also provide your app's application ID in the ${applicationId} placeholder. The value always matches the final application ID for the current build, including changes by build variants. This is useful when you want to use a unique namespace for identifiers such as an intent action, even between your build variants.

https://developer.android.com/studio/build/manage-manifests
2023-01-14 12:15:12 +02:00
..
src ci: debug identifier -> 'com.ichi2.anki.debug' 2023-01-14 12:15:12 +02:00
.gitignore Create API for easier integration with 3rd party apps 2015-09-11 05:08:18 +09:00
build.gradle ci: debug identifier -> 'com.ichi2.anki.debug' 2023-01-14 12:15:12 +02:00
COPYING.LESSER Create API for easier integration with 3rd party apps 2015-09-11 05:08:18 +09:00