Browse Source

代码提交

huyuguo 4 years ago
parent
commit
4811a8baed

+ 9 - 4
app/src/main/java/com/electric/chargingpile/activity/AboutActivity.java

30
import java.io.IOException;
30
import java.io.IOException;
31
import java.util.List;
31
import java.util.List;
32

32

33
import pub.devrel.easypermissions.AfterPermissionGranted;
34
import pub.devrel.easypermissions.AppSettingsDialog;
33
import pub.devrel.easypermissions.AppSettingsDialog;
35
import pub.devrel.easypermissions.EasyPermissions;
34
import pub.devrel.easypermissions.EasyPermissions;
36

35

62
        getVersion();
61
        getVersion();
63
    }
62
    }
64

63

64
    public void onAgreementView(View view) {
65
        Intent xieyiintent = new Intent(getApplication(), MyWebViewActivity.class);
66
        xieyiintent.putExtra("url", "http://evcharge.cc/activity/user-proto.html");
67
        startActivity(xieyiintent);
68
    }
69

65
    public void onPrivacyView(View view) {
70
    public void onPrivacyView(View view) {
66
        Intent intent = new Intent(getApplication(), IntegralDescriptionActivity.class);
67
        intent.putExtra("url", "http://evcharge.cc/pc/agreement.html");
68
        startActivity(intent);
71
        Intent yinsintent = new Intent(getApplication(), MyWebViewActivity.class);
72
        yinsintent.putExtra("url", "http://evcharge.cc/pc/privacy.html");
73
        startActivity(yinsintent);
69
    }
74
    }
70

75

71
    public void getVersion() {
76
    public void getVersion() {

+ 33 - 6
app/src/main/java/com/electric/chargingpile/activity/MainMapActivity.java

378
    public static boolean isStatusBack = false;
378
    public static boolean isStatusBack = false;
379
379
380
    private static final int RC_CAMERA_PERM = 123;
380
    private static final int RC_CAMERA_PERM = 123;
381
    private static final int RC_Location_PERM = 124;
381
    private static final int RC_Location_FIRST_PERM = 124;
382
    private static final int RC_Location_PERM = 125;
382
383
383
    private String adfloatUrl = "";
384
    private String adfloatUrl = "";
384
385
726
    @Override
727
    @Override
727
    protected void onCreate(Bundle savedInstanceState) {
728
    protected void onCreate(Bundle savedInstanceState) {
728
        super.onCreate(savedInstanceState);
729
        super.onCreate(savedInstanceState);
730
        MainApplication.getInstance().initJPush();
729
        AutoLayout.getInstance().auto(this);
731
        AutoLayout.getInstance().auto(this);
730
        setContentView(R.layout.activity_main_map);
732
        setContentView(R.layout.activity_main_map);
731
        BarColorUtil.initStatusBarColor(MainMapActivity.this);
733
        BarColorUtil.initStatusBarColor(MainMapActivity.this);
1385
        detailsBack = false;
1387
        detailsBack = false;
1386
1388
1387
        changeButton();
1389
        changeButton();
1390
1391
        if (hasLocationPermission() && center == null) {
1392
            mlocationClient.startLocation();
1393
        }
1388
    }
1394
    }
1389
1395
1390
    private void searchAll() {
1396
    private void searchAll() {
1446
    }
1452
    }
1447
1453
1448
1454
1449
1450
    /**
1455
    /**
1451
     * 方法必须重写
1456
     * 方法必须重写
1452
     */
1457
     */
1510
            //设置是否强制刷新WIFI,默认为强制刷新
1515
            //设置是否强制刷新WIFI,默认为强制刷新
1511
            //mLocationOption.setWifiActiveScan(false);
1516
            //mLocationOption.setWifiActiveScan(false);
1512
            mLocationOption.setWifiScan(true);
1517
            mLocationOption.setWifiScan(true);
1513
1514
            if (!ProfileManager.getInstance().getRequestLocationPermission(MainMapActivity.this)) {
1515
                requestLocationPermission();
1518
            if (ProfileManager.getInstance().getRequestLocationPermission(MainMapActivity.this)) {
1519
                if (hasLocationPermission()) {
1520
                    requestLocationPermission();
1521
                }
1522
            } else { // 首次启动
1516
                ProfileManager.getInstance().setRequestLocationPermission(MainMapActivity.this, true);
1523
                ProfileManager.getInstance().setRequestLocationPermission(MainMapActivity.this, true);
1524
                EasyPermissions.requestPermissions(
1525
                        this,
1526
                        "为了定位您的位置,推荐充电桩,充电桩位置路线导航需要开启位置权限,是否前往开启?",
1527
                        RC_Location_FIRST_PERM,
1528
                        Manifest.permission.ACCESS_FINE_LOCATION);
1517
            }
1529
            }
1518
        }
1530
        }
