Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ captures/

# Google Services (e.g. APIs or Firebase)
google-services.json
/secrets.properties
2 changes: 0 additions & 2 deletions app/.settings/org.eclipse.buildship.core.prefs

This file was deleted.

24 changes: 18 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
plugins {
id "com.android.application"
// 谷歌官方推荐的用于隐藏地图 KEY 的插件 https://developers.google.com/maps/documentation/places/android-sdk/secrets-gradle-plugin?hl=zh-cn
id "com.google.android.libraries.mapsplatform.secrets-gradle-plugin"
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}

android {
ndkVersion = '26.2.11394342'
compileSdk = 32
buildToolsVersion = '36.0.0'
namespace = 'com.zcshou.gogogo'

signingConfigs {
Expand All @@ -31,7 +29,7 @@ android {
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 32
versionCode 1123
versionName '1.12.3' // https://semver.org/lang/zh-CN/
versionName '1.12.3'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resourceConfigurations += ['zh', 'zh-rCN', 'en', 'en-rUS']
ndk {
Expand All @@ -54,7 +52,7 @@ android {
// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

signingConfig = signingConfigs.release
multiDexEnabled = true
Expand All @@ -64,7 +62,6 @@ android {
}
}

// 要存取 secret value 必須要使用到一個 BuildScript 的類別,默认会从 local.properties 中获取
buildFeatures {
buildConfig = true
}
Expand Down Expand Up @@ -111,6 +108,21 @@ android {
}
}

secrets {
// Optionally specify a different file name containing your secrets.
// The plugin defaults to "local.properties"
propertiesFileName = "secrets.properties"

// A properties file containing default secret values. This file can be
// checked in version control.
// defaultPropertiesFileName = "local.defaults.properties"

// Configure which keys should be ignored by the plugin by providing regular expressions.
// "sdk.dir" is ignored by default.
ignoreList.add("keyToIgnore") // Ignore the key "keyToIgnore"
ignoreList.add("sdk.*") // Ignore all keys matching the regexp "sdk.*"
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// AppCompat 1.5.1 开始显式依赖于 Lifecycle 2.5.1 和 SavedState 1.2.0
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/com/zcshou/database/DataBaseHistoryLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@ public static void updateHistoryLocation(SQLiteDatabase sqLiteDatabase, String l
XLog.e("DATABASE: update error");
}
}

// 更新历史记录的时间戳和名称(用于从历史记录中重新选择位置时,仅更新时间)
public static void updateHistoryTimestamp(SQLiteDatabase sqLiteDatabase, String locID, String location, long timestamp) {
try {
ContentValues contentValues = new ContentValues();
contentValues.put(DB_COLUMN_LOCATION, location);
contentValues.put(DB_COLUMN_TIMESTAMP, timestamp);
sqLiteDatabase.update(TABLE_NAME, contentValues, DB_COLUMN_ID + " = ?", new String[]{locID});
} catch (Exception e) {
XLog.e("DATABASE: update timestamp error");
}
}
}
24 changes: 23 additions & 1 deletion app/src/main/java/com/zcshou/gogogo/FragmentSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,29 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
}

EditTextPreference pfPosHisValid = findPreference("setting_history_expiration");
setupDecimalEditTextPreference(pfPosHisValid);
if (pfPosHisValid != null) {
pfPosHisValid.setSummaryProvider((Preference.SummaryProvider<EditTextPreference>) EditTextPreference::getText);
pfPosHisValid.setOnBindEditTextListener(editText -> {
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
editText.setSelection(editText.length());
});
// 当用户设置为永不过期(≤ 0)时弹出警告
pfPosHisValid.setOnPreferenceChangeListener((pref, newValue) -> {
if (newValue.toString().trim().isEmpty()) {
GoUtils.DisplayToast(this.getContext(), getResources().getString(R.string.app_error_input_null));
return false;
}
try {
if (Double.parseDouble(newValue.toString()) <= 0) {
GoUtils.DisplayToast(this.getContext(), getResources().getString(R.string.history_expiration_never_warn));
}
} catch (NumberFormatException e) {
GoUtils.DisplayToast(this.getContext(), getResources().getString(R.string.app_error_input));
return false;
}
return true;
});
}

// 设置版本号
String verName;
Expand Down
Loading