Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity" />
<activity android:name=".MatrixActivity" />
</application>

</manifest>
36 changes: 36 additions & 0 deletions app/src/main/java/com/example/codexthree/LoginActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.codexthree

import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_login)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.login_root)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}

val emailField = findViewById<EditText>(R.id.email_field)
val passwordField = findViewById<EditText>(R.id.password_field)
findViewById<Button>(R.id.login_button).setOnClickListener {
val email = emailField.text.toString().trim()
val password = passwordField.text.toString()
if (email.isNotEmpty() && password.isNotEmpty()) {
Toast.makeText(this, "Logged in as $email", Toast.LENGTH_SHORT).show()
finish()
} else {
Toast.makeText(this, "Please enter email and password", Toast.LENGTH_SHORT).show()
}
}
}
}
11 changes: 11 additions & 0 deletions app/src/main/java/com/example/codexthree/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.example.codexthree

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

import com.example.codexthree.MatrixActivity

class MainActivity : AppCompatActivity() {

private val justASimpleTemporaryName : String = "GoBig"
Expand All @@ -18,5 +22,12 @@ class MainActivity : AppCompatActivity() {
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
findViewById<Button>(R.id.open_login_button).setOnClickListener {
startActivity(Intent(this, LoginActivity::class.java))
}

findViewById<Button>(R.id.open_matrix_button).setOnClickListener {
startActivity(Intent(this, MatrixActivity::class.java))
}
}
}
22 changes: 22 additions & 0 deletions app/src/main/java/com/example/codexthree/MatrixActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.codexthree // App package

import android.os.Bundle // To receive savedInstanceState
import androidx.activity.enableEdgeToEdge // Utility for drawing edge-to-edge
import androidx.appcompat.app.AppCompatActivity // Base class for activities
import androidx.core.view.ViewCompat // Compat helpers for views
import androidx.core.view.WindowInsetsCompat // For handling system insets

// Activity that hosts the MatrixView animation
class MatrixActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) // Call parent implementation
enableEdgeToEdge() // Draw under system bars
setContentView(R.layout.activity_matrix) // Use layout containing MatrixView
// Adjust padding so content isn't obscured by system bars
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.matrix_root)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) // Areas occupied by status/navigation bars
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) // Apply padding
insets
}
} // End onCreate
} // End of MatrixActivity
62 changes: 62 additions & 0 deletions app/src/main/java/com/example/codexthree/MatrixView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.example.codexthree // App's package name

import android.content.Context // Provides access to application-specific resources
import android.graphics.Canvas // Canvas to draw on the screen
import android.graphics.Color // Utility for colors
import android.graphics.Paint // Paint object describes how to draw
import android.graphics.Typeface // Allows selecting font family
import android.util.AttributeSet // For XML attributes
import android.view.View // Base class for custom views
import kotlin.random.Random // Random number generator

// Custom view that draws the Matrix rain effect
class MatrixView @JvmOverloads constructor(
context: Context, // Context from the parent view or activity
attrs: AttributeSet? = null // Optional attributes from XML
) : View(context, attrs) { // Extends Android's View class

// Paint object for drawing the characters
private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.GREEN // Use a classic Matrix green
textSize = 32f // Size of each character
typeface = Typeface.MONOSPACE // Monospace font for uniform width
} // End Paint configuration

// Y positions for each column of text
private var columnY = FloatArray(0)

// Pool of characters to randomly display
private val charPool = """ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*(){}[]<>?/|+-="""

// Called whenever the view size changes
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
val textHeight = paint.textSize // Height of one character
val columnCount = (w / textHeight).toInt() + 1 // How many columns fit on screen
// Start each column at a random vertical position above the screen
columnY = FloatArray(columnCount) { Random.nextInt(h) * -1f }
} // End onSizeChanged

// Draw one frame of the animation
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas) // Let the parent do its work
canvas.drawColor(Color.BLACK) // Clear the screen with black
val textHeight = paint.textSize // Character height used for spacing
for (i in columnY.indices) { // Loop over each text column
var y = columnY[i] // Current Y position for this column
val x = i * textHeight // X coordinate based on column index
while (y < height) { // Draw characters down the screen
// Pick a random character from our pool
val ch = charPool[Random.nextInt(charPool.length)].toString()
// Random alpha value for fading effect
paint.color = Color.argb(Random.nextInt(50, 256), 0, 255, 0)
canvas.drawText(ch, x, y, paint) // Draw the character
y += textHeight / 2 // Move down half a char height (slower)
} // End while loop
columnY[i] += textHeight / 2 // Advance the starting Y position
if (columnY[i] > height) { // If we've moved past bottom
columnY[i] = 0f // Reset to top
} // End if
} // End for loop
postInvalidateOnAnimation() // Schedule next frame
} // End onDraw
} // End of MatrixView class
45 changes: 45 additions & 0 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/login_root"
android:layout_width="match_parent"
android:layout_height="match_parent">

<EditText
android:id="@+id/email_field"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="32dp"/>

<EditText
android:id="@+id/password_field"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
app:layout_constraintTop_toBottomOf="@id/email_field"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"/>

<Button
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login"
app:layout_constraintTop_toBottomOf="@id/password_field"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="24dp" />

</androidx.constraintlayout.widget.ConstraintLayout>
21 changes: 20 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,31 @@
tools:context=".MainActivity">

<TextView
android:id="@+id/hello_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/open_login_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/open_login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login"
app:layout_constraintTop_toBottomOf="@id/hello_text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<Button
android:id="@+id/open_matrix_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/open_matrix"
app:layout_constraintTop_toBottomOf="@id/open_login_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/activity_matrix.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/matrix_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">

<com.example.codexthree.MatrixView
android:id="@+id/matrix_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</FrameLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<resources>
<string name="app_name">CodexThree</string>
<string name="login">Login</string>
<string name="open_matrix">Matrix Animation</string>
</resources>