1519
    }
1531
    }
2778
2790
2779
    @Override
2791
    @Override
2780
    public void onPermissionsDenied(int requestCode, List<String> perms) {
2792
    public void onPermissionsDenied(int requestCode, List<String> perms) {
2793
        if (SystemTypeUtil.isEmui()) {
2794
            return;
2795
        }
2781
        if (requestCode == RC_CAMERA_PERM) {
2796
        if (requestCode == RC_CAMERA_PERM) {
2782
            new AlertDialogCommon(MainMapActivity.this).builder()
2797
            new AlertDialogCommon(MainMapActivity.this).builder()
2783
                    .setMsg("扫码充电需要开启位置权限,是否前往开启?")
2798
                    .setMsg("扫码充电需要开启位置权限,是否前往开启?")
2805
                }
2820
                }
2806
            }).show();
2821
            }).show();
2807
        }
2822
        }
2808
2809
    }
2823
    }
2810
2824
2811
    @Override
2825
    @Override
2819
                Manifest.permission.ACCESS_FINE_LOCATION
2833
                Manifest.permission.ACCESS_FINE_LOCATION
2820
        );
2834
        );
2821
    }
2835
    }
2836
2837
    @AfterPermissionGranted(RC_Location_FIRST_PERM)
2838
    public void requestLocationFirstPermission() {
2839
        if (hasLocationPermission()) {
2840
            mlocationClient.startLocation();
2841
        }
2842
    }
2843
2822
    @AfterPermissionGranted(RC_Location_PERM)
2844
    @AfterPermissionGranted(RC_Location_PERM)
