Skip to content

Commit

Permalink
Add Login screen and Admin screen
Browse files Browse the repository at this point in the history
  • Loading branch information
tungnk123 committed May 19, 2024
1 parent c4fdd70 commit 04bc986
Show file tree
Hide file tree
Showing 9 changed files with 299 additions and 28 deletions.
15 changes: 14 additions & 1 deletion .idea/deploymentTargetDropDown.xml

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

20 changes: 13 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
android:supportsRtl="true"
android:theme="@style/Theme.ChiecNonKyDieu"
tools:targetApi="31">
<activity
android:name=".ui.admin.HomeAdminActivity"
android:exported="false" />
<activity
android:name=".ui.admin.LoginActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.admin.AddQuestionActivity"
android:exported="false" />
Expand All @@ -34,13 +46,7 @@
android:launchMode="singleTop" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
android:exported="false"/>

<meta-data
android:name="preloaded_fonts"
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/java/com/example/chiecnonkydieu/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ class MainActivity : AppCompatActivity() {
startActivity(intent)
}

binding.btnThemCauHoi.setOnClickListener {
val intent = Intent(this, AddQuestionActivity::class.java)
startActivity(intent)
}


}
private fun goToPlayingRoom() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.chiecnonkydieu.ui.admin

import android.content.Intent
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.chiecnonkydieu.R
import com.example.chiecnonkydieu.databinding.ActivityHomeAdminBinding

class HomeAdminActivity : AppCompatActivity() {
private lateinit var binding: ActivityHomeAdminBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
binding = ActivityHomeAdminBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.admin_main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
binding.btnThemCauHoi.setOnClickListener {
val intent = Intent(this, AddQuestionActivity::class.java)
startActivity(intent)
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.example.chiecnonkydieu.ui.admin

import android.content.Intent
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.chiecnonkydieu.MainActivity
import com.example.chiecnonkydieu.R
import com.example.chiecnonkydieu.databinding.ActivityLoginBinding
import com.example.chiecnonkydieu.databinding.ActivityPlayingRoomBinding
import com.example.chiecnonkydieu.ui.wheel.WheelActivity

class LoginActivity : AppCompatActivity() {

private lateinit var binding: ActivityLoginBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
binding = ActivityLoginBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}

binding.btnDangNhap.setOnClickListener {
if (binding.edtTaikhoan.text.toString() == "admin") {
val intent: Intent = Intent(this, HomeAdminActivity::class.java)
startActivity(intent)
}
else {
val intent: Intent = Intent(this, MainActivity::class.java)
startActivity(intent)
}
}
}
}
80 changes: 80 additions & 0 deletions app/src/main/res/layout/activity_home_admin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/admin_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/purple_gradient"
tools:context=".MainActivity">

<ImageView
android:id="@+id/img_logo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="30dp"
android:contentDescription="@string/wheel_logo"
android:src="@drawable/ic_wheel"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_title"
style="@style/MaterialAlertDialog.Material3.Title.Text.CenterStacked"
android:layout_marginTop="20dp"
android:text="ADMIN"
android:textSize="30sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/img_logo" />


<com.google.android.material.button.MaterialButton
android:id="@+id/btn_taoPhong"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:text="@string/tao_nft"
android:backgroundTint="@color/orange"
android:elevation="30dp"
android:stateListAnimator="@null"
android:textColor="@color/black"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_title" />


<com.google.android.material.button.MaterialButton
android:id="@+id/btn_themCauHoi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:text="@string/btn_taoCauHoi"
android:backgroundTint="@color/orange"
android:elevation="30dp"
android:stateListAnimator="@null"
android:textColor="@color/black"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_taoPhong" />

<ImageView
android:id="@+id/img_wheel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:contentDescription="@string/wheel_logo"
android:src="@drawable/ic_roulette"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_taoPhong" />

</androidx.constraintlayout.widget.ConstraintLayout>
114 changes: 114 additions & 0 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue_200"
tools:context=".ui.admin.LoginActivity">

<ImageView
android:id="@+id/img_logo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="30dp"
android:contentDescription="@string/wheel_logo"
android:src="@drawable/ic_wheel"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tv_title"
style="@style/MaterialAlertDialog.Material3.Title.Text.CenterStacked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/app_title"
android:textSize="30sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/img_logo" />

<TextView
android:id="@+id/tv_taiKhoan"
style="@style/TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="@string/title_taikhoan"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_title" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_taiKhoan"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:hint="@string/title_taikhoan"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_taiKhoan">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_taikhoan"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textPersonName"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:id="@+id/tv_matKhau"
style="@style/TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="@string/title_matKhau"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_taiKhoan" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_matKhau"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:hint="@string/title_matKhau"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_matKhau">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_matKhau"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textPersonName"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/btn_dangNhap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:text="@string/btn_dangNhap"
android:backgroundTint="@color/orange"
android:elevation="30dp"
android:stateListAnimator="@null"
android:textColor="@color/black"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_matKhau" />
</androidx.constraintlayout.widget.ConstraintLayout>
16 changes: 0 additions & 16 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_taoPhong" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btn_themCauHoi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:text="@string/btn_taoCauHoi"
android:backgroundTint="@color/orange"
android:elevation="30dp"
android:stateListAnimator="@null"
android:textColor="@color/black"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_timPhong" />

<ImageView
android:id="@+id/img_wheel"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

<string name="btn_thoat">Thoát</string>
<string name="btn_next">Chơi tiếp</string>
<string name="btn_dangNhap">Đăng nhập</string>

<string name="title_taikhoan">Tài khoản</string>
<string name="title_matKhau">Mật khẩu</string>
<string name="tao_nft">TẠO NFT</string>


</resources>

0 comments on commit 04bc986

Please sign in to comment.