Skip to content

Commit

Permalink
Fixed issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaMulgundkar committed Apr 8, 2020
1 parent 399906e commit aa4e826
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 59 deletions.
140 changes: 85 additions & 55 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.6

* [Fixed issue #2](https://github.com/AdityaMulgundkar/wallpaper_manager/issues/2 "Problems due to change in Flutter's Embedding engine / GeneratedPluginRegistrant.java")

## 1.0.5

* More To-dos
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In the `pubspec.yaml` of your flutter project, add the following dependency:
```yaml
dependencies:
...
wallpaper_manager: "^1.0.5"
wallpaper_manager: "^1.0.6"
```
In your library add the following import:
Expand Down Expand Up @@ -94,6 +94,9 @@ For help getting started with Flutter, view the online [documentation](https://f
* iOS does not support changing Wallpapers from third-party apps [\(Source\)](https://stackoverflow.com/questions/56112014/can-i-change-ios-screen-wallpaper-programmatically-in-swift-5-and-ios-12)
* Xiaomi/MIUI does not support changing Lock Screen Wallpapers directly from the Android API [\(Source\)](https://in.c.mi.com/thread-1252992-1-0.html). You might want to look at creating a Lock Screen Launcher app instead.

## Known Issues
* Due to a change in [Flutter's Embedding Engine] (https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration), you might face an [issue](https://github.com/AdityaMulgundkar/wallpaper_manager/issues/2) while building your project. To work around this, you can upgrade to the latest version of the plugin (which directly handles both v1 & v2 Embedding from v.1.0.6) or change the [Flutter Embedding Engine version in your project](https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects).

## Todos
- [ ] Write tests
- [ ] Add rect values for optionally cropping the image
Expand Down
8 changes: 8 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@

<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application>
<activity android:name=".EmbeddingV1Activity"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
/>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mulgundkar.wallpaper_manager;
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugin.common.MethodChannel;
import com.mulgundkar.wallpaper_manager.WallpaperManagerPlugin;

public class EmbeddingV1Activity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WallpaperManagerPlugin.registerWith(registrarFor("com.mulgundkar.wallpaper_manager.WallpaperManagerPlugin"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

/** WallpaperManagerPlugin */
public class WallpaperManagerPlugin implements FlutterPlugin, MethodCallHandler {
private Context context;
private static Context context;

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
Expand All @@ -40,9 +40,10 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin
channel.setMethodCallHandler(this);
}

public void registerWith(Registrar registrar) {
public static void registerWith(Registrar registrar) {
context = registrar.context();
final MethodChannel channel = new MethodChannel(registrar.messenger(), "wallpaper_manager");
channel.setMethodCallHandler(this);
channel.setMethodCallHandler(new WallpaperManagerPlugin());
}

@Override
Expand All @@ -65,6 +66,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {

@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
context = null;
}

@SuppressLint("MissingPermission")
Expand Down

0 comments on commit aa4e826

Please sign in to comment.