ĐẠI HỌC DUY TÂN TRƯỜNG KHOA HỌC MÁY TÍNH KHOA CÔNG NGHỆ THÔNG TIN BÁO CÁO ĐỒ ÁN: APP ĐỌC BÁO XEM TIN TỨC THỂ THAO BÓNG ĐÁ MÔN: LẬP TRÌNH ỨNG DỤNG THIẾT BỊ DI ĐỘNG GIẢNG VIÊN HƯỚ
Trang 1ĐẠI HỌC DUY TÂN TRƯỜNG KHOA HỌC MÁY TÍNH KHOA CÔNG NGHỆ THÔNG TIN
BÁO CÁO
ĐỒ ÁN: APP ĐỌC BÁO XEM TIN TỨC THỂ THAO BÓNG ĐÁ MÔN: LẬP TRÌNH ỨNG DỤNG THIẾT BỊ DI ĐỘNG
GIẢNG VIÊN HƯỚNG DẪN : NGUYỄN MINH NHẬT
ĐÀ NẴNG, 09/2023
Trang 2CHƯƠNG 1 GIỚI THIỆU BÀI TOÁN
`1.1 Giới thiệu bài toán
Một ứng dụng cho phép người dùng có thể truy cập để cập nhật các thông tin mới nhất về thể thao(bóng đá), xem lịch thi đấu, các thông tin hot của các đội bóng lớn và của các cầu thủ hàng đầu, xem bxh của top các giải đấu hàng đầu Châu Âu.
1.2 Yêu cầu
Yêu cầu chức năng
- Admin
Đăng kí, đăng nhập
Thêm sửa xóa, tìm kiếm tin tức
Xem lịch sử truy cập
Thống kê số khách hàng đã sử dụng app trong tháng
Yêu cầu phi chức năng
- Thân thiện với người dùng
- Tốc độ load nhanh
- Bảo mật thông tin
Các ca sử dụng:
Đăng kí
Đăng nhập
Xem danh sách tin tức
Thêm, sửa, xóa, tìm kiếm thông tin
Thêm người dùng
Xem thông tin tin tức bóng đá
Sửa, xóa, tìm kiếm thông tin
1.3 Đặc tả các cách sử dụng
1 Đăng nhập:
Tác nhân sử dụng: Admin (Người quản trị)
Trang 3 Khi đã đăng nhập thành công: Dựa theo khả năng phân quyền thì tài khoản đó có thể sử dụng các chức năng quản lí.
Các bước thực hiện
2 Đăng ký
Tác nhân sử dụng: Admin
Điền đầy đủ thông tin để đăng kí tài khoản
Các bước thực hiện
Đưa thông tin vào cơ sở dữ liệu Thông báo thành công
Nếu nhập sai thông tin hệ thống thông báo sai và nhập lại hoặc kết thúc
3 Thêm tin tức:
Tác nhân sử dụng: Admin
Thực hiện chức năng thêm tin tức
nhập thông tin (tên đăng nhập, mật khẩu).
nhập
Hệ thống xuất ra thông báo đăng nhập thành công hoặc thất bại Nếu thành công thì thực hiện hiển thị giao diện trang chủ của app quản lí Nếu thất bại thì yêu cầu đăng nhập lại
Trang 4 Các bước thực hiện
Điền thông tin tin tức vào form hệ thống Hệ thống sẽ lưu vào cơ sở dữ liệu
Thông báo thành công
Hệ thống sẽ kiểm tra dữ liệu, sẽ không lưu nếu tin tức đã tồn tại
Nếu điền thiếu thông tin trong form thì hệ thống sẽ báo lỗi và nhập lại hoặc kết thúc
4 Xem tin tức:
Tác nhân sử dụng: Admin
Thực hiện chức năng xem tin tức
Các bước thực hiện
Hiển thị danh tin tức
5 Xóa tin tức:
Tác nhân sử dụng: Admin
Thực hiện xóa tin tức
Các bước thực hiện
Hiển thị danh sách tin tức sau khi xóa
6 Sửa tin tức:
Tác nhân sử dụng: Admin
Thực hiện chức năng sửa tin tức
Các bước thực hiện
Trang 5Chọn chức năng sửa tin tức Hệ thống sẽ hiển thị form sửa
Thông báo thành công
Hệ thống sẽ kiểm tra dữ liệu, sẽ không lưu nếu tin tức đã tồn tại
Nếu điền thiếu thông tin trong form thì hệ thống sẽ báo lỗi và nhập lại hoặc kết thúc.
7 Tìm kiếm thông tin:
Tác nhân sử dụng: Admin
Thực hiện chức năng tìm kiếm thông tin của tin tức
Các bước thực hiện:
Hiển thị danh sách tin tức thông tin cần tìm
8 Xem thông tin đã được thêm:
Tác nhân sử dụng: Admin
Thực hiện xem danh sách thông tin đã được thêm
Các bước thực hiện
Chọn chức năng xem thông tin đã được
thêm
Truy vấn cơ sở dữ liệu
Hiển thị giao diện danh sách thông tin các thông tin đã được thêm
9 Thêm thông tin người truy cập:
Tác nhân sử dụng: Admin
Thực hiện thêm thông tin khách hàng đã xem tin tức
Trang 6 Các bước thực hiện
Chọn chức năng thêm thông tin khách
hàng
Hiển thị form điền
Thông báo thành công
Hệ thống sẽ kiểm tra dữ liệu, sẽ không lưu nếu tin tức đã tồn tại
Nếu điền thiếu thông tin trong form thì hệ thống sẽ báo lỗi và nhập lại hoặc kết thúc
10 Xem lịch sử truy cập tin tức
Tác nhân sử dụng: Admin
Thực hiện chức năng xem thông tin lịch sử truy cập tin tức
Các bước thực hiện
Hệ thống hiển thị danh sách thông tin lịch
sử truy cập
11 Thống kê
Tác nhân sử dụng: Admin
Thực hiện thống kê số khách hàng đã sử dụng app trong tháng
Các bước thực hiện
Hiển thị số khách hàng đã sử dụng app trong tháng
Trang 7CHƯƠNG II PHÂN TÍCH VÀ THIẾT KẾ
1.1 Phân tích
1.1.1 Lựa chọn ngôn ngữ lập trình
Trang 8 Ngôn ngữ lập trình: Java hoặc Kotlin
Công cụ phát triển: Android Studio
Môi trường vận hành: Điện thoại có hệ điều hành Android, API 27 trở lên
1.2 Thiết kế
1.2.1 Sơ đồ sử dụng
Hình 2.1 Sơ đồ lớp User và Admin
1.2.2 Giao diện chính
- Giao diện đăng nhập:
Ở đây người dùng phải nhập tên đăng nhập và mật khẩu trong phần đăng kí trước đó để được cấp quyền vào phần quản lí
Trang 9
Hình 2.2 Giao diện đăng nhập -Code giao diện
<?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 :layout_width ="match_parent"
android :layout_height ="match_parent"
android :background ="@drawable/bgmu"
tools :context =".MainActivity">
<! LOGIN >
<RelativeLayout
android :id ="@+id/login"
android :layout_width ="369dp"
android :layout_height ="486dp"
android :layout_marginHorizontal ="20dp"
android :visibility ="visible"
app :layout_constraintBottom_toBottomOf ="parent" app :layout_constraintEnd_toEndOf ="parent"
app :layout_constraintStart_toStartOf ="parent" app :layout_constraintTop_toTopOf ="parent"
app :layout_constraintVertical_bias ="0.497">
<TextView
android :id ="@+id/text_login"
android :layout_width ="match_parent"
Trang 10android :layout_height ="wrap_content"
android :layout_marginTop ="30dp"
android :fontFamily ="@font/loginfont"
android :gravity ="center"
android :text ="Login"
android :textColor ="@color/white"
android :textSize ="70sp"
android :textStyle ="bold"></TextView>
<EditText
android :id ="@+id/editText_username"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/text_login"
android :layout_centerHorizontal ="true"
android :layout_marginStart ="100dp"
android :layout_marginLeft ="100dp"
android :layout_marginTop ="16dp"
android :hint ="Username"
android :inputType ="text"
android :minHeight ="48dp"
android :textColor ="@color/white"
android :textColorHint ="@color/white" />
<EditText
android :id ="@+id/editText_password"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/editText_username" android :layout_centerHorizontal ="true"
android :layout_marginStart ="100dp"
android :layout_marginLeft ="100dp"
android :layout_marginTop ="16dp"
android :hint ="Password"
android :inputType ="textPassword"
android :minHeight ="48dp"
android :textColor ="@color/white"
android :textColorHint ="@color/white" />
<Button
android :id ="@+id/button_login"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/editText_password" android :layout_centerHorizontal ="true"
android :layout_marginStart ="200dp"
android :layout_marginLeft ="200dp"
android :layout_marginTop ="16dp"
android :backgroundTint ="@android:color/black" android :text ="Login"
android :textColor ="@color/white"
android :textSize ="30dp" />
<TextView
android :id ="@+id/button_register"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
Trang 11android :layout_below ="@+id/button_login"
android :layout_centerHorizontal ="true"
android :layout_marginStart ="100dp"
android :layout_marginLeft ="100dp"
android :layout_marginTop ="25dp"
android :gravity ="center"
android :text ="Bạn chưa có tài khoản hãy đăng kí tại đây!"
android :textColor ="#00FF00"
android :textSize ="25sp" />
<TextView
android :id ="@+id/textView_error_message"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@+id/button_register"
android :layout_marginTop ="16dp"
android :layout_marginBottom ="10dp"
android :textSize ="30dp"
android :gravity ="center"
android :textColor ="#FF0000" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
- private fun login() {
val username = editTextUsername.text.toString()
val password = editTextPassword.text.toString()
val account = Account(null, username, null, mahoa(password,key)) val Dacs3Api = RetrofitClient.create()
CoroutineScope(Dispatchers.IO).launch {
try {
withContext(Dispatchers.Main ) {
val result = Dacs3Api.Login(account)
if (result.user == null || result.pass == null) {
withContext(Dispatchers.Main ) {
Toast.makeText(applicationContext, "Đăng nhập thất bại", Toast.LENGTH_SHORT).show()
}
} else {
Toast.makeText(applicationContext, "Đăng nhập thành công", Toast.LENGTH_SHORT).show()
editTextUsername.setText("")
editTextPassword.setText("")
var i = Intent(this@MainActivity, Home::class.java) startActivity(i)
}
}
} catch (e: Exception) {
withContext(Dispatchers.Main ) {
Trang 12Toast.makeText(applicationContext, "Đăng nhập thất bại", Toast.LENGTH_SHORT).show()
}
e.printStackTrace()
}
}
}
- Giao diện đăng kí
Người quản lí phải nhập đầy đủ thông tin cần thiết để đăng kí sử dụng app
- Một số lưu ý khi đăng ký app
+ Tên phải có ít nhất 6 ký tự
+ Số điện thoại yêu cầu có 11 chữ số
+ Mật khẩu có ít nhất 8 ký tự có một chữ viết hoa một chữ số và một ký tự đặc biệt
Hình 2.3 Giao diện đăng kí
- Code phần giao diện:
<RelativeLayout
android :id ="@+id/register"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_marginHorizontal ="20dp"
android :background ="@drawable/bgmu"
android :visibility ="gone"
app :layout_constraintBottom_toBottomOf ="parent"
app :layout_constraintEnd_toEndOf ="parent"
app :layout_constraintStart_toStartOf ="parent"
app :layout_constraintTop_toTopOf ="parent">
Trang 13<TextView
android :id ="@+id/text_register"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :fontFamily ="@font/loginfont"
android :gravity ="center"
android :text ="Register"
android :layout_marginTop ="30dp"
android :textColor ="@color/white"
android :textSize ="40sp"
android :textStyle ="bold"></TextView>
<EditText
android :id ="@+id/editText_username_rg"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/text_register"
android :layout_centerHorizontal ="true"
android :layout_marginStart ="100dp"
android :layout_marginLeft ="100dp"
android :layout_marginTop ="16dp"
android :hint ="Username"
android :inputType ="text"
android :textColor ="@color/white"
android :textColorHint ="@color/white"
/>
<EditText
android :id ="@+id/editText_phone_rg"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/editText_username_rg" android :layout_centerHorizontal ="true"
android :layout_marginStart ="100dp"
android :layout_marginLeft ="100dp"
android :layout_marginTop ="16dp"
android :hint ="Phone"
android :inputType ="text"
android :textColor ="@color/white"
android :textColorHint ="@color/white"/>
<EditText
android :id ="@+id/editText_password_rg"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/editText_phone_rg" android :layout_centerHorizontal ="true"
android :layout_marginStart ="100dp"
android :layout_marginLeft ="100dp"
android :layout_marginTop ="16dp"
android :hint ="Password"
android :inputType ="textPassword"
android :textColor ="@color/white"
Trang 14android :textColorHint ="@color/white"
/>
<EditText
android :id ="@+id/editText_confirm_password_rg"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/editText_password_rg"
android :layout_centerHorizontal ="true"
android :layout_marginStart ="100dp"
android :layout_marginLeft ="100dp"
android :layout_marginTop ="16dp"
android :hint ="Confirm Password"
android :inputType ="textPassword"
android :textColor ="@color/white"
android :textColorHint ="@color/white"
/>
<Button
android :id ="@+id/button_register_rg"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/editText_confirm_password_rg" android :layout_centerHorizontal ="true"
android :layout_marginStart ="200dp"
android :layout_marginLeft ="200dp"
android :layout_marginTop ="16dp"
android :text ="Register"
android :backgroundTint ="@android:color/black"
android :textColor ="@color/white" />
<Button
android :id ="@+id/button_login_rg"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/button_register_rg"
android :layout_centerHorizontal ="true"
android :layout_marginStart ="200dp"
android :layout_marginLeft ="200dp"
android :layout_marginTop ="16dp"
android :text ="Login"
android :backgroundTint ="@android:color/black"
android :textColor ="@color/white" />
<TextView
android :id ="@+id/textView_error_message_rg"
android :layout_width ="match_parent"
android :layout_height ="wrap_content"
android :layout_below ="@id/button_login_rg"
android :layout_marginTop ="16dp"
android :layout_marginBottom ="10dp"
android :gravity ="center"
android :textColor ="#FF0000" />