Integrate DKMA info
Этот коммит содержится в:
@@ -45,6 +45,7 @@ import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.preference.TwoStatePreference
|
||||
import dev.doubledot.doki.ui.DokiActivity
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
@@ -92,7 +93,13 @@ class MainFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListene
|
||||
alarmManager = requireActivity().getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
val originalIntent = Intent(activity, AutostartReceiver::class.java)
|
||||
originalIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
|
||||
alarmIntent = PendingIntent.getBroadcast(activity, 0, originalIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.FLAG_MUTABLE
|
||||
} else {
|
||||
0
|
||||
}
|
||||
alarmIntent = PendingIntent.getBroadcast(activity, 0, originalIntent, flags)
|
||||
|
||||
if (sharedPreferences.getBoolean(KEY_STATUS, false)) {
|
||||
startTrackingService(checkPermission = true, initialPermission = false)
|
||||
@@ -190,6 +197,9 @@ class MainFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListene
|
||||
if (item.itemId == R.id.status) {
|
||||
startActivity(Intent(activity, StatusActivity::class.java))
|
||||
return true
|
||||
} else if (item.itemId == R.id.info) {
|
||||
DokiActivity.start(requireContext())
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
@@ -122,7 +122,12 @@ class TrackingService : Service() {
|
||||
} else {
|
||||
intent = Intent(Settings.ACTION_SETTINGS)
|
||||
}
|
||||
builder.setContentIntent(PendingIntent.getActivity(context, 0, intent, 0))
|
||||
val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
} else {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
}
|
||||
builder.setContentIntent(PendingIntent.getActivity(context, 0, intent, flags))
|
||||
return builder.build()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,9 @@
|
||||
android:title="@string/menu_status"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/info"
|
||||
android:title="@string/menu_info"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<string name="settings_foreground_title">Foreground service</string>
|
||||
<string name="settings_foreground_summary">Increase service priority</string>
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_info">Info</string>
|
||||
<string name="menu_shortcuts">Add shortcuts</string>
|
||||
<string name="menu_clear">Clear</string>
|
||||
<string name="status_service_create">Service started</string>
|
||||
|
||||
Ссылка в новой задаче
Block a user