Skip to content

Commit

Permalink
Merge pull request #24 from NaJuDoRyeong/feature/#23-story-api
Browse files Browse the repository at this point in the history
Feature/#23 story api
  • Loading branch information
KDW03 authored Feb 18, 2023
2 parents 13fdb60 + e9bbbc1 commit 0e00482
Show file tree
Hide file tree
Showing 116 changed files with 1,724 additions and 328 deletions.
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/git_toolbox_prj.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions app/src/main/java/com/najudoryeong/mineme/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ package com.najudoryeong.mineme
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.activity.viewModels
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.NavigationUI
import androidx.navigation.ui.setupWithNavController
import com.najudoryeong.mineme.common_ui.MainActivityUtil
import com.najudoryeong.mineme.databinding.ActivityMainBinding
import dagger.hilt.android.AndroidEntryPoint
import com.najudoryeong.mineme.story.R.id.storyFragment
import com.najudoryeong.mineme.home.R.id.homeFragment


// 하위 모듈이 MainViewModel 코드에 접근할 수 있게 MainViewModelUtil 상속 구현
Expand Down Expand Up @@ -47,7 +46,7 @@ class MainActivity : AppCompatActivity(), MainActivityUtil {
// appbar 구성 요소 설정
// 바텀네비게이션과 연결하면 해당 프래그먼트에 네비게이션으로는 backButton x
appBarConfiguration = AppBarConfiguration(
setOf(R.id.nav_home, R.id.nav_setting, R.id.nav_setting)
setOf(homeFragment, storyFragment, R.id.nav_setting)
)

// navController 와 actionbar 연결
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/najudoryeong/mineme/MainViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.najudoryeong.mineme

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.najudoryeong.mineme

import android.app.Application
import android.util.Log
import com.example.common.util.NATIVE_APP_KEY
import com.najudoryeong.mineme.common.util.NATIVE_APP_KEY
import com.kakao.sdk.common.KakaoSdk
import com.kakao.sdk.common.util.Utility
import dagger.hilt.android.HiltAndroidApp
Expand All @@ -12,11 +12,12 @@ class MineMeApplication : Application() {
override fun onCreate() {
super.onCreate()
KakaoSdk.init(this, NATIVE_APP_KEY)
//printAppKeyHash()
printAppKeyHash()
}

private fun printAppKeyHash() {
val keyHash = Utility.getKeyHash(this)
Log.d("KeyHash", keyHash)
//RBBgnAEhRDraP7W34/nu69W5cMc=
}
}
6 changes: 4 additions & 2 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Mineme" parent="Theme.MaterialComponents.Light.NoActionBar">
<style name="Theme.Mineme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">

<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
Expand All @@ -12,6 +12,8 @@
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<!-- Customize your theme here. -->
<item name="android:statusBarColor">@color/black</item>

</style>


Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ buildscript {
kakao_version = '2.12.1'
dataStorePreferences_version = '1.0.0'
retrofit2Version = '2.9.0'
recyclerViewVersion = '1.2.1'
swipeRefreshLayoutVersion = '1.1.0'
materialVersion='1.8.0'
appCompatVersion='1.6.1'

}

Expand Down
11 changes: 11 additions & 0 deletions common-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ android {

dependencies {

api project(path: ':common')


// Material
api "com.google.android.material:material:$rootProject.materialVersion"
api "androidx.appcompat:appcompat:$rootProject.appCompatVersion"

// RecyclerView
api "androidx.recyclerview:recyclerview:$rootProject.recyclerViewVersion"

// Fragment
api "androidx.fragment:fragment:$rootProject.fragment_version"
Expand All @@ -57,6 +66,8 @@ dependencies {
implementation "com.google.dagger:hilt-android:$rootProject.hiltVersion"
kapt "com.google.dagger:hilt-android-compiler:$rootProject.hiltVersion"

// Refresh
api "androidx.swiperefreshlayout:swiperefreshlayout:$rootProject.swipeRefreshLayoutVersion"

// Glide
implementation 'com.github.bumptech.glide:glide:4.14.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ abstract class BaseFragment<T : ViewDataBinding>(val fragment: FragmentInfoUtil)
// baseFragment를 상속받은 fragment에서만 제한된 작업 initView 에서 진행
abstract fun initView()

open fun menuClick(){}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -30,6 +32,8 @@ abstract class BaseFragment<T : ViewDataBinding>(val fragment: FragmentInfoUtil)
setToolbarTitle(getString(fragment.toolbarText))
}

setVisibilityNav()

return binding.root
}

Expand All @@ -41,6 +45,13 @@ abstract class BaseFragment<T : ViewDataBinding>(val fragment: FragmentInfoUtil)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
initView()
initMenu()

}

private fun setVisibilityNav() {
(activity as MainActivityUtil).run {
setVisibilityBottomAppbar(fragment.bottomNavi_visibility)
}
}

private fun initMenu() {
Expand All @@ -62,12 +73,14 @@ abstract class BaseFragment<T : ViewDataBinding>(val fragment: FragmentInfoUtil)
android.R.id.home -> {
popBackStack()
}
else -> {}
else -> {
menuClick()
}
}
}
return true
}
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
}
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.najudoryeong.mineme.common_ui

import android.net.Uri
import android.view.View
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide


Expand All @@ -13,3 +17,24 @@ fun bindImageView(imageView: ImageView, photoUrl: String?) {
.into(imageView)
}

