Sfoglia il codice sorgente

微信小程序埋点完成

huyuguo 4 anni fa
parent
commit
9fbdce0248

+ 11 - 12
app/src/main/java/com/electric/chargingpile/activity/HomeAdActivity.java

@ -3,7 +3,9 @@ package com.electric.chargingpile.activity;
3 3
import android.app.Activity;
4 4
import android.content.Intent;
5 5
import android.os.Bundle;
6
6 7
import androidx.constraintlayout.widget.ConstraintLayout;
8
7 9
import android.util.Log;
8 10
import android.view.View;
9 11
import android.widget.ImageView;
@ -47,10 +49,8 @@ public class HomeAdActivity extends Activity implements View.OnClickListener {
47 49
        super.onCreate(savedInstanceState);
48 50
        setContentView(R.layout.activity_home_ad);
49 51
        BarColorUtil.initStatusBarColor(HomeAdActivity.this);
50
        Log.e(TAG, "onCreate: 111" + 111);
51 52
        initViews();
52 53
        initDatas();
53
54 54
    }
55 55
56 56
    private void setTimer() {
@ -134,17 +134,16 @@ public class HomeAdActivity extends Activity implements View.OnClickListener {
134 134
135 135
    private void uploadDmp(String url) {
136 136
        url = Util.generateDmpUrl(url);
137
        OkHttpUtils.get().url(url).build().connTimeOut(3000).readTimeOut(3000)
138
                .execute(new StringCallback() {
139
                    @Override
140
                    public void onError(Call call, Exception e) {
141
                        e.printStackTrace();
142
                    }
137
        OkHttpUtils.get().url(url).build().connTimeOut(3000).readTimeOut(3000).execute(new StringCallback() {
138
            @Override
139
            public void onError(Call call, Exception e) {
140
                e.printStackTrace();
141
            }
143 142
144
                    @Override
145
                    public void onResponse(String response) {
146
                    }
147
                });
143
            @Override
144
            public void onResponse(String response) {
145
            }
146
        });
148 147
    }
149 148
150 149
    private void loadAdImage() {

+ 33 - 53
app/src/main/java/com/electric/chargingpile/activity/MyWebViewActivity.java

@ -19,8 +19,10 @@ import android.os.Bundle;
19 19
import android.os.Environment;
20 20
import android.os.Handler;
21 21
import android.provider.MediaStore;
22
22 23
import androidx.annotation.NonNull;
23 24
import androidx.core.content.FileProvider;
25
24 26
import android.util.Log;
25 27
import android.view.KeyEvent;
26 28
import android.view.View;
@ -43,6 +45,7 @@ import android.widget.Toast;
43 45
import com.afollestad.materialdialogs.DialogAction;
44 46
import com.afollestad.materialdialogs.MaterialDialog;
45 47
import com.blankj.utilcode.util.LogUtils;
48
import com.electric.chargingpile.BuildConfig;
46 49
import com.electric.chargingpile.R;
47 50
import com.electric.chargingpile.application.MainApplication;
48 51
import com.electric.chargingpile.data.ChargingShareBean;
@ -57,6 +60,9 @@ import com.electric.chargingpile.util.Util;
57 60
import com.electric.chargingpile.view.AlertDialogTwo;
58 61
import com.google.gson.Gson;
59 62
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
63
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
64
import com.tencent.mm.opensdk.openapi.IWXAPI;
65
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
60 66
import com.umeng.analytics.MobclickAgent;
61 67
import com.zhy.http.okhttp.OkHttpUtils;
62 68
import com.zhy.http.okhttp.callback.StringCallback;
@ -111,8 +117,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
111 117
        super.onCreate(savedInstanceState);
112 118
        setContentView(R.layout.activity_my_web_view);
113 119
        BarColorUtil.initStatusBarColor(MyWebViewActivity.this);
114
115
//        getShareIntegral();
116 120
        getIntentData();
117 121
        initView();
118 122
        initWebView();
@ -122,7 +126,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
122 126
        mUrl = getIntent().getStringExtra("url");
123 127
        advertiser = getIntent().getStringExtra("advertiser");
124 128
        Log.e(TAG, "getIntentData: " + mUrl);
125
        if (advertiser!=null && advertiser.equals("1")) {
129
        if (advertiser != null && advertiser.equals("1")) {
126 130
            mUrl = Util.generateDmpUrl(mUrl);
127 131
        }
128 132
    }
@ -161,15 +165,30 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
161 165
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
162 166
            webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
163 167
        }
164
//        webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
165 168
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
166 169
        webView.addJavascriptInterface(this, "cdz");
167 170
        webView.setWebViewClient(mWebViewClient);
168 171
        if (null != mUrl && !"".equals(mUrl)) {
172
            if (mUrl.contains("?")) {
173
                mUrl = mUrl + "&version_code=" + BuildConfig.VERSION_CODE;
174
            } else {
175
                mUrl = mUrl + "?version_code=" + BuildConfig.VERSION_CODE;
176
            }
169 177
            webView.loadUrl(mUrl);
170 178
        }
171 179
    }
172 180
181
    // 93 3.5.5 小程序埋点
182
    @JavascriptInterface
183
    public void showminiprogram(final String user_name, String path, int type) {
184
        IWXAPI api = WXAPIFactory.createWXAPI(MyWebViewActivity.this,getResources().getString(R.string.wx_app_key));
185
        WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
186
        req.userName = user_name;
187
        req.path = path;
188
        req.miniprogramType = type;
189
        api.sendReq(req);
190
    }
191
173 192
    @JavascriptInterface
174 193
    public void showsharebtn(final String show) {
175 194
        runOnUiThread(new Runnable() {
@ -189,12 +208,9 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
189 208
190 209
    @JavascriptInterface
191 210
    public void freshpage(final String url) {
192
        Log.e(TAG, "freshpage: url=" + url);
193 211
        list.add(url);
194
//        refreshUrl = url;
195 212
    }
196 213
197
198 214
    @JavascriptInterface
199 215
    public void setrctext(final String s) {
200 216
        Log.e(TAG, "setrctext: s=" + s);
@ -222,7 +238,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
222 238
223 239
    @JavascriptInterface
224 240
    public void emitshareinfo(String shareInfo) {
225
//        LogUtils.e(shareInfo);
226 241
//        "分享标题##分享描述##分享ico##分享url"
227 242
        String[] strarray = shareInfo.split("\\#\\#");
228 243
        if (strarray.length > 1) {
@ -332,7 +347,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
332 347
                        }
333 348
                    }
334 349
                }).build();
335
//        build.
336 350
        build.show();
337 351
    }
338 352
@ -362,7 +376,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
362 376
                        }
363 377
                    }
