Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #22 from farm-mate/fix/#19-writediary-xml #23

Open
wants to merge 56 commits into
base: fix/#19-writediary-xml
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1d8f9aa
Merge pull request #22 from farm-mate/fix/#19-writediary-xml
sujinjinsu Jul 24, 2023
e8fec09
Merge pull request #24 from farm-mate/fix/#19-writediary-xml
sujinjinsu Jul 24, 2023
5c8605b
Merge pull request #25 from farm-mate/fix/#19-writediary-xml
sujinjinsu Jul 31, 2023
6eddee3
feat/#26 plant post request code
Jul 31, 2023
37fbfa1
Merge pull request #27 from farm-mate/feat/#26-plant-postrequest
Jeongbin1 Jul 31, 2023
5aac906
write diary - linking server, feat.post
sujinjinsu Jul 31, 2023
e8db642
Merge pull request #28 from farm-mate/feat/#27-writediary-linking-server
sujinjinsu Jul 31, 2023
60bdd74
[fix]- min/max temp
sujinjinsu Jul 31, 2023
d547b94
Merge pull request #29 from farm-mate/fix/#28-home-min,maxweather
sujinjinsu Jul 31, 2023
9d29466
fix/#30 plant post request restore
Jul 31, 2023
c396df2
Merge pull request #31 from farm-mate/fix/#30-plant-post-restore
Jeongbin1 Jul 31, 2023
3a47c42
fix/#30 plant post request
Aug 30, 2023
0b76212
Merge pull request #33 from farm-mate/fix/32-plant-post-request
Jeongbin1 Aug 30, 2023
102877a
feat/#34-deviceId-post-request
Sep 2, 2023
e8fec14
Merge pull request #35 from farm-mate/feat/#34-deviceId-post-request
Jeongbin1 Sep 2, 2023
886a4f2
feat/#35 (recent)
Feb 19, 2024
15a5362
Merge pull request #37 from farm-mate/feat/#36
Jeongbin1 Feb 19, 2024
7153a30
#38-diary-calendar:feat/#38 diary_calendar
Feb 29, 2024
5cde13f
Merge pull request #39 from farm-mate/feat/#38-diary-calendar
Jeongbin1 Feb 29, 2024
1bedf70
feat/#40 diagnosis add camera
Mar 2, 2024
e5e10e8
Merge pull request #41 from farm-mate/feat/#40-diagnosis-addcamera
Jeongbin1 Mar 2, 2024
3df0a12
feat/#42 home weather
Mar 3, 2024
74eb9e0
Merge pull request #43 from farm-mate/feat/#42-home-weather
Jeongbin1 Mar 3, 2024
90b1782
#42-home-weather(2)
Mar 3, 2024
ce670b2
Merge pull request #44 from farm-mate/feat/#42-home-weather
Jeongbin1 Mar 3, 2024
38b2f70
[feat] plant, diary 갤러리 기능 추가
Mar 4, 2024
e7e0650
Merge pull request #46 from farm-mate/feat/#45-plant-diary-addgallery
Jeongbin1 Mar 4, 2024
55d9564
feat/#47-plant-diary-addbutton
Mar 5, 2024
b07d49a
Merge pull request #48 from farm-mate/feat/#47-plant-diary-addbutton
Jeongbin1 Mar 5, 2024
e9b1118
feat/#49 diagnosis listitem
Mar 6, 2024
de6eb72
Merge pull request #50 from farm-mate/feat/#49-diagnosis-listitem
Jeongbin1 Mar 6, 2024
81796fd
feat/#41 plant get post 요청 + 이미지
Mar 7, 2024
14d3334
Merge pull request #52 from farm-mate/feat/#51-api-topbar
Jeongbin1 Mar 7, 2024
a8b61d4
feat/#53 plant info get 요청
Mar 7, 2024
50cf2c2
Merge pull request #54 from farm-mate/feat/#53-api-plantinfo-get
Jeongbin1 Mar 7, 2024
eb63d96
수정
Mar 11, 2024
3d8b86d
Merge pull request #56 from farm-mate/feat/#55-home-collectionview
Jeongbin1 Mar 11, 2024
3956d76
feat/식물 수정 화면
Mar 11, 2024
d50a7ec
feat/api-수정삭제(북마크식물일지)
Mar 13, 2024
9e5069a
fix - 진단api, 수정기능 이미지
Mar 14, 2024
7984f97
feat - 진단 응답 받아와서 데이터 할당
Mar 14, 2024
cd76de8
fix - 다이어리 해당 식물 것만 나오도록 수정
Mar 14, 2024
ea5892f
fix - 다이어리 점 수정
Mar 14, 2024
8182c1c
fix - 비료 추적 되도록 수정
Mar 14, 2024
04f6612
feat - openapi 병 목록 조회, 검색
Mar 16, 2024
0f65769
feat - 병검색 상세페이지 화면
Mar 17, 2024
fa3425c
feat - 병 상세검색 연결
Mar 17, 2024
3300b61
fix - 검색 탭 이미지뷰 수정
Mar 17, 2024
edecce2
fix - diaryedit 이미지
Mar 17, 2024
ea5c09b
fix - 하단바, 스피너
Mar 17, 2024
ac2466f
feat - 진단 결과 post
Mar 18, 2024
3a3c3e9
feat - 식물 개별 > 일지, 진단
Mar 18, 2024
e731998
feat - 진단 개별 get
Mar 19, 2024
aea8f83
진단 수정
Mar 19, 2024
80bc13b
아이콘 수정
Mar 19, 2024
aabf7f5
수정 - 날짜 밀림
Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies {
//레트로핏 서버
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.android.gms:play-services-location:19.0.1'
implementation 'com.google.android.gms:play-services-location:21.0.1'

//비동기
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
Expand All @@ -79,4 +79,7 @@ dependencies {

//날씨
implementation 'com.loopj.android:android-async-http:1.4.11'

// Calendar
implementation 'com.github.prolificinteractive:material-calendarview:1.4.3'
}
18 changes: 12 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,42 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />


<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/ic_launcher1"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".IntroActivity"
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=".IntroActivity"
android:name=".MainActivity"
android:windowSoftInputMode="adjustPan"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
Expand Down
Binary file added app/src/main/ic_launcher1-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
145 changes: 125 additions & 20 deletions app/src/main/java/com/example/farmmate1/ApiService.kt
Original file line number Diff line number Diff line change
@@ -1,36 +1,141 @@
package com.example.farmmate1

import com.example.farmmate1.data.TodoItem
import com.example.farmmate1.network.ToDoListInterface
import retrofit2.Call
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.*
import okhttp3.MultipartBody
import okhttp3.RequestBody
import com.example.farmmate1.api.SearchResponse

interface ApiService {
@GET("plants")
fun getPlantList(): Call<List<Plant>>
// 서버에서 식물 정보를 가져오는 GET 요청을 정의

@POST("plants")
// 기기 등록
@POST("device")
@Headers("Content-Type: application/json")
fun createPlant(@Body plant: Plant): Call<Plant>
fun saveDeviceInfo(@Body deviceInfo: DeviceInfo): Call<Void>

@GET("plants")
fun getPlant(): Call<Plant>
//-------------------------------------------------------------------------------

// 식물 전체 GET 요청
@GET("plant/device/{deviceId}")
fun getPlantList(@Path("deviceId") deviceId: String): Call<List<PlantGet>>
// 서버에서 식물 정보를 가져오는 GET 요청을 정의

@GET("history")
fun getHistoryList(): Call<List<History>>
// 서버에서 진단 결과를 가져오는 GET 요청을 정의
// 식물 POST 요청
@Multipart
@POST("plant")
fun postPlant(
@PartMap data: HashMap<String, RequestBody>,
@Part image: MultipartBody.Part? // 이미지 파일을 MultipartBody.Part로 전송
): Call<PlantPost>

@POST("history")
@Headers("Content-Type: application/json")
fun saveResult(@Body history: History): Call<History>
// 식물 개별 GET 요청
@GET("plant/{plantUuid}")
fun getPlant(@Path("plantUuid") plantUuid: String?): Call<PlantGet>

// 식물 개별 PUT 요청
@Multipart
@PUT("plant/{plantUuid}")
fun editPlant(
@Path("plantUuid") plantUuid: String,
@PartMap data: HashMap<String, RequestBody>,
@Part image: MultipartBody.Part? // 이미지 파일을 MultipartBody.Part로 전송
): Call<PlantPost>

// 북마크 POST 요청
@POST("plant/{plantUuid}/bookmark")
fun postBookmark(@Path("plantUuid")plantUuid: String): Call<Void>

// 식물 DELETE 요청
@DELETE("plant/{plantUuid}")
fun deletePlant(@Path("plantUuid")plantUuid: String?): Call<Void>

// 북마크 GET 요청
@GET("plant/device/{deviceId}/bookmark")
fun getBookmark(@Path("deviceId")deviceId: String): Call<List<PlantGet>>

//-------------------------------------------------------------------------------

// 일지 post 요청
@Multipart
@POST("diary")
fun postDiary(
//@Query("plant_uuid") plantUuid: String?,
//@Path("plantUuid") plantUuid: String,
@PartMap data: HashMap<String, RequestBody>,
@Part image: MultipartBody.Part? // 이미지 파일을 MultipartBody.Part로 전송
): Call<DiaryPost>

// 일지 개별 GET 요청
@GET("diary/{diaryUuid}")
fun getDiary(@Path("diaryUuid") diaryUuid: String?): Call<DiaryGet>

// 모든 일지 GET 요청
@GET("diary")
//fun getDiaryList(@Query("plant.plant_name") plantName: String?): Call<List<DiaryGet>>
fun getDiaryList(): Call<List<DiaryGet>>

// 일지 개별 PUT 요청
@Multipart
@PUT("diary/{diaryUuid}")
fun editDiary(
@Path("diaryUuid") diaryUuid: String,
@PartMap data: HashMap<String, RequestBody>,
@Part image: MultipartBody.Part? // 이미지 파일을 MultipartBody.Part로 전송
): Call<DiaryPost>

// 이미지를 포함하지 않은 PUT 요청
@Multipart
@PUT("diary/{diaryUuid}")
fun editDiaryWithoutImage(
@Path("diaryUuid") diaryUuid: String,
@PartMap data: HashMap<String, RequestBody>,
): Call<DiaryPost>


// 일지 개별 DELETE 요청
@DELETE("diary/{diaryUuid}")
fun deleteDiary(@Path("diaryUuid")diaryUuid: String?): Call<Void>

//-------------------------------------------------------------------------------

// 진단 POST 요청
@Multipart
@POST("plant/diagnose")
fun postDiagnosis(
@Part("plantType") plantType: RequestBody,
@Part image: MultipartBody.Part
): Call<DiagnosisResult>

// 진단 결과 저장 POST 요청
@POST("plant/diagnose/result")
fun postDiagnosisSave(@Body request: DiagnosisSaveRequest): Call<Void>

// 식물별 진단 결과 GET 요청
@GET("plant/diagnose/result/plant/{plantUuid}")
fun getSavedResult(@Path("plantUuid") plantUuid: String?): Call<List<History>>

// 개별 진단 결과 GET 요청
@GET("plant/diagnose/result/{plantDiseaseUuid}")
fun getResult(@Path("plantDiseaseUuid") plantDiseaseUuid: String?): Call<History>

//-------------------------------------------------------------------------------

@GET("history")
fun getHistory(): Call<History>
@GET("service")
fun searchDiseases(
@Query("apiKey") apiKey: String,
@Query("serviceCode") serviceCode: String,
@Query("serviceType") serviceType: String,
@Query("cropName") cropName: String,
@Query("sickNameKor") sickNameKor: String,
@Query("displayCount") displayCount: Int,
@Query("startPoint") startPoint: Int
): Call<SearchResponse>

@GET("service")
fun getDetail(
@Query("apiKey") apiKey: String,
@Query("serviceCode") serviceCode: String,
@Query("sickKey") sickKey: String
): Call<SearchDetail>

}
74 changes: 74 additions & 0 deletions app/src/main/java/com/example/farmmate1/BookmarkAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.example.farmmate1

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class BookmarkAdapter(private val context: Context, private val bookmarkedPlants: List<PlantGet>) : BaseAdapter() {

override fun getCount(): Int {
return bookmarkedPlants.size
}

override fun getItem(position: Int): Any {
return bookmarkedPlants[position]
}

override fun getItemId(position: Int): Long {
return position.toLong()
}

override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
val view: View = convertView ?: LayoutInflater.from(context).inflate(R.layout.list_item_bookmark, parent, false)

val plantNameTextView: TextView = view.findViewById(R.id.bookmark_list_item_name)
val plantTypeTextView: TextView = view.findViewById(R.id.bookmark_list_item_type)
val firstPlantingDateTextView: TextView = view.findViewById(R.id.bookmark_list_item_startdate)
val bookmarkImg = view.findViewById<ImageView>(R.id.bookmark_list_item_profile)

val plant = bookmarkedPlants[position]
plantNameTextView.text = plant.plant_name
plantTypeTextView.text = plant.plant_type
firstPlantingDateTextView.text = plant.first_planting_date

val imageUrl = plant.image_url
ImageLoaderTask(bookmarkImg).execute(imageUrl)

view.setOnClickListener {
// 해당 항목의 plant_uuid 가져오기
val plantUuid = plant.plant_uuid

// 다음 프래그먼트로 전환하기 위해 번들에 데이터 추가
val bundle = Bundle()
bundle.putString("plantUuid", plantUuid)

val plantInfoFragment = PlantInfoFragment()
plantInfoFragment.arguments = bundle
//
// 다음 프래그먼트로 이동하고 번들에 담긴 데이터 전달
val transaction = (context as AppCompatActivity).supportFragmentManager.beginTransaction()
transaction.replace(R.id.main_fl, plantInfoFragment)
transaction.addToBackStack(null)
transaction.commit()

// parentFragmentManager
// requireActivity().supportFragmentManager
// .beginTransaction()
// .replace(R.id.main_fl, plantInfoFragment)
// .commit()

// val transaction = parentFragmentManager
// .beginTransaction()
// .replace(R.id.main_fl, diaryAddFragment)
// transaction.commit()
}

return view
}
}
71 changes: 71 additions & 0 deletions app/src/main/java/com/example/farmmate1/CustomMultipleDotSpan.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.example.farmmate1

