-
Notifications
You must be signed in to change notification settings - Fork 2
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
[feat] WebViewActivity 구현 #34
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/org/sopt/pingle/presentation/ui/common/WebViewActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.sopt.pingle.presentation.ui.common | ||
|
||
import android.annotation.SuppressLint | ||
import android.os.Bundle | ||
import android.webkit.WebChromeClient | ||
import android.webkit.WebViewClient | ||
import org.sopt.pingle.R | ||
import org.sopt.pingle.databinding.ActivityWebViewBinding | ||
import org.sopt.pingle.util.base.BindingActivity | ||
|
||
class WebViewActivity : BindingActivity<ActivityWebViewBinding>(R.layout.activity_web_view) { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
initLayout() | ||
loadWebView() | ||
} | ||
|
||
@SuppressLint("SetJavaScriptEnabled") | ||
private fun initLayout() { | ||
binding.wvWebView.apply { | ||
webViewClient = WebViewClient() | ||
webChromeClient = WebChromeClient() | ||
|
||
settings.apply { | ||
javaScriptEnabled = true | ||
javaScriptCanOpenWindowsAutomatically = true | ||
loadWithOverviewMode = true | ||
useWideViewPort = true | ||
domStorageEnabled = true | ||
} | ||
} | ||
} | ||
|
||
private fun loadWebView() { | ||
intent.getStringExtra(WEB_VIEW_LINK)?.let { binding.wvWebView.loadUrl(it) } | ||
} | ||
|
||
companion object { | ||
const val WEB_VIEW_LINK = "WebViewLink" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<data> | ||
|
||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".presentation.ui.common.WebViewActivity"> | ||
|
||
<WebView | ||
android:id="@+id/wv_web_view" | ||
android:layout_width="0dp" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0dp의 신 |
||
android:layout_height="0dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
우와 신기해......... 웹뷰는 이런 식으로 연결하는 거군요 존재부터 사용방법까지 하나도 몰랐던 거라 넘 신기하구..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것만이 정답은 아니고 웹뷰를 띄우는 방법은 여러가지가 있습니다 ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마자요 intent의 ACTION_VIEW를 사용할 수도 있구 다른 방법이 많답니당!