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

해커톤 bottomSheet 구현 #63

Merged
merged 7 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 28 additions & 4 deletions .github/workflows/android-pull-request-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Android Pull Request CI
on:
push:
branches: [ develop ]
paths:
- 'android/**'
pull_request:
branches: [ develop ]
paths:
Expand Down Expand Up @@ -57,14 +59,36 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Create local.properties
env:
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
run: |
echo "$LOCAL_PROPERTIES" > local.properties

- name: Create google-services.json
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: |
touch ../android/app/google-services.json
echo GOOGLE_SERVICES_JSON >> ../android/app/google-services.json
cat ../android/app/google-services.json

- name: Lint Check
run: ./gradlew ktlintCheck

- name: Upload Event File
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}
name: Event File
path: ${{ github.event_path }}

- name: Create file
run: cat /home/runner/work/2024-friendogly/2024-friendogly/android/app/google-services.json | base64

- name: Putting data
env:
DATA: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: echo $DATA > /home/runner/work/2024-friendogly/2024-friendogly/android/app/google-services.json

- name: Run unit tests
run: ./gradlew testDebugUnitTest --stacktrace
Expand All @@ -73,5 +97,5 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results
path: "**/test-results/**/*.xml"
name: Test Results
path: "**/test-results/**/*.xml"
28 changes: 27 additions & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import java.io.FileInputStream
import java.util.Properties

plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
id("kotlin-kapt")
alias(libs.plugins.navigation.safeargs)
id("kotlin-kapt")
id("com.google.gms.google-services")
id("kotlin-parcelize")
kotlin("plugin.serialization")
}

val localPropertiesFile = rootProject.file("local.properties")
val localProperties = Properties()
localProperties.load(FileInputStream(localPropertiesFile))

val googleClientId = localProperties.getProperty("GOOGLE_CLIENT_ID") ?: ""

android {
namespace = "com.woowacourse.friendogly"
compileSdk = 34
Expand All @@ -17,6 +29,8 @@ android {
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

buildConfigField("String", "GOOGLE_CLIENT_ID", googleClientId)
}

buildTypes {
Expand All @@ -38,6 +52,9 @@ android {
dataBinding {
enable = true
}
buildFeatures {
buildConfig = true
}
}

dependencies {
Expand All @@ -52,4 +69,13 @@ dependencies {
testImplementation(libs.bundles.test)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)

// retrofit
implementation("com.squareup.retrofit2:retrofit:2.11.0")
implementation("com.squareup.retrofit2:converter-gson:2.11.0")
implementation("com.squareup.retrofit2:converter-kotlinx-serialization:2.11.0")

// serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")

}
8 changes: 8 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.Friendogly"
tools:targetApi="31">
<activity
android:name=".presentation.ui.profilesetting.ProfileSettingActivity"
android:exported="false" />
<activity
android:name=".presentation.ui.MainActivity"
android:exported="false" />
Expand All @@ -24,6 +27,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name="com.canhub.cropper.CropImageActivity"
android:theme="@style/Theme.ImageCropper" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.woowacourse.friendogly.presentation.ui.chatlist

import com.woowacourse.friendogly.R
import com.woowacourse.friendogly.databinding.FragmentChatListBinding
import com.woowacourse.friendogly.presentation.base.BaseFragment

class ChatListFragment : BaseFragment<FragmentChatListBinding>(R.layout.fragment_chat_list) {
override fun initViewCreated() {

binding.test.setOnClickListener {
val bottomSheet = WoofBottomSheet()
val bundle = WoofBottomSheet.getBundle(WoofDogUiModel("https://t1.daumcdn.net/thumb/R720x0.fjpg/?fname=http://t1.daumcdn.net/brunch/service/user/cnoC/image/PTcGsuuqjlyY1d9MxFkG7RAndmo.jpg",
"땡이","소형견",2,"땡이 닉네임이랑 땡이 강아지 이름 똑가틈"))
bottomSheet.arguments = bundle
bottomSheet.show(parentFragmentManager, "")
}
}




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.woowacourse.friendogly.presentation.ui.chatlist

import android.app.Dialog
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.woowacourse.friendogly.R
import com.woowacourse.friendogly.presentation.utils.bindGlide1000
import com.woowacourse.friendogly.presentation.utils.bundleParcelable

class WoofBottomSheet : BottomSheetDialogFragment() {

private lateinit var dlg: BottomSheetDialog

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
dlg = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
dlg.setOnShowListener {
val bottomSheet =
dlg.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout

val behavior = BottomSheetBehavior.from(bottomSheet)
behavior.isDraggable = false
behavior.state = BottomSheetBehavior.STATE_EXPANDED
}
return dlg
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.bottom_sheet_woof, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//setBackgroundTransparent()

val info = this.arguments?.bundleParcelable(EXTRA_DOG_INFO_ID, WoofDogUiModel::class.java)
?: error("dog info가 잘못 들어옴")

dlg.findViewById<TextView>(R.id.tv_woof_dog_name)?.text = info.name
dlg.findViewById<TextView>(R.id.tv_woof_dog_age)?.text = "${info.age} 살"
dlg.findViewById<TextView>(R.id.tv_woof_dog_gender)?.text = info.name
dlg.findViewById<TextView>(R.id.tv_woof_dog_size)?.text = info.size
dlg.findViewById<TextView>(R.id.tv_woof_dog_desc)?.text = info.description

Glide.with(requireContext())
.load(info.imageUrl)
.into(dlg.findViewById<ImageView>(R.id.iv_woof_dog)!!)

}

private fun setBackgroundTransparent() {
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
}

companion object {
private const val EXTRA_DOG_INFO_ID = "dogInfo"

fun getBundle(dog: WoofDogUiModel): Bundle {
return Bundle().apply { this.putParcelable(EXTRA_DOG_INFO_ID, dog) }
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.woowacourse.friendogly.presentation.ui.chatlist

import android.os.Parcelable
import kotlinx.parcelize.Parcelize


@Parcelize
data class WoofDogUiModel(
val imageUrl: String,
val name: String,
val size: String,
val age: Int,
val description: String,
): Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.woowacourse.friendogly.presentation.ui.profilesetting

import android.annotation.SuppressLint
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.databinding.BindingAdapter
import com.woowacourse.friendogly.R

@SuppressLint("SetTextI18n")
@BindingAdapter("editTextLength")
fun TextView.bindEditTextLength(contents: String?) {
val length = contents?.length ?: 0

val color =
if (length != 0) {
ContextCompat.getColor(context, R.color.black)
} else {
ContextCompat.getColor(context, R.color.gray05)
}

this.apply {
text = "$length/15"
setTextColor(color)
}
}

@SuppressLint("UseCompatLoadingForDrawables")
@BindingAdapter("editBtnBackgroundTextColor")
fun TextView.bindEditBtnBackground(contents: String?) {
val length = contents?.length ?: 0

if (length > 0) {
this.background = context.getDrawable(R.drawable.rect_blue_fill_16)
this.setTextColor(context.getColor(R.color.black))
} else {
this.background = context.getDrawable(R.drawable.rect_gray03_fill_16)
this.setTextColor(context.getColor(R.color.gray08))
}
}
Loading
Loading