Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/refact/selfQA' into feat/api/friend
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/build.gradle
  • Loading branch information
SsongSik committed May 14, 2023
2 parents 366d4c6 + 87c3c50 commit 27c2b53
Show file tree
Hide file tree
Showing 87 changed files with 2,104 additions and 798 deletions.
116 changes: 116 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-parcelize")
id("androidx.navigation.safeargs.kotlin")
id("dagger.hilt.android.plugin")
id("kotlin-kapt")
}

android {
compileSdk = 33

defaultConfig {
applicationId = "com.teampome.pome"
minSdk = 23
targetSdk = 33
versionCode = 1
versionName = "1.0"

multiDexEnabled = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
debug {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
buildConfigField("String", "BASE_URL", "\"http://13.125.237.136:8085/\"")
buildConfigField("String", "IMAGE_BASE_URL", "\"http://image-main-server.ap-northeast-2.elasticbeanstalk.com/\"")
}
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
buildConfigField("String", "BASE_URL", "\"http://52.79.89.129/\"")
buildConfigField("String", "IMAGE_BASE_URL", "\"http://image-main-server.ap-northeast-2.elasticbeanstalk.com/\"")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "1.8"
}
dataBinding {
enable = true
}
}

dependencies {
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("com.google.android.material:material:1.7.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")

// Fragment ViewModel
val fragmentKtxVersion = "1.5.3"
implementation("androidx.fragment:fragment-ktx:$fragmentKtxVersion")

// Retrofit
val retrofitVersion = "2.9.0"
implementation("com.squareup.retrofit2:retrofit:$retrofitVersion")
implementation("com.google.code.gson:gson:$retrofitVersion")
implementation("com.squareup.retrofit2:converter-gson:$retrofitVersion")

val okhttp_version = "4.10.0"
implementation("com.squareup.okhttp3:okhttp:$okhttp_version")
implementation("com.squareup.okhttp3:logging-interceptor:$okhttp_version")

// Glide
val glide_version = "4.13.2"
implementation("com.github.bumptech.glide:glide:$glide_version")
kapt("com.github.bumptech.glide:compiler:$glide_version")
implementation("com.github.bumptech.glide:okhttp3-integration:$glide_version"){
exclude(group = "glide-parent")
}
implementation("com.github.bumptech.glide:annotations:$glide_version")
annotationProcessor("com.github.bumptech.glide:compiler:$glide_version")
implementation("com.caverock:androidsvg-aar:1.4")

// Glide Tranform
implementation("jp.wasabeef:glide-transformations:4.3.0")

// Navigation
val navVersion = "2.5.2"
implementation("androidx.navigation:navigation-fragment-ktx:$navVersion")
implementation("androidx.navigation:navigation-ui-ktx:$navVersion")

// Hilt
val hiltVersion = "2.44"
implementation("com.google.dagger:hilt-android:$hiltVersion")
kapt("com.google.dagger:hilt-android-compiler:$hiltVersion")

val kotlinxMetadataJvmVersion = "0.5.0"
implementation("org.jetbrains.kotlinx:kotlinx-metadata-jvm:$kotlinxMetadataJvmVersion")

// Calendar
implementation("com.github.prolificinteractive:material-calendarview:2.0.1")
implementation("com.jakewharton.threetenabp:threetenabp:1.1.1")

// DataStore
implementation("androidx.datastore:datastore-preferences:1.0.0")

// Paging
val pagingVersion = "3.1.1"
implementation("androidx.paging:paging-runtime:$pagingVersion")
}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
8 changes: 8 additions & 0 deletions app/src/debug/res/drawable/pome_seekbar_custom_over_thumb.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:useLevel="false">
<solid android:color="@color/red_over"/>
<size android:width="35dp" android:height="20dp"/>
<corners android:radius="10dp"/>
</shape>
20 changes: 20 additions & 0 deletions app/src/debug/res/drawable/pome_seekbar_over_custom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/background_red">
<shape android:shape="rectangle">
<stroke android:color="@color/red_over"/>
<solid android:color="@color/red_over"/>
<corners android:radius="4dp"/>
</shape>
</item>

<item android:id="@+id/progress_horizontal">
<clip>
<shape android:shape="rectangle">
<stroke android:color="@color/red_over"/>
<solid android:color="@color/red_over"/>
<corners android:radius="4dp"/>
</shape>
</clip>
</item>
</layer-list>
14 changes: 12 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
Expand All @@ -24,6 +22,7 @@
android:theme="@style/Theme.Pome"
tools:targetApi="33"
android:usesCleartextTraffic="true"
android:enableOnBackInvokedCallback="true"
android:name=".PomeApplication">
<activity
android:name=".MainActivity"
Expand All @@ -35,6 +34,17 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.teampome.pome.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths">
</meta-data>
</provider>
</application>

</manifest>
72 changes: 70 additions & 2 deletions app/src/main/java/com/teampome/pome/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
package com.teampome.pome

