Skip to content

About

A wallpaper mobile app, using Kotlin, UnplashAPI and Firebase

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

28 Commits

Folders and files

Repository files navigation

WallpaperApplication

WallpaperApplication là ứng dụng Android xem ảnh nền được xây dựng để phục vụ cho project giữa kỳ của môn học Mobile Application Development (CSC13009). Ứng dụng sử dụng Unsplash API để hiển thị ảnh chất lượng cao, hỗ trợ tìm kiếm, xem chi tiết ảnh, lưu yêu thích, tải ảnh về máy và chia sẻ ảnh qua các ứng dụng khác.

Tổng quan

Với WallpaperApplication, người dùng có thể:

  • Xem danh sách ảnh nền từ Unsplash API.
  • Tìm kiếm ảnh theo từ khóa
  • Xem chi tiết ảnh và mở ảnh fullscreen
  • Đăng nhập bằng Google và lưu ảnh yêu thích theo từng tài khoản
  • Tải ảnh nền về thiết bị
  • Chia sẻ ảnh qua các ứng dụng khác

Tech Stack

  • Language: Kotlin
  • UI: XML Layout, Material Design, RecyclerView, ViewBinding
  • Architecture: MVVM, ViewModel, LiveData, Repository
  • Async: Kotlin Coroutines
  • Network: Retrofit, Gson, Unsplash API
  • Image Loading: Coil
  • Authentication & Database: Firebase Authentication, Cloud Firestore, Google Credential Manager
  • Platform: Android SDK 26+, Java 17, Gradle Kotlin DSL

Chức năng chính

Wallpaper Feed

  • Hiển thị ảnh từ Unsplash API bằng layout lưới 2 cột dạng StaggeredGrid
  • Hỗ trợ pull-to-refresh để tải lại danh sách ảnh mới
  • Hỗ trợ infinite scrolling để tải thêm ảnh khi cuộn
  • Random page khi load ảnh để nội dung đa dạng hơn

Search

  • Tìm kiếm ảnh nền theo từ khóa
  • Sử dụng debounce để hạn chế gọi API không cần thiết
  • Hỗ trợ phân trang kết quả tìm kiếm trong cùng photo feed

Image Detail

  • Mở ảnh được chọn bằng shared element transition
  • Hiển thị mô tả và ảnh preview kích thước lớn hơn
  • Hỗ trợ xem ảnh fullscreen
  • Cho phép tải ảnh về thư mục Pictures/Wallpaper
  • Chia sẻ ảnh an toàn thông qua FileProvider

Authentication

  • Hỗ trợ Google Sign-In bằng Credential Manager
  • Sử dụng Firebase Authentication để quản lý phiên đăng nhập
  • Hiển thị login dialog khi người dùng chưa đăng nhập nhưng muốn dùng tính năng yêu thích

Favorites

  • Cho phép người dùng đã đăng nhập thêm hoặc xóa ảnh yêu thích
  • Lưu danh sách ảnh yêu thích riêng cho từng user bằng Cloud Firestore
  • Kiểm tra trạng thái yêu thích khi mở màn hình chi tiết ảnh
  • Hiển thị toàn bộ ảnh đã lưu trong favorite gallery

Cấu trúc dự án

app/src/main/java/com/cuogne/wallpaperapplication/
├── data/
│   ├── api/              # Retrofit API service và client
│   ├── model/            # Model cho photo và search response
│   └── repository/       # Xử lý dữ liệu từ Unsplash và Firestore
├── ui/
│   ├── adapter/          # RecyclerView photo adapter
│   ├── auth/             # Google login dialog
│   ├── detail/           # Màn hình chi tiết ảnh và fullscreen preview
│   ├── favorite/         # Favorite gallery
│   └── main/             # Wallpaper feed và search
└── utils/                # Các hàm tiện ích

Yêu cầu

  • Android Studio Hedgehog hoặc mới hơn
  • JDK 17
  • Android SDK 26+
  • Firebase project
  • Unsplash developer account

Cài đặt

1. Clone project

git clone https://github.com/cuogne/WallpaperApplication.git
cd WallpaperApplication

2. Cấu hình Unsplash API key

Tạo hoặc cập nhật file local.properties trong thư mục root:

sdk.dir=/path/to/your/android/sdk
unsplash_api_key_access="YOUR_UNSPLASH_ACCESS_KEY"

Bạn có thể tạo Unsplash app và lấy access key tại:

https://unsplash.com/developers

3. Cấu hình Firebase

  1. Tạo Firebase project.
  2. Thêm Android app với package name:
com.cuogne.wallpaperapplication
  1. Tải file google-services.json và đặt vào:
app/google-services.json
  1. Bật các dịch vụ Firebase sau:
  • Authentication với Google Sign-In
  • Cloud Firestore

4. Cấu hình Google Web Client ID

Mở file:

app/src/main/res/values/strings.xml

Sau đó thay Web Client ID của Firebase:

<string name="default_web_client_id">YOUR_WEB_CLIENT_ID</string>

5. Cấu hình Firestore rules

Có thể dùng rules sau để đảm bảo mỗi user chỉ truy cập được dữ liệu yêu thích của chính mình:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;

      match /favorites/{photoId} {
        allow read, write: if request.auth != null && request.auth.uid == userId;
      }
    }
  }
}

Chạy ứng dụng

  1. Mở project bằng Android Studio.
  2. Đợi Gradle sync hoàn tất.
  3. Kết nối thiết bị thật hoặc khởi động emulator.
  4. Nhấn Run hoặc Shift + F10.

Demo

YouTube: https://youtu.be/hV-uFW7l1AI

About

A wallpaper mobile app, using Kotlin, UnplashAPI and Firebase

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages