Skip to content

Commit

Permalink
improve element size in dialogue
Browse files Browse the repository at this point in the history
  • Loading branch information
wuan committed Oct 8, 2023
1 parent 2101e59 commit 5970f6a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 33 deletions.
47 changes: 14 additions & 33 deletions app/src/main/java/org/blitzortung/android/app/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,7 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
Log.v(
LOG_TAG,
"Main.onRequestPermissionsResult() $requestCode - ${
permissions.joinToString(
",",
"[",
"]"
)
} - ${grantResults.joinToString(",", "[", "]") { it.toString() }}"
"Main.onRequestPermissionsResult() $requestCode - ${permissions.joinToString()} - ${grantResults.joinToString() { it.toString() }}"
)
val providerRelation = LocationProviderRelation.byOrdinal[requestCode]
if (providerRelation != null) {
Expand All @@ -580,12 +574,11 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
@TargetApi(Build.VERSION_CODES.M)
private fun requestLocationPermissions(sharedPreferences: SharedPreferences) {
val locationProviderName = sharedPreferences.get(PreferenceKey.LOCATION_MODE, PASSIVE_PROVIDER)
val permission =
when (locationProviderName) {
PASSIVE_PROVIDER, GPS_PROVIDER -> ACCESS_FINE_LOCATION
NETWORK_PROVIDER -> ACCESS_COARSE_LOCATION
else -> null
}
val permission = when (locationProviderName) {
PASSIVE_PROVIDER, GPS_PROVIDER -> ACCESS_FINE_LOCATION
NETWORK_PROVIDER -> ACCESS_COARSE_LOCATION
else -> null
}

if (permission != null) {
val requiresBackgroundPermission = if (isAtLeast(Build.VERSION_CODES.Q)) {
Expand All @@ -598,21 +591,15 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
Log.v(LOG_TAG, "self permission: $checkSelfPermission")
val requiresPermission = checkSelfPermission != PackageManager.PERMISSION_GRANTED

val requestCode = (LocationProviderRelation.byProviderName[locationProviderName]?.ordinal
?: Int.MAX_VALUE)
val requestCode = (LocationProviderRelation.byProviderName[locationProviderName]?.ordinal ?: Int.MAX_VALUE)
if (requiresPermission) {
val locationText = resources.getString(R.string.location_permission_background_disclosure)
AlertDialog.Builder(this)
.setMessage(locationText)
.setCancelable(false)
AlertDialog.Builder(this).setMessage(locationText).setCancelable(false)
.setNeutralButton(android.R.string.ok) { dialog, count ->
requestPermission(
arrayOf(permission),
requestCode,
R.string.location_permission_required
arrayOf(permission), requestCode, R.string.location_permission_required
)
}
.show()
}.show()
} else {
if (requiresBackgroundPermission) {
requestPermission(
Expand Down Expand Up @@ -693,11 +680,9 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
}
}

AlertDialog.Builder(this)
.setMessage(locationText)
AlertDialog.Builder(this).setMessage(locationText)
.setPositiveButton(android.R.string.yes, dialogClickListener)
.setNegativeButton(android.R.string.no, dialogClickListener)
.show()
.setNegativeButton(android.R.string.no, dialogClickListener).show()
}
} else {
Log.w(LOG_TAG, "requestWakeupPermissions() could not get PowerManager")
Expand Down Expand Up @@ -726,8 +711,7 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: PreferenceKey) {
@Suppress("NON_EXHAUSTIVE_WHEN")
when (key) {
@Suppress("NON_EXHAUSTIVE_WHEN") when (key) {
PreferenceKey.COLOR_SCHEME -> {
strikeListOverlay.refresh()
}
Expand Down Expand Up @@ -777,10 +761,7 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
private fun configureMenuAccess() {
val config = ViewConfiguration.get(this)

if (isAtLeast(Build.VERSION_CODES.LOLLIPOP) ||
isAtLeast(Build.VERSION_CODES.ICE_CREAM_SANDWICH) &&
!config.hasPermanentMenuKey()
) {
if (isAtLeast(Build.VERSION_CODES.LOLLIPOP) || isAtLeast(Build.VERSION_CODES.ICE_CREAM_SANDWICH) && !config.hasPermanentMenuKey()) {
binding.menu.visibility = View.VISIBLE
binding.menu.setOnClickListener {
showPopupMenu(binding.menu)
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/layout/quick_settings_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
android:layout_height="wrap_content"
android:entries="@array/regions"
android:padding="10dp"
android:minHeight="48dp"
android:prompt="@string/region" />

<View
Expand All @@ -40,6 +41,7 @@
android:layout_height="wrap_content"
android:entries="@array/raster_sizes"
android:padding="10dp"
android:minHeight="48dp"
android:prompt="@string/raster_size" />

<View
Expand All @@ -58,6 +60,7 @@
android:layout_height="wrap_content"
android:entries="@array/count_thresholds"
android:padding="10dp"
android:minHeight="48dp"
android:prompt="@string/count_threshold" />

<View
Expand All @@ -76,6 +79,7 @@
android:layout_height="wrap_content"
android:entries="@array/interval_durations"
android:padding="10dp"
android:minHeight="48dp"
android:prompt="@string/interval_duration" />

<View
Expand All @@ -94,6 +98,7 @@
android:layout_height="wrap_content"
android:entries="@array/query_periods"
android:padding="10dp"
android:minHeight="48dp"
android:prompt="@string/query_period" />
</LinearLayout>
</ScrollView>

0 comments on commit 5970f6a

Please sign in to comment.