From dfa8cc86a4ad35b486f19792de2618f697941670 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Wed, 10 May 2017 13:42:13 +0200 Subject: [PATCH] Remove urlLauncher and pathProvider from FlutterPlatformPlugin (flutter/engine#3673) --- .../plugin/platform/PlatformPlugin.java | 28 ----------------- .../framework/Source/FlutterPlatformPlugin.mm | 30 +------------------ 2 files changed, 1 insertion(+), 57 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 333186190d..6550cef4a0 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -11,14 +11,11 @@ import android.content.ClipDescription; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; -import android.net.Uri; import android.os.Build; import android.view.HapticFeedbackConstants; import android.view.SoundEffectConstants; import android.view.View; -import io.flutter.util.PathUtils; - import io.flutter.plugin.common.ActivityLifecycleListener; import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.Result; @@ -53,9 +50,6 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe } else if (method.equals("HapticFeedback.vibrate")) { vibrateHapticFeedback(); result.success(null); - } else if (method.equals("UrlLauncher.launch")) { - launchURL((String) arguments); - result.success(null); } else if (method.equals("SystemChrome.setPreferredOrientations")) { setSystemChromePreferredOrientations((JSONArray) arguments); result.success(null); @@ -76,10 +70,6 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe } else if (method.equals("Clipboard.setData")) { setClipboardData((JSONObject) arguments); result.success(null); - } else if (method.equals("PathProvider.getTemporaryDirectory")) { - result.success(getPathProviderTemporaryDirectory()); - } else if (method.equals("PathProvider.getApplicationDocumentsDirectory")) { - result.success(getPathProviderApplicationDocumentsDirectory()); } else { result.notImplemented(); } @@ -100,16 +90,6 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } - private void launchURL(String url) { - try { - Intent launchIntent = new Intent(Intent.ACTION_VIEW); - launchIntent.setData(Uri.parse(url)); - mActivity.startActivity(launchIntent); - } catch (java.lang.Exception exception) { - // Ignore parsing or ActivityNotFound errors - } - } - private void setSystemChromePreferredOrientations(JSONArray orientations) throws JSONException { // Currently the Android implementation only supports masks with zero or one // selected device orientations. @@ -212,14 +192,6 @@ public class PlatformPlugin implements MethodCallHandler, ActivityLifecycleListe clipboard.setPrimaryClip(clip); } - private String getPathProviderTemporaryDirectory() { - return mActivity.getCacheDir().getPath(); - } - - private String getPathProviderApplicationDocumentsDirectory() { - return PathUtils.getDataDirectory(mActivity); - } - @Override public void onPostResume() { updateSystemUiOverlays(); diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index 29259a1431..95368abb6c 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -13,13 +13,6 @@ namespace { constexpr char kTextPlainFormat[] = "text/plain"; -NSString* GetDirectoryOfType(NSSearchPathDirectory dir) { - NSArray* paths = NSSearchPathForDirectoriesInDomains(dir, NSUserDomainMask, YES); - if (paths.count == 0) - return nil; - return paths.firstObject; -} - } // namespaces namespace shell { @@ -49,9 +42,6 @@ using namespace shell; } else if ([method isEqualToString:@"HapticFeedback.vibrate"]) { [self vibrateHapticFeedback]; result(nil); - } else if ([method isEqualToString:@"UrlLauncher.launch"]) { - [self launchURL:args]; - result(nil); } else if ([method isEqualToString:@"SystemChrome.setPreferredOrientations"]) { [self setSystemChromePreferredOrientations:args]; result(nil); @@ -72,10 +62,6 @@ using namespace shell; } else if ([method isEqualToString:@"Clipboard.setData"]) { [self setClipboardData:args]; result(nil); - } else if ([method isEqualToString:@"PathProvider.getTemporaryDirectory"]) { - result([self getPathProviderTemporaryDirectory]); - } else if ([method isEqualToString:@"PathProvider.getApplicationDocumentsDirectory"]) { - result([self getPathProviderApplicationDocumentsDirectory]); } else { result(FlutterMethodNotImplemented); } @@ -94,13 +80,6 @@ using namespace shell; AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); } -- (NSDictionary*)launchURL:(NSString*)urlString { - NSURL* url = [NSURL URLWithString:urlString]; - UIApplication* application = [UIApplication sharedApplication]; - bool success = [application canOpenURL:url] && [application openURL:url]; - return @{ @"succes" : @(success) }; -} - - (void)setSystemChromePreferredOrientations:(NSArray*)orientations { UIInterfaceOrientationMask mask = 0; @@ -185,17 +164,10 @@ using namespace shell; return nil; } + - (void)setClipboardData:(NSDictionary*)data { UIPasteboard* pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = data[@"text"]; } -- (NSString*)getPathProviderTemporaryDirectory { - return GetDirectoryOfType(NSCachesDirectory); -} - -- (NSString*)getPathProviderApplicationDocumentsDirectory { - return GetDirectoryOfType(NSDocumentDirectory); -} - @end