Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
UWU UI update
Browse files Browse the repository at this point in the history
  • Loading branch information
AnGgIt86 committed Sep 23, 2024
1 parent a95a5ff commit 5fafd24
Show file tree
Hide file tree
Showing 51 changed files with 3,090 additions and 567 deletions.
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@
android:screenOrientation="portrait"
android:exported="false" />

<activity android:name="com.neko.uwu.TambahActivity"
android:theme="@style/AppThemeDayNight.NoActionBar"
android:screenOrientation="portrait"
android:exported="false" />

<activity android:name="com.neko.uwu.UbahActivity"
android:theme="@style/AppThemeDayNight.NoActionBar"
android:screenOrientation="portrait"
android:exported="false" />

<service
android:name=".service.V2RayVpnService"
android:enabled="true"
Expand Down
34 changes: 33 additions & 1 deletion app/src/main/java/com/neko/splash/SplashActivity.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,57 @@
package com.neko.splash

import android.content.Intent
import android.database.Cursor
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import com.neko.v2ray.R
import com.neko.v2ray.ui.BaseActivity
import com.neko.v2ray.ui.MainActivity
import com.neko.uwu.*

class SplashActivity : BaseActivity() {

private lateinit var myDB: MyDatabaseHelper
private lateinit var arrID: ArrayList<String>
private lateinit var arrUsername: ArrayList<String>

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.uwu_activity_splash)
myDB = MyDatabaseHelper(this)

window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN)

Handler(Looper.getMainLooper()).postDelayed({
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
val cursor: Cursor? = myDB.bacaSemuaData()
if (cursor == null || cursor.count == 0) {
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
} else {
try {
val db = myDB.readableDatabase
val query = "SELECT * FROM nekoray"
val rs: Cursor = db.rawQuery(query, null)

if (rs.moveToFirst()) {
val arrID = rs.getString(rs.getColumnIndexOrThrow("id"))
val username = rs.getString(rs.getColumnIndexOrThrow("username"))
val posisi = 1

val intent = Intent(this@SplashActivity, MainActivity::class.java).apply {
putExtra("varID", arrID)
putExtra("varUsername", username)
putExtra("varPosisi", posisi)
}
startActivity(intent)
}
rs.close()
} finally {
cursor?.close()
}
}
finish()
}, 1000)
}
Expand Down
60 changes: 60 additions & 0 deletions app/src/main/java/com/neko/uwu/AdapterDatabase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.neko.uwu

import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import com.neko.v2ray.R
import com.neko.v2ray.ui.MainActivity
import com.google.android.material.card.MaterialCardView

class AdapterDatabase(
private val ctx: Context,
private val arrID: ArrayList<*>,
private val arrName: ArrayList<*>,
private val arrUsername: ArrayList<*>,
private val arrEmail: ArrayList<*>,
private val arrAge: ArrayList<*>,
private val arrHobi: ArrayList<*>,
private val arrTgl: ArrayList<*>
) : RecyclerView.Adapter<AdapterDatabase.ViewHolderDatabase>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolderDatabase {
val view = LayoutInflater.from(ctx).inflate(R.layout.card_item, parent, false)
return ViewHolderDatabase(view)
}

override fun onBindViewHolder(holder: ViewHolderDatabase, position: Int) {
val alphabet: List<Char> = ('a'..'z') + ('A'..'Z') + ('0'..'9')
val randomString: String = List(15) { alphabet.random() }.joinToString("")

holder.tvID.text = arrID[position].toString()
holder.uwuID.text = randomString
holder.tvName.text = arrName[position].toString()
holder.tvUsername.text = arrUsername[position].toString()
holder.tvEmail.text = arrEmail[position].toString()
holder.tvAge.text = arrAge[position].toString()
holder.tvHobi.text = arrHobi[position].toString()
holder.tvTgl.text = arrTgl[position].toString()
}

override fun getItemCount(): Int = arrName.size

inner class ViewHolderDatabase(itemView: View) : RecyclerView.ViewHolder(itemView) {
val tvID: TextView = itemView.findViewById(R.id.tv_id)
val uwuID: TextView = itemView.findViewById(R.id.uwu_id)
val tvName: TextView = itemView.findViewById(R.id.tv_name)
val tvUsername: TextView = itemView.findViewById(R.id.tv_username)
val tvEmail: TextView = itemView.findViewById(R.id.tv_email)
val tvAge: TextView = itemView.findViewById(R.id.tv_age)
val tvHobi: TextView = itemView.findViewById(R.id.tv_hobi)
val tvTgl: TextView = itemView.findViewById(R.id.tv_tgl)
val cvDatabase: MaterialCardView = itemView.findViewById(R.id.cv_database)
}
}

83 changes: 83 additions & 0 deletions app/src/main/java/com/neko/uwu/MyDatabaseHelper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.neko.uwu

import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper

class MyDatabaseHelper(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
private val ctx: Context = context

companion object {
private const val DATABASE_NAME = "neko.db"
private const val DATABASE_VERSION = 1

private const val TABLE_NAME = "nekoray"
private const val FIELD_ID = "id"
private const val FIELD_NAME = "name"
private const val FIELD_USERNAME = "username"
private const val FIELD_EMAIL = "email"
private const val FIELD_AGE = "age"
private const val FIELD_HOBI = "hobi"
private const val FIELD_TGL = "tgl"
}

override fun onCreate(db: SQLiteDatabase) {
val query = "CREATE TABLE $TABLE_NAME (" +
"$FIELD_ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
"$FIELD_NAME TEXT, " +
"$FIELD_USERNAME TEXT, " +
"$FIELD_EMAIL TEXT, " +
"$FIELD_AGE TEXT, " +
"$FIELD_HOBI TEXT, " +
"$FIELD_TGL TEXT );"

db.execSQL(query)
}

override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
db.execSQL("DROP TABLE IF EXISTS $TABLE_NAME")
onCreate(db)
}

fun tambahDatabase(name: String, username: String, email: String, age: String, hobi: String, tgl: String): Long {
val db = this.writableDatabase
val cv = ContentValues()

cv.put(FIELD_NAME, name)
cv.put(FIELD_USERNAME, username)
cv.put(FIELD_EMAIL, email)
cv.put(FIELD_AGE, age)
cv.put(FIELD_HOBI, hobi)
cv.put(FIELD_TGL, tgl)

return db.insert(TABLE_NAME, null, cv)
}

fun ubahDatabase(id: String, name: String, username: String, email: String, age: String, hobi: String, tgl: String): Long {
val db = this.writableDatabase
val cv = ContentValues()

cv.put(FIELD_NAME, name)
cv.put(FIELD_USERNAME, username)
cv.put(FIELD_EMAIL, email)
cv.put(FIELD_AGE, age)
cv.put(FIELD_HOBI, hobi)
cv.put(FIELD_TGL, tgl)

return db.update(TABLE_NAME, cv, "id = ?", arrayOf(id)).toLong()
}

fun hapusDatabase(id: String): Long {
val db = this.writableDatabase
return db.delete(TABLE_NAME, "id = ?", arrayOf(id)).toLong()
}

fun bacaSemuaData(): Cursor? {
val query = "SELECT * FROM $TABLE_NAME"
val db = this.readableDatabase

return db?.rawQuery(query, null)
}
}
Loading

0 comments on commit 5fafd24

Please sign in to comment.