2823
    public void requestLocationPermission() {
2845
    public void requestLocationPermission() {
2824
        if (hasLocationPermission()) {
2846
        if (hasLocationPermission()) {
4928
     * add by hyg
4950
     * add by hyg
4929
     */
4951
     */
4930
    private void infoViewNavigate() {
4952
    private void infoViewNavigate() {
4953
        if (!hasLocationPermission()) {
4954
            requestLocationPermission();
4955
            return;
4956
        }
4957
4931
        if (zhanInfo == null) {
4958
        if (zhanInfo == null) {
4932
            return;
4959
            return;
4933
        }
4960
        }

+ 6 - 4
app/src/main/java/com/electric/chargingpile/application/MainApplication.java

155
        Utils.init(this);
155
        Utils.init(this);
156
        LogUtils.getConfig().setLogSwitch(true);
156
        LogUtils.getConfig().setLogSwitch(true);
157

157

158
        //极光
159
        JPushInterface.setDebugMode(false);
160
        JPushInterface.init(this);
161

162
        CrashReport.initCrashReport(getApplicationContext(), "900010422", BuildConfig.DEBUG);
158
        CrashReport.initCrashReport(getApplicationContext(), "900010422", BuildConfig.DEBUG);
163
        initImageLoader(getApplicationContext());
159
        initImageLoader(getApplicationContext());
164

160

192
        setFestival();
188
        setFestival();
193
    }
189
    }
194

190

191
    public void initJPush() {
192
        //极光
193
        JPushInterface.setDebugMode(false);
194
        JPushInterface.init(this);
195
    }
196

195
    public static MainApplication getInstance() {
197
    public static MainApplication getInstance() {
196
        if (null == instances) {
198
        if (null == instances) {
197
            instances = new MainApplication();
199
            instances = new MainApplication();

+ 110 - 39
app/src/main/java/com/electric/chargingpile/util/SystemTypeUtil.java

7
import android.net.Uri;
7
import android.net.Uri;
8
import android.os.Build;
8
import android.os.Build;
9
import android.os.Environment;
9
import android.os.Environment;
10
import android.text.TextUtils;
10
import android.util.Log;
11
import android.util.Log;
11
import android.view.View;
12
import android.view.View;
12
import android.view.Window;
13
import android.view.Window;
14
15
15
import com.electric.chargingpile.BuildConfig;
16
import com.electric.chargingpile.BuildConfig;
16
17
18
import java.io.BufferedReader;
17
import java.io.File;
19
import java.io.File;
18
import java.io.FileInputStream;
20
import java.io.FileInputStream;
19
import java.io.IOException;
21
import java.io.IOException;
22
import java.io.InputStreamReader;
20
import java.lang.reflect.Field;
23
import java.lang.reflect.Field;
21
import java.lang.reflect.Method;
24
import java.lang.reflect.Method;
22
import java.sql.Date;
25
import java.sql.Date;
29
 * 如:判断手机类型、跳转到权限管理页面、设置状态栏中图文的颜色模式(深色或亮色)
32
 * 如:判断手机类型、跳转到权限管理页面、设置状态栏中图文的颜色模式(深色或亮色)
30
 */
33
 */
31
public class SystemTypeUtil {
34
public class SystemTypeUtil {
32
    private static final String TAG = SystemTypeUtil.class.getSimpleName();
33
    private static final String KEY_EMUI_VERSION_CODE = "ro.build.version.emui";
34
    private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
35
    private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
36
    private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";
35
    private static final String TAG = "SystemTypeUtil";
37
36
37
    public static final String ROM_MIUI = "MIUI";
38
    public static final String ROM_EMUI = "EMUI";
39
    public static final String ROM_FLYME = "FLYME";
40
    public static final String ROM_OPPO = "OPPO";
41
    public static final String ROM_SMARTISAN = "SMARTISAN";
42
    public static final String ROM_VIVO = "VIVO";
43
    public static final String ROM_QIKU = "QIKU";
38
44
39
    /**
40
     * 是否为华为手机
41
     *
42
     * @return
43
     */
44
    public static boolean isEMUI() {
45
        try {
46
            return getProperty(KEY_EMUI_VERSION_CODE, null) != null;
47
        } catch (final IOException e) {
48
            return false;
45
    private static final String KEY_VERSION_MIUI = "ro.miui.ui.version.name";
46
    private static final String KEY_VERSION_EMUI = "ro.build.version.emui";
47
    private static final String KEY_VERSION_OPPO = "ro.build.version.opporom";
48
    private static final String KEY_VERSION_SMARTISAN = "ro.smartisan.version";
49
    private static final String KEY_VERSION_VIVO = "ro.vivo.os.version";
50
51
    private static String sName;
52
    private static String sVersion;
53
    // 华为
54
    public static boolean isEmui() {
55
        return check(ROM_EMUI);
56
    }
57
58
    // 小米
59
    public static boolean isMiui() {
60
        return check(ROM_MIUI);
61
    }
62
63
    // VIVO
64
    public static boolean isVivo() {
65
        return check(ROM_VIVO);
66
    }
67
68
    // OPPO
69
    public static boolean isOppo() {
70
        return check(ROM_OPPO);
71
    }
72
73
    // 魅族
74
    public static boolean isFlyme() {
75
        return check(ROM_FLYME);
76
    }
77
78
    // 360
79
    public static boolean is360() {
80
        return check(ROM_QIKU) || check("360");
81
    }
82
83
    // 锤子
84
    public static boolean isSmartisan() {
85
        return check(ROM_SMARTISAN);
86
    }
87
88
    public static String getName() {
89
        if (sName == null) {
90
            check("");
49
        }
91
        }
92
        return sName;
50
    }
93
    }
51
94
52
    /**
53
     * 是否为小米手机
54
     *
55
     * @return
56
     */
57
    public static boolean isMIUI() {
58
        try {
59
            return getProperty(KEY_MIUI_VERSION_CODE, null) != null
60
                    || getProperty(KEY_MIUI_VERSION_NAME, null) != null
61
                    || getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null;
62
        } catch (final IOException e) {
63
            return false;
95
    public static String getVersion() {
96
        if (sVersion == null) {
97
            check("");
64
        }
98
        }
99
        return sVersion;
65
    }
100
    }
66
101
67
    /**
68
     * 是否为魅族手机
69
     *
70
     * @return
71
     */
72
    public static boolean isFlyme() {
102
    public static boolean check(String rom) {
103
        if (sName != null) {
104
            return sName.equals(rom);
105
        }
106
107
        if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_MIUI))) {
108
            sName = ROM_MIUI;
109
        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_EMUI))) {
110
            sName = ROM_EMUI;
111
        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_OPPO))) {
112
            sName = ROM_OPPO;
113
        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_VIVO))) {
114
            sName = ROM_VIVO;
115
        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_SMARTISAN))) {
116
            sName = ROM_SMARTISAN;
117
        } else {
118
            sVersion = Build.DISPLAY;
119
            if (sVersion.toUpperCase().contains(ROM_FLYME)) {
120
                sName = ROM_FLYME;
121
            } else {
122
                sVersion = Build.UNKNOWN;
123
                sName = Build.MANUFACTURER.toUpperCase();
124
            }
125
        }
126
        return sName.equals(rom);
127
    }
