Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions android/capacitor/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,3 @@
}

-keep public class * extends com.getcapacitor.Plugin { *; }

# Rules for Capacitor v2 plugins and annotations
# These are deprecated but can still be used with Capacitor for now
-keep @com.getcapacitor.NativePlugin public class * {
@com.getcapacitor.PluginMethod public <methods>;
}
84 changes: 9 additions & 75 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -618,17 +618,6 @@ public void registerPluginInstances(Plugin[] pluginInstances) {
}
}

@SuppressWarnings("deprecation")
private String getLegacyPluginName(Class<? extends Plugin> pluginClass) {
NativePlugin legacyPluginAnnotation = pluginClass.getAnnotation(NativePlugin.class);
if (legacyPluginAnnotation == null) {
Logger.error("Plugin doesn't have the @CapacitorPlugin annotation. Please add it");
return null;
}

return legacyPluginAnnotation.name();
}

/**
* Register a plugin class
* @param pluginClass a class inheriting from Plugin
Expand Down Expand Up @@ -671,28 +660,25 @@ private String pluginId(Class<? extends Plugin> clazz) {
}

private String pluginName(Class<? extends Plugin> clazz) {
String pluginName;
CapacitorPlugin pluginAnnotation = clazz.getAnnotation(CapacitorPlugin.class);
if (pluginAnnotation == null) {
pluginName = this.getLegacyPluginName(clazz);
} else {
pluginName = pluginAnnotation.name();
Logger.error("Plugin doesn't have the @CapacitorPlugin annotation. Please add it");
return null;
}

return pluginName;
return pluginAnnotation.name();
}

private void logInvalidPluginException(Class<? extends Plugin> clazz) {
Logger.error(
"NativePlugin " +
"Plugin " +
clazz.getName() +
" is invalid. Ensure the @CapacitorPlugin annotation exists on the plugin class and" +
" the class extends Plugin"
);
}

private void logPluginLoadException(Class<? extends Plugin> clazz, Exception ex) {
Logger.error("NativePlugin " + clazz.getName() + " failed to load", ex);
Logger.error("Plugin " + clazz.getName() + " failed to load", ex);
}

public PluginHandle getPlugin(String pluginId) {
Expand All @@ -706,38 +692,16 @@ public PluginHandle getPlugin(String pluginId) {
* @return
*/
@Deprecated
@SuppressWarnings("deprecation")
public PluginHandle getPluginWithRequestCode(int requestCode) {
for (PluginHandle handle : this.plugins.values()) {
int[] requestCodes;

CapacitorPlugin pluginAnnotation = handle.getPluginAnnotation();
if (pluginAnnotation == null) {
// Check for legacy plugin annotation, @NativePlugin
NativePlugin legacyPluginAnnotation = handle.getLegacyPluginAnnotation();
if (legacyPluginAnnotation == null) {
continue;
}

if (legacyPluginAnnotation.permissionRequestCode() == requestCode) {
continue;
}
for (int rc : pluginAnnotation.requestCodes()) {
if (rc == requestCode) {
return handle;
}

requestCodes = legacyPluginAnnotation.requestCodes();

for (int rc : requestCodes) {
if (rc == requestCode) {
return handle;
}
}
} else {
requestCodes = pluginAnnotation.requestCodes();

for (int rc : requestCodes) {
if (rc == requestCode) {
return handle;
}
}
}
}
return null;
Expand Down Expand Up @@ -1042,16 +1006,6 @@ public void saveInstanceState(Bundle outState) {
}
}

@Deprecated
@SuppressWarnings("deprecation")
public void startActivityForPluginWithResult(PluginCall call, Intent intent, int requestCode) {
Logger.debug("Starting activity for result");

pluginCallForLastActivity = call;

getActivity().startActivityForResult(intent, requestCode);
}

/**
* Check for legacy Capacitor or Cordova plugins that may have registered to handle a permission
* request, and handle them if so. If not handled, false is returned.
Expand Down Expand Up @@ -1079,12 +1033,6 @@ boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[]
return permissionHandled;
}

// Call deprecated method if using deprecated NativePlugin annotation
if (plugin.getPluginAnnotation() == null) {
plugin.getInstance().handleRequestPermissionsResult(requestCode, permissions, grantResults);
return true;
}

return false;
}

Expand Down Expand Up @@ -1220,22 +1168,8 @@ boolean onActivityResult(int requestCode, int resultCode, Intent data) {
return false;
}

// deprecated, to be removed
PluginCall lastCall = plugin.getInstance().getSavedCall();

// If we don't have a saved last call (because our app was killed and restarted, for example),
// Then we should see if we have any saved plugin call information and generate a new,
// "dangling" plugin call (a plugin call that doesn't have a corresponding web callback)
// and then send that to the plugin
if (lastCall == null && pluginCallForLastActivity != null) {
plugin.getInstance().saveCall(pluginCallForLastActivity);
}

plugin.getInstance().handleOnActivityResult(requestCode, resultCode, data);

// Clear the plugin call we may have re-hydrated on app launch
pluginCallForLastActivity = null;

return true;
}

Expand Down
37 changes: 0 additions & 37 deletions android/capacitor/src/main/java/com/getcapacitor/NativePlugin.java

This file was deleted.

Loading
Loading