mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 09:33:33 +00:00
fix:github release check (#253)
This commit is contained in:
commit
62a10d142e
8 changed files with 37 additions and 6 deletions
|
|
@ -11,7 +11,7 @@ android {
|
||||||
targetSdk 35
|
targetSdk 35
|
||||||
|
|
||||||
versionCode 5
|
versionCode 5
|
||||||
versionName '4.2.0'
|
versionName '4.2.1'
|
||||||
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
||||||
|
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,11 @@ public class UpdateUtil {
|
||||||
|
|
||||||
public static boolean showUpdateDialog(LatestRelease release) {
|
public static boolean showUpdateDialog(LatestRelease release) {
|
||||||
if (release.getTagName() == null) return false;
|
if (release.getTagName() == null) return false;
|
||||||
|
String remoteTag = release.getTagName().replaceAll("^\\D+", "");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String[] local = BuildConfig.VERSION_NAME.split("\\.");
|
String[] local = BuildConfig.VERSION_NAME.split("\\.");
|
||||||
String[] remote = release.getTagName().split("\\.");
|
String[] remote = remoteTag.split("\\.");
|
||||||
|
|
||||||
for (int i = 0; i < local.length; i++) {
|
for (int i = 0; i < local.length; i++) {
|
||||||
int localPart = Integer.parseInt(local[i]);
|
int localPart = Integer.parseInt(local[i]);
|
||||||
|
|
|
||||||
|
|
@ -438,7 +438,7 @@ public class MainActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTempoUpdate() {
|
private void checkTempoUpdate() {
|
||||||
if (BuildConfig.FLAVOR.equals("tempus") && Preferences.showTempoUpdateDialog()) {
|
if (BuildConfig.FLAVOR.equals("tempus") && Preferences.isGithubUpdateEnabled() && Preferences.showTempusUpdateDialog()) {
|
||||||
mainViewModel.checkTempoUpdate().observe(this, latestRelease -> {
|
mainViewModel.checkTempoUpdate().observe(this, latestRelease -> {
|
||||||
if (latestRelease != null && UpdateUtil.showUpdateDialog(latestRelease)) {
|
if (latestRelease != null && UpdateUtil.showUpdateDialog(latestRelease)) {
|
||||||
GithubTempoUpdateDialog dialog = new GithubTempoUpdateDialog(latestRelease);
|
GithubTempoUpdateDialog dialog = new GithubTempoUpdateDialog(latestRelease);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class GithubTempoUpdateDialog extends DialogFragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v -> {
|
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v -> {
|
||||||
Preferences.setTempoUpdateReminder();
|
Preferences.setTempusUpdateReminder();
|
||||||
Objects.requireNonNull(getDialog()).dismiss();
|
Objects.requireNonNull(getDialog()).dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import androidx.navigation.NavOptions;
|
||||||
import androidx.navigation.fragment.NavHostFragment;
|
import androidx.navigation.fragment.NavHostFragment;
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
|
|
@ -77,6 +78,13 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
result -> {}
|
result -> {}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!BuildConfig.FLAVOR.equals("tempus")) {
|
||||||
|
PreferenceCategory githubUpdateCategory = findPreference("settings_github_update_category_key");
|
||||||
|
if (githubUpdateCategory != null) {
|
||||||
|
getPreferenceScreen().removePreference(githubUpdateCategory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
directoryPickerLauncher = registerForActivityResult(
|
directoryPickerLauncher = registerForActivityResult(
|
||||||
new ActivityResultContracts.StartActivityForResult(),
|
new ActivityResultContracts.StartActivityForResult(),
|
||||||
result -> {
|
result -> {
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ object Preferences {
|
||||||
private const val SONG_RATING_PER_ITEM = "song_rating_per_item"
|
private const val SONG_RATING_PER_ITEM = "song_rating_per_item"
|
||||||
private const val RATING_PER_ITEM = "rating_per_item"
|
private const val RATING_PER_ITEM = "rating_per_item"
|
||||||
private const val NEXT_UPDATE_CHECK = "next_update_check"
|
private const val NEXT_UPDATE_CHECK = "next_update_check"
|
||||||
|
private const val GITHUB_UPDATE_CHECK = "github_update_check"
|
||||||
private const val CONTINUOUS_PLAY = "continuous_play"
|
private const val CONTINUOUS_PLAY = "continuous_play"
|
||||||
private const val LAST_INSTANT_MIX = "last_instant_mix"
|
private const val LAST_INSTANT_MIX = "last_instant_mix"
|
||||||
private const val ALLOW_PLAYLIST_DUPLICATES = "allow_playlist_duplicates"
|
private const val ALLOW_PLAYLIST_DUPLICATES = "allow_playlist_duplicates"
|
||||||
|
|
@ -574,15 +575,21 @@ object Preferences {
|
||||||
return App.getInstance().preferences.getBoolean(RATING_PER_ITEM, false)
|
return App.getInstance().preferences.getBoolean(RATING_PER_ITEM, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun showTempoUpdateDialog(): Boolean {
|
fun isGithubUpdateEnabled(): Boolean {
|
||||||
|
return App.getInstance().preferences.getBoolean(GITHUB_UPDATE_CHECK, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun showTempusUpdateDialog(): Boolean {
|
||||||
return App.getInstance().preferences.getLong(
|
return App.getInstance().preferences.getLong(
|
||||||
NEXT_UPDATE_CHECK, 0
|
NEXT_UPDATE_CHECK, 0
|
||||||
) + 86400000 < System.currentTimeMillis()
|
) + 86400000 < System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun setTempoUpdateReminder() {
|
fun setTempusUpdateReminder() {
|
||||||
App.getInstance().preferences.edit().putLong(NEXT_UPDATE_CHECK, System.currentTimeMillis()).apply()
|
App.getInstance().preferences.edit().putLong(NEXT_UPDATE_CHECK, System.currentTimeMillis()).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -331,6 +331,9 @@
|
||||||
<string name="settings_github_summary">Follow the development</string>
|
<string name="settings_github_summary">Follow the development</string>
|
||||||
<string name="settings_github_title">Github</string>
|
<string name="settings_github_title">Github</string>
|
||||||
<string name="settings_support_discussion_link">https://github.com/eddyizm/tempus/discussions</string>
|
<string name="settings_support_discussion_link">https://github.com/eddyizm/tempus/discussions</string>
|
||||||
|
<string name="settings_github_update">Updates</string>
|
||||||
|
<string name="settings_github_update_title">Check github for release updates</string>
|
||||||
|
<string name="settings_github_update_summary">If using the github version, by default app will check for new apk release. Toggle to disable automatic github checks</string>
|
||||||
<string name="settings_support_summary">Join community discussions and support</string>
|
<string name="settings_support_summary">Join community discussions and support</string>
|
||||||
<string name="settings_support_title">User support</string>
|
<string name="settings_support_title">User support</string>
|
||||||
<string name="settings_scan_result">Scanning: counting %1$d tracks</string>
|
<string name="settings_scan_result">Scanning: counting %1$d tracks</string>
|
||||||
|
|
|
||||||
|
|
@ -400,6 +400,18 @@
|
||||||
app:useSimpleSummaryProvider="true" />
|
app:useSimpleSummaryProvider="true" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="settings_github_update_category_key"
|
||||||
|
app:title="@string/settings_github_update">
|
||||||
|
<Preference
|
||||||
|
app:selectable="false"
|
||||||
|
app:summary="@string/settings_github_update_summary" />
|
||||||
|
<SwitchPreference
|
||||||
|
android:title="@string/settings_github_update_title"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="github_update_check" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/settings_about_title">
|
<PreferenceCategory app:title="@string/settings_about_title">
|
||||||
<Preference
|
<Preference
|
||||||
app:selectable="false"
|
app:selectable="false"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue