@@ -66,11 +66,6 @@ - (instancetype)initWithStyle:(UITableViewStyle)style {
6666 SettingsSubscriptionCellSpecifierKey,
6767 SettingsRestorePurchases,
6868 SettingsReinstallVPNConfigurationKey,
69- SettingsPsiCashGroupHeaderTitleKey,
70- SettingsPsiCashCellSpecifierKey,
71- SettingsPsiCashAccountManagementSpecifierKey,
72- SettingsPsiCashAccountLogoutCellSpecifierKey,
73- SettingspsiCashAccountLoginCellSpecifierKey
7469 ];
7570
7671 }
@@ -123,37 +118,7 @@ - (void)updateHiddenKeys {
123118 [hiddenKeys addObject: kForceReconnectFooter ];
124119 }
125120
126- // PsiCash Manage Account button:
127- // - Shown when logged in account.
128- // - Not allowed when disconnected (button disabled, not hidden).
129- // - Not allowed when logging out
130- if (self.viewModel .isPsiCashAccountLoggedIn == TRUE ) {
131- [hiddenKeys removeObject: SettingsPsiCashAccountManagementSpecifierKey];
132- } else {
133- [hiddenKeys addObject: SettingsPsiCashAccountManagementSpecifierKey];
134- }
135-
136- // PsiCash Logout button:
137- // - Shown when logged in account.
138- // - Allowed when disconnected, local only, with prompt.
139- if (self.viewModel .isPsiCashAccountLoggedIn == TRUE ) {
140- [hiddenKeys removeObject: SettingsPsiCashAccountLogoutCellSpecifierKey];
141- } else {
142- [hiddenKeys addObject: SettingsPsiCashAccountLogoutCellSpecifierKey];
143- }
144-
145- // PsiCash Login button:
146- // - Shown when not logged in (no tokens, trackers, logged out state),
147- // or when PsiCash lib did not initialize successfully.
148- // - Not allowed when disconnected (button disabled, not hidden).
149- if (self.viewModel .isPsiCashInitialized == FALSE || self.viewModel .isPsiCashAccountLoggedIn == TRUE ) {
150- [hiddenKeys addObject: SettingspsiCashAccountLoginCellSpecifierKey];
151- } else {
152- [hiddenKeys removeObject: SettingspsiCashAccountLoginCellSpecifierKey];
153- }
154-
155121 [self setHiddenKeys: hiddenKeys animated: FALSE ];
156-
157122}
158123
159124- (void )viewDidAppear : (BOOL )animated {
@@ -238,47 +203,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView
238203 cell.userInteractionEnabled = enabled;
239204 cell.textLabel .enabled = enabled;
240205 cell.detailTextLabel .enabled = enabled;
241-
242- } else if ([specifier.key isEqualToString: SettingsPsiCashCellSpecifierKey]) {
243- // PsiCash button.
244- [cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];
245- cell.textLabel .text = [UserStrings PsiCash ];
246-
247- } else if ([specifier.key isEqualToString: SettingsPsiCashAccountManagementSpecifierKey]) {
248- // PsiCash Account Management button.
249- [cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];
250- [cell.textLabel setText: [UserStrings PsiCash_account_management ]];
251-
252- // PsiCash account management button disabled when not connected,
253- // and when logging out.
254- BOOL enabled = ([VPNStateCompat isConnected: self .viewModel.vpnStatus] && !self.viewModel .isLoggingOut );
255- cell.userInteractionEnabled = enabled;
256- cell.textLabel .enabled = enabled;
257- cell.detailTextLabel .enabled = enabled;
258-
259- } else if ([specifier.key isEqualToString: SettingsPsiCashAccountLogoutCellSpecifierKey]) {
260- // PsiCash Account Logout button.
261- cell.textLabel .textAlignment = NSTextAlignmentCenter;
262- cell.textLabel .text = [UserStrings Log_Out ];
263-
264- // Logout button is enabled when VPN state in not in a transitory state,
265- // and no pending logout operation.
266- BOOL enabled = ![VPNStateCompat isInTransition: self .viewModel.vpnStatus] && !self.viewModel .isLoggingOut ;
267- cell.userInteractionEnabled = enabled;
268- cell.textLabel .enabled = enabled;
269- cell.detailTextLabel .enabled = enabled;
270-
271- } else if ([specifier.key isEqualToString: SettingspsiCashAccountLoginCellSpecifierKey]) {
272- // PsiCash Account Login button.
273- cell.textLabel .textAlignment = NSTextAlignmentCenter;
274- cell.textLabel .text = [UserStrings Log_in ];
275-
276- // Login button is enabled when VPN state in not in a transitory state.
277- BOOL enabled = ![VPNStateCompat isInTransition: self .viewModel.vpnStatus];
278- cell.userInteractionEnabled = enabled;
279- cell.textLabel .enabled = enabled;
280- cell.detailTextLabel .enabled = enabled;
281-
282206 }
283207
284208 PSIAssert (cell != nil );
@@ -326,102 +250,11 @@ - (void)settingsViewController:(IASKAppSettingsViewController *)sender
326250 // Reinstall VPN config button
327251 [SwiftDelegate.bridge reinstallVPNConfig ];
328252 [self settingsViewControllerDidEnd: nil ];
329-
330- } else if ([specifier.key isEqualToString: SettingsPsiCashCellSpecifierKey]) {
331-
332- // PsiCash button
333- [self presentPsiCashStore ];
334-
335- } else if ([specifier.key isEqualToString: SettingsPsiCashAccountManagementSpecifierKey]) {
336-
337- // PsiCash Account Management button
338- [self openPsiCashAccountManagement ];
339-
340- } else if ([specifier.key isEqualToString: SettingsPsiCashAccountLogoutCellSpecifierKey]) {
341-
342- // PsiCash Account Logout button
343- [self onPsiCashAccountLogOutWithSourceView: cell];
344-
345- } else if ([specifier.key isEqualToString: SettingspsiCashAccountLoginCellSpecifierKey]) {
346-
347- // PsiCash Account Login button
348- [self onPsiCashAccountLoginTapped ];
349-
350253 }
351-
352254}
353255
354256#pragma mark - Callbacks
355257
356- - (void )presentPsiCashStore {
357- [SwiftDelegate.bridge presentPsiCashStoreViewController: PsiCashScreenTabSpeedBoost];
358- }
359-
360- - (void )openPsiCashAccountManagement {
361- [SwiftDelegate.bridge presentPsiCashAccountManagement ];
362- }
363-
364- - (void )onPsiCashAccountLoginTapped {
365- [SwiftDelegate.bridge presentPsiCashAccountViewControllerWithPsiCashScreen: FALSE ];
366- }
367-
368- - (void )onPsiCashAccountLogOutWithSourceView : (UIView *_Nonnull)sourceView {
369-
370- // No-op if tunnel is not connected or disconnected.
371- if ([VPNStateCompat isInTransition: self .viewModel.vpnStatus] == TRUE ) {
372- return ;
373- }
374-
375- BOOL isOffline = [VPNStateCompat isDisconnected: self .viewModel.vpnStatus];
376-
377- NSString *message;
378- NSString *logoutTitle;
379-
380- if (isOffline == TRUE ) {
381-
382- message = [UserStrings PsiCash_logout_offline_body ];
383- logoutTitle = [UserStrings Logout_anyway ];
384-
385- } else {
386-
387- message = [UserStrings Are_you_sure_psicash_account_logout ];
388- logoutTitle = [UserStrings Log_Out ];
389-
390- }
391-
392- UIAlertController *alert = [UIAlertController
393- alertControllerWithTitle: [UserStrings Psicash_account_logout_title ]
394- message: message
395- preferredStyle: UIAlertControllerStyleAlert];
396-
397- UIAlertAction *logoutAction = [UIAlertAction actionWithTitle: logoutTitle
398- style: UIAlertActionStyleDestructive
399- handler: ^(UIAlertAction *action) {
400- [SwiftDelegate.bridge logOutPsiCashAccount ];
401- }];
402-
403- // Adds a "Connect" button if tunnel is not connected,
404- // and sets it as the default action.
405- if (isOffline == TRUE ) {
406-
407- UIAlertAction *connectAction = [UIAlertAction actionWithTitle: [UserStrings Connect ]
408- style: UIAlertActionStyleDefault
409- handler: ^(UIAlertAction *action) {
410- [SwiftDelegate.bridge connectButtonTappedFromSettings ];
411- }];
412-
413- [alert addAction: connectAction];
414-
415- alert.preferredAction = connectAction;
416-
417- }
418-
419- [alert addAction: logoutAction];
420- [alert addCancelAction: nil ];
421-
422- [alert presentFromTopController ];
423- }
424-
425258- (void )onRestorePurchases {
426259
427260 SettingsViewController *__weak weakSelf = self;
0 commit comments