diff --git a/core/src/main/java/in/koreatech/koin/core/activity/WebViewActivity.kt b/core/src/main/java/in/koreatech/koin/core/activity/WebViewActivity.kt index 58505b015..536426432 100644 --- a/core/src/main/java/in/koreatech/koin/core/activity/WebViewActivity.kt +++ b/core/src/main/java/in/koreatech/koin/core/activity/WebViewActivity.kt @@ -18,7 +18,7 @@ class WebViewActivity : ActivityBase(R.layout.activity_webview) { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val title = intent.getStringExtra("title") + val title = intent.getStringExtra("title") ?: "" val url = intent.getStringExtra("url") init(title, url) } diff --git a/koin/src/main/java/in/koreatech/koin/ui/navigation/KoinNavigationDrawerActivity.kt b/koin/src/main/java/in/koreatech/koin/ui/navigation/KoinNavigationDrawerActivity.kt index 97435ac2f..cc422db7c 100644 --- a/koin/src/main/java/in/koreatech/koin/ui/navigation/KoinNavigationDrawerActivity.kt +++ b/koin/src/main/java/in/koreatech/koin/ui/navigation/KoinNavigationDrawerActivity.kt @@ -1,24 +1,7 @@ package `in`.koreatech.koin.ui.navigation -import `in`.koreatech.koin.R -import `in`.koreatech.koin.core.activity.ActivityBase -import `in`.koreatech.koin.core.activity.WebViewActivity -import `in`.koreatech.koin.core.toast.ToastUtil -import `in`.koreatech.koin.ui.bus.BusActivity -import `in`.koreatech.koin.ui.dining.DiningActivity -import `in`.koreatech.koin.ui.land.LandActivity -import `in`.koreatech.koin.ui.login.LoginActivity -import `in`.koreatech.koin.ui.main.activity.MainActivity -import `in`.koreatech.koin.ui.navigation.state.MenuState -import `in`.koreatech.koin.ui.navigation.viewmodel.KoinNavigationDrawerViewModel -import `in`.koreatech.koin.ui.store.activity.StoreActivity -import `in`.koreatech.koin.ui.timetable.TimetableActivity -import `in`.koreatech.koin.ui.timetable.TimetableAnonymousActivity -import `in`.koreatech.koin.ui.userinfo.UserInfoActivity -import `in`.koreatech.koin.util.ext.* import android.content.Intent import android.graphics.Typeface -import android.net.Uri import android.os.Bundle import android.view.MenuItem import android.view.View @@ -33,13 +16,36 @@ import androidx.drawerlayout.widget.DrawerLayout import com.google.android.material.navigation.NavigationView import dagger.hilt.android.AndroidEntryPoint import `in`.koreatech.koin.BuildConfig +import `in`.koreatech.koin.R +import `in`.koreatech.koin.core.activity.ActivityBase +import `in`.koreatech.koin.core.activity.WebViewActivity +import `in`.koreatech.koin.core.toast.ToastUtil import `in`.koreatech.koin.data.constant.URLConstant import `in`.koreatech.koin.domain.model.user.User +import `in`.koreatech.koin.ui.bus.BusActivity +import `in`.koreatech.koin.ui.dining.DiningActivity +import `in`.koreatech.koin.ui.land.LandActivity +import `in`.koreatech.koin.ui.login.LoginActivity +import `in`.koreatech.koin.ui.main.activity.MainActivity import `in`.koreatech.koin.ui.navigation.contract.GotoAskFormContract +import `in`.koreatech.koin.ui.navigation.state.MenuState +import `in`.koreatech.koin.ui.navigation.viewmodel.KoinNavigationDrawerViewModel +import `in`.koreatech.koin.ui.store.activity.StoreActivity +import `in`.koreatech.koin.ui.timetable.TimetableActivity +import `in`.koreatech.koin.ui.timetable.TimetableAnonymousActivity +import `in`.koreatech.koin.ui.userinfo.UserInfoActivity +import `in`.koreatech.koin.util.ext.addDrawerListener +import `in`.koreatech.koin.util.ext.blueStatusBar +import `in`.koreatech.koin.util.ext.closeDrawer +import `in`.koreatech.koin.util.ext.isDrawerOpened +import `in`.koreatech.koin.util.ext.observeLiveData +import `in`.koreatech.koin.util.ext.toggleDrawer +import `in`.koreatech.koin.util.ext.whiteStatusBar +import `in`.koreatech.koin.util.ext.windowWidth @AndroidEntryPoint abstract class KoinNavigationDrawerActivity : ActivityBase(), - NavigationView.OnNavigationItemSelectedListener { + NavigationView.OnNavigationItemSelectedListener { protected abstract val menuState: MenuState val drawerLayoutId get() = R.id.drawer_layout @@ -59,21 +65,21 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(), private val menus by lazy { listOf( - R.id.navi_item_store, - R.id.navi_item_bus, R.id.navi_item_dining, - R.id.navi_item_timetable, R.id.navi_item_land, - R.id.navi_item_owner + R.id.navi_item_store, + R.id.navi_item_bus, R.id.navi_item_dining, + R.id.navi_item_timetable, R.id.navi_item_land, + R.id.navi_item_owner ).map { findViewById(it) }.zip( - listOf( - MenuState.Store, - MenuState.Bus, - MenuState.Dining, - MenuState.Timetable, - MenuState.Land, - MenuState.Owner - ) + listOf( + MenuState.Store, + MenuState.Bus, + MenuState.Dining, + MenuState.Timetable, + MenuState.Land, + MenuState.Owner + ) ) { view, state -> state to view }.toMap() @@ -81,21 +87,21 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(), private val menuTextViews by lazy { listOf( - R.id.navi_item_store_textview, - R.id.navi_item_bus_textview, R.id.navi_item_dining_textview, - R.id.navi_item_timetable_textview, R.id.navi_item_land_textview + R.id.navi_item_store_textview, + R.id.navi_item_bus_textview, R.id.navi_item_dining_textview, + R.id.navi_item_timetable_textview, R.id.navi_item_land_textview ).map { findViewById(it).apply { changeMenuFont(this) } }.zip( - listOf( - MenuState.Store, - MenuState.Bus, - MenuState.Dining, - MenuState.Timetable, - MenuState.Land - ) + listOf( + MenuState.Store, + MenuState.Bus, + MenuState.Dining, + MenuState.Timetable, + MenuState.Land + ) ) { view, state -> state to view }.toMap() @@ -112,10 +118,15 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(), menus.forEach { (state, view) -> view.setOnClickListener { when (state) { - MenuState.Owner -> startActivity(Intent(Intent.ACTION_VIEW, Uri.parse( - if (BuildConfig.IS_DEBUG) URLConstant.OWNER_URL_STAGE - else URLConstant.OWNER_URL_PRODUCTION - ))) + MenuState.Owner -> { + Intent(this, WebViewActivity::class.java).apply { + putExtra( + "url", + if (BuildConfig.IS_DEBUG) URLConstant.OWNER_URL_STAGE + else URLConstant.OWNER_URL_PRODUCTION + ) + }.run(::startActivity) + } else -> { koinNavigationDrawerViewModel.selectMenu(state) @@ -152,7 +163,7 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(), super.onAttachedToWindow() leftNavigationView.layoutParams = - leftNavigationView.layoutParams.apply { width = windowWidth } + leftNavigationView.layoutParams.apply { width = windowWidth } } override fun onBackPressed() { @@ -162,7 +173,7 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(), if (menuState == MenuState.Main) { if (System.currentTimeMillis() > pressTime + 2000) { pressTime = System.currentTimeMillis() - ToastUtil.getInstance().makeShort("뒤로가기 버튼을 한 번 더 누르면 종료됩니다.") + ToastUtil.getInstance().makeShort(getString(R.string.press_again_to_exit)) } else { finishAffinity() } @@ -176,7 +187,7 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(), observeLiveData(userState) { user -> val nameTextview = findViewById(R.id.base_naviagtion_drawer_nickname_textview) when (user) { - User.Anonymous -> nameTextview.text = "익명" + User.Anonymous -> nameTextview.text = getString(R.string.user_anon) is User.Student -> nameTextview.text = user.name } } @@ -255,7 +266,7 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(), } else -> { - ToastUtil.getInstance().makeShort("서비스예정입니다") + ToastUtil.getInstance().makeShort(getString(R.string.to_be_opened)) } } } @@ -358,21 +369,21 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(), fun showLoginRequestDialog() { val builder = AlertDialog.Builder(this) - builder.setTitle("회원 전용 서비스") - .setMessage("로그인이 필요한 서비스입니다.\n로그인 하시겠습니까?") - .setCancelable(false) - .setPositiveButton("확인") { dialog, _ -> - val intent = Intent( - this, - LoginActivity::class.java - ) - intent.putExtra("FIRST_LOGIN", false) - startActivity(intent) - overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.fade_out) - } - .setNegativeButton("취소") { dialog, _ -> - dialog.cancel() - } + builder.setTitle(getString(R.string.user_only)) + .setMessage(getString(R.string.login_request)) + .setCancelable(false) + .setPositiveButton(getString(R.string.navigation_ok)) { dialog, _ -> + val intent = Intent( + this, + LoginActivity::class.java + ) + intent.putExtra("FIRST_LOGIN", false) + startActivity(intent) + overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.fade_out) + } + .setNegativeButton(getString(R.string.navigation_cancel)) { dialog, _ -> + dialog.cancel() + } val dialog = builder.create() // 알림창 객체 생성 dialog.show() // 알림창 띄우기 } @@ -398,8 +409,8 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(), get() { val s = text.toString() val styledText = HtmlCompat.fromHtml( - "$s", - HtmlCompat.FROM_HTML_MODE_LEGACY + "$s", + HtmlCompat.FROM_HTML_MODE_LEGACY ) setText(styledText, TextView.BufferType.SPANNABLE) //#f7941e return this diff --git a/koin/src/main/res/values/strings.xml b/koin/src/main/res/values/strings.xml index 499eb18c6..172314020 100644 --- a/koin/src/main/res/values/strings.xml +++ b/koin/src/main/res/values/strings.xml @@ -36,6 +36,13 @@ 오픈소스 로그인 로그아웃 + 취소 + 로그인이 필요한 서비스입니다.\n로그인 하시겠습니까? + 확인 + 회원 전용 서비스 + 서비스예정입니다 + 뒤로가기 버튼을 한 번 더 누르면 종료됩니다. + 익명