mirror of
https://gitea.winboll.cc/ZhanGSKen/MyWinBoLL.git
synced 2026-08-14 13:37:11 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 91d97efe4e | |||
| 1d4b232491 | |||
| 33f74f8226 | |||
| a74ab6aa06 | |||
| 8b3c6c3481 | |||
| 8a50eaf24c | |||
| d4fddaecf9 | |||
| 7c8800f873 | |||
| 32afb3ad74 | |||
| afd57c8d70 | |||
| 8b4624982c | |||
| 5283ebadc9 | |||
| e7fdf3ce6a | |||
| 7407ba582e |
+2
-2
@@ -1,10 +1,10 @@
|
||||
# [ByTheWay]
|
||||
#【老君道说】
|
||||
#【顺道说】
|
||||
|
||||
#### 介绍
|
||||
The [ByTheWay] project is designed to quickly schedule task reminders related to time and location.
|
||||
Its main feature is the ability to quickly create task-related data.
|
||||
【老君道说】项目应用应用于快速安排一个以时间和位置有关的任务提醒事项。
|
||||
【顺道说】项目应用应用于快速安排一个以时间和位置有关的任务提醒事项。
|
||||
其主要的特点是能快速建立事项任务数据。
|
||||
|
||||
#### 软件架构
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Fri Jul 03 12:40:12 HKT 2026
|
||||
stageCount=1
|
||||
#Thu Jul 09 20:17:02 HKT 2026
|
||||
stageCount=3
|
||||
libraryProject=
|
||||
baseVersion=15.20
|
||||
publishVersion=15.20.0
|
||||
publishVersion=15.20.2
|
||||
buildCount=0
|
||||
baseBetaVersion=15.20.1
|
||||
baseBetaVersion=15.20.3
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">老君道说☯</string>string>
|
||||
<string name="app_name">顺道说☯</string>string>
|
||||
</resources>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- 在后台使用位置信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
|
||||
|
||||
<!-- 前台服务 -->
|
||||
<!-- 运行前台服务 -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
|
||||
<application
|
||||
@@ -53,6 +53,8 @@
|
||||
|
||||
<activity android:name="cc.winboll.studio.bytheway.activities.SettingsActivity"/>
|
||||
|
||||
<activity android:name="cc.winboll.studio.bytheway.activities.AboutActivity"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -21,11 +21,11 @@ import android.widget.HorizontalScrollView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libappbase.CrashActivity;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.libappbase.utils.CrashHandleNotifyUtils;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
@@ -53,6 +53,7 @@ public class App extends GlobalApplication {
|
||||
public void onCreate() {
|
||||
try {
|
||||
super.onCreate();
|
||||
WinBoLLActivityManager.init(this);
|
||||
|
||||
// 初始化主题样式ID列表
|
||||
AESThemeUtil.init(null);
|
||||
|
||||
@@ -2,26 +2,31 @@ package cc.winboll.studio.bytheway;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import cc.winboll.studio.bytheway.activities.GpsListActivity;
|
||||
import cc.winboll.studio.bytheway.activities.SettingsActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.bytheway.activities.AboutActivity;
|
||||
import cc.winboll.studio.bytheway.activities.BaseWinBoLLActivity;
|
||||
import cc.winboll.studio.bytheway.activities.GpsListActivity;
|
||||
import cc.winboll.studio.bytheway.activities.SettingsActivity;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libaes.utils.DevelopUtils;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
public class MainActivity extends BaseWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "MainActivity";
|
||||
|
||||
public static final String TAG = "MainActivity";
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
AESThemeUtil.applyAppCompatTheme(this);
|
||||
//AESThemeUtil.applyAppCompatTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
@@ -60,6 +65,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
return true;
|
||||
}
|
||||
if (item.getItemId() == R.id.action_about) {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
return true;
|
||||
}
|
||||
if (DevelopUtils.onDevelopItemSelected(this, item)) {
|
||||
LogUtils.d(TAG, String.format("onOptionsItemSelected item.getItemId() %d ", item.getItemId()));
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package cc.winboll.studio.bytheway.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.bytheway.MainActivity;
|
||||
import cc.winboll.studio.bytheway.R;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.models.APPInfo;
|
||||
import cc.winboll.studio.libappbase.views.AboutView;
|
||||
|
||||
/**
|
||||
* @Author 豆包&BigPickle&ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/07/07 00:17
|
||||
* @Describe 应用介绍窗口
|
||||
*/
|
||||
public class AboutActivity extends BaseWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "AboutActivity";
|
||||
|
||||
private Toolbar mToolbar;
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
|
||||
// 设置工具栏
|
||||
initToolbar();
|
||||
|
||||
AboutView aboutView = findViewById(R.id.aboutview);
|
||||
aboutView.setAPPInfo(genDefaultAppInfo());
|
||||
}
|
||||
|
||||
private void initToolbar() {
|
||||
LogUtils.d(TAG, "initToolbar() 开始初始化");
|
||||
mToolbar = findViewById(R.id.toolbar);
|
||||
if (mToolbar == null) {
|
||||
LogUtils.e(TAG, "initToolbar() | Toolbar未找到");
|
||||
return;
|
||||
}
|
||||
setSupportActionBar(mToolbar);
|
||||
mToolbar.setSubtitle(getTag());
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "导航栏 点击返回按钮");
|
||||
WinBoLLActivityManager.getInstance().resumeActivity(MainActivity.class);
|
||||
WinBoLLActivityManager.getInstance().finish(AboutActivity.this);
|
||||
}
|
||||
});
|
||||
LogUtils.d(TAG, "initToolbar() 配置完成");
|
||||
}
|
||||
|
||||
private APPInfo genDefaultAppInfo() {
|
||||
LogUtils.d(TAG, "genDefaultAppInfo() 调用");
|
||||
String branchName = "bytheway";
|
||||
APPInfo appInfo = new APPInfo();
|
||||
appInfo.setAppName(getString(R.string.app_name));
|
||||
appInfo.setAppIcon(R.drawable.ic_winboll);
|
||||
appInfo.setAppDescription(getString(R.string.app_description));
|
||||
appInfo.setAppGitName("MyWinBoLL");
|
||||
appInfo.setAppGitOwner("ZhanGSKen");
|
||||
appInfo.setAppGitAPPBranch(branchName);
|
||||
appInfo.setAppGitAPPSubProjectFolder(branchName);
|
||||
appInfo.setAppHomePage("https://www.winboll.cc/apks/index.php?project=ByTheWay");
|
||||
appInfo.setAppAPKName("ByTheWay");
|
||||
appInfo.setAppAPKFolderName("ByTheWay");
|
||||
LogUtils.d(TAG, "genDefaultAppInfo: 应用信息已生成");
|
||||
return appInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cc.winboll.studio.bytheway.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author 豆包&BigPickle&ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/07/07 00:21
|
||||
* @Describe BaseWinBollActivity 【继承AppCompatActivity,保留核心能力,不额外暴露方法】
|
||||
* 继承链路:BaseWinBoLLActivity → AppCompatActivity → FragmentActivity,AppCompat能力天然继承可用
|
||||
*/
|
||||
public abstract class BaseWinBoLLActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
public static final String TAG = "BaseWinBoLLActivity";
|
||||
|
||||
protected volatile AESThemeBean.ThemeType mThemeType;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
//AESThemeUtil.applyAppCompatTheme(this);
|
||||
mThemeType = AESThemeBean.getThemeStyleType(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||
setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||
super.onCreate(savedInstanceState);
|
||||
WinBoLLActivityManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
WinBoLLActivityManager.getInstance().registeRemove(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
// 子类必须实现getTag(),确保唯一标识
|
||||
@Override
|
||||
public abstract String getTag();
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import cc.winboll.studio.bytheway.R;
|
||||
import cc.winboll.studio.bytheway.adapters.GpsAdapter;
|
||||
import cc.winboll.studio.bytheway.helpers.GpsDbManager;
|
||||
import cc.winboll.studio.bytheway.models.GpsBean;
|
||||
import cc.winboll.studio.bytheway.utils.GpsUtil;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,7 +24,6 @@ public class GpsListActivity extends AppCompatActivity {
|
||||
|
||||
private SwipeRefreshLayout swipeRefresh;
|
||||
private RecyclerView rvGps;
|
||||
private GpsDbManager dbManager;
|
||||
private GpsAdapter adapter;
|
||||
|
||||
@Override
|
||||
@@ -41,7 +40,6 @@ public class GpsListActivity extends AppCompatActivity {
|
||||
private void initView() {
|
||||
swipeRefresh = findViewById(R.id.swipe_refresh_layout);
|
||||
rvGps = findViewById(R.id.rv_gps_list);
|
||||
dbManager = new GpsDbManager(this);
|
||||
rvGps.setLayoutManager(new LinearLayoutManager(this));
|
||||
LogUtils.i("GpsListActivity", "控件初始化完成");
|
||||
}
|
||||
@@ -64,7 +62,7 @@ public class GpsListActivity extends AppCompatActivity {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<GpsBean> gpsDataList = dbManager.queryAllGps();
|
||||
final List<GpsBean> gpsDataList = GpsUtil.queryAllGps(GpsListActivity.this);
|
||||
LogUtils.i("GpsListActivity", "查询GPS数据条数:" + gpsDataList.size());
|
||||
|
||||
adapter = new GpsAdapter(GpsListActivity.this, gpsDataList);
|
||||
|
||||
@@ -16,17 +16,18 @@ public class SettingsActivity extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
|
||||
Switch swGpsService = findViewById(R.id.sw_gps_service);
|
||||
swGpsService.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
Switch swGpsReceiveService = findViewById(R.id.sw_gps_receive_service);
|
||||
swGpsReceiveService.setChecked(GpsReceiveService.isServiceRunning());
|
||||
swGpsReceiveService.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
GpsReceiveService.startGpsService(SettingsActivity.this);
|
||||
GpsReceiveService.startGpsReceiveService(SettingsActivity.this);
|
||||
} else {
|
||||
GpsReceiveService.stopGpsService(SettingsActivity.this);
|
||||
GpsReceiveService.stopGpsReceiveService(SettingsActivity.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.bytheway.R;
|
||||
import cc.winboll.studio.bytheway.models.GpsBean;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import cc.winboll.studio.bytheway.utils.GpsUtil;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -21,7 +20,6 @@ public class GpsAdapter extends RecyclerView.Adapter<GpsAdapter.GpsHolder> {
|
||||
|
||||
private final Context context;
|
||||
private final List<GpsBean> gpsList;
|
||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public GpsAdapter(Context context, List<GpsBean> gpsList) {
|
||||
this.context = context;
|
||||
@@ -39,15 +37,12 @@ public class GpsAdapter extends RecyclerView.Adapter<GpsAdapter.GpsHolder> {
|
||||
public void onBindViewHolder(@NonNull GpsHolder holder, int position) {
|
||||
GpsBean bean = gpsList.get(position);
|
||||
|
||||
//时间格式化
|
||||
String time = sdf.format(new Date(bean.getReceiveTime()));
|
||||
String time = GpsUtil.formatTime(bean.getReceiveTime());
|
||||
holder.tvTime.setText("接收时间:" + time);
|
||||
|
||||
//经纬度
|
||||
holder.tvLatLng.setText("纬度:" + bean.getLatitude() + " 经度:" + bean.getLongitude());
|
||||
holder.tvLatLng.setText(GpsUtil.formatLatLng(bean.getLatitude(), bean.getLongitude()));
|
||||
|
||||
//海拔、精度、速度
|
||||
holder.tvOther.setText("精度:"+bean.getAccuracy()+"m 海拔:"+bean.getAltitude()+"m 速度:"+bean.getSpeed()+"m/s");
|
||||
holder.tvOther.setText(GpsUtil.formatOther(bean.getAccuracy(), bean.getAltitude(), bean.getSpeed()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package cc.winboll.studio.bytheway.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
/**
|
||||
* GPS数据库创建、版本升级管理
|
||||
* @author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||
* 创建时间:2026-07-02 15:00:00
|
||||
* 最后编辑时间:2026-07-02 16:35:41
|
||||
*/
|
||||
public class GpsDbHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final String DB_NAME = "GpsLocation.db";
|
||||
private static final int DB_VERSION = 1;
|
||||
public static final String TABLE_GPS = "gps_table";
|
||||
|
||||
private static final String CREATE_TABLE = "CREATE TABLE " + TABLE_GPS + " ("
|
||||
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
+ "latitude REAL,"
|
||||
+ "longitude REAL,"
|
||||
+ "accuracy REAL,"
|
||||
+ "altitude REAL,"
|
||||
+ "speed REAL,"
|
||||
+ "receive_time INTEGER"
|
||||
+ ")";
|
||||
|
||||
public GpsDbHelper(final Context context) {
|
||||
super(context, DB_NAME, null, DB_VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(final SQLiteDatabase db) {
|
||||
db.execSQL(CREATE_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
|
||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_GPS);
|
||||
onCreate(db);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
package cc.winboll.studio.bytheway.helpers;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import cc.winboll.studio.bytheway.models.GpsBean;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* GPS SQLite数据库数据管理工具
|
||||
* 负责本地定位轨迹插入、查询、时间段筛选、清空操作
|
||||
* @author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||
* 创建时间:2026-07-02 15:03:00
|
||||
* 最后编辑时间:2026-07-02 16:35:41
|
||||
*/
|
||||
public class GpsDbManager {
|
||||
|
||||
private static final String TABLE_GPS = "gps_table";
|
||||
private final GpsDbHelper dbHelper;
|
||||
|
||||
public GpsDbManager(final Context context) {
|
||||
dbHelper = new GpsDbHelper(context);
|
||||
}
|
||||
|
||||
//插入单条GPS定位数据
|
||||
public void insertGps(final GpsBean bean) {
|
||||
final SQLiteDatabase db = dbHelper.getWritableDatabase();
|
||||
final ContentValues values = new ContentValues();
|
||||
|
||||
values.put("latitude", bean.getLatitude());
|
||||
values.put("longitude", bean.getLongitude());
|
||||
values.put("accuracy", bean.getAccuracy());
|
||||
values.put("altitude", bean.getAltitude());
|
||||
values.put("speed", bean.getSpeed());
|
||||
values.put("receive_time", bean.getReceiveTime());
|
||||
|
||||
db.insert(TABLE_GPS, null, values);
|
||||
LogUtils.i("GpsDbManager", "GPS数据插入成功");
|
||||
db.close();
|
||||
}
|
||||
|
||||
//查询全部GPS记录,按时间倒序排列
|
||||
public List<GpsBean> queryAllGps() {
|
||||
final List<GpsBean> list = new ArrayList<GpsBean>();
|
||||
final SQLiteDatabase db = dbHelper.getReadableDatabase();
|
||||
|
||||
final Cursor cursor = db.query(TABLE_GPS, null, null, null, null, null, "receive_time DESC");
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
final GpsBean bean = new GpsBean();
|
||||
bean.setId(cursor.getInt(0));
|
||||
bean.setLatitude(cursor.getDouble(1));
|
||||
bean.setLongitude(cursor.getDouble(2));
|
||||
bean.setAccuracy(cursor.getFloat(3));
|
||||
bean.setAltitude(cursor.getDouble(4));
|
||||
bean.setSpeed(cursor.getFloat(5));
|
||||
bean.setReceiveTime(cursor.getLong(6));
|
||||
|
||||
list.add(bean);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
||||
LogUtils.i("GpsDbManager", "查询全部GPS条数:" + list.size());
|
||||
cursor.close();
|
||||
db.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
//根据时间区间查询GPS轨迹
|
||||
public List<GpsBean> queryByTime(final long startTime, final long endTime) {
|
||||
final List<GpsBean> list = new ArrayList<GpsBean>();
|
||||
final SQLiteDatabase db = dbHelper.getReadableDatabase();
|
||||
|
||||
final String where = "receive_time >= ? AND receive_time <= ?";
|
||||
final String[] args = {String.valueOf(startTime), String.valueOf(endTime)};
|
||||
|
||||
final Cursor cursor = db.query(TABLE_GPS, null, where, args, null, null, "receive_time ASC");
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
final GpsBean bean = new GpsBean();
|
||||
bean.setId(cursor.getInt(0));
|
||||
bean.setLatitude(cursor.getDouble(1));
|
||||
bean.setLongitude(cursor.getDouble(2));
|
||||
bean.setAccuracy(cursor.getFloat(3));
|
||||
bean.setAltitude(cursor.getDouble(4));
|
||||
bean.setSpeed(cursor.getFloat(5));
|
||||
bean.setReceiveTime(cursor.getLong(6));
|
||||
|
||||
list.add(bean);
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
|
||||
LogUtils.i("GpsDbManager", "时间段查询GPS条数:" + list.size());
|
||||
cursor.close();
|
||||
db.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
//清空所有本地GPS历史数据
|
||||
public void clearAllGps() {
|
||||
final SQLiteDatabase db = dbHelper.getWritableDatabase();
|
||||
db.delete(TABLE_GPS, null, null);
|
||||
LogUtils.i("GpsDbManager", "已清空全部GPS数据库数据");
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
|
||||
+129
-57
@@ -4,125 +4,185 @@ import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.bytheway.helpers.GpsDbManager;
|
||||
import cc.winboll.studio.bytheway.models.GpsBean;
|
||||
import cc.winboll.studio.bytheway.utils.GpsUtil;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
/**
|
||||
* @Author 豆包&BigPickle&ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/07/02 15:33
|
||||
* @Describe 动态注册定位广播,接收GPS数据并持久化存入SQLite数据库。单例独占模式,自带重复启动拦截,对外静态统一启停接口
|
||||
* @Describe GPS定位接收服务,通过LocationManager获取GPS数据并持久化存入SQLite数据库。单例独占模式,自带重复启动拦截,对外静态统一启停接口
|
||||
*/
|
||||
public class GpsReceiveService extends Service {
|
||||
|
||||
public static final String TAG = "GpsReceiveService";
|
||||
private static final int NOTIFICATION_ID = 1001;
|
||||
private static final String CHANNEL_ID = "gps_service_channel";
|
||||
private static final String CHANNEL_ID = "gps_receive_service_channel";
|
||||
|
||||
private static boolean serviceRunning = false;
|
||||
private GpsDbManager dbManager;
|
||||
private BroadcastReceiver gpsBroadcastReceiver;
|
||||
private static GpsReceiveService instance;
|
||||
private int gpsReceiveCount = 0;
|
||||
private GpsBean currentGpsBean;
|
||||
private LocationManager locationManager;
|
||||
private LocationListener locationListener;
|
||||
|
||||
/**
|
||||
* 获取GPS定位服务运行状态
|
||||
* @return true=服务正在运行, false=服务未运行
|
||||
*/
|
||||
public static boolean isServiceRunning() {
|
||||
return serviceRunning;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前最新的GPS定位数据
|
||||
* @return 当前GPS数据,未收到定位时返回null
|
||||
*/
|
||||
public static GpsBean getCurrentGpsBean() {
|
||||
return serviceRunning ? instance.currentGpsBean : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部统一静态启动服务
|
||||
*/
|
||||
public static void startGpsService(final Context context) {
|
||||
public static void startGpsReceiveService(final Context context) {
|
||||
if (serviceRunning) {
|
||||
LogUtils.i("GpsReceiveService", "服务已运行,无需重复启动");
|
||||
return;
|
||||
}
|
||||
final Intent intent = new Intent(context, GpsReceiveService.class);
|
||||
context.startService(intent);
|
||||
LogUtils.i("GpsReceiveService", "GPS接收服务启动请求发送");
|
||||
LogUtils.i("GpsReceiveService", "GPS定位消息接收服务启动请求发送");
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部统一静态关闭服务
|
||||
*/
|
||||
public static void stopGpsService(final Context context) {
|
||||
public static void stopGpsReceiveService(final Context context) {
|
||||
if (!serviceRunning) {
|
||||
LogUtils.i("GpsReceiveService", "服务未运行,无需关闭");
|
||||
return;
|
||||
}
|
||||
final Intent intent = new Intent(context, GpsReceiveService.class);
|
||||
context.stopService(intent);
|
||||
LogUtils.i("GpsReceiveService", "GPS接收服务停止请求发送");
|
||||
LogUtils.i("GpsReceiveService", "GPS定位消息接收服务停止请求发送");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
instance = this;
|
||||
serviceRunning = true;
|
||||
dbManager = new GpsDbManager(getApplicationContext());
|
||||
registerGpsBroadcast();
|
||||
gpsReceiveCount = 0;
|
||||
currentGpsBean = null;
|
||||
startGpsLocationUpdates();
|
||||
startForeground(NOTIFICATION_ID, createNotification());
|
||||
LogUtils.i("GpsReceiveService", "GPS接收服务创建完成");
|
||||
Toast.makeText(this, "GPS定位服务已开启", Toast.LENGTH_SHORT).show();
|
||||
LogUtils.i("GpsReceiveService", "GPS定位消息接收服务创建完成");
|
||||
Toast.makeText(this, "GPS定位消息接收服务已开启", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private Notification createNotification() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(
|
||||
CHANNEL_ID,
|
||||
"GPS定位服务",
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
CHANNEL_ID,
|
||||
"GPS定位消息接收服务",
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
);
|
||||
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
String contentText;
|
||||
if (currentGpsBean != null) {
|
||||
contentText = "已接收 " + gpsReceiveCount + " 次 | "
|
||||
+ "纬度:" + currentGpsBean.getLatitude()
|
||||
+ " 经度:" + currentGpsBean.getLongitude()
|
||||
+ " 精度:" + currentGpsBean.getAccuracy() + "m";
|
||||
} else {
|
||||
contentText = "等待GPS定位数据...";
|
||||
}
|
||||
return new Notification.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle("ByTheWay")
|
||||
.setContentText("GPS定位服务运行中")
|
||||
.setSmallIcon(android.R.drawable.ic_menu_mylocation)
|
||||
.setOngoing(true)
|
||||
.build();
|
||||
.setContentTitle("ByTheWay")
|
||||
.setContentText(contentText)
|
||||
.setSmallIcon(android.R.drawable.ic_menu_mylocation)
|
||||
.setOngoing(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态注册GPS定位广播接收器
|
||||
* 更新前台服务通知栏显示
|
||||
*/
|
||||
private void registerGpsBroadcast() {
|
||||
gpsBroadcastReceiver = new BroadcastReceiver() {
|
||||
private void updateNotification() {
|
||||
final NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
manager.notify(NOTIFICATION_ID, createNotification());
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动GPS定位更新监听
|
||||
*/
|
||||
private void startGpsLocationUpdates() {
|
||||
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
locationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
parseAndSaveGpsData(intent);
|
||||
public void onLocationChanged(final Location location) {
|
||||
handleGpsLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(final String provider, final int status, final Bundle extras) {
|
||||
LogUtils.d("GpsReceiveService", "GPS状态变化: " + provider + ", status=" + status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(final String provider) {
|
||||
LogUtils.d("GpsReceiveService", "GPS提供者已启用: " + provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(final String provider) {
|
||||
LogUtils.d("GpsReceiveService", "GPS提供者已禁用: " + provider);
|
||||
}
|
||||
};
|
||||
final IntentFilter filter = new IntentFilter();
|
||||
//GPS定位广播动作,与你定位发送广播对应
|
||||
filter.addAction("android.location.GPS_LOCATION_BROADCAST");
|
||||
registerReceiver(gpsBroadcastReceiver, filter);
|
||||
LogUtils.i("GpsReceiveService", "GPS广播动态注册成功");
|
||||
try {
|
||||
// 最小时间间隔1秒,最小距离间隔0米,确保每次位置更新都能接收
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.GPS_PROVIDER,
|
||||
1000L,
|
||||
0f,
|
||||
locationListener
|
||||
);
|
||||
LogUtils.i("GpsReceiveService", "GPS定位监听已启动");
|
||||
} catch (SecurityException e) {
|
||||
LogUtils.e("GpsReceiveService", "缺少GPS定位权限: " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("GpsReceiveService", "启动GPS定位监听失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析广播GPS数据并写入SQLite数据库
|
||||
* 处理GPS定位数据,写入SQLite数据库并更新通知栏
|
||||
*/
|
||||
private void parseAndSaveGpsData(final Intent intent) {
|
||||
final double latitude = intent.getDoubleExtra("latitude", 0);
|
||||
final double longitude = intent.getDoubleExtra("longitude", 0);
|
||||
final float accuracy = intent.getFloatExtra("accuracy", 0);
|
||||
final double altitude = intent.getDoubleExtra("altitude", 0);
|
||||
final float speed = intent.getFloatExtra("speed", 0);
|
||||
final long time = intent.getLongExtra("receive_time", System.currentTimeMillis());
|
||||
|
||||
private void handleGpsLocation(final Location location) {
|
||||
final GpsBean bean = new GpsBean();
|
||||
bean.setLatitude(latitude);
|
||||
bean.setLongitude(longitude);
|
||||
bean.setAccuracy(accuracy);
|
||||
bean.setAltitude(altitude);
|
||||
bean.setSpeed(speed);
|
||||
bean.setReceiveTime(time);
|
||||
|
||||
dbManager.insertGps(bean);
|
||||
LogUtils.d("GpsReceiveService", "收到GPS广播,已保存定位数据");
|
||||
bean.setLatitude(location.getLatitude());
|
||||
bean.setLongitude(location.getLongitude());
|
||||
bean.setAccuracy(location.getAccuracy());
|
||||
bean.setAltitude(location.getAltitude());
|
||||
bean.setSpeed(location.getSpeed());
|
||||
bean.setReceiveTime(System.currentTimeMillis());
|
||||
currentGpsBean = bean;
|
||||
GpsUtil.insertGps(getApplicationContext(), bean);
|
||||
gpsReceiveCount++;
|
||||
updateNotification();
|
||||
LogUtils.d("GpsReceiveService", "收到GPS定位,已保存数据,累计接收 " + gpsReceiveCount + " 次");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,15 +198,27 @@ public class GpsReceiveService extends Service {
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
stopGpsLocationUpdates();
|
||||
stopForeground(true);
|
||||
serviceRunning = false;
|
||||
//反注册广播,防止内存泄漏
|
||||
if (gpsBroadcastReceiver != null) {
|
||||
unregisterReceiver(gpsBroadcastReceiver);
|
||||
}
|
||||
LogUtils.i("GpsReceiveService", "GPS接收服务已销毁,广播已解绑");
|
||||
instance = null;
|
||||
LogUtils.i("GpsReceiveService", "GPS接收服务已销毁,定位监听已停止");
|
||||
Toast.makeText(this, "GPS定位服务已关闭", Toast.LENGTH_SHORT).show();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 停止GPS定位更新监听
|
||||
*/
|
||||
private void stopGpsLocationUpdates() {
|
||||
if (locationManager != null && locationListener != null) {
|
||||
try {
|
||||
locationManager.removeUpdates(locationListener);
|
||||
LogUtils.i("GpsReceiveService", "GPS定位监听已移除");
|
||||
} catch (SecurityException e) {
|
||||
LogUtils.e("GpsReceiveService", "移除GPS监听异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
package cc.winboll.studio.bytheway.utils;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import cc.winboll.studio.bytheway.models.GpsBean;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* GPS数据处理模块
|
||||
* 集合GPS数据解析、格式化、数据库存取等所有操作,外部统一通过本类访问
|
||||
* @author ZhanGSKen<zhangsken@qq.com>
|
||||
*/
|
||||
public class GpsUtil {
|
||||
|
||||
private static final String TAG = "GpsUtil";
|
||||
|
||||
// Intent广播中的GPS数据键名
|
||||
public static final String KEY_LATITUDE = "latitude";
|
||||
public static final String KEY_LONGITUDE = "longitude";
|
||||
public static final String KEY_ACCURACY = "accuracy";
|
||||
public static final String KEY_ALTITUDE = "altitude";
|
||||
public static final String KEY_SPEED = "speed";
|
||||
public static final String KEY_RECEIVE_TIME = "receive_time";
|
||||
|
||||
// 时间格式
|
||||
private static final String FORMAT_TIME = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
// ======================== 数据解析方法 ========================
|
||||
|
||||
/**
|
||||
* 从Intent广播数据中解析GPS定位信息,构造GpsBean对象
|
||||
* @param intent GPS定位广播Intent
|
||||
* @return 解析后的GpsBean对象
|
||||
*/
|
||||
public static GpsBean parseFromIntent(final Intent intent) {
|
||||
final double latitude = intent.getDoubleExtra(KEY_LATITUDE, 0);
|
||||
final double longitude = intent.getDoubleExtra(KEY_LONGITUDE, 0);
|
||||
final float accuracy = intent.getFloatExtra(KEY_ACCURACY, 0);
|
||||
final double altitude = intent.getDoubleExtra(KEY_ALTITUDE, 0);
|
||||
final float speed = intent.getFloatExtra(KEY_SPEED, 0);
|
||||
final long time = intent.getLongExtra(KEY_RECEIVE_TIME, System.currentTimeMillis());
|
||||
|
||||
final GpsBean bean = new GpsBean();
|
||||
bean.setLatitude(latitude);
|
||||
bean.setLongitude(longitude);
|
||||
bean.setAccuracy(accuracy);
|
||||
bean.setAltitude(altitude);
|
||||
bean.setSpeed(speed);
|
||||
bean.setReceiveTime(time);
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从数据库游标中解析GPS定位信息,构造GpsBean对象
|
||||
* 游标字段顺序:id, latitude, longitude, accuracy, altitude, speed, receive_time
|
||||
* @param cursor 数据库查询游标(需已定位到目标行)
|
||||
* @return 解析后的GpsBean对象
|
||||
*/
|
||||
public static GpsBean parseFromCursor(final Cursor cursor) {
|
||||
final GpsBean bean = new GpsBean();
|
||||
bean.setId(cursor.getInt(0));
|
||||
bean.setLatitude(cursor.getDouble(1));
|
||||
bean.setLongitude(cursor.getDouble(2));
|
||||
bean.setAccuracy(cursor.getFloat(3));
|
||||
bean.setAltitude(cursor.getDouble(4));
|
||||
bean.setSpeed(cursor.getFloat(5));
|
||||
bean.setReceiveTime(cursor.getLong(6));
|
||||
return bean;
|
||||
}
|
||||
|
||||
// ======================== 格式化方法 ========================
|
||||
|
||||
/**
|
||||
* 将时间戳格式化为可读时间字符串
|
||||
* @param timestamp 毫秒时间戳
|
||||
* @return 格式化后的时间字符串
|
||||
*/
|
||||
public static String formatTime(final long timestamp) {
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_TIME, Locale.getDefault());
|
||||
return sdf.format(new Date(timestamp));
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化经纬度显示文本
|
||||
* @param latitude 纬度
|
||||
* @param longitude 经度
|
||||
* @return 格式化后的经纬度字符串
|
||||
*/
|
||||
public static String formatLatLng(final double latitude, final double longitude) {
|
||||
return "纬度:" + latitude + " 经度:" + longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化精度、海拔、速度显示文本
|
||||
* @param accuracy 精度(米)
|
||||
* @param altitude 海拔(米)
|
||||
* @param speed 速度(m/s)
|
||||
* @return 格式化后的字符串
|
||||
*/
|
||||
public static String formatOther(final float accuracy, final double altitude, final float speed) {
|
||||
return "精度:" + accuracy + "m 海拔:" + altitude + "m 速度:" + speed + "m/s";
|
||||
}
|
||||
|
||||
/**
|
||||
* 将速度从m/s转换为km/h
|
||||
* @param speedMps 速度(m/s)
|
||||
* @return 速度(km/h)
|
||||
*/
|
||||
public static float speedToKmh(final float speedMps) {
|
||||
return speedMps * 3.6f;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化速度显示文本(km/h)
|
||||
* @param speedMps 速度(m/s)
|
||||
* @return 格式化后的速度字符串
|
||||
*/
|
||||
public static String formatSpeed(final float speedMps) {
|
||||
return speedToKmh(speedMps) + "km/h";
|
||||
}
|
||||
|
||||
// ======================== 数据库操作方法 ========================
|
||||
|
||||
/**
|
||||
* 插入单条GPS定位数据
|
||||
* @param context 上下文
|
||||
* @param bean GPS数据对象
|
||||
*/
|
||||
public static void insertGps(final Context context, final GpsBean bean) {
|
||||
final GpsDbHelper helper = new GpsDbHelper(context);
|
||||
final SQLiteDatabase db = helper.getWritableDatabase();
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put("latitude", bean.getLatitude());
|
||||
values.put("longitude", bean.getLongitude());
|
||||
values.put("accuracy", bean.getAccuracy());
|
||||
values.put("altitude", bean.getAltitude());
|
||||
values.put("speed", bean.getSpeed());
|
||||
values.put("receive_time", bean.getReceiveTime());
|
||||
db.insert(GpsDbHelper.TABLE_GPS, null, values);
|
||||
LogUtils.i(TAG, "GPS数据插入成功");
|
||||
db.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部GPS记录,按时间倒序排列
|
||||
* @param context 上下文
|
||||
* @return GPS数据列表
|
||||
*/
|
||||
public static List<GpsBean> queryAllGps(final Context context) {
|
||||
final List<GpsBean> list = new ArrayList<GpsBean>();
|
||||
final GpsDbHelper helper = new GpsDbHelper(context);
|
||||
final SQLiteDatabase db = helper.getReadableDatabase();
|
||||
final Cursor cursor = db.query(GpsDbHelper.TABLE_GPS, null, null, null, null, null, "receive_time DESC");
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
list.add(parseFromCursor(cursor));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
LogUtils.i(TAG, "查询全部GPS条数:" + list.size());
|
||||
cursor.close();
|
||||
db.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间区间查询GPS轨迹
|
||||
* @param context 上下文
|
||||
* @param startTime 起始时间戳
|
||||
* @param endTime 结束时间戳
|
||||
* @return GPS数据列表
|
||||
*/
|
||||
public static List<GpsBean> queryByTime(final Context context, final long startTime, final long endTime) {
|
||||
final List<GpsBean> list = new ArrayList<GpsBean>();
|
||||
final GpsDbHelper helper = new GpsDbHelper(context);
|
||||
final SQLiteDatabase db = helper.getReadableDatabase();
|
||||
final String where = "receive_time >= ? AND receive_time <= ?";
|
||||
final String[] args = {String.valueOf(startTime), String.valueOf(endTime)};
|
||||
final Cursor cursor = db.query(GpsDbHelper.TABLE_GPS, null, where, args, null, null, "receive_time ASC");
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
list.add(parseFromCursor(cursor));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
LogUtils.i(TAG, "时间段查询GPS条数:" + list.size());
|
||||
cursor.close();
|
||||
db.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空所有本地GPS历史数据
|
||||
* @param context 上下文
|
||||
*/
|
||||
public static void clearAllGps(final Context context) {
|
||||
final GpsDbHelper helper = new GpsDbHelper(context);
|
||||
final SQLiteDatabase db = helper.getWritableDatabase();
|
||||
db.delete(GpsDbHelper.TABLE_GPS, null, null);
|
||||
LogUtils.i(TAG, "已清空全部GPS数据库数据");
|
||||
db.close();
|
||||
}
|
||||
|
||||
// ======================== 内部类:数据库管理 ========================
|
||||
|
||||
/**
|
||||
* SQLite数据库创建、版本升级管理
|
||||
*/
|
||||
private static class GpsDbHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final String DB_NAME = "GpsLocation.db";
|
||||
private static final int DB_VERSION = 1;
|
||||
private static final String TABLE_GPS = "gps_table";
|
||||
|
||||
private static final String CREATE_TABLE = "CREATE TABLE " + TABLE_GPS + " ("
|
||||
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
+ "latitude REAL,"
|
||||
+ "longitude REAL,"
|
||||
+ "accuracy REAL,"
|
||||
+ "altitude REAL,"
|
||||
+ "speed REAL,"
|
||||
+ "receive_time INTEGER"
|
||||
+ ")";
|
||||
|
||||
public GpsDbHelper(final Context context) {
|
||||
super(context, DB_NAME, null, DB_VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(final SQLiteDatabase db) {
|
||||
db.execSQL(CREATE_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
|
||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_GPS);
|
||||
onCreate(db);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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" android:background="@drawable/bg_container_border">
|
||||
|
||||
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/toolbar"/>
|
||||
|
||||
<cc.winboll.studio.libappbase.views.AboutView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/aboutview"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/sw_gps_service"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="GPS定位服务" />
|
||||
<Switch
|
||||
android:id="@+id/sw_gps_receive_service"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="GPS定位消息接收服务"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -14,4 +14,10 @@
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_about"
|
||||
android:icon="@android:drawable/ic_menu_info_details"
|
||||
android:title="@string/action_about"
|
||||
app:showAsAction="never" />
|
||||
|
||||
</menu>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">老君道说</string>
|
||||
<string name="app_name">顺道说</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
<string name="app_name">ByTheWay</string>
|
||||
<string name="action_settings">设置</string>
|
||||
<string name="action_gps_list">GPS列表</string>
|
||||
<string name="action_about">应用介绍</string>
|
||||
<string name="app_description">The [ByTheWay] project is designed to quickly schedule task reminders related to time and location. Its main feature is the ability to quickly create task-related data.</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user