Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,10 @@ protected void init() {

setupWebView();

// Compute URL with theme parameter based on current app theme
// Compute URL with theme and source parameters for analytics tracking
String url = VSHARE_BASE_URL;
if (DarkModelUtils.isDarkMode()) {
url += "?theme=dark";
} else {
url += "?theme=light";
}
String themeParam = DarkModelUtils.isDarkMode() ? "dark" : "light";
url += "?theme=" + themeParam + "&source=v2er-android";
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Manual string concatenation for query parameters can lead to errors if the base URL ever includes existing parameters or if values need encoding. Consider using Uri.Builder: Uri.parse(VSHARE_BASE_URL).buildUpon().appendQueryParameter("theme", themeParam).appendQueryParameter("source", "v2er-android").build().toString() for safer construction.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new URL construction adding theme and source parameters is not covered by a test verifying the final loaded URL (e.g., via a mocked WebView client or Uri parse assertion). Adding a test ensures analytics query parameters are consistently present.

Copilot generated this review using guidance from repository custom instructions.
mWebView.loadUrl(url);
}

Expand Down Expand Up @@ -143,6 +140,12 @@ private void setupWebView() {

WebSettings settings = mWebView.getSettings();

// Set custom User-Agent for analytics tracking
String defaultUserAgent = settings.getUserAgentString();
String appVersion = getAppVersion();
String customUserAgent = defaultUserAgent + " V2er-Android/" + appVersion;
settings.setUserAgentString(customUserAgent);
Comment on lines +148 to +152
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New User-Agent augmentation logic lacks automated test coverage (e.g., instrumentation test asserting WebView#getSettings().getUserAgentString() ends with the expected suffix). Adding a focused test would protect analytics integrity across refactors.

Copilot generated this review using guidance from repository custom instructions.

// Enable JavaScript
settings.setJavaScriptEnabled(true);

Expand Down Expand Up @@ -273,6 +276,18 @@ private int getStatusBarHeight() {
return result;
}

/**
* Get app version name for User-Agent tracking
*/
private String getAppVersion() {
try {
return getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (Exception e) {
Log.e(TAG, "Failed to get app version", e);
return "unknown";
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using PackageManager#getPackageInfo with a raw int flag is deprecated on newer API levels and catching generic Exception is overly broad. Prefer BuildConfig.VERSION_NAME directly (no try/catch needed) or catch PackageManager.NameNotFoundException specifically. Example: return BuildConfig.VERSION_NAME != null ? BuildConfig.VERSION_NAME : "unknown";.

Copilot uses AI. Check for mistakes.
}
}

/**
* Handle URL loading for WebView
* Returns true if the URL was handled externally, false if WebView should load it
Expand Down
Loading