Skip to content

Commit

Permalink
Merge pull request #31 from matsumo0922/fix-bugs
Browse files Browse the repository at this point in the history
Add ability to manually attempt login
  • Loading branch information
matsumo0922 authored Jan 22, 2025
2 parents d69871e + 81f03bf commit edcd95f
Show file tree
Hide file tree
Showing 14 changed files with 292 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.content.pm.verify.domain.DomainVerificationUserState
import android.net.Uri
import android.os.Build
import android.provider.Settings
import android.widget.Toast
import androidx.activity.compose.LocalActivity
import androidx.annotation.RequiresApi
import androidx.compose.foundation.background
Expand Down Expand Up @@ -49,6 +50,7 @@ import me.matsumo.fanbox.core.resources.domain_validation_request_button
import me.matsumo.fanbox.core.resources.domain_validation_request_message
import me.matsumo.fanbox.core.resources.domain_validation_request_never_ask
import me.matsumo.fanbox.core.resources.domain_validation_request_title
import me.matsumo.fanbox.core.resources.error_no_available_this_device
import me.matsumo.fanbox.core.ui.extensition.padding
import me.matsumo.fanbox.core.ui.theme.bold
import org.jetbrains.compose.resources.stringResource
Expand Down Expand Up @@ -82,6 +84,7 @@ private fun RequestDomainVerification(
) {
val scope = rememberCoroutineScope()
var shouldRequest by remember { mutableStateOf(false) }
val errorMessage = stringResource(Res.string.error_no_available_this_device)

LaunchedEffect(Unit) {
val manager = activity.getSystemService(DomainVerificationManager::class.java)
Expand All @@ -100,8 +103,13 @@ private fun RequestDomainVerification(
if (shouldRequest) {
RequestDomainVerificationDialog(
onRequestClicked = {
activity.startActivity(Intent(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS, Uri.parse("package:${activity.packageName}")))
shouldRequest = false
runCatching {
activity.startActivity(Intent(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS, Uri.parse("package:${activity.packageName}")))
}.onFailure {
Toast.makeText(activity, errorMessage, Toast.LENGTH_SHORT).show()
}.onSuccess {
shouldRequest = false
}
},
onCancelClicked = { isChecked ->
if (isChecked) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
Expand All @@ -23,7 +22,6 @@ import com.svenjacobs.reveal.RevealCanvas
import com.svenjacobs.reveal.rememberRevealCanvasState
import dev.icerock.moko.biometry.compose.BindBiometryAuthenticatorEffect
import dev.icerock.moko.biometry.compose.rememberBiometryAuthenticatorFactory
import io.github.aakira.napier.Napier
import kotlinx.collections.immutable.ImmutableMap
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -129,25 +127,26 @@ fun PixiViewApp(

DisposableEffect(lifecycleOwner) {
val observer = object : DefaultLifecycleObserver {
override fun onResume(owner: LifecycleOwner) {
Napier.d { "onResume" }
override fun onCreate(owner: LifecycleOwner) {
viewModel.billingClientInitialize()
}

override fun onResume(owner: LifecycleOwner) {
viewModel.setAppLock(true)
viewModel.billingClientUpdate()
}

override fun onDestroy(owner: LifecycleOwner) {
viewModel.billingClientFinish()
}
}

lifecycleOwner.lifecycle.addObserver(observer)

onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
}
}
}
}

LaunchedEffect(true) {
viewModel.billingClientInitialize()
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ class PixiViewViewModel(
),
) { flows ->
val userData = flows[0] as UserData
val sessionId = flows[1] as String
val sessionId = flows[1] as String?
val downloadState = flows[2] as DownloadState
val isLoggedIn = flows[3] as Boolean
val isAppLocked = flows[4] as Boolean

ScreenState.Idle(
MainUiState(
userData = userData,
sessionId = sessionId,
sessionId = sessionId.orEmpty(),
fanboxMetadata = suspendRunCatching { fanboxRepository.getMetadata() }.getOrElse { getFanboxMetadataDummy() },
downloadState = downloadState,
isLoggedIn = isLoggedIn,
Expand Down Expand Up @@ -113,6 +113,10 @@ class PixiViewViewModel(
billingStatus.init()
}

fun billingClientFinish() {
billingStatus.finish()
}

fun billingClientUpdate() {
billingStatus.update()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ class BillingStatusImpl(
}

override fun finish() {
// do nothing
billingClient.dispose()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,16 @@
},
{
"versionName": "2.2.0",
"versionCode": 51,
"versionCode": 52,
"date": "2025/01/20",
"logJp": "・クリエイターの投稿をキーワードから検索できる機能を追加\n・ダウンロードキュー画面を追加\n・Android App Links に対応\n・UIの調整\n・投稿詳細画面にバナー広告を追加(アプリ維持費のためです。ごめんなさい!)",
"logEn": "・Added the ability to search creators' posts by keyword\n・Added a download queue screen\n・Supports Android App Links\n・Added banner ads to the post details screen (to cover app maintenance costs. Sorry!)"
},
{
"versionName": "2.2.1",
"versionCode": 53,
"date": "2025/01/23",
"logJp": "・ログインができない場合の救済導線を追加\n・アプリがクラッシュする恐れのある不具合の修正",
"logEn": "・Added a rescue guide for when you can't log in\n・Fixed a bug that could cause the app to crash"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<string name="error_service_status">サービス稼働状況</string>
<string name="error_ad_load_failed">広告の読み込みに失敗しました</string>
<string name="error_ad_load_failed_description">サービスの品質維持のために広告を表示しています。</string>
<string name="error_no_available_this_device">このデバイスでは利用できない機能です</string>

<!-- Common Unit -->
<string name="unit_day_before">%1$d日前</string>
Expand Down Expand Up @@ -354,8 +355,10 @@
<string name="welcome_login_dialog_message">GoogleやX(Twitter)のOAuthを利用した認証はセキュリティ上の懸念により対応していません。\n\nメールアドレスとパスワードを直接入力してログインを行ってください。</string>
<string name="welcome_login_debug_dialog_title">注意</string>
<string name="welcome_login_debug_dialog_message">デバッグログインを実行しますか?\n\nデバッグアカウントは事前に準備されたアカウントで、通常ユーザーの挙動を模倣します。ステージング環境保全のため、一部操作ができないもしくはエラーになる場合があります。</string>
<string name="welcome_login_other_title">ログインできない場合</string>
<string name="welcome_login_other_title">FANBOXSESSID 直接入力</string>
<string name="welcome_login_other_message">このアプリが動作するためには FANBOXSESSID というセッションIDが必要です。以下のリンクの手順に従って FANBOXSESSID を取得し、入力してください。</string>
<string name="welcome_login_web_help">ログインできない場合</string>
<string name="welcome_login_web_help_description">email と passwordを入力し、画面上ではログインできているにも関わらず、自動的に画面が切り替わらない場合のみ以下をお試しください。\n\nこのダイアログを一旦閉じ、ログインしていないと閲覧することができない情報があるページまで、画面上で遷移してください(ex: 支援しているクリエイターの投稿詳細画面)。\n\nその画面まで遷移したら再度画面下部の「ログインできない場合」のボタンを押し、このダイアログを表示してください。\n\nこの状態でダイアログ下部のログインボタンをタップしてください。WebView からログイン情報を取得し、ログインを試みます。</string>
<string name="welcome_permission_title">権限</string>
<string name="welcome_permission_message">アプリの利用には以下の権限が必要です\n下のボタンを押して権限を許可してください</string>
<string name="welcome_permission_ready_title">準備完了</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<string name="error_service_status">서비스 운영 현황</string>
<string name="error_ad_load_failed">광고를 로드하지 못했습니다.</string>
<string name="error_ad_load_failed_description">서비스 품질 유지를 위해 광고를 게재하고 있습니다.</string>
<string name="error_no_available_this_device">이 기기에서는 사용할 수 없는 기능입니다</string>

<!-- Common Unit -->
<string name="unit_day_before">%1$d일 전</string>
Expand Down Expand Up @@ -343,8 +344,10 @@
<string name="welcome_login_dialog_message">구글이나 X의 OAuth를 이용한 인증은 보안상의 문제로 인해 지원하지 않습니다.\n\n 이메일 주소와 비밀번호를 직접 입력하여 로그인하십시오.</string>
<string name="welcome_login_debug_dialog_title">주의</string>
<string name="welcome_login_debug_dialog_message">디버그 로그인을 실행하시겠습니까?\n\n디버그 계정은 미리 준비된 계정으로, 일반 사용자의 행동을 모방합니다. 스테이징 환경 보존을 위해 일부 조작이 불가능하거나 오류가 발생할 수 있습니다.</string>
<string name="welcome_login_other_title">로그인할 수 없는 경우</string>
<string name="welcome_login_other_message">이 앱이 작동하려면 FANBOXSESSID라는 세션 ID가 필요합니다. 아래 링크의 절차에 따라 FANBOXSESSID를 발급받아 입력하세요.</string>
<string name="welcome_login_other_title">FANBOXSESSID 직접 입력</string>
<string name="welcome_login_other_message">이 앱이 작동하려면 FANBOXSESSID라는 세션 ID가 필요합니다. 아래 링크의 지침에 따라 FANBOXSESSID를 얻은 후 입력해주세요.</string>
<string name="welcome_login_web_help">로그인할 수 없는 경우</string>
<string name="welcome_login_web_help_description">이메일과 비밀번호를 입력하고 화면에서 로그인된 것처럼 보이지만 화면이 자동으로 전환되지 않을 경우 아래 단계를 시도해보세요:\n\n이 대화 상자를 한 번 닫고 로그인하지 않으면 볼 수 없는 페이지(예: 후원 중인 창작자의 게시물 상세 페이지)로 화면을 이동하세요.\n\n그 화면으로 이동한 후 다시 화면 하단의 '로그인할 수 없는 경우' 버튼을 눌러 이 대화 상자를 표시해주세요.\n\n이 상태에서 대화 상자 하단의 로그인 버튼을 눌러주세요. WebView에서 로그인 정보를 가져와 로그인을 시도합니다."</string>
<string name="welcome_permission_title">권한 설정</string>
<string name="welcome_permission_message">이 앱을 이용하려면 다음 권한이 필요합니다.\n아래의 버튼을 눌러 권한을 허용해주세요</string>
<string name="welcome_permission_ready_title">준비 완료</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<string name="error_service_status">服务可用性</string>
<string name="error_ad_load_failed">广告加载失败</string>
<string name="error_ad_load_failed_description">我们展示广告来维护我们服务的质量。</string>
<string name="error_no_available_this_device">此设备无法使用该功能</string>

<!-- Common Unit -->
<string name="unit_day_before">%1$d天前</string>
Expand Down Expand Up @@ -355,8 +356,10 @@
<string name="welcome_login_dialog_message">由于安全问题,不支持使用Google或X(Twitter)的OAuth进行身份验证。\n\n请直接输入您的电子邮件地址和密码登录。</string>
<string name="welcome_login_debug_dialog_title">注意</string>
<string name="welcome_login_debug_dialog_message">是否要执行调试登录?\n\n调试帐户是模拟常规用户行为的预先设置的帐户。为了保留暂存环境,某些操作可能无法执行或可能会发生错误。</string>
<string name="welcome_login_other_title">如果无法登录</string>
<string name="welcome_login_other_message">此应用需要名为FANBOXSESSID的会话ID才能运行。请按照下面链接中的步骤获取并输入您的FANBOXSESSID。</string>
<string name="welcome_login_other_title">直接输入 FANBOXSESSID</string>
<string name="welcome_login_other_message">此应用需要一个名为 FANBOXSESSID 的会话 ID 才能运行。请按照以下链接中的步骤获取 FANBOXSESSID 并输入。</string>
<string name="welcome_login_web_help">无法登录时</string>
<string name="welcome_login_web_help_description">如果输入邮箱和密码后,虽然屏幕显示已登录,但界面没有自动切换,请尝试以下步骤:\n\n先关闭此对话框,并在屏幕上导航到需要登录才能查看的页面(例如:支持的创作者的帖子详细页面)。\n\n导航到该页面后,再次点击屏幕底部的“无法登录时”按钮,显示此对话框。\n\n在此状态下,点击对话框底部的登录按钮。应用将尝试从 WebView 获取登录信息并进行登录。”</string>
<string name="welcome_permission_title">权限</string>
<string name="welcome_permission_message">使用应用程序需要以下权限。\n单击下面的按钮以授予权限。</string>
<string name="welcome_permission_ready_title">准备就绪</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<string name="error_service_status">Service operation status</string>
<string name="error_ad_load_failed">Failed to load ads.</string>
<string name="error_ad_load_failed_description">We display advertisements to maintain the quality of our service.</string>
<string name="error_no_available_this_device">This feature is not available on this device</string>

<!-- Common Unit -->
<string name="unit_day_before">%1$d days ago</string>
Expand Down Expand Up @@ -355,8 +356,10 @@
<string name="welcome_login_dialog_message">Authentication using Google or X (Twitter)'s OAuth is not supported due to security concerns. \n\nPlease log in by directly entering your email address and password.</string>
<string name="welcome_login_debug_dialog_title">Caution</string>
<string name="welcome_login_debug_dialog_message">Do you want to perform a debug login?\n\nDebug accounts are pre-provisioned accounts that mimic the behavior of regular users. In order to preserve the staging environment, some operations may not be possible or errors may occur.</string>
<string name="welcome_login_other_title">When can't log in</string>
<string name="welcome_login_other_message">A session ID called FANBOXSESSID is required for this app to work. Please follow the steps in the link below to obtain and enter your FANBOXSESSID.</string>
<string name="welcome_login_other_title">Direct Input of FANBOXSESSID</string>
<string name="welcome_login_other_message">This app requires a session ID called FANBOXSESSID to function. Please follow the instructions in the link below to obtain FANBOXSESSID and input it.</string>
<string name="welcome_login_web_help">If You Cannot Log In</string>
<string name="welcome_login_web_help_description">If you enter your email and password, and although it seems like you are logged in on the screen, the screen does not automatically transition, please try the following:\n\nClose this dialog once and navigate to a page that requires login to view content (e.g., the post details of a creator you are supporting).\n\nOnce you have navigated to such a page, press the 'If You Cannot Log In' button at the bottom of the screen again to display this dialog.\n\nIn this state, tap the login button at the bottom of the dialog. The app will attempt to retrieve login information from WebView and log you in."</string>
<string name="welcome_permission_title">Permissions</string>
<string name="welcome_permission_message">The following permissions are required to use the app\nClick the button below to grant permission</string>
<string name="welcome_permission_ready_title">Ready</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SettingTopViewModel(
SettingTopUiState(
userData = userData,
metaData = suspendRunCatching { fanboxRepository.getMetadata() }.getOrElse { getFanboxMetadataDummy() },
fanboxSessionId = sessionId ?: "unknown",
fanboxSessionId = sessionId ?: "Unknown",
config = pixiViewConfig,
),
)
Expand Down
Loading

0 comments on commit edcd95f

Please sign in to comment.