364 378
                }).build();
365
//        build.
366 379
        build.show();
367 380
    }
368 381
@ -379,7 +392,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
379 392
            @Override
380 393
            public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
381 394
                getShareIntegral();
382
//                ToastUtil.showToast(getApplicationContext(),"分享成功",Toast.LENGTH_SHORT);
383 395
            }
384 396
385 397
            @Override
@ -409,7 +421,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
409 421
                if (MainApplication.isLogin()) {
410 422
                    getShareIntegral();
411 423
                }
412
//                ToastUtil.showToast(getApplicationContext(),"分享成功",Toast.LENGTH_SHORT);
413 424
            }
414 425
415 426
            @Override
@ -434,7 +445,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
434 445
    public void telTask(final String s) {
435 446
        if (hasCallPhonePermission()) {
436 447
            // Have permission, do the thing!
437
//            Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
438 448
            new com.electric.chargingpile.view.AlertDialog(MyWebViewActivity.this).builder()
439 449
                    .setMsg(s)
440 450
                    .setPositiveButton("呼叫", new View.OnClickListener() {
@ -472,10 +482,10 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
472 482
        AlertDialogTwo wechatAlert = new AlertDialogTwo(MyWebViewActivity.this);
473 483
        wechatAlert.builder().setTitle("温馨提示")
474 484
                .setMsg("客服微信:chongdianzhuang2")
475
                .setPositiveButton("复制", new View.OnClickListener(){
485
                .setPositiveButton("复制", new View.OnClickListener() {
476 486
                    @Override
477 487
                    public void onClick(View view) {
478
                        ClipboardManager cm = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
488
                        ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
479 489
                        ClipData cdzData = ClipData.newPlainText("Label", "chongdianzhuang2");
480 490
                        cm.setPrimaryClip(cdzData);
481 491
                        ToastUtil.showToast(getApplicationContext(), "微信号复制成功", Toast.LENGTH_SHORT);
@ -835,10 +845,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
835 845
                }
836 846
            }
837 847
        };
838
        OkHttpUtils.get()
839
                .url(url)
840
                .build()
841
                .execute(stringCallback);
848
        OkHttpUtils.get().url(url).build().execute(stringCallback);
842 849
    }
843 850
844 851
    private void onResumeSkip() {
@ -897,7 +904,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
897 904
        for (int i = 0; i < list.size(); i++) {
898 905
            if (currentUrl.contains(list.get(i))) {
899 906
                Log.e(TAG, "onResume: =" + "========");
900
//                ToastUtil.showToast(getApplicationContext(),"1111",Toast.LENGTH_SHORT);
901 907
                webView.reload();
902 908
                list.remove(list.get(i));
903 909
                break;
@ -919,7 +925,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
919 925
            e.printStackTrace();
920 926
        }
921 927
        String replace = URLEncoder.encode(encode_token);
922
//                    startActivity(new Intent(getApplication(), ShopActivity.class));
923 928
        Intent intent11 = new Intent();
924 929
        intent11.setClass(getApplicationContext(), CreditActivity.class);
925 930
        intent11.putExtra("navColor", "#fcfcfc");    //配置导航条的背景颜色,请用#ffffff长格式。
@ -942,22 +947,12 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
942 947
             */
943 948
            public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
944 949
                //当分享按钮被点击时,会调用此处代码。在这里处理分享的业务逻辑。
945
//                            new AlertDialog.Builder(webView.getContext())
946
//                                    .setTitle("分享信息")
947
//                                    .setItems(new String[] {"标题:"+shareTitle,"副标题:"+shareSubtitle,"缩略图地址:"+shareThumbnail,"链接:"+shareUrl}, null)
948
//                                    .setNegativeButton("确定", null)
949
//                                    .show();
950
951 950
                ChargingShareBean chargingShareBean = new ChargingShareBean();
952 951
                chargingShareBean.setIcon(shareThumbnail);
953 952
                chargingShareBean.setTitle(shareTitle);
954 953
                chargingShareBean.setUrl(shareUrl);
955 954
                chargingShareBean.setText("");
956
957
958 955
                showSimpleBottomSheetGrid(chargingShareBean);
959
960
961 956
            }
962 957
963 958
            /**
@ -973,15 +968,12 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
973 968
                //当用户登录成功后,需要重新请求一次服务端,带上currentUrl。
974 969
                //用该方法中的webview变量加载请求链接。
975 970
                //服务端收到请求后在生成免登录url时,将currentUrl放入redirect参数,通知客户端302跳转到新生成的免登录URL。
976
                new AlertDialog.Builder(webView.getContext())
977
                        .setTitle("跳转登录")
978
                        .setMessage("跳转到登录页面?")
971
                new AlertDialog.Builder(webView.getContext()).setTitle("跳转登录").setMessage("跳转到登录页面?")
979 972
                        .setPositiveButton("是", new DialogInterface.OnClickListener() {
980 973
                            @Override
981 974
                            public void onClick(DialogInterface dialog, int which) {
982 975
                                MainApplication.current_url = currentUrl;
983 976
                                startActivity(new Intent(getApplicationContext(), LoginActivity.class));
984
985 977
                            }
986 978
                        })
987 979
                        .setNegativeButton("否", null)
@ -1009,7 +1001,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1009 1001
            public void onLocalRefresh(WebView mWebView, String credits) {
1010 1002
                //String credits为积分商城返回的最新积分,不保证准确。
1011 1003
                //触发更新本地积分,这里建议用ajax向自己服务器请求积分值,比较准确。
1012
//                    Toast.makeText(getApplicationContext(), "触发本地刷新积分:"+credits,Toast.LENGTH_SHORT).show();
1013 1004
            }
1014 1005
        };
1015 1006
    }
@ -1052,11 +1043,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1052 1043
             */
1053 1044
            public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
1054 1045
                //当分享按钮被点击时,会调用此处代码。在这里处理分享的业务逻辑。
1055
//                            new AlertDialog.Builder(webView.getContext())
1056
//                                    .setTitle("分享信息")
1057
//                                    .setItems(new String[] {"标题:"+shareTitle,"副标题:"+shareSubtitle,"缩略图地址:"+shareThumbnail,"链接:"+shareUrl}, null)
1058
//                                    .setNegativeButton("确定", null)
1059
//                                    .show();
1060 1046
                ChargingShareBean chargingShareBean = new ChargingShareBean();
1061 1047
                chargingShareBean.setIcon(shareThumbnail);
1062 1048
                chargingShareBean.setTitle(shareTitle);
@ -1086,7 +1072,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1086 1072
                        .setPositiveButton("是", new DialogInterface.OnClickListener() {
1087 1073
                            @Override
1088 1074
                            public void onClick(DialogInterface dialog, int which) {
1089
//                                        MainApplication.current_url = currentUrl;
1090 1075
                                MainApplication.h5_url = currentUrl;
1091 1076
                                startActivity(new Intent(getApplicationContext(), LoginActivity.class));
1092 1077
@ -1117,7 +1102,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1117 1102
            public void onLocalRefresh(WebView mWebView, String credits) {
1118 1103
                //String credits为积分商城返回的最新积分,不保证准确。
1119 1104
                //触发更新本地积分,这里建议用ajax向自己服务器请求积分值,比较准确。
1120
//                    Toast.makeText(getApplicationContext(), "触发本地刷新积分:" + credits, Toast.LENGTH_SHORT).show();
1121 1105
            }
1122 1106
        };
1123 1107
    }
@ -1240,10 +1224,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1240 1224
            mOpenFileWebChromeClient.mFilePathCallback = null;
1241 1225
            mOpenFileWebChromeClient.mFilePathCallbacks = null;
1242 1226
        }
1243
//        if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
1244
//            new AppSettingsDialog.Builder(MyWebViewActivity.this,
1245
//                    "该功能需要开启拨号权限,是否前往开启?").build().show();
1246
//        }
1247 1227
    }
1248 1228
1249 1229
    private boolean hasCallPhonePermission() {
@ -1351,7 +1331,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1351 1331
                .canceledOnTouchOutside(false).itemsCallback(new MaterialDialog.ListCallback() {
1352 1332
            @Override
1353 1333
            public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
1354
                if (position == 0){
1334
                if (position == 0) {
1355 1335
                    takeCamera();
1356 1336
                } else if (position == 1) {
1357 1337
                    takePhoto();
@ -1377,7 +1357,7 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1377 1357
            File imageFile = ImageUitl.getFile(cameraFilePath);
1378 1358
            Uri uri = parseUri(imageFile);
1379 1359
            intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
1380
            try{
1360
            try {
1381 1361
                startActivityForResult(intent, FILE_CAMERA_RESULT_CODE);
1382 1362
            } catch (Exception e) {
1383 1363
                e.printStackTrace();
@ -1432,7 +1412,6 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1432 1412
                    intent.setData(Uri.parse(url));
1433 1413
                    startActivity(intent);
1434 1414
                } catch (ActivityNotFoundException e) {
1435
//                        MiscUtil.toastShortShow(mContext, "请安装微信最新版!");
1436 1415
                }
1437 1416
            } else if (url.startsWith("tel:")) {
1438 1417
                Intent intent = new Intent(Intent.ACTION_VIEW,
@ -1450,7 +1429,8 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1450 1429
    @Override
1451 1430
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
1452 1431
        super.onActivityResult(requestCode, resultCode, data);
1453
        if (null == mOpenFileWebChromeClient.mFilePathCallback && null == mOpenFileWebChromeClient.mFilePathCallbacks) return;
1432
        if (null == mOpenFileWebChromeClient.mFilePathCallback && null == mOpenFileWebChromeClient.mFilePathCallbacks)
1433
            return;
1454 1434
        if (resultCode != RESULT_OK) {
1455 1435
            if (mOpenFileWebChromeClient.mFilePathCallbacks != null) {
1456 1436
                mOpenFileWebChromeClient.mFilePathCallbacks.onReceiveValue(null);
@ -1501,13 +1481,13 @@ public class MyWebViewActivity extends Activity implements PlatformActionListene
1501 1481
            ClipData clipData = intent.getClipData();
1502 1482
            if (clipData != null) {
1503 1483
                results = new Uri[clipData.getItemCount()];
1504
                for (int i=0;i<clipData.getItemCount();i++) {
1484
                for (int i = 0; i < clipData.getItemCount(); i++) {
1505 1485
                    ClipData.Item item = clipData.getItemAt(i);
1506 1486
                    results[i] = item.getUri();
1507 1487
                }
1508 1488
            }
1509 1489
            if (dataString != null) {
1510
                results = new Uri[] {Uri.parse(dataString)};
1490
                results = new Uri[]{Uri.parse(dataString)};
1511 1491
            }
1512 1492
            mOpenFileWebChromeClient.mFilePathCallbacks.onReceiveValue(results);
1513 1493
            mOpenFileWebChromeClient.mFilePathCallbacks = null;

+ 17 - 80
app/src/main/java/com/electric/chargingpile/activity/WelcomeActivity.java

@ -14,9 +14,11 @@ import android.os.Bundle;
14 14
import android.os.Environment;
15 15
import android.os.Handler;
16 16
import android.os.Message;
17

17 18
import androidx.annotation.NonNull;
18 19
import androidx.viewpager.widget.ViewPager;
19 20
import androidx.appcompat.app.AlertDialog;
21

20 22
import android.util.Log;
21 23
import android.view.LayoutInflater;
22 24
import android.view.View;
@ -113,21 +115,10 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
113 115
        public void handleMessage(Message msg) {
114 116
            switch (msg.what) {
115 117
                case 1:
116

117 118
                    try {
118

119 119
                        JSONArray jsonArray = new JSONArray(msg.obj.toString());
120

121 120
                        JSONObject jsonObj = new JSONObject(jsonArray.get(0).toString());
122 121
                        img = jsonObj.getString("img");
123

124

125
//                        Log.e("!!!!!pic", MainApplication.url + "/zhannew//uploadfile/" + img);
126

127
//						JSONObject jsonObj = new JSONObject(msg.obj.toString());
128
//						final String img = jsonObj.getString("img");
129

130

131 122
                    } catch (JSONException e) {
132 123
                        e.printStackTrace();
133 124
                    }
@ -167,16 +158,13 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
167 158
                                intent.putExtra("is_dui", is_dui);
168 159
                                startActivity(intent);
169 160
                                finish();
170
//                                mTimer.cancel();
171 161
                                overridePendingTransition(0, 0);
172 162
                            } else {
173 163
                                new Handler().postDelayed(new Runnable() {
174 164
                                    @Override
175 165
                                    public void run() {
176
                                        startActivity(new Intent(WelcomeActivity.this,
177
                                                MainMapActivity.class));
166
                                        startActivity(new Intent(WelcomeActivity.this, MainMapActivity.class));
178 167
                                        finish();
179
//                                        mTimer.cancel();
180 168
                                    }
181 169
                                }, 2000);
182 170
                            }
@ -215,16 +203,12 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
215 203
                                MainApplication.huodonglabel = JsonUtils.getKeyResult(s, "meg");
216 204
                            }
217 205
                        }
218
//                        Toast.makeText(getApplicationContext(),MainApplication.huodonglabel,Toast.LENGTH_SHORT).show();
219 206
                        if (EmptyUtils.isEmpty(ad)) {
220 207
                            new Handler().postDelayed(new Runnable() {
221 208
                                @Override
222 209
                                public void run() {
223
//                                    LogUtils.e("123123");
224
                                    startActivity(new Intent(WelcomeActivity.this,
225
                                            MainMapActivity.class));
210
                                    startActivity(new Intent(WelcomeActivity.this, MainMapActivity.class));
226 211
                                    finish();
227
//                                    mTimer.cancel();
228 212
                                }
229 213
                            }, 1000);
230 214
                        }
@ -253,7 +237,7 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
253 237
                                intent.putExtra("icon", icon);
254 238
                                intent.putExtra("title", title);
255 239
                                intent.putExtra("is_dui", is_dui);
256
                                intent.putExtra("advertiser",advertiser);
240
                                intent.putExtra("advertiser", advertiser);
257 241
                                startActivity(intent);
258 242
                                finish();
259 243
                                overridePendingTransition(0, 0);
@ -261,8 +245,7 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
261 245
                                new Handler().postDelayed(new Runnable() {
262 246
                                    @Override
263 247
                                    public void run() {
264
                                        startActivity(new Intent(WelcomeActivity.this,
265
                                                MainMapActivity.class));
248
                                        startActivity(new Intent(WelcomeActivity.this, MainMapActivity.class));
266 249
                                        finish();
267 250
                                    }
268 251
                                }, 2000);
@ -309,14 +292,10 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
309 292
            viewPager = (ViewPager) findViewById(R.id.viewpager);
310 293
            viewPager.setVisibility(View.VISIBLE);
311 294
            views = new ArrayList<View>();
312
            one = LayoutInflater.from(this).inflate(
313
                    R.layout.viewpager_guide_one, null);
314
            two = LayoutInflater.from(this).inflate(
315
                    R.layout.viewpager_guide_two, null);
316
            three = LayoutInflater.from(this).inflate(
317
                    R.layout.viewpager_guide_three, null);
318
            four = LayoutInflater.from(this).inflate(
319
                    R.layout.viewpager_guide_four, null);
295
            one = LayoutInflater.from(this).inflate(R.layout.viewpager_guide_one, null);
296
            two = LayoutInflater.from(this).inflate(R.layout.viewpager_guide_two, null);
297
            three = LayoutInflater.from(this).inflate(R.layout.viewpager_guide_three, null);
298
            four = LayoutInflater.from(this).inflate(R.layout.viewpager_guide_four, null);
320 299
            enter = (ImageView) four.findViewById(R.id.bt_enter);
321 300
            enter.setOnClickListener(this);
322 301

@ -373,18 +352,14 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
373 352
                    }
374 353
                    socket = new Socket(host, 9503);
375 354
                    // 向服务器发送消息
376
                    PrintWriter out = new PrintWriter(new BufferedWriter(
377
                            new OutputStreamWriter(socket.getOutputStream())), true);
355
                    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);
378 356
                    out.println(params);
379 357
                    // out.println("{\"fun\":\"getcity\"}");
380 358
                    // 接收来自服务器的消息
381
                    BufferedReader br = new BufferedReader(new InputStreamReader(
382
                            socket.getInputStream()));
359
                    BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
383 360

384 361
                    String msg = br.readLine();
385
//                    Log.d("dddddss",msg);
386 362
                    String token = msg;
387
//                    Log.e("msg_init", msg);
388 363
                    int time = (int) (System.currentTimeMillis() / 1000);
389 364

390 365
                    MainMapActivity.cha = time - Integer.parseInt(msg);
@ -396,7 +371,7 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
396 371
                    initParams.append(",\"h\":\"" + Utils.getScreenHeight(WelcomeActivity.this) + "\"");
397 372
                    initParams.append(",\"version_name\":\"" + BuildConfig.VERSION_NAME + "\"");
398 373
                    initParams.append(",\"version_code\":\"" + BuildConfig.VERSION_CODE + "\"");
399
                    initParams.append(",\"os\":\"android "+ Build.VERSION.RELEASE +"\""); // 操作系统及版本
374
                    initParams.append(",\"os\":\"android " + Build.VERSION.RELEASE + "\""); // 操作系统及版本
400 375
                    initParams.append(",\"brand\":\"" + Build.BRAND + "\""); // 品牌
401 376
                    initParams.append(",\"model\":\"" + Build.MODEL + "\""); // 型号
402 377
                    initParams.append("}");
@ -422,18 +397,11 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
422 397
                        host = "59.110.68.162";
423 398
                    }
424 399
                    socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
425
//                    SocketAddress socAddress = new InetSocketAddress("cdz.d1ev.com", 9503);
426
//                    socket.connect(socAddress, 5000);
427 400
                    // 向服务器发送消息
428
                    PrintWriter out = new PrintWriter(new BufferedWriter(
429
                            new OutputStreamWriter(socket.getOutputStream())), true);
401
                    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);
430 402
                    out.println(params);
431
                    // out.println("{\"fun\":\"getcity\"}");
432 403
                    // 接收来自服务器的消息
433
                    BufferedReader br = new BufferedReader(new InputStreamReader(
434
                            socket.getInputStream()));
435

436

404
                    BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
437 405
                    String msg = br.readLine();
438 406
                    if (msg != null) {
439 407
                        Message mes = new Message();
@ -442,15 +410,11 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
442 410
                        handler.sendMessage(mes);
443 411
                        mTimer.cancel();
444 412
                    }
445

446

447 413
                } catch (Exception e) {
448 414
                    e.printStackTrace();
449

450 415
                }
451 416
            }
452 417
        }).start();
453

454 418
    }
455 419

456 420

@ -478,16 +442,11 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
478 442
        Drawable drawable = null;
479 443
        try {
480 444
            // 可以在这里通过文件名来判断,是否本地有此图片
481

482
            drawable = Drawable.createFromStream(
483
                    new URL(imageUrl).openStream(), "adout.jpg");
484

445
            drawable = Drawable.createFromStream(new URL(imageUrl).openStream(), "adout.jpg");
485 446
            Message msg = new Message();
486 447
            msg.obj = drawable;
487 448
            msg.what = 19;
488 449
            handler.sendMessage(msg);
489

490

491 450
        } catch (IOException e) {
492 451
            Log.d("test", e.getMessage());
493 452
        }
@ -501,7 +460,6 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
501 460
    }
502 461

503 462

504

505 463
    public void saveBitmap(Bitmap mBitmap) {
506 464
        String dir_path = Environment.getExternalStorageDirectory() + File.separator + "d1ev/";
507 465
        File directory = new File(dir_path);
@ -542,11 +500,8 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
542 500
                    long appTime1 = System.currentTimeMillis() / 1000;
543 501
                    long updatetime = appTime1 - 7200;
544 502
                    String token = String.valueOf(updatetime);
545

546 503
                    String replace = URLEncoder.encode(DES3.encode(token));
547

548 504
                    url = MainApplication.url + "/zhannew/basic/web/index.php/ad/get?timer=" + replace;
549

550 505
                } catch (Exception e) {
551 506
                    e.printStackTrace();
552 507
                }
@ -575,8 +530,6 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
575 530
                    msg.obj = json;
576 531
                    msg.what = 1;
577 532
                    handler.sendMessage(msg);
578
                    Log.e("url", json);
579
//                    Log.i("token解密:", DES3.decode(encode_token));
580 533
                } catch (Exception e) {
581 534
                    e.printStackTrace();
582 535
                    Message msg = new Message();
@ -628,10 +581,8 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
628 581
        String operator = ProfileManager.getInstance().getKeyOperator(getApplicationContext());
629 582
        String localOperators = "";
630 583
        if (StringUtils.isEmpty(operator)) {
631
//            LogUtils.e("读取本地");
632 584
            localOperators = getResources().getString(R.string.app_operator_list);
633 585
        } else {
634
//            LogUtils.e("读取缓存");
635 586
            localOperators = operator;
636 587
        }
637 588
        Gson gson = new Gson();
@ -661,7 +612,6 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
661 612
                if (code.equals("200")) {
662 613
                    String data = JsonUtils.getKeyResult(response, "data");
663 614
                    ProfileManager.getInstance().setAppOperator(getApplicationContext(), data);
664
//                    LogUtils.e(ProfileManager.getInstance().getKeyOperator(getApplicationContext()));
665 615
                    Gson gson = new Gson();
666 616
                    ll = gson.fromJson(data, new TypeToken<List<OperatorData>>() {
667 617
                    }.getType());
@ -676,9 +626,7 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
676 626
    }
677 627

678 628
    @Override
679
    public void onRequestPermissionsResult(int requestCode,
680
                                           @NonNull String[] permissions,
681
                                           @NonNull int[] grantResults) {
629
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
682 630
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
683 631
        // EasyPermissions handles the request result.
684 632
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
@ -686,7 +634,6 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
686 634

687 635
    @Override
688 636
    public void onPermissionsGranted(int requestCode, List<String> perms) {
689
        LogUtils.e("onPermissionsGranted");
690 637
        for (String s : perms) {
691 638
            if (s.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
692 639
                new Handler().postDelayed(new Runnable() {
@ -702,7 +649,6 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
702 649

703 650
    @Override
704 651
    public void onPermissionsDenied(int requestCode, List<String> perms) {
705
        LogUtils.e("onPermissionsDenied");
706 652
        for (String s : perms) {
707 653
            if (s.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
708 654
                AlertDialog.Builder builder = new AlertDialog.Builder(WelcomeActivity.this);
@ -722,16 +668,11 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
722 668
            }
723 669
            break;
724 670
        }
725

726

727 671
    }
728 672

729 673
    @AfterPermissionGranted(RC_CAMERA_PERM)
730 674
    public void cameraTask() {
731 675
        if (isPermissionOK()) {
732
            // Have permission, do the thing!
733
//            Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
734
//            ifTimeout();
735 676
        } else {
736 677
            // Ask for one permission
737 678
            EasyPermissions.requestPermissions(
@ -754,8 +695,6 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
754 695
                }
755 696
            }, 1000);
756 697
            // Have permission, do the thing!
757
//            Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
758
//            ifTimeout();
759 698
        } else {
760 699
            // Ask for one permission
761 700
            EasyPermissions.requestPermissions(
@ -804,6 +743,4 @@ public class WelcomeActivity extends Activity implements OnClickListener, EasyPe
804 743
            }
805 744
        }
806 745
    }
807

808

809 746
}

+ 13 - 0
app/src/main/java/com/electric/chargingpile/wxapi/WXEntryActivity.java

@ -12,6 +12,11 @@ import android.content.Intent;
12 12
import android.os.Bundle;
13 13
import android.os.PersistableBundle;
14 14
import android.widget.Toast;
15
16
import com.tencent.mm.opensdk.constants.ConstantsAPI;
17
import com.tencent.mm.opensdk.modelbase.BaseResp;
18
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
19
15 20
import cn.sharesdk.wechat.utils.WXAppExtendObject;
16 21
import cn.sharesdk.wechat.utils.WXMediaMessage;
17 22
import cn.sharesdk.wechat.utils.WechatHandlerActivity;
@ -57,5 +62,13 @@ public class WXEntryActivity extends WechatHandlerActivity {
57 62
        }
58 63
    }
59 64
65
    public void onResp(BaseResp resp) {
66
        if (resp.getType() == ConstantsAPI.COMMAND_LAUNCH_WX_MINIPROGRAM) {
67
            WXLaunchMiniProgram.Resp launchMiniProResp = (WXLaunchMiniProgram.Resp) resp;
68
            String extraData = launchMiniProResp.extMsg;
69
            System.out.println(extraData);
70
        }
71
    }
72
60 73
61 74
}

+ 4 - 1
app/src/main/res/layout/activity_welcome.xml

@ -1,5 +1,6 @@
1 1
<?xml version="1.0" encoding="utf-8"?>
2 2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:tools="http://schemas.android.com/tools"
3 4
    android:id="@+id/rl_welcome"
4 5
    android:layout_width="match_parent"
5 6
    android:layout_height="match_parent">
@ -12,6 +13,7 @@
12 13
        android:layout_centerVertical="true"
13 14
        android:background="#ffffff"
14 15
        android:orientation="vertical">
16

15 17
        <ImageView
16 18
            android:id="@+id/img_welcome"
17 19
            android:layout_width="160dp"
@ -20,7 +22,8 @@
20 22
            android:layout_marginTop="240dp"
21 23
            android:contentDescription="@null"
22 24
            android:src="@drawable/bg_welcome_text"
23
            android:visibility="visible" />
25
            android:visibility="visible"
26
            tools:visibility="gone" />
24 27
    </LinearLayout>
25 28
    <!-- logo end    -->
26 29