Commit Graph

218 Commits

Author SHA1 Message Date
Igor Solomennikov
2fd17eda12 Animate controls on the crop screens in and out.
This change also fixes a bug when bottom buttons in the crop screen
were not visible. That happened because ImageEditorBottomBar by default
had its controls hidden (with the intent that they are animated in once
view controller's view is visible). That was a poor design choice on my
end and is fixed in this commit.
2022-07-07 08:37:34 -07:00
Igor Solomennikov
7f4a5f3f7b Merge branch igor/media-editor-updates. 2022-07-06 14:54:26 -07:00
Evan Hahn
d0c7de494a Computed accessors shold always be in the same order
`get`, then `set`. This fixes violations of [SwiftLint's
`computed_accessors_order` rule][0].

A very mechanical change.

[0]: https://realm.github.io/SwiftLint/computed_accessors_order.html
2022-06-24 09:35:07 -07:00
Evan Hahn
576d854c6f Remove unnecessary break statements
This fixes all of our violations of [SwiftLint's
`unneeded_break_in_switch` rule][0].

[0]: https://realm.github.io/SwiftLint/unneeded_break_in_switch.html
2022-06-24 09:32:34 -07:00
Evan Hahn
76c8d66702 Use "done" button on gift badge message keyboard
Goodbye "return", hello "done".

Clicking "done" will dismiss the keyboard.
2022-06-23 17:09:57 +00:00
Evan Hahn
5696c50d7d Make some outgoing message params optional
We frequently send outgoing messages with some parameters, like "link
preview" or "quoted reply", empty.

This change lets those parameters be omitted (instead of explicitly
empty) for brevity.

This is a stylistic change and should have no user impact.

Tested this by sending a regular message, a message with a link preview,
and two messages with photos.
2022-06-23 12:53:05 +00:00
Evan Hahn
b5b560a0fe Shorten message send expiry timer lookup
Similar to e79f37cc01.
2022-06-22 14:35:48 -07:00
Sasha Weiss (Signal)
5695809776
Prevent non-temporary-file attachments from being deleted when shared 2022-06-22 13:15:04 -07:00
Evan Hahn
7e0fa84c6d Only add necessary completion callbacks to message send transaction
You can add callbacks to be executed when a transaction completes. We
usually do this when sending messages, but not always.

Previously, the logic was "add a callback that runs the completion
function, if it exists." Now, the logic is "if the completion function
exists, add a callback that runs it."

I think this slightly better reflects our intent, and helps reduce
memory usage (and potential capturing?) slightly.
2022-06-21 16:46:59 +00:00
Sasha Weiss (Signal)
2f4ded9d03
Fix reentrant DB read on mentions processing 2022-06-20 13:21:22 -07:00
Nora Trapp
7bd167f815
Initial story sending support
* Little fix for context menu

* Add 'My Stories' section to stories tab

* Add new story thread types

* Show stories in conversation picker

* Support for sending stories

* Update story list when sending stories

* Add basic 'My Stories' view controller

* Initial stories settings screens

* Consolidate TSPrivateStoryThread and TSMyStoryThread into one class

* Require an explicit read transaction to initialize an outgoing message

* Fix linting

* Allow enabling group story from internal settings

* Fix tests

* PR Feedback
2022-06-10 22:28:03 -04:00
Max Radermacher
66a2638edd Don’t attach canceled link previews 2022-06-09 15:10:50 -07:00
Nora Trapp
a106ecdfdd Fix RTL layout of video playback progress bar 2022-06-08 16:58:56 -04:00
Evan Hahn
41c4be6b71 Remove useless override
This override stopped being relevant in
c4f967ef46, as far as I can tell.
2022-06-06 14:45:54 +00:00
Evan Hahn
c2e7f0ca93 Prefer implicit getters
_I recommend reviewing this with whitespace changes disabled._

This fixes violations of [SwiftLint's `implicit_getter` rule][0] by
removing explicit getters when an implicit one would do.

[0]: https://realm.github.io/SwiftLint/implicit_getter.html
2022-06-06 14:00:15 +00:00
Evan Hahn
24ca5abf9c Remove unneeded breaks
This fixes our violations of [the SwiftLint `unneeded_break_in_switch`
rule][0].

[0]: https://realm.github.io/SwiftLint/unneeded_break_in_switch.html
2022-06-03 17:52:28 +00:00
Jordan Rose
91f4615d5d Avoid multiple ThemeDidChange notifications
We get notified of the system theme changing through OWSWindow, but
there's more than one window in the app.
2022-06-02 14:01:42 -07:00
Evan Hahn
0cee2789b9 Update "pending changes action sheet" localization metadata
_I recommend reviewing this with whitespace changes disabled._

This is a minor change; it have no direct user impact.

We have a "pending changes action sheet" which shows up to warn users
that their changes may not be saved. The localization key and comment
indicated that its strings were only for groups, but that's not
true—it's used for lots of things, such as editing your profile or
updating a group's metadata.
2022-05-27 21:54:42 +00:00
Igor Solomennikov
db0c4e7c73 Fix crash when opening media flow with message pre-populated.
Steps to reproduce:
• open group chat and type a message containing "@" but don't send it.
• tap on + and select last photo/video from the strip.
• observe app crashing.

Cause of crash:
Attempting to access a child view controller of UIPageViewController
while using force unwrap when UIPageViewController's view is not yet loaded.

The fix:
• Remove force unwrapping (linter was complaining about that too).
• Add "isViewLoaded" check to the method that was causing the crash.
2022-05-25 11:42:04 -07:00
Igor Solomennikov
8b3ea9d27d Fix typo: "Gausian" -> "Gaussian". 2022-05-17 19:25:30 -07:00
Evan Hahn
29c0ddf60e Fix violations of SwiftLint's attributes rule
_I recommend reviewing this with whitespace changes disabled._

Most of these were `@objc` being on the same line, which I fixed with [a
silly script][1]—probably could've used `sed` if I were wiser. The rest
were manual fixes.

See [the SwiftLint documentation for this rule][0].

[0]: https://realm.github.io/SwiftLint/attributes.html
[1]: https://gist.github.com/EvanHahn-Signal/d353c93fa269c82b96baca0a1086521f
2022-05-14 09:07:42 -05:00
Max Radermacher
84cb841110 Add “Gift a Badge” menu item 2022-05-12 15:09:58 -05:00
Max Radermacher
9e31f6875d
Remove unused chat view code
* Remove unused `CVComponent` properties
* Remove unused `bubbleChatColor(message:)`
2022-05-10 09:48:28 -07:00
Adam Mork
bb7b73213f Use shorter fog report URI in wallet 2022-05-09 08:11:42 -05:00
Max Radermacher
b1874b4c5f Fix some _isDebugAssertConfiguration warnings
By moving the check after the `isLoggingEnabled()` check, there isn’t
unreachable code, so the compiler warning goes away. (The `_isDebug…`
check has to be second, or the `isLoggingEnabled()` call would be
unreachable code.)

For the other case, I wrapped the entire check in a single `assert`,
avoiding the `_isDebugAssertConfiguration` call altogether. (This one
wasn’t a warning, but I think this approach is more canonical, and it’s
probably best to avoid `_` functions where possible.)
2022-05-06 09:48:50 -05:00
Evan Hahn
df8592fa23 Fix SwiftLint switch_case_alignment violations
_I recommend reviewing this with whitespace changes disabled._

Bad:

```swift
switch foo {
    case .one: return 1
    case .two: return 2
}
```

Good:

```swift
switch foo {
case .one: return 1
case .two: return 2
}
```

See [the rule's documentation][0] for more.

[0]: https://realm.github.io/SwiftLint/switch_case_alignment.html
2022-05-03 12:15:05 -05:00
Evan Hahn
04d7bb7462 Stop using arc4random in Swift files
This removes calls to `arc4random` and `arc4random_uniform` and replaces
them with calls to `Int.random` or equivalent.

These are a little less readable, which may be [why SwiftLint doesn't
like them][0]. (SwiftLint calls them "legacy", possibly because they're
not strong random number generators, but I couldn't find a clear
explanation for this anywhere, including [the original PR][1].)

This is the kind of change that's error-prone, so I wrote [a simple
script to help avoid regressions][2]. The script runs 10,000 iterations
of the old and new RNG and compares the ranges, reporting differences.
(Some differences are likely, like the ones that involve floats; others
are very unlikely to have differences.)

`git grep arc4random | grep swift` returns no results after this change.
Same for [everything else SwiftLint checks for][3].

[0]: https://realm.github.io/SwiftLint/legacy_random.html
[1]: https://github.com/realm/SwiftLint/pull/2419
[2]: https://gist.github.com/EvanHahn-Signal/9c75c9f484f4778149cbde3eafc9b285
[3]: ea6cc50890/Source/SwiftLintFramework/Rules/Idiomatic/LegacyRandomRule.swift (L23-L27)
2022-05-03 10:19:07 -05:00
Ehren Kret
c123d91dd5 Revert "Use shorter URLs for MOB FOG"
This reverts commit f45b50fe80.
2022-05-02 20:39:52 -05:00
Ehren Kret
f45b50fe80 Use shorter URLs for MOB FOG 2022-05-02 11:21:01 -05:00
Evan Hahn
5be42da750 Change references from master to main
_I recommend reviewing this with whitespace changes disabled._

Signal has renamed its primary branch to `main`. This updates references
to the old name, `master`, to either reference `main` or a specific
commit hash.

I also fixed a couple of small whitespace issues in a file I was
editing.
2022-05-02 10:30:40 -05:00
igor-signal
4a6473b448
Localize user-visible file sizes.
Use ByteCountFormatter with default settings to localize any download sizes that user might see.
2022-04-29 09:57:56 -05:00
Martin Böttcher
54b743de2d
moved older stringsdict changes into new branch; minor changes (#4205)
moved older stringsdict changes into new branch
2022-04-28 17:41:43 +02:00
Igor Solomennikov
dc19eb835f Fix "the the" in comments. 2022-04-27 20:16:45 -07:00
Igor Solomennikov
8fe9963f16 Address PR feedback. 2022-04-22 11:15:21 -07:00
Igor Solomennikov
9349af7fa5 Fix incorrect (old) media editor layout in landscape on non-plus size devices. 2022-04-22 11:15:21 -07:00
Igor Solomennikov
1aec65bc1d Fix incorrect layouts constraints in AL helper method.
UIView.autoPin(toEdgesOf:withInset:) was creating incorrect vertical
edge constraints.

Also rename the method to better match conventions: `withInsets` instead
of `withInset`.
2022-04-22 11:08:20 -07:00
Nora Trapp
f2473a01a0 Fix quoting story reactions 2022-04-21 11:00:12 -07:00
Nora Trapp
1443eef293 Animate presentation and dismissal of stories with interactive dismissal 2022-04-21 11:00:12 -07:00
Nora Trapp
1ce7bdd672 Support sending 1:1 story replies 2022-04-21 10:58:28 -07:00
Igor Solomennikov
1f3ceac66c Fix GradientView not working in some cases.
GradientView would not work if its colors were passed during initialization
and never changed after. This was caused by the fact that `CAGradientLayer`'s
colors were updated in `GradientView.colors.didSet`, which isn't
called during `init()`.

Also allow access to `GradientView.gradientLayer` so that users of
that class can build more advanced gradients.
2022-04-20 10:23:50 -07:00
Evan Hahn
67ea0d0516 Fix some trivial compiler warnings
This fixes 10 of our Xcode warnings:

- `MessageReactionPicker.swift` was declaring a variable and not using
  it, leading to "Immutable value 'emoji' was never used". I simply
  removed it.
- `Stripe.swift` had a bunch of unnecessary `public`s, which caused
  "'public' modifier is redundant for static property declared in a
  public extension".
- `SubscriptionManager.swift` had an unnecessary `try`, causing "No
  calls to throwing functions occur within 'try' expression".
- `CallService.swift:696` was calling a function and not using its
  result, so I annotated that function with `@discardableResult`.
- `MobileCoinAPI+Configuration.swift` declared a variable with `var`
  that should've used `let`.

Nothing major here, but wanted to find ones that were easy to fix.
2022-04-19 09:28:15 -05:00
Nora Trapp
27e03b6a70 Render 1:1 story replies 2022-04-15 19:28:14 -07:00
Michelle Linington
37fe097812 Lint 2022-04-13 20:23:22 -07:00
Michelle Linington
d54d654cfc PR Feedback: Remove notImplemented altogether 2022-04-13 20:21:47 -07:00
Michelle Linington
6b2f8d31d6 Lint 2022-04-13 20:21:46 -07:00
Michelle Linington
cca09295e6 Adopt notImplemented() where it's unadopted
notImplemented() ends up forwarding to fatalError() anyway, but before
it does so it flushes our logs. That's probably good to have. I think
most of these come from the default implementations Xcode provides for
you with a fix-it.
2022-04-13 20:21:46 -07:00
Igor Solomennikov
2128a2f7f2 Lint. 2022-04-12 17:38:21 -07:00
Igor Solomennikov
e7e218743d Use OWSFormat.localizedDurationString(from:) whenever a duration is displayed in the UI. 2022-04-12 17:38:21 -07:00
Igor Solomennikov
527e352258 Require secure coding when archiving data with NSKeyedArchiver.
Per PR feedback.
2022-04-12 13:24:57 -07:00
Igor Solomennikov
e946ab932a Stop using deprecated NSKeyedArchiver methods.
• use NSKeyedArchiver.archivedData(withRootObject:requiringSecureCoding:)
  instead of NSKeyedArchiver.archivedData(withRootObject).
• use NSKeyedArchived.unarchivedObject(ofClass:from:) instead of
  NSKeyedArchiver.unarchiveTopLevelObjectWithData().
2022-04-12 13:24:57 -07:00