├── LICENSE
├── README.md
├── app
├── build.gradle
├── proguard-rules.pro
├── release
│ ├── app-release.apk
│ └── output-metadata.json
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── sagarkhurana
│ │ └── quizforfun
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── sagarkhurana
│ │ │ └── quizforfun
│ │ │ ├── EditPasswordActivity.java
│ │ │ ├── FinalResultActivity.java
│ │ │ ├── GeographyOrLiteratureQuizActivity.java
│ │ │ ├── HistoryActivity.java
│ │ │ ├── LoginActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── MathQuizActivity.java
│ │ │ ├── QuizOptionActivity.java
│ │ │ ├── RegisterActivity.java
│ │ │ ├── RuleActivity.java
│ │ │ ├── adapter
│ │ │ ├── HistoryAdapter.java
│ │ │ └── RulesViewPagerAdapter.java
│ │ │ ├── data
│ │ │ ├── Attempt.java
│ │ │ ├── User.java
│ │ │ ├── UserDao.java
│ │ │ ├── UserDatabase.java
│ │ │ ├── UserDatabaseClient.java
│ │ │ └── UserWithAttempts.java
│ │ │ └── other
│ │ │ ├── Constants.java
│ │ │ ├── Convertor.java
│ │ │ ├── SharedPref.java
│ │ │ └── Utils.java
│ └── res
│ │ ├── drawable-v24
│ │ ├── ic_launcher_foreground.xml
│ │ └── question1.gif
│ │ ├── drawable
│ │ ├── arrow.xml
│ │ ├── blackboard.xml
│ │ ├── book.xml
│ │ ├── correct.gif
│ │ ├── history.xml
│ │ ├── home_bg.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── icon.xml
│ │ ├── incorrect.gif
│ │ ├── keys.xml
│ │ ├── logout.xml
│ │ ├── noted.gif
│ │ ├── quiz.xml
│ │ ├── rules.xml
│ │ ├── selected.xml
│ │ ├── splash_image.xml
│ │ ├── unselected.xml
│ │ └── worldwide.xml
│ │ ├── layout
│ │ ├── activity_edit_password.xml
│ │ ├── activity_final_result.xml
│ │ ├── activity_geography_or_literature_quiz.xml
│ │ ├── activity_history.xml
│ │ ├── activity_login.xml
│ │ ├── activity_main.xml
│ │ ├── activity_math_quiz.xml
│ │ ├── activity_quiz_option.xml
│ │ ├── activity_register.xml
│ │ ├── activity_rule.xml
│ │ ├── item_history.xml
│ │ └── slide_rules.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimen.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── sagarkhurana
│ └── quizforfun
│ └── ExampleUnitTest.java
├── build.gradle
├── build
└── intermediates
│ └── lint-cache
│ ├── maven.google
│ ├── androidx
│ │ ├── appcompat
│ │ │ └── group-index.xml
│ │ ├── constraintlayout
│ │ │ └── group-index.xml
│ │ ├── room
│ │ │ └── group-index.xml
│ │ └── test
│ │ │ ├── espresso
│ │ │ └── group-index.xml
│ │ │ └── ext
│ │ │ └── group-index.xml
│ ├── com
│ │ └── google
│ │ │ └── android
│ │ │ └── material
│ │ │ └── group-index.xml
│ └── master-index.xml
│ └── sdk-registry.xml
│ └── sdk-registry.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
├── screenshots
├── 0.png
├── 1.png
├── 10.png
├── 2.png
├── 3.png
├── 4.png
├── 5.png
├── 6.png
├── 7.png
├── 8.png
├── 9.png
└── qrCodeForApk.png
└── settings.gradle
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Sagar Khurana
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Quiz App
2 | A Quiz Android application 📱 built using Java ♨️ and showing best practices of 🛠️ Room
3 | -------------------
4 |
5 | ## ❤️ Try App
6 | ## Scan QR Code
7 |
9 | ---------------
10 | ### Get Apk [Download here](https://raw.githubusercontent.com/pikachu404/Quiz-App/master/app/release/app-release.apk)
11 | ------------
12 | ## ⚙️ Features
13 | * App consists of Quiz of primarily three subject - Maths, Geography, Literature
14 | * Maintaining history of previous attempts of quiz using Room.
15 | * You can switch users using the Login/Register
16 | * Feature to change to your current password
17 | * Added loader while data is being fetched from API
18 | * Showing the result at the end the Quiz.
19 | * Implemented login, register,edit password, previous attempts all using SQL Lite DB using Room
20 |
21 | ## 🚀 Technology Used
22 |
23 | * Quiz App is build using Java
24 | * Asynctask for asynchronous
25 | * Room Persistence Library
26 |
27 | ## 📸 Screenshots
28 |
29 | ||||
30 | |:----------------------------------------:|:-----------------------------------------:|:-----------------------------------------: |
31 | |  |  |  |
32 | |  |  |  |
33 | |  |  |  |
34 | |  |  |  |
35 |
36 | ## ⚡ Dependencies Used
37 | ```sh
38 | * Room Persistence Library 2.2.5
39 | * Gson 2.8.6
40 | ```
41 |
42 | ## License
43 | ```
44 | MIT License
45 |
46 | Copyright (c) 2021 Sagar Khurana
47 |
48 | Permission is hereby granted, free of charge, to any person obtaining a copy
49 | of this software and associated documentation files (the "Software"), to deal
50 | in the Software without restriction, including without limitation the rights
51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52 | copies of the Software, and to permit persons to whom the Software is
53 | furnished to do so, subject to the following conditions:
54 |
55 | The above copyright notice and this permission notice shall be included in all
56 | copies or substantial portions of the Software.
57 |
58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
64 | SOFTWARE.
65 | ```
66 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | compileSdkVersion 30
7 | buildToolsVersion "30.0.2"
8 |
9 | defaultConfig {
10 | applicationId "com.sagarkhurana.quizforfun"
11 | minSdkVersion 21
12 | targetSdkVersion 30
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_1_8
27 | targetCompatibility JavaVersion.VERSION_1_8
28 | }
29 | }
30 |
31 | dependencies {
32 |
33 | implementation 'androidx.appcompat:appcompat:1.2.0'
34 | implementation 'com.google.android.material:material:1.2.1'
35 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
36 | implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
37 | testImplementation 'junit:junit:4.+'
38 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
39 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
40 |
41 | // Room
42 | def room_version = "2.2.5"
43 | implementation "androidx.room:room-runtime:$room_version"
44 | annotationProcessor "androidx.room:room-compiler:$room_version"
45 |
46 | // Gson
47 | implementation 'com.google.code.gson:gson:2.8.6'
48 |
49 | //View Pager Dots Indicator
50 | //https://github.com/tommybuonomo/dotsindicator
51 | implementation 'com.tbuonomo:dotsindicator:4.2'
52 | }
--------------------------------------------------------------------------------
/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/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/release/output-metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "artifactType": {
4 | "type": "APK",
5 | "kind": "Directory"
6 | },
7 | "applicationId": "com.sagarkhurana.quizforfun",
8 | "variantName": "processReleaseResources",
9 | "elements": [
10 | {
11 | "type": "SINGLE",
12 | "filters": [],
13 | "versionCode": 1,
14 | "versionName": "1.0",
15 | "outputFile": "app-release.apk"
16 | }
17 | ]
18 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/sagarkhurana/quizforfun/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
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.sagarkhurana.quizforfun", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/EditPasswordActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.AsyncTask;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.Toast;
11 |
12 | import com.sagarkhurana.quizforfun.data.User;
13 | import com.sagarkhurana.quizforfun.data.UserDatabase;
14 | import com.sagarkhurana.quizforfun.data.UserDatabaseClient;
15 | import com.sagarkhurana.quizforfun.other.SharedPref;
16 |
17 | public class EditPasswordActivity extends AppCompatActivity {
18 |
19 | private EditText etOldPassword,etNewPassword,etConfirmNewPassword;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_edit_password);
25 |
26 | etOldPassword = findViewById(R.id.tietPassword);
27 | etNewPassword = findViewById(R.id.tietPasswordNewPass);
28 | etConfirmNewPassword = findViewById(R.id.tietPasswordConfirmNewPass);
29 | Button btnSavePassword = findViewById(R.id.btnChangePassword);
30 |
31 | findViewById(R.id.imageViewEditPassword).setOnClickListener(new View.OnClickListener() {
32 | @Override
33 | public void onClick(View view) {
34 | finish();
35 | }
36 | });
37 |
38 | btnSavePassword.setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View view) {
41 |
42 | String oldPassword = etOldPassword.getText().toString();
43 | String newPassword = etNewPassword.getText().toString();
44 | String confirmNewPassword = etConfirmNewPassword.getText().toString();
45 |
46 | if (!validateInput(oldPassword,newPassword,confirmNewPassword)) return;
47 |
48 | changePassword(oldPassword, newPassword);
49 | }
50 | });
51 |
52 |
53 | }
54 |
55 | private void changePassword(String oldPassword,String newPassword) {
56 |
57 | User user = SharedPref.getInstance().getUser(this);
58 | if (!user.getPassword().equals(oldPassword)){
59 | Toast.makeText(this, "Please enter the right password", Toast.LENGTH_SHORT).show();
60 | return;
61 | }
62 | user.setPassword(newPassword);
63 | UpdatePasswordTask updatePasswordTask = new UpdatePasswordTask(user);
64 | updatePasswordTask.execute();
65 |
66 | }
67 |
68 | private boolean validateInput(String oldPassword, String newPassword, String confirmNewPassword) {
69 |
70 | if (oldPassword.isEmpty()){
71 | Toast.makeText(this, getString(R.string.old_password_cannot_be_empty), Toast.LENGTH_SHORT).show();
72 | return false;
73 | }
74 |
75 | if (newPassword.isEmpty()){
76 | Toast.makeText(this, getString(R.string.old_password_cannot_be_empty), Toast.LENGTH_SHORT).show();
77 | return false;
78 | }
79 |
80 | if (confirmNewPassword.isEmpty()){
81 | Toast.makeText(this, getString(R.string.old_password_cannot_be_empty), Toast.LENGTH_SHORT).show();
82 | return false;
83 | }
84 |
85 | if (!confirmNewPassword.equals(newPassword)){
86 | Toast.makeText(this, getString(R.string.password_must_be_same), Toast.LENGTH_SHORT).show();
87 | return false;
88 | }
89 |
90 | if (oldPassword.equals(newPassword)){
91 | Toast.makeText(this, getString(R.string.new_password_must_be_different), Toast.LENGTH_SHORT).show();
92 | return false;
93 | }
94 |
95 | return true;
96 | }
97 |
98 | class UpdatePasswordTask extends AsyncTask {
99 |
100 | private final User user;
101 |
102 | public UpdatePasswordTask(User user) {
103 | this.user = user;
104 | }
105 |
106 | @Override
107 | protected Void doInBackground(Void... voids) {
108 | UserDatabase databaseClient = UserDatabaseClient.getInstance(getApplicationContext());
109 | databaseClient.userDao().updateUser(user);
110 | return null;
111 | }
112 |
113 | @Override
114 | protected void onPostExecute(Void aVoid) {
115 | super.onPostExecute(aVoid);
116 | Toast.makeText(EditPasswordActivity.this, "Password Updated Successfully!", Toast.LENGTH_SHORT).show();
117 | SharedPref.getInstance().setUser(EditPasswordActivity.this,user);
118 | finish();
119 | }
120 | }
121 |
122 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/FinalResultActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.os.AsyncTask;
7 | import android.os.Bundle;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.widget.TextView;
11 |
12 | import com.sagarkhurana.quizforfun.data.Attempt;
13 | import com.sagarkhurana.quizforfun.data.UserDatabase;
14 | import com.sagarkhurana.quizforfun.data.UserDatabaseClient;
15 | import com.sagarkhurana.quizforfun.other.Constants;
16 | import com.sagarkhurana.quizforfun.other.SharedPref;
17 | import com.sagarkhurana.quizforfun.other.Utils;
18 |
19 | import java.util.Calendar;
20 |
21 | public class FinalResultActivity extends AppCompatActivity {
22 |
23 | private TextView tvSubject, tvCorrect, tvIncorrect, tvEarned, tvOverallStatus, tvDate;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_final_result);
29 |
30 | Intent intent = getIntent();
31 | int correctAnswer = intent.getIntExtra(Constants.CORRECT, 0);
32 | int incorrectAnswer = intent.getIntExtra(Constants.INCORRECT, 0);
33 | String subject = intent.getStringExtra(Constants.SUBJECT);
34 | String email = SharedPref.getInstance().getUser(this).getEmail();
35 | int earnedPoints = (correctAnswer * Constants.CORRECT_POINT) - (incorrectAnswer * Constants.INCORRECT_POINT);
36 |
37 | tvSubject = findViewById(R.id.textView16);
38 | tvCorrect = findViewById(R.id.textView19);
39 | tvIncorrect = findViewById(R.id.textView27);
40 | tvEarned = findViewById(R.id.textView28);
41 | tvOverallStatus = findViewById(R.id.textView29);
42 | tvDate = findViewById(R.id.textView30);
43 |
44 | findViewById(R.id.imageViewFinalResultQuiz).setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View view) {
47 | Intent intent = new Intent(FinalResultActivity.this,MainActivity.class);
48 | startActivity(intent);
49 | finish();
50 | }
51 | });
52 |
53 | findViewById(R.id.btnFinishQuiz).setOnClickListener(new View.OnClickListener() {
54 | @Override
55 | public void onClick(View view) {
56 | Intent intent = new Intent(FinalResultActivity.this,MainActivity.class);
57 | startActivity(intent);
58 | finish();
59 | }
60 | });
61 |
62 | Attempt attempt = new Attempt(
63 | Calendar.getInstance().getTimeInMillis(),
64 | subject,
65 | correctAnswer,
66 | incorrectAnswer,
67 | earnedPoints,
68 | email
69 | );
70 |
71 | getOverAllPoints(attempt);
72 | }
73 |
74 | @Override
75 | public void onBackPressed() {
76 | super.onBackPressed();
77 | Intent intent = new Intent(this,MainActivity.class);
78 | startActivity(intent);
79 | finish();
80 | }
81 |
82 | private void getOverAllPoints(Attempt attempt) {
83 | GetOverallPointsTask getOverallPointsTask = new GetOverallPointsTask(attempt);
84 | getOverallPointsTask.execute();
85 | }
86 |
87 | class GetOverallPointsTask extends AsyncTask {
88 |
89 | private final Attempt attempt;
90 | private int overallPoints = 0;
91 |
92 | public GetOverallPointsTask(Attempt attempt) {
93 | this.attempt = attempt;
94 | }
95 |
96 | @Override
97 | protected Void doInBackground(Void... voids) {
98 | UserDatabase databaseClient = UserDatabaseClient.getInstance(getApplicationContext());
99 | overallPoints = databaseClient.userDao().getOverAllPoints(attempt.getEmail());
100 | return null;
101 | }
102 |
103 | @Override
104 | protected void onPostExecute(Void aVoid) {
105 | super.onPostExecute(aVoid);
106 |
107 | attempt.setOverallPoints(overallPoints + attempt.getEarned());
108 | displayData(attempt);
109 | SaveUserAttemptTask saveUserAttemptTask = new SaveUserAttemptTask(attempt);
110 | saveUserAttemptTask.execute();
111 |
112 | Log.d("OVERALL POINTS", String.valueOf(overallPoints));
113 | }
114 | }
115 |
116 | private void displayData(Attempt attempt) {
117 |
118 | tvSubject.setText(attempt.getSubject());
119 | tvCorrect.setText(String.valueOf(attempt.getCorrect()));
120 | tvIncorrect.setText(String.valueOf(attempt.getIncorrect()));
121 | tvEarned.setText(String.valueOf(attempt.getEarned()));
122 | tvOverallStatus.setText(String.valueOf(attempt.getOverallPoints()));
123 | tvDate.setText(Utils.formatDate(attempt.getCreatedTime()));
124 |
125 | }
126 |
127 | class SaveUserAttemptTask extends AsyncTask {
128 |
129 | private Attempt attempt;
130 |
131 | public SaveUserAttemptTask(Attempt attempt) {
132 | this.attempt = attempt;
133 | }
134 |
135 | @Override
136 | protected Void doInBackground(Void... voids) {
137 | UserDatabase databaseClient = UserDatabaseClient.getInstance(getApplicationContext());
138 | databaseClient.userDao().insertAttempt(attempt);
139 | return null;
140 | }
141 |
142 | @Override
143 | protected void onPostExecute(Void aVoid) {
144 | super.onPostExecute(aVoid);
145 | Log.d("Attempt Saved", attempt.toString());
146 | }
147 | }
148 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/GeographyOrLiteratureQuizActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.RadioButton;
10 | import android.widget.RadioGroup;
11 | import android.widget.TextView;
12 |
13 | import com.sagarkhurana.quizforfun.other.Constants;
14 | import com.sagarkhurana.quizforfun.other.Utils;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 | import java.util.Map;
19 |
20 | public class GeographyOrLiteratureQuizActivity extends AppCompatActivity {
21 |
22 | private int currentQuestionIndex = 0;
23 | private TextView tvQuestion, tvQuestionNumber;
24 | private Button btnNext;
25 | private RadioGroup radioGroup;
26 | private RadioButton radioButton1, radioButton2, radioButton3, radioButton4;
27 | private List questions;
28 | private int correctQuestion = 0;
29 | private Map> questionsAnswerMap;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_geography_or_literature_quiz);
35 |
36 | Intent intent = getIntent();
37 | String subject = intent.getStringExtra(Constants.SUBJECT);
38 |
39 | TextView tvTitle = findViewById(R.id.textView26);
40 |
41 | if (subject.equals(getString(R.string.literature))) {
42 | questionsAnswerMap = Utils.getRandomLiteratureAndGeographyQuestions(this,getString(R.string.literature),Constants.QUESTION_SHOWING);
43 | tvTitle.setText(getString(R.string.literature_quiz));
44 | }else{
45 | questionsAnswerMap = Utils.getRandomLiteratureAndGeographyQuestions(this,getString(R.string.geography),Constants.QUESTION_SHOWING);
46 | tvTitle.setText(getString(R.string.geography_quiz));
47 | }
48 | questions = new ArrayList<>(questionsAnswerMap.keySet());
49 |
50 |
51 | tvQuestion = findViewById(R.id.textView78);
52 | tvQuestionNumber = findViewById(R.id.textView18);
53 | btnNext = findViewById(R.id.btnNextQuestionLiteratureAndGeography);
54 | radioGroup = findViewById(R.id.radioGroup);
55 |
56 | radioButton1 = findViewById(R.id.radioButton1);
57 | radioButton2 = findViewById(R.id.radioButton2);
58 | radioButton3 = findViewById(R.id.radioButton3);
59 | radioButton4 = findViewById(R.id.radioButton4);
60 |
61 | findViewById(R.id.btnNextQuestionLiteratureAndGeography).setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View view) {
64 |
65 | RadioButton radioButton = findViewById(radioGroup.getCheckedRadioButtonId());
66 | boolean answer = questionsAnswerMap.get(questions.get(currentQuestionIndex)).get(radioButton.getText());
67 |
68 | if (answer){
69 | correctQuestion++;
70 | }
71 |
72 | currentQuestionIndex++;
73 |
74 | if (btnNext.getText().equals(getString(R.string.next))){
75 | displayNextQuestions();
76 | }else{
77 | Intent intentResult = new Intent(GeographyOrLiteratureQuizActivity.this,FinalResultActivity.class);
78 | intentResult.putExtra(Constants.SUBJECT,subject);
79 | intentResult.putExtra(Constants.CORRECT,correctQuestion);
80 | intentResult.putExtra(Constants.INCORRECT,Constants.QUESTION_SHOWING - correctQuestion);
81 | intentResult.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
82 | startActivity(intentResult);
83 | finish();
84 | }
85 |
86 | }
87 | });
88 |
89 | findViewById(R.id.imageViewStartQuizGeographyOrLiterature).setOnClickListener(new View.OnClickListener() {
90 | @Override
91 | public void onClick(View view) {
92 | finish();
93 | }
94 | });
95 |
96 | displayData();
97 | }
98 |
99 | private void displayNextQuestions() {
100 | setAnswersToRadioButton();
101 | tvQuestion.setText(questions.get(currentQuestionIndex));
102 | tvQuestionNumber.setText("Current Question: " + (currentQuestionIndex + 1));
103 |
104 | if (currentQuestionIndex == Constants.QUESTION_SHOWING - 1){
105 | btnNext.setText(getText(R.string.finish));
106 | }
107 | }
108 |
109 | private void displayData() {
110 | tvQuestion.setText(questions.get(currentQuestionIndex));
111 | tvQuestionNumber.setText("Current Question: " + (currentQuestionIndex + 1));
112 |
113 | setAnswersToRadioButton();
114 | }
115 |
116 | private void setAnswersToRadioButton(){
117 |
118 | ArrayList questionKey = new ArrayList(questionsAnswerMap.get(questions.get(currentQuestionIndex)).keySet());
119 |
120 | radioButton1.setText(questionKey.get(0));
121 | radioButton2.setText(questionKey.get(1));
122 | radioButton3.setText(questionKey.get(2));
123 | radioButton4.setText(questionKey.get(3));
124 |
125 | }
126 |
127 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/HistoryActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.recyclerview.widget.RecyclerView;
5 |
6 | import android.os.AsyncTask;
7 | import android.os.Bundle;
8 | import android.view.View;
9 | import android.widget.TextView;
10 |
11 | import com.sagarkhurana.quizforfun.adapter.HistoryAdapter;
12 | import com.sagarkhurana.quizforfun.data.Attempt;
13 | import com.sagarkhurana.quizforfun.data.UserDatabase;
14 | import com.sagarkhurana.quizforfun.data.UserDatabaseClient;
15 | import com.sagarkhurana.quizforfun.data.UserWithAttempts;
16 | import com.sagarkhurana.quizforfun.other.SharedPref;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Collections;
20 | import java.util.Comparator;
21 | import java.util.List;
22 |
23 | public class HistoryActivity extends AppCompatActivity {
24 |
25 | private RecyclerView rvHistory;
26 | private List userWithAttempts;
27 | private TextView tvTotalPoints, tvTotalQuestions;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_history);
33 |
34 | rvHistory = findViewById(R.id.rvHistory);
35 | tvTotalQuestions = findViewById(R.id.tvTotalQuestionsHistory);
36 | tvTotalPoints = findViewById(R.id.tvOverAllPointsHistory);
37 |
38 | findViewById(R.id.imageViewHistory).setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View view) {
41 | finish();
42 | }
43 | });
44 |
45 | String email = SharedPref.getInstance().getUser(this).getEmail();
46 | GetAllUserAttemptTask getAllUserAttemptTask = new GetAllUserAttemptTask(email);
47 | getAllUserAttemptTask.execute();
48 | }
49 |
50 |
51 | class GetAllUserAttemptTask extends AsyncTask {
52 |
53 | private final String email;
54 | ArrayList attempts = new ArrayList<>();
55 |
56 | public GetAllUserAttemptTask(String email) {
57 | this.email = email;
58 | }
59 |
60 | @Override
61 | protected Void doInBackground(Void... voids) {
62 | UserDatabase databaseClient = UserDatabaseClient.getInstance(getApplicationContext());
63 | attempts = (ArrayList) databaseClient.userDao().getUserAndAttemptsWithSameEmail(email);
64 | return null;
65 | }
66 |
67 | @Override
68 | protected void onPostExecute(Void aVoid) {
69 | super.onPostExecute(aVoid);
70 |
71 | int overallPoints = 0;
72 |
73 | for (Attempt userWithAttempts : attempts) {
74 | overallPoints += userWithAttempts.getEarned();
75 | }
76 |
77 | tvTotalQuestions.setText(String.valueOf(attempts.size()));
78 | tvTotalPoints.setText(String.valueOf(overallPoints));
79 |
80 | Collections.sort(attempts, new AttemptCreatedTimeComparator());
81 |
82 | HistoryAdapter adapter = new HistoryAdapter(attempts);
83 | rvHistory.setAdapter(adapter);
84 |
85 |
86 | }
87 | }
88 |
89 | public class AttemptCreatedTimeComparator implements Comparator {
90 |
91 | @Override
92 | public int compare(Attempt attempt, Attempt t1) {
93 | return String.valueOf(t1.getCreatedTime()).compareTo(String.valueOf(attempt.getCreatedTime()));
94 | }
95 | }
96 |
97 |
98 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.os.AsyncTask;
7 | import android.os.Bundle;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.TextView;
12 | import android.widget.Toast;
13 |
14 | import com.sagarkhurana.quizforfun.data.User;
15 | import com.sagarkhurana.quizforfun.data.UserDatabase;
16 | import com.sagarkhurana.quizforfun.data.UserDatabaseClient;
17 | import com.sagarkhurana.quizforfun.other.SharedPref;
18 |
19 | import java.util.ArrayList;
20 |
21 | public class LoginActivity extends AppCompatActivity {
22 |
23 | private EditText etUsername,etPassword;
24 |
25 | @Override
26 | protected void onStart() {
27 | super.onStart();
28 |
29 | SharedPref sharedPref = SharedPref.getInstance();
30 | if (sharedPref.getUser(this)!=null){
31 | startActivity(new Intent(this,MainActivity.class));
32 | finish();
33 | }
34 | }
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setTheme(R.style.Theme_QuizForFun);
40 | setContentView(R.layout.activity_login);
41 |
42 | etUsername = findViewById(R.id.tietUsername);
43 | etPassword = findViewById(R.id.tiePassword);
44 | TextView tvSignUp = findViewById(R.id.tvSignUp);
45 | Button btnLogin = findViewById(R.id.btnLogin);
46 |
47 | btnLogin.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View view) {
50 |
51 | String username = etUsername.getText().toString();
52 | String password = etPassword.getText().toString();
53 |
54 | if (!validaInputs(username,password)) return;
55 |
56 | LoginUserTask ut = new LoginUserTask(username,password);
57 | ut.execute();
58 |
59 | }
60 | });
61 |
62 |
63 | tvSignUp.setOnClickListener(new View.OnClickListener() {
64 | @Override
65 | public void onClick(View view) {
66 | startActivity(new Intent(LoginActivity.this,RegisterActivity.class));
67 | }
68 | });
69 |
70 | }
71 |
72 | private boolean validaInputs(String username, String password) {
73 |
74 | if (username.isEmpty()){
75 | Toast.makeText(this, getString(R.string.username_cannot_empty), Toast.LENGTH_SHORT).show();
76 | return false;
77 | }
78 |
79 | if (password.isEmpty()){
80 | Toast.makeText(this, getString(R.string.password_cannot_empty), Toast.LENGTH_SHORT).show();
81 | return false;
82 | }
83 |
84 | return true;
85 | }
86 |
87 | class LoginUserTask extends AsyncTask {
88 |
89 | private final String username;
90 | private final String password;
91 | private ArrayList users = new ArrayList<>();
92 |
93 | public LoginUserTask(String username, String password) {
94 | this.username = username;
95 | this.password = password;
96 | }
97 |
98 | @Override
99 | protected Void doInBackground(Void... voids) {
100 | UserDatabase databaseClient = UserDatabaseClient.getInstance(getApplicationContext());
101 | users = (ArrayList) databaseClient.userDao().observeAllUser();
102 | return null;
103 | }
104 |
105 | @Override
106 | protected void onPostExecute(Void aVoid) {
107 | super.onPostExecute(aVoid);
108 | for (User user : users){
109 | if (username.equals(user.getUsername()) && password.equals(user.getPassword())){
110 | SharedPref sharedPref = SharedPref.getInstance();
111 | sharedPref.setUser(LoginActivity.this,user);
112 | startActivity(new Intent(LoginActivity.this,MainActivity.class));
113 | return;
114 | }
115 | }
116 | Toast.makeText(LoginActivity.this, "User not exist", Toast.LENGTH_SHORT).show();
117 |
118 | }
119 | }
120 |
121 | }
122 |
123 |
124 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.cardview.widget.CardView;
5 |
6 | import android.content.Intent;
7 | import android.os.Bundle;
8 | import android.view.View;
9 | import android.widget.TextView;
10 |
11 | import com.sagarkhurana.quizforfun.data.User;
12 | import com.sagarkhurana.quizforfun.other.SharedPref;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 |
21 | TextView tvUsername = findViewById(R.id.tvUsernameHome);
22 | CardView cvStartQuiz = findViewById(R.id.cvStartQuiz);
23 | CardView cvRule = findViewById(R.id.cvRule);
24 | CardView cvHistory = findViewById(R.id.cvHistory);
25 | CardView cvEditPassword = findViewById(R.id.cvEditPassword);
26 | CardView cvLogout = findViewById(R.id.cvLogout);
27 |
28 | SharedPref sharedPref = SharedPref.getInstance();
29 | User user = sharedPref.getUser(this);
30 | tvUsername.setText("Hello, " + user.getUsername());
31 |
32 | cvStartQuiz.setOnClickListener(new View.OnClickListener() {
33 | @Override
34 | public void onClick(View view) {
35 | startActivity(new Intent(MainActivity.this,QuizOptionActivity.class));
36 | }
37 | });
38 |
39 | cvRule.setOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View view) {
42 | startActivity(new Intent(MainActivity.this,RuleActivity.class));
43 | }
44 | });
45 |
46 | cvHistory.setOnClickListener(new View.OnClickListener() {
47 | @Override
48 | public void onClick(View view) {
49 | startActivity(new Intent(MainActivity.this,HistoryActivity.class));
50 | }
51 | });
52 |
53 | cvEditPassword.setOnClickListener(new View.OnClickListener() {
54 | @Override
55 | public void onClick(View view) {
56 | startActivity(new Intent(MainActivity.this,EditPasswordActivity.class));
57 | }
58 | });
59 |
60 | cvLogout.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View view) {
63 | sharedPref.clearSharedPref(MainActivity.this);
64 | Intent intent = new Intent(MainActivity.this,LoginActivity.class);
65 | startActivity(intent);
66 | finish();
67 | }
68 | });
69 |
70 |
71 |
72 |
73 | }
74 |
75 |
76 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/MathQuizActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.TextView;
11 | import android.widget.Toast;
12 |
13 | import com.sagarkhurana.quizforfun.other.Constants;
14 | import com.sagarkhurana.quizforfun.other.Utils;
15 |
16 | import java.util.ArrayList;
17 | import java.util.HashMap;
18 | import java.util.List;
19 |
20 | public class MathQuizActivity extends AppCompatActivity {
21 |
22 | private int currentQuestionIndex = 0;
23 | private TextView tvQuestion, tvQuestionNumber;
24 | private Button btnNext;
25 | private List questions;
26 | private int correctQuestion = 0;
27 | private EditText etAnswer;
28 | private HashMap questionsAnswerMap;
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_math_quiz);
34 |
35 | Intent getIntent = getIntent();
36 | questionsAnswerMap = (HashMap) Utils.getRandomMathQuestions(Constants.QUESTION_SHOWING);
37 | questions = new ArrayList<>(questionsAnswerMap.keySet());
38 |
39 | tvQuestion = findViewById(R.id.textView8);
40 | tvQuestionNumber = findViewById(R.id.tvQuestionNumberMath);
41 | btnNext = findViewById(R.id.btnNextQuestionMath);
42 | etAnswer = findViewById(R.id.tietEnterAnswerMath);
43 |
44 | findViewById(R.id.imageViewStartQuiz).setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View view) {
47 | finish();
48 | }
49 | });
50 |
51 | btnNext.setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View view) {
54 |
55 | String answer = etAnswer.getText().toString();
56 |
57 | if (answer.isEmpty()){
58 | Toast.makeText(MathQuizActivity.this, "Answer cannot be empty", Toast.LENGTH_SHORT).show();
59 | return;
60 | }
61 |
62 | if (questionsAnswerMap.get(questions.get(currentQuestionIndex)).equals(answer)) {
63 | correctQuestion++;
64 | }
65 | currentQuestionIndex++;
66 |
67 | if (btnNext.getText().equals(getString(R.string.next))){
68 | displayNextQuestions();
69 | }else{
70 | Intent intentResult = new Intent(MathQuizActivity.this,FinalResultActivity.class);
71 | intentResult.putExtra(Constants.SUBJECT,getString(R.string.math));
72 | intentResult.putExtra(Constants.CORRECT,correctQuestion);
73 | intentResult.putExtra(Constants.INCORRECT,Constants.QUESTION_SHOWING - correctQuestion);
74 | intentResult.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
75 | startActivity(intentResult);
76 | finish();
77 | }
78 | }
79 | });
80 |
81 | displayData();
82 | }
83 |
84 | private void displayNextQuestions() {
85 | etAnswer.setText("");
86 | tvQuestion.setText(questions.get(currentQuestionIndex) + " = ?");
87 | tvQuestionNumber.setText("Current Question: " + (currentQuestionIndex + 1));
88 |
89 | if (currentQuestionIndex == Constants.QUESTION_SHOWING - 1){
90 | btnNext.setText(getText(R.string.finish));
91 | }
92 | }
93 |
94 | private void displayData() {
95 | tvQuestion.setText(questions.get(currentQuestionIndex) + " = ?");
96 | tvQuestionNumber.setText("Current Question: " + (currentQuestionIndex + 1));
97 | }
98 |
99 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/QuizOptionActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.cardview.widget.CardView;
5 |
6 | import android.content.Intent;
7 | import android.os.Bundle;
8 | import android.view.View;
9 |
10 | import com.sagarkhurana.quizforfun.other.Constants;
11 |
12 | public class QuizOptionActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_quiz_option);
18 |
19 | CardView cvMath = findViewById(R.id.cvMath);
20 | CardView cvGeography = findViewById(R.id.cvGeography);
21 | CardView cvLiterature = findViewById(R.id.cvLiterature);
22 |
23 | findViewById(R.id.imageViewQuizOption).setOnClickListener(new View.OnClickListener() {
24 | @Override
25 | public void onClick(View view) {
26 | finish();
27 | }
28 | });
29 |
30 | cvMath.setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View view) {
33 | Intent intent = new Intent(QuizOptionActivity.this, MathQuizActivity.class);
34 | intent.putExtra(Constants.SUBJECT,getString(R.string.math));
35 | startActivity(intent);
36 | }
37 | });
38 |
39 | cvGeography.setOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View view) {
42 | Intent intent = new Intent(QuizOptionActivity.this, GeographyOrLiteratureQuizActivity.class);
43 | intent.putExtra(Constants.SUBJECT,getString(R.string.geography));
44 | startActivity(intent);
45 | }
46 | });
47 |
48 | cvLiterature.setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View view) {
51 | Intent intent = new Intent(QuizOptionActivity.this, GeographyOrLiteratureQuizActivity.class);
52 | intent.putExtra(Constants.SUBJECT,getString(R.string.literature));
53 | startActivity(intent);
54 | }
55 | });
56 |
57 | }
58 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/RegisterActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.database.sqlite.SQLiteConstraintException;
7 | import android.os.AsyncTask;
8 | import android.os.Bundle;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.ImageView;
13 | import android.widget.Toast;
14 |
15 | import com.sagarkhurana.quizforfun.data.User;
16 | import com.sagarkhurana.quizforfun.data.UserDatabase;
17 | import com.sagarkhurana.quizforfun.data.UserDatabaseClient;
18 | import com.sagarkhurana.quizforfun.other.SharedPref;
19 |
20 | import java.util.ArrayList;
21 | import java.util.Calendar;
22 |
23 | import static com.sagarkhurana.quizforfun.other.Utils.isValidEmail;
24 |
25 | public class RegisterActivity extends AppCompatActivity {
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_register);
31 |
32 | ImageView btnBack = findViewById(R.id.imageView);
33 | EditText etUsername = findViewById(R.id.tietUsername);
34 | EditText etEmail = findViewById(R.id.tietPassword);
35 | EditText etPassword = findViewById(R.id.tiePassword);
36 | Button btnRegister = findViewById(R.id.btnRegister);
37 |
38 | btnBack.setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View view) {
41 | finish();
42 | }
43 | });
44 |
45 | btnRegister.setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View view) {
48 |
49 | String username = etUsername.getText().toString();
50 | String email = etEmail.getText().toString();
51 | String password = etPassword.getText().toString();
52 |
53 | if (!validateInputs(username,email,password)) return;
54 |
55 | RegisterUserTask registerUserTask = new RegisterUserTask(username,email,password);
56 | registerUserTask.execute();
57 | }
58 | });
59 | }
60 |
61 | private boolean validateInputs(String username,String email,String password){
62 |
63 | if (username.isEmpty()){
64 | Toast.makeText(this, getString(R.string.username_cannot_empty), Toast.LENGTH_SHORT).show();
65 | return false;
66 | }
67 |
68 | if (email.isEmpty()){
69 | Toast.makeText(this, getString(R.string.email_cannot_empty), Toast.LENGTH_SHORT).show();
70 | return false;
71 | }
72 |
73 | if (!isValidEmail(email)){
74 | Toast.makeText(this, getString(R.string.email_not_valid), Toast.LENGTH_SHORT).show();
75 | return false;
76 | }
77 |
78 | if (password.isEmpty()){
79 | Toast.makeText(this, getString(R.string.password_cannot_empty), Toast.LENGTH_SHORT).show();
80 | return false;
81 | }
82 |
83 | return true;
84 | }
85 |
86 | class RegisterUserTask extends AsyncTask {
87 |
88 | private final String username;
89 | private final String email;
90 | private final String password;
91 | private User user ;
92 | private boolean isOkay = true ;
93 |
94 | public RegisterUserTask(String username, String email, String password) {
95 | this.username = username;
96 | this.email = email;
97 | this.password = password;
98 | }
99 |
100 | @Override
101 | protected Void doInBackground(Void... voids) {
102 | UserDatabase databaseClient = UserDatabaseClient.getInstance(getApplicationContext());
103 |
104 | user = new User(
105 | username,
106 | email,
107 | password
108 | );
109 |
110 | try {
111 | databaseClient.userDao().insertUser(user);
112 | }catch (SQLiteConstraintException e){
113 | isOkay =false;
114 | }
115 |
116 | return null;
117 | }
118 |
119 | @Override
120 | protected void onPostExecute(Void aVoid) {
121 | super.onPostExecute(aVoid);
122 |
123 | if (isOkay){
124 | Toast.makeText(RegisterActivity.this, "User Created!", Toast.LENGTH_SHORT).show();
125 | SharedPref sharedPref = SharedPref.getInstance();
126 | sharedPref.setUser(RegisterActivity.this,user);
127 | Intent intent = new Intent(RegisterActivity.this,MainActivity.class);
128 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
129 | startActivity(intent);
130 | finish();
131 | }else{
132 | Toast.makeText(RegisterActivity.this, "This email is already using by someone else", Toast.LENGTH_SHORT).show();
133 | }
134 |
135 | }
136 | }
137 |
138 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/RuleActivity.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import androidx.viewpager.widget.ViewPager;
5 |
6 | import android.os.Bundle;
7 | import android.widget.ImageView;
8 |
9 | import com.sagarkhurana.quizforfun.adapter.RulesViewPagerAdapter;
10 | import com.tbuonomo.viewpagerdotsindicator.SpringDotsIndicator;
11 |
12 | public class RuleActivity extends AppCompatActivity {
13 |
14 | public static ViewPager viewPager;
15 | RulesViewPagerAdapter adapter;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_rule);
21 |
22 | SpringDotsIndicator springDotsIndicator = findViewById(R.id.spring_dots_indicator);
23 | ImageView back= findViewById(R.id.imageRule);
24 |
25 | //Event onClick for back button
26 | back.setOnClickListener(v -> finish());
27 |
28 | //Init dotIndicator and PagerAdapter
29 | viewPager=findViewById(R.id.viewpager);
30 | adapter=new RulesViewPagerAdapter(this);
31 | viewPager.setAdapter(adapter);
32 | springDotsIndicator.setViewPager(viewPager);
33 | }
34 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/adapter/HistoryAdapter.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.adapter;
2 |
3 | import android.view.LayoutInflater;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.TextView;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.cardview.widget.CardView;
10 | import androidx.recyclerview.widget.RecyclerView;
11 |
12 | import com.sagarkhurana.quizforfun.R;
13 | import com.sagarkhurana.quizforfun.data.Attempt;
14 |
15 | import java.util.List;
16 |
17 | import static com.sagarkhurana.quizforfun.other.Utils.formatDate;
18 |
19 | public class HistoryAdapter extends RecyclerView.Adapter {
20 |
21 | private final List attempts;
22 |
23 | public HistoryAdapter(List attempts) {
24 | this.attempts = attempts;
25 | }
26 |
27 | @NonNull
28 | @Override
29 | public AttemptViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
30 | LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
31 | View view = layoutInflater.inflate(R.layout.item_history, parent, false);
32 | return new HistoryAdapter.AttemptViewHolder(view);
33 | }
34 |
35 | @Override
36 | public void onBindViewHolder(@NonNull AttemptViewHolder holder, int position) {
37 |
38 | Attempt item = attempts.get(position);
39 |
40 | holder.tvSubject.setText(String.valueOf(item.getSubject()));
41 | holder.tvEarned.setText(String.valueOf(item.getEarned()));
42 | holder.tvDate.setText(formatDate(item.getCreatedTime()));
43 |
44 | holder.cvParent.setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View view) {
47 | // DO NOTHING
48 | }
49 | });
50 |
51 | }
52 |
53 | @Override
54 | public int getItemCount() {
55 | return attempts.size();
56 | }
57 |
58 | public static class AttemptViewHolder extends RecyclerView.ViewHolder {
59 |
60 | public TextView tvSubject,tvEarned,tvDate;
61 | public CardView cvParent;
62 |
63 | public AttemptViewHolder(View v) {
64 | super(v);
65 | tvSubject = v.findViewById(R.id.textView23);
66 | tvEarned = v.findViewById(R.id.textView24);
67 | tvDate = v.findViewById(R.id.textView25);
68 | cvParent = v.findViewById(R.id.cvItemHistory);
69 |
70 | }
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/adapter/RulesViewPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.viewpager.widget.PagerAdapter;
11 |
12 | import com.sagarkhurana.quizforfun.R;
13 |
14 | import pl.droidsonroids.gif.GifImageView;
15 |
16 | public class RulesViewPagerAdapter extends PagerAdapter {
17 |
18 | Context ctx;
19 |
20 | public RulesViewPagerAdapter(Context ctx) {
21 | this.ctx = ctx;
22 | }
23 |
24 | @Override
25 | public int getCount() {
26 | return 4;
27 | }
28 |
29 | @Override
30 | public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
31 | return view==object;
32 | }
33 |
34 | @NonNull
35 | @Override
36 | public Object instantiateItem(@NonNull ViewGroup container, final int position) {
37 |
38 | LayoutInflater layoutInflater= (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
39 | View view=layoutInflater.inflate(R.layout.slide_rules,container,false);
40 |
41 | GifImageView logo = view.findViewById(R.id.dancer);
42 |
43 | TextView title = view.findViewById(R.id.textView31);
44 |
45 | switch (position)
46 | {
47 | case 0:
48 | logo.setImageResource(R.drawable.question1);
49 | title.setText(R.string.rules1_description);
50 | break;
51 | case 1:
52 | logo.setImageResource(R.drawable.correct);
53 | title.setText(R.string.rules2_description);
54 | break;
55 | case 2:
56 | logo.setImageResource(R.drawable.incorrect);
57 | title.setText(R.string.rules3_description);
58 | break;
59 | case 3:
60 | logo.setImageResource(R.drawable.noted);
61 | title.setText(R.string.rules4_description);
62 | break;
63 | }
64 | container.addView(view);
65 | return view;
66 | }
67 | @Override
68 | public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
69 | container.removeView((View) object);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/data/Attempt.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.data;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.room.ColumnInfo;
8 | import androidx.room.Entity;
9 | import androidx.room.PrimaryKey;
10 |
11 | @Entity(tableName = "attempt")
12 | public class Attempt implements Parcelable {
13 |
14 | @PrimaryKey(autoGenerate = false)
15 | @ColumnInfo(name = "createdTimeAttempt")
16 | private final long createdTime;
17 | @ColumnInfo(name = "subject")
18 | private final String subject;
19 | @ColumnInfo(name = "correct")
20 | private final int correct;
21 | @ColumnInfo(name = "incorrect")
22 | private final int incorrect;
23 | @ColumnInfo(name = "earned")
24 | private final int earned;
25 | @ColumnInfo(name = "email")
26 | private final String email;
27 | @ColumnInfo(name = "overallPoints")
28 | private int overallPoints;
29 |
30 | public Attempt(long createdTime, String subject, int correct, int incorrect, int earned, String email) {
31 | this.createdTime = createdTime;
32 | this.subject = subject;
33 | this.correct = correct;
34 | this.incorrect = incorrect;
35 | this.earned = earned;
36 | this.email = email;
37 | }
38 |
39 | public void setOverallPoints(int overallPoints) {
40 | this.overallPoints = overallPoints;
41 | }
42 |
43 | public long getCreatedTime() {
44 | return createdTime;
45 | }
46 |
47 | public String getSubject() {
48 | return subject;
49 | }
50 |
51 | public int getCorrect() {
52 | return correct;
53 | }
54 |
55 | public int getIncorrect() {
56 | return incorrect;
57 | }
58 |
59 | public int getEarned() {
60 | return earned;
61 | }
62 |
63 | public String getEmail() {
64 | return email;
65 | }
66 |
67 | public int getOverallPoints() {
68 | return overallPoints;
69 | }
70 |
71 | public static Creator getCREATOR() {
72 | return CREATOR;
73 | }
74 |
75 | protected Attempt(Parcel in) {
76 | createdTime = in.readLong();
77 | subject = in.readString();
78 | correct = in.readInt();
79 | incorrect = in.readInt();
80 | earned = in.readInt();
81 | email = in.readString();
82 | overallPoints = in.readInt();
83 | }
84 |
85 | @Override
86 | public void writeToParcel(Parcel dest, int flags) {
87 | dest.writeLong(createdTime);
88 | dest.writeString(subject);
89 | dest.writeInt(correct);
90 | dest.writeInt(incorrect);
91 | dest.writeInt(earned);
92 | dest.writeString(email);
93 | dest.writeInt(overallPoints);
94 | }
95 |
96 | @Override
97 | public int describeContents() {
98 | return 0;
99 | }
100 |
101 | public static final Creator CREATOR = new Creator() {
102 | @Override
103 | public Attempt createFromParcel(Parcel in) {
104 | return new Attempt(in);
105 | }
106 |
107 | @Override
108 | public Attempt[] newArray(int size) {
109 | return new Attempt[size];
110 | }
111 | };
112 | }
113 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/data/User.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.data;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.room.ColumnInfo;
8 | import androidx.room.Embedded;
9 | import androidx.room.Entity;
10 | import androidx.room.PrimaryKey;
11 |
12 | import java.util.List;
13 |
14 | @Entity(tableName = "user")
15 | public class User implements Parcelable {
16 |
17 | @ColumnInfo(name = "username")
18 | private final String username;
19 | @NonNull
20 | @PrimaryKey(autoGenerate = false)
21 | @ColumnInfo(name = "email")
22 | private final String email;
23 | @ColumnInfo(name = "password")
24 | private String password;
25 |
26 | public User(String username, @NonNull String email, String password) {
27 | this.username = username;
28 | this.email = email;
29 | this.password = password;
30 | }
31 |
32 | public void setPassword(String password) {
33 | this.password = password;
34 | }
35 |
36 | public String getUsername() {
37 | return username;
38 | }
39 |
40 | @NonNull
41 | public String getEmail() {
42 | return email;
43 | }
44 |
45 | public String getPassword() {
46 | return password;
47 | }
48 |
49 | public static Creator getCREATOR() {
50 | return CREATOR;
51 | }
52 |
53 | protected User(Parcel in) {
54 | username = in.readString();
55 | email = in.readString();
56 | password = in.readString();
57 | }
58 |
59 | @Override
60 | public void writeToParcel(Parcel dest, int flags) {
61 | dest.writeString(username);
62 | dest.writeString(email);
63 | dest.writeString(password);
64 | }
65 |
66 | @Override
67 | public int describeContents() {
68 | return 0;
69 | }
70 |
71 | public static final Creator CREATOR = new Creator() {
72 | @Override
73 | public User createFromParcel(Parcel in) {
74 | return new User(in);
75 | }
76 |
77 | @Override
78 | public User[] newArray(int size) {
79 | return new User[size];
80 | }
81 | };
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/data/UserDao.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.data;
2 |
3 | import androidx.room.Dao;
4 | import androidx.room.Delete;
5 | import androidx.room.Insert;
6 | import androidx.room.OnConflictStrategy;
7 | import androidx.room.Query;
8 | import androidx.room.Transaction;
9 | import androidx.room.Update;
10 |
11 | import java.util.List;
12 |
13 | @Dao
14 | public interface UserDao {
15 |
16 | @Insert(onConflict = OnConflictStrategy.ABORT)
17 | void insertUser(User user);
18 |
19 | @Insert(onConflict = OnConflictStrategy.REPLACE)
20 | void insertAttempt(Attempt attempt);
21 |
22 | @Update
23 | void updateUser(User user);
24 |
25 | @Query("SELECT * FROM user")
26 | List observeAllUser();
27 |
28 | @Delete
29 | void deleteUser(User user);
30 |
31 | @Transaction
32 | @Query("SELECT DISTINCT * FROM attempt WHERE email = :email")
33 | List getUserAndAttemptsWithSameEmail(String email);
34 |
35 | @Transaction
36 | @Query("SELECT SUM(earned) FROM attempt WHERE email = :email")
37 | int getOverAllPoints(String email);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/data/UserDatabase.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.data;
2 |
3 | import android.app.Person;
4 | import android.content.Context;
5 |
6 | import androidx.room.Database;
7 | import androidx.room.Room;
8 | import androidx.room.RoomDatabase;
9 | import androidx.room.TypeConverters;
10 |
11 | import com.sagarkhurana.quizforfun.other.Convertor;
12 |
13 | @Database(
14 | entities = {User.class,Attempt.class},
15 | exportSchema = false,
16 | version = 1
17 | )
18 | public abstract class UserDatabase extends RoomDatabase {
19 |
20 | public abstract UserDao userDao();
21 |
22 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/data/UserDatabaseClient.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.data;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.room.Room;
6 |
7 | public class UserDatabaseClient {
8 |
9 | private static final String DB_NAME = "user_db";
10 | private static UserDatabase instance;
11 |
12 | public static synchronized UserDatabase getInstance(Context context){
13 | if (instance == null){
14 | instance = Room.databaseBuilder(
15 | context.getApplicationContext(), UserDatabase.class,DB_NAME)
16 | .fallbackToDestructiveMigration()
17 | .build();
18 | }
19 | return instance;
20 | }
21 |
22 | public UserDatabase getUserDatabase() {
23 | return instance;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/data/UserWithAttempts.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.data;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import androidx.room.Embedded;
7 | import androidx.room.Relation;
8 |
9 | public class UserWithAttempts implements Parcelable {
10 |
11 | @Embedded
12 | private User user;
13 | @Relation(
14 | parentColumn = "email",
15 | entityColumn = "email",
16 | entity = Attempt.class
17 | )
18 | private Attempt attempt;
19 |
20 | public UserWithAttempts(User user, Attempt attempt) {
21 | this.user = user;
22 | this.attempt = attempt;
23 | }
24 |
25 | protected UserWithAttempts(Parcel in) {
26 | user = in.readParcelable(User.class.getClassLoader());
27 | attempt = in.readParcelable(Attempt.class.getClassLoader());
28 | }
29 |
30 | @Override
31 | public void writeToParcel(Parcel dest, int flags) {
32 | dest.writeParcelable(user, flags);
33 | dest.writeParcelable(attempt, flags);
34 | }
35 |
36 | @Override
37 | public int describeContents() {
38 | return 0;
39 | }
40 |
41 | public static final Creator CREATOR = new Creator() {
42 | @Override
43 | public UserWithAttempts createFromParcel(Parcel in) {
44 | return new UserWithAttempts(in);
45 | }
46 |
47 | @Override
48 | public UserWithAttempts[] newArray(int size) {
49 | return new UserWithAttempts[size];
50 | }
51 | };
52 |
53 | public User getUser() {
54 | return user;
55 | }
56 |
57 | public Attempt getAttempt() {
58 | return attempt;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/other/Constants.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.other;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import java.util.Random;
7 |
8 | public class Constants {
9 |
10 | public static final String USER = "user";
11 | public static final String SUBJECT = "subject";
12 | public static final String CORRECT = "correct";
13 | public static final String INCORRECT = "incorrect";
14 | public static final String QUESTIONS = "questions";
15 | public static final int QUESTION_SHOWING = 5;
16 |
17 | public static final int CORRECT_POINT = 5;
18 | public static final int INCORRECT_POINT = 2;
19 |
20 |
21 | public static final String DATE_FORMAT = "dd MMM YYYY hh:mm a";
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/other/Convertor.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.other;
2 |
3 | import androidx.room.TypeConverter;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 | import com.sagarkhurana.quizforfun.data.Attempt;
8 |
9 | import java.util.List;
10 |
11 | public class Convertor {
12 |
13 | @TypeConverter
14 | String fromList(List list){
15 | return new Gson().toJson(list);
16 | }
17 |
18 | @TypeConverter
19 | List toList(String json){
20 | return new Gson().fromJson(json, new TypeToken>(){}.getType());
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sagarkhurana/quizforfun/other/SharedPref.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun.other;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | import com.google.gson.Gson;
9 | import com.sagarkhurana.quizforfun.data.User;
10 |
11 | public class SharedPref {
12 |
13 | private static SharedPref instance = null;
14 |
15 | private static final String sharedPreferencesName = "kevinSharedPref";
16 |
17 | private SharedPref() {
18 | }
19 |
20 | public static SharedPref getInstance() {
21 | if (instance == null) {
22 | instance = new SharedPref();
23 | }
24 | return instance;
25 | }
26 |
27 | public void setUser(Context context, User user){
28 | SharedPreferences pref = context.getSharedPreferences(sharedPreferencesName, Context.MODE_PRIVATE);
29 | SharedPreferences.Editor editor = pref.edit();
30 | editor.putString(Constants.USER,new Gson().toJson(user));
31 | editor.apply();
32 | }
33 |
34 | public User getUser(Context context){
35 | SharedPreferences pref = context.getSharedPreferences(sharedPreferencesName, Context.MODE_PRIVATE);
36 | return new Gson().fromJson(pref.getString(Constants.USER,""),User.class);
37 | }
38 |
39 | public void clearSharedPref(@NonNull Context context) {
40 | SharedPreferences pref = context.getSharedPreferences(sharedPreferencesName, Context.MODE_PRIVATE);
41 | SharedPreferences.Editor editor = pref.edit();
42 | editor.clear();
43 | editor.apply();
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/question1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/drawable-v24/question1.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/arrow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/blackboard.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
51 |
54 |
57 |
60 |
63 |
66 |
69 |
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/book.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/correct.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/drawable/correct.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/history.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
51 |
54 |
57 |
60 |
63 |
66 |
69 |
72 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/home_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/incorrect.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/drawable/incorrect.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/keys.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logout.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/noted.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/drawable/noted.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
51 |
54 |
57 |
60 |
63 |
66 |
69 |
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selected.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/splash_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/unselected.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/worldwide.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edit_password.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
32 |
33 |
34 |
44 |
45 |
53 |
54 |
55 |
65 |
66 |
74 |
75 |
76 |
86 |
87 |
95 |
96 |
97 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_final_result.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
32 |
33 |
44 |
45 |
54 |
55 |
64 |
65 |
74 |
75 |
84 |
85 |
94 |
95 |
104 |
105 |
115 |
116 |
129 |
130 |
139 |
140 |
149 |
150 |
160 |
161 |
170 |
171 |
181 |
182 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_geography_or_literature_quiz.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
16 |
17 |
18 |
19 |
31 |
32 |
42 |
43 |
58 |
59 |
60 |
71 |
72 |
82 |
83 |
89 |
90 |
96 |
97 |
98 |
104 |
105 |
111 |
112 |
113 |
114 |
115 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_history.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
32 |
33 |
42 |
43 |
53 |
54 |
67 |
68 |
80 |
81 |
97 |
98 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
22 |
23 |
34 |
35 |
45 |
46 |
54 |
55 |
56 |
64 |
65 |
72 |
73 |
74 |
84 |
85 |
99 |
100 |
114 |
115 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_math_quiz.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
32 |
33 |
47 |
48 |
49 |
59 |
60 |
69 |
70 |
71 |
72 |
83 |
84 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_quiz_option.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
32 |
33 |
44 |
45 |
46 |
49 |
50 |
51 |
60 |
61 |
71 |
72 |
73 |
74 |
75 |
84 |
85 |
86 |
89 |
90 |
91 |
100 |
101 |
111 |
112 |
113 |
114 |
123 |
124 |
125 |
128 |
129 |
130 |
139 |
140 |
150 |
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_register.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
32 |
33 |
43 |
44 |
52 |
53 |
54 |
55 |
65 |
66 |
74 |
75 |
76 |
77 |
85 |
86 |
93 |
94 |
95 |
96 |
106 |
107 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_rule.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
32 |
33 |
42 |
43 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_history.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
19 |
20 |
33 |
34 |
43 |
44 |
55 |
56 |
67 |
68 |
79 |
80 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/slide_rules.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF6200EE
7 | #FF018786
8 | #0D233F
9 |
10 | #FF6F5E
11 | #A0A3B1
12 | #F2F3F7
13 | #FFFFFFFF
14 |
15 | #03A9F4
16 | #89C4DA
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 12dp
5 |
6 | 70dp
7 |
8 | 24dp
9 | 24dp
10 |
11 | 100dp
12 |
13 | 140dp
14 |
15 | 64dp
16 |
17 | 25dp
18 |
19 | 80dp
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | QuizForFun
3 | Password
4 | Login
5 | Username
6 | Welcome Back!
7 | Login to continue
8 |
9 | Username cannot be empty
10 | Password cannot be empty
11 | Old Password cannot be empty
12 | New Password cannot be empty
13 | Confirm New Password cannot be empty
14 | Password must be same
15 | New Password must be different
16 | Email cannot be empty
17 | Email must be valid
18 | Don’t have an account?
19 | SIGN UP
20 | Create Account
21 | Register
22 | Email
23 | Start Quiz
24 | Rule
25 | History
26 | Menu
27 | Quiz Option
28 | Edit Password
29 | Logout
30 | New Password
31 | Confirm New Password
32 | Old Password
33 | Create
34 | Save Password
35 | Literature
36 | Geography
37 | Math
38 | Finish
39 | Next
40 | Enter Answer
41 | Final Result
42 | Subject :
43 | Correct :
44 | Incorrect :
45 | Earned :
46 | Total Questions :
47 | Overall Points :
48 | Math Quiz
49 | Literature Quiz
50 | Geography Quiz
51 | Date :
52 | Start Again!
53 |
54 |
55 | The Quiz will contain 5 randomized questions.
56 |
57 |
58 | Every correct answer scores you 5 points.
59 |
60 |
61 | Every wrong answer deduct you 2 points.
62 |
63 |
64 | Your results will be saved and will be accumulated in your history.
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
37 |
38 |
41 |
42 |
47 |
48 |
53 |
54 |
59 |
60 |
66 |
67 |
72 |
73 |
77 |
78 |
82 |
83 |
84 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/app/src/test/java/com/sagarkhurana/quizforfun/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.sagarkhurana.quizforfun;
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 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath "com.android.tools.build:gradle:4.1.1"
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | google()
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/appcompat/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/constraintlayout/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/room/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/test/espresso/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/test/ext/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/com/google/android/material/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/master-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
--------------------------------------------------------------------------------
/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 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Nov 18 16:06:32 IST 2020
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-6.5-bin.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | sdk.dir=C\:\\Users\\sagar\\AppData\\Local\\Android\\Sdk
--------------------------------------------------------------------------------
/screenshots/0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/0.png
--------------------------------------------------------------------------------
/screenshots/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/1.png
--------------------------------------------------------------------------------
/screenshots/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/10.png
--------------------------------------------------------------------------------
/screenshots/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/2.png
--------------------------------------------------------------------------------
/screenshots/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/3.png
--------------------------------------------------------------------------------
/screenshots/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/4.png
--------------------------------------------------------------------------------
/screenshots/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/5.png
--------------------------------------------------------------------------------
/screenshots/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/6.png
--------------------------------------------------------------------------------
/screenshots/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/7.png
--------------------------------------------------------------------------------
/screenshots/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/8.png
--------------------------------------------------------------------------------
/screenshots/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/9.png
--------------------------------------------------------------------------------
/screenshots/qrCodeForApk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hellosagar/Quiz-App/de5e93ae433288122442045a66d2005b8b28c954/screenshots/qrCodeForApk.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "QuizForFun"
--------------------------------------------------------------------------------