Skip to content

Commit

Permalink
[Android] Clean up for UnusedMethod and UnusedVariable lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
samartnik committed Dec 3, 2024
1 parent 42e82d3 commit bcc81d1
Show file tree
Hide file tree
Showing 24 changed files with 0 additions and 597 deletions.
1 change: 0 additions & 1 deletion android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ brave_java_resources = [
"java/res/drawable/brave_sync_top_rounded.xml",
"java/res/drawable/brave_sync_top_rounded_light.xml",
"java/res/drawable/card_bg.xml",
"java/res/drawable/checked_circle_filled.xml",
"java/res/drawable/circular_progress.xml",
"java/res/drawable/country_spinner_background.xml",
"java/res/drawable/create_custom_filter_edit_bg.xml",
Expand Down
1 change: 0 additions & 1 deletion android/java/apk_for_test.flags
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@
}

-keep class org.chromium.chrome.browser.notifications.permissions.NotificationPermissionRationaleDialogController {
*** wrapDialogDismissalCallback(...);
public <init>(...);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,6 @@ public BraveRewardsHelper(Tab tab) {
}
}

/** we don't destroy sLargeIconBridge sisnce it's static */
private void destroy() {
if (sLargeIconBridge != null) {
sLargeIconBridge.destroy();
sLargeIconBridge = null;
}
mCallback = null;
}

public void detach() {
mCallback = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1425,39 +1425,6 @@ private void setImage(ImageView imageView, String type, int index) {
}
}

// used for logging the Glide implementation
private RequestListener<Drawable> createLoggerListener(final String unused_name) {
return new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(
@Nullable GlideException e,
Object model,
Target target,
boolean isFirstResource) {
return false;
}

@Override
public boolean onResourceReady(
Drawable resource,
Object model,
Target target,
DataSource dataSource,
boolean isFirstResource) {
if (resource instanceof BitmapDrawable) {
// Bitmap bitmap = ((BitmapDrawable) resource).getBitmap();
// Log.d(TAG,String.format(Locale.getDefault(), "Ready %s bitmap %,d bytes,
// size: %d x %d",
// unused_name,
// bitmap.getByteCount(),
// bitmap.getWidth(),
// bitmap.getHeight()));
}
return false;
}
};
}

