Skip to content

Commit

Permalink
增加隐私政策、增加友盟SDK的使用,对错误信息进行上传。
Browse files Browse the repository at this point in the history
  • Loading branch information
lilongweidev committed Aug 30, 2021
1 parent c2e4da9 commit 0703d5a
Show file tree
Hide file tree
Showing 16 changed files with 427 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

## APP功能描述

  15天天气预报、空气质量、生活建议、出行建议、灾害预警、分钟级降水、城市切换、城市搜索、常用城市、世界国家/地区的城市、壁纸切换、壁纸下载、地图天气、地图搜索定位、每日提醒、语音播报、语音搜索、快捷切换常用城市、应用自动更新
  15天天气预报、空气质量、生活建议、出行建议、灾害预警、分钟级降水、城市切换、城市搜索、常用城市、世界国家/地区的城市、壁纸切换、壁纸下载、地图天气、地图搜索定位、每日提醒、语音播报、语音搜索、快捷切换常用城市、应用自动更新、错误监控


## 运行效果图
Expand Down Expand Up @@ -89,7 +89,7 @@ GIF看不了的,打开下面的视频地址进行观看<br>
[Android 天气APP(三十二)快捷切换常用城市](https://blog.csdn.net/qq_38436214/article/details/113498027)<br>
[Android 天气APP(三十三)语音播报](https://blog.csdn.net/qq_38436214/article/details/113544891)<br>
[Android 天气APP(三十四)语音搜索](https://blog.csdn.net/qq_38436214/article/details/113699279)<br>

[Android 天气APP(三十五)修复BUG、升级网络请求框架](https://blog.csdn.net/qq_38436214/article/details/119295627?spm=1001.2014.3001.5501)<br>

文章代码是一篇一篇进行迭代的,也欢迎读者提供新的需求,适当采纳,更好的优化这个项目<br>

Expand All @@ -98,8 +98,11 @@ GIF看不了的,打开下面的视频地址进行观看<br>
博主:[初学者-Study](https://blog.csdn.net/qq_38436214)<br>

## 版本说明

### V 2.6 (最新版本)
### V 2.8 (最新版本)
* 增加友盟+性能监控SDK<br>
### V 2.7
* 修复UI显示问题、资源图片处理、优化网络请求框架<br>
### V 2.6
* 优化用户体验,新增快捷切换城市、语音播报、语音搜索功能<br>
### V 2.5
* 分钟级降水、每日提醒<br>
Expand Down
26 changes: 15 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "2.7"
versionName "2.8"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -44,17 +44,21 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.2.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

//butterknife 这个部分比较特殊,所以不管是模块还是项目里都要引入依赖,否则你的控件会报空对象
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
implementation project(':mvplibrary')//引入模块 然后将项目里的依赖移动到模块的build.gradle里

implementation 'com.tencent.bugly:crashreport:latest.release'
//其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如2.2.0
//Bugly SDK
implementation 'com.tencent.bugly:crashreport:3.4.4'
// 友盟基础组件库(所有友盟业务SDK都依赖基础组件库)
implementation "com.umeng.umsdk:common:9.4.2" //(必选)
implementation "com.umeng.umsdk:asms:1.4.1" // asms包依赖(必选)
implementation "com.umeng.umsdk:apm:1.4.2" // U-APM包依赖(必选)
}
21 changes: 10 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 获取运营商信息,用于支持提供运营商信息相关的接口 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/><!--获取手机状态-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 写入扩展存储,向扩展卡写入数据,用于写入离线定位数据 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 读取扩展存储 -->
<uses-permission android:name="android.permission.INTERNET" /><!--网络访问-->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /><!--应用安装-->
<uses-permission android:name="android.permission.RECORD_AUDIO" /><!--录音-->
<uses-permission android:name="android.permission.INTERNET" /> <!-- 网络访问 -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!-- 应用安装 -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />


<application
android:name=".WeatherApplication"
Expand All @@ -26,7 +28,8 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".ui.SettingActivity"></activity>
<activity android:name=".ui.PrivacyPolicyActivity"></activity>
<activity android:name=".ui.SettingActivity" />
<activity android:name=".ui.WebActivity" />
<activity android:name=".ui.WorldCityListActivity" />
<activity android:name=".ui.ImageActivity" />
Expand All @@ -53,26 +56,22 @@
<activity android:name=".MainActivity" />
<activity android:name=".ui.CommonlyUsedCityActivity" />
<activity android:name=".ui.WorldCityWeatherActivity" />
<activity android:name=".ui.SearchCityActivity" />

<!-- 百度定位AK -->
<activity android:name=".ui.SearchCityActivity" /> <!-- 百度定位AK -->
<meta-data
android:name="com.baidu.lbsapi.API_KEY"
android:value="Fh0NIFb6Tg8f7altVIpdGoDH0BR2myG4" /> <!-- 百度定位服务 -->
<service
android:name="com.baidu.location.f"
android:enabled="true"
android:process=":remote" />
<!-- 下载APK广播 -->
android:process=":remote" /> <!-- 下载APK广播 -->
<receiver
android:name=".receiver.DownloadApkReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
</intent-filter>
</receiver>
<!-- Android7.0以后读取文件需要配置Provider -->
</receiver> <!-- Android7.0以后读取文件需要配置Provider -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.llw.goodweather.fileprovider"
Expand Down
44 changes: 44 additions & 0 deletions app/src/main/java/com/llw/goodweather/WeatherApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;

import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;
import com.iflytek.cloud.SpeechConstant;
import com.iflytek.cloud.SpeechUtility;
import com.llw.goodweather.utils.APKVersionInfoUtils;
import com.llw.goodweather.utils.Constant;
import com.llw.goodweather.utils.GlideUtil;
import com.llw.goodweather.utils.SPUtils;
import com.llw.mvplibrary.BaseApplication;
import com.llw.mvplibrary.bean.AppVersion;
import com.llw.mvplibrary.newnet.NetworkApi;
import com.llw.mvplibrary.utils.ActivityManager;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
Expand All @@ -24,6 +29,10 @@
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.tencent.bugly.crashreport.CrashReport;
import com.uc.crashsdk.export.CrashApi;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.umcrash.UMCrash;
import com.umeng.umcrash.UMCrashCallback;

import org.litepal.LitePal;

Expand Down Expand Up @@ -119,6 +128,41 @@ public void onActivityDestroyed(Activity activity) {
CrashReport.initCrashReport(getApplicationContext(), "d3637c0f25", true);
//配置讯飞语音SDK
SpeechUtility.createUtility(this, SpeechConstant.APPID +"=6018c2cb");

//用户是否同意隐私政策
boolean isAgree = SPUtils.getBoolean(Constant.AGREE, false,context);
if (isAgree) {
//友盟SDK初始化
UMConfigure.init(this, Constant.U_MENG_APPKEY, "Umeng", UMConfigure.DEVICE_TYPE_PHONE, "");
} else {
//预初始化
UMConfigure.preInit(this, Constant.U_MENG_APPKEY,"Umeng");
}
//友盟配置
umengConfig();
}

/**
* 友盟配置
*/
private void umengConfig() {
//设置App版本
UMCrash.setAppVersion(
APKVersionInfoUtils.getVerName(this),
APKVersionInfoUtils.getSubVersion(this), Build.ID);

//针对于Native崩溃信息采集
// final Bundle customInfo = new Bundle();
// customInfo.putBoolean("mCallNativeDefaultHandler",true);
// CrashApi.getInstance().updateCustomInfo(customInfo);

//崩溃回调
UMCrash.registerUMCrashCallback(new UMCrashCallback(){
@Override
public String onCallback(){
return "App程序崩溃了";
}
});
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.llw.goodweather.ui;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.llw.goodweather.R;
import com.llw.mvplibrary.base.BaseActivity;

/**
* 隐私页面页面
* @author lonel
*/
public class PrivacyPolicyActivity extends BaseActivity {
private WebView webView;
@Override
public void initData(Bundle savedInstanceState) {
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(v -> finish());
webView = findViewById(R.id.webview);

loadUrl("https://www.umeng.com/page/policy");
}

@Override
public int getLayoutId() {
return R.layout.activity_privacy_policy;
}

/**
* 加载网页Url
*
* @param url
*/
private void loadUrl(String url) {
if (url == null) {
return;
}

WebSettings webSetting = webView.getSettings();
//设置JS允许
webSetting.setJavaScriptEnabled(true);
//设置WebView是否使用viewport
webSetting.setUseWideViewPort(true);
//设置WebView是否使用预览模式加载界面。
webSetting.setLoadWithOverviewMode(true);
//设置WebView是否支持使用屏幕控件或手势进行缩放
webSetting.setSupportZoom(true);
//设置WebView是否使用其内置的变焦机制,该机制集合屏幕缩放控件使用
webSetting.setBuiltInZoomControls(true);
webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
webSetting.setAllowFileAccess(true);
webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
webSetting.setUseWideViewPort(true);
webSetting.setLoadWithOverviewMode(true);
webSetting.setSupportMultipleWindows(true);
webSetting.setAppCacheEnabled(true);//APP缓存
webSetting.setDomStorageEnabled(true);
webSetting.setGeolocationEnabled(true);//地理位置
webSetting.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);//读取缓存

webView.loadUrl(url);

webView.setWebViewClient(new WebViewClient() {

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
Log.d("webViewT", "加载开始");
}

@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Log.d("webViewT", "加载完成");
}

});

//进度
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView webView, int newProgress) {
super.onProgressChanged(webView, newProgress);
Log.d("webViewT", "newProgress: " + newProgress);
}
});
}
}
Loading

0 comments on commit 0703d5a

Please sign in to comment.