Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

영양사 페이지 진입점에 웹뷰 추가 #219

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -59,43 +65,43 @@ 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<View>(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()
}

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<TextView>(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()
Expand All @@ -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)
Expand Down Expand Up @@ -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() {
Expand All @@ -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()
}
Expand All @@ -176,7 +187,7 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(),
observeLiveData(userState) { user ->
val nameTextview = findViewById<TextView>(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
}
}
Expand Down Expand Up @@ -255,7 +266,7 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(),
}

else -> {
ToastUtil.getInstance().makeShort("서비스예정입니다")
ToastUtil.getInstance().makeShort(getString(R.string.to_be_opened))
}
}
}
Expand Down Expand Up @@ -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() // 알림창 띄우기
}
Expand All @@ -398,8 +409,8 @@ abstract class KoinNavigationDrawerActivity : ActivityBase(),
get() {
val s = text.toString()
val styledText = HtmlCompat.fromHtml(
"<font color='#f7941e'>$s</font>",
HtmlCompat.FROM_HTML_MODE_LEGACY
"<font color='#f7941e'>$s</font>",
HtmlCompat.FROM_HTML_MODE_LEGACY
)
setText(styledText, TextView.BufferType.SPANNABLE) //#f7941e
return this
Expand Down
7 changes: 7 additions & 0 deletions koin/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
<string name="navigation_item_open_source">오픈소스</string>
<string name="navigation_item_login">로그인</string>
<string name="navigation_item_logout">로그아웃</string>
<string name="navigation_cancel">취소</string>
<string name="login_request">로그인이 필요한 서비스입니다.\n로그인 하시겠습니까?</string>
<string name="navigation_ok">확인</string>
<string name="user_only">회원 전용 서비스</string>
<string name="to_be_opened">서비스예정입니다</string>
<string name="press_again_to_exit">뒤로가기 버튼을 한 번 더 누르면 종료됩니다.</string>
<string name="user_anon">익명</string>


<!-- Server Messages -->
Expand Down