Skip to content

Commit

Permalink
Parallel downloading option android (uplift to 1.70.x) (#25181)
Browse files Browse the repository at this point in the history
Uplift of #25157 (squashed) to beta
  • Loading branch information
brave-builds authored Aug 20, 2024
1 parent 20efa4e commit b856094
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
1 change: 1 addition & 0 deletions android/java/org/chromium/base/BraveFeatureList.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public abstract class BraveFeatureList {
public static final String USE_DEV_UPDATER_URL = "UseDevUpdaterUrl";
public static final String FORCE_WEB_CONTENTS_DARK_MODE = "WebContentsForceDark";
public static final String ENABLE_FORCE_DARK = "enable-force-dark";
public static final String ENABLE_PARALLEL_DOWNLOADING = "enable-parallel-downloading";
public static final String BRAVE_SEARCH_OMNIBOX_BANNER = "BraveSearchOmniboxBanner";
public static final String BRAVE_BACKGROUND_VIDEO_PLAYBACK = "BraveBackgroundVideoPlayback";
public static final String BRAVE_BACKGROUND_VIDEO_PLAYBACK_INTERNAL =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,29 @@

import androidx.preference.Preference;

import org.chromium.base.BraveFeatureList;
import org.chromium.base.BravePreferenceKeys;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.BraveFeatureUtil;
import org.chromium.chrome.browser.BraveRelaunchUtils;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
import org.chromium.components.browser_ui.settings.SettingsUtils;

public class BraveDownloadSettings
extends DownloadSettings implements Preference.OnPreferenceChangeListener {
public class BraveDownloadSettings extends DownloadSettings
implements Preference.OnPreferenceChangeListener {
private static final String PREF_AUTOMATICALLY_OPEN_WHEN_POSSIBLE =
"automatically_open_when_possible";
public static final String PREF_LOCATION_PROMPT_ENABLED = "location_prompt_enabled";
private static final String PREF_DOWNLOAD_PROGRESS_NOTIFICATION_BUBBLE =
"download_progress_notification_bubble";
private static final String PREF_ENABLE_PARALLEL_DOWNLOADING = "enable_parallel_downloading";
private static final String PARALLEL_DOWNLOADING = "ParallelDownloading";

private ChromeSwitchPreference mAutomaticallyOpenWhenPossiblePref;
private ChromeSwitchPreference mDownloadProgressNotificationBubblePref;
private ChromeSwitchPreference mParallelDownloadingPref;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -40,6 +47,10 @@ public void onCreate(Bundle savedInstanceState) {
(ChromeSwitchPreference) findPreference(PREF_DOWNLOAD_PROGRESS_NOTIFICATION_BUBBLE);
mDownloadProgressNotificationBubblePref.setOnPreferenceChangeListener(this);

mParallelDownloadingPref =
(ChromeSwitchPreference) findPreference(PREF_ENABLE_PARALLEL_DOWNLOADING);
mParallelDownloadingPref.setOnPreferenceChangeListener(this);

ChromeSwitchPreference locationPromptEnabledPref =
(ChromeSwitchPreference) findPreference(PREF_LOCATION_PROMPT_ENABLED);
if (locationPromptEnabledPref != null) {
Expand All @@ -60,10 +71,15 @@ private void updateDownloadSettings() {
mAutomaticallyOpenWhenPossiblePref.setChecked(automaticallyOpenWhenPossible);

boolean downloadProgressNotificationBubble =
ContextUtils.getAppSharedPreferences().getBoolean(
BravePreferenceKeys.BRAVE_DOWNLOADS_DOWNLOAD_PROGRESS_NOTIFICATION_BUBBLE,
false);
ContextUtils.getAppSharedPreferences()
.getBoolean(
BravePreferenceKeys
.BRAVE_DOWNLOADS_DOWNLOAD_PROGRESS_NOTIFICATION_BUBBLE,
false);
mDownloadProgressNotificationBubblePref.setChecked(downloadProgressNotificationBubble);

boolean isParallelDownloadingEnabled = ChromeFeatureList.isEnabled(PARALLEL_DOWNLOADING);
mParallelDownloadingPref.setChecked(isParallelDownloadingEnabled);
}

// Preference.OnPreferenceChangeListener implementation.
Expand All @@ -79,10 +95,15 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
} else if (PREF_DOWNLOAD_PROGRESS_NOTIFICATION_BUBBLE.equals(preference.getKey())) {
ContextUtils.getAppSharedPreferences()
.edit()
.putBoolean(BravePreferenceKeys
.BRAVE_DOWNLOADS_DOWNLOAD_PROGRESS_NOTIFICATION_BUBBLE,
.putBoolean(
BravePreferenceKeys
.BRAVE_DOWNLOADS_DOWNLOAD_PROGRESS_NOTIFICATION_BUBBLE,
(boolean) newValue)
.apply();
} else if (PREF_ENABLE_PARALLEL_DOWNLOADING.equals(preference.getKey())) {
BraveFeatureUtil.enableFeature(
BraveFeatureList.ENABLE_PARALLEL_DOWNLOADING, (boolean) newValue, false);
BraveRelaunchUtils.askForRelaunch(getActivity());
}
return super.onPreferenceChange(preference, newValue);
}
Expand Down
5 changes: 5 additions & 0 deletions android/java/res/xml/brave_download_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@
android:title="@string/download_progress_notification_title"
android:summaryOn="@string/text_on"
android:summaryOff="@string/text_off" />

<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
android:key="enable_parallel_downloading"
android:title="@string/enable_parallel_downloading_title"
android:summary="@string/enable_parallel_downloading_text" />

</PreferenceScreen>
6 changes: 6 additions & 0 deletions browser/ui/android/strings/android_brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,12 @@ Are you sure you want to do this?
<message name="IDS_BRAVE_DOWNLOAD_LOCATION_PROMPT_ENABLED_TITLE" desc="Title for preference that allows the user to indicate whether they want to show a change downloads location prompt every time they download.">
Ask where to save files (if SD card is detected)
</message>
<message name="IDS_ENABLE_PARALLEL_DOWNLOADING_TITLE" desc="Title for preference that allows the user to enable parallel downloading.">
Parallel Downloading
</message>
<message name="IDS_ENABLE_PARALLEL_DOWNLOADING_TEXT" desc="Summary for preference that allows the user to enable parallel downloading.">
Enable parallel downloading to accelerate download speed
</message>
<message name="IDS_VIEW_FULL_PRIVACY_REPORT" desc="Shields privacy report text">
View full Privacy Report
</message>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
&brave_vpn::features::kBraveVPNLinkSubscriptionAndroidUI, \
&brave_wallet::features::kNativeBraveWalletFeature, \
&playlist::features::kPlaylist, \
&download::features::kParallelDownloading, \
&preferences::features::kBraveBackgroundVideoPlayback, \
&request_otr::features::kBraveRequestOTRTab, \
&safe_browsing::features::kBraveAndroidSafeBrowsing, \
Expand Down

0 comments on commit b856094

Please sign in to comment.