forked from havesource/cordova-plugin-push
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to LTS plugin version, rewrite FullScreenActivity to kotlin, f…
…ixes for Android API 31 (#2) * feat: Add full screen notification, fix target API version 31:on 31: commit 72ee17b Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Tue Aug 16 14:58:03 2022 +0200 restore selecting flag for os version commit fe398f6 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Tue Aug 16 14:01:25 2022 +0200 Update flag check for API 31 commit cefe7c0 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Tue Aug 16 12:28:35 2022 +0200 fix flags commit 61c19fa Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Tue Aug 16 12:15:16 2022 +0200 fix pending intent flag commit 1aff7e7 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Tue Aug 16 08:32:02 2022 +0200 fix variable commit d85abfa Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Tue Aug 16 08:24:11 2022 +0200 fix typing commit 279242d Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Tue Aug 16 08:06:35 2022 +0200 fix compile issues commit 9a0e9c3 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Fri Aug 12 17:00:28 2022 +0200 fix parse int commit 3aafe54 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Fri Aug 12 16:24:37 2022 +0200 fix translation to kotlin commit 6650697 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Fri Aug 12 16:06:32 2022 +0200 fix fetch push constant commit f4da44c Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Fri Aug 12 15:36:58 2022 +0200 fix full screen activity path commit 16aa608 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Fri Aug 12 15:35:25 2022 +0200 fix fcmservice path commit 1119044 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Fri Aug 12 15:24:05 2022 +0200 fix source order commit a53c4b4 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Fri Aug 12 15:09:53 2022 +0200 chore: update to kotlin file version commit 7c643f2 Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Fri Aug 12 15:09:52 2022 +0200 Rename .java to .kt commit 6066326 Merge: a9939fa aa23f4b Author: p.mikolajczak@tkhtechnology.com <p.mikolajczak@tkhtechnology.com> Date: Fri Aug 12 14:29:06 2022 +0200 Merge branch 'MX002-5965' of https://github.com/mjcctech/cordova-plugin-push into MX002-6941 commit aa23f4b Author: mjaruzel <m.jaruzel@cctechnology.pl> Date: Fri Oct 1 11:58:15 2021 +0200 add missing import commit 0d2a82b Author: mjaruzel <m.jaruzel@cctechnology.pl> Date: Fri Oct 1 11:27:48 2021 +0200 fix whitespace commit 4bc2cb9 Author: mjaruzel <m.jaruzel@cctechnology.pl> Date: Fri Oct 1 11:13:53 2021 +0200 rollback whitespace changes commit 6cae4a1 Author: mjaruzel <m.jaruzel@cctechnology.pl> Date: Fri Oct 1 10:55:31 2021 +0200 rollback whitespace changes commit 6bc5655 Author: mjaruzel <m.jaruzel@cctechnology.pl> Date: Fri Oct 1 10:23:01 2021 +0200 Add full screen activity * remove unused variable, logging * fix typo
- Loading branch information
Showing
4 changed files
with
117 additions
and
14 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
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,85 @@ | ||
package com.adobe.phonegap.push | ||
|
||
import android.app.Activity | ||
import android.app.KeyguardManager | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.view.WindowManager | ||
|
||
class FullScreenActivity : Activity() { | ||
public override fun onCreate(savedInstanceState: Bundle?) { | ||
Log.d(LOG_TAG, "onCreate") | ||
super.onCreate(savedInstanceState) | ||
turnScreenOnAndKeyguardOff() | ||
forceMainActivityReload() | ||
finish() | ||
} | ||
|
||
private fun forceMainActivityReload() { | ||
val pm: PackageManager = getPackageManager() | ||
val launchIntent: Intent? = | ||
pm.getLaunchIntentForPackage(getApplicationContext().getPackageName()) | ||
launchIntent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) | ||
launchIntent?.addFlags(Intent.FLAG_FROM_BACKGROUND) | ||
startActivity(launchIntent) | ||
} | ||
|
||
protected override fun onDestroy() { | ||
super.onDestroy() | ||
Log.d(LOG_TAG, "onDestroy") | ||
turnScreenOffAndKeyguardOn() | ||
} | ||
|
||
private fun turnScreenOnAndKeyguardOff() { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { | ||
Log.d(LOG_TAG, "setShowWhenLocked") | ||
setShowWhenLocked(true) | ||
setTurnScreenOn(true) | ||
} else { | ||
Log.d(LOG_TAG, "addFlags") | ||
getWindow().addFlags( | ||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | ||
or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | ||
) | ||
} | ||
val keyguardManager: KeyguardManager? = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager? | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && keyguardManager != null) { | ||
keyguardManager?.requestDismissKeyguard(this, object : KeyguardManager.KeyguardDismissCallback() { | ||
override fun onDismissCancelled() { | ||
super.onDismissCancelled() | ||
Log.d(LOG_TAG, "canceled") | ||
} | ||
|
||
override fun onDismissError() { | ||
super.onDismissError() | ||
Log.d(LOG_TAG, "onDismissError") | ||
} | ||
|
||
override fun onDismissSucceeded() { | ||
super.onDismissSucceeded() | ||
Log.d(LOG_TAG, "onDismissSucceeded") | ||
} | ||
}) | ||
} | ||
} | ||
|
||
private fun turnScreenOffAndKeyguardOn() { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { | ||
setShowWhenLocked(false) | ||
setTurnScreenOn(false) | ||
} else { | ||
getWindow().clearFlags( | ||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | ||
or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | ||
) | ||
} | ||
} | ||
|
||
companion object { | ||
private const val LOG_TAG = "FullScreenActivity" | ||
} | ||
} |
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