├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap │ │ │ └── ic_launcher.png │ │ ├── drawable │ │ │ └── ic_add_white_24dp.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── styles.xml │ │ │ └── strings.xml │ │ ├── menu │ │ │ └── menu_main.xml │ │ └── layout │ │ │ ├── fragment_definition.xml │ │ │ ├── fragment_image.xml │ │ │ ├── simple_list_item_multiple_choice_left.xml │ │ │ ├── activity_card.xml │ │ │ └── activity_main.xml │ │ ├── java │ │ └── in │ │ │ └── rab │ │ │ └── bildkort │ │ │ ├── Utils.java │ │ │ ├── Model.java │ │ │ ├── DefinitionFragment.java │ │ │ ├── MainActivity.java │ │ │ ├── ImageFragment.java │ │ │ ├── CardActivity.java │ │ │ └── SentenceFragment.java │ │ ├── assets │ │ ├── model.question.html │ │ └── imagepicker.js │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── screenshots ├── images.png └── sentences.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /screenshots/images.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vitkyrka/bildkortsappen/HEAD/screenshots/images.png -------------------------------------------------------------------------------- /screenshots/sentences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vitkyrka/bildkortsappen/HEAD/screenshots/sentences.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vitkyrka/bildkortsappen/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vitkyrka/bildkortsappen/HEAD/app/src/main/res/mipmap/ic_launcher.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vitkyrka/bildkortsappen/HEAD/app/src/main/res/drawable/ic_add_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 180dp 3 | 16dp 4 | 5 | 16dp 6 | 16dp 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ' + 44 | ''; 45 | var els = document.getElementsByTagName('img'); 46 | var onclick = "toggleSelected(this);"; 47 | 48 | for (i = 0; i < els.length; i++) { 49 | var src = ''; 50 | 51 | if (i == 0) { 52 | continue; 53 | } 54 | 55 | src = els[i].src; 56 | if (src == '') { 57 | src = els[i].dataset.src; 58 | } 59 | 60 | if (!src) { 61 | continue; 62 | } 63 | 64 | /* 65 | * Change images pointing to the various encrypted-tbn[0-9].gstatic.com 66 | * servers to point to the local one encrypted-tbn0.gstatic.com, to get 67 | * around the canvas cross-origin restrictions in toDataURL. 68 | */ 69 | src = src.replace(/^http.*\.com/, ''); 70 | 71 | if (src && (src.substr(0, 5) == 'data:' || src.indexOf('tbn:') != -1)) { 72 | html += ''; 73 | } 74 | } 75 | 76 | wcm.pushPickerHtml(html); 77 | }; 78 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/in/rab/bildkort/DefinitionFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Rabin Vincent 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.rab.bildkort; 18 | 19 | import android.os.Bundle; 20 | import android.support.annotation.Nullable; 21 | import android.support.v4.app.Fragment; 22 | import android.view.LayoutInflater; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | import android.webkit.WebView; 26 | import android.widget.EditText; 27 | 28 | 29 | public class DefinitionFragment extends Fragment { 30 | private EditText mEditText; 31 | 32 | public DefinitionFragment() { 33 | } 34 | 35 | public static DefinitionFragment newInstance(String definition, Boolean isHtml) { 36 | DefinitionFragment fragment = new DefinitionFragment(); 37 | Bundle args = new Bundle(); 38 | args.putString("definition", definition); 39 | args.putBoolean("isHtml", isHtml); 40 | fragment.setArguments(args); 41 | return fragment; 42 | } 43 | 44 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 45 | super.onActivityCreated(savedInstanceState); 46 | 47 | String definition = getArguments().getString("definition"); 48 | Boolean isHtml = getArguments().getBoolean("isHtml"); 49 | 50 | mEditText = (EditText) getView().findViewById(R.id.editText); 51 | WebView webView = (WebView) getView().findViewById(R.id.webView); 52 | 53 | if (isHtml) { 54 | // Anki centers text by default, which is not optimal for large HTML 55 | // chunks such as those we get from NE. 56 | definition = "
" + definition + "
"; 57 | 58 | mEditText.setVisibility(View.GONE); 59 | webView.setVisibility(View.VISIBLE); 60 | } else { 61 | mEditText.setVisibility(View.VISIBLE); 62 | webView.setVisibility(View.GONE); 63 | } 64 | 65 | mEditText.setText(definition); 66 | webView.loadDataWithBaseURL("http://fake", definition, "text/html", "UTF-8", null); 67 | } 68 | 69 | @Override 70 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 71 | Bundle savedInstanceState) { 72 | return inflater.inflate(R.layout.fragment_definition, container, false); 73 | } 74 | 75 | public String getText() { 76 | return mEditText.getText().toString(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/in/rab/bildkort/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Rabin Vincent 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package in.rab.bildkort; 18 | 19 | import android.content.Intent; 20 | import android.os.Bundle; 21 | import android.support.v7.app.AppCompatActivity; 22 | import android.support.v7.widget.Toolbar; 23 | import android.view.View; 24 | import android.widget.ArrayAdapter; 25 | import android.widget.Button; 26 | import android.widget.EditText; 27 | import android.widget.Spinner; 28 | 29 | public class MainActivity extends AppCompatActivity { 30 | private class PosItem { 31 | private String mName; 32 | private String mId; 33 | 34 | public PosItem(int resource, String id) { 35 | mName = getString(resource); 36 | mId = id; 37 | } 38 | 39 | public String getId() { 40 | return mId; 41 | } 42 | 43 | public String toString() { 44 | return mName; 45 | } 46 | } 47 | 48 | @Override 49 | protected void onCreate(Bundle savedInstanceState) { 50 | super.onCreate(savedInstanceState); 51 | setContentView(R.layout.activity_main); 52 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 53 | setSupportActionBar(toolbar); 54 | 55 | final EditText wordEdit = (EditText) findViewById(R.id.wordEdit); 56 | final Spinner posSpinner = (Spinner) findViewById(R.id.posSpinner); 57 | 58 | PosItem[] array = { 59 | new PosItem(R.string.pos_unknown, SentenceFragment.POS_UNKNOWN), 60 | new PosItem(R.string.pos_noun, SentenceFragment.POS_NOUN), 61 | new PosItem(R.string.pos_adjective, SentenceFragment.POS_ADJECTIVE), 62 | new PosItem(R.string.pos_verb, SentenceFragment.POS_VERB), 63 | new PosItem(R.string.pos_preposition, SentenceFragment.POS_PREPOSITION), 64 | new PosItem(R.string.pos_none, SentenceFragment.POS_NONE), 65 | }; 66 | 67 | ArrayAdapter adapter = new ArrayAdapter(this, 68 | android.R.layout.simple_spinner_item, array); 69 | 70 | adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 71 | posSpinner.setAdapter(adapter); 72 | 73 | Button button = (Button) findViewById(R.id.button); 74 | button.setOnClickListener(new View.OnClickListener() { 75 | @Override 76 | public void onClick(View v) { 77 | Intent intent = new Intent(MainActivity.this, CardActivity.class); 78 | PosItem posItem = (PosItem) posSpinner.getSelectedItem(); 79 | 80 | intent.putExtra(Intent.EXTRA_SUBJECT, wordEdit.getText().toString()); 81 | intent.putExtra("in.rab.extra.pos", posItem.getId()); 82 | startActivity(intent); 83 | } 84 | }); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 22 | 23 | 24 | 25 | 37 | 38 | 44 | 45 | 51 | 52 | 57 | 58 | 64 | 65 | 70 | 71 |