-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v4.2.0' into 'master'
Release v4.2.0 See merge request mobile/android/android!1877
- Loading branch information
Showing
152 changed files
with
3,231 additions
and
3,720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/src/main/java/mega/privacy/android/app/activities/AskForDisplayOverActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package mega.privacy.android.app.activities | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.graphics.Color | ||
import android.net.Uri | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.provider.Settings | ||
import android.view.View | ||
import android.widget.Toast | ||
import androidx.annotation.RequiresApi | ||
import mega.privacy.android.app.DatabaseHandler | ||
import mega.privacy.android.app.R | ||
|
||
/** | ||
* A dialog style activity can lead to system setting page. | ||
* Launched by notification even when the app is killed. | ||
* | ||
* @see mega.privacy.android.app.utils.IncomingCallNotification.toSystemSettingNotification | ||
*/ | ||
@RequiresApi(Build.VERSION_CODES.M) | ||
class AskForDisplayOverActivity : Activity(), View.OnClickListener { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
window.statusBarColor = Color.TRANSPARENT | ||
setContentView(R.layout.ask_for_display_over_activity_layout) | ||
} | ||
|
||
/** | ||
* Close the activity. | ||
*/ | ||
fun notNow() { | ||
// This will keep showing after the activity is destroyed, so can't use snack bar. | ||
Toast.makeText(this, R.string.ask_for_display_over_explain, Toast.LENGTH_LONG).show() | ||
finish() | ||
} | ||
|
||
/** | ||
* Launch system setting page by implicit intent. | ||
*/ | ||
fun toSetting() { | ||
val intent = Intent( | ||
Settings.ACTION_MANAGE_OVERLAY_PERMISSION, | ||
Uri.parse("package:$packageName") | ||
) | ||
|
||
startActivity(intent) | ||
|
||
finish() | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
DatabaseHandler.getDbHandler(this).dontAskForDisplayOver() | ||
} | ||
|
||
override fun onClick(v: View) { | ||
when (v.id) { | ||
R.id.btn_not_now -> notNow() | ||
R.id.btn_allow -> toSetting() | ||
} | ||
} | ||
} |
Oops, something went wrong.