diff --git a/Quizime/.gitignore b/Quizime/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/Quizime/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/Quizime/.idea/.gitignore b/Quizime/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Quizime/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Quizime/.idea/compiler.xml b/Quizime/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/Quizime/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Quizime/.idea/gradle.xml b/Quizime/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/Quizime/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/Quizime/.idea/jarRepositories.xml b/Quizime/.idea/jarRepositories.xml new file mode 100644 index 0000000..0380d8d --- /dev/null +++ b/Quizime/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Quizime/.idea/misc.xml b/Quizime/.idea/misc.xml new file mode 100644 index 0000000..036871e --- /dev/null +++ b/Quizime/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Quizime/.idea/runConfigurations.xml b/Quizime/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/Quizime/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Quizime/app/.gitignore b/Quizime/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/Quizime/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/Quizime/app/build.gradle b/Quizime/app/build.gradle new file mode 100644 index 0000000..a496169 --- /dev/null +++ b/Quizime/app/build.gradle @@ -0,0 +1,47 @@ +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'kotlin-android-extensions' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.example.quizime" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.core:core-ktx:1.6.0' + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.0' + testImplementation 'junit:junit:4.+' + implementation 'com.google.android.material:material:1.1.0-alpha06' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} \ No newline at end of file diff --git a/Quizime/app/proguard-rules.pro b/Quizime/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/Quizime/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/Quizime/app/src/androidTest/java/com/example/quizime/ExampleInstrumentedTest.kt b/Quizime/app/src/androidTest/java/com/example/quizime/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..aeea9a2 --- /dev/null +++ b/Quizime/app/src/androidTest/java/com/example/quizime/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.quizime + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.example.quizime", appContext.packageName) + } +} \ No newline at end of file diff --git a/Quizime/app/src/main/AndroidManifest.xml b/Quizime/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..6933386 --- /dev/null +++ b/Quizime/app/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Quizime/app/src/main/java/com/example/quizime/Constants.kt b/Quizime/app/src/main/java/com/example/quizime/Constants.kt new file mode 100644 index 0000000..3e7992f --- /dev/null +++ b/Quizime/app/src/main/java/com/example/quizime/Constants.kt @@ -0,0 +1,48 @@ +package com.example.quizime + +object Constants { + + const val USER_NAME : String = "user_name" + const val TOTAL_QUESTIONS : String = "total_questions" + const val CORRECT_ANSWERS : String = "correct_answers" + + fun getQuestions(): ArrayList{ + val questionsList = ArrayList() + + //questions start here + + val que1 = Question(1,"Which Anime Character is this ?" , + R.drawable.img_1 , + "Monkey D. Luffy" , "Usopp" , "Marshal D. Teech" , + "Gol D. Roger" ,1) + questionsList.add(que1) + + val que2 = Question(2,"Which Anime show does this Character belongs to ?" , + R.drawable.img_2 , + "One Piece" , "Naruto" , "Tokyo Revengers" , + "Tokyo Ghoul" ,4) + questionsList.add(que2) + + val que3 = Question(3,"Which legendary show does this Character belongs to ?" , + R.drawable.img_3, + "One Piece" , "Naruto" , "Tokyo Revengers" , + "Dragon Ball" ,4) + questionsList.add(que3) + + val que4 = Question(4,"Is he Light Yagami ?" , + R.drawable.img_4, + "Yes" , "definiteLy" , "You're wrong , he's awesome" , + "He's L" ,3) + questionsList.add(que4) + + val que5 = Question(5,"Which fruit this guy ate ?" , + R.drawable.img_5, + "Gumo Gumo ni" , "Mera Mera no Mi" , "Fire-Fire fruit" , + "Flame-Fist fruit" ,2) + questionsList.add(que5) + + return questionsList + } + + +} \ No newline at end of file diff --git a/Quizime/app/src/main/java/com/example/quizime/MainActivity.kt b/Quizime/app/src/main/java/com/example/quizime/MainActivity.kt new file mode 100644 index 0000000..f626c78 --- /dev/null +++ b/Quizime/app/src/main/java/com/example/quizime/MainActivity.kt @@ -0,0 +1,27 @@ + package com.example.quizime + +import android.content.Intent +import android.os.Bundle +import android.view.View +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.activity_main.* + + class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN + submitbtn.setOnClickListener{ + if (eett_name.text.toString().isEmpty()){ + Toast.makeText(this,"Please Enter A Valid Name",Toast.LENGTH_SHORT).show() + }else{ + val intent = Intent(this , QuizQuestionsActivity::class.java) + intent.putExtra(Constants.USER_NAME , eett_name.text.toString()) + startActivity(intent) + finish() + } + } + } +} \ No newline at end of file diff --git a/Quizime/app/src/main/java/com/example/quizime/Question.kt b/Quizime/app/src/main/java/com/example/quizime/Question.kt new file mode 100644 index 0000000..529b8bb --- /dev/null +++ b/Quizime/app/src/main/java/com/example/quizime/Question.kt @@ -0,0 +1,4 @@ +package com.example.quizime + +data class Question (val id: Int , val question :String , val image: Int , val optionOne : String , +val optionTwo : String , val optionThree : String , val optionFour : String , val correctAnswer : Int) \ No newline at end of file diff --git a/Quizime/app/src/main/java/com/example/quizime/QuizQuestionsActivity.kt b/Quizime/app/src/main/java/com/example/quizime/QuizQuestionsActivity.kt new file mode 100644 index 0000000..f56c1a9 --- /dev/null +++ b/Quizime/app/src/main/java/com/example/quizime/QuizQuestionsActivity.kt @@ -0,0 +1,166 @@ +package com.example.quizime + +import android.content.Intent +import android.graphics.Color +import android.graphics.Typeface +import android.os.Bundle +import android.view.View +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat +import kotlinx.android.synthetic.main.activity_quiz_questions.* + +class QuizQuestionsActivity : AppCompatActivity() , View.OnClickListener{ + + private var mCurrentPosition:Int = 1 //used for assigning the current question + private var mQuestionsList: ArrayList? = null + private var mSelectedOptionPosition: Int = 0 //used for selecting the position of option + private var mCorrectAnswers : Int = 0 // for your score :) + private var mUserName : String? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_quiz_questions) + + mUserName = intent.getStringExtra(Constants.USER_NAME) + + mQuestionsList = Constants.getQuestions() + + setQuestion() + + tv_option_one.setOnClickListener(this) + tv_option_two.setOnClickListener(this) + tv_option_three.setOnClickListener(this) + tv_option_four.setOnClickListener(this) + quesubmit.setOnClickListener(this) + } + + private fun setQuestion(){ + + val question = mQuestionsList!!.get(mCurrentPosition-1) + defaultOptionsView() + + if(mCurrentPosition == mQuestionsList!!.size){ + quesubmit.text == "FINISH" + }else{ + quesubmit.text == "SUBMIT" + } + + //set the xml attribute "progress" of progressBar (xml id of progressbar) eqv. to currentPosition.. + progressBar.progress=mCurrentPosition + //the text horizontally right to progressbar + tv_progress.text = "$mCurrentPosition" + "/" +progressBar.max + //set the question text + tv_question.text = question!!.question + //set the image of question + iv_image.setImageResource(question.image) + //set the options one by one + tv_option_one.text = question.optionOne + tv_option_two.text = question.optionTwo + tv_option_three.text = question.optionThree + tv_option_four.text = question.optionFour + } + + private fun defaultOptionsView(){ + val options = ArrayList() + + options.add(0 , tv_option_one) + options.add(1 , tv_option_two) + options.add(2 , tv_option_three) + options.add(3 , tv_option_four) + + for(option in options){ + option.setTextColor(Color.parseColor("#7A8089")) + option.typeface = Typeface.DEFAULT + option.background = ContextCompat.getDrawable(this , R.drawable.default_shape) + } + } + + override fun onClick(v: View?) { + when(v?.id){ + R.id.tv_option_one -> { + selectedOptionView(tv_option_one , 1) + } + R.id.tv_option_two -> { + selectedOptionView(tv_option_two , 2) + } + R.id.tv_option_three -> { + selectedOptionView(tv_option_three , 3) + } + R.id.tv_option_four -> { + selectedOptionView(tv_option_four , 4) + } + R.id.quesubmit -> { + if(mSelectedOptionPosition==0){ + mCurrentPosition++ + } + when{ + mCurrentPosition <= mQuestionsList!!.size-> + { + setQuestion() + } + else->{ + val intent = Intent(this , ResultActivity::class.java) + intent.putExtra(Constants.USER_NAME , mUserName) + intent.putExtra(Constants.CORRECT_ANSWERS , mCorrectAnswers) + intent.putExtra(Constants.TOTAL_QUESTIONS , mQuestionsList!!.size) + startActivity(intent) + finish() + } + + } + } + else->{ + val question = mQuestionsList?.get(mCurrentPosition-1) + if(question!!.correctAnswer != mSelectedOptionPosition){ + answerCorrectView(mSelectedOptionPosition , R.drawable.wrong_option_border) + } + else{ + mCorrectAnswers++ + } + answerCorrectView(mSelectedOptionPosition , R.drawable.correct_option_border) + + if(mCurrentPosition == mQuestionsList!!.size){ + quesubmit.text == "FINISH" + }else{ + quesubmit.text == "GO TO NEXT QUESTION" + } + mSelectedOptionPosition = 0 + } +} + } + + private fun answerCorrectView(answer :Int , drawableView :Int){ + when(answer){ + 1 -> { + tv_option_one.background = ContextCompat.getDrawable( + this , drawableView + ) + } + 2 -> { + tv_option_two.background = ContextCompat.getDrawable( + this , drawableView + ) + } + 3 -> { + tv_option_three.background = ContextCompat.getDrawable( + this , drawableView + ) + } 4 -> { + tv_option_four.background = ContextCompat.getDrawable( + this , drawableView + ) + } + } + } + + private fun selectedOptionView(tv: TextView , selectedOptionNum : Int){ + defaultOptionsView() + mSelectedOptionPosition = selectedOptionNum + + tv.setTextColor(Color.parseColor("#363A43")) + tv.setTypeface(tv.typeface , Typeface.BOLD) + tv.background = ContextCompat.getDrawable(this , R.drawable.selected_option_border) + } + +} \ No newline at end of file diff --git a/Quizime/app/src/main/java/com/example/quizime/ResultActivity.kt b/Quizime/app/src/main/java/com/example/quizime/ResultActivity.kt new file mode 100644 index 0000000..bd9bc6f --- /dev/null +++ b/Quizime/app/src/main/java/com/example/quizime/ResultActivity.kt @@ -0,0 +1,27 @@ +package com.example.quizime + +import android.content.Intent +import android.os.Bundle +import android.view.View +import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.activity_result.* + +class ResultActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_result) + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN + + val username = intent.getStringExtra(Constants.USER_NAME) + tv_username.text = username + val totalQuestions = intent.getIntExtra(Constants.TOTAL_QUESTIONS , 0) + val correctAnswers = intent.getIntExtra(Constants.CORRECT_ANSWERS , 0) + + tv_score.text = "Your score is $correctAnswers out of $totalQuestions" + + btn_finish.setOnClickListener(){ + startActivity(Intent(this , MainActivity::class.java)) + finish() + } + } +} \ No newline at end of file diff --git a/Quizime/app/src/main/res/drawable-v24/animebg.jpg b/Quizime/app/src/main/res/drawable-v24/animebg.jpg new file mode 100644 index 0000000..c272d6c Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/animebg.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/animebg2.jpg b/Quizime/app/src/main/res/drawable-v24/animebg2.jpg new file mode 100644 index 0000000..2bf07af Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/animebg2.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/Quizime/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/Quizime/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Quizime/app/src/main/res/drawable-v24/ic_trophy.png b/Quizime/app/src/main/res/drawable-v24/ic_trophy.png new file mode 100644 index 0000000..4353286 Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/ic_trophy.png differ diff --git a/Quizime/app/src/main/res/drawable-v24/img_1.jpg b/Quizime/app/src/main/res/drawable-v24/img_1.jpg new file mode 100644 index 0000000..33af29d Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/img_1.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/img_10.jpg b/Quizime/app/src/main/res/drawable-v24/img_10.jpg new file mode 100644 index 0000000..e86e13e Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/img_10.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/img_2.jpg b/Quizime/app/src/main/res/drawable-v24/img_2.jpg new file mode 100644 index 0000000..e5b2cd0 Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/img_2.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/img_3.jpg b/Quizime/app/src/main/res/drawable-v24/img_3.jpg new file mode 100644 index 0000000..b5bd2a5 Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/img_3.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/img_4.jpg b/Quizime/app/src/main/res/drawable-v24/img_4.jpg new file mode 100644 index 0000000..56547dc Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/img_4.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/img_5.jpg b/Quizime/app/src/main/res/drawable-v24/img_5.jpg new file mode 100644 index 0000000..02a145e Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/img_5.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/img_6.jpg b/Quizime/app/src/main/res/drawable-v24/img_6.jpg new file mode 100644 index 0000000..dc89596 Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/img_6.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/img_7.jpg b/Quizime/app/src/main/res/drawable-v24/img_7.jpg new file mode 100644 index 0000000..b522a52 Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/img_7.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/img_9.jpg b/Quizime/app/src/main/res/drawable-v24/img_9.jpg new file mode 100644 index 0000000..fe7e5d6 Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/img_9.jpg differ diff --git a/Quizime/app/src/main/res/drawable-v24/realdeal.png b/Quizime/app/src/main/res/drawable-v24/realdeal.png new file mode 100644 index 0000000..ec56674 Binary files /dev/null and b/Quizime/app/src/main/res/drawable-v24/realdeal.png differ diff --git a/Quizime/app/src/main/res/drawable/correct_option_border.xml b/Quizime/app/src/main/res/drawable/correct_option_border.xml new file mode 100644 index 0000000..feec55c --- /dev/null +++ b/Quizime/app/src/main/res/drawable/correct_option_border.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/Quizime/app/src/main/res/drawable/default_shape.xml b/Quizime/app/src/main/res/drawable/default_shape.xml new file mode 100644 index 0000000..621ddae --- /dev/null +++ b/Quizime/app/src/main/res/drawable/default_shape.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/Quizime/app/src/main/res/drawable/ic_launcher_background.xml b/Quizime/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/Quizime/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Quizime/app/src/main/res/drawable/selected_option_border.xml b/Quizime/app/src/main/res/drawable/selected_option_border.xml new file mode 100644 index 0000000..b39fb35 --- /dev/null +++ b/Quizime/app/src/main/res/drawable/selected_option_border.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/Quizime/app/src/main/res/drawable/wrong_option_border.xml b/Quizime/app/src/main/res/drawable/wrong_option_border.xml new file mode 100644 index 0000000..1753cad --- /dev/null +++ b/Quizime/app/src/main/res/drawable/wrong_option_border.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/Quizime/app/src/main/res/layout/activity_main.xml b/Quizime/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..3fecd11 --- /dev/null +++ b/Quizime/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Quizime/app/src/main/res/layout/activity_quiz_questions.xml b/Quizime/app/src/main/res/layout/activity_quiz_questions.xml new file mode 100644 index 0000000..3dbd48f --- /dev/null +++ b/Quizime/app/src/main/res/layout/activity_quiz_questions.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + +