Skip to content

Commit

Permalink
second public material
Browse files Browse the repository at this point in the history
2nd published files
  • Loading branch information
prophet18 committed Jul 4, 2024
1 parent 6b52afe commit 075a208
Show file tree
Hide file tree
Showing 14 changed files with 165 additions and 254 deletions.
15 changes: 1 addition & 14 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ android {
dependencies {

implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.2")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3")
implementation("androidx.activity:activity-compose:1.9.0")
implementation(platform("androidx.compose:compose-bom:2024.06.00"))
implementation("androidx.compose.ui:ui")
Expand All @@ -66,8 +66,8 @@ dependencies {
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.activity:activity-ktx:1.9.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.0")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2024.06.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@
</application>

</manifest>

4 changes: 2 additions & 2 deletions app/src/main/java/coleccion/android/AllDatas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object AllDatas {
try {
if (highScores.createNewFile() && csvHighScores.createNewFile()) {
println("Files created ")
/*

val addHS = BufferedWriter(FileWriter(highScores, true))
val csvHS = BufferedWriter(FileWriter(csvHighScores, true))
// csvHS.write("$dAndTime,$scoreString,$gDuration,$bgStrins")
Expand All @@ -55,7 +55,7 @@ object AllDatas {
addHS.write("Date &\nTime" + " " + "Score" + " " + "Game\nDuration" + " " + "Background")
addHS.newLine()
addHS.close()
*/


} else {
println("Files already exist.")
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/coleccion/android/GameOverScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package coleccion.android
The Coil utility is implemented to render a gif which serves as the background of the screen.
*/

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.widget.ImageButton
Expand All @@ -27,7 +26,6 @@ class GameOverScreen : ComponentActivity() {
private lateinit var timeReport2 : String
private lateinit var bgView : ImageView

@SuppressLint("MissingInflatedId")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.gameover_screen)
Expand Down
30 changes: 6 additions & 24 deletions app/src/main/java/coleccion/android/HighScoreScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package coleccion.android
time, and background info.
*/

import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Typeface
import android.os.Build
Expand All @@ -24,42 +23,24 @@ import java.io.IOException

class HighScoreScreen : ComponentActivity() {

private lateinit var dTime1: TextView
private lateinit var sTime1: TextView
private lateinit var gSelect1: TextView
private lateinit var bSelect1: TextView

private lateinit var eButto4 : ImageButton
var fileName = "/data/data/coleccion.android/files/coleccionHighScores.csv"


@SuppressLint("MissingInflatedId")
@RequiresApi(Build.VERSION_CODES.R)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.highscore_layout)

val tableLayout: TableLayout = findViewById(R.id.highscoren_layout)

eButto4 = findViewById(R.id.e_button4)
dTime1 = findViewById(R.id.dtimes); sTime1 = findViewById(R.id.stimes)
gSelect1 = findViewById(R.id.gdur); bSelect1 = findViewById(R.id.bground)

eButto4.setOnClickListener { returningHome2() }

AllDatas.textSizing(this, dTime1, 0.02)
AllDatas.textSizing(this, sTime1, 0.02)
AllDatas.textSizing(this, gSelect1, 0.02)
AllDatas.textSizing(this, bSelect1, 0.02)

try {
val reader = CSVReader(FileReader(fileName))
/*
val header = reader.readNext() // Read the header row
if (header != null) {
addHeaderRow(tableLayout, header)
}
*/

var record: Array<String>?
while (reader.readNext().also { record = it } != null) {
Expand All @@ -70,7 +51,7 @@ class HighScoreScreen : ComponentActivity() {
}
}

@RequiresApi(Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.R)
private fun addHeaderRow(tableLayout: TableLayout, header: Array<String>) {
val headerRow = TableRow(this)
for (column in header) {
Expand All @@ -82,7 +63,7 @@ class HighScoreScreen : ComponentActivity() {
tableLayout.addView(headerRow)
}

@RequiresApi(Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.R)
private fun addDataRow(tableLayout: TableLayout, record: Array<String>?) {
val dataRow = TableRow(this)
if (record != null) {
Expand All @@ -96,27 +77,29 @@ class HighScoreScreen : ComponentActivity() {
tableLayout.addView(dataRow)
}

@RequiresApi(Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.R)
private fun createTextView(text: String): TextView {
val typeFont : Typeface = resources.getFont(R.font.ocraextended)
val textView = TextView(this)
textView.text = text
textView.setPadding(10, 10, 10, 10)
textView.gravity = Gravity.CENTER
textView.textSize = 15.toFloat()
AllDatas.textSizing(this, textView, 0.012)
textView.setTypeface(typeFont)
textView.setTextColor(getColor(R.color.white))
return textView
}

@RequiresApi(Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.R)
private fun createTextHeader(text: String): TextView {
val typeFont : Typeface = resources.getFont(R.font.ocraextended)
val textView = TextView(this)
textView.text = text
textView.setPadding(10, 10, 10, 10)
textView.gravity = Gravity.CENTER
textView.textSize = 18.toFloat()
AllDatas.textSizing(this, textView, 0.015)
textView.setTypeface(typeFont)
textView.setTextColor(getColor(R.color.yellow))
return textView
Expand All @@ -128,4 +111,3 @@ class HighScoreScreen : ComponentActivity() {
startActivity(intent1)
}
}

26 changes: 2 additions & 24 deletions app/src/main/java/coleccion/android/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ package coleccion.android
Using Spinners, players can select the background and game duration they desire.
*/

import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import android.view.WindowMetrics
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.ImageButton
Expand Down Expand Up @@ -89,10 +86,8 @@ class Settings : ComponentActivity() {
return2home!!.setOnClickListener { returningHome() }

// Calculate text size based on the TextView dimensions
AllDatas.textSizing(this, bSelect, 0.045)
AllDatas.textSizing(this, tSelect, 0.045)
// textSizing(bSelect)
// textSizing(tSelect)
AllDatas.textSizing(this, bSelect, 0.04)
AllDatas.textSizing(this, tSelect, 0.04)

}

Expand All @@ -102,21 +97,4 @@ class Settings : ComponentActivity() {
startActivity(intent1)
}

@RequiresApi(Build.VERSION_CODES.R)
private fun textSizingo(tView : TextView) {

// Get screen dimensions using WindowMetrics
val windowManager = getSystemService(Context.WINDOW_SERVICE) as WindowManager
val windowMetrics: WindowMetrics = windowManager.currentWindowMetrics
val bounds = windowMetrics.bounds
val screenWidth = bounds.width()
val screenHeight = bounds.height()

// Calculate the new text size as a percentage of the smaller screen dimension
val newTextSize = (screenWidth.coerceAtMost(screenHeight) * 0.045).toFloat()

// Set the new text size
tView.textSize = newTextSize

}
}
94 changes: 94 additions & 0 deletions app/src/main/res/layout/backup_layouts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1739,4 +1739,98 @@ play_layoutthree.xml
android:background="@color/black"/>
</TableRow>
-->

<!--
<TableRow
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:gravity="center"
android:id="@+id/tRow2"
android:background="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/hScores"
app:layout_constraintBottom_toTopOf="@+id/scrollView2"
app:layout_constraintWidth_percent="0.99"
app:layout_constraintHeight_percent="0.08">
<TextView
android:id="@+id/dtimes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_weight="1"
android:contentDescription="@string/dtime"
android:fontFamily="@font/ocraextended"
android:gravity="center"
android:textColor="@color/yellow"
android:text="@string/dtimetv"
android:textSize="18sp" />
<TextView
android:id="@+id/stimes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:contentDescription="@string/scoretwo"
android:fontFamily="@font/ocraextended"
android:gravity="center"
android:textColor="@color/yellow"
android:text="@string/scoretwo"
android:textSize="18sp"/>
<TextView
android:id="@+id/gdur"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:contentDescription="@string/time"
android:fontFamily="@font/ocraextended"
android:gravity="center"
android:textColor="@color/yellow"
android:text="@string/gtimetv"
android:textSize="18sp" />
<TextView
android:id="@+id/bground"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1.5"
android:contentDescription="@string/choose_game_background"
android:fontFamily="@font/ocraextended"
android:gravity="center"
android:textColor="@color/yellow"
android:text="@string/btime"
android:textSize="18sp"/>
</TableRow>
<GridLayout
android:id="@+id/highscoren_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3"
android:rowCount="0"
android:orientation="horizontal"
android:padding="3dp"
android:layout_gravity="center"
android:useDefaultMargins="true" />
private lateinit var dTime1: TextView
private lateinit var sTime1: TextView
private lateinit var gSelect1: TextView
private lateinit var bSelect1: TextView
dTime1 = findViewById(R.id.dtimes); sTime1 = findViewById(R.id.stimes)
gSelect1 = findViewById(R.id.gdur); bSelect1 = findViewById(R.id.bground)
-->
2 changes: 2 additions & 0 deletions app/src/main/res/layout/gameover_screen.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- XML setup and organization of items on the game over screen. -->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/layout/help_layouts.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- XML setup and organization of items on the help pages. -->

<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/helpFlipper"
Expand All @@ -19,7 +21,9 @@
android:id="@+id/help_info111"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:layout_marginTop="15dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:contentDescription="@string/help_info_111"
android:scaleType="fitXY"
android:src="@drawable/how_2_play_icon1"
Expand Down
Loading

0 comments on commit 075a208

Please sign in to comment.