Remove urlLauncher and pathProvider from FlutterPlatformPlugin (flutter/engine#3673)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user