This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[path_provider] support the v2 embedder #2153
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
30429b2
Migrate path_provider to the new embedding
audkar 030e640
Making activity with embeddingV2 as main launcher
audkar 2d0de32
Add TODO comment
audkar 3e90531
Adding lifecycle deps workaround
audkar b746aed
Adding e2e tests
audkar 06f572b
fix missing import
audkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| org.gradle.jvmargs=-Xmx1536M | ||
| android.enableJetifier=true | ||
| android.useAndroidX=true |
25 changes: 25 additions & 0 deletions
25
...h_provider/android/src/main/java/dev/flutter/plugins/pathprovider/PathProviderPlugin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright 2019 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package dev.flutter.plugins.pathprovider; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import io.flutter.embedding.engine.plugins.FlutterPlugin; | ||
| import io.flutter.plugin.common.MethodChannel; | ||
| import io.flutter.plugins.pathprovider.PathProviderMethodCallHandler; | ||
|
|
||
| public class PathProviderPlugin implements FlutterPlugin { | ||
| @Override | ||
| public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { | ||
| MethodChannel channel = | ||
| new MethodChannel( | ||
| binding.getFlutterEngine().getDartExecutor(), "plugins.flutter.io/path_provider"); | ||
| PathProviderMethodCallHandler handler = | ||
| new PathProviderMethodCallHandler(binding.getApplicationContext()); | ||
| channel.setMethodCallHandler(handler); | ||
| } | ||
|
|
||
| @Override | ||
| public void onDetachedFromEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {} | ||
| } |
62 changes: 62 additions & 0 deletions
62
.../android/src/main/java/io/flutter/plugins/pathprovider/PathProviderMethodCallHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Copyright 2019 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.pathprovider; | ||
|
|
||
| import android.content.Context; | ||
| import androidx.annotation.NonNull; | ||
| import io.flutter.plugin.common.MethodCall; | ||
| import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
| import io.flutter.plugin.common.MethodChannel.Result; | ||
| import io.flutter.util.PathUtils; | ||
| import java.io.File; | ||
|
|
||
| public class PathProviderMethodCallHandler implements MethodCallHandler { | ||
|
|
||
| private final Context context; | ||
|
|
||
| public PathProviderMethodCallHandler(Context context) { | ||
| this.context = context; | ||
| } | ||
|
|
||
| @Override | ||
| public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { | ||
| switch (call.method) { | ||
| case "getTemporaryDirectory": | ||
| result.success(getPathProviderTemporaryDirectory()); | ||
| break; | ||
| case "getApplicationDocumentsDirectory": | ||
| result.success(getPathProviderApplicationDocumentsDirectory()); | ||
| break; | ||
| case "getStorageDirectory": | ||
| result.success(getPathProviderStorageDirectory()); | ||
| break; | ||
| case "getApplicationSupportDirectory": | ||
| result.success(getApplicationSupportDirectory()); | ||
| break; | ||
| default: | ||
| result.notImplemented(); | ||
| } | ||
| } | ||
|
|
||
| private String getPathProviderTemporaryDirectory() { | ||
| return context.getCacheDir().getPath(); | ||
| } | ||
|
|
||
| private String getApplicationSupportDirectory() { | ||
| return PathUtils.getFilesDir(context); | ||
| } | ||
|
|
||
| private String getPathProviderApplicationDocumentsDirectory() { | ||
| return PathUtils.getDataDirectory(context); | ||
| } | ||
|
|
||
| private String getPathProviderStorageDirectory() { | ||
| final File dir = context.getExternalFilesDir(null); | ||
| if (dir == null) { | ||
| return null; | ||
| } | ||
| return dir.getAbsolutePath(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
.../src/androidTest/java/io/flutter/plugins/pathproviderexample/EmbeddingV1ActivityTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Copyright 2019, the Chromium project authors. Please see the AUTHORS file | ||
| // for details. All rights reserved. Use of this source code is governed by a | ||
| // BSD-style license that can be found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.pathproviderexample; | ||
|
|
||
| import static org.junit.Assert.*; | ||
|
|
||
| import androidx.test.rule.ActivityTestRule; | ||
| import dev.flutter.plugins.e2e.FlutterRunner; | ||
| import org.junit.Rule; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| @RunWith(FlutterRunner.class) | ||
| public class EmbeddingV1ActivityTest { | ||
| @Rule | ||
| public ActivityTestRule<EmbeddingV1Activity> rule = | ||
| new ActivityTestRule<>(EmbeddingV1Activity.class); | ||
| } |
15 changes: 15 additions & 0 deletions
15
...oid/app/src/androidTest/java/io/flutter/plugins/pathproviderexample/MainActivityTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Copyright 2019, the Chromium project authors. Please see the AUTHORS file | ||
| // for details. All rights reserved. Use of this source code is governed by a | ||
| // BSD-style license that can be found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.pathproviderexample; | ||
|
|
||
| import androidx.test.rule.ActivityTestRule; | ||
| import dev.flutter.plugins.e2e.FlutterRunner; | ||
| import org.junit.Rule; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| @RunWith(FlutterRunner.class) | ||
| public class MainActivityTest { | ||
| @Rule public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class); | ||
| } |
35 changes: 25 additions & 10 deletions
35
packages/path_provider/example/android/app/src/main/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...android/app/src/main/java/io/flutter/plugins/pathproviderexample/EmbeddingV1Activity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // Copyright 2017 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.pathproviderexample; | ||
|
|
||
| import android.os.Bundle; | ||
| import io.flutter.app.FlutterActivity; | ||
| import io.flutter.plugins.GeneratedPluginRegistrant; | ||
|
|
||
| public class EmbeddingV1Activity extends FlutterActivity { | ||
|
|
||
| @Override | ||
| protected void onCreate(Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
| GeneratedPluginRegistrant.registerWith(this); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| org.gradle.jvmargs=-Xmx1536M | ||
| android.enableJetifier=false | ||
| android.useAndroidX=true | ||
| android.enableR8=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ dependencies: | |
| path_provider: | ||
| path: ../ | ||
| uuid: "^1.0.0" | ||
| e2e: "^0.2.1" | ||
|
|
||
| dev_dependencies: | ||
| flutter_driver: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with this temporary tweak, the error you were pointing at should be gone on stable. Would you like to sync your PR up to master and try the tests again?