|
@ -23,6 +23,7 @@ import android.provider.MediaStore;
|
23
|
23
|
import androidx.annotation.NonNull;
|
24
|
24
|
import androidx.core.content.FileProvider;
|
25
|
25
|
|
|
26
|
import android.text.TextUtils;
|
26
|
27
|
import android.util.Log;
|
27
|
28
|
import android.view.KeyEvent;
|
28
|
29
|
import android.view.View;
|
|
@ -111,6 +112,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
111
|
112
|
private final static int FILE_CHOOSER_RESULT_CODE = 128; // 图片
|
112
|
113
|
private final static int FILE_CAMERA_RESULT_CODE = 129; // 拍照
|
113
|
114
|
private String cameraFilePath; // 拍照图片路径
|
|
115
|
private boolean loginToShare;
|
114
|
116
|
|
115
|
117
|
@Override
|
116
|
118
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@ -174,6 +176,10 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
174
|
176
|
} else {
|
175
|
177
|
mUrl = mUrl + "?version_code=" + BuildConfig.VERSION_CODE + "&from=cdz&system=android";
|
176
|
178
|
}
|
|
179
|
if (MainApplication.isLogin()) {
|
|
180
|
mUrl = mUrl + "&phone=" + MainApplication.userPhone;
|
|
181
|
}
|
|
182
|
|
177
|
183
|
webView.loadUrl(mUrl);
|
178
|
184
|
}
|
179
|
185
|
}
|
|
@ -182,7 +188,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
182
|
188
|
@JavascriptInterface
|
183
|
189
|
public void showminiprogram(final String user_name, String path, int type) {
|
184
|
190
|
if (Util.isWxAppInstalledAndSupported(MyWebViewActivity.this)) {
|
185
|
|
IWXAPI api = WXAPIFactory.createWXAPI(MyWebViewActivity.this,getResources().getString(R.string.wx_app_key));
|
|
191
|
IWXAPI api = WXAPIFactory.createWXAPI(MyWebViewActivity.this, getResources().getString(R.string.wx_app_key));
|
186
|
192
|
WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
|
187
|
193
|
req.userName = user_name;
|
188
|
194
|
req.path = path;
|
|
@ -194,6 +200,18 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
194
|
200
|
}
|
195
|
201
|
|
196
|
202
|
@JavascriptInterface
|
|
203
|
public void welfareshare(final String shareUrl) {
|
|
204
|
if (TextUtils.isEmpty(shareUrl)) {
|
|
205
|
loginToShare = true;
|
|
206
|
startActivity(new Intent(getApplicationContext(), LoginActivity.class));
|
|
207
|
ToastUtil.showToast(getApplicationContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
208
|
} else {
|
|
209
|
loginToShare = false;
|
|
210
|
showSimpleBottomSheetGrid(shareUrl);
|
|
211
|
}
|
|
212
|
}
|
|
213
|
|
|
214
|
@JavascriptInterface
|
197
|
215
|
public void showsharebtn(final String show) {
|
198
|
216
|
runOnUiThread(new Runnable() {
|
199
|
217
|
@Override
|
|
@ -322,10 +340,10 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
322
|
340
|
}
|
323
|
341
|
|
324
|
342
|
private void btnToShare() {
|
325
|
|
showSimpleBottomSheetGrid();
|
|
343
|
showSimpleBottomSheetGrid(shareUrl);
|
326
|
344
|
}
|
327
|
345
|
|
328
|
|
private void showSimpleBottomSheetGrid() {
|
|
346
|
private void showSimpleBottomSheetGrid(final String shareUrl) {
|
329
|
347
|
final int TAG_SHARE_WECHAT_FRIEND = 0;
|
330
|
348
|
final int TAG_SHARE_WECHAT_MOMENT = 1;
|
331
|
349
|
final int TAG_SHARE_QQ = 2;
|
|
@ -340,13 +358,13 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
340
|
358
|
int tag = (int) itemView.getTag();
|
341
|
359
|
switch (tag) {
|
342
|
360
|
case TAG_SHARE_WECHAT_FRIEND:
|
343
|
|
share(Wechat.NAME);
|
|
361
|
share(Wechat.NAME, shareUrl);
|
344
|
362
|
break;
|
345
|
363
|
case TAG_SHARE_WECHAT_MOMENT:
|
346
|
|
share(WechatMoments.NAME);
|
|
364
|
share(WechatMoments.NAME, shareUrl);
|
347
|
365
|
break;
|
348
|
366
|
case TAG_SHARE_QQ:
|
349
|
|
share(QQ.NAME);
|
|
367
|
share(QQ.NAME, shareUrl);
|
350
|
368
|
break;
|
351
|
369
|
}
|
352
|
370
|
}
|
|
@ -383,7 +401,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
383
|
401
|
build.show();
|
384
|
402
|
}
|
385
|
403
|
|
386
|
|
private void share(final String name) {
|
|
404
|
private void share(final String name, final String shareUrl) {
|
387
|
405
|
Platform.ShareParams paramsToShare = new Platform.ShareParams();
|
388
|
406
|
paramsToShare.setText(shareContext);
|
389
|
407
|
paramsToShare.setTitle(shareTitle);
|
|
@ -441,7 +459,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
441
|
459
|
|
442
|
460
|
@JavascriptInterface
|
443
|
461
|
public void gotoshare() {
|
444
|
|
showSimpleBottomSheetGrid();
|
|
462
|
showSimpleBottomSheetGrid(shareUrl);
|
445
|
463
|
}
|
446
|
464
|
|
447
|
465
|
|
|
@ -913,6 +931,15 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
913
|
931
|
break;
|
914
|
932
|
}
|
915
|
933
|
}
|
|
934
|
|
|
935
|
if (null != mUrl && !"".equals(mUrl) && loginToShare) {
|
|
936
|
if (!mUrl.contains("&phone=")) {
|
|
937
|
if (MainApplication.isLogin()) {
|
|
938
|
mUrl = mUrl + "&phone=" + MainApplication.userPhone;
|
|
939
|
webView.loadUrl(mUrl);
|
|
940
|
}
|
|
941
|
}
|
|
942
|
}
|
916
|
943
|
}
|
917
|
944
|
|
918
|
945
|
private void skipShopCenter() {
|
|
@ -1070,7 +1097,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
1070
|
1097
|
//当用户登录成功后,需要重新请求一次服务端,带上currentUrl。
|
1071
|
1098
|
//用该方法中的webview变量加载请求链接。
|
1072
|
1099
|
//服务端收到请求后在生成免登录url时,将currentUrl放入redirect参数,通知客户端302跳转到新生成的免登录URL。
|
1073
|
|
new android.app.AlertDialog.Builder(webView.getContext())
|
|
1100
|
new AlertDialog.Builder(webView.getContext())
|
1074
|
1101
|
.setTitle("跳转登录")
|
1075
|
1102
|
.setMessage("跳转到登录页面?")
|
1076
|
1103
|
.setPositiveButton("是", new DialogInterface.OnClickListener() {
|
|
@ -1092,7 +1119,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
1092
|
1119
|
*/
|
1093
|
1120
|
public void onCopyCode(WebView webView, String code) {
|
1094
|
1121
|
//当未登录的用户点击去登录时,会调用此处代码。
|
1095
|
|
new android.app.AlertDialog.Builder(webView.getContext())
|
|
1122
|
new AlertDialog.Builder(webView.getContext())
|
1096
|
1123
|
.setTitle("复制券码")
|
1097
|
1124
|
.setMessage("已复制,券码为:" + code)
|
1098
|
1125
|
.setPositiveButton("是", null)
|
|
@ -1262,7 +1289,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
|
1262
|
1289
|
public void onGeolocationPermissionsShowPrompt(String origin,
|
1263
|
1290
|
GeolocationPermissions.Callback callback) {
|
1264
|
1291
|
callback.invoke(origin, true, false);
|
1265
|
|
// TODO Auto-generated method stub
|
1266
|
1292
|
super.onGeolocationPermissionsShowPrompt(origin, callback);
|
1267
|
1293
|
}
|
1268
|
1294
|
|