-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lucky
committed
Aug 20, 2022
1 parent
00888e5
commit 3a83bc2
Showing
21 changed files
with
216 additions
and
41 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 was deleted.
Oops, something went wrong.
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
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
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
46 changes: 46 additions & 0 deletions
46
app/src/main/java/me/lucky/sentry/panic/PanicConnectionActivity.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,46 @@ | ||
package me.lucky.sentry.panic | ||
|
||
import android.content.pm.PackageManager | ||
import android.os.Bundle | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
|
||
import info.guardianproject.panic.PanicResponder | ||
import me.lucky.sentry.MainActivity | ||
import me.lucky.sentry.R | ||
|
||
class PanicConnectionActivity : MainActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
if (PanicResponder.checkForDisconnectIntent(this)) { | ||
finish() | ||
return | ||
} | ||
val sender = PanicResponder.getConnectIntentSender(this) | ||
val packageName = PanicResponder.getTriggerPackageName(this) | ||
if (sender != "" && sender != packageName) showOptInDialog() else finish() | ||
} | ||
|
||
private fun showOptInDialog() { | ||
var app: CharSequence = getString(R.string.panic_app_unknown_app) | ||
val packageName = callingActivity?.packageName | ||
if (packageName != null) { | ||
try { | ||
app = packageManager | ||
.getApplicationLabel(packageManager.getApplicationInfo(packageName, 0)) | ||
} catch (exc: PackageManager.NameNotFoundException) {} | ||
} | ||
MaterialAlertDialogBuilder(this) | ||
.setTitle(R.string.panic_app_dialog_title) | ||
.setMessage(getString(R.string.panic_app_dialog_message, app)) | ||
.setNegativeButton(R.string.allow) { _, _ -> | ||
PanicResponder.setTriggerPackageName(this) | ||
setResult(RESULT_OK) | ||
finish() | ||
} | ||
.setPositiveButton(android.R.string.cancel) { _, _ -> | ||
setResult(RESULT_CANCELED) | ||
finish() | ||
} | ||
.show() | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/me/lucky/sentry/panic/PanicResponderActivity.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,21 @@ | ||
package me.lucky.sentry.panic | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
|
||
import info.guardianproject.panic.Panic | ||
import info.guardianproject.panic.PanicResponder | ||
import me.lucky.sentry.AppDatabase | ||
|
||
class PanicResponderActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
if (!Panic.isTriggerIntent(intent)) { | ||
finishAndRemoveTask() | ||
return | ||
} | ||
if (PanicResponder.receivedTriggerFromConnectedApp(this)) | ||
AppDatabase.getInstance(this).packageDao().deleteAll() | ||
finishAndRemoveTask() | ||
} | ||
} |
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
Oops, something went wrong.