File tree Expand file tree Collapse file tree
java/me/nya_n/notificationnotifier/views/activities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ dependencies {
4444 implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version "
4545 implementation ' androidx.core:core-ktx:1.1.0'
4646 implementation ' androidx.appcompat:appcompat:1.1.0'
47- implementation ' com.google.android.material:material:1.0 .0'
47+ implementation ' com.google.android.material:material:1.3 .0'
4848 implementation ' androidx.constraintlayout:constraintlayout:1.1.3'
4949 implementation ' androidx.navigation:navigation-fragment-ktx:2.1.0'
5050 implementation ' androidx.navigation:navigation-ui-ktx:2.1.0'
Original file line number Diff line number Diff line change 11package me.nya_n.notificationnotifier.views.activities
22
3+ import android.content.Intent
34import android.os.Bundle
5+ import android.provider.Settings
6+ import androidx.appcompat.app.AlertDialog
47import androidx.appcompat.app.AppCompatActivity
8+ import androidx.core.app.NotificationManagerCompat
59import me.nya_n.notificationnotifier.R
610
711class MainActivity : AppCompatActivity () {
@@ -10,5 +14,21 @@ class MainActivity : AppCompatActivity() {
1014 super .onCreate(savedInstanceState)
1115 setContentView(R .layout.activity_main)
1216 setSupportActionBar(findViewById(R .id.toolbar))
17+ permissionCheck()
18+ }
19+
20+ private fun permissionCheck () {
21+ if (NotificationManagerCompat .getEnabledListenerPackages(this )
22+ .contains(packageName)) {
23+ return
24+ }
25+ AlertDialog .Builder (this )
26+ .setMessage(R .string.require_permission)
27+ .setPositiveButton(R .string.next) { _, _ ->
28+ Intent (Settings .ACTION_NOTIFICATION_LISTENER_SETTINGS ).apply {
29+ startActivity(this )
30+ }
31+ }
32+ .show()
1333 }
1434}
Original file line number Diff line number Diff line change 1616 android : id =" @+id/toolbar"
1717 android : layout_width =" match_parent"
1818 android : layout_height =" ?attr/actionBarSize"
19- android : background =" ?attr/colorPrimary"
20- app : popupTheme =" @style/AppTheme.PopupOverlay" />
19+ android : background =" ?attr/colorPrimary" />
2120
2221 </com .google.android.material.appbar.AppBarLayout>
2322
Original file line number Diff line number Diff line change 1313 <string name =" notify_test" >通知テスト</string >
1414 <string name =" loading" >読み込み中</string >
1515 <string name =" search_by_app_name" >アプリ名で検索</string >
16+ <string name =" next" >[次へ]</string >
17+ <string name =" require_permission" >次の画面で「通知へのアクセス」を許可してください。</string >
1618</resources >
Original file line number Diff line number Diff line change 1414
1515 <style name =" AppTheme.AppBarOverlay" parent =" ThemeOverlay.AppCompat.Dark.ActionBar" />
1616
17- <style name =" AppTheme.PopupOverlay" parent =" ThemeOverlay.AppCompat.Light" />
18-
1917</resources >
You can’t perform that action at this time.
0 commit comments