@capacitor/android 2.4.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -152,6 +152,11 @@ public class Bridge {
|
|
|
152
152
|
this.config = new CapConfig(getActivity().getAssets(), config);
|
|
153
153
|
Logger.init(this.config);
|
|
154
154
|
|
|
155
|
+
// Display splash screen if configured
|
|
156
|
+
if (context instanceof BridgeActivity) {
|
|
157
|
+
Splash.showOnLaunch((BridgeActivity) context, this.config);
|
|
158
|
+
}
|
|
159
|
+
|
|
155
160
|
// Initialize web view and message handler for it
|
|
156
161
|
this.initWebView();
|
|
157
162
|
this.msgHandler = new MessageHandler(this, webView, pluginManager);
|
|
@@ -82,8 +82,6 @@ public class BridgeActivity extends AppCompatActivity {
|
|
|
82
82
|
cordovaInterface.onCordovaInit(pluginManager);
|
|
83
83
|
bridge = new Bridge(this, webView, initialPlugins, cordovaInterface, pluginManager, preferences, this.config);
|
|
84
84
|
|
|
85
|
-
Splash.showOnLaunch(this, bridge.getConfig());
|
|
86
|
-
|
|
87
85
|
if (savedInstanceState != null) {
|
|
88
86
|
bridge.restoreInstanceState(savedInstanceState);
|
|
89
87
|
}
|
|
@@ -3,195 +3,161 @@ package com.getcapacitor;
|
|
|
3
3
|
import android.app.Activity;
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.content.res.TypedArray;
|
|
6
|
-
import android.net.Uri;
|
|
7
6
|
import android.os.Bundle;
|
|
8
7
|
import android.util.AttributeSet;
|
|
9
8
|
import android.view.LayoutInflater;
|
|
10
9
|
import android.view.View;
|
|
11
10
|
import android.view.ViewGroup;
|
|
12
11
|
import android.webkit.WebView;
|
|
13
|
-
|
|
14
12
|
import androidx.fragment.app.Fragment;
|
|
15
|
-
|
|
16
13
|
import com.getcapacitor.android.R;
|
|
17
14
|
import com.getcapacitor.cordova.MockCordovaInterfaceImpl;
|
|
18
15
|
import com.getcapacitor.cordova.MockCordovaWebViewImpl;
|
|
19
|
-
|
|
16
|
+
import java.util.ArrayList;
|
|
17
|
+
import java.util.List;
|
|
20
18
|
import org.apache.cordova.ConfigXmlParser;
|
|
21
19
|
import org.apache.cordova.CordovaPreferences;
|
|
22
20
|
import org.apache.cordova.PluginEntry;
|
|
23
21
|
import org.apache.cordova.PluginManager;
|
|
24
22
|
import org.json.JSONObject;
|
|
25
23
|
|
|
26
|
-
import java.util.ArrayList;
|
|
27
|
-
import java.util.List;
|
|
28
|
-
|
|
29
24
|
/**
|
|
30
25
|
* A simple {@link Fragment} subclass.
|
|
31
|
-
* Activities that contain this fragment must implement the
|
|
32
|
-
* {@link BridgeFragment.OnFragmentInteractionListener} interface
|
|
33
|
-
* to handle interaction events.
|
|
34
26
|
* Use the {@link BridgeFragment#newInstance} factory method to
|
|
35
27
|
* create an instance of this fragment.
|
|
36
28
|
*/
|
|
37
29
|
public class BridgeFragment extends Fragment {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
* @return A new instance of fragment BridgeFragment.
|
|
70
|
-
*/
|
|
71
|
-
public static BridgeFragment newInstance(String startDir) {
|
|
72
|
-
BridgeFragment fragment = new BridgeFragment();
|
|
73
|
-
Bundle args = new Bundle();
|
|
74
|
-
args.putString(ARG_START_DIR, startDir);
|
|
75
|
-
fragment.setArguments(args);
|
|
76
|
-
return fragment;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
protected void init(Bundle savedInstanceState) {
|
|
80
|
-
loadConfig(this.getActivity().getApplicationContext(), this.getActivity());
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Load the WebView and create the Bridge
|
|
85
|
-
*/
|
|
86
|
-
protected void load(Bundle savedInstanceState) {
|
|
87
|
-
Logger.debug("Starting BridgeActivity");
|
|
88
|
-
|
|
89
|
-
Bundle args = getArguments();
|
|
90
|
-
String startDir = null;
|
|
91
|
-
|
|
92
|
-
if (args != null) {
|
|
93
|
-
startDir = getArguments().getString(ARG_START_DIR);
|
|
30
|
+
private static final String ARG_START_DIR = "startDir";
|
|
31
|
+
|
|
32
|
+
private WebView webView;
|
|
33
|
+
protected Bridge bridge;
|
|
34
|
+
protected MockCordovaInterfaceImpl cordovaInterface;
|
|
35
|
+
protected boolean keepRunning = true;
|
|
36
|
+
private ArrayList<PluginEntry> pluginEntries;
|
|
37
|
+
private PluginManager pluginManager;
|
|
38
|
+
private CordovaPreferences preferences;
|
|
39
|
+
private MockCordovaWebViewImpl mockWebView;
|
|
40
|
+
|
|
41
|
+
private List<Class<? extends Plugin>> initialPlugins = new ArrayList<>();
|
|
42
|
+
private JSONObject config = new JSONObject();
|
|
43
|
+
|
|
44
|
+
public BridgeFragment() {
|
|
45
|
+
// Required empty public constructor
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Use this factory method to create a new instance of
|
|
50
|
+
* this fragment using the provided parameters.
|
|
51
|
+
*
|
|
52
|
+
* @param startDir the directory to serve content from
|
|
53
|
+
* @return A new instance of fragment BridgeFragment.
|
|
54
|
+
*/
|
|
55
|
+
public static BridgeFragment newInstance(String startDir) {
|
|
56
|
+
BridgeFragment fragment = new BridgeFragment();
|
|
57
|
+
Bundle args = new Bundle();
|
|
58
|
+
args.putString(ARG_START_DIR, startDir);
|
|
59
|
+
fragment.setArguments(args);
|
|
60
|
+
return fragment;
|
|
94
61
|
}
|
|
95
62
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (savedInstanceState != null) {
|
|
99
|
-
cordovaInterface.restoreInstanceState(savedInstanceState);
|
|
63
|
+
protected void init(Bundle savedInstanceState) {
|
|
64
|
+
loadConfig(this.getActivity().getApplicationContext(), this.getActivity());
|
|
100
65
|
}
|
|
101
66
|
|
|
102
|
-
|
|
103
|
-
|
|
67
|
+
public void addPlugin(Class<? extends Plugin> plugin) {
|
|
68
|
+
this.initialPlugins.add(plugin);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Load the WebView and create the Bridge
|
|
73
|
+
*/
|
|
74
|
+
protected void load(Bundle savedInstanceState) {
|
|
75
|
+
Logger.debug("Starting BridgeActivity");
|
|
76
|
+
|
|
77
|
+
Bundle args = getArguments();
|
|
78
|
+
String startDir = null;
|
|
104
79
|
|
|
105
|
-
|
|
106
|
-
|
|
80
|
+
if (args != null) {
|
|
81
|
+
startDir = getArguments().getString(ARG_START_DIR);
|
|
82
|
+
}
|
|
107
83
|
|
|
108
|
-
|
|
109
|
-
|
|
84
|
+
webView = getView().findViewById(R.id.webview);
|
|
85
|
+
cordovaInterface = new MockCordovaInterfaceImpl(this.getActivity());
|
|
86
|
+
if (savedInstanceState != null) {
|
|
87
|
+
cordovaInterface.restoreInstanceState(savedInstanceState);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
mockWebView = new MockCordovaWebViewImpl(getActivity().getApplicationContext());
|
|
91
|
+
mockWebView.init(cordovaInterface, pluginEntries, preferences, webView);
|
|
92
|
+
|
|
93
|
+
pluginManager = mockWebView.getPluginManager();
|
|
94
|
+
cordovaInterface.onCordovaInit(pluginManager);
|
|
95
|
+
|
|
96
|
+
if (preferences == null) {
|
|
97
|
+
preferences = new CordovaPreferences();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
bridge = new Bridge(this.getActivity(), webView, initialPlugins, cordovaInterface, pluginManager, preferences, config);
|
|
101
|
+
|
|
102
|
+
if (startDir != null) {
|
|
103
|
+
bridge.setServerAssetPath(startDir);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (savedInstanceState != null) {
|
|
107
|
+
bridge.restoreInstanceState(savedInstanceState);
|
|
108
|
+
}
|
|
109
|
+
this.keepRunning = preferences.getBoolean("KeepRunning", true);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
public void loadConfig(Context context, Activity activity) {
|
|
113
|
+
ConfigXmlParser parser = new ConfigXmlParser();
|
|
114
|
+
parser.parse(context);
|
|
115
|
+
preferences = parser.getPreferences();
|
|
116
|
+
preferences.setPreferencesBundle(activity.getIntent().getExtras());
|
|
117
|
+
pluginEntries = parser.getPluginEntries();
|
|
118
|
+
}
|
|
113
119
|
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
@Override
|
|
121
|
+
public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) {
|
|
122
|
+
super.onInflate(context, attrs, savedInstanceState);
|
|
123
|
+
|
|
124
|
+
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.bridge_fragment);
|
|
125
|
+
CharSequence c = a.getString(R.styleable.bridge_fragment_start_dir);
|
|
126
|
+
|
|
127
|
+
if (c != null) {
|
|
128
|
+
String startDir = c.toString();
|
|
129
|
+
Bundle args = new Bundle();
|
|
130
|
+
args.putString(ARG_START_DIR, startDir);
|
|
131
|
+
setArguments(args);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@Override
|
|
136
|
+
public void onCreate(Bundle savedInstanceState) {
|
|
137
|
+
super.onCreate(savedInstanceState);
|
|
116
138
|
}
|
|
117
139
|
|
|
118
|
-
|
|
119
|
-
|
|
140
|
+
@Override
|
|
141
|
+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
142
|
+
// Inflate the layout for this fragment
|
|
143
|
+
return inflater.inflate(R.layout.fragment_bridge, container, false);
|
|
120
144
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
preferences = parser.getPreferences();
|
|
128
|
-
preferences.setPreferencesBundle(activity.getIntent().getExtras());
|
|
129
|
-
pluginEntries = parser.getPluginEntries();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
@Override
|
|
134
|
-
public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) {
|
|
135
|
-
super.onInflate(context, attrs, savedInstanceState);
|
|
136
|
-
|
|
137
|
-
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.bridge_fragment);
|
|
138
|
-
CharSequence c = a.getString(R.styleable.bridge_fragment_start_dir);
|
|
139
|
-
|
|
140
|
-
if (c != null) {
|
|
141
|
-
String startDir = c.toString();
|
|
142
|
-
Bundle args = new Bundle();
|
|
143
|
-
args.putString(ARG_START_DIR, startDir);
|
|
144
|
-
setArguments(args);
|
|
145
|
+
|
|
146
|
+
@Override
|
|
147
|
+
public void onActivityCreated(Bundle savedInstanceState) {
|
|
148
|
+
super.onActivityCreated(savedInstanceState);
|
|
149
|
+
this.init(savedInstanceState);
|
|
150
|
+
this.load(savedInstanceState);
|
|
145
151
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// Inflate the layout for this fragment
|
|
157
|
-
return inflater.inflate(R.layout.fragment_bridge, container, false);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
@Override
|
|
161
|
-
public void onActivityCreated(Bundle savedInstanceState) {
|
|
162
|
-
super.onActivityCreated(savedInstanceState);
|
|
163
|
-
this.init(savedInstanceState);
|
|
164
|
-
this.load(savedInstanceState);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
@Override
|
|
168
|
-
public void onAttach(Context context) {
|
|
169
|
-
super.onAttach(context);
|
|
170
|
-
if (context instanceof OnFragmentInteractionListener) {
|
|
171
|
-
mListener = (OnFragmentInteractionListener) context;
|
|
172
|
-
} else {
|
|
173
|
-
throw new RuntimeException(context.toString()
|
|
174
|
-
+ " must implement OnFragmentInteractionListener");
|
|
152
|
+
|
|
153
|
+
@Override
|
|
154
|
+
public void onDestroy() {
|
|
155
|
+
super.onDestroy();
|
|
156
|
+
if (this.bridge != null) {
|
|
157
|
+
this.bridge.onDestroy();
|
|
158
|
+
}
|
|
159
|
+
if (this.mockWebView != null) {
|
|
160
|
+
mockWebView.handleDestroy();
|
|
161
|
+
}
|
|
175
162
|
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@Override
|
|
179
|
-
public void onDetach() {
|
|
180
|
-
super.onDetach();
|
|
181
|
-
mListener = null;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* This interface must be implemented by activities that contain this
|
|
186
|
-
* fragment to allow an interaction in this fragment to be communicated
|
|
187
|
-
* to the activity and potentially other fragments contained in that
|
|
188
|
-
* activity.
|
|
189
|
-
* <p>
|
|
190
|
-
* See the Android Training lesson <a href=
|
|
191
|
-
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
|
192
|
-
* >Communicating with Other Fragments</a> for more information.
|
|
193
|
-
*/
|
|
194
|
-
public interface OnFragmentInteractionListener {
|
|
195
|
-
void onFragmentInteraction(Uri uri);
|
|
196
|
-
}
|
|
197
163
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/android",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "Capacitor: cross-platform mobile apps with the web",
|
|
5
5
|
"homepage": "https://capacitor.ionicframework.com/",
|
|
6
6
|
"author": "Ionic Team <hi@ionic.io> (https://ionicframework.com) ",
|