Skip to content

Commit

Permalink
Revert "feat(#677): add native version of privacy screen (still not h…
Browse files Browse the repository at this point in the history
…appy with Android version)"

This reverts commit e409089.
  • Loading branch information
tamslo committed Dec 27, 2023
1 parent 80d72a7 commit 2c49c32
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 151 deletions.
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 app/android/app/src/main/kotlin/de/hpi/pharme/MainActivity.kt

This file was deleted.

56 changes: 0 additions & 56 deletions app/ios/Runner/AppDelegate.swift
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()
}
}
29 changes: 0 additions & 29 deletions app/lib/common/utilities/platform_channel_utils.dart

This file was deleted.

0 comments on commit 2c49c32

Please sign in to comment.