Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/local_auth/local_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.1.4

* Updates documentation for Android version 8 and below theme compatibility.

## 2.1.3

* Updates minimum Flutter version to 2.10.
Expand Down
31 changes: 31 additions & 0 deletions packages/local_auth/local_auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,37 @@ types (such as face scanning) and you want to support SDKs lower than Q,
_do not_ call `getAvailableBiometrics`. Simply call `authenticate` with `biometricOnly: true`.
This will return an error if there was no hardware available.

#### Android theme

On Android, ensure that the `LaunchTheme` of your app has a parent style with the `Theme.AppCompat.Light` theme; otherwise the app may crash. To do that go to `android > app > src > main > res > values > styles.xml` and look for the style with name `LaunchTheme` (Notice that `LaunchTheme` must be referenced in the `AndroidManifest.xml` file). Then, change the parent style with the new value and you should have set up something like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Please wrap all of the new text here to 80 characters, as with the rest of the README.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove "On Android", since this is in the Android section of the README.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is .Light the only option here? Why not just Theme.AppCompat?

Copy link
Contributor Author

@Abel1027 Abel1027 Feb 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some research and test all variants of the Theme.AppCompat, and these were the results:

Using Theme.AppCompat alone results in a dialog with weird (no contrast) theme:
android-6-appcompat

Therefore, only two options left from the documentation:

  • Light
  • Dark

However, since API 29 there is an extra option: DayNight, which enables light/dark modes switching when the user changes the theme from the device's settings.

To check the later, I set up the Theme.AppCompat.DayNight theme and these are the results:

  • Choosing light mode from device's settings

android-11-appcompat-daynight-light

  • Chossing dark mode from device's settings

android-11-appcompat-daynight-dark

The good thing is that even the Theme.AppCompat.DayNight theme has only sense from API 29, it maps the available mode of lower API versions. The following is an example of using DayNight on API 23 (Android 6):
android-6-appcompat-daynight

As the options of AppCompat are related to a usecase, I updated the doc by suggesting to apply one of the AppCompat options. And I gave the DayNight example:

You need to update the LaunchTheme parent style with a valid Theme.AppCompat
theme to be compatible with Android version 8 and below, otherwise the app
crashes for those versions. For example, use Theme.AppCompat.DayNight to
enable light/dark modes for the biometric dialog.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: replace the ; with a , since the final clause is not a full sentence.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the parenthetical; why does someone need to "notice" something in order to make this change, particularly something in another file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In AndroidManifest.xml you specify the name of the style you have defined in the styles.xml, therefore if you don't notice that you have referenced the correct name the theme in styles.xml won't apply.

I updated this part telling the reader that this reference makes possible the application of the defined theme in styles.xml:

(Notice that LaunchTheme must be referenced in the AndroidManifest.xml file to apply the changes made in styles.xml)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you don't notice that you have referenced the correct name the theme in styles.xml won't apply

Whether or not someone notices that its' there is irrelevant to whether it works, only whether it is there. So this is telling someone to do something that doesn't help ("notice" something) if it is there, and also doesn't tell them what to do if it's not. The instructions here for styles.xml seem to assume that the reader isn't familiar with any of this and thus needs extremely detailed instructions; the instructions for AndroidManifest.xml should equally clear and detailed, assuming the same level of reader knowledge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. Well, due to Flutter creates the styles.xml always with a LaunchTheme style name and it is associated to the AndroidManifest.xml by default, I will remove the phrase between parentheses (...).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "and you should have set up something like this" isn't really adding anything to the instructions, it's just making it longer. "Then change the parent for that style as follows:" conveys the same information, but is much shorter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the paths here and below written like menu navigation instructions (with >) rather than as paths (with /)?


```xml
...
<resources>
<style name="LaunchTheme" parent="Theme.AppCompat.Light">
...
</style>
...
</resources>
...
```

In case you don't have a `styles.xml` file for your Android project you can set up the Android theme directly on your `android > app > src > main > AndroidManifest.xml` file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: If you don't have

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: directly in

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove "your" and "file" at the end; the fact that it's a file in their project is clear from context.


```xml
...
<application
...
<activity
...
android:theme="@style/Theme.AppCompat.Light"
...
>
</activity>
</application>
...
```

## Sticky Auth

You can set the `stickyAuth` option on the plugin to true so that plugin does not
Expand Down
2 changes: 1 addition & 1 deletion packages/local_auth/local_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Android and iOS devices to allow local
authentication via fingerprint, touch ID, face ID, passcode, pin, or pattern.
repository: https://github.com/flutter/plugins/tree/main/packages/local_auth/local_auth
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
version: 2.1.3
version: 2.1.4

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down