增加定位和天气依赖

This commit is contained in:
2025-11-04 19:19:33 +08:00
parent 9ac7cf86f3
commit 02772c241e
9 changed files with 302 additions and 4 deletions

1
.gitignore vendored
View File

@@ -13,3 +13,4 @@
.externalNativeBuild .externalNativeBuild
.cxx .cxx
/.idea/ /.idea/
/config.gradle

View File

@@ -1,5 +1,13 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
static def appName() {
return "TTStdElderlyDialer"
}
static def releaseTime() {
return new Date().format("yyyyMMdd_HHmmss", TimeZone.getDefault())
}
android { android {
compileSdkVersion 29 compileSdkVersion 29
// buildToolsVersion "36.0.0" // buildToolsVersion "36.0.0"
@@ -42,12 +50,56 @@ android {
dataBinding { dataBinding {
enabled true enabled true
} }
buildConfigField "String", "QweatherId", "\"${qweatherConfigs.credential.id}\""
buildConfigField "String", "QweatherKey", "\"${qweatherConfigs.credential.key}\""
}
signingConfigs {
keypub {
storeFile file(rootProject.ext.signingConfigs.keypub.storeFile)
storePassword rootProject.ext.signingConfigs.keypub.storePassword
keyAlias rootProject.ext.signingConfigs.keypub.keyAlias
keyPassword rootProject.ext.signingConfigs.keypub.keyPassword
}
} }
buildTypes { buildTypes {
debug {
versionNameSuffix "_debug"
debuggable true
minifyEnabled false
//Zipalign优化
zipAlignEnabled true
signingConfig signingConfigs.keypub
applicationVariants.all { variant ->
variant.outputs.each { output ->
if (outputFile != null) {
def fileName = "${appName()}_V${defaultConfig.versionName}_${releaseTime()}.apk"
output.outputFileName = fileName
}
}
}
}
release { release {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' //Zipalign优化
zipAlignEnabled true
//前一部分代表系统默认的android程序的混淆文件该文件已经包含了基本的混淆声明后一个文件是自己的定义混淆文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//签名
signingConfig signingConfigs.keypub
// 将release版本的包名重命名加上版本及日期
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = ""
if (outputFile != null) {
def fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType.name}.apk"
output.outputFileName = new File(outputFile, fileName)
}
}
}
} }
} }
@@ -55,6 +107,8 @@ android {
dependencies { dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar']) // implementation fileTree(dir: 'libs', include: ['*.jar'])
//Android 4.4+
implementation files('libs/QWeather_Public_Android_V4.20.jar')
implementation project(path: ':niceimageview') implementation project(path: ':niceimageview')
implementation project(path: ':iconloader') implementation project(path: ':iconloader')
@@ -125,6 +179,14 @@ dependencies {
// 要与compiler匹配使用均使用最新版可以保证兼容 // 要与compiler匹配使用均使用最新版可以保证兼容
implementation 'com.alibaba:arouter-api:1.5.2' implementation 'com.alibaba:arouter-api:1.5.2'
annotationProcessor 'com.alibaba:arouter-compiler:1.5.2' annotationProcessor 'com.alibaba:arouter-compiler:1.5.2'
//地图组件
implementation 'com.baidu.lbsyun:BaiduMapSDK_Map:7.6.4'
//基础定位组件
implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.6.4'
//全量定位组件
// implementation 'com.baidu.lbsyun:BaiduMapSDK_Location_All:9.6.4'
//TTS组件
implementation 'com.baidu.lbsyun:NaviTts:3.2.13'
//指示器 //指示器
implementation 'com.github.hackware1993:MagicIndicator:1.7.0' implementation 'com.github.hackware1993:MagicIndicator:1.7.0'

Binary file not shown.

View File

@@ -9,6 +9,24 @@
<uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.CALL_PHONE" />
<!--baidumap start-->
<!-- 这个权限用于进行网络定位-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- 这个权限用于访问系统接口提供的卫星定位信息-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- 用于访问wifi网络信息wifi信息会用于进行网络定位-->
<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.WRITE_EXTERNAL_STORAGE" />
<!-- 访问网络,网络定位需要上网-->
<uses-permission android:name="android.permission.INTERNET" />
<!--baidumap end-->
<application <application
android:name=".base.BaseApplication" android:name=".base.BaseApplication"
android:allowBackup="true" android:allowBackup="true"
@@ -48,6 +66,18 @@
android:launchMode="singleTask" android:launchMode="singleTask"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<receiver
android:name=".receiver.AppChangedReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"
@@ -59,8 +89,17 @@
android:resource="@xml/file_paths" /> android:resource="@xml/file_paths" />
</provider> </provider>
<service
android:name="com.baidu.location.f"
android:enabled="true"
android:process=":remote" />
<meta-data <meta-data
android:name="com.ttstd.elderlyassistant.annotations.CustomGlideModule" android:name="com.baidu.lbsapi.API_KEY"
android:value="rS7n0XrNj0HTswA5aA3LGZhcUubEbqnv" />
<meta-data
android:name="com.ttstd.dialer.annotations.CustomGlideModule"
android:value="AppGlideModule" /> android:value="AppGlideModule" />
<meta-data <meta-data

View File

@@ -1,5 +1,9 @@
package com.ttstd.dialer.activity.main; package com.ttstd.dialer.activity.main;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log; import android.util.Log;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@@ -25,6 +29,8 @@ import net.lucode.hackware.magicindicator.ViewPagerHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.jessyan.autosize.AutoSize;
public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBinding> { public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBinding> {
private static final String TAG = "MainActivity"; private static final String TAG = "MainActivity";
protected MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE); protected MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
@@ -150,6 +156,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
@Override @Override
protected void initData() { protected void initData() {
registerReceivers();
mViewModel.mDesktopSortAppData.observe(this, new Observer<List<AppInfo>>() { mViewModel.mDesktopSortAppData.observe(this, new Observer<List<AppInfo>>() {
@Override @Override
public void onChanged(List<AppInfo> appInfos) { public void onChanged(List<AppInfo> appInfos) {
@@ -164,10 +171,51 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
//修补autozie fragment item大小不一致
AutoSize.autoConvertDensityOfGlobal(this);
Log.e(TAG, "onResume: "); Log.e(TAG, "onResume: ");
mViewModel.getOutsideApp(); mViewModel.getOutsideApp();
} }
@Override
protected void onDestroy() {
super.onDestroy();
Log.e(TAG, "onDestroy: ");
unregisterReceivers();
}
private void registerReceivers() {
registerAppChangedReceive();
}
private void unregisterReceivers() {
if (mPackageChangedReceiver != null) {
unregisterReceiver(mPackageChangedReceiver);
}
}
private PackageChangedReceiver mPackageChangedReceiver;
private void registerAppChangedReceive() {
if (null == mPackageChangedReceiver) {
mPackageChangedReceiver = new PackageChangedReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addDataScheme("package");
registerReceiver(mPackageChangedReceiver, filter);
}
private class PackageChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "onReceive: " + intent.getAction());
}
}
private void setAppList() { private void setAppList() {
Log.e(TAG, "setAppList: mFragments size = " + mFragments.size()); Log.e(TAG, "setAppList: mFragments size = " + mFragments.size());
mFragments = mFragments.subList(0, mFragmentSize); mFragments = mFragments.subList(0, mFragmentSize);

View File

@@ -6,16 +6,15 @@ import android.content.Context;
import android.os.Build; import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.android.arouter.launcher.ARouter;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.hjq.toast.Toaster; import com.hjq.toast.Toaster;
import com.qweather.sdk.view.HeConfig;
import com.tencent.bugly.crashreport.CrashReport; import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.mmkv.MMKV; import com.tencent.mmkv.MMKV;
import com.ttstd.dialer.BuildConfig; import com.ttstd.dialer.BuildConfig;
import com.ttstd.dialer.config.CommonConfig;
import com.ttstd.dialer.manager.AppManager; import com.ttstd.dialer.manager.AppManager;
import com.ttstd.dialer.utils.SystemUtils; import com.ttstd.dialer.utils.SystemUtils;
import com.ttstd.iconloader.IconCacheManager; import com.ttstd.iconloader.IconCacheManager;
@@ -55,6 +54,10 @@ public class BaseApplication extends Application {
String rootDir = MMKV.initialize(this); String rootDir = MMKV.initialize(this);
Log.e(TAG, "mmkv root: " + rootDir); Log.e(TAG, "mmkv root: " + rootDir);
HeConfig.init(BuildConfig.QweatherId, BuildConfig.QweatherKey);
//切换至免费订阅
HeConfig.switchToDevService();
if (BuildConfig.DEBUG) { // 这两行必须写在init之前否则这些配置在init过程中将无效 if (BuildConfig.DEBUG) { // 这两行必须写在init之前否则这些配置在init过程中将无效
ARouter.openLog(); // 打印日志 ARouter.openLog(); // 打印日志
ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行必须开启调试模式线上版本需要关闭,否则有安全风险) ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行必须开启调试模式线上版本需要关闭,否则有安全风险)

View File

@@ -0,0 +1,40 @@
package com.ttstd.dialer.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import com.tencent.mmkv.MMKV;
import com.ttstd.dialer.config.CommonConfig;
public class AppChangedReceiver extends BroadcastReceiver {
private static final String TAG = "ApkInstallReceiver";
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
@Override
public void onReceive(final Context context, Intent intent) {
String action = intent.getAction();
Log.e(TAG, "onReceive: " + "action = " + action);
if (TextUtils.isEmpty(action)) {
return;
}
String packageName = intent.getDataString().replace("package:", "");
switch (action) {
case Intent.ACTION_PACKAGE_ADDED:
Log.e(TAG, "onReceive: added " + packageName);
break;
case Intent.ACTION_PACKAGE_REPLACED:
Log.e(TAG, "onReceive: replaced " + packageName);
break;
case Intent.ACTION_PACKAGE_REMOVED:
Log.e(TAG, "onReceive: removed " + packageName);
break;
default:
break;
}
}
}

View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".fragment.dialog.permission.PermissionDialogFragment">
<data>
<variable
name="click"
type="com.ttstd.dialer.fragment.dialog.permission.PermissionDialogFragment.BtnClick" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="@drawable/default_dialog_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="服务协议和隐私政策"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="32dp"
app:layout_constraintBottom_toTopOf="@+id/linearLayout5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_title">
<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/black"
android:textSize="18sp"
tools:text="内容文本" />
</ScrollView>
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:id="@+id/tv_denied"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:maxLines="1"
android:onClick="@{click::onDenied}"
android:singleLine="true"
android:text="拒绝"
android:textColor="@color/red"
android:textSize="19sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_content" />
<TextView
android:id="@+id/tv_granted"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:maxLines="1"
android:onClick="@{click::onGranted}"
android:singleLine="true"
android:text="同意"
android:textColor="@color/dodgerBlue"
android:textSize="19sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/tv_content"
app:layout_constraintTop_toBottomOf="@+id/tv_content" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@@ -1,4 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: "config.gradle"
buildscript { buildscript {