import android.graphics.Canvas
import android.graphics.Paint
import android.text.style.LineBackgroundSpan
import android.util.Log

class CustomMultipleDotSpan(private val radius: Float = DEFAULT_RADIUS, private val colors: IntArray) : LineBackgroundSpan {

companion object {
private const val DEFAULT_RADIUS = 5f
}

// override fun drawBackground(
// canvas: Canvas, paint: Paint, left: Int, right: Int, top: Int, baseline: Int, bottom: Int,
// charSequence: CharSequence, start: Int, end: Int, lineNum: Int
// ) {
// val total = if (colors.size > 3) 3 else colors.size
// var leftMost = (total - 1) * -12
//
// for (i in 0 until total) {
// val oldColor = paint.color
// if (colors[i] != 0) {
// paint.color = colors[i]
// }
// canvas.drawCircle(((left + right) / 2 - leftMost).toFloat(), bottom + radius, radius, paint)
// paint.color = oldColor
// leftMost += 24
// }
// }
override fun drawBackground(
canvas: Canvas, paint: Paint, left: Int, right: Int, top: Int, baseline: Int, bottom: Int,
charSequence: CharSequence, start: Int, end: Int, lineNum: Int
) {
val total = colors.size
val centerX = (left + right) / 2 // 가운데 x 좌표

// 각 점 사이의 간격 계산
val interval: Float = if (total > 1) {
if (total % 2 == 0) { // 짝수인 경우
(right - left - radius * 2) / (total*3.3 - 1).toFloat()
} else { // 홀수인 경우
(right - left - radius * 2) / (total*2).toFloat()
}
} else {
0f
}

var currentX = centerX - (interval * (total - 1) / 2) // 첫 번째 점의 x 좌표 계산

for (i in 0 until total) {
val oldColor = paint.color
if (colors[i] != 0) {
paint.color = colors[i]
}

// 각 점의 x 좌표 계산
val x = currentX.toFloat()
Log.d("CustomMultipleDotSpan", "점 ${i + 1}의 x 좌표: $x")

canvas.drawCircle(x, bottom + radius, radius, paint) // 점 그리기
paint.color = oldColor

currentX += interval.toInt() // 다음 점으로 이동
}
}




}
3 changes: 3 additions & 0 deletions app/src/main/java/com/example/farmmate1/DeviceInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.example.farmmate1

data class DeviceInfo(val deviceId: String)
Loading