private LayerDrawable makeRound(int type, int background, int radius) {
float[] outerRadii =
new float[] {radius, radius, radius, radius, radius, radius, radius, radius};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ private static BigDecimal safeVal(Amount value) {
return (value != null && value.mValue != null) ? value.mValue : BigDecimal.ZERO;
}

private void safeInit() {
if (mValue == null) mValue = BigDecimal.ZERO;
}

public BigDecimal getValue() {
return BigDecimal.valueOf(mValue.doubleValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ public static int tooltipGravityToArrowDirection(int tooltipGravity) {
}
}

private static ViewGroup.MarginLayoutParams getOrCreateMarginLayoutParams(View view) {
ViewGroup.LayoutParams lp = view.getLayoutParams();
if (lp != null) {
if (lp instanceof ViewGroup.MarginLayoutParams) {
return (ViewGroup.MarginLayoutParams) lp;
} else {
return new ViewGroup.MarginLayoutParams(lp);
}
} else {
return new ViewGroup.MarginLayoutParams(view.getWidth(), view.getHeight());
}
}

public static int getColor(Context context, @ColorRes int colorRes) {
return context.getColor(colorRes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,6 @@ private void onClickViews() {
}
}

private boolean shouldForceDefaultBrowserPrompt() {
return !DayZeroHelper.getDayZeroExptFlag() && !isDefaultBrowser();
}

private void setDefaultBrowserAndProceedToNextStep() {
BraveSetDefaultBrowserUtils.setDefaultBrowser(this);
if (!BraveSetDefaultBrowserUtils.supportsDefaultRoleManager()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,32 +255,6 @@ public long insertStats(BraveStatsTable braveStat) {
// return -1;
}

private boolean isAdsTrackerAlreadyAdded(BraveStatsTable braveStat) {
String sql =
"SELECT * FROM "
+ BraveStatsTable.TABLE_NAME
+ " WHERE "
+ BraveStatsTable.COLUMN_STAT_SITE
+ " = '"
+ braveStat.getStatSite()
+ "'"
+ " AND "
+ BraveStatsTable.COLUMN_URL
+ " = '"
+ braveStat.getUrl()
+ "'";

Log.e("NTP", sql);

SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(sql, null);

int count = cursor.getCount();
cursor.close();

return count > 0;
}

@SuppressLint("Range")
public List<BraveStatsTable> getAllStats() {
List<BraveStatsTable> braveStats = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,4 @@ public BraveNotificationPermissionRationaleDialogController(
/** This is empty override method, to block default android 13 chromium dialog */
@Override
public void showRationaleUi(Callback<Integer> rationaleCallback) {}

@SuppressWarnings("UnusedVariable")
private Callback<Integer> wrapDialogDismissalCallback(Callback<Integer> rationaleCallback) {
assert false : "wrapDialogDismissalCallback should be redirected to parent in bytecode!";
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1485,22 +1485,6 @@ private void initBraveNewsController() {
}
}

private int getMaxRowsForMostVisitedTiles() {
try {
if (!ProfileManager.isInitialized()
|| !UserPrefs.get(BraveActivity.getBraveActivity().getCurrentProfile())
.getBoolean(BravePref.NEW_TAB_PAGE_SHOW_BACKGROUND_IMAGE)) {
return 2;
} else {
return 1;
}
} catch (BraveActivity.BraveActivityNotFoundException e) {
Log.e(TAG, "getMaxRowsForMostVisitedTiles ", e);
}

return 2;
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mIsTablet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,61 +47,6 @@ public class NTPImageUtil {
public static HashMap<String, SoftReference<Bitmap>> imageCache =
new HashMap<String, SoftReference<Bitmap>>();

// This function is not used, but removing it completely causes errors for unused resources:
// The resource R.string.earn_tokens_for_viewing appears to be unused [UnusedResources]
// The resource R.string.you_are_earning_tokens appears to be unused [UnusedResources]
// This is related to rewards, so I keep it till review
@SuppressWarnings("UnusedVariable")
private static SpannableString getBannerText(
ChromeActivity chromeActivity,
int ntpType,
View bannerLayout,
SponsoredTab sponsoredTab,
NewTabPageListener newTabPageListener) {
String bannerText = "";
if (ntpType == SponsoredImageUtil.BR_ON_ADS_ON) {
bannerText =
String.format(
chromeActivity
.getResources()
.getString(R.string.you_are_earning_tokens),
chromeActivity.getResources().getString(R.string.learn_more));
} else if (ntpType == SponsoredImageUtil.BR_ON_ADS_OFF) {
bannerText =
String.format(
chromeActivity
.getResources()
.getString(R.string.earn_tokens_for_viewing),
chromeActivity.getResources().getString(R.string.learn_more));
}
int learnMoreIndex =
bannerText.indexOf(chromeActivity.getResources().getString(R.string.learn_more));
Spanned learnMoreSpanned = BraveRewardsHelper.spannedFromHtmlString(bannerText);
SpannableString learnMoreTextSS = new SpannableString(learnMoreSpanned.toString());

ForegroundColorSpan brOffForegroundSpan =
new ForegroundColorSpan(chromeActivity.getColor(R.color.brave_theme_color));
// setSpan gives us IndexOutOfBoundsException in case of end or start are > length and in
// some other cases.
int length = learnMoreTextSS.length();
int endIndex = learnMoreIndex
+ chromeActivity.getResources().getString(R.string.learn_more).length();
if (endIndex < learnMoreIndex || learnMoreIndex >= length || endIndex >= length
|| learnMoreIndex < 0 || endIndex < 0) {
return learnMoreTextSS;
}
try {
learnMoreTextSS.setSpan(brOffForegroundSpan, learnMoreIndex, endIndex,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} catch (IndexOutOfBoundsException e) {
Log.e(TAG,
"getBannerText: learnMoreIndex == " + learnMoreIndex
+ ", endIndex == " + endIndex + ". Error: " + e.getMessage());
}

return learnMoreTextSS;
}

public static Bitmap getWallpaperBitmap(NTPImage ntpImage, int layoutWidth, int layoutHeight) {
Context mContext = ContextUtils.getApplicationContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,29 +432,6 @@ private void openPlaylistInTab(boolean isIncognito, String url) {
TabUtils.openUrlInNewTab(isIncognito, url);
}

private void updatePlaylistItem(String playlistId, PlaylistItem playlistItem) {
if (mPlaylistViewModel == null) {
return;
}
PlaylistItemModel playlistItemModel =
new PlaylistItemModel(
playlistItem.id,
playlistId,
playlistItem.name,
playlistItem.pageSource.url,
playlistItem.mediaPath.url,
playlistItem.hlsMediaPath.url,
playlistItem.mediaSource.url,
playlistItem.thumbnailPath.url,
playlistItem.author,
playlistItem.duration,
playlistItem.lastPlayedPosition,
(long) playlistItem.mediaFileBytes,
playlistItem.cached,
false);
mPlaylistViewModel.updatePlaylistItem(playlistItemModel);
}

private void deleteHLSContent(String playlistItemId) {
PostTask.postTask(
TaskTraits.BEST_EFFORT_MAY_BLOCK,
Expand Down
Loading

0 comments on commit bcc81d1

Please sign in to comment.