updated version.properties parsing + cleanup code
This commit is contained in:
@@ -2,9 +2,9 @@ package ru.vtosters.lite.deviceinfo;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
import ru.vtosters.lite.utils.VersionReader;
|
||||
|
||||
import static ru.vtosters.lite.deviceinfo.OEMDetector.*;
|
||||
import static ru.vtosters.lite.utils.About.getBuildNumber;
|
||||
|
||||
public class Device {
|
||||
private String boardName;
|
||||
@@ -88,7 +88,8 @@ public class Device {
|
||||
|
||||
public String toDeviceName() {
|
||||
return "Device information: "
|
||||
+ "commit='" + getBuildNumber()
|
||||
+ "commit='" + VersionReader.getVersionBuild()
|
||||
+ "', fullVersionInfo='" + VersionReader.getVersionFull()
|
||||
+ "', isMilkshake='" + ThemesUtils.isMilkshake()
|
||||
+ "', sdkVersion='" + this.sdkVersion
|
||||
+ "', productName='" + this.productName
|
||||
@@ -105,7 +106,8 @@ public class Device {
|
||||
|
||||
public String forLogging() {
|
||||
return "**" + AndroidUtils.getString("device_info") + ":** " + "\n\n"
|
||||
+ "- Commit: " + getBuildNumber() + "\n"
|
||||
+ "- Commit: " + VersionReader.getVersionBuild() + "\n"
|
||||
+ "- Full Version Information: " + VersionReader.getVersionFull() + "\n"
|
||||
+ "- Android SDK: " + this.sdkVersion + "\n"
|
||||
+ "- Product: " + this.productName + "\n"
|
||||
+ "- Device: " + this.deviceName + "\n"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ru.vtosters.lite.music;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -65,7 +64,8 @@ public class VKM3UParser {
|
||||
if (TextUtils.isEmpty(mData)) throw new NullPointerException("mData==null");
|
||||
Scanner scanner = new Scanner(mData);
|
||||
String line = scanner.nextLine();
|
||||
if (!"#EXTM3U".equals(line)) throw new IllegalStateException(String.format("Unknown initial M3U tag: %s", line));
|
||||
if (!"#EXTM3U".equals(line))
|
||||
throw new IllegalStateException(String.format("Unknown initial M3U tag: %s", line));
|
||||
boolean aes128 = false;
|
||||
String keyUri = "";
|
||||
while (scanner.hasNextLine()) {
|
||||
@@ -82,7 +82,7 @@ public class VKM3UParser {
|
||||
} else {
|
||||
throw new RuntimeException(String.format("Failed to parse: %s", line));
|
||||
}
|
||||
mHeapSize += line.getBytes().length;;
|
||||
mHeapSize += line.getBytes().length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -18,7 +18,9 @@ import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.NetworkUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TracklistInjector {
|
||||
|
||||
@@ -224,6 +226,7 @@ public class TracklistInjector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject createVirtualCatalog(List<MusicTrack> tracks) throws JSONException {
|
||||
var audiosBlock = new JSONObject()
|
||||
.put("id", getRandomId())
|
||||
|
||||
@@ -18,7 +18,7 @@ import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static ru.vtosters.lite.feature.groupslist.GroupsCatalogInjector.*;
|
||||
import static ru.vtosters.lite.feature.groupslist.GroupsCatalogInjector.injectIntoCatalog;
|
||||
import static ru.vtosters.lite.hooks.DateHook.getLocale;
|
||||
import static ru.vtosters.lite.music.cache.helpers.PlaylistHelper.*;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
@@ -152,7 +152,8 @@ public class CatalogJsonInjector {
|
||||
var useOldAppVer = getBoolValue("useOldAppVer", false);
|
||||
var isUsersCatalog = section.optString("url").equals("https://vk.com/audios" + getUserId() + "?section=" + (useOldAppVer ? "all" : "general"));
|
||||
|
||||
if (!isUsersCatalog || !CacheDatabaseDelegate.hasTracks() || LibVKXClient.isIntegrationEnabled()) return; // early return if not users catalog or no tracks or integration enabled
|
||||
if (!isUsersCatalog || !CacheDatabaseDelegate.hasTracks() || LibVKXClient.isIntegrationEnabled())
|
||||
return; // early return if not users catalog or no tracks or integration enabled
|
||||
var blocks = section.getJSONArray("blocks");
|
||||
var noPlaylists = !json.has("playlists");
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@ import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class ImBanner {
|
||||
private static final String TAG = "ImBanner";
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class UsersList {
|
||||
private static final String TAG = "UsersList";
|
||||
|
||||
@@ -8,9 +8,9 @@ import android.os.Bundle;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.deviceinfo.OEMDetector;
|
||||
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
|
||||
import ru.vtosters.lite.utils.About;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.VersionReader;
|
||||
|
||||
public class SystemInfo extends TrackedMaterialPreferenceToolbarFragment {
|
||||
|
||||
@@ -33,7 +33,9 @@ public class SystemInfo extends TrackedMaterialPreferenceToolbarFragment {
|
||||
String miuiUiVersionCodeName = OEMDetector.getMiuiUiVersionCode();
|
||||
String emuiVersionCode = OEMDetector.getEmuiVersionCode();
|
||||
String packageName = requireContext().getPackageName();
|
||||
String commit = About.getBuildNumber();
|
||||
String commit = VersionReader.getVersionCommit();
|
||||
String branch = VersionReader.getVersionBranch();
|
||||
String fullbuildinfo = VersionReader.getVersionFull();
|
||||
|
||||
boolean isMiui = OEMDetector.isMIUI();
|
||||
boolean isFlyme = OEMDetector.isFlyme();
|
||||
@@ -62,6 +64,18 @@ public class SystemInfo extends TrackedMaterialPreferenceToolbarFragment {
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Branch", branch, 0, preference -> {
|
||||
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", branch));
|
||||
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Build Info", fullbuildinfo, 0, preference -> {
|
||||
((ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", fullbuildinfo));
|
||||
AndroidUtils.sendToast(requireContext().getString(R.string.copied_to_clipboard));
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "Valid Signature", "Value: " + isValidSignature, 0, null);
|
||||
|
||||
PreferenceFragmentUtils.addPreference(getPreferenceScreen(), "", "isTablet", "Value: " + isTablet, 0, null);
|
||||
|
||||
@@ -520,7 +520,7 @@ public class VTSettings extends TrackedMaterialPreferenceToolbarFragment impleme
|
||||
getPreferenceScreen(),
|
||||
"",
|
||||
requireContext().getString(R.string.menu_about),
|
||||
Preferences.getBuildName() + " | " + About.getBuildNumber(),
|
||||
Preferences.getBuildName() + " | " + (Preferences.isValidSignature() ? VersionReader.getVersionBuild() : VersionReader.getVersionFull()),
|
||||
R.drawable.ic_about_outline_28,
|
||||
preference -> {
|
||||
NavigatorUtils.switchFragment(requireContext(), AboutAppFragment.class);
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.*;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getApplicationName;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.Preferences.devmenu;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBuildName;
|
||||
|
||||
public class About {
|
||||
public static String getBuildNumber() {
|
||||
return getBuild(getGlobalContext(), "version.properties");
|
||||
}
|
||||
|
||||
public static void injectToToolBar(View view) {
|
||||
view.setOnLongClickListener(v -> {
|
||||
if (devmenu()) {
|
||||
@@ -31,24 +22,10 @@ public class About {
|
||||
}
|
||||
|
||||
public static String getCommitLink() {
|
||||
return "https://github.com/vtosters/lite/commit/" + getBuild(getGlobalContext(), "version.properties"); // https://git.maki.su/gdlbo/lite/commit/ github repo
|
||||
}
|
||||
|
||||
public static String getBuild(Context context, String name) {
|
||||
try {
|
||||
final var scanner = new Scanner(context.getAssets().open(name, AssetManager.ACCESS_BUFFER));
|
||||
while (scanner.hasNextLine()) {
|
||||
final var line = scanner.findInLine("VERSION_BUILD=.+");
|
||||
if (!TextUtils.isEmpty(line))
|
||||
return line.substring(14);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "0000000";
|
||||
return "https://github.com/vtosters/lite/commit/" + VersionReader.getVersionCommit(); // https://git.maki.su/gdlbo/lite/commit/ github repo
|
||||
}
|
||||
|
||||
public static String getAppVersion() {
|
||||
return getApplicationName() + " " + getBuildName() + " | " + getBuildNumber();
|
||||
return getApplicationName() + " " + getBuildName() + " | " + VersionReader.getVersionFull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ public class AnalyticsHelper {
|
||||
@Override
|
||||
public void onPreparedLog(@NonNull Log log, @NonNull String groupName, int flags) {
|
||||
var device = log.getDevice();
|
||||
device.setAppVersion(About.getBuildNumber());
|
||||
device.setAppBuild(About.getBuildNumber());
|
||||
device.setAppVersion(VersionReader.getVersionBuild());
|
||||
device.setAppBuild(VersionReader.getVersionBuild());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@ package ru.vtosters.lite.utils;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import com.google.firebase.iid.FirebaseInstanceIdReceiver;
|
||||
import com.google.firebase.iid.FirebaseInstanceIdReceiver2;
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.Arrays;
|
||||
public class IOUtils {
|
||||
public static final int BUFFER_SIZE = 8192;
|
||||
|
||||
public static byte[] decodeStream(InputStream encIs,byte[] aesKey)
|
||||
public static byte[] decodeStream(InputStream encIs, byte[] aesKey)
|
||||
throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IOException {
|
||||
CipherInputStream cip = new CipherInputStream(encIs, getCipher(aesKey));
|
||||
return readFully(cip);
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.telephony.TelephonyManager;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class OTAUtils {
|
||||
|
||||
public boolean isNewVersion() {
|
||||
try {
|
||||
return !mCommitSHA.startsWith(About.getBuildNumber());
|
||||
return !mCommitSHA.startsWith(VersionReader.getVersionBuild());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class VersionReader {
|
||||
public static String getValue(String key) {
|
||||
try (var inputStream = AndroidUtils.getGlobalContext().getAssets().open("version.properties")) {
|
||||
Properties properties = new Properties();
|
||||
properties.load(inputStream);
|
||||
return properties.getProperty(key);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getVersionBuild() {
|
||||
return getValue("VERSION_BUILD");
|
||||
}
|
||||
|
||||
public static String getVersionBranch() {
|
||||
return getValue("VERSION_BRANCH");
|
||||
}
|
||||
|
||||
public static String getVersionCommit() {
|
||||
return getValue("VERSION_COMMIT");
|
||||
}
|
||||
|
||||
public static String getVersionFull() {
|
||||
return getValue("VERSION_FULL");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user