Commit 2209ed90 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

account setting: share name to contact

Change-Id: I4a396609d0ad387b16e0de837fc1d2629eb76e1a
parent db2ccb27
......@@ -52,6 +52,12 @@ internal enum L10n {
internal enum AccountPage {
/// Block List
internal static let blockedContacts = L10n.tr("Localizable", "accountPage.blockedContacts")
/// Contact me using "%s" on the Jami distributet communication platform: https://jami.net
internal static func contactMeOnJamiContant(_ p1: UnsafePointer<CChar>) -> String {
return L10n.tr("Localizable", "accountPage.contactMeOnJamiContant", p1)
}
/// Contact me on Jami!
internal static let contactMeOnJamiTitle = L10n.tr("Localizable", "accountPage.contactMeOnJamiTitle")
/// Account Details
internal static let credentialsHeader = L10n.tr("Localizable", "accountPage.credentialsHeader")
/// Device revocation error
......@@ -108,6 +114,8 @@ internal enum L10n {
internal static let saveProxyAddress = L10n.tr("Localizable", "accountPage.saveProxyAddress")
/// Settings
internal static let settingsHeader = L10n.tr("Localizable", "accountPage.settingsHeader")
/// Share Account Details
internal static let shareAccountDetails = L10n.tr("Localizable", "accountPage.shareAccountDetails")
/// UNBLOCK
internal static let unblockContact = L10n.tr("Localizable", "accountPage.unblockContact")
/// username:
......
......@@ -335,6 +335,21 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
cell.textLabel?.text = label
cell.selectionStyle = .none
return cell
case .shareAccountDetails:
let cell = DisposableCell()
cell.textLabel?.text = L10n.AccountPage.shareAccountDetails
cell.textLabel?.textColor = UIColor.jamiMain
cell.textLabel?.textAlignment = .center
cell.selectionStyle = .none
let button = UIButton.init(frame: cell.frame)
let size = CGSize(width: self.view.frame.width, height: button.frame.height)
button.frame.size = size
cell.addSubview(button)
button.rx.tap.subscribe(onNext: { [weak self] in
self?.shareAccountInfo()
}).disposed(by: cell.disposeBag)
return cell
case .notifications:
let cell = tableView.dequeueReusableCell(for: indexPath,
cellType: NotificationCell.self)
......@@ -645,6 +660,16 @@ extension MeViewController: UITableViewDelegate {
}
}
func shareAccountInfo() {
guard let content = self.viewModel.accountInfoToShare else {return}
let title = L10n.AccountPage.contactMeOnJamiTitle
let activityViewController = UIActivityViewController(activityItems: content,
applicationActivities: nil)
activityViewController.setValue(title, forKey: "Subject")
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)
}
private func scrollViewDidStopScrolling() {
var contentOffset = self.settingsTable.contentOffset
if self.stretchyHeader.frame.height <= self.stretchyHeader.minimumContentHeight {
......
......@@ -39,6 +39,7 @@ enum SettingsSection: SectionModelType {
case linkNew
case blockedList
case removeAccount
case shareAccountDetails
case sectionHeader(title: String)
case ordinary(label: String)
case notifications
......@@ -122,11 +123,44 @@ class MeViewModel: ViewModel, Stateable {
} else {
items.append(.ordinary(label: L10n.AccountPage.usernameNotRegistered))
}
items.append(.shareAccountDetails)
return SettingsSection
.credentials(items: items)
}
}()
var accountInfoToShare: [Any]? {
var info = [String]()
guard let account = self.accountService.currentAccount else {return nil}
var nameToContact = ""
if self.isAccountSip.value {
guard let accountDetails = account.details,
let credentials = account.credentialDetails.first else {return nil}
if AccountModelHelper.init(withAccount: account).isAccountRing() {
return nil
}
let username = credentials.username
let server = accountDetails.get(withConfigKeyModel: ConfigKeyModel.init(withKey: .accountHostname))
if username.isEmpty || server.isEmpty {
return nil
}
nameToContact = username + "@" + server
}
if !account.registeredName.isEmpty {
nameToContact = account.registeredName
} else if let userNameData = UserDefaults.standard.dictionary(forKey: registeredNamesKey),
let accountName = userNameData[account.id] as? String,
!accountName.isEmpty {
nameToContact = accountName
}
if nameToContact.isEmpty {
nameToContact = account.jamiId
}
let title = L10n.AccountPage.contactMeOnJamiContant(nameToContact)
info.append(title)
return info
}
lazy var linkNewDevice: Observable<SettingsSection> = {
return Observable.just(.linkNewDevice(items: [.linkNew]))
}()
......@@ -231,16 +265,16 @@ class MeViewModel: ViewModel, Stateable {
return .accountSettings( items: [.sectionHeader(title: ""),
.sipUserName(value: username),
.sipPassword(value: password),
.sipServer(value: server)])
.sipServer(value: server),
.shareAccountDetails])
}
return .accountSettings( items: [.sectionHeader(title: ""),
.sipUserName(value: username),
.sipPassword(value: password),
.sipServer(value: server),
.port(value: port),
.proxyServer(value: proxyServer)])
.proxyServer(value: proxyServer),
.shareAccountDetails])
}
}()
......
......@@ -174,6 +174,10 @@
"accountPage.removeAccountTitle" = "Remove account";
"accountPage.removeAccountMessage" = "By clicking \"Remove\" you will remove this account on this device! This action can not be undone. Also, your registered name can be lost.";
"accountPage.removeAccountButton" = "Remove";
"accountPage.shareAccountDetails" = "Share Account Details";
"accountPage.contactMeOnJamiTitle" = "Contact me on Jami!";
"accountPage.contactMeOnJamiContant" = "Contact me using \"%s\" on the Jami distributet communication platform: https://jami.net";
//Account
"account.sipUsername" = "User Name";
"account.sipPassword" = "Password";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment