Skip to content

Commit

Permalink
Merge branch 'main' into camera-platform-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
PROGrand authored Sep 27, 2023
2 parents e8dd52d + 21c2ebb commit cf15472
Show file tree
Hide file tree
Showing 84 changed files with 728 additions and 418 deletions.
56 changes: 56 additions & 0 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,34 @@ targets:
{"dependency": "android_virtual_device", "version": "33"}
]
- name: Linux_android android_platform_tests_api_33_shard_1 master
recipe: packages/packages
timeout: 60
bringup: true
properties:
target_file: android_platform_tests_api_33.yaml
channel: master
version_file: flutter_master.version
package_sharding: "--shardIndex 0 --shardCount 2"
dependencies: >-
[
{"dependency": "android_virtual_device", "version": "33"}
]
- name: Linux_android android_platform_tests_api_33_shard_2 master
recipe: packages/packages
timeout: 60
bringup: true
properties:
target_file: android_platform_tests_api_33.yaml
channel: master
version_file: flutter_master.version
package_sharding: "--shardIndex 1 --shardCount 2"
dependencies: >-
[
{"dependency": "android_virtual_device", "version": "33"}
]
- name: Linux_android android_platform_tests_shard_1 stable
recipe: packages/packages
presubmit: false
Expand Down Expand Up @@ -464,6 +492,34 @@ targets:
{"dependency": "android_virtual_device", "version": "33"}
]
- name: Linux_android android_platform_tests_api_33_shard_1 stable
recipe: packages/packages
timeout: 60
bringup: true
properties:
target_file: android_platform_tests_api_33.yaml
channel: master
version_file: flutter_stable.version
package_sharding: "--shardIndex 0 --shardCount 2"
dependencies: >-
[
{"dependency": "android_virtual_device", "version": "33"}
]
- name: Linux_android android_platform_tests_api_33_shard_2 stable
recipe: packages/packages
timeout: 60
bringup: true
properties:
target_file: android_platform_tests_api_33.yaml
channel: master
version_file: flutter_stable.version
package_sharding: "--shardIndex 1 --shardCount 2"
dependencies: >-
[
{"dependency": "android_virtual_device", "version": "33"}
]
# Device versions of Android integration tests, run via FTL.
# TODO(stuartmorgan): Revisit whether physical device tests are redundant once
# we have more data about emulator tests; see
Expand Down
30 changes: 30 additions & 0 deletions .ci/targets/android_platform_tests_api_33_avd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Same as android_platform_tests.yaml with only packages currently requiring
# Android 33 due to test failures caused by running on Android 34 AVDs.
tasks:
- name: prepare tool
script: .ci/scripts/prepare_tool.sh
infra_step: true # Note infra steps failing prevents "always" from running.
- name: download Dart and Android deps
script: script/tool_runner.sh
infra_step: true
args: ["fetch-deps", "--android", "--supporting-target-platforms-only", "--filter-packages-to=script/configs/still_requires_api_33_avd.yaml"]
- name: build examples
script: script/tool_runner.sh
args: ["build-examples", "--apk", "--filter-packages-to=script/configs/still_requires_api_33_avd.yaml"]
- name: lint
script: script/tool_runner.sh
args: ["lint-android", "--filter-packages-to=script/configs/still_requires_api_33_avd.yaml"]
# Native unit and native integration are split into two steps to allow for
# different exclusions.
# TODO(stuartmorgan): Eliminate the native unit test exclusion, and combine
# these steps.
- name: native unit tests
script: script/tool_runner.sh
args: ["native-test", "--android", "--no-integration", "--filter-packages-to=script/configs/still_requires_api_33_avd.yaml"]
- name: native integration tests
script: script/tool_runner.sh
args: ["native-test", "--android", "--no-unit", "--filter-packages-to=script/configs/still_requires_api_33_avd.yaml"]
- name: drive examples
script: script/tool_runner.sh
args: ["drive-examples", "--android", "--filter-packages-to=script/configs/still_requires_api_33_avd.yaml"]

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
cd $GITHUB_WORKSPACE
# Checks out a copy of the repo.
- name: Check out code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
fetch-depth: 0 # Fetch all history so the tool can get all the tags to determine version.
- name: Set up tools
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v2.4.0
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v2.4.0
with:
persist-credentials: false

Expand Down
8 changes: 8 additions & 0 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.10.8+11

* Downgrades AGP version for compatibility with legacy projects.

## 0.10.8+10

* Sets android.defaults.buildfeatures.buildconfig to true for compatibility with AGP 8.0+.

## 0.10.8+9

* Removes usage of `_ambiguate` method in example.
Expand Down
5 changes: 4 additions & 1 deletion packages/camera/camera_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'com.android.tools.build:gradle:7.3.0'
}
}

Expand All @@ -27,6 +27,9 @@ project.getTasks().withType(JavaCompile){
apply plugin: 'com.android.library'

android {
buildFeatures {
buildConfig true
}
// Conditional for compatibility with AGP <4.2.
if (project.android.hasProperty("namespace")) {
namespace 'io.flutter.plugins.camera'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.1.1'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
2 changes: 1 addition & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22

version: 0.10.8+9
version: 0.10.8+11

environment:
sdk: ">=2.19.0 <4.0.0"
Expand Down
12 changes: 12 additions & 0 deletions packages/go_router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 11.1.1

- Fixes a missing `{@end-tool}` doc directive tag for `GoRoute.name`.

## 11.1.0

- Adds optional parameter `overridePlatformDefaultLocation` to override initial route set by platform.

## 11.0.1

- Fixes the Android back button ignores top level route's onExit.

## 11.0.0

- Fixes the GoRouter.goBranch so that it doesn't reset extra to null if extra is not serializable.
Expand Down
6 changes: 6 additions & 0 deletions packages/go_router/lib/src/delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
return true;
}
}
// This should be the only place where the last GoRoute exit the screen.
final GoRoute lastRoute =
currentConfiguration.matches.last.route as GoRoute;
if (lastRoute.onExit != null && navigatorKey.currentContext != null) {
return !(await lastRoute.onExit!(navigatorKey.currentContext!));
}
return false;
}

Expand Down
1 change: 1 addition & 0 deletions packages/go_router/lib/src/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class GoRoute extends RouteBase {
/// queryParameters: <String, String>{'qid': 'quid'},
/// );
/// ```
/// {@end-tool}
///
/// See the [named routes example](https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/named_routes.dart)
/// for a complete runnable app.
Expand Down
25 changes: 25 additions & 0 deletions packages/go_router/lib/src/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class GoRouter implements RouterConfig<RouteMatchList> {
int redirectLimit = 5,
bool routerNeglect = false,
String? initialLocation,
this.overridePlatformDefaultLocation = false,
Object? initialExtra,
List<NavigatorObserver>? observers,
bool debugLogDiagnostics = false,
Expand All @@ -91,6 +92,8 @@ class GoRouter implements RouterConfig<RouteMatchList> {
initialExtra == null || initialLocation != null,
'initialLocation must be set in order to use initialExtra',
),
assert(!overridePlatformDefaultLocation || initialLocation != null,
'Initial location must be set to override platform default'),
assert(
(onException == null ? 0 : 1) +
(errorPageBuilder == null ? 0 : 1) +
Expand Down Expand Up @@ -299,6 +302,23 @@ class GoRouter implements RouterConfig<RouteMatchList> {
@override
late final GoRouteInformationParser routeInformationParser;

/// Whether to ignore platform's default initial location when
/// `initialLocation` is set.
///
/// When set to [true], the [initialLocation] will take
/// precedence over the platform's default initial location.
/// This allows developers to control the starting route of the application
/// independently of the platform.
///
/// Platform's initial location is set when the app opens via a deeplink.
/// Use [overridePlatformDefaultLocation] only if one wants to override
/// platform implemented initial location.
///
/// Setting this parameter to [false] (default) will allow the platform's
/// default initial location to be used even if the `initialLocation` is set.
/// It's advisable to only set this to [true] if one explicitly wants to.
final bool overridePlatformDefaultLocation;

/// Returns `true` if there is at least two or more route can be pop.
bool canPop() => routerDelegate.canPop();

Expand Down Expand Up @@ -507,6 +527,11 @@ class GoRouter implements RouterConfig<RouteMatchList> {
}

String _effectiveInitialLocation(String? initialLocation) {
if (overridePlatformDefaultLocation) {
// The initialLocation must not be null as it's already
// verified by assert() during the initialization.
return initialLocation!;
}
final String platformDefault =
WidgetsBinding.instance.platformDispatcher.defaultRouteName;
if (initialLocation == null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: go_router
description: A declarative router for Flutter based on Navigation 2 supporting
deep linking, data-driven routes and more
version: 11.0.0
version: 11.1.1
repository: https://github.com/flutter/packages/tree/main/packages/go_router
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22

Expand Down
54 changes: 54 additions & 0 deletions packages/go_router/test/go_router_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4955,6 +4955,60 @@ void main() {
expect(statefulWidgetKeyB.currentState?.counter, equals(1));
});
});

///Regression tests for https://github.com/flutter/flutter/issues/132557
group('overridePlatformDefaultLocation', () {
test('No initial location provided', () {
expect(
() => GoRouter(
overridePlatformDefaultLocation: true,
routes: <RouteBase>[
GoRoute(
path: '/a',
builder: (BuildContext context, GoRouterState state) =>
const Placeholder(),
),
GoRoute(
path: '/b',
builder: (BuildContext context, GoRouterState state) =>
const Placeholder(),
),
],
),
throwsA(const TypeMatcher<AssertionError>()));
});
testWidgets('Test override using routeInformationProvider',
(WidgetTester tester) async {
tester.binding.platformDispatcher.defaultRouteNameTestValue =
'/some-route';
final String platformRoute =
WidgetsBinding.instance.platformDispatcher.defaultRouteName;
const String expectedInitialRoute = '/kyc';
expect(platformRoute != expectedInitialRoute, isTrue);

final List<RouteBase> routes = <RouteBase>[
GoRoute(
path: '/abc',
builder: (BuildContext context, GoRouterState state) =>
const Placeholder(),
),
GoRoute(
path: '/bcd',
builder: (BuildContext context, GoRouterState state) =>
const Placeholder(),
),
];

final GoRouter router = await createRouter(
routes,
tester,
overridePlatformDefaultLocation: true,
initialLocation: expectedInitialRoute,
);
expect(router.routeInformationProvider.value.uri.toString(),
expectedInitialRoute);
});
});
}

class TestInheritedNotifier extends InheritedNotifier<ValueNotifier<String>> {
Expand Down
Loading

0 comments on commit cf15472

Please sign in to comment.