Remove origin signin scene

This commit is contained in:
tarsin committed 2023-01-11 13:22:56 +08:00
1 parent 97d1bd7685
commit f036774e07
15 files changed
+16 -1420

No files matched your search

@@ -55,7 +55,6 @@ import com.hippo.ehviewer.client.EhCookieStore
import com.hippo.ehviewer.client.EhUrl
import com.hippo.ehviewer.client.EhUtils
import com.hippo.ehviewer.ui.LoginActivity.Companion.SELECT_SITE_ROUTE_NAME
import com.hippo.ehviewer.ui.scene.getProfile
import com.hippo.util.ExceptionUtils
import com.hippo.util.getClipboardManager
import com.hippo.util.getTextFromClipboard
@@ -0,0 +1,14 @@
package com.hippo.ehviewer.ui.compose
import com.hippo.ehviewer.Settings
import com.hippo.ehviewer.client.EhClient
import com.hippo.ehviewer.client.parser.ProfileParser
suspend fun getProfile() {
runCatching {
(EhClient.execute(EhClient.METHOD_GET_PROFILE) as ProfileParser.Result).run {
Settings.putDisplayName(displayName)
Settings.putAvatar(avatar)
}
}
}
@@ -108,6 +108,7 @@ fun SelectSiteScreen(finish: () -> Unit) {
) {
Button(onClick = {
Settings.putSelectSite(false)
Settings.putNeedSignIn(false)
if (!site)
Settings.putGallerySite(EhUrl.SITE_E)
else
@@ -61,7 +61,6 @@ import com.hippo.ehviewer.client.EhUtils
import com.hippo.ehviewer.ui.LoginActivity.Companion.COOKIE_SIGN_IN_ROUTE_NAME
import com.hippo.ehviewer.ui.LoginActivity.Companion.SELECT_SITE_ROUTE_NAME
import com.hippo.ehviewer.ui.LoginActivity.Companion.WEBVIEW_SIGN_IN_ROUTE_NAME
import com.hippo.ehviewer.ui.scene.getProfile
import com.hippo.util.ExceptionUtils
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.withUIContext
@@ -1,216 +0,0 @@
/*
* Copyright 2016 Hippo Seven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.ehviewer.ui.scene
import android.graphics.Paint
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.hippo.app.BaseDialogBuilder
import com.hippo.ehviewer.EhApplication.Companion.ehCookieStore
import com.hippo.ehviewer.R
import com.hippo.ehviewer.client.EhClient
import com.hippo.ehviewer.client.EhCookieStore
import com.hippo.ehviewer.client.EhRequest
import com.hippo.ehviewer.client.EhUrl
import com.hippo.ehviewer.client.EhUtils
import com.hippo.ehviewer.databinding.SceneCookieSignInBinding
import com.hippo.util.ExceptionUtils
import com.hippo.util.getClipboardManager
import com.hippo.util.getTextFromClipboard
import eu.kanade.tachiyomi.util.lang.launchIO
import okhttp3.Cookie
import java.util.Locale
class CookieSignInScene : BaseScene() {
private var _binding: SceneCookieSignInBinding? = null
private val binding
get() = _binding!!
override fun needShowLeftDrawer(): Boolean {
return false
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
showSoftInput(binding.ipbMemberId)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?, savedInstanceState: Bundle?
): View {
_binding = SceneCookieSignInBinding.inflate(inflater, container, false)
binding.fromClipboard.run {
paintFlags = paintFlags or Paint.UNDERLINE_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG
}
binding.ipbPassHash.setOnEditorActionListener { _, _, _ ->
enter()
true
}
binding.ok.setOnClickListener {
enter()
}
binding.fromClipboard.setOnClickListener {
fillCookiesFromClipboard()
}
// Try to get old version cookie info
val sharedPreferences = requireContext().getSharedPreferences("eh_info", 0)
val ipbMemberId = sharedPreferences.getString("ipb_member_id", null)
val ipbPassHash = sharedPreferences.getString("ipb_pass_hash", null)
val igneous = sharedPreferences.getString("igneous", null)
var getIt = false
if (!TextUtils.isEmpty(ipbMemberId)) {
binding.ipbMemberId.setText(ipbMemberId)
getIt = true
}
if (!TextUtils.isEmpty(ipbPassHash)) {
binding.ipbPassHash.setText(ipbPassHash)
getIt = true
}
if (!TextUtils.isEmpty(igneous)) {
binding.igneous.setText(igneous)
getIt = true
}
if (getIt) {
showTip(R.string.found_cookies, LENGTH_SHORT)
}
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
fun enter() {
val ipbMemberId = binding.ipbMemberId.text.toString().trim { it <= ' ' }
val ipbPassHash = binding.ipbPassHash.text.toString().trim { it <= ' ' }
val igneous = binding.igneous.text.toString().trim { it <= ' ' }
if (TextUtils.isEmpty(ipbMemberId)) {
binding.ipbMemberIdLayout.error = getString(R.string.text_is_empty)
return
} else {
binding.ipbMemberIdLayout.error = null
}
if (TextUtils.isEmpty(ipbPassHash)) {
binding.ipbPassHashLayout.error = getString(R.string.text_is_empty)
return
} else {
binding.ipbPassHashLayout.error = null
}
hideSoftInput()
storeCookie(ipbMemberId, ipbPassHash, igneous)
val request = EhRequest()
.setMethod(EhClient.METHOD_GET_PROFILE)
.setCallback(CookieSignInListener())
request.enqueue(this)
}
private fun storeCookie(id: String, hash: String, igneous: String) {
EhUtils.signOut()
val store = ehCookieStore
store.addCookie(newCookie(EhCookieStore.KEY_IPD_MEMBER_ID, id, EhUrl.DOMAIN_E))
store.addCookie(newCookie(EhCookieStore.KEY_IPD_MEMBER_ID, id, EhUrl.DOMAIN_EX))
store.addCookie(newCookie(EhCookieStore.KEY_IPD_PASS_HASH, hash, EhUrl.DOMAIN_E))
store.addCookie(newCookie(EhCookieStore.KEY_IPD_PASS_HASH, hash, EhUrl.DOMAIN_EX))
if (igneous.isNotEmpty()) {
store.addCookie(newCookie(EhCookieStore.KEY_IGNEOUS, igneous, EhUrl.DOMAIN_E))
store.addCookie(newCookie(EhCookieStore.KEY_IGNEOUS, igneous, EhUrl.DOMAIN_EX))
}
}
private fun fillCookiesFromClipboard() {
val context = requireContext()
hideSoftInput()
val text = context.getClipboardManager().getTextFromClipboard(context)
if (text == null) {
showTip(R.string.from_clipboard_error, LENGTH_SHORT)
return
}
try {
val kvs: Array<String> = if (text.contains(";")) {
text.split(";".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
} else if (text.contains("\n")) {
text.split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
} else {
showTip(R.string.from_clipboard_error, LENGTH_SHORT)
return
}
if (kvs.size < 3) {
showTip(R.string.from_clipboard_error, LENGTH_SHORT)
return
}
for (s in kvs) {
val kv: Array<String> = if (s.contains("=")) {
s.split("=".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
} else if (s.contains(":")) {
s.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
} else {
continue
}
if (kv.size != 2) {
continue
}
when (kv[0].trim { it <= ' ' }.lowercase(Locale.getDefault())) {
"ipb_member_id" -> binding.ipbMemberId.setText(kv[1].trim { it <= ' ' })
"ipb_pass_hash" -> binding.ipbPassHash.setText(kv[1].trim { it <= ' ' })
"igneous" -> binding.igneous.setText(kv[1].trim { it <= ' ' })
}
}
enter()
} catch (e: Exception) {
ExceptionUtils.throwIfFatal(e)
e.printStackTrace()
showTip(R.string.from_clipboard_error, LENGTH_SHORT)
}
}
private inner class CookieSignInListener : EhClient.Callback<Any?> {
override fun onSuccess(result: Any?) {
launchIO {
getProfile()
}
navigateToTop()
}
override fun onFailure(e: Exception) {
ehCookieStore.signOut()
BaseDialogBuilder(requireContext()).setTitle(R.string.sign_in_failed)
.setMessage(
"""
${ExceptionUtils.getReadableString(e)}
${getString(R.string.wrong_cookie_warning)}
""".trimIndent()
)
.setPositiveButton(R.string.get_it, null).show()
}
override fun onCancel() {
ehCookieStore.signOut()
}
}
companion object {
private fun newCookie(name: String, value: String, domain: String): Cookie {
return Cookie.Builder().name(name).value(value)
.domain(domain).expiresAt(Long.MAX_VALUE).build()
}
}
}
@@ -1,73 +0,0 @@
/*
* Copyright 2016 Hippo Seven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.ehviewer.ui.scene
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.hippo.ehviewer.EhApplication.Companion.ehCookieStore
import com.hippo.ehviewer.R
import com.hippo.ehviewer.Settings
import com.hippo.ehviewer.client.EhUrl
import com.hippo.ehviewer.databinding.SceneSelectSiteBinding
class SelectSiteScene : BaseScene() {
private var _binding: SceneSelectSiteBinding? = null
private val binding
get() = _binding!!
override fun needShowLeftDrawer(): Boolean {
return false
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = SceneSelectSiteBinding.inflate(inflater, container, false)
if (ehCookieStore.hasSignedIn()) {
binding.siteEx.isChecked = true
} else {
binding.siteE.isChecked = true
}
binding.ok.setOnClickListener {
when (binding.buttonGroup.checkedButtonId) {
R.id.site_e -> {
Settings.putSelectSite(false)
Settings.putGallerySite(EhUrl.SITE_E)
navigateToTop()
}
R.id.site_ex -> {
Settings.putSelectSite(false)
Settings.putGallerySite(EhUrl.SITE_EX)
navigateToTop()
}
else -> {
showTip(R.string.no_select, LENGTH_SHORT)
}
}
}
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
@@ -1,178 +0,0 @@
/*
* Copyright 2016 Hippo Seven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.ehviewer.ui.scene
import android.graphics.Paint
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import androidx.lifecycle.lifecycleScope
import com.hippo.app.BaseDialogBuilder
import com.hippo.ehviewer.R
import com.hippo.ehviewer.Settings
import com.hippo.ehviewer.UrlOpener
import com.hippo.ehviewer.client.EhClient
import com.hippo.ehviewer.client.EhUrl
import com.hippo.ehviewer.client.EhUtils
import com.hippo.ehviewer.client.parser.ProfileParser
import com.hippo.ehviewer.databinding.SceneLoginBinding
import com.hippo.util.ExceptionUtils
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.withUIContext
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
class SignInScene : BaseScene() {
private var _binding: SceneLoginBinding? = null
private val binding
get() = _binding!!
private var mSignInJob: Job? = null
override fun needShowLeftDrawer(): Boolean {
return false
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = SceneLoginBinding.inflate(inflater, container, false)
binding.signInViaWebview.run {
paintFlags = paintFlags or Paint.UNDERLINE_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG
}
binding.signInViaCookies.run {
paintFlags = paintFlags or Paint.UNDERLINE_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG
}
binding.touristMode.run {
paintFlags = paintFlags or Paint.UNDERLINE_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG
}
binding.password.setOnEditorActionListener { v, actionId, _ ->
if (v === binding.password) {
if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_NULL) {
signIn()
return@setOnEditorActionListener true
}
}
false
}
binding.register.setOnClickListener {
UrlOpener.openUrl(requireActivity(), EhUrl.URL_REGISTER, false)
}
binding.signIn.setOnClickListener { signIn() }
binding.signInViaWebview.setOnClickListener { navigate(R.id.webViewSignInScene, null) }
binding.signInViaCookies.setOnClickListener { navigate(R.id.cookieSignInScene, null) }
binding.touristMode.setOnClickListener {
// Set gallery size SITE_E if skip sign in
Settings.putGallerySite(EhUrl.SITE_E)
finishSignIn()
}
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
private fun showProgress() {
if (View.VISIBLE != binding.progress.visibility) {
binding.progress.run {
alpha = 0.0f
visibility = View.VISIBLE
animate().alpha(1.0f).setDuration(500).start()
}
}
}
private fun hideProgress() {
binding.progress.visibility = View.GONE
}
private fun signIn() {
if (mSignInJob?.isActive == true) return
val username = binding.username.text.toString()
val password = binding.password.text.toString()
if (username.isEmpty()) {
binding.usernameLayout.error = getString(R.string.error_username_cannot_empty)
return
} else {
binding.usernameLayout.error = null
}
if (password.isEmpty()) {
binding.passwordLayout.error = getString(R.string.error_password_cannot_empty)
return
} else {
binding.passwordLayout.error = null
}
hideSoftInput()
showProgress()
EhUtils.signOut()
mSignInJob = viewLifecycleOwner.lifecycleScope.launchIO {
runCatching {
(EhClient.execute(EhClient.METHOD_SIGN_IN, username, password) as String).let {
Settings.putDisplayName(it)
}
}.onFailure {
it.printStackTrace()
withUIContext {
hideProgress()
showResultErrorDialog(it)
}
}.onSuccess {
// This fragment's lifecycle is to be finished
GlobalScope.launchIO {
getProfile()
}
withUIContext {
finishSignIn()
}
}
}
}
private fun finishSignIn() {
Settings.putNeedSignIn(false)
if (Settings.getSelectSite()) {
navigate(R.id.selectSiteScene, null)
} else {
navigateToTop()
}
}
private fun showResultErrorDialog(e: Throwable) {
BaseDialogBuilder(requireContext())
.setTitle(R.string.sign_in_failed)
.setMessage(
"""
${ExceptionUtils.getReadableString(e)}
${getString(R.string.sign_in_failed_tip)}
""".trimIndent()
)
.setPositiveButton(R.string.get_it, null)
.show()
}
}
suspend fun getProfile() {
runCatching {
(EhClient.execute(EhClient.METHOD_GET_PROFILE) as ProfileParser.Result).run {
Settings.putDisplayName(displayName)
Settings.putAvatar(avatar)
}
}
}
@@ -28,6 +28,7 @@ import com.hippo.ehviewer.EhApplication.Companion.ehCookieStore
import com.hippo.ehviewer.client.EhCookieStore
import com.hippo.ehviewer.client.EhUrl
import com.hippo.ehviewer.client.EhUtils
import com.hippo.ehviewer.ui.compose.getProfile
import com.hippo.ehviewer.widget.DialogWebChromeClient
import eu.kanade.tachiyomi.util.lang.launchIO
import okhttp3.Cookie
@@ -1,166 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2022 hathlife
~
~ This file is part of EhViewer
~
~ EhViewer is free software: you can redistribute it and/or
~ modify it under the terms of the GNU General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ EhViewer is distributed in the hope that it will be useful, but
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License along with EhViewer.
~ If not, see <https://www.gnu.org/licenses/>.
~
-->
<FrameLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:fitsSystemWindowsInsets="top|bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="480dp"
android:layout_height="match_parent"
android:orientation="vertical">
<Space
android:layout_width="match_parent"
android:layout_height="80dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="32dp"
android:text="@string/cookie_explain"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_little_small"
app:drawableTopCompat="@drawable/v_cookie_brown_x256" />
</LinearLayout>
<LinearLayout
android:id="@+id/buttonPanel"
style="?attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="bottom"
android:orientation="vertical"
android:paddingLeft="12dp"
android:paddingTop="4dp"
android:paddingRight="12dp"
android:paddingBottom="4dp">
<Space
android:layout_width="match_parent"
android:layout_height="80dp" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ipb_member_id_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/keyline_margin"
android:hint="ipb_member_id"
android:minWidth="@dimen/single_max_width">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ipb_member_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
tools:ignore="HardcodedText" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ipb_pass_hash_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="ipb_pass_hash"
android:minWidth="@dimen/single_max_width">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ipb_pass_hash"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
tools:ignore="HardcodedText" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/igneous_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="igneous"
android:minWidth="@dimen/single_max_width">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/igneous"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
tools:ignore="HardcodedText" />
<Space
android:layout_width="wrap_content"
android:layout_height="64dp"
android:layout_weight="1" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/ok"
style="@style/Widget.Material3.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:insetLeft="80dp"
android:insetRight="80dp"
android:text="@android:string/ok" />
<Space
android:layout_width="match_parent"
android:layout_height="40dp" />
<TextView
android:id="@+id/from_clipboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="?selectableItemBackground"
android:paddingHorizontal="8dp"
android:text="@string/from_clipboard" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
@@ -1,188 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2022 hathlife
~
~ This file is part of EhViewer
~
~ EhViewer is free software: you can redistribute it and/or
~ modify it under the terms of the GNU General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ EhViewer is distributed in the hope that it will be useful, but
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License along with EhViewer.
~ If not, see <https://www.gnu.org/licenses/>.
~
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:fitsSystemWindowsInsets="top|bottom">
<LinearLayout
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="@dimen/keyline_margin">
<LinearLayout
android:layout_width="480dp"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="257dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:padding="@dimen/keyline_margin"
app:srcCompat="@drawable/ic_launcher_foreground" />
</LinearLayout>
<LinearLayout
android:id="@+id/buttonPanel"
style="?attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="bottom"
android:orientation="vertical"
android:paddingLeft="12dp"
android:paddingTop="100dp"
android:paddingRight="12dp"
android:paddingBottom="4dp">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/username_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="@string/username"
android:minWidth="@dimen/single_max_width">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="username"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="@string/password"
android:minWidth="@dimen/single_max_width"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
style="@style/TextAppearance.Material3.LabelLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:maxWidth="@dimen/single_max_width"
android:paddingTop="24dp"
android:text="@string/app_waring" />
<Space
android:layout_width="match_parent"
android:layout_height="40dp" />
<Button
android:id="@+id/sign_in"
style="@style/Widget.Material3.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:insetLeft="80dp"
android:insetRight="80dp"
android:text="@string/sign_in" />
<Button
android:id="@+id/register"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:insetLeft="80dp"
android:insetRight="80dp"
android:text="@string/register" />
<Space
android:layout_width="match_parent"
android:layout_height="40dp" />
<TextView
android:id="@+id/sign_in_via_webview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="?selectableItemBackground"
android:paddingHorizontal="8dp"
android:text="@string/sign_in_via_webview" />
<TextView
android:id="@+id/sign_in_via_cookies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="?selectableItemBackground"
android:paddingHorizontal="8dp"
android:text="@string/sign_in_via_cookies" />
<TextView
android:id="@+id/tourist_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="?selectableItemBackground"
android:paddingHorizontal="8dp"
android:text="@string/tourist_mode" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:visibility="gone">
<com.google.android.material.progressindicator.CircularProgressIndicator
style="@style/ProgressView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
@@ -1,125 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2022 hathlife
~
~ This file is part of EhViewer
~
~ EhViewer is free software: you can redistribute it and/or
~ modify it under the terms of the GNU General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ EhViewer is distributed in the hope that it will be useful, but
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License along with EhViewer.
~ If not, see <https://www.gnu.org/licenses/>.
~
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:fitsSystemWindowsInsets="top|bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="480dp"
android:layout_height="match_parent"
android:orientation="vertical">
<Space
android:layout_width="match_parent"
android:layout_height="96dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="128dp"
android:paddingTop="100dp"
android:paddingEnd="12dp"
android:text="@string/select_scene"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<Space
android:layout_width="match_parent"
android:layout_height="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="128dp"
android:paddingTop="100dp"
android:paddingEnd="12dp"
android:text="@string/select_scene_explain" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Space
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/button_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/keyline_margin"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.button.MaterialButton
android:id="@+id/site_e"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="@string/site_e" />
<com.google.android.material.button.MaterialButton
android:id="@+id/site_ex"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="@string/site_ex" />
</com.google.android.material.button.MaterialButtonToggleGroup>
<Space
android:layout_width="match_parent"
android:layout_height="77dp"
android:layout_weight="1" />
<Button
android:id="@+id/ok"
style="@style/Widget.Material3.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:insetLeft="80dp"
android:insetRight="80dp"
android:text="@android:string/ok" />
<Space
android:layout_width="match_parent"
android:layout_height="96dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
@@ -1,160 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2016 Hippo Seven
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<LinearLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/keyline_margin"
app:fitsSystemWindowsInsets="top|bottom">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="@dimen/keyline_margin"
app:srcCompat="@drawable/v_cookie_brown_x48" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:clipToPadding="false"
android:paddingVertical="@dimen/keyline_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="32dp"
android:text="@string/cookie_explain"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_little_small" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ipb_member_id_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/keyline_margin"
android:hint="ipb_member_id"
android:minWidth="@dimen/single_max_width">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ipb_member_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
tools:ignore="HardcodedText" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ipb_pass_hash_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="ipb_pass_hash"
android:minWidth="@dimen/single_max_width">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ipb_pass_hash"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
tools:ignore="HardcodedText" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/igneous_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="igneous"
android:minWidth="@dimen/single_max_width">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/igneous"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
tools:ignore="HardcodedText" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/buttonPanel"
style="?attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="12dp"
android:paddingTop="4dp"
android:paddingRight="12dp"
android:paddingBottom="4dp">
<Button
android:id="@+id/ok"
style="@style/Widget.Material3.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@android:string/ok" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="bottom|center_horizontal"
android:orientation="horizontal"
android:paddingLeft="12dp"
android:paddingTop="4dp"
android:paddingRight="12dp"
android:paddingBottom="4dp">
<TextView
android:id="@+id/from_clipboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="8dp"
android:text="@string/from_clipboard" />
</LinearLayout>
</LinearLayout>
-188
View File
@@ -1,188 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2016 Hippo Seven
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:fitsSystemWindowsInsets="top|bottom">
<ScrollView
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/keyline_margin">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="@dimen/keyline_margin"
app:srcCompat="@drawable/ic_launcher_foreground" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/username_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="@string/username"
android:minWidth="@dimen/single_max_width">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="username"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password_layout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="@string/password"
android:minWidth="@dimen/single_max_width"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
style="@style/TextAppearance.Material3.LabelLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:maxWidth="@dimen/single_max_width"
android:paddingTop="24dp"
android:text="@string/app_waring" />
<Space
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/buttonPanel"
style="?attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="12dp"
android:paddingTop="4dp"
android:paddingRight="12dp"
android:paddingBottom="4dp">
<Button
android:id="@+id/register"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:layout_weight="1"
android:text="@string/register" />
<Button
android:id="@+id/sign_in"
style="@style/Widget.Material3.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:layout_weight="1"
android:text="@string/sign_in" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingLeft="12dp"
android:paddingTop="4dp"
android:paddingRight="12dp"
android:paddingBottom="4dp">
<TextView
android:id="@+id/sign_in_via_webview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:paddingHorizontal="8dp"
android:text="@string/sign_in_via_webview" />
<TextView
android:id="@+id/sign_in_via_cookies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:paddingHorizontal="8dp"
android:text="@string/sign_in_via_cookies" />
</LinearLayout>
<TextView
android:id="@+id/tourist_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="?selectableItemBackground"
android:paddingHorizontal="8dp"
android:text="@string/tourist_mode" />
</LinearLayout>
</ScrollView>
<FrameLayout
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:visibility="gone">
<com.google.android.material.progressindicator.CircularProgressIndicator
style="@style/ProgressView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
@@ -1,112 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2016 Hippo Seven
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingHorizontal="@dimen/keyline_margin"
android:paddingTop="@dimen/keyline_margin"
app:fitsSystemWindowsInsets="top|bottom">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:clipToPadding="false"
android:fillViewport="true"
android:paddingVertical="@dimen/keyline_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_scene"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<Space
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/button_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/keyline_margin"
app:selectionRequired="true"
app:singleSelection="true">
<com.google.android.material.button.MaterialButton
android:id="@+id/site_e"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="@string/site_e" />
<com.google.android.material.button.MaterialButton
android:id="@+id/site_ex"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="@string/site_ex" />
</com.google.android.material.button.MaterialButtonToggleGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_scene_explain" />
<Space
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/buttonPanel"
style="?attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="12dp"
android:paddingTop="4dp"
android:paddingRight="12dp"
android:paddingBottom="20dp">
<Button
android:id="@+id/ok"
style="@style/Widget.Material3.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@android:string/ok" />
</LinearLayout>
</LinearLayout>
-12
View File
@@ -76,20 +76,8 @@
android:id="@+id/progressScene"
android:name="com.hippo.ehviewer.ui.scene.ProgressScene"
android:label="ProgressScene" />
<fragment
android:id="@+id/signInScene"
android:name="com.hippo.ehviewer.ui.scene.SignInScene"
android:label="SignInScene" />
<fragment
android:id="@+id/selectSiteScene"
android:name="com.hippo.ehviewer.ui.scene.SelectSiteScene"
android:label="SelectSiteScene" />
<fragment
android:id="@+id/webViewSignInScene"
android:name="com.hippo.ehviewer.ui.scene.WebViewSignInScene"
android:label="WebViewSignInScene" />
<fragment
android:id="@+id/cookieSignInScene"
android:name="com.hippo.ehviewer.ui.scene.CookieSignInScene"
android:label="CookieSignInScene" />
</navigation>