diff --git a/Ceres/.gitignore b/Ceres/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/Ceres/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/Ceres/.idea/.gitignore b/Ceres/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Ceres/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Ceres/.idea/AndroidProjectSystem.xml b/Ceres/.idea/AndroidProjectSystem.xml new file mode 100644 index 0000000..4a53bee --- /dev/null +++ b/Ceres/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/Ceres/.idea/compiler.xml b/Ceres/.idea/compiler.xml new file mode 100644 index 0000000..b86273d --- /dev/null +++ b/Ceres/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Ceres/.idea/deploymentTargetSelector.xml b/Ceres/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/Ceres/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/Ceres/.idea/deviceManager.xml b/Ceres/.idea/deviceManager.xml new file mode 100644 index 0000000..91f9558 --- /dev/null +++ b/Ceres/.idea/deviceManager.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/Ceres/.idea/gradle.xml b/Ceres/.idea/gradle.xml new file mode 100644 index 0000000..639c779 --- /dev/null +++ b/Ceres/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/Ceres/.idea/migrations.xml b/Ceres/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/Ceres/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Ceres/.idea/misc.xml b/Ceres/.idea/misc.xml new file mode 100644 index 0000000..b4c5de2 --- /dev/null +++ b/Ceres/.idea/misc.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Ceres/.idea/runConfigurations.xml b/Ceres/.idea/runConfigurations.xml new file mode 100644 index 0000000..16660f1 --- /dev/null +++ b/Ceres/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/Ceres/.idea/studiobot.xml b/Ceres/.idea/studiobot.xml new file mode 100644 index 0000000..539e3b8 --- /dev/null +++ b/Ceres/.idea/studiobot.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/Ceres/.idea/vcs.xml b/Ceres/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Ceres/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Ceres/app/.gitignore b/Ceres/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/Ceres/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/Ceres/app/build.gradle.kts b/Ceres/app/build.gradle.kts new file mode 100644 index 0000000..f18877d --- /dev/null +++ b/Ceres/app/build.gradle.kts @@ -0,0 +1,53 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) +} + +android { + namespace = "com.example.ceres" + compileSdk = 34 + + defaultConfig { + applicationId = "com.example.ceres" + minSdk = 24 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } +} + +dependencies { + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.material) + implementation(libs.androidx.activity) + implementation(libs.androidx.constraintlayout) + + // API & Image Loading + implementation(libs.retrofit) + implementation(libs.retrofit.converter.gson) + implementation(libs.glide) + + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) +} \ No newline at end of file diff --git a/Ceres/app/proguard-rules.pro b/Ceres/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/Ceres/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/Ceres/app/src/androidTest/java/com/example/ceres/ExampleInstrumentedTest.kt b/Ceres/app/src/androidTest/java/com/example/ceres/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..e1b258c --- /dev/null +++ b/Ceres/app/src/androidTest/java/com/example/ceres/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.ceres + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.example.ceres", appContext.packageName) + } +} \ No newline at end of file diff --git a/Ceres/app/src/main/AndroidManifest.xml b/Ceres/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..667e89c --- /dev/null +++ b/Ceres/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ceres/app/src/main/java/com/example/ceres/MainActivity.kt b/Ceres/app/src/main/java/com/example/ceres/MainActivity.kt new file mode 100644 index 0000000..f80696a --- /dev/null +++ b/Ceres/app/src/main/java/com/example/ceres/MainActivity.kt @@ -0,0 +1,218 @@ +package com.example.ceres + +import android.graphics.drawable.Drawable +import android.os.Bundle +import android.text.Html +import android.view.View +import android.widget.Button +import android.widget.ImageView +import android.widget.LinearLayout +import android.widget.ProgressBar +import android.widget.ScrollView +import android.widget.TextView +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import com.bumptech.glide.Glide +import com.bumptech.glide.load.DataSource +import com.bumptech.glide.load.engine.GlideException +import com.bumptech.glide.request.RequestListener +import com.bumptech.glide.request.target.Target +import com.google.android.material.button.MaterialButton +import com.google.gson.annotations.SerializedName +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import retrofit2.http.GET +import retrofit2.http.Query + +// --- API Models --- +data class RandomUserResponse(val results: List) +data class User(val name: UserName, val email: String, val location: UserLocation) +data class UserName(val first: String, val last: String) +data class UserLocation(val city: String, val country: String) + +data class TriviaResponse(val results: List) +data class TriviaQuestion( + val question: String, + @SerializedName("correct_answer") val correctAnswer: String, + @SerializedName("incorrect_answers") val incorrectAnswers: List +) + +data class DogResponse(val message: String) +data class YesNoResponse(val image: String, val answer: String) + +// --- Retrofit Interfaces --- +interface ApiService { + @GET("https://randomuser.me/api/") + fun getRandomUser(): Call + + @GET("https://opentdb.com/api.php") + fun getTrivia(@Query("amount") amount: Int = 1): Call + + @GET("https://dog.ceo/api/breeds/image/random") + fun getRandomDog(): Call + + @GET("https://yesno.wtf/api") + fun getYesNo(): Call +} + +class MainActivity : AppCompatActivity() { + + private lateinit var apiService: ApiService + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContentView(R.layout.activity_main) + + val mainLayout = findViewById(R.id.main) + val firstScreen = findViewById(R.id.firstScreen) + val secondScreen = findViewById(R.id.secondScreen) + val btnGenerate = findViewById