-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
254 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,9 @@ | ||
.DS_Store | ||
.atom/ | ||
.idea | ||
.packages | ||
.pub/ | ||
build/ | ||
ios/.generated/ | ||
packages | ||
pubspec.lock |
This file contains 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,12 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
|
||
/gradle | ||
/gradlew | ||
/gradlew.bat |
25 changes: 25 additions & 0 deletions
25
...pen_directory/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
This file contains 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 @@ | ||
package io.flutter.plugins; | ||
|
||
import io.flutter.plugin.common.PluginRegistry; | ||
import net.zibaei.open_directory.OpenDirectoryPlugin; | ||
|
||
/** | ||
* Generated file. Do not edit. | ||
*/ | ||
public final class GeneratedPluginRegistrant { | ||
public static void registerWith(PluginRegistry registry) { | ||
if (alreadyRegisteredWith(registry)) { | ||
return; | ||
} | ||
OpenDirectoryPlugin.registerWith(registry.registrarFor("net.zibaei.open_directory.OpenDirectoryPlugin")); | ||
} | ||
|
||
private static boolean alreadyRegisteredWith(PluginRegistry registry) { | ||
final String key = GeneratedPluginRegistrant.class.getCanonicalName(); | ||
if (registry.hasPlugin(key)) { | ||
return true; | ||
} | ||
registry.registrarFor(key); | ||
return false; | ||
} | ||
} |
This file contains 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,32 @@ | ||
group 'net.zibaei.open_directory' | ||
version '1.0-SNAPSHOT' | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.3.0' | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '25.0.3' | ||
|
||
defaultConfig { | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
lintOptions { | ||
disable 'InvalidPackage' | ||
} | ||
} |
This file contains 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 @@ | ||
org.gradle.jvmargs=-Xmx1536M |
This file contains 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 @@ | ||
rootProject.name = 'open_directory' |
This file contains 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,7 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="net.zibaei.open_directory" | ||
android:versionCode="1" | ||
android:versionName="0.3.0"> | ||
|
||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" /> | ||
</manifest> |
57 changes: 57 additions & 0 deletions
57
...s/open_directory/android/src/main/java/net/zibaei/open_directory/OpenDirectoryPlugin.java
This file contains 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,57 @@ | ||
package net.zibaei.open_directory; | ||
|
||
import android.app.Activity; | ||
import android.content.ComponentName; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import io.flutter.plugin.common.MethodCall; | ||
import io.flutter.plugin.common.MethodChannel; | ||
import io.flutter.plugin.common.PluginRegistry; | ||
|
||
import java.io.File; | ||
import java.util.HashMap; | ||
|
||
public class OpenDirectoryPlugin implements MethodChannel.MethodCallHandler { | ||
private final Activity activity; | ||
|
||
public static void registerWith(PluginRegistry.Registrar registrar) { | ||
MethodChannel channel = | ||
new MethodChannel(registrar.messenger(), "net.zibaei.flutter/open_directory"); | ||
OpenDirectoryPlugin instance = new OpenDirectoryPlugin(registrar.activity()); | ||
channel.setMethodCallHandler(instance); | ||
} | ||
|
||
private OpenDirectoryPlugin(Activity activity) { | ||
this.activity = activity; | ||
} | ||
|
||
@Override | ||
public void onMethodCall(MethodCall call, MethodChannel.Result result) { | ||
String uri = ((HashMap) call.arguments()).get("uri").toString(); | ||
if (call.method.equals("canOpen")) { | ||
canOpen(uri, result); | ||
} else if (call.method.equals("openDirectory")) { | ||
openDirectory(uri, result); | ||
} else { | ||
result.notImplemented(); | ||
} | ||
} | ||
|
||
private void openDirectory(String uri, MethodChannel.Result result) { | ||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); | ||
intent.setDataAndType(Uri.parse(uri), "resource/folder"); | ||
activity.startActivity(intent); | ||
result.success(null); | ||
} | ||
|
||
private void canOpen(String uri, MethodChannel.Result result) { | ||
boolean canLaunch; | ||
Intent launchIntent = new Intent(Intent.ACTION_VIEW); | ||
launchIntent.setDataAndType(Uri.parse(uri), "resource/folder"); | ||
ComponentName componentName = launchIntent.resolveActivity(activity.getPackageManager()); | ||
canLaunch = componentName != null | ||
&& !"{com.android.fallback/com.android.fallback.Fallback}" | ||
.equals(componentName.toShortString()); | ||
result.success(canLaunch); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/open_directory/ios/Runner/GeneratedPluginRegistrant.h
This file contains 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,14 @@ | ||
// | ||
// Generated file. Do not edit. | ||
// | ||
|
||
#ifndef GeneratedPluginRegistrant_h | ||
#define GeneratedPluginRegistrant_h | ||
|
||
#import <Flutter/Flutter.h> | ||
|
||
@interface GeneratedPluginRegistrant : NSObject | ||
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry; | ||
@end | ||
|
||
#endif /* GeneratedPluginRegistrant_h */ |
14 changes: 14 additions & 0 deletions
14
packages/open_directory/ios/Runner/GeneratedPluginRegistrant.m
This file contains 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,14 @@ | ||
// | ||
// Generated file. Do not edit. | ||
// | ||
|
||
#import "GeneratedPluginRegistrant.h" | ||
#import <open_directory/OpenDirectoryPlugin.h> | ||
|
||
@implementation GeneratedPluginRegistrant | ||
|
||
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry { | ||
[OpenDirectoryPlugin registerWithRegistrar:[registry registrarForPlugin:@"OpenDirectoryPlugin"]]; | ||
} | ||
|
||
@end |
This file contains 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,14 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/services.dart'; | ||
|
||
const _channel = const MethodChannel('net.zibaei.flutter/open_directory'); | ||
|
||
Future<dynamic> openDirectory(String uriString) { | ||
return _channel.invokeMethod('openDirectory', {"uri": uriString}); | ||
} | ||
|
||
Future<bool> canOpen(String uriString) async { | ||
if (uriString == null) return false; | ||
return await _channel.invokeMethod('canOpen', {"uri": uriString}); | ||
} |
This file contains 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,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="WEB_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<excludeFolder url="file://$MODULE_DIR$/.pub" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build" /> | ||
<excludeFolder url="file://$MODULE_DIR$/example/.pub" /> | ||
<excludeFolder url="file://$MODULE_DIR$/example/build" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Dart SDK" level="project" /> | ||
<orderEntry type="library" name="Dart Packages" level="project" /> | ||
</component> | ||
</module> |
This file contains 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,16 @@ | ||
name: open_directory | ||
description: Open Directory plugin | ||
version: 0.3.0 | ||
author: Ahmadreza Zibaei <ahmadreza@zibaei.net> | ||
|
||
flutter: | ||
plugin: | ||
androidPackage: net.zibaei.open_directory | ||
pluginClass: OpenDirectoryPlugin | ||
|
||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
|
||
environment: | ||
sdk: ">=2.0.0 <2.2.0" |
This file contains 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 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