본문 바로가기
IT/안드로이드

jetpack compose Review URL Open

by DOSGamer 2023. 7. 13.
반응형

암호 입력을 요구하는 게임들 때문에

게임 플레이 중에 암호를 블로그에서 보게 하려면 앱 내부에서 Webview 로 띄우는 게 아니라 

휴대폰 별도 웹 브라우저로 띄워야 하기에 해당 기능을 제외 합니다.

 

 

기존 방식

기존의 WebView 를 이용해서 

Toggle 형태로 띄웠다가 닫았다가 했었음

//ReviewUrl 이 있으면 OPEN Review Button
if (game.reviewUrl != "") {
    Column(
        modifier = Modifier.fillMaxWidth(),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        FilledIconButton(
            onClick = { reviewToggle = !reviewToggle },
            modifier = Modifier
                .fillMaxWidth()
                .height(52.dp)
                .padding(0.dp),
            shape = RoundedCornerShape(4.dp),
            colors = IconButtonDefaults.filledIconButtonColors(
                containerColor = MaterialTheme.colorScheme.primary.copy(0.48f),
                contentColor = MaterialTheme.colorScheme.onSurface
            )
        ) {
            Row {
                Text(
                    text = if (reviewToggle) stringResource(id = R.string.all_review_close) else stringResource(
                        id = R.string.all_review_open
                    )
                )
                Icon(
                    imageVector = if (reviewToggle) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown,
                    "Down Arrow",
                )
            }
        }
        Spacer(modifier = Modifier.height(16.dp))
        AnimatedVisibility(
            visible = reviewToggle,
        ) {
            WebViewPage(game.reviewUrl, detailViewModel)
        }
    }
}

 

 

변경 방식

리뷰 오픈 버튼 누르면 크롬 브라우저로 잘 뜹니다.

    val reviewWebIntent = Intent(Intent.ACTION_VIEW, Uri.parse(game.reviewUrl))

    FilledIconButton(
        onClick = { context.startActivity(reviewWebIntent) },
        modifier = Modifier
            .fillMaxWidth()
            .height(52.dp)
            .padding(0.dp),
        shape = RoundedCornerShape(4.dp),
        colors = IconButtonDefaults.filledIconButtonColors(
            containerColor = MaterialTheme.colorScheme.primary.copy(0.48f),
            contentColor = MaterialTheme.colorScheme.onSurface
        )
    ) {
        Text( text = stringResource(id = R.string.all_review_open) )
    }

 

반응형