diff --git a/app/build.gradle b/app/build.gradle index 2184382..c541a1c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -64,4 +64,8 @@ dependencies { implementation 'com.squareup.retrofit2:retrofit:2.9.0' // 레트로핏 설치 (필수) implementation 'com.squareup.retrofit2:converter-gson:2.9.0' // 컨버터 (선택) implementation 'com.google.code.gson:gson:2.9.1' //GSON (선택) + + // material-calendarview + implementation 'com.github.prolificinteractive:material-calendarview:2.0.1' + implementation 'com.jakewharton.threetenabp:threetenabp:1.4.0' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 09eb59d..5b79d61 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,9 +7,9 @@ android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" - android:icon="@mipmap/ic_launcher" + android:icon="@mipmap/ic_main" android:label="@string/app_name" - android:roundIcon="@mipmap/ic_launcher_round" + android:roundIcon="@mipmap/ic_main_round" android:supportsRtl="true" android:theme="@style/Theme.SujungVillageAdmin" tools:targetApi="31"> diff --git a/app/src/main/ic_main-playstore.png b/app/src/main/ic_main-playstore.png new file mode 100644 index 0000000..08821da Binary files /dev/null and b/app/src/main/ic_main-playstore.png differ diff --git a/app/src/main/java/kr/co/sujungvillage_admin/api/HomeService.kt b/app/src/main/java/kr/co/sujungvillage_admin/api/HomeService.kt new file mode 100644 index 0000000..f12a431 --- /dev/null +++ b/app/src/main/java/kr/co/sujungvillage_admin/api/HomeService.kt @@ -0,0 +1,17 @@ +package kr.co.sujungvillage_admin.api + +import kr.co.sujungvillage_admin.retrofit.HomeInfoResultDTO +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Header +import retrofit2.http.Query + +interface HomeService { + // 관리자 홈 화면 정보 조회 + @GET("/api/admin/home_info") + fun homeInfo( + @Header("user_id") userId: String, + @Query("year") year: String, + @Query("month") month: String, + ): Call +} \ No newline at end of file diff --git a/app/src/main/java/kr/co/sujungvillage_admin/data/Home.kt b/app/src/main/java/kr/co/sujungvillage_admin/data/Home.kt new file mode 100644 index 0000000..74ac658 --- /dev/null +++ b/app/src/main/java/kr/co/sujungvillage_admin/data/Home.kt @@ -0,0 +1,20 @@ +package kr.co.sujungvillage_admin.retrofit + +import com.google.gson.annotations.SerializedName +import java.io.Serializable + +data class HomeInfoResultDTO( + @SerializedName("adminInfo") + val adminInfo: HomeAdminInfo, + @SerializedName("rollcallDays") + val rollcallDays: List, +): Serializable {} + +data class HomeAdminInfo( + @SerializedName("name") + val name: String, + @SerializedName("dormitoryName") + val dormitory: String, + @SerializedName("description") + val description: String, +): Serializable {} diff --git a/app/src/main/java/kr/co/sujungvillage_admin/fragment/HomeFragment.kt b/app/src/main/java/kr/co/sujungvillage_admin/fragment/HomeFragment.kt index 6b85794..e7bf247 100644 --- a/app/src/main/java/kr/co/sujungvillage_admin/fragment/HomeFragment.kt +++ b/app/src/main/java/kr/co/sujungvillage_admin/fragment/HomeFragment.kt @@ -1,25 +1,44 @@ package kr.co.sujungvillage_admin.fragment import android.content.Intent +import android.graphics.Color import android.os.Bundle +import android.text.style.ForegroundColorSpan +import android.util.Log import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import com.prolificinteractive.materialcalendarview.CalendarDay +import com.prolificinteractive.materialcalendarview.DayViewDecorator +import com.prolificinteractive.materialcalendarview.DayViewFacade import kr.co.sujungvillage_admin.AlarmActivity import kr.co.sujungvillage_admin.NoticeActivity import kr.co.sujungvillage_admin.R +import kr.co.sujungvillage_admin.RollCallActivity import kr.co.sujungvillage_admin.databinding.FragmentHomeBinding +import kr.co.sujungvillage_admin.retrofit.HomeInfoResultDTO +import kr.co.sujungvillage_admin.retrofit.RetrofitBuilder +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response class HomeFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val binding = FragmentHomeBinding.inflate(inflater, container, false) + // ★★★ 재사생 학번 불러오기 + val userNum = "99990001" + // lottie 이미지 회전 binding.imgWave.rotationX = 180f // 알림 버튼 연결 + binding.btnAlarm.setOnClickListener { + var intent = Intent(this.activity, AlarmActivity::class.java) + startActivity(intent) + } // 홈화면 주요 기능 버튼 연결 // 1. 공지사항 버튼 연결 @@ -29,13 +48,81 @@ class HomeFragment : Fragment() { } // 2. 상벌점 관리 버튼 연결 // 3. 점호 확인 버튼 연결 - // 4. 재사생 관리 버튼 연결 - // 5. 알람 버튼 연결 - binding.btnAlarm.setOnClickListener { - var intent = Intent(this.activity, AlarmActivity::class.java) + binding.btnRollcall.setOnClickListener { + var intent = Intent(this.activity, RollCallActivity::class.java) startActivity(intent) } + // 4. 재사생 관리 버튼 연결 + + // 관리자 홈 화면 정보 조회 API 연결 + RetrofitBuilder.homeApi.homeInfo(userNum, binding.calendar.currentDate.year.toString(), binding.calendar.currentDate.month.toString()).enqueue(object : Callback { + override fun onResponse(call: Call, response: Response) { + Log.d("HOME_INFO", "홈 화면 정보 조회 성공") + Log.d("HOME_INFO", "user : " + response.body()?.adminInfo.toString()) + Log.d("HOME_INFO", "roll-call days : " + response.body()?.rollcallDays.toString()) + + // 유저 정보 반영 + binding.textName.text = response.body()?.adminInfo?.name + binding.textDormitory.text = + response.body()?.adminInfo?.dormitory + " 기숙사 " + response.body()?.adminInfo?.description + " 담당" + + // 캘린더 정보 반영 + val rollcallDecorator = RollcallDecorator(this@HomeFragment, response.body()!!.rollcallDays) + val todayDecorator = TodayDecorator(this@HomeFragment) + binding.calendar.addDecorators(rollcallDecorator, todayDecorator) + } + + override fun onFailure(call: Call, t: Throwable) { + Log.d("HOME_INFO", "홈 화면 정보 조회 실패") + Log.d("HOME_INFO", t.message.toString()) + } + }) + + // 캘린더 좌우 버튼 연결 + binding.calendar.setOnMonthChangedListener { widget, date -> + RetrofitBuilder.homeApi.homeInfo(userNum, date.year.toString(), date.month.toString()).enqueue(object : Callback { + override fun onResponse(call: Call, response: Response) { + Log.d("HOME_INFO", "캘린더 정보 조회 성공") + Log.d("HOME_INFO", "roll-call days : " + response.body()?.rollcallDays.toString()) + + // 캘린더 정보 반영 + val rollcallDecorator = RollcallDecorator(this@HomeFragment, response.body()!!.rollcallDays) + val todayDecorator = TodayDecorator(this@HomeFragment) + binding.calendar.addDecorators(rollcallDecorator, todayDecorator) + } + + override fun onFailure(call: Call, t: Throwable) { + Log.d("HOME_INFO", "캘린더 정보 조회 실패") + Log.d("HOME_INFO", t.message.toString()) + } + }) + } return binding.root } +} + +// 점호일 커스텀 함수 +class RollcallDecorator(context: HomeFragment, days: List) : DayViewDecorator { + val rollcallDrawable = context.resources.getDrawable(R.drawable.style_home_cal_rollcall) + val days = days + + override fun shouldDecorate(day: CalendarDay?): Boolean { // 커스텀 여부 반환 + return days.contains(day?.day) + } + + override fun decorate(view: DayViewFacade?) { // 커스텀 설정 + view?.setBackgroundDrawable(rollcallDrawable) + } +} + +// 오늘 커스텀 함수 +class TodayDecorator(context: HomeFragment) : DayViewDecorator { + override fun shouldDecorate(day: CalendarDay?): Boolean { // 커스텀 여부 반환 + return return day?.equals(CalendarDay.today())!! + } + + override fun decorate(view: DayViewFacade?) { // 커스텀 설정 + view?.addSpan(object : ForegroundColorSpan(Color.parseColor("#FF9AE000")) {}) + } } \ No newline at end of file diff --git a/app/src/main/java/kr/co/sujungvillage_admin/fragment/SettingFragment.kt b/app/src/main/java/kr/co/sujungvillage_admin/fragment/SettingFragment.kt index adebaf2..ba5e534 100644 --- a/app/src/main/java/kr/co/sujungvillage_admin/fragment/SettingFragment.kt +++ b/app/src/main/java/kr/co/sujungvillage_admin/fragment/SettingFragment.kt @@ -1,18 +1,52 @@ package kr.co.sujungvillage_admin.fragment +import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import kr.co.sujungvillage_admin.AlarmActivity import kr.co.sujungvillage_admin.R import kr.co.sujungvillage_admin.databinding.FragmentSettingBinding +import kr.co.sujungvillage_admin.retrofit.HomeInfoResultDTO +import kr.co.sujungvillage_admin.retrofit.RetrofitBuilder +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response class SettingFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val binding = FragmentSettingBinding.inflate(inflater, container, false) + // ★★★ 재사생 학번 불러오기 + val userNum = "99990001" + + // 알림 버튼 연결 + binding.btnAlarm.setOnClickListener { + var intent = Intent(this.activity, AlarmActivity::class.java) + startActivity(intent) + } + + // 설정 화면 정보 조회 API 연결 (홈 화면 정보 조회 API 활용) + RetrofitBuilder.homeApi.homeInfo(userNum, "2022", "8").enqueue(object : Callback { + override fun onResponse(call: Call, response: Response) { + Log.d("HOME_INFO", "설정 화면 정보 조회 성공") + Log.d("HOME_INFO", "user : " + response.body()?.adminInfo.toString()) + + // 유저 정보 반영 + binding.textName.text = response.body()?.adminInfo?.name + binding.textCharge.text = "담당 : " + response.body()?.adminInfo?.dormitory + " " + response.body()?.adminInfo?.description + } + + override fun onFailure(call: Call, t: Throwable) { + Log.d("HOME_INFO", "홈 화면 정보 조회 실패") + Log.d("HOME_INFO", t.message.toString()) + } + }) + return binding.root } } \ No newline at end of file diff --git a/app/src/main/java/kr/co/sujungvillage_admin/retrofit/RetrofitBuilder.kt b/app/src/main/java/kr/co/sujungvillage_admin/retrofit/RetrofitBuilder.kt index ec09f16..9ae97a3 100644 --- a/app/src/main/java/kr/co/sujungvillage_admin/retrofit/RetrofitBuilder.kt +++ b/app/src/main/java/kr/co/sujungvillage_admin/retrofit/RetrofitBuilder.kt @@ -2,6 +2,7 @@ package kr.co.sujungvillage_admin.retrofit import com.google.gson.GsonBuilder import kr.co.sujungvillage_admin.BuildConfig.BASE_URL +import kr.co.sujungvillage_admin.api.HomeService import kr.co.sujungvillage_admin.api.NoticeService import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory @@ -9,6 +10,7 @@ import retrofit2.converter.gson.GsonConverterFactory object RetrofitBuilder { // 사용할 API 인터페이스 선언 var noticeApi: NoticeService + var homeApi: HomeService val gson = GsonBuilder().setLenient().create() @@ -20,5 +22,6 @@ object RetrofitBuilder { .build() noticeApi = retrofit.create(NoticeService::class.java) + homeApi = retrofit.create(HomeService::class.java) } } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_main_background.xml b/app/src/main/res/drawable/ic_main_background.xml new file mode 100644 index 0000000..ca3826a --- /dev/null +++ b/app/src/main/res/drawable/ic_main_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/style_home_cal_rollcall.xml b/app/src/main/res/drawable/style_home_cal_rollcall.xml new file mode 100644 index 0000000..af925bf --- /dev/null +++ b/app/src/main/res/drawable/style_home_cal_rollcall.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 4031347..2445c86 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -243,30 +243,28 @@ - + app:mcv_dateTextAppearance="@style/calendar_date_text_default" + app:mcv_headerTextAppearance="@style/calendar_header_text_default" + app:mcv_weekDayTextAppearance="@style/calendar_week_text_default" + app:mcv_selectionMode="none" /> - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_main.xml b/app/src/main/res/mipmap-anydpi-v26/ic_main.xml new file mode 100644 index 0000000..7c7c2d2 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_main.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_main_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_main_round.xml new file mode 100644 index 0000000..7c7c2d2 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_main_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_main.png b/app/src/main/res/mipmap-hdpi/ic_main.png new file mode 100644 index 0000000..062d62e Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_main.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_main_foreground.png b/app/src/main/res/mipmap-hdpi/ic_main_foreground.png new file mode 100644 index 0000000..9875e0d Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_main_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_main_round.png b/app/src/main/res/mipmap-hdpi/ic_main_round.png new file mode 100644 index 0000000..c083a24 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_main_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_main.png b/app/src/main/res/mipmap-mdpi/ic_main.png new file mode 100644 index 0000000..64c8978 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_main.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_main_foreground.png b/app/src/main/res/mipmap-mdpi/ic_main_foreground.png new file mode 100644 index 0000000..9d49420 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_main_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_main_round.png b/app/src/main/res/mipmap-mdpi/ic_main_round.png new file mode 100644 index 0000000..07c8122 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_main_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_main.png b/app/src/main/res/mipmap-xhdpi/ic_main.png new file mode 100644 index 0000000..3513560 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_main.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_main_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_main_foreground.png new file mode 100644 index 0000000..c8ac42a Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_main_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_main_round.png b/app/src/main/res/mipmap-xhdpi/ic_main_round.png new file mode 100644 index 0000000..fb988bf Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_main_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_main.png b/app/src/main/res/mipmap-xxhdpi/ic_main.png new file mode 100644 index 0000000..64b9bce Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_main.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_main_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_main_foreground.png new file mode 100644 index 0000000..dfd867e Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_main_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_main_round.png b/app/src/main/res/mipmap-xxhdpi/ic_main_round.png new file mode 100644 index 0000000..b473d96 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_main_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_main.png b/app/src/main/res/mipmap-xxxhdpi/ic_main.png new file mode 100644 index 0000000..21cbe7f Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_main.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_main_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_main_foreground.png new file mode 100644 index 0000000..e0df9d7 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_main_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_main_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_main_round.png new file mode 100644 index 0000000..5e5306c Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_main_round.png differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5694754..4d55496 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - SujungVillage-Admin + 수정마을 관리자 Hello blank fragment \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..d14882f --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,25 @@ + + + + + + + + + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index cd0519b..1386732 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,7 @@ kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true + +# Duplicate class found ?? ??? ?? ??? ?? (?? ?? ??? ???) +android.enableJetifier=true \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index c25cf76..87b6a8f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,6 +10,7 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + maven { url 'https://jitpack.io' } } } rootProject.name = "SujungVillage-Admin"