├── .idea ├── .name ├── .gitignore ├── compiler.xml ├── vcs.xml ├── misc.xml └── gradle.xml ├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── values │ │ │ │ ├── preloaded_fonts.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── strings.xml │ │ │ │ ├── themes.xml │ │ │ │ └── font_certs.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── anim │ │ │ │ ├── shake_animation.xml │ │ │ │ └── random_animation.xml │ │ │ ├── font │ │ │ │ └── alata.xml │ │ │ ├── xml │ │ │ │ ├── backup_rules.xml │ │ │ │ └── data_extraction_rules.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── basictrivia │ │ │ │ ├── data │ │ │ │ ├── AnswerListAsyncResponse.java │ │ │ │ └── Repository.java │ │ │ │ ├── model │ │ │ │ └── Questions.java │ │ │ │ ├── controller │ │ │ │ └── AppController.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── basictrivia │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── example │ │ └── basictrivia │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── gradle.properties ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | Basic Trivia -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanzalahwaheed/basic-trivia-application/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/preloaded_fonts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @font/alata 5 | 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Dec 02 23:34:06 IST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/basictrivia/data/AnswerListAsyncResponse.java: -------------------------------------------------------------------------------- 1 | package com.example.basictrivia.data; 2 | 3 | import com.example.basictrivia.model.Questions; 4 | 5 | import java.util.ArrayList; 6 | 7 | public interface AnswerListAsyncResponse { 8 | void processFinished(ArrayList questionsArrayList); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/anim/shake_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/font/alata.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "Basic Trivia" 16 | include ':app' 17 | -------------------------------------------------------------------------------- /app/src/main/res/anim/random_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #1C0D32 4 | #271849 5 | #1C0D32 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 14 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/basictrivia/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.basictrivia; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Basic Trivia 3 | Basic Trivia 4 | TRUE 5 | FALSE 6 | NEXT 7 | PREVIOUS 8 | Hello World! This is where we add our Questions! 9 | Correct Answer! 10 | Incorrect Answer! 11 | Question: 1/914 12 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/basictrivia/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.basictrivia; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.example.basictrivia", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/basictrivia/model/Questions.java: -------------------------------------------------------------------------------- 1 | package com.example.basictrivia.model; 2 | 3 | public class Questions { 4 | private String answer; 5 | private boolean answerTrue; 6 | 7 | public Questions() {} 8 | public Questions(String answer, boolean answerTrue) { 9 | this.answer = answer; 10 | this.answerTrue = answerTrue; 11 | } 12 | 13 | public String getAnswer() { 14 | return answer; 15 | } 16 | 17 | public void setAnswer(String answer) { 18 | this.answer = answer; 19 | } 20 | 21 | public boolean isAnswerTrue() { 22 | return answerTrue; 23 | } 24 | 25 | public void setAnswerTrue(boolean answerTrue) { 26 | this.answerTrue = answerTrue; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "Questions{" + 32 | "answer='" + answer + '\'' + 33 | ", answerTrue=" + answerTrue + 34 | '}'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/basictrivia/controller/AppController.java: -------------------------------------------------------------------------------- 1 | package com.example.basictrivia.controller; 2 | 3 | import android.app.Application; 4 | 5 | import com.android.volley.Request; 6 | import com.android.volley.RequestQueue; 7 | import com.android.volley.toolbox.Volley; 8 | 9 | public class AppController extends Application { 10 | private static AppController instance; 11 | private RequestQueue requestQueue; 12 | public static synchronized AppController getInstance() { 13 | return instance; 14 | } 15 | public RequestQueue getRequestQueue() { 16 | if (requestQueue == null) { 17 | requestQueue = Volley.newRequestQueue(getApplicationContext()); 18 | } 19 | return requestQueue; 20 | } 21 | public void addToRequestQueue(Request req) { 22 | getRequestQueue().add(req); 23 | } 24 | @Override 25 | public void onCreate() { 26 | super.onCreate(); 27 | instance = this; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdk 32 7 | 8 | defaultConfig { 9 | applicationId "com.example.basictrivia" 10 | minSdk 24 11 | targetSdk 32 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | } 17 | buildFeatures { 18 | dataBinding true 19 | } 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_8 28 | targetCompatibility JavaVersion.VERSION_1_8 29 | } 30 | } 31 | 32 | dependencies { 33 | 34 | implementation 'androidx.appcompat:appcompat:1.5.1' 35 | implementation 'com.google.android.material:material:1.7.0' 36 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 37 | implementation 'com.android.volley:volley:1.2.1' 38 | testImplementation 'junit:junit:4.13.2' 39 | androidTestImplementation 'androidx.test.ext:junit:1.1.4' 40 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' 41 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/basictrivia/data/Repository.java: -------------------------------------------------------------------------------- 1 | package com.example.basictrivia.data; 2 | 3 | import android.util.Log; 4 | 5 | import com.android.volley.Request; 6 | import com.android.volley.toolbox.JsonArrayRequest; 7 | import com.example.basictrivia.controller.AppController; 8 | import com.example.basictrivia.model.Questions; 9 | 10 | import org.json.JSONException; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | public class Repository { 16 | ArrayList questionsArrayList = new ArrayList<>(); 17 | 18 | String url = "https://raw.githubusercontent.com/curiousily/simple-quiz/master/script/statements-data.json"; 19 | 20 | public List getQuestions(AnswerListAsyncResponse callBack) { 21 | JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, url, null, 22 | response -> { 23 | for (int i = 0; i < response.length(); i++) { 24 | try { 25 | Questions questions = new Questions(response.getJSONArray(i).getString(0), 26 | response.getJSONArray(i).getBoolean(1)); 27 | questionsArrayList.add(questions); 28 | } catch (JSONException e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | if(null != callBack){ 33 | callBack.processFinished(questionsArrayList); 34 | 35 | } 36 | }, error -> { 37 | Log.d("MAIN", "getQuestions: Failed to Import!"); 38 | }); 39 | AppController.getInstance().addToRequestQueue(jsonArrayRequest); 40 | return questionsArrayList; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /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 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /app/src/main/res/values/font_certs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @array/com_google_android_gms_fonts_certs_dev 5 | @array/com_google_android_gms_fonts_certs_prod 6 | 7 | 8 | 9 | MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550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yl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/basictrivia/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.basictrivia; 2 | 3 | import android.graphics.Color; 4 | import android.graphics.drawable.Animatable; 5 | import android.os.Bundle; 6 | import android.view.animation.Animation; 7 | import android.view.animation.AnimationUtils; 8 | 9 | import androidx.appcompat.app.AppCompatActivity; 10 | import androidx.databinding.DataBindingUtil; 11 | 12 | import com.example.basictrivia.data.Repository; 13 | import com.example.basictrivia.databinding.ActivityMainBinding; 14 | import com.example.basictrivia.model.Questions; 15 | import com.google.android.material.snackbar.Snackbar; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | public class MainActivity extends AppCompatActivity { 21 | List questionsList; 22 | private ActivityMainBinding binding; 23 | private int currentQuestionIndex = 0; 24 | 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_main); 29 | binding = DataBindingUtil.setContentView(this, R.layout.activity_main); 30 | 31 | questionsList = new Repository().getQuestions(questionsArrayList -> { 32 | binding.textViewQuestion.setText(questionsArrayList.get(currentQuestionIndex).getAnswer()); 33 | updateCounter(questionsArrayList); 34 | }); 35 | 36 | binding.buttonNext.setOnClickListener(v -> { 37 | currentQuestionIndex = (currentQuestionIndex + 1) % questionsList.size(); 38 | updateQuestion(); 39 | }); 40 | binding.buttonPrevious.setOnClickListener(v -> { 41 | if (currentQuestionIndex == 0) { 42 | currentQuestionIndex = questionsList.size(); 43 | } else { 44 | currentQuestionIndex = (currentQuestionIndex - 1) % questionsList.size(); 45 | updateQuestion(); 46 | } 47 | 48 | }); 49 | binding.buttonTrue.setOnClickListener(v -> { 50 | checkAnswer(true); 51 | updateQuestion(); 52 | }); 53 | binding.buttonFalse.setOnClickListener(v -> { 54 | checkAnswer(false); 55 | updateQuestion(); 56 | }); 57 | } 58 | 59 | private void checkAnswer(boolean userChoseCorrect) { 60 | boolean answer = questionsList.get(currentQuestionIndex).isAnswerTrue(); 61 | int snackMessage = 0; 62 | if (userChoseCorrect == answer) { 63 | snackMessage = R.string.correct_answer; 64 | randomAnimation(); 65 | } else { 66 | snackMessage = R.string.incorrect_answer; 67 | shakeAnimation(); 68 | } 69 | Snackbar.make(binding.cardView, snackMessage, Snackbar.LENGTH_SHORT).show(); 70 | } 71 | 72 | private void updateCounter(ArrayList questionsArrayList) { 73 | binding.textViewOutOf.setText("Question: " + (currentQuestionIndex + 1) + "/" + (questionsArrayList.size() + 1)); 74 | } 75 | 76 | private void updateQuestion() { 77 | String question = questionsList.get(currentQuestionIndex).getAnswer(); 78 | binding.textViewQuestion.setText(question); 79 | updateCounter((ArrayList) questionsList); 80 | } 81 | 82 | private void shakeAnimation(){ 83 | Animation shake = AnimationUtils.loadAnimation(MainActivity.this, 84 | R.anim.shake_animation); 85 | binding.cardView.setAnimation(shake); 86 | shake.setAnimationListener(new Animation.AnimationListener() { 87 | @Override 88 | public void onAnimationStart(Animation animation) { 89 | binding.textViewQuestion.setTextColor(Color.RED); 90 | } 91 | 92 | @Override 93 | public void onAnimationEnd(Animation animation) { 94 | binding.textViewQuestion.setTextColor(Color.WHITE); 95 | } 96 | 97 | @Override 98 | public void onAnimationRepeat(Animation animation) { 99 | 100 | } 101 | }); 102 | } 103 | 104 | private void randomAnimation(){ 105 | Animation shake = AnimationUtils.loadAnimation(MainActivity.this, 106 | R.anim.random_animation); 107 | binding.cardView.setAnimation(shake); 108 | shake.setAnimationListener(new Animation.AnimationListener() { 109 | @Override 110 | public void onAnimationStart(Animation animation) { 111 | binding.textViewQuestion.setTextColor(Color.GREEN); 112 | } 113 | 114 | @Override 115 | public void onAnimationEnd(Animation animation) { 116 | binding.textViewQuestion.setTextColor(Color.WHITE); 117 | } 118 | 119 | @Override 120 | public void onAnimationRepeat(Animation animation) { 121 | 122 | } 123 | }); 124 | } 125 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 27 | 28 | 40 | 41 | 54 | 55 | 63 | 64 | 65 |