@BindingAdapter("uri")
fun bindImageView(imageView: ImageView, uri: Uri?) {
Glide.with(imageView.context)
.load(uri)
.into(imageView)
}

@BindingAdapter("visible")
fun setVisibility(view: View, flag: Boolean) {
view.visibility = if (flag) View.VISIBLE else View.GONE
}

@BindingAdapter("adapter", "submitList", requireAll = true)
fun bindRecyclerView(view: RecyclerView, adapter: RecyclerView.Adapter<*>, submitList: List<Any>?) {
view.adapter = adapter.apply {
stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY
(this as ListAdapter<Any, *>).submitList(submitList?.toMutableList())
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.najudoryeong.mineme.common_ui

import android.widget.DatePicker
import android.widget.TextView
import java.text.SimpleDateFormat
import java.util.*

class CalendarUtil {
companion object {

private val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.KOREA)

private fun Calendar.getYear() = get(Calendar.YEAR)
private fun Calendar.getMonth() = get(Calendar.MONTH)+1
private fun Calendar.getDay() = get(Calendar.DAY_OF_MONTH)


fun getTodayDate(): String = Calendar.getInstance().let {
return "${it.getYear()}-${it.getMonth()}-${it.getDay()}"
}

// private fun getDateFormat(year : String, month: String, day: String) : String = "${year} ${getMonthFormat(month)}"

fun DatePicker.getDate() = "$year-${month+1}-$dayOfMonth"

fun parseStringToDate(textView: TextView): Date? =
dateFormat.parse(textView.text.toString())

fun getMonthFormat(month: String): String {
return when (month.toInt()) {
Calendar.FEBRUARY -> "Feb"
Calendar.MARCH -> "Mar"
Calendar.APRIL -> "Apr"
Calendar.MAY -> "May"
Calendar.JUNE -> "Jun"
Calendar.JULY -> "Jul"
Calendar.AUGUST -> "Aug"
Calendar.SEPTEMBER -> "Sep"
Calendar.OCTOBER -> "Oct"
Calendar.NOVEMBER -> "Nov"
Calendar.DECEMBER -> "Dec"
else -> throw IllegalArgumentException("Invalid month: $month")
}
}


}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.najudoryeong.mineme.common_ui

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import com.najudoryeong.mineme.common_ui.CalendarUtil.Companion.getDate
import com.najudoryeong.mineme.common_ui.databinding.DialogForDatepickerBinding
import java.util.*

class DialogForDatePicker(
context: Context,
private val initDate: Date,
private val onClickPositiveButton: (String) -> Unit
) : Dialog(context) {
private lateinit var binding: DialogForDatepickerBinding
private var calendar: Calendar = Calendar.getInstance()

init {
calendar.time = initDate
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = DialogForDatepickerBinding.inflate(layoutInflater).apply {
datePicker.init(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH),null)
positiveButton.setOnClickListener {
onClickPositiveButton.invoke(datePicker.getDate())
dismiss()
}
negativeButton.setOnClickListener {
dismiss()
}
}
setContentView(binding.root)

window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
}

class Builder(private val context: Context) {
private lateinit var initDate: Date
private var onClickPositiveButton : (String) -> Unit = {}


fun setInitDate(initDate: Date) = apply {
this.initDate = initDate
}

fun setOnClickPositiveButton(onClickPositiveButton: (String) -> Unit) = apply {
this.onClickPositiveButton = onClickPositiveButton
}


fun build() = DialogForDatePicker(
context,
initDate,
onClickPositiveButton
)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.najudoryeong.mineme.common_ui

import androidx.fragment.app.Fragment

interface MainActivityUtil{
fun setToolbarTitle(newTitle: String)
fun setVisibilityBottomAppbar(visibilityMode : Int)
Expand Down
9 changes: 9 additions & 0 deletions common-ui/src/main/res/drawable/img_dropdown.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M11.767,12.833L15.592,9.008C15.747,8.852 15.834,8.641 15.834,8.421C15.834,8.201 15.747,7.99 15.592,7.833C15.514,7.755 15.422,7.693 15.321,7.651C15.219,7.609 15.11,7.587 15,7.587C14.89,7.587 14.781,7.609 14.679,7.651C14.578,7.693 14.486,7.755 14.408,7.833L10.592,11.667C10.514,11.745 10.422,11.807 10.321,11.849C10.219,11.892 10.11,11.913 10,11.913C9.89,11.913 9.781,11.892 9.68,11.849C9.578,11.807 9.486,11.745 9.408,11.667L5.592,7.833C5.436,7.676 5.224,7.588 5.003,7.587C4.782,7.586 4.569,7.673 4.412,7.829C4.256,7.985 4.167,8.197 4.166,8.418C4.165,8.639 4.253,8.851 4.408,9.008L8.233,12.833C8.702,13.302 9.337,13.564 10,13.564C10.663,13.564 11.298,13.302 11.767,12.833Z"
android:fillColor="#B0B0B1"/>
</vector>
16 changes: 16 additions & 0 deletions common-ui/src/main/res/drawable/spinner_shape.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#B0B0B1" />
<solid android:color="#FFFFFF" />
<corners android:radius="10dp" />
<padding android:right="12dp" />
</shape>
</item>
<item android:width="25dp" android:height="25dp" android:drawable="@drawable/img_dropdown" android:gravity="center|end" />
</layer-list>
</item>
</selector>
Loading

0 comments on commit 0e00482

Please sign in to comment.