kopia lustrzana https://github.com/ge0rg/aprsdroid
Permissions: rework failure dialog
rodzic
03e4a36d61
commit
4c6a8a1b3f
|
@ -73,4 +73,7 @@ class BackendPrefs extends PreferenceActivity
|
|||
override def onAllPermissionsGranted(action: Int): Unit = {
|
||||
findPreference("kenwood.gps").asInstanceOf[CheckBoxPreference].setChecked(true)
|
||||
}
|
||||
override def onPermissionsFailedCancel(action: Int): Unit = {
|
||||
// nop
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,4 +72,7 @@ class LocationPrefs extends PreferenceActivity with OnSharedPreferenceChangeList
|
|||
pe.commit()
|
||||
} else Toast.makeText(this, getString(R.string.map_track_unknown, prefs.getCallsign()), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
override def onPermissionsFailedCancel(action: Int): Unit = {
|
||||
// nop
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,14 +109,13 @@ class MapAct extends MapActivity with MapMenuHelper {
|
|||
}
|
||||
}
|
||||
|
||||
override def onPermissionsFailed(action: Int, permissions: Set[String]): Unit = {
|
||||
if (action == RELOAD_MAP) {
|
||||
if (targetcall == "")
|
||||
startActivity(new Intent(this, classOf[HubActivity]).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
|
||||
finish()
|
||||
}
|
||||
super.onPermissionsFailed(action, permissions)
|
||||
}
|
||||
override def onPermissionsFailed(action : Int, permissions : Set[String]): Unit = {
|
||||
// fail to online OSM map
|
||||
}
|
||||
|
||||
override def onPermissionsFailedCancel(action: Int): Unit = {
|
||||
// should never be called
|
||||
}
|
||||
|
||||
def reloadMapAndTheme() {
|
||||
val mapfile = new File(prefs.getString("mapfile", android.os.Environment.getExternalStorageDirectory() + "/aprsdroid.map"))
|
||||
|
|
|
@ -10,6 +10,9 @@ import android.provider.Settings
|
|||
trait PermissionHelper extends Activity {
|
||||
def getActionName(action : Int): Int
|
||||
def onAllPermissionsGranted(action : Int): Unit
|
||||
def onPermissionsFailedCancel(action : Int): Unit
|
||||
|
||||
var permissionsPopupShown = false
|
||||
|
||||
def checkPermissions(permissions : Array[String], action : Int): Boolean = {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
|
@ -55,6 +58,9 @@ trait PermissionHelper extends Activity {
|
|||
}
|
||||
}
|
||||
def onPermissionsFailed(action : Int, permissions : Set[String]): Unit = {
|
||||
if (permissionsPopupShown)
|
||||
return
|
||||
permissionsPopupShown = true
|
||||
val sb = new StringBuilder(getString(R.string.no_perm_text))
|
||||
sb.append("\n\n")
|
||||
for (p <- permissions) {
|
||||
|
@ -71,7 +77,11 @@ trait PermissionHelper extends Activity {
|
|||
startActivity(intent)
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener {
|
||||
override def onClick(dialogInterface: DialogInterface, i: Int): Unit = {
|
||||
onPermissionsFailedCancel(action)
|
||||
}
|
||||
})
|
||||
.create().show()
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,9 @@ trait UIHelper extends Activity
|
|||
case START_SERVICE_ONCE => startService(AprsService.intent(this, AprsService.SERVICE_ONCE))
|
||||
}
|
||||
}
|
||||
override def onPermissionsFailedCancel(action: Int): Unit = {
|
||||
// nop
|
||||
}
|
||||
def startAprsService(action : Int): Unit = {
|
||||
checkPermissions(currentListOfPermissions(), action)
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue