Skip to content

Commit

Permalink
Merge pull request #21 from Kusitms-Hackathon-C/feature/20
Browse files Browse the repository at this point in the history
[Feat] #20
  • Loading branch information
PIYUJIN authored Oct 7, 2023
2 parents af15471 + ad09e64 commit 78d5101
Show file tree
Hide file tree
Showing 11 changed files with 892 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies {

implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.pcandriod.kusitms_hackathon_c.presentation.ui.main.write

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.pcandriod.kusitms_hackathon_c.R

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [WriteCompleteFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class WriteCompleteFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_write_complete, container, false)
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment WriteCompleteFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
WriteCompleteFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package com.pcandriod.kusitms_hackathon_c.presentation.ui.main.write

import android.content.Intent
import android.graphics.BitmapFactory
import android.graphics.ImageDecoder
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.provider.MediaStore
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.pcandriod.kusitms_hackathon_c.R
import com.pcandriod.kusitms_hackathon_c.databinding.FragmentWriteCustomerBinding
import com.pcandriod.kusitms_hackathon_c.databinding.FragmentWriteOwnerBinding
import com.pcandriod.kusitms_hackathon_c.presentation.ui.main.MainActivity

class WriteCustomerFragment : Fragment() {


lateinit var fragmentWriteCustomerBinding: FragmentWriteCustomerBinding
lateinit var mainActivity: MainActivity
lateinit var albumLauncher: ActivityResultLauncher<Intent>
// 업로드할 이미지의 Uri
var uploadUri: Uri? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {

fragmentWriteCustomerBinding = FragmentWriteCustomerBinding.inflate(inflater)
mainActivity = activity as MainActivity
// 앨범 설정
albumLauncher = albumSetting(fragmentWriteCustomerBinding.ivRegisterImage)

fragmentWriteCustomerBinding.run {

ivRegisterImage.visibility = View.GONE

ibtnClose.setOnClickListener {

}

btnComplete.setOnClickListener {
// 게시글 데이터 전송

}

ibtnRegisterImage.setOnClickListener{
// 앨범에서 사진을 선택할 수 있는 Activity를 실행한다.
val newIntent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
// 실행할 액티비티의 마임타입 설정(이미지로 설정해준다)
newIntent.setType("image/*")
// 선택할 파일의 타입을 지정(안드로이드 OS가 이미지에 대한 사전 작업을 할 수 있도록)
val mimeType = arrayOf("image/*")
newIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimeType)

// 액티비티를 실행한다.
albumLauncher.launch(newIntent)

val handler = Handler()
handler.postDelayed({
ivRegisterImage.visibility = View.VISIBLE
ibtnRegisterImage.visibility = View.GONE
}, 2000) // 2000ms (2초) 후에 RecyclerView 생성
}

}


return fragmentWriteCustomerBinding.root
}

// 앨범 설정
fun albumSetting(previewImageView: ImageView): ActivityResultLauncher<Intent> {
val albumContract = ActivityResultContracts.StartActivityForResult()
val albumLauncher = registerForActivityResult(albumContract) {
if (it?.resultCode == AppCompatActivity.RESULT_OK) {
// 선택한 이미지에 접근할 수 있는 Uri 객체를 추출한다.
if (it.data?.data != null) {
uploadUri = it.data?.data

// 안드로이드 10 (Q) 이상이라면...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// 이미지를 생성할 수 있는 디코더를 생성한다.
val source = ImageDecoder.createSource(mainActivity.contentResolver, uploadUri!!)
// Bitmap객체를 생성한다.
val bitmap = ImageDecoder.decodeBitmap(source)

previewImageView.setImageBitmap(bitmap)
} else {
// 컨텐츠 프로바이더를 통해 이미지 데이터 정보를 가져온다.
val cursor = mainActivity.contentResolver.query(uploadUri!!, null, null, null, null)
if (cursor != null) {
cursor.moveToNext()

// 이미지의 경로를 가져온다.
val idx = cursor.getColumnIndex(MediaStore.Images.Media.DATA)
val source = cursor.getString(idx)

// 이미지를 생성하여 보여준다.
val bitmap = BitmapFactory.decodeFile(source)
previewImageView.setImageBitmap(bitmap)
}
}
}
}
}

return albumLauncher
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package com.pcandriod.kusitms_hackathon_c.presentation.ui.main.write

import android.content.Intent
import android.graphics.BitmapFactory
import android.graphics.ImageDecoder
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.provider.MediaStore
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.pcandriod.kusitms_hackathon_c.R
import com.pcandriod.kusitms_hackathon_c.databinding.FragmentWriteOwnerBinding
import com.pcandriod.kusitms_hackathon_c.presentation.ui.main.MainActivity

class WriteOwnerFragment : Fragment() {

lateinit var fragmentWriteOwnerBinding: FragmentWriteOwnerBinding
lateinit var mainActivity: MainActivity
lateinit var albumLauncher: ActivityResultLauncher<Intent>
// 업로드할 이미지의 Uri
var uploadUri: Uri? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {

fragmentWriteOwnerBinding = FragmentWriteOwnerBinding.inflate(inflater)
mainActivity = activity as MainActivity
// 앨범 설정
albumLauncher = albumSetting(fragmentWriteOwnerBinding.ivRegisterImage)

fragmentWriteOwnerBinding.run {

ivRegisterImage.visibility = View.GONE

ibtnClose.setOnClickListener {

}

btnComplete.setOnClickListener {
// 게시글 데이터 전송

}

ibtnRegisterImage.setOnClickListener{
// 앨범에서 사진을 선택할 수 있는 Activity를 실행한다.
val newIntent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
// 실행할 액티비티의 마임타입 설정(이미지로 설정해준다)
newIntent.setType("image/*")
// 선택할 파일의 타입을 지정(안드로이드 OS가 이미지에 대한 사전 작업을 할 수 있도록)
val mimeType = arrayOf("image/*")
newIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimeType)

// 액티비티를 실행한다.
albumLauncher.launch(newIntent)

val handler = Handler()
handler.postDelayed({
ivRegisterImage.visibility = View.VISIBLE
ibtnRegisterImage.visibility = View.GONE
}, 2000) // 2000ms (2초) 후에 RecyclerView 생성
}

}


return fragmentWriteOwnerBinding.root
}

// 앨범 설정
fun albumSetting(previewImageView: ImageView): ActivityResultLauncher<Intent> {
val albumContract = ActivityResultContracts.StartActivityForResult()
val albumLauncher = registerForActivityResult(albumContract) {
if (it?.resultCode == AppCompatActivity.RESULT_OK) {
// 선택한 이미지에 접근할 수 있는 Uri 객체를 추출한다.
if (it.data?.data != null) {
uploadUri = it.data?.data

// 안드로이드 10 (Q) 이상이라면...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// 이미지를 생성할 수 있는 디코더를 생성한다.
val source = ImageDecoder.createSource(mainActivity.contentResolver, uploadUri!!)
// Bitmap객체를 생성한다.
val bitmap = ImageDecoder.decodeBitmap(source)

previewImageView.setImageBitmap(bitmap)
} else {
// 컨텐츠 프로바이더를 통해 이미지 데이터 정보를 가져온다.
val cursor = mainActivity.contentResolver.query(uploadUri!!, null, null, null, null)
if (cursor != null) {
cursor.moveToNext()

// 이미지의 경로를 가져온다.
val idx = cursor.getColumnIndex(MediaStore.Images.Media.DATA)
val source = cursor.getString(idx)

// 이미지를 생성하여 보여준다.
val bitmap = BitmapFactory.decodeFile(source)
previewImageView.setImageBitmap(bitmap)
}
}
}
}
}

return albumLauncher
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/home_icn_cancel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M1,1L8,8M15,15L8,8M8,8L15,1L1,15"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#202020"
android:strokeLineCap="round"/>
</vector>
35 changes: 35 additions & 0 deletions app/src/main/res/drawable/home_sos_write_btn_picture.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="134dp"
android:height="37dp"
android:viewportWidth="134"
android:viewportHeight="37">
<path
android:strokeWidth="1"
android:pathData="M18.5,0.5L115.5,0.5A18,18 0,0 1,133.5 18.5L133.5,18.5A18,18 0,0 1,115.5 36.5L18.5,36.5A18,18 0,0 1,0.5 18.5L0.5,18.5A18,18 0,0 1,18.5 0.5z"
android:fillColor="#FCFCFC"
android:strokeColor="#D7D7D7"/>
<path
android:pathData="M50.25,14.02H51.07V15.97C51.07,18.37 49.77,20.71 48.06,21.62L47.44,20.83C49.02,20.04 50.25,17.95 50.25,15.97V14.02ZM50.43,14.02H51.24V15.97C51.24,17.88 52.45,19.86 53.98,20.62L53.37,21.42C51.69,20.52 50.43,18.3 50.43,15.97V14.02ZM54.93,13.09H55.94V23.94H54.93V13.09ZM55.7,17.48H57.72V18.32H55.7V17.48ZM61.04,14.28H61.87V15.38C61.87,17.37 60.64,19.04 58.82,19.7L58.3,18.91C59.94,18.33 61.04,16.93 61.04,15.38V14.28ZM61.23,14.28H62.06V15.38C62.06,16.84 63.19,18.16 64.8,18.7L64.28,19.48C62.48,18.87 61.23,17.29 61.23,15.38V14.28ZM58.57,13.99H64.51V14.79H58.57V13.99ZM66.04,13.1H67.05V21.03H66.04V13.1ZM60.08,22.88H67.38V23.7H60.08V22.88ZM60.08,20.29H61.06V23.24H60.08V20.29ZM70.92,18.25H80.73V19.08H70.92V18.25ZM72.16,16.41H79.59V17.22H72.16V16.41ZM72.16,13.52H79.5V14.34H73.14V16.8H72.16V13.52ZM75.81,20.01C78.12,20.01 79.53,20.72 79.53,21.97C79.53,23.22 78.12,23.91 75.81,23.91C73.49,23.91 72.09,23.22 72.09,21.97C72.09,20.72 73.49,20.01 75.81,20.01ZM75.81,20.78C74.11,20.78 73.09,21.21 73.09,21.97C73.09,22.71 74.11,23.13 75.81,23.13C77.51,23.13 78.52,22.71 78.52,21.97C78.52,21.21 77.51,20.78 75.81,20.78ZM81.47,19.05H91.31V19.87H81.47V19.05ZM82.72,13.36H90.04V15.99H83.72V17.46H82.74V15.26H89.06V14.14H82.72V13.36ZM82.74,17.13H90.28V17.91H82.74V17.13ZM85.88,17.54H86.88V19.46H85.88V17.54ZM82.56,20.7H90.11V23.84H89.11V21.51H82.56V20.7ZM99.38,13.09H100.38V23.94H99.38V13.09ZM100.14,17.54H102.16V18.38H100.14V17.54ZM91.98,14.82H98.38V15.63H91.98V14.82ZM95.22,16.53C96.76,16.53 97.86,17.56 97.86,19.03C97.86,20.49 96.76,21.52 95.22,21.52C93.7,21.52 92.58,20.49 92.58,19.03C92.58,17.56 93.7,16.53 95.22,16.53ZM95.22,17.36C94.24,17.36 93.53,18.04 93.53,19.03C93.53,20 94.24,20.7 95.22,20.7C96.2,20.7 96.91,20 96.91,19.03C96.91,18.04 96.2,17.36 95.22,17.36ZM94.7,13.22H95.7V15.19H94.7V13.22ZM110.5,13.09H111.49V23.94H110.5V13.09ZM107.32,14.25H108.3C108.3,17.4 106.88,20.14 103.26,21.92L102.73,21.12C105.86,19.6 107.32,17.3 107.32,14.42V14.25ZM103.22,14.25H107.75V15.07H103.22V14.25Z"
android:fillColor="#202020"/>
<path
android:pathData="M36,10H22C20.9,10 20,10.9 20,12V26C20,27.1 20.9,28 22,28H36C37.1,28 38,27.1 38,26V12C38,10.9 37.1,10 36,10Z"
android:strokeLineJoin="round"
android:strokeWidth="1.5"
android:fillColor="#00000000"
android:strokeColor="#54D4D3"
android:strokeLineCap="round"/>
<path
android:pathData="M25.5,17C26.33,17 27,16.33 27,15.5C27,14.67 26.33,14 25.5,14C24.67,14 24,14.67 24,15.5C24,16.33 24.67,17 25.5,17Z"
android:strokeLineJoin="round"
android:strokeWidth="1.5"
android:fillColor="#00000000"
android:strokeColor="#54D4D3"
android:strokeLineCap="round"/>
<path
android:pathData="M38,22L33,17L22,28"
android:strokeLineJoin="round"
android:strokeWidth="1.5"
android:fillColor="#00000000"
android:strokeColor="#54D4D3"
android:strokeLineCap="round"/>
</vector>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_marker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="42dp"
android:viewportWidth="50"
android:viewportHeight="42">
<path
android:pathData="M9.068,1C7.028,1 5.216,2.303 4.568,4.238L1.25,14.128C0.218,17.203 2.507,20.385 5.751,20.385H6.272V36.209C6.272,38.831 8.398,40.956 11.02,40.956H38.316C40.938,40.956 43.064,38.831 43.064,36.209V20.385H43.502C46.654,20.385 48.931,17.369 48.068,14.338L45.253,4.448C44.672,2.407 42.808,1 40.687,1H9.068Z"
android:fillColor="#808080"
android:fillType="evenOdd"/>
<path
android:pathData="M4.568,4.238L3.619,3.92L3.619,3.92L4.568,4.238ZM1.25,14.128L2.198,14.446L2.198,14.446L1.25,14.128ZM6.272,20.385H7.272V19.385H6.272V20.385ZM43.064,20.385V19.385H42.064V20.385H43.064ZM48.068,14.338L49.03,14.064L49.03,14.064L48.068,14.338ZM45.253,4.448L44.291,4.722L44.291,4.722L45.253,4.448ZM5.516,4.556C6.028,3.029 7.458,2 9.068,2V0C6.598,0 4.405,1.578 3.619,3.92L5.516,4.556ZM2.198,14.446L5.516,4.556L3.619,3.92L0.302,13.81L2.198,14.446ZM5.751,19.385C3.19,19.385 1.384,16.873 2.198,14.446L0.302,13.81C-0.947,17.533 1.824,21.385 5.751,21.385V19.385ZM6.272,19.385H5.751V21.385H6.272V19.385ZM7.272,36.209V20.385H5.272V36.209H7.272ZM11.02,39.956C8.95,39.956 7.272,38.278 7.272,36.209H5.272C5.272,39.383 7.846,41.956 11.02,41.956V39.956ZM38.316,39.956H11.02V41.956H38.316V39.956ZM42.064,36.209C42.064,38.278 40.386,39.956 38.316,39.956V41.956C41.491,41.956 44.064,39.383 44.064,36.209H42.064ZM42.064,20.385V36.209H44.064V20.385H42.064ZM43.502,19.385H43.064V21.385H43.502V19.385ZM47.106,14.612C47.787,17.005 45.99,19.385 43.502,19.385V21.385C47.318,21.385 50.074,17.734 49.03,14.064L47.106,14.612ZM44.291,4.722L47.106,14.612L49.03,14.064L46.215,4.174L44.291,4.722ZM40.687,2C42.362,2 43.833,3.111 44.291,4.722L46.215,4.174C45.512,1.704 43.255,0 40.687,0V2ZM9.068,2H40.687V0H9.068V2Z"
android:fillColor="#FCFCFC"/>
</vector>
Loading

0 comments on commit 78d5101

Please sign in to comment.