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
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MatrixActivity"
android:exported="false" />
<activity
android:name=".JustMeActivity"
android:exported="false" />
</application>

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

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class JustMeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_just_me)
}
}
17 changes: 15 additions & 2 deletions app/src/main/java/com/example/codexone/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.codexone

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
Expand All @@ -18,18 +19,22 @@ class MainActivity : AppCompatActivity() {

// Get references to the views
val usernameEditText: EditText = findViewById(R.id.usernameEditText)
val emailEditText: EditText = findViewById(R.id.emailEditText)
val passwordEditText: EditText = findViewById(R.id.passwordEditText)
val loginButton: Button = findViewById(R.id.loginButton)
val forgotPasswordText: TextView = findViewById(R.id.forgotPasswordText)
val helpButton: Button = findViewById(R.id.helpButton)
val matrixButton: Button = findViewById(R.id.matrixButton)

// Set a click listener for the login button
loginButton.setOnClickListener {
val username = usernameEditText.text.toString()
val email = emailEditText.text.toString()
val password = passwordEditText.text.toString()

// Basic validation
if (username.isEmpty() || password.isEmpty()) {
Toast.makeText(this, "Please enter both username and password", Toast.LENGTH_SHORT).show()
if (username.isEmpty() || email.isEmpty() || password.isEmpty()) {
Toast.makeText(this, "Please fill in all fields", Toast.LENGTH_SHORT).show()
} else {
// In a real app, you would check credentials here
// For this example, we'll just show a Toast
Expand All @@ -39,6 +44,14 @@ class MainActivity : AppCompatActivity() {
}
}

helpButton.setOnClickListener {
Toast.makeText(this, "Help clicked", Toast.LENGTH_SHORT).show()
}

matrixButton.setOnClickListener {
startActivity(Intent(this, MatrixActivity::class.java))
}

// Set a click listener for the forgot password text
forgotPasswordText.setOnClickListener {
// Handle forgot password click (e.g., open a new screen or display a message)
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/com/example/codexone/MatrixActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.codexone

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class MatrixActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_matrix)
}
}
70 changes: 70 additions & 0 deletions app/src/main/java/com/example/codexone/MatrixView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.example.codexone

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Typeface
import android.os.Handler
import android.os.Looper
import android.util.AttributeSet
import android.view.View
import kotlin.random.Random

class MatrixView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : View(context, attrs) {

private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.GREEN
textSize = 20f * resources.displayMetrics.density
typeface = Typeface.MONOSPACE
}

private val charHeight: Float = paint.textSize
private var columns: Int = 0
private var offsets: FloatArray = FloatArray(0)
private val random = Random

private val handler = Handler(Looper.getMainLooper())
private val updateRunnable = object : Runnable {
override fun run() {
for (i in offsets.indices) {
offsets[i] += charHeight
if (offsets[i] > height) offsets[i] = 0f
}
invalidate()
handler.postDelayed(this, 50)
}
}

init {
handler.post(updateRunnable)
}

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
val charWidth = paint.measureText("0")
columns = (w / charWidth + 1).toInt()
offsets = FloatArray(columns) { random.nextFloat() * h }
}

override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
val charWidth = paint.measureText("0")
for (i in 0 until columns) {
var y = offsets[i]
while (y > -charHeight) {
val c = randomChar()
canvas.drawText(c.toString(), i * charWidth, y, paint)
y -= charHeight
}
}
}

private fun randomChar(): Char {
val chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
return chars[random.nextInt(chars.length)]
}
}
12 changes: 12 additions & 0 deletions app/src/main/res/layout/activity_just_me.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/justMeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am back"
android:layout_gravity="center" />
</FrameLayout>
32 changes: 31 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@
android:inputType="textEmailAddress"
android:layout_marginBottom="16dp"/>

<!-- Email EditText -->
<EditText
android:id="@+id/emailEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
android:layout_below="@id/usernameEditText"
android:layout_marginBottom="16dp"/>

<!-- Password EditText -->
<EditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:layout_below="@id/usernameEditText"
android:layout_below="@id/emailEditText"
android:layout_marginBottom="16dp"/>

<!-- Login Button -->
Expand All @@ -40,4 +50,24 @@
android:textColor="#0000FF"
android:layout_below="@id/loginButton"
android:layout_marginTop="10dp"/>

<!-- Help Button -->
<Button
android:id="@+id/helpButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Help"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_margin="16dp" />

<!-- Matrix Button -->
<Button
android:id="@+id/matrixButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Matrix"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_margin="16dp" />
</RelativeLayout>
11 changes: 11 additions & 0 deletions app/src/main/res/layout/activity_matrix.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000">

<com.example.codexone.MatrixView
android:id="@+id/matrixView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>