├── settings.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── app
├── src
│ └── main
│ │ ├── res
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-hdpi
│ │ │ └── ic_share_white_24dp.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_share_white_24dp.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_share_white_24dp.png
│ │ ├── drawable-xxhdpi
│ │ │ └── ic_share_white_24dp.png
│ │ ├── drawable-xxxhdpi
│ │ │ └── ic_share_white_24dp.png
│ │ ├── values
│ │ │ ├── dimens.xml
│ │ │ └── strings.xml
│ │ ├── menu
│ │ │ ├── main_menu.xml
│ │ │ └── action_mode_menu.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── layout
│ │ │ ├── activity_main.xml
│ │ │ └── word_layout.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── ichi2
│ │ └── apisample
│ │ ├── AnkiDroidConfig.java
│ │ ├── AnkiDroidHelper.java
│ │ └── MainActivity.java
└── build.gradle
├── README.md
├── .gitignore
├── AnkiDroid_Sync.prf.xml
├── gradlew.bat
├── gradlew
└── LICENSE
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | android.enableJetifier=true
2 | android.useAndroidX=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/app/src/main/res/drawable-hdpi/ic_share_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/app/src/main/res/drawable-mdpi/ic_share_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ankidroid/apisample/HEAD/app/src/main/res/drawable-xxxhdpi/ic_share_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # apisample
2 | Sample project for the AnkiDroid API.
3 |
4 | Developers should see [the Wiki](https://github.com/ankidroid/Anki-Android/wiki/AnkiDroid-API) for info on how to use the API.
5 |
6 | Users can install the app by getting an APK from [the release section](https://github.com/ankidroid/apisample/releases) to see the API in action.
7 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/action_mode_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | API sample
3 | Share
4 | Instant-Add
5 | Other apps
6 | Settings
7 | %d items selected
8 | %d items added to AnkiDroid
9 | Error adding cards to AnkiDroid
10 | Couldn\'t get permission to access the AnkiDroid database
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # built native files
12 | *.o
13 | *.so
14 |
15 | # generated files
16 | bin/
17 | gen/
18 |
19 | # Ignore gradle files
20 | .gradle/
21 | build/
22 |
23 | # Local configuration file (sdk path, etc)
24 | local.properties
25 |
26 | # Proguard folder generated by Eclipse
27 | proguard/
28 |
29 | # Eclipse Metadata
30 | .metadata/
31 |
32 | # Mac OS X clutter
33 | *.DS_Store
34 |
35 | # Windows clutter
36 | Thumbs.db
37 |
38 | # Ubunut gedit cluter
39 | *~
40 |
41 | # Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067)
42 | .idea/*
43 |
44 | # Additionally ignore project files themselves so developers can choose their root directory name freely
45 | .idea/modules.xml
46 | *.iml
47 |
48 | # Crowdin files
49 | ankidroid.zip
50 | tools/crowdin_key.txt
51 |
52 | .idea/misc.xml
53 |
54 | .idea/vcs.xml
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/word_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
17 |
23 |
--------------------------------------------------------------------------------
/AnkiDroid_Sync.prf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1446713011681
4 | 1446713143626
5 | 9
6 | 4
7 | AnkiDroid Sync
8 |
9 | 599
10 | android.intent.action.ACTION_POWER_CONNECTED
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | 1445006914290
19 | 1445022789689
20 | 4
21 | AnkiDroid Sync
22 | 100
23 |
24 | 877
25 | com.ichi2.anki.DO_SYNC
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | def homePath = System.properties['user.home']
3 |
4 | android {
5 | namespace = 'com.ichi2.apisample'
6 | compileSdkVersion 35
7 | buildToolsVersion "35.0.0"
8 |
9 | defaultConfig {
10 | applicationId "com.ichi2.apisample"
11 | minSdkVersion 21
12 | targetSdkVersion 33
13 | versionCode 2
14 | versionName "1.0.1"
15 | }
16 | compileOptions {
17 | sourceCompatibility JavaVersion.VERSION_11
18 | targetCompatibility JavaVersion.VERSION_11
19 | }
20 | signingConfigs {
21 | release {
22 | storeFile file("${homePath}/src/android-keystore")
23 | keyAlias "nrkeystorealias"
24 | storePassword "ENTER_PASSWORD"
25 | keyPassword "ENTER_PASSWORD"
26 | }
27 | }
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
32 | signingConfig = signingConfigs.release
33 | }
34 | }
35 | }
36 |
37 | dependencies {
38 | implementation fileTree(dir: 'libs', include: ['*.jar'])
39 | implementation 'androidx.appcompat:appcompat:1.7.1'
40 | implementation 'com.github.ankidroid:Anki-Android:api-v1.1.0'
41 | }
42 |
43 | configurations.all {
44 | resolutionStrategy {
45 | force 'org.jetbrains.kotlin:kotlin-stdlib:1.8.22'
46 | force 'org.jetbrains.kotlin:kotlin-stdlib-common:1.8.22'
47 | // Exclude the old jdk7/jdk8 variants
48 | exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
49 | exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ichi2/apisample/AnkiDroidConfig.java:
--------------------------------------------------------------------------------
1 | package com.ichi2.apisample;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collections;
5 | import java.util.HashMap;
6 | import java.util.HashSet;
7 | import java.util.List;
8 | import java.util.Map;
9 | import java.util.Set;
10 |
11 | /** Some fields to store configuration details for AnkiDroid **/
12 | final class AnkiDroidConfig {
13 | // Name of deck which will be created in AnkiDroid
14 | public static final String DECK_NAME = "API Sample";
15 | // Name of model which will be created in AnkiDroid
16 | public static final String MODEL_NAME = "com.ichi2.apisample";
17 | // Optional space separated list of tags to add to every note
18 | public static final Set TAGS = new HashSet<>(Collections.singletonList("API_Sample_App"));
19 | // List of field names that will be used in AnkiDroid model
20 | public static final String[] FIELDS = {"Expression","Reading","Meaning","Furigana","Grammar","Sentence",
21 | "SentenceFurigana","SentenceMeaning"};
22 | // List of card names that will be used in AnkiDroid (one for each direction of learning)
23 | public static final String[] CARD_NAMES = {"Japanese>English", "English>Japanese"};
24 | // CSS to share between all the cards (optional). User will need to install the NotoSans font by themselves
25 | public static final String CSS = ".card {\n" +
26 | " font-family: NotoSansJP;\n" +
27 | " font-size: 24px;\n" +
28 | " text-align: center;\n" +
29 | " color: black;\n" +
30 | " background-color: white;\n" +
31 | " word-wrap: break-word;\n" +
32 | "}\n" +
33 | "@font-face { font-family: \"NotoSansJP\"; src: url('_NotoSansJP-Regular.otf'); }\n" +
34 | "@font-face { font-family: \"NotoSansJP\"; src: url('_NotoSansJP-Bold.otf'); font-weight: bold; }\n" +
35 | "\n" +
36 | ".big { font-size: 48px; }\n" +
37 | ".small { font-size: 18px;}\n";
38 | // Template for the question of each card
39 | static final String QFMT1 = "{{Expression}}
{{Grammar}}";
40 | static final String QFMT2 = "{{Meaning}}
{{Grammar}}
({{SentenceMeaning}})
";
41 | public static final String[] QFMT = {QFMT1, QFMT2};
42 | // Template for the answer (use identical for both sides)
43 | static final String AFMT1 = "{{furigana:Furigana}}
{{Meaning}}\n" +
44 | "
\n" +
45 | "{{furigana:SentenceFurigana}}
\n" +
46 | "Sentence Translation\n" +
47 | "{{SentenceMeaning}}
\n" +
48 | "
\n" +
49 | "{{Grammar}}
{{Tags}}
";
50 | public static final String[] AFMT = {AFMT1, AFMT1};
51 | // Define two keys which will be used when using legacy ACTION_SEND intent
52 | public static final String FRONT_SIDE_KEY = FIELDS[0];
53 | public static final String BACK_SIDE_KEY = FIELDS[2];
54 |
55 | /**
56 | * Generate the ArrayList example data which will be sent to AnkiDroid
57 | */
58 | public static List