Skip to content

Commit

Permalink
fix: update prominent disclosures (#934)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariobehling authored May 23, 2024
2 parents a369194 + 9de7d23 commit 93891ba
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.app.Activity
import android.app.AlertDialog
import android.widget.Toast
import androidx.core.content.ContextCompat
import org.fossasia.badgemagic.R

class BadgeMagicPermission private constructor() {

Expand Down Expand Up @@ -69,32 +70,32 @@ class BadgeMagicPermission private constructor() {
if (listPermissionsNeeded.size > 0) {
for (permission in listPermissionsNeeded) {
if (permission == Manifest.permission.ACCESS_FINE_LOCATION) {
val builder = AlertDialog.Builder(activity)
builder.setTitle("Location Permission Disclosure")
builder.setMessage("Badge Magic collects location data to enable the transfer of data to LED Badges via Bluetooth LE in the background.")
builder.setCancelable(false)
builder.setPositiveButton("ACCEPT") { _, _ ->
activity.requestPermissions(locationPermissions, REQUEST_PERMISSION_CODE)
}
builder.setNegativeButton("DENY") { _, _ ->
Toast.makeText(activity, "Please grant the permission", Toast.LENGTH_SHORT).show()
activity.requestPermissions(locationPermissions, REQUEST_PERMISSION_CODE)
}
builder.show()
AlertDialog.Builder(activity)
.setIcon(ContextCompat.getDrawable(activity, R.drawable.ic_caution))
.setTitle(activity.getString(R.string.location_required_title))
.setMessage(activity.getString(R.string.location_required_message))
.setPositiveButton("OK") { _, _ ->
activity.requestPermissions(locationPermissions, REQUEST_PERMISSION_CODE)
}
.setNegativeButton("Cancel") { _, _ ->
Toast.makeText(activity, activity.getString(R.string.location_canceled_warning), Toast.LENGTH_SHORT).show()
}
.create()
.show()
} else if (permission == Manifest.permission.WRITE_EXTERNAL_STORAGE) {
val builder = AlertDialog.Builder(activity)
builder.setTitle("Storage Permission Disclosure")
builder.setMessage("Badge Magic requires access to storage to enable the storage and import of data.")
builder.setCancelable(false)
builder.setPositiveButton("ACCEPT") { _, _ ->
activity.requestPermissions(storagePermissions, REQUEST_PERMISSION_CODE)
}
builder.setNegativeButton("DENY") { _, _ ->
Toast.makeText(activity, "Please grant the permission", Toast.LENGTH_SHORT).show()
activity.requestPermissions(storagePermissions, REQUEST_PERMISSION_CODE)
}
builder.show()
} else if (permission == Manifest.permission.BLUETOOTH || permission == Manifest.permission.BLUETOOTH_ADMIN || permission == Manifest.permission.BLUETOOTH_PRIVILEGED || permission == Manifest.permission.BLUETOOTH_CONNECT || permission == Manifest.permission.BLUETOOTH_SCAN) {
AlertDialog.Builder(activity)
.setIcon(ContextCompat.getDrawable(activity, R.drawable.ic_caution))
.setTitle(activity.getString(R.string.storage_required_title))
.setMessage(activity.getString(R.string.storage_required_message))
.setPositiveButton("OK") { _, _ ->
activity.requestPermissions(storagePermissions, REQUEST_PERMISSION_CODE)
}
.setNegativeButton("Cancel") { _, _ ->
Toast.makeText(activity, activity.getString(R.string.storage_canceled_warning), Toast.LENGTH_SHORT).show()
}
.create()
.show()
} else if (permission == Manifest.permission.BLUETOOTH_CONNECT || permission == Manifest.permission.BLUETOOTH_SCAN) {
activity.requestPermissions(bluetoothPermissions, REQUEST_PERMISSION_CODE)
}
}
Expand Down
14 changes: 11 additions & 3 deletions android/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.fossasia.badgemagic.ui

import android.Manifest
import android.app.Activity
import android.app.AlertDialog
import android.content.DialogInterface
Expand Down Expand Up @@ -56,8 +57,6 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val permission = BadgeMagicPermission.instance
permission.checkPermissions(this, permission.ALL_PERMISSION)

binding = ActivityDrawerBinding.inflate(layoutInflater)
setContentView(binding.root)
Expand Down Expand Up @@ -226,7 +225,7 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi
private fun prepareForScan() {
if (isBleSupported()) {
val permission = BadgeMagicPermission.instance
permission.checkPermissions(this, permission.BLUETOOTH_PERMISSION)
permission.checkPermissions(this, permission.LOCATION_PERMISSION)
} else {
Toast.makeText(this, "BLE is not supported", Toast.LENGTH_LONG).show()
finish()
Expand Down Expand Up @@ -295,6 +294,15 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Timber.d { "Required Permission Accepted" }
}
for (p in permissions) {
if (
p == Manifest.permission.ACCESS_FINE_LOCATION &&
grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED
) {
val permission = BadgeMagicPermission.instance
permission.checkPermissions(this, permission.BLUETOOTH_PERMISSION)
}
}
}
else -> super.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
Expand Down
13 changes: 13 additions & 0 deletions android/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@
<string name="drawer_saved_cliparts">保存的教具</string>
<string name="no_gps_enabled">找不到GPS,请从设置中启用GPS</string>

<string name="location_required_title">需要位置许可</string>
<string name="location_required_message">
此应用程序使用蓝牙 LE 服务,需要启用位置权限才能扫描附近的设备。\n\n
该应用程序不会以任何方式使用用户的任何个人和位置信息。\n\n
如果您未启用定位服务,此应用程序可能无法找到附近的任何 LED 徽章并且无法正常运行。
</string>
<string name="location_canceled_warning">请允许位置权限。 蓝牙 LE 需要这个才能工作。</string>


<string name="storage_required_title">需要存储权限</string>
<string name="storage_required_message">此应用程序需要访问存储空间才能保存和访问已保存的徽章/剪贴画。</string>
<string name="storage_canceled_warning">请允许存储权限来保存和访问已保存的徽章/剪贴画。</string>

<string name="share_msg">Badge Magic是一个用于控制LED名称徽章的Android应用。该应用程序提供了在LED徽章上描绘姓名,图形和简单动画的功能。 \n您也可以从下面的链接下载它 https://play.google.com/store/apps/details?id=org.fossasia.badgemagic</string>
<string name="share_using">分享使用</string>
<string name="badge_delete_warning">" 您确定要删除此徽章吗?"</string>
Expand Down
12 changes: 12 additions & 0 deletions android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@
<string name="clipart_saved_error">Error in saving Clipart</string>
<string name="drawer_saved_cliparts">Saved Cliparts</string>
<string name="no_gps_enabled">No GPS Found, Please Enable GPS from Settings</string>

<string name="location_required_title">Location Permission Required</string>
<string name="location_required_message">
This application use Bluetooth LE services which require background location to be enabled to scan and transfer data to nearby devices.\n\n
This application is not using any personal and location information of users in anyway.\n\n
If you are not enabling the location permission, this application might not find any nearby LED Badge and cannot function correctly.
</string>
<string name="location_canceled_warning">Please allow Location permissions. Bluetooth LE requires this to work.</string>

<string name="storage_required_title">Storage Permission Required</string>
<string name="storage_required_message">This application requires access to storage to save and access saved Badges/Cliparts.</string>
<string name="storage_canceled_warning">Please allow Storage permissions to save and access saved Badges/Cliparts.</string>

<string name="share_msg">Badge Magic is an Android app to control LED name badges. This app provides features to portray names, graphics and simple animations on LED badges. \nYou can also download it from below link \nhttps://play.google.com/store/apps/details?id=org.fossasia.badgemagic</string>
<string name="share_using">Share Using</string>
Expand Down

0 comments on commit 93891ba

Please sign in to comment.