refactor: update variable & method modifiers

This commit is contained in:
エリス 2024-12-29 02:55:26 +09:00
parent b6ac771142
commit 9d4d32dc0d
No known key found for this signature in database
GPG Key ID: 2E5FF17FB26AF7F2
25 changed files with 69 additions and 69 deletions

View File

@ -74,7 +74,7 @@ public class AllowListPlugin extends CordovaPlugin {
}
private class CustomConfigXmlParser extends ConfigXmlParser {
private CordovaPreferences prefs = new CordovaPreferences();
private final CordovaPreferences prefs = new CordovaPreferences();
@Override
public void handleStartTag(XmlPullParser xml) {

View File

@ -35,7 +35,7 @@ import java.lang.reflect.Field;
public class BuildHelper {
private static String TAG="BuildHelper";
private static final String TAG = "BuildHelper";
/*
* This needs to be implemented if you wish to use the Camera Plugin or other plugins

View File

@ -27,8 +27,8 @@ import org.json.JSONObject;
public class CallbackContext {
private static final String LOG_TAG = "CordovaPlugin";
private String callbackId;
private CordovaWebView webView;
private final String callbackId;
private final CordovaWebView webView;
protected boolean finished;
private int changingThreads;

View File

@ -28,7 +28,7 @@ import android.util.SparseArray;
*/
public class CallbackMap {
private int currentCallbackId = 0;
private SparseArray<Pair<CordovaPlugin, Integer>> callbacks;
private final SparseArray<Pair<CordovaPlugin, Integer>> callbacks;
public CallbackMap() {
this.callbacks = new SparseArray<>();

View File

@ -29,17 +29,17 @@ import org.xmlpull.v1.XmlPullParserException;
import android.content.Context;
public class ConfigXmlParser {
private static String TAG = "ConfigXmlParser";
private static final String TAG = "ConfigXmlParser";
private static String SCHEME_HTTP = "http";
private static String SCHEME_HTTPS = "https";
private static String DEFAULT_HOSTNAME = "localhost";
private static final String SCHEME_HTTP = "http";
private static final String SCHEME_HTTPS = "https";
private static final String DEFAULT_HOSTNAME = "localhost";
private static final String DEFAULT_CONTENT_SRC = "index.html";
private String launchUrl;
private String contentSrc;
private CordovaPreferences prefs = new CordovaPreferences();
private ArrayList<PluginEntry> pluginEntries = new ArrayList<>(20);
private final CordovaPreferences prefs = new CordovaPreferences();
private final ArrayList<PluginEntry> pluginEntries = new ArrayList<>(20);
public CordovaPreferences getPreferences() {
return prefs;

View File

@ -77,14 +77,14 @@ import androidx.core.splashscreen.SplashScreen;
*
*/
public class CordovaActivity extends AppCompatActivity {
public static String TAG = "CordovaActivity";
public static final String TAG = "CordovaActivity";
// The webview for our app
protected CordovaWebView appView;
private static int ACTIVITY_STARTING = 0;
private static int ACTIVITY_RUNNING = 1;
private static int ACTIVITY_EXITING = 2;
private static final int ACTIVITY_STARTING = 0;
private static final int ACTIVITY_RUNNING = 1;
private static final int ACTIVITY_EXITING = 2;
// Keep app running when pause is received. (default = true)
// If true, then the JavaScript and native code continue to run in the background

View File

@ -25,7 +25,7 @@ import org.json.JSONObject;
import android.util.Base64;
public class CordovaArgs {
private JSONArray baseArgs;
private final JSONArray baseArgs;
public CordovaArgs(JSONArray args) {
this.baseArgs = args;

View File

@ -32,8 +32,8 @@ import org.json.JSONException;
*/
public class CordovaBridge {
private static final String LOG_TAG = "CordovaBridge";
private PluginManager pluginManager;
private NativeToJsMessageQueue jsMessageQueue;
private final PluginManager pluginManager;
private final NativeToJsMessageQueue jsMessageQueue;
private volatile int expectedBridgeSecret = -1; // written by UI thread, read by JS thread.
public CordovaBridge(PluginManager pluginManager, NativeToJsMessageQueue jsMessageQueue) {

View File

@ -117,6 +117,6 @@ public class CordovaDialogsHelper {
}
public interface Result {
public void gotResult(boolean success, String value);
void gotResult(boolean success, String value);
}
}

View File

@ -39,14 +39,14 @@ public interface CordovaInterface {
* @param intent The intent to start
* @param requestCode The request code that is passed to callback to identify the activity
*/
abstract public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode);
void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode);
/**
* Set the plugin to be called when a sub-activity exits.
*
* @param plugin The plugin on which onActivityResult is to be called
*/
abstract public void setActivityResultCallback(CordovaPlugin plugin);
void setActivityResultCallback(CordovaPlugin plugin);
/**
* Get the Android activity.
@ -55,14 +55,14 @@ public interface CordovaInterface {
*
* @return the Activity
*/
public abstract AppCompatActivity getActivity();
AppCompatActivity getActivity();
/**
* Get the Android context.
*
* @return the Context
*/
public Context getContext();
Context getContext();
/**
* Called when a message is sent to plugin.
@ -71,28 +71,28 @@ public interface CordovaInterface {
* @param data The message data
* @return Object or null
*/
public Object onMessage(String id, Object data);
Object onMessage(String id, Object data);
/**
* @return a shared thread pool that can be used for background tasks.
*/
public ExecutorService getThreadPool();
ExecutorService getThreadPool();
/**
* Sends a permission request to the activity for one permission.
*/
public void requestPermission(CordovaPlugin plugin, int requestCode, String permission);
void requestPermission(CordovaPlugin plugin, int requestCode, String permission);
/**
* Sends a permission request to the activity for a group of permissions
*/
public void requestPermissions(CordovaPlugin plugin, int requestCode, String [] permissions);
void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions);
/**
* Check for a permission.
*
* @return true if the permission is granted, false otherwise.
*/
public boolean hasPermission(String permission);
boolean hasPermission(String permission);
}

View File

@ -40,12 +40,12 @@ import java.util.concurrent.Executors;
*/
public class CordovaInterfaceImpl implements CordovaInterface {
private static final String TAG = "CordovaInterfaceImpl";
protected AppCompatActivity activity;
protected ExecutorService threadPool;
protected final AppCompatActivity activity;
protected final ExecutorService threadPool;
protected PluginManager pluginManager;
protected ActivityResultHolder savedResult;
protected CallbackMap permissionResultCallbacks;
protected final CallbackMap permissionResultCallbacks;
protected CordovaPlugin activityResultCallback;
protected String initCallbackService;
protected int activityResultRequestCode;
@ -199,9 +199,9 @@ public class CordovaInterfaceImpl implements CordovaInterface {
}
private static class ActivityResultHolder {
private int requestCode;
private int resultCode;
private Intent intent;
private final int requestCode;
private final int resultCode;
private final Intent intent;
public ActivityResultHolder(int requestCode, int resultCode, Intent intent) {
this.requestCode = requestCode;

View File

@ -29,7 +29,7 @@ import android.app.Activity;
import android.os.Bundle;
public class CordovaPreferences {
private HashMap<String, String> prefs = new HashMap<>(20);
private final HashMap<String, String> prefs = new HashMap<>(20);
private Bundle preferencesBundleExtras;
public void setPreferencesBundle(Bundle extras) {

View File

@ -31,7 +31,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
* are not expected to implement it.
*/
public interface CordovaWebView {
public static final String CORDOVA_VERSION = "13.0.1-dev";
String CORDOVA_VERSION = "13.0.1-dev";
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);

View File

@ -66,7 +66,7 @@ public interface CordovaWebViewEngine {
* Used to retrieve the associated CordovaWebView given a View without knowing the type of Engine.
* E.g. ((CordovaWebView.EngineView)activity.findViewById(android.R.id.webView)).getCordovaWebView();
*/
public interface EngineView {
interface EngineView {
CordovaWebView getCordovaWebView();
}
@ -74,7 +74,7 @@ public interface CordovaWebViewEngine {
* Contains methods that an engine uses to communicate with the parent CordovaWebView.
* Methods may be added in future cordova versions, but never removed.
*/
public interface Client {
interface Client {
Boolean onDispatchKeyEvent(KeyEvent event);
void clearLoadTimeoutTimer();
void onPageStarted(String newUrl);

View File

@ -62,7 +62,7 @@ public class CordovaWebViewImpl implements CordovaWebView {
private CordovaPreferences preferences;
private CoreAndroid appPlugin;
private NativeToJsMessageQueue nativeToJsMessageQueue;
private EngineClient engineClient = new EngineClient();
private final EngineClient engineClient = new EngineClient();
private boolean hasPausedEver;
// The URL passed to loadUrl(), not necessarily the URL of the current page.
@ -72,7 +72,7 @@ public class CordovaWebViewImpl implements CordovaWebView {
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
private Set<Integer> boundKeyCodes = new HashSet<>();
private final Set<Integer> boundKeyCodes = new HashSet<>();
public static CordovaWebViewEngine createEngine(Context context, CordovaPreferences preferences) {
String className = preferences.getString("webview", SystemWebViewEngine.class.getCanonicalName());

View File

@ -25,7 +25,7 @@ import org.json.JSONException;
* Any exposed Javascript API MUST implement these three things!
*/
public interface ExposedJsApi {
public String exec(int bridgeSecret, String service, String action, String callbackId, String arguments) throws JSONException, IllegalAccessException;
public void setNativeToJsBridgeMode(int bridgeSecret, int value) throws IllegalAccessException;
public String retrieveJsMessages(int bridgeSecret, boolean fromOnlineEvent) throws IllegalAccessException;
String exec(int bridgeSecret, String service, String action, String callbackId, String arguments) throws JSONException, IllegalAccessException;
void setNativeToJsBridgeMode(int bridgeSecret, int value) throws IllegalAccessException;
String retrieveJsMessages(int bridgeSecret, boolean fromOnlineEvent) throws IllegalAccessException;
}

View File

@ -29,32 +29,32 @@ public interface ICordovaClientCertRequest {
/**
* Cancel this request
*/
public void cancel();
void cancel();
/**
* @return the host name of the server requesting the certificate.
*/
public String getHost();
String getHost();
/**
* @return the acceptable types of asymmetric keys (can be null).
*/
public String[] getKeyTypes();
String[] getKeyTypes();
/**
* @return the port number of the server requesting the certificate.
*/
public int getPort();
int getPort();
/**
* @return the acceptable certificate issuers for the certificate matching the private key (can be null).
*/
public Principal[] getPrincipals();
Principal[] getPrincipals();
/**
* Ignore the request for now. Do not remember user's choice.
*/
public void ignore();
void ignore();
/**
* Proceed with the specified private key and client certificate chain. Remember the user's positive choice and use it for future requests.
@ -62,5 +62,5 @@ public interface ICordovaClientCertRequest {
* @param privateKey The privateKey
* @param chain The certificate chain
*/
public void proceed(PrivateKey privateKey, X509Certificate[] chain);
void proceed(PrivateKey privateKey, X509Certificate[] chain);
}

View File

@ -21,13 +21,13 @@ package org.apache.cordova;
public interface ICordovaCookieManager {
public void setCookiesEnabled(boolean accept);
void setCookiesEnabled(boolean accept);
public void setCookie(final String url, final String value);
void setCookie(final String url, final String value);
public String getCookie(final String url);
String getCookie(final String url);
public void clearCookies();
void clearCookies();
public void flush();
void flush();
}

View File

@ -26,7 +26,7 @@ package org.apache.cordova;
/**
* Instructs the WebView to cancel the authentication request.
*/
public void cancel ();
void cancel();
/**
* Instructs the WebView to proceed with the authentication with the given credentials.
@ -34,5 +34,5 @@ package org.apache.cordova;
* @param username The user name
* @param password The password
*/
public void proceed (String username, String password);
void proceed(String username, String password);
}

View File

@ -40,7 +40,7 @@ public class NativeToJsMessageQueue {
// to send to the JavaScript in one shot.
// This currently only chops up on message boundaries.
// It may be useful to split and reassemble response messages someday.
private static int COMBINED_RESPONSE_CUTOFF = 16 * 1024 * 1024;
private static final int COMBINED_RESPONSE_CUTOFF = 16 * 1024 * 1024;
/**
* When true, the active listener is not fired upon enqueue. When set to false,
@ -56,7 +56,7 @@ public class NativeToJsMessageQueue {
/**
* The array of listeners that can be used to send messages to JS.
*/
private ArrayList<BridgeMode> bridgeModes = new ArrayList<>();
private final ArrayList<BridgeMode> bridgeModes = new ArrayList<>();
/**
* When null, the bridge is disabled. This occurs during page transitions.

View File

@ -42,12 +42,12 @@ import android.webkit.WebView;
* from JavaScript.
*/
public class PluginManager {
private static String TAG = "PluginManager";
private static final String TAG = "PluginManager";
// @todo same as ConfigXmlParser. Research centralizing ideas, maybe create CordovaConstants
private static String SCHEME_HTTPS = "https";
private static final String SCHEME_HTTPS = "https";
// @todo same as ConfigXmlParser. Research centralizing ideas, maybe create CordovaConstants
private static String DEFAULT_HOSTNAME = "localhost";
private static final String DEFAULT_HOSTNAME = "localhost";
private static final int SLOW_EXEC_WARNING_THRESHOLD = Debug.isDebuggerConnected() ? 60 : 16;

View File

@ -169,7 +169,7 @@ public class PluginResult {
public static final int MESSAGE_TYPE_BINARYSTRING = 7;
public static final int MESSAGE_TYPE_MULTIPART = 8;
public static String[] StatusMessages = new String[] {
public static final String[] StatusMessages = new String[] {
"No result",
"OK",
"Class not found",

View File

@ -27,8 +27,8 @@ import java.util.List;
public class ResumeCallback extends CallbackContext {
private final String TAG = "CordovaResumeCallback";
private String serviceName;
private PluginManager pluginManager;
private final String serviceName;
private final PluginManager pluginManager;
public ResumeCallback(String serviceName, PluginManager pluginManager) {
super("resumecallback", null);

View File

@ -61,14 +61,14 @@ public class SystemWebChromeClient extends WebChromeClient {
private static final int FILECHOOSER_RESULTCODE = 5173;
private static final String LOG_TAG = "SystemWebChromeClient";
private long MAX_QUOTA = 100 * 1024 * 1024;
private final long MAX_QUOTA = 100 * 1024 * 1024;
protected final SystemWebViewEngine parentEngine;
// the video progress view
private View mVideoProgressView;
private CordovaDialogsHelper dialogsHelper;
private Context appContext;
private final CordovaDialogsHelper dialogsHelper;
private final Context appContext;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
private View mCustomView;

View File

@ -68,7 +68,7 @@ public class SystemWebViewClient extends WebViewClient {
boolean isCurrentlyLoading;
/** The authorization tokens. */
private Hashtable<String, AuthenticationToken> authenticationTokens = new Hashtable<>();
private final Hashtable<String, AuthenticationToken> authenticationTokens = new Hashtable<>();
public SystemWebViewClient(SystemWebViewEngine parentEngine) {
this.parentEngine = parentEngine;