-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
280 additions
and
389 deletions.
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
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 @@ | ||
/build |
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,10 @@ | ||
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed | ||
plugins { | ||
hmh("feature") | ||
} | ||
|
||
android { | ||
namespace = "com.hmh.hamyeonham.onboarding" | ||
} | ||
|
||
dependencies {} |
Empty file.
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
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
106 changes: 25 additions & 81 deletions
106
feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/OnBoardingActivity.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 |
---|---|---|
@@ -1,113 +1,57 @@ | ||
package com.hmh.hamyeonham.feature.onboarding | ||
|
||
import android.app.usage.UsageStatsManager | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.provider.Settings | ||
import androidx.activity.result.ActivityResultLauncher | ||
import androidx.activity.result.contract.ActivityResultContracts | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.hmh.hamyeonham.common.context.toast | ||
import com.hmh.hamyeonham.common.navigation.NavigationProvider | ||
import com.hmh.hamyeonham.common.view.viewBinding | ||
import com.hmh.hamyeonham.feature.onboarding.databinding.ActivityOnBoardingBinding | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import javax.inject.Inject | ||
|
||
@AndroidEntryPoint | ||
class OnBoardingActivity : AppCompatActivity() { | ||
|
||
private val binding by viewBinding(ActivityOnBoardingBinding::inflate) | ||
|
||
@Inject | ||
lateinit var navigationProvider: NavigationProvider | ||
|
||
private val accessibilitySettingsLauncher: ActivityResultLauncher<Intent> = | ||
registerForActivityResult( | ||
ActivityResultContracts.StartActivityForResult(), | ||
) { | ||
if (isAccessibilityServiceEnabled()) { | ||
toast("접근성 서비스가 활성화되었습니다.") | ||
} else { | ||
toast("접근성 서비스가 활성화되지 않았습니다.") | ||
} | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(binding.root) | ||
clickRequireAccessibilityBtn() | ||
initViewPager() | ||
} | ||
|
||
private fun clickRequireAccessibilityBtn() { | ||
binding.btnAccessibility.setOnClickListener { | ||
openAccessibilitySettingsIfNeeded() | ||
} | ||
binding.btnUsage.setOnClickListener { | ||
requestUsageAccessPermission() | ||
} | ||
binding.btnDrawOnOthers.setOnClickListener { | ||
if (!hasOverlayPermission()) { | ||
requestOverlayPermission() | ||
} else { | ||
toast("다른 앱 위에 그리기 권한이 이미 허용되어 있습니다.") | ||
} | ||
private fun initViewPager() { | ||
val pagerAdapter = setOnboardingPageAdapter() | ||
binding.btnOnboardingNext.setOnClickListener { | ||
navigateToNextOnboardingStep(pagerAdapter) | ||
} | ||
} | ||
|
||
private fun requestUsageAccessPermission() { | ||
if (!hasUsageStatsPermission()) { | ||
try { | ||
val packageUri = Uri.parse("package:$packageName") | ||
val intent = Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS, packageUri) | ||
startActivity(intent) | ||
} catch (e: Exception) { | ||
val intent = Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS) | ||
startActivity(intent) | ||
private fun navigateToNextOnboardingStep(pagerAdapter: OnBoardingFragmentStateAdapter) { | ||
binding.vpOnboardingContainer.let { viewPager -> | ||
val currentItem = viewPager.currentItem | ||
val lastItem = pagerAdapter.itemCount - 1 | ||
when { | ||
currentItem < lastItem -> viewPager.currentItem = currentItem + 1 | ||
currentItem == lastItem -> startOnBoardingDoneSignUpActivity() | ||
} | ||
} else { | ||
toast("사용 정보 접근 권한이 이미 허용되어 있습니다.") | ||
} | ||
} | ||
|
||
private fun requestOverlayPermission() { | ||
val packageUri = Uri.parse("package:$packageName") | ||
val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, packageUri) | ||
private fun startOnBoardingDoneSignUpActivity() { | ||
val intent = Intent(this, OnBoardingDoneSingUpActivity::class.java).apply { | ||
addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) | ||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) | ||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
} | ||
startActivity(intent) | ||
finish() | ||
} | ||
|
||
private fun hasOverlayPermission(): Boolean { | ||
return Settings.canDrawOverlays(this) | ||
} | ||
|
||
private fun isAccessibilityServiceEnabled(): Boolean { | ||
val service = packageName + "/" + OnBoardingAccessibilityService::class.java.canonicalName | ||
val enabledServicesSetting = Settings.Secure.getString( | ||
contentResolver, | ||
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, | ||
) | ||
return enabledServicesSetting?.contains(service) == true | ||
} | ||
|
||
private fun openAccessibilitySettingsIfNeeded() { | ||
if (!isAccessibilityServiceEnabled()) { | ||
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS) | ||
accessibilitySettingsLauncher.launch(intent) | ||
} else { | ||
toast("접근성 권한이 이미 허용되어 있습니다.") | ||
private fun setOnboardingPageAdapter(): OnBoardingFragmentStateAdapter { | ||
val pagerAdapter = OnBoardingFragmentStateAdapter(this) | ||
binding.vpOnboardingContainer.run { | ||
adapter = pagerAdapter | ||
isUserInputEnabled = false | ||
} | ||
} | ||
|
||
private fun hasUsageStatsPermission(): Boolean { | ||
val usageStatsManager = getSystemService(Context.USAGE_STATS_SERVICE) as UsageStatsManager | ||
val time = System.currentTimeMillis() | ||
val stats = usageStatsManager.queryUsageStats( | ||
UsageStatsManager.INTERVAL_DAILY, | ||
time - 1000 * 60, | ||
time, | ||
) | ||
return stats != null && stats.isNotEmpty() | ||
return pagerAdapter | ||
} | ||
} |
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
31 changes: 0 additions & 31 deletions
31
.../onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/OnBoardingQuestionList.kt
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
...rding/src/main/java/com/hmh/hamyeonham/feature/onboarding/OnBoardingSelectDataActivity.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.