-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat(#677): add native version of privacy screen (still not h…
…appy with Android version)" This reverts commit e409089.
- Loading branch information
Showing
4 changed files
with
6 additions
and
151 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
app/android/app/src/main/kotlin/de/hpi/frasecys/MainActivity.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,6 @@ | ||
package de.hpi.pharme | ||
|
||
import io.flutter.embedding.android.FlutterActivity | ||
|
||
class MainActivity: FlutterActivity() { | ||
} |
66 changes: 0 additions & 66 deletions
66
app/android/app/src/main/kotlin/de/hpi/pharme/MainActivity.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,13 @@ | ||
import UIKit | ||
import Flutter | ||
|
||
// Add privacy screen, based on | ||
// https://articles.wesionary.team/securing-your-flutter-app-implementing-a-privacy-screen-61383ce09f0a | ||
|
||
@UIApplicationMain | ||
@objc class AppDelegate: FlutterAppDelegate { | ||
private var flutterViewController: FlutterViewController! | ||
private var securityChannel: FlutterMethodChannel! | ||
private var blurEffectView: UIVisualEffectView? | ||
private var isInBackground: Bool = false // Track whether app is in background | ||
|
||
override func application( | ||
_ application: UIApplication, | ||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | ||
) -> Bool { | ||
GeneratedPluginRegistrant.register(with: self) | ||
|
||
setupFlutterCommunication() | ||
|
||
return super.application(application, didFinishLaunchingWithOptions: launchOptions) | ||
} | ||
|
||
private func setupFlutterCommunication() { | ||
flutterViewController = window?.rootViewController as? FlutterViewController | ||
securityChannel = FlutterMethodChannel( | ||
name: "security", | ||
binaryMessenger: flutterViewController.binaryMessenger | ||
) | ||
|
||
securityChannel.setMethodCallHandler(handle) | ||
} | ||
|
||
override func applicationWillResignActive(_ application: UIApplication) { | ||
isInBackground = true // App will be inactive | ||
enableAppSecurity() | ||
} | ||
|
||
override func applicationDidBecomeActive(_ application: UIApplication) { | ||
// Check if the app was in background before becoming active | ||
if isInBackground { | ||
disableAppSecurity() | ||
isInBackground = false | ||
} | ||
} | ||
|
||
private func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { | ||
switch call.method { | ||
case "enableAppSecurity": | ||
result(nil) | ||
case "disableAppSecurity": | ||
result(nil) | ||
default: | ||
result(FlutterMethodNotImplemented) | ||
} | ||
} | ||
|
||
private func enableAppSecurity() { | ||
let blurEffect = UIBlurEffect(style: .light) | ||
blurEffectView = UIVisualEffectView(effect: blurEffect) | ||
blurEffectView?.frame = window!.frame | ||
window?.addSubview(blurEffectView!) | ||
} | ||
|
||
private func disableAppSecurity() { | ||
blurEffectView?.removeFromSuperview() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.