Skip to content

Commit 2a1ae5e

Browse files
authored
Update README.md
1 parent 38e21a8 commit 2a1ae5e

1 file changed

Lines changed: 23 additions & 21 deletions

File tree

README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[![](https://jitpack.io/v/BaselHorany/ProgressStatusBar.svg)](https://jitpack.io/#BaselHorany/ProgressStatusBar)
22

33

4+
## 1.1.5 workaround to supports Oreo
5+
46
# ProgressStatusBar
57
Another way to show progress. A progress View over the system StatusBar.
68
in addition to showing a toast message.
@@ -17,16 +19,6 @@ The first form is suitable for showing that the activity is being loaded like fe
1719
<img src="https://github.com/BaselHorany/ProgressStatusBar/blob/master/showtoast.png?raw=true" width="360" />
1820
</p>
1921

20-
## Important Note
21-
Due to Android O changes, this will not work on API 27 and above so you have to check:
22-
23-
```java
24-
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
25-
// use this library
26-
} else {
27-
// another progress way
28-
}
29-
```
3022

3123
## Setup
3224
1- Add jitpack.io repositories to you project `build.gradle`
@@ -45,7 +37,10 @@ dependencies {
4537
```
4638
3- Add `SYSTEM_ALERT_WINDOW` permission
4739
```xml
40+
<!--for all android versions-->
4841
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
42+
<!--in addition to this for oreo and above-->
43+
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
4944
```
5045

5146
## Usage
@@ -54,6 +49,18 @@ dependencies {
5449
```java
5550
public class MainActivity extends AppCompatActivity {
5651

52+
//overlay permission only if above Oreo
53+
@SuppressLint("NewApi")
54+
public void checkDrawOverlayPermission() {
55+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
56+
if (!Settings.canDrawOverlays(MainActivity.this)) {
57+
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
58+
Uri.parse("package:" + getPackageName()));
59+
startActivityForResult(intent, 11);
60+
}
61+
}
62+
}
63+
5764
ProgressStatusBar mProgressStatusBar;
5865

5966
@Override
@@ -96,6 +103,12 @@ public class MainActivity extends AppCompatActivity {
96103

97104
}
98105

106+
@Override
107+
protected void onResume() {
108+
super.onResume();
109+
//!important;
110+
checkDrawOverlayPermission();
111+
}
99112

100113
@Override
101114
protected void onPause() {
@@ -106,17 +119,6 @@ public class MainActivity extends AppCompatActivity {
106119
}
107120
```
108121

109-
## Important Note
110-
Due to Android O changes, this will not work on API 27 and above so you have to check:
111-
112-
```java
113-
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
114-
// use this library
115-
} else {
116-
// another progress way
117-
}
118-
```
119-
120122

121123
## Author
122124
Basel Horany

0 commit comments

Comments
 (0)