Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
chore: lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
anddea committed May 27, 2024
1 parent 9521baa commit d14d77b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public static void setExtendedUtils(@NonNull Activity mActivity) {
ExtendedUtils.setApplicationLabel();
ExtendedUtils.setSmallestScreenWidthDp();
ExtendedUtils.setVersionName();
ExtendedUtils.setYouTabUsed();
ExtendedUtils.setPlayerFlyoutMenuAdditionalSettings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import java.util.ArrayList;

import app.revanced.integrations.shared.utils.Utils;
import app.revanced.integrations.youtube.patches.utils.PatchStatus;
import app.revanced.integrations.youtube.utils.ThemeUtils;
import app.revanced.integrations.youtube.whitelist.VideoChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static app.revanced.integrations.shared.utils.StringRef.str;

import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
Expand Down Expand Up @@ -438,25 +439,23 @@ private static String formatSegmentTime(long segmentTime) {
return String.format(Locale.US, formatPattern, formatArgs);
}

@TargetApi(26)
public static String getTimeSavedString(long totalSecondsSaved) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
Duration duration = Duration.ofSeconds(totalSecondsSaved);
final long hours = duration.toHours();
final long minutes = duration.toMinutes() % 60;
// Format all numbers so non-western numbers use a consistent appearance.
String minutesFormatted = statsNumberFormatter.format(minutes);
if (hours > 0) {
String hoursFormatted = statsNumberFormatter.format(hours);
return str("revanced_sb_stats_saved_hour_format", hoursFormatted, minutesFormatted);
}
final long seconds = duration.getSeconds() % 60;
String secondsFormatted = statsNumberFormatter.format(seconds);
if (minutes > 0) {
return str("revanced_sb_stats_saved_minute_format", minutesFormatted, secondsFormatted);
}
return str("revanced_sb_stats_saved_second_format", secondsFormatted);
Duration duration = Duration.ofSeconds(totalSecondsSaved);
final long hours = duration.toHours();
final long minutes = duration.toMinutes() % 60;
// Format all numbers so non-western numbers use a consistent appearance.
String minutesFormatted = statsNumberFormatter.format(minutes);
if (hours > 0) {
String hoursFormatted = statsNumberFormatter.format(hours);
return str("revanced_sb_stats_saved_hour_format", hoursFormatted, minutesFormatted);
}
final long seconds = duration.getSeconds() % 60;
String secondsFormatted = statsNumberFormatter.format(seconds);
if (minutes > 0) {
return str("revanced_sb_stats_saved_minute_format", minutesFormatted, secondsFormatted);
}
return "error"; // will never be reached. YouTube requires Android O or greater
return str("revanced_sb_stats_saved_second_format", secondsFormatted);
}

private static class EditByHandSaveDialogListener implements DialogInterface.OnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,9 @@
import app.revanced.integrations.shared.settings.BooleanSetting;
import app.revanced.integrations.shared.settings.Setting;
import app.revanced.integrations.shared.utils.PackageUtils;
import app.revanced.integrations.youtube.patches.components.FeedComponentsFilter;
import app.revanced.integrations.youtube.settings.Settings;

public class ExtendedUtils extends PackageUtils {
/**
* Versions of YouTube after this version use the You tab instead of the Library tab.
*/
private static final String CLIENT_VERSIONS_YOU_TAB_USED = "18.36.32";
/**
* Spoofing this version restores the old library shelves.
*/
private static final String RESTORE_OLD_LIBRARY_SHELF = "18.09.39";
/**
* This value is used in {@link FeedComponentsFilter}.
* In old YouTube client, hiding carousel shelves via navigation tab buttons does not work as intended.
*/
private static boolean youTabUsed = false;

public static boolean isFullscreenHidden() {
boolean isFullscreenHidden = isTablet() &&
Expand All @@ -44,20 +30,6 @@ public static boolean isSpoofingToLessThan(@NonNull String versionName) {
return isVersionToLessThan(Settings.SPOOF_APP_VERSION_TARGET.get(), versionName);
}

public static boolean isYouTabUsed() {
return youTabUsed;
}

public static void setYouTabUsed() {
if (isVersionToLessThan(getVersionName(), CLIENT_VERSIONS_YOU_TAB_USED)) {
return;
}
if (isSpoofingToLessThan(RESTORE_OLD_LIBRARY_SHELF)) {
return;
}
youTabUsed = true;
}

public static void setCommentPreviewSettings() {
final boolean enabled = Settings.HIDE_PREVIEW_COMMENT.get();
final boolean newMethod = Settings.HIDE_PREVIEW_COMMENT_TYPE.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void copyUrl(boolean withTimestamp) {
}

public static void copyTimeStamp() {
final String timeStamp = getTimeStamp(VideoInformation.getVideoTime(), false);
final String timeStamp = getTimeStamp(VideoInformation.getVideoTime());
setClipboard(timeStamp, str("revanced_share_copy_timestamp_success", timeStamp));
}

Expand Down Expand Up @@ -153,28 +153,24 @@ public static void showFlyoutMenu() {
public static String getFormattedTimeStamp(long videoTime) {
return "'" + videoTime +
"' (" +
getTimeStamp(videoTime, false) +
getTimeStamp(videoTime) +
")\n";
}

@TargetApi(26)
@SuppressLint("DefaultLocale")
public static String getTimeStamp(long time, boolean mills) {
public static String getTimeStamp(long time) {
final Duration duration = Duration.ofMillis(time);

final long hours = duration.toHours();
final long minutes = duration.toMinutes() % 60;
final long seconds = duration.getSeconds() % 60;
final long millis = duration.toMillis() % 1000;

if (mills) {
return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, millis);
if (hours > 0) {
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
} else {
if (hours > 0) {
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
} else {
return String.format("%02d:%02d", minutes, seconds);
}
return String.format("%02d:%02d", minutes, seconds);
}
}

Expand Down

0 comments on commit d14d77b

Please sign in to comment.