128
129
    public static String getProp(String name) {
130
        String line = null;
131
        BufferedReader input = null;
73
        try {
132
        try {
74
            final Method method = Build.class.getMethod("hasSmartBar");
75
            return method != null;
76
        } catch (final Exception e) {
77
            return false;
133
            Process p = Runtime.getRuntime().exec("getprop " + name);
134
            input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
135
            line = input.readLine();
136
            input.close();
137
        } catch (IOException ex) {
138
            Log.e(TAG, "Unable to read prop " + name, ex);
139
            return null;
140
        } finally {
141
            if (input != null) {
142
                try {
143
                    input.close();
144
                } catch (IOException e) {
145
                    e.printStackTrace();
146
                }
147
            }
78
        }
148
        }
149
        return line;
79
    }
150
    }
80
151
81
152
99
                e.printStackTrace();
170
                e.printStackTrace();
100
                context.startActivity(getAppDetailSettingIntent(context));
171
                context.startActivity(getAppDetailSettingIntent(context));
101
            }
172
            }
102
        } else if (isMIUI()) {
173
        } else if (isMiui()) {
103
//            ToastUtil.show("我是小米");
174
//            ToastUtil.show("我是小米");
104
            Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
175
            Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
105
            ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
176
            ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
111
                e.printStackTrace();
182
                e.printStackTrace();
112
                context.startActivity(getAppDetailSettingIntent(context));
183
                context.startActivity(getAppDetailSettingIntent(context));
113
            }
184
            }
114
        } else if (isEMUI()) {
185
        } else if (isEmui()) {
115
//            ToastUtil.show("我是华为");
186
//            ToastUtil.show("我是华为");
116
            try {
187
            try {
117
                Intent intent = new Intent();
188
                Intent intent = new Intent();

+ 15 - 2
app/src/main/res/layout/activity_about.xml

86
            android:background="@drawable/textviewhuiline_style"
86
            android:background="@drawable/textviewhuiline_style"
87
            android:gravity="center"
87
            android:gravity="center"
88
            android:layout_below="@+id/tv_2"
88
            android:layout_below="@+id/tv_2"
89
            android:layout_marginTop="252px"
89
            android:layout_marginTop="40dp"
90
            android:layout_centerHorizontal="true"/>
90
            android:layout_centerHorizontal="true"/>
91

91

92
        <TextView
92
        <TextView
101

101

102

102

103
        <TextView
103
        <TextView
104
            android:text="《用户协议和隐私政策》"
104
            android:text="《充电桩APP用户使用协议》"
105
            android:layout_width="wrap_content"
106
            android:layout_above="@+id/privacy"
107
            android:textSize="15sp"
108
            android:textColor="#1e90ff"
109
            android:layout_centerHorizontal="true"
110
            android:onClick="onAgreementView"
111
            android:clickable="true"
112
            android:layout_marginBottom="8dp"
113
            android:layout_height="wrap_content"/>
114

115
        <TextView
116
            android:id="@+id/privacy"
117
            android:text="《充电桩隐私政策》"
105
            android:layout_width="wrap_content"
118
            android:layout_width="wrap_content"
106
            android:layout_above="@+id/android"
119
            android:layout_above="@+id/android"
107
            android:textSize="15sp"
120
            android:textSize="15sp"