Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
14
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
e73d1ac3
Commit
e73d1ac3
authored
8 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Permission dialog and check for drawing overlays
parent
5d7cd375
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vlc-android/res/values/strings.xml
+2
-0
2 additions, 0 deletions
vlc-android/res/values/strings.xml
vlc-android/src/org/videolan/vlc/util/Permissions.java
+20
-1
20 additions, 1 deletion
vlc-android/src/org/videolan/vlc/util/Permissions.java
with
22 additions
and
1 deletion
vlc-android/res/values/strings.xml
+
2
−
0
View file @
e73d1ac3
...
...
@@ -404,6 +404,8 @@
<string
name=
"allow_settings_access_ringtone_description"
>
VLC needs you to grant this permission to set up this song as your ringtone.
</string>
<string
name=
"allow_settings_access_brightness_title"
>
Allow VLC to change brightness mode
</string>
<string
name=
"allow_settings_access_brightness_description"
>
VLC needs you to grant this permission to change your brightness mode.
</string>
<string
name=
"allow_draw_overlays_title"
>
Allow VLC player popup over other apps
</string>
<string
name=
"allow_sdraw_overlays_description"
>
VLC needs you to grant this permission display your video in a popup over other applications.
</string>
<string
name=
"permission_ask_again"
>
Grant permission
</string>
<string
name=
"exit_app"
>
Close VLC
</string>
<string
name=
"hardware_acceleration_error"
>
hardware acceleration error, switching to software decoding
</string>
...
...
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/util/Permissions.java
+
20
−
1
View file @
e73d1ac3
...
...
@@ -53,11 +53,17 @@ public class Permissions {
public
static
final
int
PERMISSION_SYSTEM_RINGTONE
=
42
;
public
static
final
int
PERMISSION_SYSTEM_BRIGHTNESS
=
43
;
public
static
final
int
PERMISSION_SYSTEM_DRAW_OVRLAYS
=
44
;
/*
* Marshmallow permission system management
*/
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
public
static
boolean
canDrawOverlays
(
Context
context
)
{
return
!
AndroidUtil
.
isMarshMallowOrLater
()
||
Settings
.
canDrawOverlays
(
context
);
}
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
public
static
boolean
canWriteSettings
(
Context
context
)
{
return
!
AndroidUtil
.
isMarshMallowOrLater
()
||
Settings
.
System
.
canWrite
(
context
);
...
...
@@ -82,6 +88,12 @@ public class Permissions {
}
}
public
static
void
checkDrawOverlaysPermission
(
Activity
activity
)
{
if
(
AndroidUtil
.
isMarshMallowOrLater
()
&&
!
canDrawOverlays
(
activity
))
{
showSettingsPermissionDialog
(
activity
,
PERMISSION_SYSTEM_DRAW_OVRLAYS
);
}
}
public
static
void
checkWriteSettingsPermission
(
Activity
activity
,
int
mode
)
{
if
(
AndroidUtil
.
isMarshMallowOrLater
()
&&
!
canWriteSettings
(
activity
))
{
showSettingsPermissionDialog
(
activity
,
mode
);
...
...
@@ -183,6 +195,7 @@ public class Permissions {
private
static
Dialog
createSettingsDialogCompat
(
final
Activity
activity
,
int
mode
)
{
int
titleId
=
0
,
textId
=
0
;
String
action
=
Settings
.
ACTION_MANAGE_WRITE_SETTINGS
;
switch
(
mode
)
{
case
PERMISSION_SYSTEM_RINGTONE:
titleId
=
R
.
string
.
allow_settings_access_ringtone_title
;
...
...
@@ -192,7 +205,13 @@ public class Permissions {
titleId
=
R
.
string
.
allow_settings_access_brightness_title
;
textId
=
R
.
string
.
allow_settings_access_brightness_description
;
break
;
case
PERMISSION_SYSTEM_DRAW_OVRLAYS:
titleId
=
R
.
string
.
allow_draw_overlays_title
;
textId
=
R
.
string
.
allow_sdraw_overlays_description
;
action
=
Settings
.
ACTION_MANAGE_OVERLAY_PERMISSION
;
break
;
}
final
String
finalAction
=
action
;
AlertDialog
.
Builder
dialogBuilder
=
new
AlertDialog
.
Builder
(
activity
)
.
setTitle
(
activity
.
getString
(
titleId
))
.
setMessage
(
activity
.
getString
(
textId
))
...
...
@@ -201,7 +220,7 @@ public class Permissions {
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
whichButton
)
{
SharedPreferences
settings
=
PreferenceManager
.
getDefaultSharedPreferences
(
activity
);
Intent
i
=
new
Intent
(
Settings
.
ACTION_MANAGE_WRITE_SETTINGS
);
Intent
i
=
new
Intent
(
finalAction
);
i
.
setData
(
Uri
.
parse
(
"package:"
+
activity
.
getPackageName
()));
try
{
activity
.
startActivity
(
i
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment