添加米盟广告SDK,添加主题风格设置。
This commit is contained in:
@@ -38,9 +38,22 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 米盟 SDK
|
||||||
|
packagingOptions {
|
||||||
|
doNotStrip "*/*/libmimo_1011.so"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
// 米盟
|
||||||
|
api 'com.miui.zeus:mimo-ad-sdk:5.3.+'//请使用最新版sdk
|
||||||
|
//注意:以下5个库必须要引入
|
||||||
|
//api 'androidx.appcompat:appcompat:1.4.1'
|
||||||
|
api 'androidx.recyclerview:recyclerview:1.0.0'
|
||||||
|
api 'com.google.code.gson:gson:2.8.5'
|
||||||
|
api 'com.github.bumptech.glide:glide:4.9.0'
|
||||||
|
//annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/com.jzxiang.pickerview/TimePickerDialog
|
// https://mvnrepository.com/artifact/com.jzxiang.pickerview/TimePickerDialog
|
||||||
api 'com.jzxiang.pickerview:TimePickerDialog:1.0.1'
|
api 'com.jzxiang.pickerview:TimePickerDialog:1.0.1'
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Sun Dec 07 21:00:59 HKT 2025
|
#Sun Dec 07 15:55:26 GMT 2025
|
||||||
stageCount=1
|
stageCount=1
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.12
|
baseVersion=15.12
|
||||||
publishVersion=15.12.0
|
publishVersion=15.12.0
|
||||||
buildCount=0
|
buildCount=5
|
||||||
baseBetaVersion=15.12.1
|
baseBetaVersion=15.12.1
|
||||||
|
|||||||
@@ -112,7 +112,7 @@
|
|||||||
<activity android:name="cc.winboll.studio.positions.activities.LocationActivity"/>
|
<activity android:name="cc.winboll.studio.positions.activities.LocationActivity"/>
|
||||||
|
|
||||||
<activity android:name="cc.winboll.studio.positions.activities.ShortcutActionActivity"/>
|
<activity android:name="cc.winboll.studio.positions.activities.ShortcutActionActivity"/>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".services.MainService"
|
android:name=".services.MainService"
|
||||||
android:exported="false"/>
|
android:exported="false"/>
|
||||||
@@ -134,16 +134,15 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.max_aspect"
|
android:name="android.max_aspect"
|
||||||
android:value="4.0"/>
|
android:value="4.0"/>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.gms.version"
|
android:name="com.google.android.gms.version"
|
||||||
android:value="@integer/google_play_services_version"/>
|
android:value="@integer/google_play_services_version"/>
|
||||||
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.fileprovider"
|
android:authorities="${applicationId}.fileprovider"
|
||||||
@@ -156,6 +155,8 @@
|
|||||||
|
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
|
<activity android:name="cc.winboll.studio.positions.activities.SettingsActivity"/>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -6,6 +6,8 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
@@ -15,11 +17,14 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||||
|
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||||
|
import cc.winboll.studio.libaes.utils.DevelopUtils;
|
||||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||||
|
import cc.winboll.studio.libaes.views.ADsBannerView;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.positions.activities.LocationActivity;
|
import cc.winboll.studio.positions.activities.LocationActivity;
|
||||||
|
import cc.winboll.studio.positions.activities.SettingsActivity;
|
||||||
import cc.winboll.studio.positions.activities.WinBoLLActivity;
|
import cc.winboll.studio.positions.activities.WinBoLLActivity;
|
||||||
import cc.winboll.studio.positions.services.MainService;
|
|
||||||
import cc.winboll.studio.positions.utils.AppConfigsUtil;
|
import cc.winboll.studio.positions.utils.AppConfigsUtil;
|
||||||
import cc.winboll.studio.positions.utils.ServiceUtil;
|
import cc.winboll.studio.positions.utils.ServiceUtil;
|
||||||
|
|
||||||
@@ -34,7 +39,7 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
|||||||
// 权限请求码(建议定义为类常量,避免魔法值)
|
// 权限请求码(建议定义为类常量,避免魔法值)
|
||||||
private static final int REQUEST_LOCATION_PERMISSIONS = 1001;
|
private static final int REQUEST_LOCATION_PERMISSIONS = 1001;
|
||||||
private static final int REQUEST_BACKGROUND_LOCATION_PERMISSION = 1002;
|
private static final int REQUEST_BACKGROUND_LOCATION_PERMISSION = 1002;
|
||||||
|
|
||||||
// UI 控件:服务控制开关、顶部工具栏
|
// UI 控件:服务控制开关、顶部工具栏
|
||||||
private Switch mServiceSwitch;
|
private Switch mServiceSwitch;
|
||||||
private Button mManagePositionsButton;
|
private Button mManagePositionsButton;
|
||||||
@@ -42,6 +47,7 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
|||||||
// 服务相关:服务实例、绑定状态标记
|
// 服务相关:服务实例、绑定状态标记
|
||||||
//private DistanceRefreshService mDistanceService;
|
//private DistanceRefreshService mDistanceService;
|
||||||
private boolean isServiceBound = false;
|
private boolean isServiceBound = false;
|
||||||
|
ADsBannerView mADsBannerView;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,11 +99,18 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
|||||||
}
|
}
|
||||||
// 4. 绑定服务(仅用于获取服务实时状态,不影响服务独立运行)
|
// 4. 绑定服务(仅用于获取服务实时状态,不影响服务独立运行)
|
||||||
//bindDistanceService();
|
//bindDistanceService();
|
||||||
|
|
||||||
|
mADsBannerView = findViewById(R.id.adsbanner);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
if (mADsBannerView != null) {
|
||||||
|
mADsBannerView.releaseAdResources();
|
||||||
|
}
|
||||||
|
|
||||||
// 页面销毁时解绑服务,避免Activity与服务相互引用导致内存泄漏
|
// 页面销毁时解绑服务,避免Activity与服务相互引用导致内存泄漏
|
||||||
// if (isServiceBound) {
|
// if (isServiceBound) {
|
||||||
// unbindService(mServiceConn);
|
// unbindService(mServiceConn);
|
||||||
@@ -106,6 +119,16 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (mADsBannerView != null) {
|
||||||
|
mADsBannerView.resumeADs(MainActivity.this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------- 核心功能1:初始化UI组件(Toolbar + 服务开关) ----------------------
|
// ---------------------- 核心功能1:初始化UI组件(Toolbar + 服务开关) ----------------------
|
||||||
/**
|
/**
|
||||||
* 初始化顶部 Toolbar,设置页面标题
|
* 初始化顶部 Toolbar,设置页面标题
|
||||||
@@ -155,6 +178,39 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
// 主题菜单
|
||||||
|
AESThemeUtil.inflateMenu(this, menu);
|
||||||
|
// 调试工具菜单
|
||||||
|
if (App.isDebugging()) {
|
||||||
|
DevelopUtils.inflateMenu(this, menu);
|
||||||
|
}
|
||||||
|
// 应用其他菜单
|
||||||
|
getMenuInflater().inflate(R.menu.toolbar_main, menu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
int menuItemId = item.getItemId();
|
||||||
|
if (AESThemeUtil.onAppThemeItemSelected(this, item)) {
|
||||||
|
recreate();
|
||||||
|
} if (DevelopUtils.onDevelopItemSelected(this, item)) {
|
||||||
|
LogUtils.d(TAG, String.format("onOptionsItemSelected item.getItemId() %d ", item.getItemId()));
|
||||||
|
} else if (item.getItemId() == R.id.item_settings) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setClass(this, SettingsActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
// 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 绑定服务(仅用于获取服务状态,不启动服务)
|
* 绑定服务(仅用于获取服务状态,不启动服务)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ import android.view.View;
|
|||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.ToastUtils;
|
import cc.winboll.studio.libappbase.ToastUtils;
|
||||||
import cc.winboll.studio.positions.R;
|
import cc.winboll.studio.positions.R;
|
||||||
@@ -33,12 +35,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
* 2. Adapter 初始化传入 MainService 实例,确保数据来源唯一
|
* 2. Adapter 初始化传入 MainService 实例,确保数据来源唯一
|
||||||
* 3. 所有位置/任务操作通过 MainService 接口执行
|
* 3. 所有位置/任务操作通过 MainService 接口执行
|
||||||
*/
|
*/
|
||||||
public class LocationActivity extends Activity {
|
public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||||
public static final String TAG = "LocationActivity";
|
public static final String TAG = "LocationActivity";
|
||||||
|
|
||||||
|
private Toolbar mToolbar;
|
||||||
|
|
||||||
private RecyclerView mRvPosition;
|
private RecyclerView mRvPosition;
|
||||||
private PositionAdapter mPositionAdapter;
|
private PositionAdapter mPositionAdapter;
|
||||||
|
|
||||||
// MainService 引用+绑定状态(AtomicBoolean 确保多线程状态可见性)
|
// MainService 引用+绑定状态(AtomicBoolean 确保多线程状态可见性)
|
||||||
private MainService mMainService;
|
private MainService mMainService;
|
||||||
private final AtomicBoolean isServiceBound = new AtomicBoolean(false);
|
private final AtomicBoolean isServiceBound = new AtomicBoolean(false);
|
||||||
@@ -96,11 +100,34 @@ public class LocationActivity extends Activity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Activity getActivity() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_location);
|
setContentView(R.layout.activity_location);
|
||||||
|
|
||||||
|
mToolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(mToolbar);
|
||||||
|
mToolbar.setSubtitle(getTag());
|
||||||
|
mToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
LogUtils.d(TAG, "【导航栏】点击返回");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 1. 初始化视图(优先执行,避免Adapter初始化时视图为空)
|
// 1. 初始化视图(优先执行,避免Adapter初始化时视图为空)
|
||||||
initView();
|
initView();
|
||||||
// 2. 初始化GPS监听(提前创建,避免绑定服务后空指针)
|
// 2. 初始化GPS监听(提前创建,避免绑定服务后空指针)
|
||||||
@@ -167,7 +194,7 @@ public class LocationActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogUtils.d(TAG, "数据同步完成:服务位置数=" + (servicePosList == null ? 0 : servicePosList.size())
|
LogUtils.d(TAG, "数据同步完成:服务位置数=" + (servicePosList == null ? 0 : servicePosList.size())
|
||||||
+ ",本地缓存数=" + mLocalPosCache.size());
|
+ ",本地缓存数=" + mLocalPosCache.size());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtils.d(TAG, "同步服务数据失败:" + e.getMessage());
|
LogUtils.d(TAG, "同步服务数据失败:" + e.getMessage());
|
||||||
@@ -183,9 +210,9 @@ public class LocationActivity extends Activity {
|
|||||||
// 1. 多重安全校验(避免销毁后初始化/重复初始化/依赖未就绪)
|
// 1. 多重安全校验(避免销毁后初始化/重复初始化/依赖未就绪)
|
||||||
if (isAdapterInited.get() || !isServiceBound.get() || mMainService == null || mRvPosition == null) {
|
if (isAdapterInited.get() || !isServiceBound.get() || mMainService == null || mRvPosition == null) {
|
||||||
LogUtils.w(TAG, "Adapter初始化跳过:"
|
LogUtils.w(TAG, "Adapter初始化跳过:"
|
||||||
+ "已初始化=" + isAdapterInited.get()
|
+ "已初始化=" + isAdapterInited.get()
|
||||||
+ ",服务绑定=" + isServiceBound.get()
|
+ ",服务绑定=" + isServiceBound.get()
|
||||||
+ ",视图就绪=" + (mRvPosition != null));
|
+ ",视图就绪=" + (mRvPosition != null));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,54 +222,54 @@ public class LocationActivity extends Activity {
|
|||||||
|
|
||||||
// 3. 设置删除回调(删除时同步服务+本地缓存+Adapter)
|
// 3. 设置删除回调(删除时同步服务+本地缓存+Adapter)
|
||||||
mPositionAdapter.setOnDeleteClickListener(new PositionAdapter.OnDeleteClickListener() {
|
mPositionAdapter.setOnDeleteClickListener(new PositionAdapter.OnDeleteClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDeleteClick(int position) {
|
public void onDeleteClick(int position) {
|
||||||
// 安全校验(索引有效+服务绑定+缓存非空)
|
// 安全校验(索引有效+服务绑定+缓存非空)
|
||||||
if (position < 0 || position >= mLocalPosCache.size() || !isServiceBound.get() || mMainService == null) {
|
if (position < 0 || position >= mLocalPosCache.size() || !isServiceBound.get() || mMainService == null) {
|
||||||
LogUtils.w(TAG, "删除位置失败:索引无效/服务未就绪(索引=" + position + ",缓存量=" + mLocalPosCache.size() + ")");
|
LogUtils.w(TAG, "删除位置失败:索引无效/服务未就绪(索引=" + position + ",缓存量=" + mLocalPosCache.size() + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PositionModel deletePos = mLocalPosCache.get(position);
|
PositionModel deletePos = mLocalPosCache.get(position);
|
||||||
if (deletePos != null && !deletePos.getPositionId().isEmpty()) {
|
if (deletePos != null && !deletePos.getPositionId().isEmpty()) {
|
||||||
// 步骤1:调用服务删除(确保服务数据一致性)
|
// 步骤1:调用服务删除(确保服务数据一致性)
|
||||||
mMainService.removePosition(deletePos.getPositionId());
|
mMainService.removePosition(deletePos.getPositionId());
|
||||||
// 步骤2:删除本地缓存(确保缓存与服务同步)
|
// 步骤2:删除本地缓存(确保缓存与服务同步)
|
||||||
synchronized (mLocalPosCache) {
|
synchronized (mLocalPosCache) {
|
||||||
mLocalPosCache.remove(position);
|
mLocalPosCache.remove(position);
|
||||||
}
|
}
|
||||||
// 步骤3:通知Adapter刷新(基于缓存操作,避免空数据)
|
// 步骤3:通知Adapter刷新(基于缓存操作,避免空数据)
|
||||||
mPositionAdapter.notifyItemRemoved(position);
|
mPositionAdapter.notifyItemRemoved(position);
|
||||||
showToast("删除位置成功:" + deletePos.getMemo());
|
showToast("删除位置成功:" + deletePos.getMemo());
|
||||||
LogUtils.d(TAG, "删除位置完成:ID=" + deletePos.getPositionId() + "(服务+缓存已同步)");
|
LogUtils.d(TAG, "删除位置完成:ID=" + deletePos.getPositionId() + "(服务+缓存已同步)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 4. 设置保存回调(保存时同步服务+本地缓存+Adapter)
|
// 4. 设置保存回调(保存时同步服务+本地缓存+Adapter)
|
||||||
mPositionAdapter.setOnSavePositionClickListener(new PositionAdapter.OnSavePositionClickListener() {
|
mPositionAdapter.setOnSavePositionClickListener(new PositionAdapter.OnSavePositionClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSavePositionClick(int position, PositionModel updatedPos) {
|
public void onSavePositionClick(int position, PositionModel updatedPos) {
|
||||||
// 安全校验(索引有效+服务绑定+数据非空)
|
// 安全校验(索引有效+服务绑定+数据非空)
|
||||||
if (!isServiceBound.get() || mMainService == null
|
if (!isServiceBound.get() || mMainService == null
|
||||||
|| position < 0 || position >= mLocalPosCache.size() || updatedPos == null) {
|
|| position < 0 || position >= mLocalPosCache.size() || updatedPos == null) {
|
||||||
LogUtils.w(TAG, "保存位置失败:服务未就绪/索引无效/数据空");
|
LogUtils.w(TAG, "保存位置失败:服务未就绪/索引无效/数据空");
|
||||||
showToast("服务未就绪,保存失败");
|
showToast("服务未就绪,保存失败");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 步骤1:调用服务更新(确保服务数据一致性)
|
// 步骤1:调用服务更新(确保服务数据一致性)
|
||||||
mMainService.updatePosition(updatedPos);
|
mMainService.updatePosition(updatedPos);
|
||||||
// 步骤2:更新本地缓存(确保缓存与服务同步)
|
// 步骤2:更新本地缓存(确保缓存与服务同步)
|
||||||
synchronized (mLocalPosCache) {
|
synchronized (mLocalPosCache) {
|
||||||
mLocalPosCache.set(position, updatedPos);
|
mLocalPosCache.set(position, updatedPos);
|
||||||
}
|
}
|
||||||
// 步骤3:通知Adapter刷新(基于缓存操作,避免空数据)
|
// 步骤3:通知Adapter刷新(基于缓存操作,避免空数据)
|
||||||
mPositionAdapter.notifyItemChanged(position);
|
mPositionAdapter.notifyItemChanged(position);
|
||||||
showToast("保存位置成功:" + updatedPos.getMemo());
|
showToast("保存位置成功:" + updatedPos.getMemo());
|
||||||
LogUtils.d(TAG, "保存位置完成:ID=" + updatedPos.getPositionId() + "(服务+缓存已同步)");
|
LogUtils.d(TAG, "保存位置完成:ID=" + updatedPos.getPositionId() + "(服务+缓存已同步)");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 5. 设置Adapter到RecyclerView(最后一步,确保Adapter已配置完成)
|
// 5. 设置Adapter到RecyclerView(最后一步,确保Adapter已配置完成)
|
||||||
mRvPosition.setAdapter(mPositionAdapter);
|
mRvPosition.setAdapter(mPositionAdapter);
|
||||||
@@ -268,7 +295,7 @@ public class LocationActivity extends Activity {
|
|||||||
}
|
}
|
||||||
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------- 页面交互(新增位置逻辑保留,适配GPS数据) ----------------------
|
// ---------------------- 页面交互(新增位置逻辑保留,适配GPS数据) ----------------------
|
||||||
/**
|
/**
|
||||||
* 新增位置(调用服务addPosition(),可选:用当前GPS位置初始化新位置)
|
* 新增位置(调用服务addPosition(),可选:用当前GPS位置初始化新位置)
|
||||||
@@ -395,9 +422,7 @@ public class LocationActivity extends Activity {
|
|||||||
LogUtils.d(TAG, "onResume:服务已绑定但Adapter未初始化,重新同步数据");
|
LogUtils.d(TAG, "onResume:服务已绑定但Adapter未初始化,重新同步数据");
|
||||||
syncDataFromMainService();
|
syncDataFromMainService();
|
||||||
initPositionAdapter();
|
initPositionAdapter();
|
||||||
}
|
} else if (isServiceBound.get() && mMainService != null && isAdapterInited.get() && mPositionAdapter != null) {
|
||||||
// 2. 服务已绑定且Adapter已初始化:刷新数据(确保与服务同步)
|
|
||||||
else if (isServiceBound.get() && mMainService != null && isAdapterInited.get() && mPositionAdapter != null) {
|
|
||||||
syncDataFromMainService();
|
syncDataFromMainService();
|
||||||
mPositionAdapter.notifyDataSetChanged();
|
mPositionAdapter.notifyDataSetChanged();
|
||||||
LogUtils.d(TAG, "onResume:刷新位置数据(与服务同步)");
|
LogUtils.d(TAG, "onResume:刷新位置数据(与服务同步)");
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package cc.winboll.studio.positions.activities;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||||
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
import cc.winboll.studio.libappbase.ToastUtils;
|
||||||
|
import cc.winboll.studio.positions.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||||
|
* @Date 2025/12/07 23:29
|
||||||
|
* @Describe 应用设置活动窗口
|
||||||
|
*/
|
||||||
|
public class SettingsActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||||
|
|
||||||
|
public static final String TAG = "SettingsActivity";
|
||||||
|
|
||||||
|
private Toolbar mToolbar;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Activity getActivity() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_settings);
|
||||||
|
|
||||||
|
mToolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(mToolbar);
|
||||||
|
mToolbar.setSubtitle(getTag());
|
||||||
|
mToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
LogUtils.d(TAG, "【导航栏】点击返回");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import android.os.Bundle;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||||
|
import cc.winboll.studio.libaes.models.AESThemeBean;
|
||||||
|
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
|
||||||
@@ -17,6 +19,8 @@ public class WinBoLLActivity extends AppCompatActivity implements IWinBoLLActivi
|
|||||||
|
|
||||||
public static final String TAG = "WinBoLLActivity";
|
public static final String TAG = "WinBoLLActivity";
|
||||||
|
|
||||||
|
protected volatile AESThemeBean.ThemeType mThemeType;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Activity getActivity() {
|
public Activity getActivity() {
|
||||||
return this;
|
return this;
|
||||||
@@ -27,6 +31,22 @@ public class WinBoLLActivity extends AppCompatActivity implements IWinBoLLActivi
|
|||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
mThemeType = getThemeType();
|
||||||
|
setThemeStyle();
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
AESThemeBean.ThemeType getThemeType() {
|
||||||
|
return AESThemeBean.getThemeStyleType(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setThemeStyle() {
|
||||||
|
setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -36,12 +56,12 @@ public class WinBoLLActivity extends AppCompatActivity implements IWinBoLLActivi
|
|||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
/*if (item.getItemId() == R.id.item_log) {
|
/*if (item.getItemId() == R.id.item_log) {
|
||||||
WinBoLLActivityManager.getInstance().startLogActivity(this);
|
WinBoLLActivityManager.getInstance().startLogActivity(this);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.item_home) {
|
} else if (item.getItemId() == R.id.item_home) {
|
||||||
startActivity(new Intent(this, MainActivity.class));
|
startActivity(new Intent(this, MainActivity.class));
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}*/
|
||||||
// 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。
|
// 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,67 +1,81 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:padding="20dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||||
android:id="@+id/layout_location_info"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="30dp"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:gravity="center_horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="实时位置信息"
|
|
||||||
android:textSize="22sp"
|
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_longitude"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="当前经度:等待更新..."
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:layout_marginTop="15dp"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_latitude"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="当前纬度:等待更新..."
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:layout_marginTop="10dp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rv_position_list"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="@dimen/toolbar_height"
|
||||||
android:layout_below="@id/layout_location_info"
|
android:id="@+id/toolbar"
|
||||||
android:layout_above="@id/fab_p_button"
|
android:gravity="center_vertical"/>
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:paddingBottom="10dp"/>
|
|
||||||
|
|
||||||
<Button
|
<RelativeLayout
|
||||||
android:id="@+id/fab_p_button"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="60dp"
|
android:layout_height="0dp"
|
||||||
android:layout_height="60dp"
|
android:padding="20dp"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_weight="1.0">
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_margin="20dp"
|
|
||||||
android:background="@drawable/circle_button_bg"
|
|
||||||
android:text="P"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textSize="24sp"
|
|
||||||
android:elevation="6dp"
|
|
||||||
android:padding="0dp"
|
|
||||||
android:onClick="addNewPosition"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
<LinearLayout
|
||||||
|
android:id="@+id/layout_location_info"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="实时位置信息"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_longitude"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="当前经度:等待更新..."
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_marginTop="15dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_latitude"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="当前纬度:等待更新..."
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_marginTop="10dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rv_position_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_below="@id/layout_location_info"
|
||||||
|
android:layout_above="@id/fab_p_button"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:paddingBottom="10dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fab_p_button"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_margin="20dp"
|
||||||
|
android:background="@drawable/circle_button_bg"
|
||||||
|
android:text="P"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:elevation="6dp"
|
||||||
|
android:padding="0dp"
|
||||||
|
android:onClick="addNewPosition"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -2,38 +2,51 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/toolbar_height"
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:gravity="center_vertical"/>
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
android:background="?attr/colorPrimary"
|
|
||||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
|
||||||
|
|
||||||
<Switch
|
<LinearLayout
|
||||||
android:id="@+id/switch_service_control"
|
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:text="GPS服务开关"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="0dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="1.0">
|
||||||
|
|
||||||
<Button
|
<Switch
|
||||||
|
android:id="@+id/switch_service_control"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:text="GPS服务开关"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:onClick="onPositions"
|
||||||
|
android:text="位置与任务管理"
|
||||||
|
android:id="@+id/btn_manage_positions"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:onClick="onLog"
|
||||||
|
android:text="查看应用日志"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<cc.winboll.studio.libaes.views.ADsBannerView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="16dp"
|
android:id="@+id/adsbanner"
|
||||||
android:onClick="onPositions"
|
android:layout_alignParentBottom="true"/>
|
||||||
android:text="位置与任务管理"
|
|
||||||
android:id="@+id/btn_manage_positions"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:onClick="onLog"
|
|
||||||
android:text="查看应用日志"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
21
positions/src/main/res/layout/activity_settings.xml
Normal file
21
positions/src/main/res/layout/activity_settings.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/toolbar_height"
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:gravity="center_vertical"/>
|
||||||
|
|
||||||
|
<cc.winboll.studio.libaes.views.ADsControlView
|
||||||
|
android:id="@+id/ads_control_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
9
positions/src/main/res/menu/toolbar_main.xml
Normal file
9
positions/src/main/res/menu/toolbar_main.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/item_settings"
|
||||||
|
android:title="Settings"/>
|
||||||
|
|
||||||
|
</menu>
|
||||||
7
positions/src/main/res/values/dimens.xml
Normal file
7
positions/src/main/res/values/dimens.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<dimen name="toolbar_height">60dp</dimen>
|
||||||
|
<dimen name="text_content_size">18dp</dimen>
|
||||||
|
<dimen name="text_title_size">24dp</dimen>
|
||||||
|
<dimen name="text_subtitle_size">16dp</dimen>
|
||||||
|
</resources>
|
||||||
@@ -14,4 +14,12 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 设置Toolbar标题字体的大小 -->
|
||||||
|
<style name="Toolbar.TitleText" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
|
||||||
|
<item name="android:textSize">@dimen/text_title_size</item>
|
||||||
|
</style>
|
||||||
|
<style name="Toolbar.SubTitleText" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
|
||||||
|
<item name="android:textSize">@dimen/text_subtitle_size</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user