Skip to content
Snippets Groups Projects
Commit e52cd730 authored by SaiArrow's avatar SaiArrow
Browse files

Lab2 Added

parent 7f7e54b6
No related branches found
No related tags found
No related merge requests found
Showing
with 305 additions and 0 deletions
File added
.idea/
.gradle/
build/
*.log
local.properties
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'androidx.navigation.safeargs'
}
android {
compileSdkVersion build_versions.compile_sdk
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation deps.core_ktx
implementation deps.activity.activity_ktx
implementation deps.fragment.fragment_ktx
implementation deps.app_compat
implementation deps.material
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="course.examples.theanswer">
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.App" >
<activity
android:name="course.examples.theanswer.TheAnswer"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package course.examples.theanswer
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import course.examples.theanswer.databinding.AnswerLayoutBinding
class TheAnswer : AppCompatActivity() {
companion object {
private val answers = intArrayOf(42, -10, 0, 100, 1000)
private const val answer = 42
}
override fun onCreate(savedInstanceState: Bundle?) {
// Required call through to Activity.onCreate()‹
// Restore any saved instance state
super.onCreate(savedInstanceState)
// Set up the application's user interface (content view)
val binding = AnswerLayoutBinding.inflate(layoutInflater)
setContentView(binding.root)
val value = findAnswer()
val output =
if (value == answer) answer.toString() else getString(R.string.never_know_string)
// Get a reference to a TextView in the content view
// Set desired text in answerView TextView
binding.answerView.text = output
}
private fun findAnswer(): Int? {
// Incorrect behavior
return answers.firstOrNull { it == -answer }
// Correct behavior
// return answers.firstOrNull { it == answer }
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/rippleColor">
<item>
<selector>
<item android:state_checked="true">
<color android:color="?attr/colorControlHighlight" />
</item>
</selector>
</item>
</ripple>
\ No newline at end of file
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_margin">
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_margin"
android:text="@string/question_string"
android:textAppearance="@android:style/TextAppearance.Material.Display1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/answer_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Material.Display3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_view"
app:layout_constraintVertical_bias="0.5" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Labs/Lab2_DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-hdpi/ic_launcher.png

7.48 KiB

Labs/Lab2_DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-mdpi/ic_launcher.png

3.69 KiB

Labs/Lab2_DevelopmentEnvironment/TheAnswer/app/src/main/res/mipmap-xhdpi/ic_launcher.png

12.2 KiB

<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.App" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/md_theme_dark_primary</item>
<item name="colorPrimaryVariant">@color/md_theme_dark_primaryContainer</item>
<item name="colorOnPrimary">@color/md_theme_dark_onPrimary</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/md_theme_dark_tertiary</item>
<item name="colorSecondaryVariant">@color/md_theme_dark_secondaryContainer</item>
<item name="colorOnSecondary">@color/md_theme_dark_onSecondary</item>
<item name="colorAccent">@color/md_theme_dark_tertiary</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<item name="android:selectableItemBackground" tools:targetApi="l">@drawable/background_selector</item>
<item name="rippleColor">@color/ripple_dark</item>
</style>
</resources>
\ No newline at end of file
<resources>
<color name="md_theme_light_primary">#2196F3</color>
<color name="md_theme_light_onPrimary">#FFFFFF</color>
<color name="md_theme_light_primaryContainer">#1976D2</color>
<color name="md_theme_light_onPrimaryContainer">#001D36</color>
<color name="md_theme_light_secondary">#005FB1</color>
<color name="md_theme_light_onSecondary">#FFFFFF</color>
<color name="md_theme_light_secondaryContainer">#D3E3FF</color>
<color name="md_theme_light_tertiary">#EF5350</color>
<color name="md_theme_dark_primary">#9BCAFF</color>
<color name="md_theme_dark_onPrimary">#226AA2</color>
<color name="md_theme_dark_primaryContainer">#00497E</color>
<color name="md_theme_dark_secondary">#A4C8FF</color>
<color name="md_theme_dark_onSecondary">#003060</color>
<color name="md_theme_dark_secondaryContainer">#004788</color>
<color name="md_theme_dark_tertiary">#CF7C77</color>
<color name="ripple_light">#40FFFFFF</color>
<color name="ripple_dark">#40000000</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<!-- Old colors -->
<color name="red">#CC0000</color>
<color name="green">#00FF00</color>
<color name="blue">#0000FF</color>
<color name="yellow">#FFFF00</color>
<color name="gold">#FFD700</color>
<color name="primary">#FF5722</color>
<color name="primary_dark">#E64A19</color>
<color name="primary_light">#FFCCBC</color>
<color name="primary_disabled">#FFF8AD96</color>
<color name="accent">#536DFE</color>
<color name="primary_text">#212121</color>
<color name="secondary_text">#757575</color>
<color name="icons">#FFFFFF</color>
<color name="divider">#BDBDBD</color>
<color name="edit_text">#202020</color>
<color name="black_text_87">#DE000000</color>
<color name="black_text_54">#8A000000</color>
<color name="background_color">#08237e</color>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_margin">16dp</dimen>
<dimen name="list_item_padding">8dp</dimen>
<dimen name="content_area_padding">8dp</dimen>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TheAnswer</string>
<string name="question_string">The answer to life, the universe and everything is:</string>
<string name="never_know_string">We may never know</string>
</resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.App" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/md_theme_light_primary</item>
<item name="colorPrimaryVariant">@color/md_theme_light_primaryContainer</item>
<item name="colorOnPrimary">@color/md_theme_light_onPrimary</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/md_theme_light_tertiary</item>
<item name="colorSecondaryVariant">@color/md_theme_light_secondaryContainer</item>
<item name="colorOnSecondary">@color/md_theme_light_onSecondary</item>
<item name="colorAccent">@color/md_theme_light_tertiary</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<item name="android:selectableItemBackground" tools:targetApi="l">@drawable/background_selector</item>
<item name="rippleColor">@color/ripple_light</item>
</style>
<style name="Theme.App.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.App.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.App.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: 'versions.gradle'
repositories {
google()
}
dependencies {
// Navigation safe-args plugin does had to be declared
// in a buildscript block and not in plugins block.
classpath deps.navigation.safe_args_plugin
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
\ No newline at end of file
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
\ No newline at end of file
File added
#Sat Jun 04 15:15:23 EDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment