diff --git a/.gitignore b/.gitignore index b4959436..759e12d2 100644 --- a/.gitignore +++ b/.gitignore @@ -33,5 +33,6 @@ google-services.json # Android Profiling *.hprof + /keyStore /app/release diff --git a/README.md b/README.md index 73ba54e1..eadc3d74 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ -# android-map-refactoring +# android-map-refactoring STEP1 + +## 개요 + +`android-map-refactoring STEP1`에서는 `android-map-search`에서 SQLite를 이용해 구현했던 로컬 데이터베이스를 Room 라이브러리로 대체합니다. +또한, `Hilt`를 이용해 의존성 주입 패턴을 적용합니다. \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2c1a15f2..e3b451e0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,5 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") @@ -17,8 +19,9 @@ android { targetSdk = 34 versionCode = 1 versionName = "1.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + resValue("string", "kakao_api_key", getApiKey("KAKAO_API_KEY")) + buildConfigField("String", "KAKAO_REST_API_KEY", getApiKey("KAKAO_REST_API_KEY")) } buildTypes { @@ -39,6 +42,7 @@ android { } buildFeatures { + viewBinding = true dataBinding = true buildConfig = true } @@ -78,3 +82,5 @@ dependencies { androidTestImplementation("com.google.dagger:hilt-android-testing:2.48.1") kaptAndroidTest("com.google.dagger:hilt-android-compiler:2.48.1") } + +fun getApiKey(key: String): String = gradleLocalProperties(rootDir, providers).getProperty(key) \ No newline at end of file diff --git a/app/src/androidTest/java/campus/tech/kakao/map/MapActivityTest.kt b/app/src/androidTest/java/campus/tech/kakao/map/MapActivityTest.kt new file mode 100644 index 00000000..1e87a9bd --- /dev/null +++ b/app/src/androidTest/java/campus/tech/kakao/map/MapActivityTest.kt @@ -0,0 +1,34 @@ +package campus.tech.kakao.map + +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.* +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class MapActivityTest { + + @get:Rule + val activityScenarioRule = ActivityScenarioRule(MapActivity::class.java) + + @Before + fun setUp() { + } + + @Test + fun testFirstScreen() { + onView(withId(R.id.search_button)).check(ViewAssertions.matches(isDisplayed())) + } + @Test + fun testSearchButtonClick() { + onView(withId(R.id.search_button)).perform(click()) + Thread.sleep(1000) + onView(withId(R.id.search_edit_text)).check(ViewAssertions.matches(ViewMatchers.isDisplayed())) + } +} diff --git a/app/src/androidTest/java/campus/tech/kakao/map/MapActivityUnitTest.kt b/app/src/androidTest/java/campus/tech/kakao/map/MapActivityUnitTest.kt new file mode 100644 index 00000000..9ac54f5d --- /dev/null +++ b/app/src/androidTest/java/campus/tech/kakao/map/MapActivityUnitTest.kt @@ -0,0 +1,45 @@ +package campus.tech.kakao.map + +import android.content.Context +import android.content.SharedPreferences +import androidx.appcompat.app.AppCompatActivity +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.Assert.assertEquals + +@RunWith(AndroidJUnit4::class) +class MapActivityUnitTest { + + @get:Rule + val activityScenarioRule = ActivityScenarioRule(MapActivity::class.java) + + private lateinit var sharedPreferences: SharedPreferences + + @Before + fun setUp() { + val context = ApplicationProvider.getApplicationContext() + sharedPreferences = context.getSharedPreferences("lastLatLng", AppCompatActivity.MODE_PRIVATE) + sharedPreferences.edit().clear().apply() + } + + @Test + fun testSaveLatLng() { + val latitude = "35.231627" + val longitude = "129.084020" + + activityScenarioRule.scenario.onActivity { activity -> + activity.saveLatLng(latitude, longitude) + + val savedLat = sharedPreferences.getString("lastLat", null) + val savedLng = sharedPreferences.getString("lastLng", null) + + assertEquals(latitude, savedLat) + assertEquals(longitude, savedLng) + } + } +} diff --git a/app/src/androidTest/java/campus/tech/kakao/map/ResultRecyclerViewMatcher.kt b/app/src/androidTest/java/campus/tech/kakao/map/ResultRecyclerViewMatcher.kt new file mode 100644 index 00000000..1fbf5938 --- /dev/null +++ b/app/src/androidTest/java/campus/tech/kakao/map/ResultRecyclerViewMatcher.kt @@ -0,0 +1,38 @@ +package campus.tech.kakao.map + +import android.view.View +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import androidx.test.espresso.matcher.BoundedMatcher +import org.hamcrest.Description +import org.hamcrest.Matcher + +class ResultRecyclerViewMatcher { + fun atPosition(position: Int, itemMatcher: Matcher): Matcher { + return object : BoundedMatcher(RecyclerView::class.java) { + override fun matchesSafely(recyclerView: RecyclerView): Boolean { + val viewHolder = recyclerView.findViewHolderForAdapterPosition(position) + return itemMatcher.matches(viewHolder?.itemView) + } + + override fun describeTo(description: Description) { + description.appendText("has item at position $position: ") + itemMatcher.describeTo(description) + } + } + } + + fun hasTextInViewWithId(viewId: Int, text: String): Matcher { + return object : BoundedMatcher(View::class.java) { + override fun matchesSafely(view: View): Boolean { + val textView = view.findViewById(viewId) + return textView?.text.toString() == text + } + + override fun describeTo(description: Description) { + description.appendText("has text '$text' in view with id $viewId") + } + } + } +} diff --git a/app/src/androidTest/java/campus/tech/kakao/map/SearchActivityTest.kt b/app/src/androidTest/java/campus/tech/kakao/map/SearchActivityTest.kt new file mode 100644 index 00000000..e9f98c84 --- /dev/null +++ b/app/src/androidTest/java/campus/tech/kakao/map/SearchActivityTest.kt @@ -0,0 +1,92 @@ +package campus.tech.kakao.map + +import android.annotation.SuppressLint +import androidx.recyclerview.widget.RecyclerView +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.* +import androidx.test.espresso.assertion.ViewAssertions.* +import androidx.test.espresso.contrib.RecyclerViewActions +import androidx.test.espresso.matcher.ViewMatchers.* +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.filters.MediumTest +import org.hamcrest.CoreMatchers.* +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(androidx.test.ext.junit.runners.AndroidJUnit4::class) +@MediumTest +class SearchActivityTest { + + @get:Rule + val activityScenarioRule = ActivityScenarioRule(SearchActivity::class.java) + + @Before + fun setup() { + activityScenarioRule.scenario.onActivity { activity -> + (activity.application as KyleMaps).isTestMode = true + } + } + + @Test + fun testSearchFunctionality() { + onView(withId(R.id.no_results)) + .check(matches(isDisplayed())) + } + + @Test + fun testViewVisibility() { + onView(withId(R.id.search_edit_text)).perform(typeText("Hello")) + Thread.sleep(1000) + onView(withId(R.id.no_results)).check(matches(not(isDisplayed()))) + onView(withId(R.id.recycler_view)).check(matches(isDisplayed())) + } + + @Test + fun testResultRecyclerViewItem() { + val resultRecyclerViewMatcher = ResultRecyclerViewMatcher() + onView(withId(R.id.search_edit_text)).perform(typeText("DDDD")) + Thread.sleep(1000) + onView(withId(R.id.recycler_view)) + .check(matches(resultRecyclerViewMatcher.atPosition( + 0, + resultRecyclerViewMatcher.hasTextInViewWithId(R.id.place_name, "DDDD") + ))) + onView(withId(R.id.recycler_view)) + .check(matches(resultRecyclerViewMatcher.atPosition( + 0, + resultRecyclerViewMatcher.hasTextInViewWithId(R.id.place_category, "음식점") + ))) + onView(withId(R.id.recycler_view)) + .check(matches(resultRecyclerViewMatcher.atPosition( + 0, + resultRecyclerViewMatcher.hasTextInViewWithId(R.id.place_address, "경남 창원시 성산구 용호동 17-1") + ))) + } + +// @SuppressLint("CheckResult") +// @Test +// fun testSearchHistoryRecyclerViewItem() { +// val searchHistoryRecyclerViewMatcher = SearchHistoryRecyclerViewMatcher() +// var itemCount = 0 +// activityScenarioRule.scenario.onActivity { activity -> +// val recyclerView: RecyclerView = activity.findViewById(R.id.horizontal_recycler_view) +// itemCount = recyclerView.adapter?.itemCount ?: 0 +// } +// onView(withId(R.id.search_edit_text)).perform(typeText("DDDD")) +// Thread.sleep(1000) +// +// onView(withId(R.id.recycler_view)) +// .perform(RecyclerViewActions.actionOnItemAtPosition(0, click())) +// Thread.sleep(1000) +// +// onView(withId(R.id.horizontal_recycler_view)) +// .check(matches(searchHistoryRecyclerViewMatcher.atPosition( +// itemCount-1, +// searchHistoryRecyclerViewMatcher.hasTextInViewWithId(R.id.search_history_item, "DDDD") +// ))) +// } + // 로그도 잘 찍히고 아무 문제 없어보이는데 왜 안 되는 지 도무지 모르겠는 테스트 코드 ! + +} diff --git a/app/src/androidTest/java/campus/tech/kakao/map/SearchActivityUnitTest.kt b/app/src/androidTest/java/campus/tech/kakao/map/SearchActivityUnitTest.kt new file mode 100644 index 00000000..bd79884f --- /dev/null +++ b/app/src/androidTest/java/campus/tech/kakao/map/SearchActivityUnitTest.kt @@ -0,0 +1,32 @@ +package campus.tech.kakao.map + +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import junit.framework.TestCase.assertEquals +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class SearchActivityUnitTest { + + @get:Rule + val activityScenarioRule = ActivityScenarioRule(SearchActivity::class.java) + + @Before + fun setUp() {} + +// @Test +// fun testSearchPlacesWithResults() { +// activityScenarioRule.scenario.onActivity { activity -> +// activity.searchPlaces("DDDD") +// +// val recyclerViewAdapter = activity.findViewById(R.id.recycler_view).adapter as ResultRecyclerViewAdapter +// assertEquals(1, recyclerViewAdapter.itemCount) +// } +// } + // 도저히 왜 안 되는 지 모르겠는 코드 2.. +} diff --git a/app/src/androidTest/java/campus/tech/kakao/map/SearchHistoryRecyclerViewMatcher.kt b/app/src/androidTest/java/campus/tech/kakao/map/SearchHistoryRecyclerViewMatcher.kt new file mode 100644 index 00000000..9b7dead9 --- /dev/null +++ b/app/src/androidTest/java/campus/tech/kakao/map/SearchHistoryRecyclerViewMatcher.kt @@ -0,0 +1,37 @@ +package campus.tech.kakao.map + +import android.view.View +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import androidx.test.espresso.matcher.BoundedMatcher +import org.hamcrest.Description +import org.hamcrest.Matcher + +class SearchHistoryRecyclerViewMatcher { + fun atPosition(position: Int, itemMatcher: Matcher): Matcher { + return object : BoundedMatcher(RecyclerView::class.java) { + override fun matchesSafely(recyclerView: RecyclerView): Boolean { + val viewHolder = recyclerView.findViewHolderForAdapterPosition(position) + return itemMatcher.matches(viewHolder?.itemView) + } + + override fun describeTo(description: Description) { + description.appendText("has item at position $position: ") + itemMatcher.describeTo(description) + } + } + } + + fun hasTextInViewWithId(viewId: Int, text: String): Matcher { + return object : BoundedMatcher(View::class.java) { + override fun matchesSafely(view: View): Boolean { + val textView = view.findViewById(viewId) + return textView?.text.toString() == text + } + + override fun describeTo(description: Description) { + description.appendText("has text '$text' in view with id $viewId") + } + } + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6bca2f54..92d8850a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,25 +2,32 @@ + + + + - + + + diff --git a/app/src/main/java/campus/tech/kakao/map/AuthenticationErrorActivity.kt b/app/src/main/java/campus/tech/kakao/map/AuthenticationErrorActivity.kt new file mode 100644 index 00000000..8e7e3be2 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/AuthenticationErrorActivity.kt @@ -0,0 +1,21 @@ +package campus.tech.kakao.map + +import android.os.Bundle +import android.widget.ImageView +import android.widget.ProgressBar +import androidx.appcompat.app.AppCompatActivity + +class AuthenticationErrorActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_authentication_error) + + val retryIcon: ImageView = findViewById(R.id.retry_icon) + val loadingIndicator: ProgressBar = findViewById(R.id.loading_indicator) + + retryIcon.setOnClickListener { + loadingIndicator.visibility = ProgressBar.VISIBLE + } + } +} diff --git a/app/src/main/java/campus/tech/kakao/map/KyleMaps.kt b/app/src/main/java/campus/tech/kakao/map/KyleMaps.kt new file mode 100644 index 00000000..1157cbb2 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/KyleMaps.kt @@ -0,0 +1,17 @@ +package campus.tech.kakao.map + +import android.app.Application +import campus.tech.kakao.map.db.AppModule +import campus.tech.kakao.map.db.DataBase +import com.kakao.vectormap.KakaoMapSdk + +class KyleMaps : Application() { + +// var isTestMode: Boolean = false + lateinit var database: DataBase + override fun onCreate() { + super.onCreate() + KakaoMapSdk.init(this, getString(R.string.kakao_api_key)) + database = AppModule.provideDatabase(this) + } +} diff --git a/app/src/main/java/campus/tech/kakao/map/MainActivity.kt b/app/src/main/java/campus/tech/kakao/map/MainActivity.kt deleted file mode 100644 index 95b43803..00000000 --- a/app/src/main/java/campus/tech/kakao/map/MainActivity.kt +++ /dev/null @@ -1,11 +0,0 @@ -package campus.tech.kakao.map - -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - } -} diff --git a/app/src/main/java/campus/tech/kakao/map/MapActivity.kt b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt new file mode 100644 index 00000000..18a5a7c0 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/MapActivity.kt @@ -0,0 +1,135 @@ +package campus.tech.kakao.map + +import android.content.Intent +import android.graphics.Color +import android.os.Bundle +import android.util.Log +import android.widget.LinearLayout +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import com.google.android.material.bottomsheet.BottomSheetDialog +import com.kakao.vectormap.KakaoMap +import com.kakao.vectormap.KakaoMapReadyCallback +import com.kakao.vectormap.LatLng +import com.kakao.vectormap.MapLifeCycleCallback +import com.kakao.vectormap.MapView +import com.kakao.vectormap.label.LabelOptions +import com.kakao.vectormap.label.LabelStyle +import com.kakao.vectormap.label.LabelStyles + +class MapActivity : AppCompatActivity() { + + private lateinit var mapView: MapView + private lateinit var searchButton: LinearLayout + private lateinit var bottomSheet: BottomSheetDialog + + private var name: String? = null + private var address: String? = null + private var kakaoMap: KakaoMap? = null + private var latitude: String? = null + private var longitude: String? = null + + override fun onCreate(savedInstanceState: Bundle?) { + Log.d("here", "I'm in MapActivity") + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_map) + + mapView = findViewById(R.id.map_view) + searchButton = findViewById(R.id.search_button) + val bottomSheetLayout = layoutInflater.inflate(R.layout.layout_map_bottom_sheet_dialog, null) + bottomSheet = BottomSheetDialog(this) + + val defLat = "35.231627" + val defLng = "129.084020" + val lastLatLng = getSharedPreferences("lastLatLng", MODE_PRIVATE) + latitude = lastLatLng.getString("lastLat", defLat) // 기본 위치: 부산대. + longitude = lastLatLng.getString("lastLng", defLng) // 기본 위치: 부산대. + Log.d("sharedPreference", "saveLatLng밖에꺼: $latitude") + Log.d("sharedPreference", "saveLatLng밖에꺼: $longitude") + + // Intent에서 값을 가져옴 + intent?.let { + latitude = it.getStringExtra("mapY") ?: latitude + longitude = it.getStringExtra("mapX") ?: longitude + name = it.getStringExtra("name") + address = it.getStringExtra("address") + } + + Log.d("latlngcheck1", "Intent에서 가져온 값: $latitude, $longitude, $name") + + mapView.start( + object : MapLifeCycleCallback() { + override fun onMapDestroy() { + } + + override fun onMapError(error: Exception) { + Log.e("MapActivity", "Map error: ${error.message}") + val errorIntent = Intent(this@MapActivity, AuthenticationErrorActivity::class.java) + startActivity(errorIntent) + finish() + } + + }, + object : KakaoMapReadyCallback() { + override fun onMapReady(kakaoMap: KakaoMap) { + Log.d("latlngcheck2", "onMapReady에서: $latitude, $longitude") + this@MapActivity.kakaoMap = kakaoMap + name?.let { + addMarker(kakaoMap, latitude ?: defLat, longitude ?: defLng, it) + saveLatLng(latitude ?: defLat, longitude ?: defLng) // 마커 찍은 위치를 sharedPreference에 저장 + val tvBottomSheetPlaceName = bottomSheetLayout.findViewById(R.id.bottomSheetPlaceName) + val tvBottomSheetPlaceAddress = bottomSheetLayout.findViewById(R.id.bottomsheetPlaceAddress) + tvBottomSheetPlaceName.text = name + tvBottomSheetPlaceAddress.text = address + bottomSheet.setContentView(bottomSheetLayout) + bottomSheet.show() + } + } + + override fun getPosition(): LatLng { + Log.d("latlngcheck3", "getPosition에서: $latitude, $longitude") + val lat = (latitude ?: defLat).toDouble() + val lng = (longitude ?: defLng).toDouble() + return LatLng.from(lat, lng) + } + } + ) + + searchButton.setOnClickListener { + val mapToSearchIntent = Intent(this@MapActivity, SearchActivity::class.java) + startActivity(mapToSearchIntent) + finish() + } + } + + private fun addMarker(kakaoMap: KakaoMap, latitude: String, longitude: String, name: String) { + Log.d("addMarker", "addMarker: $latitude, $longitude, $name") + val styles = kakaoMap.labelManager?.addLabelStyles(LabelStyles.from(LabelStyle.from(R.drawable.location_marker).setTextStyles(25, Color.BLACK))) + val options = LabelOptions.from(LatLng.from(latitude.toDouble(), longitude.toDouble())).setStyles(styles) + val layer = kakaoMap.labelManager?.layer + val label = layer?.addLabel(options) + label?.changeText(name) + } + + fun saveLatLng(latitude: String, longitude: String) { + val sharedPreference = getSharedPreferences("lastLatLng", MODE_PRIVATE) + sharedPreference.edit().apply { + putString("lastLat", latitude) + putString("lastLng", longitude) + apply() + } + Log.d("sharedPreference", "saveLatLng: ${sharedPreference.getString("lastLat", "default_lat")}") + Log.d("sharedPreference", "saveLatLng: ${sharedPreference.getString("lastLng", "default_lng")}") + } + + override fun onResume() { + super.onResume() + mapView.resume() + } + + override fun onPause() { + super.onPause() + mapView.pause() + } + +} diff --git a/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt new file mode 100644 index 00000000..9bf748f6 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/SearchActivity.kt @@ -0,0 +1,154 @@ +package campus.tech.kakao.map + +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.widget.EditText +import android.widget.ImageButton +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import androidx.core.widget.addTextChangedListener +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.db.AppModule +import campus.tech.kakao.map.db.DataBase +import campus.tech.kakao.map.db.SearchHistory +import campus.tech.kakao.map.db.SearchHistoryDao +import campus.tech.kakao.map.dto.Place +import campus.tech.kakao.map.repository.KakaoRepository +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import retrofit2.Retrofit + +class SearchActivity : AppCompatActivity() { + private val coroutineScope = CoroutineScope(Dispatchers.Main) + private lateinit var searchEditText: EditText + private lateinit var resultRecyclerView: RecyclerView + private lateinit var searchHistoryRecyclerView: RecyclerView + private lateinit var noResults: TextView + private lateinit var retrofit: Retrofit + private lateinit var kakaoRepository: KakaoRepository + private lateinit var database: DataBase + private lateinit var searchHistoryDao: SearchHistoryDao + private lateinit var resultRecyclerViewAdapter: ResultRecyclerViewAdapter + private lateinit var searchHistoryRecyclerViewAdapter: SearchHistoryRecyclerViewAdapter + private lateinit var placeList: List + private lateinit var searchHistoryList: MutableList + private lateinit var backButton: ImageButton + private lateinit var mapX: String + private lateinit var mapY: String + private lateinit var name: String + private lateinit var address: String + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + Log.d("here", "I'm in SearchActivity") + setContentView(R.layout.activity_search) + + searchEditText = findViewById(R.id.search_edit_text) + resultRecyclerView = findViewById(R.id.recycler_view) + searchHistoryRecyclerView = findViewById(R.id.horizontal_recycler_view) + noResults = findViewById(R.id.no_results) + backButton = findViewById(R.id.back_button) + + retrofit = AppModule.provideRetrofit() + database = (application as KyleMaps).database + searchHistoryDao = AppModule.provideSearchHistoryDao(database) + kakaoRepository = AppModule.provideKakaoRepository(retrofit) + + coroutineScope.launch { + searchHistoryList = searchHistoryDao.getAllSearchHistory().toMutableList() + searchHistoryRecyclerViewAdapter = SearchHistoryRecyclerViewAdapter( + searchHistory = searchHistoryList, + onItemClick = { history -> + searchEditText.setText(history.placeName) + searchEditText.clearFocus() + searchEditText.isFocusable = false + }, + onItemDelete = { history -> + coroutineScope.launch { + searchHistoryDao.deleteSearchHistoryById(history.id) + searchHistoryList.remove(history) + searchHistoryRecyclerViewAdapter.notifyDataSetChanged() + } + } + ) + + searchHistoryRecyclerView.adapter = searchHistoryRecyclerViewAdapter + searchHistoryRecyclerView.layoutManager = LinearLayoutManager(this@SearchActivity, LinearLayoutManager.HORIZONTAL, false) + } + + resultRecyclerViewAdapter = ResultRecyclerViewAdapter( + places = emptyList(), + onItemClick = { place -> + coroutineScope.launch { + val searchHistory = SearchHistory(placeName = place.place_name) + searchHistoryDao.insertSearchHistory(searchHistory) + updateSearchHistoryRecyclerView(searchHistory) + updateMapPosition(place) + goBackToMap() + } + } + ) + + resultRecyclerView.adapter = resultRecyclerViewAdapter + resultRecyclerView.layoutManager = LinearLayoutManager(this) + + searchEditText.addTextChangedListener { text -> + text?.let { searchPlaces(it.toString()) } + } + + backButton.setOnClickListener { + goBackToMap() + } + } + + fun searchPlaces(query: String) { + kakaoRepository.searchPlaces(query) { places -> + runOnUiThread { + placeList = places + resultRecyclerViewAdapter.setPlaces(places) + showNoResultsMessage(places.isEmpty()) + Log.d("searchPlaces", "searchPlaces: ${resultRecyclerViewAdapter.itemCount}") + } + } + } + + private fun showNoResultsMessage(show: Boolean) { + if (show) { + noResults.visibility = TextView.VISIBLE + resultRecyclerView.visibility = RecyclerView.GONE + Log.d("visibility", "noresult: ${noResults.visibility}, recycler: ${resultRecyclerView.visibility} ") + } else { + noResults.visibility = TextView.GONE + resultRecyclerView.visibility = RecyclerView.VISIBLE + Log.d("visibility", "noresult: ${noResults.visibility}, recycler: ${resultRecyclerView.visibility} ") + } + } + + private fun updateSearchHistoryRecyclerView(searchHistory: SearchHistory) { + Log.d("updateSearchHistoryRecyclerView", "I'm executed") + searchHistoryList.add(searchHistory) + searchHistoryRecyclerViewAdapter.notifyDataSetChanged() + } + + private fun goBackToMap() { + val searchToMapIntent = Intent(this, MapActivity::class.java) + searchToMapIntent.putExtra("mapX", mapX) + searchToMapIntent.putExtra("mapY", mapY) + searchToMapIntent.putExtra("name", name) + searchToMapIntent.putExtra("address", address) + Log.d("goBackToMap", "goBackToMap: $mapX, $mapY") + finish() + startActivity(searchToMapIntent) + } + + private fun updateMapPosition(place: Place) { + mapX = place.x + mapY = place.y + name = place.place_name + address = place.address_name + Log.d("goBackToMap", "updateMapPosition: $mapX, $mapY") + } +} diff --git a/app/src/main/java/campus/tech/kakao/map/SearchHistoryRecyclerViewAdapter.kt b/app/src/main/java/campus/tech/kakao/map/SearchHistoryRecyclerViewAdapter.kt new file mode 100644 index 00000000..9a4436fb --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/SearchHistoryRecyclerViewAdapter.kt @@ -0,0 +1,49 @@ +package campus.tech.kakao.map + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.db.SearchHistory + +class SearchHistoryRecyclerViewAdapter( + private val searchHistory: MutableList, + private val onItemClick: (SearchHistory) -> Unit, + private val onItemDelete: (SearchHistory) -> Unit +) : RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_search_history, parent, false) + return ViewHolder(view) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val history = searchHistory[position] + holder.bind(history) + } + + override fun getItemCount(): Int { + return searchHistory.size + } + + inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + private val searchHistoryBtn: TextView = itemView.findViewById(R.id.search_history_item) + private val searchHistoryDeleteBtn: ImageView = itemView.findViewById(R.id.search_history_delete_button) + + fun bind(history: SearchHistory) { + searchHistoryBtn.text = history.placeName + searchHistoryBtn.setOnClickListener { onItemClick(history) } + searchHistoryDeleteBtn.setOnClickListener { + onItemDelete(history) + val position = adapterPosition + if (position != RecyclerView.NO_POSITION) { + searchHistory.removeAt(position) + notifyItemRemoved(position) + notifyItemRangeChanged(position, itemCount) + } + } + } + } +} diff --git a/app/src/main/java/campus/tech/kakao/map/SearchResultRecyclerViewAdapter.kt b/app/src/main/java/campus/tech/kakao/map/SearchResultRecyclerViewAdapter.kt new file mode 100644 index 00000000..6b0aef6c --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/SearchResultRecyclerViewAdapter.kt @@ -0,0 +1,43 @@ +package campus.tech.kakao.map + +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import campus.tech.kakao.map.dto.Place + +class ResultRecyclerViewAdapter( + private var places: List, + private val onItemClick: (Place) -> Unit +) : RecyclerView.Adapter() { + + class PlaceViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val placeName: TextView = itemView.findViewById(R.id.place_name) + val placeCategory: TextView = itemView.findViewById(R.id.place_category) + val placeAddress: TextView = itemView.findViewById(R.id.place_address) + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaceViewHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_search_result, parent, false) + return PlaceViewHolder(view) + } + + override fun onBindViewHolder(holder: PlaceViewHolder, position: Int) { + val place = places[position] + holder.placeName.text = place.place_name + holder.placeCategory.text = place.category_group_name + holder.placeAddress.text = place.address_name + holder.itemView.setOnClickListener { onItemClick(place) } + } + + override fun getItemCount(): Int { + return places.size + } + + fun setPlaces(newPlaces: List) { + places = newPlaces + notifyDataSetChanged() + } +} diff --git a/app/src/main/java/campus/tech/kakao/map/db/AppModule.kt b/app/src/main/java/campus/tech/kakao/map/db/AppModule.kt new file mode 100644 index 00000000..9bf8b0dc --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/db/AppModule.kt @@ -0,0 +1,57 @@ +package campus.tech.kakao.map.db + +import android.content.Context +import androidx.room.Room +import campus.tech.kakao.map.network.KakaoLocalApi +import campus.tech.kakao.map.repository.KakaoRepository +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext +import dagger.hilt.components.SingletonComponent +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object AppModule { + + @Provides + @Singleton + fun provideDatabase(@ApplicationContext context: Context): DataBase { + return Room.databaseBuilder( + context.applicationContext, + DataBase::class.java, + "kyle_maps_database" + ).build() + } + + @Provides + fun provideSearchHistoryDao(database: DataBase): SearchHistoryDao { + return database.searchHistoryDao() + } + + @Provides + @Singleton + fun provideRetrofit(): Retrofit { + return Retrofit.Builder() + .baseUrl("https://dapi.kakao.com") + .addConverterFactory(GsonConverterFactory.create()) + .build() + } + + @Provides + @Singleton + fun provideKakaoLocalApi(retrofit: Retrofit): KakaoLocalApi { + return retrofit.create(KakaoLocalApi::class.java) + } + + @Provides + @Singleton + fun provideKakaoRepository( + retrofit: Retrofit, + ): KakaoRepository { + return KakaoRepository(retrofit) + } +} diff --git a/app/src/main/java/campus/tech/kakao/map/db/DataBase.kt b/app/src/main/java/campus/tech/kakao/map/db/DataBase.kt new file mode 100644 index 00000000..85a95ee0 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/db/DataBase.kt @@ -0,0 +1,9 @@ +package campus.tech.kakao.map.db + +import androidx.room.Database +import androidx.room.RoomDatabase + +@Database(entities = [SearchHistory::class], version = 1) +abstract class DataBase : RoomDatabase() { + abstract fun searchHistoryDao(): SearchHistoryDao +} diff --git a/app/src/main/java/campus/tech/kakao/map/db/SearchHistory.kt b/app/src/main/java/campus/tech/kakao/map/db/SearchHistory.kt new file mode 100644 index 00000000..0e9f109a --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/db/SearchHistory.kt @@ -0,0 +1,10 @@ +package campus.tech.kakao.map.db + +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity(tableName = "SearchHistoryTable") +data class SearchHistory( + @PrimaryKey(autoGenerate = true) val id: Int = 0, + val placeName: String +) diff --git a/app/src/main/java/campus/tech/kakao/map/db/SearchHistoryDao.kt b/app/src/main/java/campus/tech/kakao/map/db/SearchHistoryDao.kt new file mode 100644 index 00000000..829df64b --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/db/SearchHistoryDao.kt @@ -0,0 +1,18 @@ +package campus.tech.kakao.map.db + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.Query +import campus.tech.kakao.map.db.SearchHistory + +@Dao +interface SearchHistoryDao { + @Insert + suspend fun insertSearchHistory(searchHistory: SearchHistory): Long + + @Query("DELETE FROM SearchHistoryTable WHERE id = :id") + suspend fun deleteSearchHistoryById(id: Int): Int + + @Query("SELECT * FROM SearchHistoryTable ORDER BY id DESC") + suspend fun getAllSearchHistory(): MutableList +} diff --git a/app/src/main/java/campus/tech/kakao/map/dto/Place.kt b/app/src/main/java/campus/tech/kakao/map/dto/Place.kt new file mode 100644 index 00000000..e89710e8 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/dto/Place.kt @@ -0,0 +1,16 @@ +package campus.tech.kakao.map.dto + +data class Place( + val address_name: String, + val category_group_code: String, + val category_group_name: String, + val category_name: String, + val distance: String, + val id: String, + val phone: String, + val place_name: String, + val place_url: String, + val road_address_name: String, + val x: String, + val y: String +) // 장소 정보 클래스 \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/dto/PlaceMeta.kt b/app/src/main/java/campus/tech/kakao/map/dto/PlaceMeta.kt new file mode 100644 index 00000000..591e52d7 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/dto/PlaceMeta.kt @@ -0,0 +1,8 @@ +package campus.tech.kakao.map.dto + +data class PlaceMeta( + val total_count: Int, + val pageable_count: Int, + val is_end: Boolean, + val same_name: RegionInfo +) // 검색 결과 메타데이터 클래스 \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/dto/RegionInfo.kt b/app/src/main/java/campus/tech/kakao/map/dto/RegionInfo.kt new file mode 100644 index 00000000..fcb13cbc --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/dto/RegionInfo.kt @@ -0,0 +1,7 @@ +package campus.tech.kakao.map.dto + +data class RegionInfo( + val region: List, + val keyword: String, + val selected_region: String +) // 지역 및 키워드 분석 정보 클래스 \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/dto/ResultSearchKeyword.kt b/app/src/main/java/campus/tech/kakao/map/dto/ResultSearchKeyword.kt new file mode 100644 index 00000000..d59f4a46 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/dto/ResultSearchKeyword.kt @@ -0,0 +1,5 @@ +package campus.tech.kakao.map.dto +data class ResultSearchKeyword( + val documents: List, + val meta: PlaceMeta +) diff --git a/app/src/main/java/campus/tech/kakao/map/network/KakaoLocalAPI.kt b/app/src/main/java/campus/tech/kakao/map/network/KakaoLocalAPI.kt new file mode 100644 index 00000000..bbb52eaa --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/network/KakaoLocalAPI.kt @@ -0,0 +1,15 @@ +package campus.tech.kakao.map.network + +import campus.tech.kakao.map.dto.ResultSearchKeyword +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Header +import retrofit2.http.Query + +interface KakaoLocalApi { + @GET("/v2/local/search/keyword.json") + fun searchKeyword( + @Header("Authorization") authorization: String, + @Query("query") query: String + ): Call +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/repository/KakaoRepository.kt b/app/src/main/java/campus/tech/kakao/map/repository/KakaoRepository.kt new file mode 100644 index 00000000..b52698e7 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/repository/KakaoRepository.kt @@ -0,0 +1,40 @@ +package campus.tech.kakao.map.repository + +import android.util.Log +import campus.tech.kakao.map.BuildConfig.KAKAO_REST_API_KEY +import campus.tech.kakao.map.dto.Place +import campus.tech.kakao.map.dto.ResultSearchKeyword +import campus.tech.kakao.map.network.KakaoLocalApi +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import retrofit2.Retrofit + +class KakaoRepository(private val retrofit: Retrofit) { + + private val api: KakaoLocalApi = retrofit.create(KakaoLocalApi::class.java) + + fun searchPlaces(query: String, callback: (List) -> Unit) { + api.searchKeyword("KakaoAK $KAKAO_REST_API_KEY", query) + .enqueue(object : Callback { + override fun onResponse( + call: Call, + response: Response + ) { + if (response.isSuccessful) { + val places = response.body()?.documents ?: emptyList() + callback(places) + Log.d("KakaoRepository", "API call successful. Received ${places.size} places.") + } else { + callback(emptyList()) + Log.e("KakaoRepository", "API call failed with code ${response.code()}.") + } + } + + override fun onFailure(call: Call, t: Throwable) { + callback(emptyList()) + Log.e("KakaoRepository", "API call failed: ${t.message}", t) + } + }) + } +} diff --git a/app/src/main/kyle_maps_icon-playstore.png b/app/src/main/kyle_maps_icon-playstore.png new file mode 100644 index 00000000..d201f5f1 Binary files /dev/null and b/app/src/main/kyle_maps_icon-playstore.png differ diff --git a/app/src/main/res/drawable/arrow_back.xml b/app/src/main/res/drawable/arrow_back.xml new file mode 100644 index 00000000..af84914d --- /dev/null +++ b/app/src/main/res/drawable/arrow_back.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/bottom_sheet_background.xml b/app/src/main/res/drawable/bottom_sheet_background.xml new file mode 100644 index 00000000..a9d4de8f --- /dev/null +++ b/app/src/main/res/drawable/bottom_sheet_background.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/delete.xml b/app/src/main/res/drawable/delete.xml new file mode 100644 index 00000000..e0278034 --- /dev/null +++ b/app/src/main/res/drawable/delete.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/edit_text_background.xml b/app/src/main/res/drawable/edit_text_background.xml new file mode 100644 index 00000000..f0c748cc --- /dev/null +++ b/app/src/main/res/drawable/edit_text_background.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_retry.png b/app/src/main/res/drawable/ic_retry.png new file mode 100644 index 00000000..04c6c277 Binary files /dev/null and b/app/src/main/res/drawable/ic_retry.png differ diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 00000000..8006ac8c --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/item_search_history_background.xml b/app/src/main/res/drawable/item_search_history_background.xml new file mode 100644 index 00000000..fdf40547 --- /dev/null +++ b/app/src/main/res/drawable/item_search_history_background.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/src/main/res/drawable/kyle_maps_icon_background.xml b/app/src/main/res/drawable/kyle_maps_icon_background.xml new file mode 100644 index 00000000..ca3826a4 --- /dev/null +++ b/app/src/main/res/drawable/kyle_maps_icon_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/location.xml b/app/src/main/res/drawable/location.xml new file mode 100644 index 00000000..9e71ddca --- /dev/null +++ b/app/src/main/res/drawable/location.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/location_marker.png b/app/src/main/res/drawable/location_marker.png new file mode 100644 index 00000000..aab4b5ee Binary files /dev/null and b/app/src/main/res/drawable/location_marker.png differ diff --git a/app/src/main/res/drawable/search_bar_background.xml b/app/src/main/res/drawable/search_bar_background.xml new file mode 100644 index 00000000..8efcfb53 --- /dev/null +++ b/app/src/main/res/drawable/search_bar_background.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/app/src/main/res/layout/activity_authentication_error.xml b/app/src/main/res/layout/activity_authentication_error.xml new file mode 100644 index 00000000..37b4ae91 --- /dev/null +++ b/app/src/main/res/layout/activity_authentication_error.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xml new file mode 100644 index 00000000..1f08be14 --- /dev/null +++ b/app/src/main/res/layout/activity_map.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml new file mode 100644 index 00000000..e7bce753 --- /dev/null +++ b/app/src/main/res/layout/activity_search.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_search_history.xml b/app/src/main/res/layout/item_search_history.xml new file mode 100644 index 00000000..4e372778 --- /dev/null +++ b/app/src/main/res/layout/item_search_history.xml @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_search_result.xml b/app/src/main/res/layout/item_search_result.xml new file mode 100644 index 00000000..9f510caf --- /dev/null +++ b/app/src/main/res/layout/item_search_result.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/layout_map_bottom_sheet_dialog.xml b/app/src/main/res/layout/layout_map_bottom_sheet_dialog.xml new file mode 100644 index 00000000..3417e815 --- /dev/null +++ b/app/src/main/res/layout/layout_map_bottom_sheet_dialog.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/kyle_maps_icon.xml b/app/src/main/res/mipmap-anydpi-v26/kyle_maps_icon.xml new file mode 100644 index 00000000..ba86639b --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/kyle_maps_icon.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/kyle_maps_icon_round.xml b/app/src/main/res/mipmap-anydpi-v26/kyle_maps_icon_round.xml new file mode 100644 index 00000000..ba86639b --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/kyle_maps_icon_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/kyle_maps_icon.webp b/app/src/main/res/mipmap-hdpi/kyle_maps_icon.webp new file mode 100644 index 00000000..2dcc32b0 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/kyle_maps_icon.webp differ diff --git a/app/src/main/res/mipmap-hdpi/kyle_maps_icon_foreground.webp b/app/src/main/res/mipmap-hdpi/kyle_maps_icon_foreground.webp new file mode 100644 index 00000000..35130116 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/kyle_maps_icon_foreground.webp differ diff --git a/app/src/main/res/mipmap-hdpi/kyle_maps_icon_round.webp b/app/src/main/res/mipmap-hdpi/kyle_maps_icon_round.webp new file mode 100644 index 00000000..cec24aef Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/kyle_maps_icon_round.webp differ diff --git a/app/src/main/res/mipmap-mdpi/kyle_maps_icon.webp b/app/src/main/res/mipmap-mdpi/kyle_maps_icon.webp new file mode 100644 index 00000000..a8476572 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/kyle_maps_icon.webp differ diff --git a/app/src/main/res/mipmap-mdpi/kyle_maps_icon_foreground.webp b/app/src/main/res/mipmap-mdpi/kyle_maps_icon_foreground.webp new file mode 100644 index 00000000..0c356419 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/kyle_maps_icon_foreground.webp differ diff --git a/app/src/main/res/mipmap-mdpi/kyle_maps_icon_round.webp b/app/src/main/res/mipmap-mdpi/kyle_maps_icon_round.webp new file mode 100644 index 00000000..022fbb01 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/kyle_maps_icon_round.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/kyle_maps_icon.webp b/app/src/main/res/mipmap-xhdpi/kyle_maps_icon.webp new file mode 100644 index 00000000..ac78e581 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/kyle_maps_icon.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/kyle_maps_icon_foreground.webp b/app/src/main/res/mipmap-xhdpi/kyle_maps_icon_foreground.webp new file mode 100644 index 00000000..958bc6cf Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/kyle_maps_icon_foreground.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/kyle_maps_icon_round.webp b/app/src/main/res/mipmap-xhdpi/kyle_maps_icon_round.webp new file mode 100644 index 00000000..3bb7a097 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/kyle_maps_icon_round.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/kyle_maps_icon.webp b/app/src/main/res/mipmap-xxhdpi/kyle_maps_icon.webp new file mode 100644 index 00000000..9c147e59 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/kyle_maps_icon.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/kyle_maps_icon_foreground.webp b/app/src/main/res/mipmap-xxhdpi/kyle_maps_icon_foreground.webp new file mode 100644 index 00000000..25d96684 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/kyle_maps_icon_foreground.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/kyle_maps_icon_round.webp b/app/src/main/res/mipmap-xxhdpi/kyle_maps_icon_round.webp new file mode 100644 index 00000000..5682235a Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/kyle_maps_icon_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/kyle_maps_icon.webp b/app/src/main/res/mipmap-xxxhdpi/kyle_maps_icon.webp new file mode 100644 index 00000000..9356e765 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/kyle_maps_icon.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/kyle_maps_icon_foreground.webp b/app/src/main/res/mipmap-xxxhdpi/kyle_maps_icon_foreground.webp new file mode 100644 index 00000000..99a0f274 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/kyle_maps_icon_foreground.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/kyle_maps_icon_round.webp b/app/src/main/res/mipmap-xxxhdpi/kyle_maps_icon_round.webp new file mode 100644 index 00000000..34d20ef7 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/kyle_maps_icon_round.webp differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e5ba5b9c..b71c1d37 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,30 @@ Map + 검색어를 입력해 주세요. + 검색 결과가 없습니다. + + 카카오 카페 + 카카오 식당 + 카카오 포차 + 테크 카페 + 테크 식당 + 테크 포차 + 캠퍼스 카페 + 캠퍼스 식당 + 캠퍼스 포차 + + 카페 + 식당 + 주점 + + 금정구 1 + 금정구 2 + 금정구 3 + 금정구 4 + 금정구 5 + 금정구 6 + 금정구 7 + 금정구 8 + 금정구 9 + \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2927e499..3fa8f862 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Sat Jun 15 19:44:23 KST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0c..cb58b5bb 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,11 @@ #!/usr/bin/env sh - +#!/bin/sh # # Copyright 2015 the original author or authors. + + +# +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -52,32 +56,99 @@ MAX_FD="maximum" warn () { echo "$*" } +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +158,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +169,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/settings.gradle.kts b/settings.gradle.kts index 48bba0fc..ffdb3e45 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,9 +16,12 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + //카카오맵 maven("https://devrepo.kakao.com/nexus/repository/kakaomap-releases/") + //키해시용 + maven("https://devrepo.kakao.com/nexus/content/groups/public/") } } -rootProject.name = "android-map-refactoring" +rootProject.name = "android-map-location" include(":app")