Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  MultiThisDeviceCell.swift   Sprache: JAVA

 

import CocoaLumberjackSwift
import Foundation
import SwiftUI
import ThreemaFramework
import ThreemaMacros

final class MultiThisDeviceCell: MultiDeviceCell {

    // MARK: - Public property
    
    weak var parentViewController: MultiDeviceViewController?
    
    var enabled = false {
        didSet {
            enabledSwitch.isOn = enabled
            enabledSwitch.isEnabled = true
        }
    }
    
    // MARK: - Private properties
    
    // MARK: Subviews
    
    lazy var enabledSwitch: UISwitch = {
        let uiSwitch = UISwitch()
        
        uiSwitch.addTarget(self, action: #selector(self.enabledSwitchValueChanged), for: .valueChanged)
        
        return uiSwitch
    }()
    
    @objc private func enabledSwitchValueChanged(_ sender: UISwitch) {
        if sender.isOn {
            if let duplicates = BusinessInjector.ui.entityManager.entityFetcher.duplicateContactIdentities() {
                let duplicateIdentitiesDesc = duplicates.joined(separator: ", ")
                UIAlertTemplate.showOKAlert(
                    owner: parentViewController!,
                    title: #localize("multi_device_linked_duplicate_contacts_title"),
                    message: String(
                        format: #localize("multi_device_linked_duplicate_contacts_desc"),
                        duplicateIdentitiesDesc
                    )
                )
                
                enabledSwitch.isOn = false
                return
            }

            MultiDeviceWizardManager.shared.showWizard(on: (parentViewController?.navigationController)!)
        }
        else {
            UIAlertTemplate.showAlert(
                owner: parentViewController!,
                title: #localize("multi_device_linked_devices_removed_devices_title"),
                message: #localize("multi_device_linked_devices_removed_devices_message"),
                titleOk: #localize("multi_device_linked_devices_removed_devices_ok")
            ) { _ in
                self.parentViewController?.activityIndicator.hidesWhenStopped = true
                self.parentViewController?.activityIndicator.startAnimating()
                
                let dl = DeviceLinking(businessInjector: BusinessInjector.ui)
                dl.disableMultiDevice()
                    .ensure {
                        self.parentViewController?.load()
                        self.parentViewController?.activityIndicator.stopAnimating()
                    }
                    .catch { error in
                        self.enabledSwitch.isOn = true

                        DDLogError("Disable Multi Device failed: \(error)")
                        self.parentViewController?.showAlertRemoveDeviceFailed()
                    }

            } actionCancel: { _ in
                self.enabledSwitch.isOn = true
            }
        }
    }
    
    // MARK: - Lifecycle
    
    override func configureCell() {
        super.configureCell()
        
        // add switch to cell
        accessoryView = enabledSwitch

        if BusinessInjector.ui.userSettings.allowSeveralLinkedDevices {
            let tapGestureRecognizer = UITapGestureRecognizer(
                target: self,
                action: #selector(platformIconTapped(tapGestureRecognizer:))
            )
            platformIcon.addGestureRecognizer(tapGestureRecognizer)
            platformIcon.isUserInteractionEnabled = true
        }
    }

    @objc
    private func platformIconTapped(tapGestureRecognizer: UITapGestureRecognizer) {
        let deviceGroupKeyManager = DeviceGroupKeyManager()
        if deviceGroupKeyManager.dgk != nil {
            MultiDeviceWizardManager.shared.showWizard(
                on: (parentViewController?.navigationController)!,
                additionalLinking: true
            )
        }
    }
}

Messung
CHZG
849710093

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1104842
#Domains=499168