├── app ├── .gitignore ├── src │ ├── main │ │ ├── assets │ │ │ ├── user.png │ │ │ ├── flipview.png │ │ │ └── categories │ │ │ │ ├── ART.png │ │ │ │ ├── BOOKS.png │ │ │ │ ├── FILMS.png │ │ │ │ ├── MUSIC.png │ │ │ │ ├── ANIMALS.png │ │ │ │ ├── COMICS.png │ │ │ │ ├── GADGETS.png │ │ │ │ ├── HISTORY.png │ │ │ │ ├── SPORTS.png │ │ │ │ ├── BOARDGAMES.png │ │ │ │ ├── COMPUTERS.png │ │ │ │ ├── GEOGRAPHY.png │ │ │ │ ├── MYTHOLOGY.png │ │ │ │ ├── POLITICS.png │ │ │ │ ├── TELEVISION.png │ │ │ │ ├── VEHICLES.png │ │ │ │ ├── VIDEOGAMES.png │ │ │ │ ├── CELEBRITIES.png │ │ │ │ ├── MATHEMATICS.png │ │ │ │ ├── ANIME_AND_MANGA.png │ │ │ │ ├── GENERAL_KNOWLEDGE.png │ │ │ │ ├── MUSICAL_AND_THEATRES.png │ │ │ │ ├── SCIENCE_AND_NATURE.png │ │ │ │ └── CARTOONS_AND_ANIMATIONS.png │ │ ├── ic_launcher-web.png │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── launcher_icon_custom.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── values │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── colors.xml │ │ │ │ └── strings.xml │ │ │ ├── drawable │ │ │ │ ├── rounded_progressbar.xml │ │ │ │ ├── plus.xml │ │ │ │ ├── highscore.xml │ │ │ │ ├── rounded_corners.xml │ │ │ │ ├── image.xml │ │ │ │ ├── email.xml │ │ │ │ ├── delete.xml │ │ │ │ ├── logout.xml │ │ │ │ ├── changeusername.xml │ │ │ │ ├── changepass.xml │ │ │ │ └── settings.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── spinner_item.xml │ │ │ │ ├── activity_question.xml │ │ │ │ ├── dialog_custom_adpt.xml │ │ │ │ ├── app_bar.xml │ │ │ │ ├── item_difficulty.xml │ │ │ │ ├── activity_settings.xml │ │ │ │ ├── dialog_loading.xml │ │ │ │ ├── dialog_add_question.xml │ │ │ │ ├── fragment_loading.xml │ │ │ │ ├── dialog_confirm_pass.xml │ │ │ │ ├── fragment_finish.xml │ │ │ │ ├── item_highscore.xml │ │ │ │ ├── activity_splash.xml │ │ │ │ └── dialog_change_pass.xml │ │ │ ├── menu │ │ │ │ └── start_meny.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── xml │ │ │ │ └── preferences.xml │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── qwez │ │ │ ├── util │ │ │ ├── UrlConstant.java │ │ │ ├── QuestionC.java │ │ │ ├── ExtrasConstant.java │ │ │ ├── QuestionType.java │ │ │ ├── QuestionUtil.java │ │ │ └── Difficulty.java │ │ │ ├── di │ │ │ ├── FragmentScope.java │ │ │ ├── ActivityScope.java │ │ │ ├── ApplicationScope.java │ │ │ ├── ApplicationModule.java │ │ │ ├── OpenTDBModule.java │ │ │ ├── SharedPreferencesModule.java │ │ │ ├── AppComponent.java │ │ │ ├── BinderModule.java │ │ │ ├── FirebaseModule.java │ │ │ └── NetworkModule.java │ │ │ ├── bus │ │ │ └── event │ │ │ │ ├── NullEvent.java │ │ │ │ ├── GameEvent.java │ │ │ │ ├── BooleanEvent.java │ │ │ │ ├── ChangePassowordEvent.java │ │ │ │ ├── SignupEvent.java │ │ │ │ └── LoginEvent.java │ │ │ ├── entity │ │ │ ├── ErrorCarrier.java │ │ │ ├── FinishedGame.java │ │ │ ├── Answer.java │ │ │ ├── Highscore.java │ │ │ └── IntroData.java │ │ │ ├── repository │ │ │ ├── opentdb │ │ │ │ ├── OpenTDBType.java │ │ │ │ ├── OpenTDBAPI.java │ │ │ │ ├── OpenTDB.java │ │ │ │ └── entity │ │ │ │ │ └── ResponseBody.java │ │ │ ├── firebase │ │ │ │ ├── FirebaseStorageRepositoryType.java │ │ │ │ ├── FirebaseDatabaseType.java │ │ │ │ ├── rxwrapper │ │ │ │ │ ├── RxWrapperNullException.java │ │ │ │ │ ├── FirebaseFunctionsWrapper.java │ │ │ │ │ ├── FirebaseStorageWrapper.java │ │ │ │ │ ├── MaybeTask.java │ │ │ │ │ └── CompletableTask.java │ │ │ │ ├── FirebaseStorageRepository.java │ │ │ │ └── FirebaseAuthRepositoryType.java │ │ │ ├── local │ │ │ │ ├── entity │ │ │ │ │ ├── GameQuestion.java │ │ │ │ │ └── Game.java │ │ │ │ ├── dao │ │ │ │ │ ├── GameDao.java │ │ │ │ │ ├── QuestionDao.java │ │ │ │ │ ├── GameQuestionDao.java │ │ │ │ │ └── BaseDao.java │ │ │ │ └── GameDatabase.java │ │ │ ├── sharedpref │ │ │ │ ├── SharedPreferencesRepositoryType.java │ │ │ │ └── SharedPreferencesRepository.java │ │ │ └── ApiOperator.java │ │ │ ├── ui │ │ │ ├── login │ │ │ │ ├── LoginFragmentModule.java │ │ │ │ ├── LoginVMFactory.java │ │ │ │ ├── LoginModule.java │ │ │ │ └── LoginViewModel.java │ │ │ ├── highscore │ │ │ │ ├── HighscoreVMFactory.java │ │ │ │ ├── HighscoreModule.java │ │ │ │ ├── recyclerview │ │ │ │ │ ├── HighscoreAdapter.java │ │ │ │ │ └── HighscoreHolder.java │ │ │ │ └── HighscoreViewmodel.java │ │ │ ├── splash │ │ │ │ ├── SplashModule.java │ │ │ │ ├── SplashVMFactory.java │ │ │ │ ├── SplashActivity.java │ │ │ │ └── SplashViewModel.java │ │ │ ├── common │ │ │ │ └── ItemDecorator.java │ │ │ ├── start │ │ │ │ ├── recycler │ │ │ │ │ ├── CustomAdapter.java │ │ │ │ │ ├── GameAdapter.java │ │ │ │ │ └── GameHolder.java │ │ │ │ └── StartVMFactory.java │ │ │ ├── dialog │ │ │ │ └── DifficultyItem.java │ │ │ ├── question │ │ │ │ ├── QuestionVMFactory.java │ │ │ │ ├── FinishFragment.java │ │ │ │ └── QuestionModule.java │ │ │ └── settings │ │ │ │ └── SettingsVMFactory.java │ │ │ ├── validator │ │ │ ├── EmailValidate.java │ │ │ ├── EmptyValidate.java │ │ │ ├── PasswordValidate.java │ │ │ ├── PatternValidate.java │ │ │ └── Validate.java │ │ │ ├── base │ │ │ ├── BaseAdapter.java │ │ │ ├── BaseViewHolder.java │ │ │ ├── BaseViewModel.java │ │ │ └── BaseFragment.java │ │ │ ├── router │ │ │ ├── HighscoreRouter.java │ │ │ ├── QuestionRouter.java │ │ │ ├── LoginRouter.java │ │ │ ├── SettingsRouter.java │ │ │ └── StartRouter.java │ │ │ ├── interactor │ │ │ ├── LogoutUserInteractor.java │ │ │ ├── DeleteGameInteractor.java │ │ │ ├── GetUserInteractor.java │ │ │ ├── FirstTimeInteractor.java │ │ │ ├── GetAllGamesInteractor.java │ │ │ ├── LoginUserInteractor.java │ │ │ ├── SignupInteractor.java │ │ │ ├── ChangeUserNickInteractor.java │ │ │ ├── GetAllGamesAndQuestionsInteractor.java │ │ │ ├── UpdateQuestionAndGameInteractor.java │ │ │ ├── DeleteAccountInteractor.java │ │ │ ├── ChangeUserPasswordInteractor.java │ │ │ ├── ChangeProfilePhotoInteractor.java │ │ │ ├── GetSingleGameAndQuestionsInteractor.java │ │ │ ├── rx │ │ │ │ └── Operators.java │ │ │ ├── GetHighscoreInteractor.java │ │ │ ├── RememberUserInteractor.java │ │ │ ├── PointsInteractor.java │ │ │ └── FetchQuestionsInteractor.java │ │ │ └── service │ │ │ └── MyFirebaseMessagingService.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── qwez │ │ ├── android │ │ └── text │ │ │ └── TextUtils.java │ │ ├── ui │ │ └── question │ │ │ └── QuestionViewModelTest.java │ │ ├── RxResources.java │ │ ├── util │ │ └── QuestionConverterTest.java │ │ ├── repository │ │ └── firebase │ │ │ └── rxwrapper │ │ │ └── FirebaseTestHelper.java │ │ ├── validator │ │ └── ValidateTest.java │ │ └── interactor │ │ ├── LogoutUserInteractorTest.java │ │ ├── DeleteGameInteractorTest.java │ │ ├── LoginUserInteractorTest.java │ │ ├── GetUserInteractorTest.java │ │ ├── GetSingleGameAndQuestionsInteractorTest.java │ │ ├── SignupInteractorTest.java │ │ └── GetAllGamesInteractorTest.java ├── google-services.json └── proguard-rules.pro ├── functions ├── .gitignore └── package.json ├── settings.gradle ├── Qwez.zip ├── .firebaserc ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── firebase.json ├── .idea ├── encodings.xml ├── vcs.xml ├── compiler.xml ├── inspectionProfiles │ └── Project_Default.xml ├── runConfigurations.xml ├── gradle.xml └── misc.xml ├── .gitignore ├── gradle.properties ├── .travis.yml └── gradlew.bat /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /functions/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /Qwez.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/Qwez.zip -------------------------------------------------------------------------------- /.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "qwez-take-2" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/assets/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/user.png -------------------------------------------------------------------------------- /app/src/main/assets/flipview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/flipview.png -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/assets/categories/ART.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/ART.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/BOOKS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/BOOKS.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/FILMS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/FILMS.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/MUSIC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/MUSIC.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/ANIMALS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/ANIMALS.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/COMICS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/COMICS.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/GADGETS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/GADGETS.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/HISTORY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/HISTORY.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/SPORTS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/SPORTS.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/BOARDGAMES.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/BOARDGAMES.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/COMPUTERS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/COMPUTERS.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/GEOGRAPHY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/GEOGRAPHY.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/MYTHOLOGY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/MYTHOLOGY.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/POLITICS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/POLITICS.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/TELEVISION.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/TELEVISION.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/VEHICLES.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/VEHICLES.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/VIDEOGAMES.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/VIDEOGAMES.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "functions": { 3 | "predeploy": [ 4 | "npm --prefix \"$RESOURCE_DIR\" run lint" 5 | ] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/assets/categories/CELEBRITIES.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/CELEBRITIES.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/MATHEMATICS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/MATHEMATICS.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/ANIME_AND_MANGA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/ANIME_AND_MANGA.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/GENERAL_KNOWLEDGE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/GENERAL_KNOWLEDGE.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/MUSICAL_AND_THEATRES.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/MUSICAL_AND_THEATRES.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/SCIENCE_AND_NATURE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/SCIENCE_AND_NATURE.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/launcher_icon_custom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-hdpi/launcher_icon_custom.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/assets/categories/CARTOONS_AND_ANIMATIONS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/assets/categories/CARTOONS_AND_ANIMATIONS.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/appearance/Qwez/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #A63A35 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rounded_progressbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/util/UrlConstant.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.util; 2 | 3 | /** 4 | * Constants class 5 | */ 6 | public class UrlConstant { 7 | 8 | public static final String URL_END_POINT = "https://opentdb.com/"; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/qwez/android/text/TextUtils.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.android.text; 2 | 3 | 4 | public class TextUtils { 5 | public static boolean isEmpty(CharSequence str) { 6 | return str == null || str.length() == 0; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Apr 18 16:49:01 CEST 2019 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-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/qwez/ui/question/QuestionViewModelTest.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.question; 2 | 3 | import org.junit.Before; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | public class QuestionViewModelTest { 8 | 9 | @Before 10 | public void setUp() throws Exception { 11 | } 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/di/FragmentScope.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.di; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | import javax.inject.Scope; 7 | 8 | @Scope 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface FragmentScope { 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/util/QuestionC.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.util; 2 | 3 | /** 4 | * Constants Class 5 | */ 6 | public class QuestionC { 7 | 8 | public static final int AMOUNT_STANDARD = 10; 9 | public static final String TIMEOUT_ANSWER = "RandonStringAnswer5936952760765365307"; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/util/ExtrasConstant.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.util; 2 | 3 | /** 4 | * Bundle Extras Constants Class 5 | */ 6 | public class ExtrasConstant { 7 | 8 | public static final String QUESTION_LIST = "question list"; 9 | public static final String QUESTION_ID = "question id"; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/bus/event/NullEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.bus.event; 2 | 3 | /** 4 | * Empty object to be used when no data is to be published. 5 | * 6 | * This is a requirement to be able to subscribe/publish anyting, because RxBus publishsubject cannot 7 | * accept nulls 8 | */ 9 | public class NullEvent { 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/plus.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/spinner_item.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/di/ActivityScope.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.di; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | import javax.inject.Scope; 7 | 8 | /** 9 | * Dagger scope specifying scope for Activity 10 | */ 11 | @Scope 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface ActivityScope { 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/highscore.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rounded_corners.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/util/QuestionType.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.util; 2 | 3 | /** 4 | * Question type ENUM 5 | */ 6 | public enum QuestionType { 7 | 8 | MULTIPLE_CHOICE("multiple"), 9 | TRUE_OR_FALSE("boolean"); 10 | 11 | private String type; 12 | 13 | QuestionType(String type) { 14 | this.type = type; 15 | } 16 | 17 | public String getType() { 18 | return type; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/di/ApplicationScope.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.di; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | import javax.inject.Scope; 7 | 8 | /** 9 | * Dagger scope specifying scope for Application 10 | * Lifecycle as long as application is running 11 | */ 12 | @Scope 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface ApplicationScope { 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/entity/ErrorCarrier.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.entity; 2 | 3 | /** 4 | * POJO class for carrying error(s) in application. Used in Viewmodel LiveData error 5 | */ 6 | public class ErrorCarrier { 7 | 8 | private final String message; 9 | 10 | public ErrorCarrier(String message) { 11 | this.message = message; 12 | } 13 | 14 | public String getMessage() { 15 | return message; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/image.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/entity/FinishedGame.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.entity; 2 | 3 | public class FinishedGame { 4 | 5 | private final int score; 6 | private final int gameID; 7 | 8 | public FinishedGame(int score, int gameID) { 9 | this.score = score; 10 | this.gameID = gameID; 11 | } 12 | 13 | public int getScore() { 14 | return score; 15 | } 16 | 17 | public int getGameID() { 18 | return gameID; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/email.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/delete.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/opentdb/OpenTDBType.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.opentdb; 2 | 3 | import com.example.qwez.repository.opentdb.entity.Question; 4 | 5 | import java.util.List; 6 | 7 | import io.reactivex.Single; 8 | 9 | /** 10 | * API interface 11 | */ 12 | public interface OpenTDBType { 13 | 14 | /** 15 | * Get Question from API 16 | */ 17 | Single> getQuestionByCategory(int amount, int category, String difficulty, String type); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/bus/event/GameEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.bus.event; 2 | 3 | import com.example.qwez.repository.local.entity.Game; 4 | 5 | /** 6 | * POJO class for {@link com.example.qwez.bus.RxBus} event type. 7 | * final variable value and getter(s). 8 | */ 9 | public class GameEvent { 10 | 11 | private final Game game; 12 | 13 | public GameEvent(Game game) { 14 | this.game = game; 15 | } 16 | 17 | public Game getGame() { 18 | return game; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_question.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/bus/event/BooleanEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.bus.event; 2 | 3 | /** 4 | * POJO class for {@link com.example.qwez.bus.RxBus} event type. 5 | * final variable value and getter(s). 6 | */ 7 | public class BooleanEvent { 8 | 9 | private final boolean booleanValue; 10 | 11 | public BooleanEvent(boolean booleanValue) { 12 | this.booleanValue = booleanValue; 13 | } 14 | 15 | public boolean isBooleanValue() { 16 | return booleanValue; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/firebase/FirebaseStorageRepositoryType.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.firebase; 2 | 3 | import android.net.Uri; 4 | 5 | import com.google.firebase.storage.StorageReference; 6 | import com.google.firebase.storage.UploadTask; 7 | 8 | import io.reactivex.Single; 9 | 10 | public interface FirebaseStorageRepositoryType { 11 | 12 | Single uploadPhoto(String user, Uri uri); 13 | 14 | Single getDownloadUrl(StorageReference reference); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/logout.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_custom_adpt.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/di/ApplicationModule.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.di; 2 | 3 | import android.content.Context; 4 | 5 | import com.example.qwez.App; 6 | 7 | import dagger.Module; 8 | import dagger.Provides; 9 | 10 | @Module 11 | public class ApplicationModule { 12 | 13 | /** 14 | * Get application context 15 | * @param app 16 | * @return 17 | */ 18 | @Provides 19 | @ApplicationScope 20 | Context context(App app){ 21 | return app.getApplicationContext(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/bus/event/ChangePassowordEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.bus.event; 2 | 3 | /** 4 | * POJO class for {@link com.example.qwez.bus.RxBus} event type. 5 | * final variable value and getter(s). 6 | */ 7 | public class ChangePassowordEvent { 8 | 9 | private final String newPassword; 10 | 11 | public ChangePassowordEvent(String newPassword) { 12 | this.newPassword = newPassword; 13 | } 14 | 15 | public String getNewPassword() { 16 | return newPassword; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/entity/Answer.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.entity; 2 | 3 | public class Answer { 4 | 5 | private String yourAnswer; 6 | private String correctAnswer; 7 | 8 | public Answer(String yourAnswer, String correctAnswer) { 9 | this.yourAnswer = yourAnswer; 10 | this.correctAnswer = correctAnswer; 11 | } 12 | 13 | public String getYourAnswer() { 14 | return yourAnswer; 15 | } 16 | 17 | public String getCorrectAnswer() { 18 | return correctAnswer; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/entity/Highscore.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Highscore implements Serializable{ 6 | 7 | private String nick; 8 | private int score; 9 | 10 | public Highscore(){} 11 | 12 | public Highscore(String nick, int score) { 13 | this.nick = nick; 14 | this.score = score; 15 | } 16 | 17 | public String getNick() { 18 | return nick; 19 | } 20 | 21 | public int getScore() { 22 | return score; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/local/entity/GameQuestion.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.local.entity; 2 | 3 | import androidx.room.Embedded; 4 | import androidx.room.Relation; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Nested fields Class with {@link @Entity #Game} as @Embedded object and @Relation (as list) 10 | * {@link @Entity #Question} 11 | */ 12 | public class GameQuestion { 13 | 14 | @Embedded 15 | public Game game; 16 | 17 | @Relation(parentColumn = "id", entityColumn = "question_id") 18 | public List questions; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/menu/start_meny.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/firebase/FirebaseDatabaseType.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.firebase; 2 | 3 | import com.example.qwez.entity.Highscore; 4 | 5 | import java.util.List; 6 | 7 | import io.reactivex.Completable; 8 | import io.reactivex.Single; 9 | 10 | public interface FirebaseDatabaseType { 11 | 12 | Single getUserHighscore(String uId); 13 | 14 | Single> getTop50Highscores(); 15 | 16 | Completable updateNick(String uid, String newNick); 17 | 18 | Completable updateHighscore(String uid, int addToHighscore); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/login/LoginFragmentModule.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.login; 2 | 3 | import com.example.qwez.interactor.RememberUserInteractor; 4 | import com.example.qwez.repository.sharedpref.SharedPreferencesRepositoryType; 5 | 6 | import dagger.Module; 7 | import dagger.Provides; 8 | 9 | @Module 10 | public class LoginFragmentModule { 11 | 12 | @Provides 13 | RememberUserInteractor rememberUserInteractor(SharedPreferencesRepositoryType sharedPreferencesRepositoryType){ 14 | return new RememberUserInteractor(sharedPreferencesRepositoryType); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/firebase/rxwrapper/RxWrapperNullException.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.firebase.rxwrapper; 2 | 3 | /** 4 | * RxWrapper specific Exception class 5 | */ 6 | public class RxWrapperNullException extends Exception { 7 | 8 | public final static String NO_CURRENT_USER = "No current user(s) found."; 9 | 10 | private final String message; 11 | 12 | public RxWrapperNullException(String message) { 13 | this.message = message; 14 | } 15 | 16 | @Override 17 | public String getMessage() { 18 | return message; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/validator/EmailValidate.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.validator; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | /** 6 | * Validate Class for checking String against email Regex Pattern 7 | */ 8 | public class EmailValidate extends PatternValidate { 9 | 10 | private static final String NOT_VALID_EMAIL = "Not a valid email address."; 11 | private static final String EMAIL_PATTERN = "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$"; 12 | 13 | public EmailValidate() { 14 | super(NOT_VALID_EMAIL, Pattern.compile(EMAIL_PATTERN, Pattern.CASE_INSENSITIVE)); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/changeusername.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/changepass.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 13 | 14 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/bus/event/SignupEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.bus.event; 2 | 3 | /** 4 | * POJO class for {@link com.example.qwez.bus.RxBus} event type. 5 | * final variable value and getter(s). 6 | */ 7 | public class SignupEvent { 8 | 9 | private final String email; 10 | private final String password; 11 | 12 | public SignupEvent(String email, String password) { 13 | this.email = email; 14 | this.password = password; 15 | } 16 | 17 | public String getEmail() { 18 | return email; 19 | } 20 | 21 | public String getPassword() { 22 | return password; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/di/OpenTDBModule.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.di; 2 | 3 | import com.example.qwez.repository.opentdb.OpenTDB; 4 | import com.example.qwez.repository.opentdb.OpenTDBAPI; 5 | import com.example.qwez.repository.opentdb.OpenTDBType; 6 | 7 | import dagger.Module; 8 | import dagger.Provides; 9 | 10 | @Module 11 | public class OpenTDBModule { 12 | 13 | /** 14 | * Get OpenTDB. Singleton 15 | * @param openTDBAPI Dagger provided 16 | * @return OpenTDB 17 | */ 18 | @Provides 19 | @ApplicationScope 20 | OpenTDBType openTDBType(OpenTDBAPI openTDBAPI){ 21 | return new OpenTDB(openTDBAPI); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/validator/EmptyValidate.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.validator; 2 | 3 | /** 4 | * Validate Class for checking if String is empty 5 | */ 6 | public class EmptyValidate extends Validate { 7 | 8 | private static final String EMPTY_ERROR_MESSAGE = "Field cannot be empty"; 9 | 10 | public EmptyValidate() { 11 | super(EMPTY_ERROR_MESSAGE); 12 | } 13 | 14 | /** 15 | * Check if String is not empty 16 | * @param textToCheck to check 17 | * @return true if valid 18 | */ 19 | @Override 20 | public boolean isValid(String textToCheck) { 21 | return textToCheck.length() > 0; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_difficulty.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/sharedpref/SharedPreferencesRepositoryType.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.sharedpref; 2 | 3 | import io.reactivex.Completable; 4 | import io.reactivex.Single; 5 | 6 | /** 7 | * SharedPrefences interface 8 | */ 9 | public interface SharedPreferencesRepositoryType { 10 | 11 | Single getNotFirstTime(); 12 | 13 | Completable setNotFirstTime(boolean setTo); 14 | 15 | Single isRemembered(); 16 | 17 | Single getRemembered(); 18 | 19 | Completable setRemembered(String toRemember); 20 | 21 | Completable setNotRemember(); 22 | 23 | Completable setIsRemember(boolean remember); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/qwez/RxResources.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez; 2 | 3 | import org.junit.rules.ExternalResource; 4 | 5 | import io.reactivex.android.plugins.RxAndroidPlugins; 6 | import io.reactivex.plugins.RxJavaPlugins; 7 | import io.reactivex.schedulers.Schedulers; 8 | 9 | public class RxResources extends ExternalResource { 10 | 11 | @Override 12 | protected void before() throws Throwable { 13 | RxAndroidPlugins.reset(); 14 | RxJavaPlugins.reset(); 15 | RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.trampoline()); 16 | RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/validator/PasswordValidate.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.validator; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | /** 6 | * Validate Class for checking passwords 7 | */ 8 | public class PasswordValidate extends PatternValidate { 9 | 10 | private static final String PASSWORD_NOT_VALID = "Password must contain at least 1 lowercase character, 1 uppercase character, 1 special character, and be between 8 to 20 characters long."; 11 | private static final String PASSWORD_REGEX = "((?=.*[a-z])(?=.*\\d)(?=.*[A-Z])(?=.*[@#$%!=]).{8,20})"; 12 | 13 | public PasswordValidate() { 14 | super(PASSWORD_NOT_VALID, Pattern.compile(PASSWORD_REGEX)); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "functions", 3 | "description": "Cloud Functions for Firebase", 4 | "scripts": { 5 | "lint": "eslint .", 6 | "serve": "firebase serve --only functions", 7 | "shell": "firebase functions:shell", 8 | "start": "npm run shell", 9 | "deploy": "firebase deploy --only functions", 10 | "logs": "firebase functions:log" 11 | }, 12 | "engines": { 13 | "node": "8" 14 | }, 15 | "dependencies": { 16 | "firebase-admin": "~7.0.0", 17 | "firebase-functions": "^2.3.0" 18 | }, 19 | "devDependencies": { 20 | "eslint": "^5.12.0", 21 | "eslint-plugin-promise": "^4.0.1", 22 | "firebase-functions-test": "^0.1.6" 23 | }, 24 | "private": true 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/base/BaseAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.base; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.recyclerview.widget.RecyclerView; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public abstract class BaseAdapter extends RecyclerView.Adapter { 10 | 11 | protected final List dataList = new ArrayList<>(); 12 | 13 | public void setData(@NonNull List newDataList){ 14 | dataList.clear(); 15 | dataList.addAll(newDataList); 16 | notifyDataSetChanged(); 17 | } 18 | 19 | @Override 20 | public int getItemCount() { 21 | return dataList.size(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/router/HighscoreRouter.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.router; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import com.example.qwez.ui.highscore.HighscoreActivity; 9 | 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | public class HighscoreRouter { 13 | 14 | public void open(@NonNull Context context, boolean clearStack){ 15 | Intent intent = new Intent(context, HighscoreActivity.class); 16 | if (clearStack) { 17 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); 18 | } 19 | context.startActivity(intent); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/validator/PatternValidate.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.validator; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import java.util.regex.Pattern; 6 | 7 | /** 8 | * Validate extension Class that for Regex Matching 9 | */ 10 | public class PatternValidate extends Validate { 11 | private final Pattern pattern; 12 | 13 | public PatternValidate(String errorMessage, @NonNull Pattern pattern) { 14 | super(errorMessage); 15 | this.pattern = pattern; 16 | } 17 | 18 | /** 19 | * Check if String is valid by matching to Regex Pattern 20 | * @param textToCheck to check 21 | * @return true if valid 22 | */ 23 | public boolean isValid(String textToCheck) { 24 | return pattern.matcher(textToCheck).matches(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/bus/event/LoginEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.bus.event; 2 | 3 | /** 4 | * POJO class for {@link com.example.qwez.bus.RxBus} event type. 5 | * final variable value and getter(s). 6 | */ 7 | public class LoginEvent { 8 | 9 | private final String email; 10 | private final String password; 11 | private final boolean rememberMe; 12 | 13 | public LoginEvent(String email, String password, boolean rememberMe) { 14 | this.email = email; 15 | this.password = password; 16 | this.rememberMe = rememberMe; 17 | } 18 | 19 | public String getEmail() { 20 | return email; 21 | } 22 | 23 | public String getPassword() { 24 | return password; 25 | } 26 | 27 | public boolean isRememberMe() { 28 | return rememberMe; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /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 | android.enableJetifier=true 10 | android.useAndroidX=true 11 | org.gradle.jvmargs=-Xmx1536m 12 | # When configured, Gradle will run in incubating parallel mode. 13 | # This option should only be used with decoupled projects. More details, visit 14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 15 | # org.gradle.parallel=true 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/router/QuestionRouter.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.router; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import com.example.qwez.ui.question.QuestionActivity; 9 | import com.example.qwez.util.ExtrasConstant; 10 | 11 | /** 12 | * Opens QuestionActivity.class 13 | */ 14 | public class QuestionRouter { 15 | 16 | /** 17 | * Open QuestionActivity.class 18 | * @param context of current Activity 19 | * @param qId clear Activity stack. true clears stack 20 | */ 21 | public void open(@NonNull Context context, int qId){ 22 | Intent intent = new Intent(context, QuestionActivity.class); 23 | intent.putExtra(ExtrasConstant.QUESTION_ID, qId); 24 | context.startActivity(intent); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/local/dao/GameDao.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.local.dao; 2 | 3 | import androidx.room.Dao; 4 | import androidx.room.Insert; 5 | import androidx.room.Query; 6 | 7 | import com.example.qwez.repository.local.entity.Game; 8 | 9 | import java.util.List; 10 | 11 | import io.reactivex.Completable; 12 | import io.reactivex.Flowable; 13 | import io.reactivex.Single; 14 | 15 | /** 16 | * Dao for @Entity Game 17 | */ 18 | @Dao 19 | public interface GameDao extends BaseDao { 20 | 21 | @Insert 22 | long insertReturnId(Game game); 23 | 24 | @Query("SELECT * FROM games") 25 | Flowable> getAll(); 26 | 27 | @Query("DELETE FROM games WHERE id=:id") 28 | Completable deleteById(int id); 29 | 30 | @Query("SELECT * FROM games WHERE id=:id") 31 | Single getGameById(int id); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/router/LoginRouter.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.router; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import com.example.qwez.ui.login.LoginActivity; 9 | 10 | /** 11 | * Opens LoginActivity.class 12 | */ 13 | public class LoginRouter { 14 | 15 | /** 16 | * Open LoginActivity.class 17 | * @param context of current Activity 18 | * @param clearStack clear Activity stack. true clears stack 19 | */ 20 | public void open(@NonNull Context context, boolean clearStack){ 21 | Intent intent = new Intent(context, LoginActivity.class); 22 | if (clearStack) { 23 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); 24 | } 25 | context.startActivity(intent); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/highscore/HighscoreVMFactory.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.highscore; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.lifecycle.ViewModel; 5 | import androidx.lifecycle.ViewModelProvider; 6 | 7 | import com.example.qwez.interactor.GetHighscoreInteractor; 8 | 9 | public class HighscoreVMFactory implements ViewModelProvider.Factory { 10 | 11 | private final GetHighscoreInteractor getUserHighscoreInteractor; 12 | 13 | HighscoreVMFactory(GetHighscoreInteractor getUserHighscoreInteractor) { 14 | this.getUserHighscoreInteractor = getUserHighscoreInteractor; 15 | } 16 | 17 | @SuppressWarnings("unchecked") 18 | @NonNull 19 | @Override 20 | public T create(@NonNull Class modelClass) { 21 | return (T) new HighscoreViewmodel(getUserHighscoreInteractor); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/validator/Validate.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.validator; 2 | 3 | /** 4 | * Abstract Class for Validation 5 | */ 6 | public abstract class Validate { 7 | protected String errorMessage; 8 | 9 | public Validate(String errorMessage) { 10 | this.errorMessage = errorMessage; 11 | } 12 | 13 | /** 14 | * Checks if {@code textToCheck} is valid 15 | * @param textToCheck to check 16 | * @return true if valid 17 | */ 18 | public abstract boolean isValid(String textToCheck); 19 | 20 | /** 21 | * @return true is Validate has error message 22 | */ 23 | public boolean hasErrorMessage() { 24 | return errorMessage != null; 25 | } 26 | 27 | /** 28 | * @return error message 29 | */ 30 | public String getErrorMessage() { 31 | return errorMessage; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/router/SettingsRouter.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.router; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import com.example.qwez.ui.settings.SettingsActivity; 9 | 10 | /** 11 | * Opens SettingsActivity.class 12 | */ 13 | public class SettingsRouter { 14 | 15 | /** 16 | * Open SettingsActivity.class 17 | * @param context of current Activity 18 | * @param clearStack clear Activity stack. true clears stack 19 | */ 20 | public void open(@NonNull Context context, boolean clearStack){ 21 | Intent intent = new Intent(context, SettingsActivity.class); 22 | if (clearStack) { 23 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); 24 | } 25 | context.startActivity(intent); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/LogoutUserInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import com.example.qwez.repository.firebase.FirebaseAuthRepositoryType; 4 | 5 | import io.reactivex.Completable; 6 | import io.reactivex.android.schedulers.AndroidSchedulers; 7 | 8 | /** 9 | * Interactor to log out FirebaseUser 10 | */ 11 | public class LogoutUserInteractor { 12 | 13 | private final FirebaseAuthRepositoryType firebaseAuthRepositoryType; 14 | 15 | public LogoutUserInteractor(FirebaseAuthRepositoryType firebaseAuthRepositoryType) { 16 | this.firebaseAuthRepositoryType = firebaseAuthRepositoryType; 17 | } 18 | 19 | /** 20 | * Log out FirebaseUser 21 | * @return Completable 22 | */ 23 | public Completable logout(){ 24 | return firebaseAuthRepositoryType.logoutUser() 25 | .observeOn(AndroidSchedulers.mainThread()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/router/StartRouter.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.router; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import com.example.qwez.ui.start.StartActivity; 9 | 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | /** 13 | * Opens StartActivity.class 14 | */ 15 | public class StartRouter { 16 | 17 | /** 18 | * Open StartActivity.class 19 | * @param context of current Activity 20 | * @param clearStack clear Activity stack. true clears stack 21 | */ 22 | public void open(@NonNull Context context, boolean clearStack){ 23 | Intent intent = new Intent(context, StartActivity.class); 24 | if (clearStack) { 25 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); 26 | } 27 | context.startActivity(intent); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/firebase/rxwrapper/FirebaseFunctionsWrapper.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.firebase.rxwrapper; 2 | 3 | import com.google.firebase.functions.FirebaseFunctions; 4 | import com.google.firebase.functions.HttpsCallableResult; 5 | 6 | import io.reactivex.Single; 7 | 8 | public final class FirebaseFunctionsWrapper { 9 | 10 | public static Single performFunction(FirebaseFunctions functions, String function, Object data){ 11 | return Single.create(emitter -> functions.getHttpsCallable(function) 12 | .call(data) 13 | .addOnSuccessListener(emitter::onSuccess) 14 | .addOnFailureListener(emitter::onError)); 15 | } 16 | 17 | public static Single performFunction(FirebaseFunctions functions, String function){ 18 | return performFunction(functions, function, null); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/opentdb/OpenTDBAPI.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.opentdb; 2 | 3 | 4 | import com.example.qwez.repository.opentdb.entity.ResponseBody; 5 | 6 | import io.reactivex.Observable; 7 | import retrofit2.Response; 8 | import retrofit2.http.GET; 9 | import retrofit2.http.Query; 10 | 11 | public interface OpenTDBAPI { 12 | 13 | /** 14 | * Get Question from API 15 | * @param amount of questions to get 16 | * @param category Question category 17 | * @param difficulty Question difficulty 18 | * @param type Question type 19 | * @return Retrofit Response with List of Question 20 | */ 21 | @GET("api.php?") 22 | Observable> getQuestions( 23 | @Query("amount") int amount, 24 | @Query("category") int category, 25 | @Query("difficulty") String difficulty, 26 | @Query("type") String type 27 | ); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/local/GameDatabase.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.local; 2 | 3 | import androidx.room.Database; 4 | import androidx.room.RoomDatabase; 5 | 6 | import com.example.qwez.repository.local.dao.GameDao; 7 | import com.example.qwez.repository.local.dao.GameQuestionDao; 8 | import com.example.qwez.repository.local.dao.QuestionDao; 9 | import com.example.qwez.repository.local.entity.Game; 10 | import com.example.qwez.repository.local.entity.Question; 11 | 12 | /** 13 | * Application Database Class. 14 | * 15 | * Provides Dao(s) 16 | */ 17 | @Database(entities = {Game.class, Question.class}, version = 2) 18 | public abstract class GameDatabase extends RoomDatabase { 19 | 20 | public static final String DATABASE_NAME = "game_database"; 21 | 22 | public abstract GameDao gameDao(); 23 | 24 | public abstract QuestionDao questionDao(); 25 | 26 | public abstract GameQuestionDao gameQuestionDao(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/settings.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/highscore/HighscoreModule.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.highscore; 2 | 3 | import com.example.qwez.interactor.GetHighscoreInteractor; 4 | import com.example.qwez.repository.firebase.FirebaseAuthRepositoryType; 5 | import com.example.qwez.repository.firebase.FirebaseDatabaseType; 6 | 7 | import dagger.Module; 8 | import dagger.Provides; 9 | 10 | @Module 11 | public class HighscoreModule { 12 | 13 | @Provides 14 | GetHighscoreInteractor getUserHighscoreInteractor(FirebaseDatabaseType firebaseDatabaseType, 15 | FirebaseAuthRepositoryType firebaseAuthRepositoryType){ 16 | return new GetHighscoreInteractor(firebaseDatabaseType, firebaseAuthRepositoryType); 17 | } 18 | 19 | @Provides 20 | HighscoreVMFactory highscoreVMFactory(GetHighscoreInteractor getUserHighscoreInteractor){ 21 | return new HighscoreVMFactory(getUserHighscoreInteractor); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/DeleteGameInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import com.example.qwez.repository.local.GameRepositoryType; 4 | import com.example.qwez.repository.local.entity.Game; 5 | 6 | import io.reactivex.Completable; 7 | import io.reactivex.android.schedulers.AndroidSchedulers; 8 | 9 | /** 10 | * Interactor for deleting games. 11 | */ 12 | public class DeleteGameInteractor { 13 | 14 | private final GameRepositoryType gameRepositoryType; 15 | 16 | public DeleteGameInteractor(GameRepositoryType gameRepositoryType){ 17 | this.gameRepositoryType = gameRepositoryType; 18 | } 19 | 20 | /** 21 | * Delete {@code game} from local database 22 | * @param game @Entity object to delete 23 | * @return Completable 24 | */ 25 | public Completable deleteGame(Game game){ 26 | return gameRepositoryType.deleteGame(game) 27 | .observeOn(AndroidSchedulers.mainThread()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/di/SharedPreferencesModule.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.di; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | import com.example.qwez.repository.sharedpref.SharedPreferencesRepository; 7 | import com.example.qwez.repository.sharedpref.SharedPreferencesRepositoryType; 8 | 9 | import dagger.Module; 10 | import dagger.Provides; 11 | 12 | @Module 13 | public class SharedPreferencesModule { 14 | 15 | private static final String SHARED_PREFS = "shared prefs qwez"; 16 | 17 | @Provides 18 | @ApplicationScope 19 | SharedPreferencesRepositoryType sharedPreferencesRepositoryType(SharedPreferences sharedPreferences){ 20 | return new SharedPreferencesRepository(sharedPreferences); 21 | } 22 | 23 | @Provides 24 | @ApplicationScope 25 | SharedPreferences sharedPreferences(Context context){ 26 | return context.getSharedPreferences(SHARED_PREFS, Context.MODE_PRIVATE); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/highscore/recyclerview/HighscoreAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.highscore.recyclerview; 2 | 3 | import android.view.ViewGroup; 4 | 5 | import androidx.annotation.NonNull; 6 | 7 | import com.example.qwez.R; 8 | import com.example.qwez.base.BaseAdapter; 9 | import com.example.qwez.entity.Highscore; 10 | 11 | public class HighscoreAdapter extends BaseAdapter { 12 | 13 | public HighscoreAdapter() { 14 | } 15 | 16 | @NonNull 17 | @Override 18 | public HighscoreHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 19 | return new HighscoreHolder(R.layout.item_highscore, parent); 20 | } 21 | 22 | @Override 23 | public void onBindViewHolder(@NonNull HighscoreHolder holder, int position) { 24 | holder.bind(dataList.get(position)); 25 | } 26 | 27 | @Override 28 | public int getItemCount() { 29 | return dataList.size(); 30 | } 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/GetUserInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import com.example.qwez.repository.firebase.FirebaseAuthRepositoryType; 4 | import com.google.firebase.auth.FirebaseUser; 5 | 6 | import io.reactivex.Observable; 7 | import io.reactivex.android.schedulers.AndroidSchedulers; 8 | 9 | /** 10 | * Interactor to get FirebaseUser 11 | */ 12 | public class GetUserInteractor { 13 | 14 | private final FirebaseAuthRepositoryType firebaseAuthRepositoryType; 15 | 16 | public GetUserInteractor(FirebaseAuthRepositoryType firebaseAuthRepositoryType) { 17 | this.firebaseAuthRepositoryType = firebaseAuthRepositoryType; 18 | } 19 | 20 | /** 21 | * Get user 22 | * @return Observable which emits FirebaseUser object 23 | */ 24 | public Observable getUser(){ 25 | return firebaseAuthRepositoryType.getCurrentUser() 26 | .observeOn(AndroidSchedulers.mainThread()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #92D1C3 6 | #8BB8A8 7 | #FFD5FF 8 | #B47EB3 9 | #FDF5BF 10 | 11 | 12 | #C0FFE0 13 | #00c262 14 | #FF8400 15 | #FFFFE0 16 | #E00000 17 | #FA8072 18 | 19 | 20 | #D81B60 21 | #9F0000 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/local/dao/QuestionDao.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.local.dao; 2 | 3 | import androidx.room.Dao; 4 | import androidx.room.Query; 5 | import androidx.room.Update; 6 | 7 | import com.example.qwez.repository.local.entity.Question; 8 | 9 | import java.util.List; 10 | 11 | import io.reactivex.Completable; 12 | import io.reactivex.Flowable; 13 | import io.reactivex.Single; 14 | 15 | /** 16 | * Dao for Question 17 | */ 18 | @Dao 19 | public interface QuestionDao extends BaseDao { 20 | 21 | @Query("SELECT * FROM questions") 22 | Single> getAll(); 23 | 24 | @Query("DELETE FROM questions WHERE question_id=:id") 25 | Completable deleteById(int id); 26 | 27 | @Update 28 | Single insertAndReturnId(Question question); 29 | 30 | @Query("SELECT * FROM QUESTIONS where id=:id") 31 | Single getById(int id); 32 | 33 | @Query("SELECT * FROM QUESTIONS where question_id=:id") 34 | Flowable> getAllQuestionsByGameId(int id); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/service/MyFirebaseMessagingService.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.service; 2 | 3 | import com.google.firebase.messaging.FirebaseMessagingService; 4 | import com.google.firebase.messaging.RemoteMessage; 5 | 6 | //preperation for new features 7 | public class MyFirebaseMessagingService extends FirebaseMessagingService { 8 | 9 | public MyFirebaseMessagingService() { 10 | super(); 11 | } 12 | 13 | @Override 14 | public void onMessageReceived(RemoteMessage remoteMessage) { 15 | super.onMessageReceived(remoteMessage); 16 | } 17 | 18 | @Override 19 | public void onDeletedMessages() { 20 | super.onDeletedMessages(); 21 | } 22 | 23 | @Override 24 | public void onMessageSent(String s) { 25 | super.onMessageSent(s); 26 | } 27 | 28 | @Override 29 | public void onSendError(String s, Exception e) { 30 | super.onSendError(s, e); 31 | } 32 | 33 | @Override 34 | public void onNewToken(String s) { 35 | super.onNewToken(s); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/FirstTimeInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import com.example.qwez.repository.sharedpref.SharedPreferencesRepositoryType; 4 | 5 | import io.reactivex.Completable; 6 | import io.reactivex.Single; 7 | import io.reactivex.android.schedulers.AndroidSchedulers; 8 | 9 | public class FirstTimeInteractor { 10 | 11 | private final SharedPreferencesRepositoryType sharedPreferencesRepositoryType; 12 | 13 | public FirstTimeInteractor(SharedPreferencesRepositoryType sharedPreferencesRepositoryType) { 14 | this.sharedPreferencesRepositoryType = sharedPreferencesRepositoryType; 15 | } 16 | 17 | public Single checkNotFirstTime(){ 18 | return sharedPreferencesRepositoryType.getNotFirstTime() 19 | .observeOn(AndroidSchedulers.mainThread()); 20 | } 21 | 22 | public Completable setNotFirstTime(){ 23 | return sharedPreferencesRepositoryType.setNotFirstTime(true) 24 | .observeOn(AndroidSchedulers.mainThread()); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/GetAllGamesInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import com.example.qwez.repository.local.GameRepositoryType; 4 | import com.example.qwez.repository.local.entity.Game; 5 | 6 | import java.util.List; 7 | 8 | import io.reactivex.Flowable; 9 | import io.reactivex.android.schedulers.AndroidSchedulers; 10 | 11 | /** 12 | * Interactor to get all games. 13 | */ 14 | public class GetAllGamesInteractor { 15 | 16 | private final GameRepositoryType gameRepositoryType; 17 | 18 | public GetAllGamesInteractor(GameRepositoryType gameRepositoryType) { 19 | this.gameRepositoryType = gameRepositoryType; 20 | } 21 | 22 | /** 23 | * Get all Games continually. 24 | * @return Flowable that emitts Game object, once on subscribe, and there after emitts 25 | * on each change in database 26 | */ 27 | public Flowable> getAllGames(){ 28 | return gameRepositoryType 29 | .getAllGames() 30 | .observeOn(AndroidSchedulers.mainThread()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_add_question.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 18 | 19 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/splash/SplashModule.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.splash; 2 | 3 | import com.example.qwez.interactor.GetUserInteractor; 4 | import com.example.qwez.repository.firebase.FirebaseAuthRepositoryType; 5 | import com.example.qwez.router.LoginRouter; 6 | import com.example.qwez.router.StartRouter; 7 | 8 | import dagger.Module; 9 | import dagger.Provides; 10 | 11 | @Module 12 | public class SplashModule { 13 | 14 | @Provides 15 | SplashVMFactory splashVMFactory(StartRouter startRouter, GetUserInteractor getUserInteractor, LoginRouter loginRouter){ 16 | return new SplashVMFactory(startRouter, getUserInteractor, loginRouter); 17 | } 18 | 19 | @Provides 20 | GetUserInteractor getUserInteractor(FirebaseAuthRepositoryType firebaseAuthRepositoryType){ 21 | return new GetUserInteractor(firebaseAuthRepositoryType); 22 | } 23 | 24 | @Provides 25 | LoginRouter loginRouter(){ 26 | return new LoginRouter(); 27 | } 28 | 29 | @Provides 30 | StartRouter startRouter(){ 31 | return new StartRouter(); 32 | } 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/LoginUserInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.example.qwez.repository.firebase.FirebaseAuthRepositoryType; 6 | 7 | import io.reactivex.Completable; 8 | import io.reactivex.android.schedulers.AndroidSchedulers; 9 | 10 | /** 11 | * Interactor to log in FirebaseUser 12 | */ 13 | public class LoginUserInteractor { 14 | 15 | private final FirebaseAuthRepositoryType firebaseAuthRepositoryType; 16 | 17 | public LoginUserInteractor(FirebaseAuthRepositoryType firebaseAuthRepositoryType) { 18 | this.firebaseAuthRepositoryType = firebaseAuthRepositoryType; 19 | } 20 | 21 | /** 22 | * Log in user 23 | * @param email user email address 24 | * @param password user password 25 | * @return Completable 26 | */ 27 | public Completable login(@NonNull String email, @NonNull String password){ 28 | return firebaseAuthRepositoryType.signInUserEmailAndPassword(email, password) 29 | .observeOn(AndroidSchedulers.mainThread()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/SignupInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.example.qwez.repository.firebase.FirebaseAuthRepositoryType; 6 | 7 | import io.reactivex.Completable; 8 | import io.reactivex.android.schedulers.AndroidSchedulers; 9 | 10 | /** 11 | * Interactor to sign up a new FirebaseUser 12 | */ 13 | public class SignupInteractor { 14 | 15 | private final FirebaseAuthRepositoryType firebaseAuthRepositoryType; 16 | 17 | public SignupInteractor(FirebaseAuthRepositoryType firebaseAuthRepositoryType) { 18 | this.firebaseAuthRepositoryType = firebaseAuthRepositoryType; 19 | } 20 | 21 | /** 22 | * Sign up new FirebaseUser 23 | * @param email user email address 24 | * @param password user password 25 | * @return Completable 26 | */ 27 | public Completable signupUser(@NonNull String email, @NonNull String password){ 28 | return Completable.fromMaybe(firebaseAuthRepositoryType.createUserEmailAndPassword(email, password) 29 | .observeOn(AndroidSchedulers.mainThread())); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/splash/SplashVMFactory.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.splash; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.lifecycle.ViewModel; 5 | import androidx.lifecycle.ViewModelProvider; 6 | 7 | import com.example.qwez.interactor.GetUserInteractor; 8 | import com.example.qwez.router.LoginRouter; 9 | import com.example.qwez.router.StartRouter; 10 | 11 | public class SplashVMFactory implements ViewModelProvider.Factory { 12 | 13 | private final StartRouter startRouter; 14 | private final GetUserInteractor getUserInteractor; 15 | private final LoginRouter loginRouter; 16 | 17 | SplashVMFactory(StartRouter startRouter, GetUserInteractor getUserInteractor, LoginRouter loginRouter) { 18 | this.startRouter = startRouter; 19 | this.getUserInteractor = getUserInteractor; 20 | this.loginRouter = loginRouter; 21 | } 22 | 23 | @SuppressWarnings("unchecked") 24 | @NonNull 25 | @Override 26 | public T create(@NonNull Class modelClass) { 27 | return (T) new SplashViewModel(startRouter, loginRouter, getUserInteractor); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_confirm_pass.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/local/dao/GameQuestionDao.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.local.dao; 2 | 3 | import androidx.room.Dao; 4 | import androidx.room.Insert; 5 | import androidx.room.Query; 6 | import androidx.room.Transaction; 7 | 8 | import com.example.qwez.repository.local.entity.GameQuestion; 9 | import com.example.qwez.repository.local.entity.Question; 10 | 11 | import java.util.List; 12 | 13 | import io.reactivex.Completable; 14 | import io.reactivex.Flowable; 15 | import io.reactivex.Single; 16 | 17 | /** 18 | * Dao for GameQuestion objects 19 | */ 20 | @Dao 21 | public interface GameQuestionDao { 22 | 23 | @Transaction 24 | @Query("SELECT * FROM games") 25 | Flowable> getGameQuestions(); 26 | 27 | @Transaction 28 | @Query("SELECT * FROM games WHERE id=:id") 29 | Flowable getGameQuestionById(int id); 30 | 31 | 32 | @Transaction 33 | @Query("SELECT * FROM questions where questions.answer_chosen=questions.correct_answer and questions.question_id=:gameId") 34 | Single> getPoints(int gameId); 35 | //can't manage to get it to return GameQuestion Object? 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "961562256854", 4 | "firebase_url": "https://qwez-take-2.firebaseio.com", 5 | "project_id": "qwez-take-2", 6 | "storage_bucket": "qwez-take-2.appspot.com" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:961562256854:android:30245e41159ed5f1", 12 | "android_client_info": { 13 | "package_name": "com.example.qwez" 14 | } 15 | }, 16 | "oauth_client": [ 17 | { 18 | "client_id": "961562256854-sepn33a3fkcolh37up20i6f34tlir5q7.apps.googleusercontent.com", 19 | "client_type": 3 20 | } 21 | ], 22 | "api_key": [ 23 | { 24 | "current_key": "AIzaSyBZUnUV_cUMgju6ZXl5fld2-0Q1D5eT2FU" 25 | } 26 | ], 27 | "services": { 28 | "appinvite_service": { 29 | "other_platform_oauth_client": [ 30 | { 31 | "client_id": "961562256854-sepn33a3fkcolh37up20i6f34tlir5q7.apps.googleusercontent.com", 32 | "client_type": 3 33 | } 34 | ] 35 | } 36 | } 37 | } 38 | ], 39 | "configuration_version": "1" 40 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/firebase/rxwrapper/FirebaseStorageWrapper.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.firebase.rxwrapper; 2 | 3 | import android.net.Uri; 4 | 5 | import com.google.firebase.storage.StorageReference; 6 | import com.google.firebase.storage.StorageTask; 7 | import com.google.firebase.storage.UploadTask; 8 | 9 | import io.reactivex.Maybe; 10 | import io.reactivex.Single; 11 | 12 | public final class FirebaseStorageWrapper { 13 | 14 | public static Single putFile(StorageReference reference, Uri uri){ 15 | return Single.create(emitter -> { 16 | StorageTask task = reference.putFile(uri) 17 | .addOnSuccessListener(emitter::onSuccess) 18 | .addOnFailureListener(e -> { 19 | if(!emitter.isDisposed()){ 20 | emitter.onError(e); 21 | } 22 | }); 23 | emitter.setCancellable(task::cancel); 24 | }); 25 | } 26 | 27 | public static Maybe getDownloadUrl(StorageReference ref) { 28 | return Maybe.create(emitter -> MaybeTask.assign(emitter, ref.getDownloadUrl())); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/highscore/recyclerview/HighscoreHolder.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.highscore.recyclerview; 2 | 3 | import android.view.ViewGroup; 4 | import android.widget.TextView; 5 | 6 | import androidx.annotation.LayoutRes; 7 | import androidx.annotation.Nullable; 8 | 9 | import com.example.qwez.R; 10 | import com.example.qwez.base.BaseViewHolder; 11 | import com.example.qwez.entity.Highscore; 12 | 13 | import butterknife.BindView; 14 | 15 | public class HighscoreHolder extends BaseViewHolder { 16 | 17 | @BindView(R.id.highscore_nick) 18 | TextView nick; 19 | @BindView(R.id.highscore_score) 20 | TextView score; 21 | 22 | /** 23 | * Create a BaseViewHolder with {@code layoutRes} layout 24 | * 25 | * @param layoutRes 26 | * @param parent 27 | */ 28 | HighscoreHolder(@LayoutRes int layoutRes, ViewGroup parent) { 29 | super(layoutRes, parent); 30 | } 31 | 32 | @Override 33 | public void bind(@Nullable Highscore data) { 34 | if(data != null){ 35 | this.data = data; 36 | nick.setText(data.getNick()); 37 | score.setText(String.format("%s points", data.getScore())); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/qwez/util/QuestionConverterTest.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.util; 2 | 3 | import com.example.qwez.repository.opentdb.entity.Question; 4 | 5 | import org.junit.Test; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | public class QuestionConverterTest { 13 | 14 | @Test 15 | public void toDatabase() { 16 | 17 | List questions = new ArrayList<>(); 18 | List wrongAnswers = new ArrayList<>(); 19 | wrongAnswers.add("2"); 20 | wrongAnswers.add("3"); 21 | wrongAnswers.add("4"); 22 | 23 | Question question = new Question("categ", "type", "diff", "1?", "1", wrongAnswers); 24 | questions.add(question); 25 | 26 | List converted = QuestionUtil.toDatabase(questions); 27 | 28 | assertEquals(converted.size(),1 ); 29 | com.example.qwez.repository.local.entity.Question questionConverted = converted.get(0); 30 | assertEquals(questionConverted.getCorrectAnswer(), question.getCorrectAnswer()); 31 | assertEquals(questionConverted.getWrongAnswer1(), question.getIncorrectAnswers().get(0)); 32 | 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/login/LoginVMFactory.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.login; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.lifecycle.ViewModel; 5 | import androidx.lifecycle.ViewModelProvider; 6 | 7 | import com.example.qwez.interactor.LoginUserInteractor; 8 | import com.example.qwez.interactor.SignupInteractor; 9 | import com.example.qwez.router.StartRouter; 10 | 11 | public class LoginVMFactory implements ViewModelProvider.Factory { 12 | 13 | private final LoginUserInteractor loginUserInteractor; 14 | private final SignupInteractor signupInteractor; 15 | private final StartRouter startRouter; 16 | 17 | LoginVMFactory(LoginUserInteractor loginUserInteractor, 18 | SignupInteractor signupInteractor, 19 | StartRouter startRouter) { 20 | this.loginUserInteractor = loginUserInteractor; 21 | this.signupInteractor = signupInteractor; 22 | this.startRouter = startRouter; 23 | } 24 | 25 | @SuppressWarnings("unchecked") 26 | @NonNull 27 | @Override 28 | public T create(@NonNull Class modelClass) { 29 | return (T) new LoginViewModel(loginUserInteractor, signupInteractor, startRouter); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/repository/local/dao/BaseDao.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.repository.local.dao; 2 | 3 | import androidx.room.Delete; 4 | import androidx.room.Insert; 5 | import androidx.room.Query; 6 | import androidx.room.Update; 7 | 8 | import io.reactivex.Completable; 9 | 10 | /** 11 | * Base Dao Class that all Dao(s) must implement 12 | */ 13 | public interface BaseDao { 14 | 15 | /** 16 | * Insert T t into database 17 | * @param t object to insert 18 | * @return Completable that emits insertion result 19 | */ 20 | @Insert 21 | Completable insert(T t); 22 | 23 | /** 24 | * Insert T ...t objects into database 25 | * @param t objects to insert 26 | * @return Completable that emits insertion result 27 | */ 28 | @Insert 29 | Completable insert(T ...t); 30 | 31 | /** 32 | * Update T t object in the database 33 | * @param t object to update 34 | * @return Completable that emits update result 35 | */ 36 | @Update 37 | Completable update(T t); 38 | 39 | /** 40 | * Delete T t object in the database 41 | * @param t object to delete 42 | * @return Completable that emits deletion result 43 | */ 44 | @Delete 45 | Completable delete(T t); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/common/ItemDecorator.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.common; 2 | 3 | import android.graphics.Rect; 4 | import android.view.View; 5 | 6 | import androidx.annotation.NonNull; 7 | import androidx.recyclerview.widget.RecyclerView; 8 | 9 | /** 10 | * Custom ItemDecorator class for Recyclerview 11 | * Adds padding to bottom of items in recyclerView. 12 | */ 13 | public class ItemDecorator extends RecyclerView.ItemDecoration { 14 | 15 | //amont of dp of padding 16 | private final int space; 17 | public static final int MARGIN = 5; 18 | 19 | /** 20 | * 21 | * @param space amount of space to add as padding at bottom of each recyclerView (In dp as unit). 22 | */ 23 | public ItemDecorator(int space) { 24 | this.space = space; 25 | } 26 | 27 | /** 28 | * Only set the bottom space if it is not the last item 29 | */ 30 | @Override 31 | public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { 32 | outRect.left = space; 33 | outRect.right = space; 34 | if (parent.getChildAdapterPosition(view) != state.getItemCount()-1) { 35 | outRect.bottom = space * 2; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/ChangeUserNickInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import com.example.qwez.repository.firebase.FirebaseAuthRepositoryType; 4 | import com.example.qwez.repository.firebase.FirebaseDatabaseType; 5 | 6 | import io.reactivex.Completable; 7 | import io.reactivex.android.schedulers.AndroidSchedulers; 8 | 9 | public class ChangeUserNickInteractor { 10 | 11 | private final FirebaseAuthRepositoryType firebaseAuthRepositoryType; 12 | private final FirebaseDatabaseType firebaseDatabaseType; 13 | 14 | public ChangeUserNickInteractor(FirebaseAuthRepositoryType firebaseAuthRepositoryType, FirebaseDatabaseType firebaseDatabaseType) { 15 | this.firebaseAuthRepositoryType = firebaseAuthRepositoryType; 16 | this.firebaseDatabaseType = firebaseDatabaseType; 17 | } 18 | 19 | public Completable changeNick(String nick){ 20 | return firebaseAuthRepositoryType.getCurrentUser() 21 | .take(1) 22 | .flatMapCompletable(firebaseUser -> firebaseAuthRepositoryType.changeUserNick(firebaseUser, nick) 23 | .doOnComplete(() -> firebaseDatabaseType.updateNick(firebaseUser.getUid(), nick))) 24 | .observeOn(AndroidSchedulers.mainThread()); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/ui/start/recycler/CustomAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.ui.start.recycler; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ArrayAdapter; 8 | import android.widget.TextView; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.annotation.Nullable; 12 | 13 | import java.util.List; 14 | 15 | public class CustomAdapter extends ArrayAdapter { 16 | 17 | public CustomAdapter(@NonNull Context context, int resource, @NonNull List objects) { 18 | super(context, resource, objects); 19 | } 20 | 21 | @Override 22 | public boolean isEnabled(int position) { 23 | return position != 0; 24 | } 25 | 26 | @Override 27 | public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { 28 | View view = super.getDropDownView(position, convertView, parent); 29 | TextView tv = (TextView) view; 30 | if(position == 0){ 31 | // Set the hint text color gray 32 | tv.setTextColor(Color.GRAY); 33 | } 34 | else { 35 | tv.setTextColor(Color.BLACK); 36 | } 37 | return view; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/GetAllGamesAndQuestionsInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import com.example.qwez.repository.local.GameRepositoryType; 4 | import com.example.qwez.repository.local.entity.GameQuestion; 5 | 6 | import org.reactivestreams.Publisher; 7 | 8 | import java.util.List; 9 | import java.util.Observable; 10 | 11 | import io.reactivex.Flowable; 12 | import io.reactivex.android.schedulers.AndroidSchedulers; 13 | import io.reactivex.functions.Function; 14 | 15 | /** 16 | * Interactor for getting all games and questions 17 | */ 18 | public class GetAllGamesAndQuestionsInteractor { 19 | 20 | private final GameRepositoryType gameRepositoryType; 21 | 22 | public GetAllGamesAndQuestionsInteractor(GameRepositoryType gameRepositoryType) { 23 | this.gameRepositoryType = gameRepositoryType; 24 | } 25 | 26 | /** 27 | * Get all Games and Questions continually. 28 | * @return Flowable that emitts GameQuestion object, once on subscribe, and there after emitts 29 | * on each change in database 30 | */ 31 | public Flowable> getAllGamesAndQuestions(){ 32 | return gameRepositoryType.getAllGamesAndQuestions() 33 | .observeOn(AndroidSchedulers.mainThread()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/qwez/interactor/UpdateQuestionAndGameInteractor.java: -------------------------------------------------------------------------------- 1 | package com.example.qwez.interactor; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.example.qwez.interactor.rx.Operators; 6 | import com.example.qwez.repository.local.GameRepositoryType; 7 | import com.example.qwez.repository.local.entity.Question; 8 | 9 | import io.reactivex.Completable; 10 | import io.reactivex.android.schedulers.AndroidSchedulers; 11 | import io.reactivex.schedulers.Schedulers; 12 | import timber.log.Timber; 13 | 14 | import static com.example.qwez.interactor.rx.Operators.GAME_MAPPER; 15 | 16 | public class UpdateQuestionAndGameInteractor { 17 | 18 | private final GameRepositoryType gameRepositoryType; 19 | 20 | public UpdateQuestionAndGameInteractor(GameRepositoryType gameRepositoryType) { 21 | this.gameRepositoryType = gameRepositoryType; 22 | } 23 | 24 | public Completable updateQuestion(@NonNull Question question){ 25 | return gameRepositoryType.updateQuestion(question) 26 | //.andThen(gameRepositoryType.getGameById(question.getqId()) 27 | //.map(GAME_MAPPER) 28 | //.flatMapCompletable(gameRepositoryType::updateGame)) 29 | .observeOn(AndroidSchedulers.mainThread()); 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_finish.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 18 | 19 |