import android.app.Dialog
import android.content.IntentFilter
import android.graphics.drawable.ColorDrawable
import androidx.appcompat.app.AppCompatActivity
import android.net.ConnectivityManager
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.annotation.ColorRes
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources
import androidx.databinding.DataBindingUtil
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.bumptech.glide.Glide
import com.teampome.pome.databinding.ActivityMainBinding
import com.teampome.pome.databinding.PomeRemoveDialogBinding
import com.teampome.pome.util.common.CommonUtil
import com.teampome.pome.util.customview.PomeLoadingDialog
import dagger.hilt.android.AndroidEntryPoint


@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding

// loading 관련 dialog
private lateinit var loadingDialog: PomeLoadingDialog

// 목표 삭제 클릭 다이얼로그
private lateinit var networkErrorDialogBinding: PomeRemoveDialogBinding
private lateinit var networkErrorDialog: Dialog

private val connectivityReceiver by lazy {
PomeConnectivityReceiver()
}

private val connectivityReceiverIntentFilter by lazy {
IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)
}

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

registerReceiver(connectivityReceiver, connectivityReceiverIntentFilter)

binding = DataBindingUtil.setContentView(this, R.layout.activity_main)

// nav controller 찾고
Expand Down Expand Up @@ -55,6 +75,7 @@ class MainActivity : AppCompatActivity() {
changeStatusBarColor(R.color.main)
}
R.id.splashLoginFragment -> {
binding.activityMainBnv.visibility = View.GONE
changeStatusBarColor(R.color.white)
}
R.id.register_profile_fragment -> {
Expand All @@ -69,6 +90,14 @@ class MainActivity : AppCompatActivity() {
loadingDialog = PomeLoadingDialog(this)
loadingDialog.window?.setBackgroundDrawable(ColorDrawable(android.graphics.Color.TRANSPARENT))
loadingDialog.setCancelable(false)

makeGoalRemoveDialog()

PomeConnectivityReceiver.ConnectivityUtils.getLiveConnectivityState().observe(this) {
if(!it.isConnected) {
networkErrorDialog.show()
}
}
}

// status bar color 바꾸기
Expand All @@ -86,4 +115,43 @@ class MainActivity : AppCompatActivity() {
fun hideLoadingProgress() {
loadingDialog.dismiss()
}

override fun onDestroy() {
super.onDestroy()

unregisterReceiver(connectivityReceiver)
}

private fun makeGoalRemoveDialog() {
networkErrorDialog = Dialog(this)
networkErrorDialogBinding = PomeRemoveDialogBinding.inflate(layoutInflater, null, false)

networkErrorDialog.setContentView(networkErrorDialogBinding.root)
networkErrorDialog.setCancelable(false)

networkErrorDialogBinding.removeDialogTitleAtv.text = "인터넷에 연결할 수 없어요"
networkErrorDialogBinding.removeDialogSubtitleAtv.text = "다시 시도하거나 네트워크 설정을 확인해주세요"
networkErrorDialogBinding.removeTrashAiv.setImageDrawable(AppCompatResources.getDrawable(this, R.drawable.ic_exclamation_24))

CommonUtil.makePomeDialog(networkErrorDialog)

// 삭제하기 버튼 클릭
networkErrorDialogBinding.removeYesTextAtv.apply {
text = "다시시도"

setOnClickListener {
networkErrorDialog.dismiss()
recreate()
}
}
// 아니요 버튼 클릭
networkErrorDialogBinding.removeNoTextAtv.apply {
text = "취소"

setOnClickListener {
networkErrorDialog.dismiss()
finish()
}
}
}
}
56 changes: 56 additions & 0 deletions app/src/main/java/com/teampome/pome/PomeConnectivityReceiver.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.teampome.pome

import android.app.Dialog
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.net.ConnectivityManager
import android.net.NetworkInfo
import android.widget.Toast
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.teampome.pome.databinding.PomeRemoveDialogBinding

class PomeConnectivityReceiver: BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
context?.let {
ConnectivityUtils.notifyNetworkStatus(it)
}
}

enum class NetworkState(val isConnected: Boolean) {
CONNECTED(true),
DISCONNECTED(false)
}

object ConnectivityUtils {
private val liveConnectivityState = MutableLiveData<NetworkState>()

fun notifyNetworkStatus(context: Context) {
val newState = getLatestConnectivityStatusWithContext(context)

liveConnectivityState.value = newState
}

private fun getLatestConnectivityStatusWithContext(context: Context): NetworkState {
val isConnect = isConnected(context)

return if(isConnect) {
NetworkState.CONNECTED
} else {
NetworkState.DISCONNECTED
}
}

fun getLiveConnectivityState() : LiveData<NetworkState> {
return liveConnectivityState
}

private fun isConnected(context: Context): Boolean {
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkInfo: NetworkInfo? = connectivityManager.activeNetworkInfo

return networkInfo != null && networkInfo.isConnected
}
}
}
Loading

0 comments on commit 27c2b53

Please sign in to comment.