Skip to content

Commit

Permalink
Apply code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
simoarpe committed Dec 20, 2024
1 parent 5419f3d commit 2ac1422
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 160 deletions.
6 changes: 3 additions & 3 deletions android/brave_java_resources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ brave_java_resources = [
"java/res/drawable/ellipse_217.xml",
"java/res/drawable/exchange_shape.xml",
"java/res/drawable/fingerprint_unlock_layer_list.xml",
"java/res/drawable/fullscreen_on.xml",
"java/res/drawable/ic_ac_onboarding.xml",
"java/res/drawable/ic_accessibility.xml",
"java/res/drawable/ic_add.xml",
Expand Down Expand Up @@ -643,6 +644,7 @@ brave_java_resources = [
"java/res/drawable/orange_rounded_button.xml",
"java/res/drawable/p2p_rewards_inside_background.xml",
"java/res/drawable/password_match.xml",
"java/res/drawable/picture_in_picture.xml",
"java/res/drawable/private_tab_gradient_background.xml",
"java/res/drawable/product_private_layer_list.xml",
"java/res/drawable/product_vpn_layer_list.xml",
Expand Down Expand Up @@ -756,8 +758,6 @@ brave_java_resources = [
"java/res/drawable/youtube_features_background.xml",
"java/res/drawable/youtube_features_ripple_left_mask.xml",
"java/res/drawable/youtube_features_ripple_right_mask.xml",
"java/res/drawable/picture_in_picture.xml",
"java/res/drawable/fullscreen_on.xml",
"java/res/layout-land/brave_shields_stats_row.xml",
"java/res/layout-sw600dp-land/brave_shields_stats_row.xml",
"java/res/layout-sw600dp/brave_rewards_tippingpanel_fragment.xml",
Expand Down Expand Up @@ -1005,6 +1005,7 @@ brave_java_resources = [
"java/res/values-h748dp/dimens.xml",
"java/res/values-h765dp/dimens.xml",
"java/res/values-h820dp/dimens.xml",
"java/res/values-land/brave_dimens.xml",
"java/res/values-night/brave_colors.xml",
"java/res/values-sw600dp/brave_dimens.xml",
"java/res/values-v21/brave_styles.xml",
Expand All @@ -1014,7 +1015,6 @@ brave_java_resources = [
"java/res/values/brave_attrs.xml",
"java/res/values/brave_colors.xml",
"java/res/values/brave_dimens.xml",
"java/res/values-land/brave_dimens.xml",
"java/res/values/brave_ids.xml",
"java/res/values/brave_styles.xml",
"java/res/values/shimmer_attrs.xml",
Expand Down
2 changes: 1 addition & 1 deletion android/brave_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/upgrade/BraveUpgradeJobIntentServiceImpl.java",
"../../brave/android/java/org/chromium/chrome/browser/upgrade/NotificationIntent.java",
"../../brave/android/java/org/chromium/chrome/browser/util/BraveConstants.java",
"../../brave/android/java/org/chromium/chrome/browser/util/PictureInPictureUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/util/BraveDbUtil.java",
"../../brave/android/java/org/chromium/chrome/browser/util/BraveDynamicColors.java",
"../../brave/android/java/org/chromium/chrome/browser/util/BraveReferrer.java",
Expand All @@ -462,6 +461,7 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/util/KeyboardVisibilityHelper.java",
"../../brave/android/java/org/chromium/chrome/browser/util/LiveDataUtil.java",
"../../brave/android/java/org/chromium/chrome/browser/util/PackageUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/util/PictureInPictureUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/util/SharedPreferencesHelper.java",
"../../brave/android/java/org/chromium/chrome/browser/util/TabUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/util/TouchDelegateComposite.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

package org.chromium.chrome.browser;

import org.chromium.base.Log;
import org.chromium.chrome.browser.app.BraveActivity;
import org.jni_zero.CalledByNative;
import org.jni_zero.JNINamespace;
import org.jni_zero.NativeMethods;

import org.chromium.base.Log;
import org.chromium.chrome.browser.app.BraveActivity;
import org.chromium.content_public.browser.WebContents;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,46 @@
import androidx.annotation.NonNull;

/**
* Auxiliary class containing static methods that helps
* to determine if picture in picture mode is supported by device
* and enabled via permission settings.
* Auxiliary class containing static methods that helps to determine if picture in picture mode is
* supported by device and enabled via permission settings.
*/
public class PictureInPictureUtils {
/**
* Returns {@code true} if picture in picture permission is enabled
* in app settings.
*/
public static boolean hasPictureInPicturePermissionEnabled(@NonNull final Context context) {
final AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
return appOps != null && appOps.unsafeCheckOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), context.getPackageName()) == AppOpsManager.MODE_ALLOWED;
} else {
//noinspection deprecation
return appOps != null && appOps.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), context.getPackageName()) == AppOpsManager.MODE_ALLOWED;
}
}
/** Returns {@code true} if picture in picture permission is enabled in app settings. */
public static boolean hasPictureInPicturePermissionEnabled(@NonNull final Context context) {
final AppOpsManager appOps =
(AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
return appOps != null
&& appOps.unsafeCheckOpNoThrow(
AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
android.os.Process.myUid(),
context.getPackageName())
== AppOpsManager.MODE_ALLOWED;
} else {
//noinspection deprecation
return appOps != null
&& appOps.checkOpNoThrow(
AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
android.os.Process.myUid(),
context.getPackageName())
== AppOpsManager.MODE_ALLOWED;
}
}

/**
* Launches picture in picture permission settings screen.
* Note: this method should be called only when a device correctly supports picture in picture mode.
*/
public static void launchPictureInPictureSettings(@NonNull final Context context) {
context.startActivity(new Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Uri.parse(String.format("package:%s",context.getPackageName()))));
}
/**
* Launches picture in picture permission settings screen. Note: this method should be called
* only when a device correctly supports picture in picture mode.
*/
public static void launchPictureInPictureSettings(@NonNull final Context context) {
context.startActivity(
new Intent(
"android.settings.PICTURE_IN_PICTURE_SETTINGS",
Uri.parse(String.format("package:%s", context.getPackageName()))));
}

/**
* Returns {code true} if a device supports picture in picture mode.
*/
public static boolean deviceSupportedPictureInPictureMode(@NonNull final Context context) {
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
}
/** Returns {code true} if a device supports picture in picture mode. */
public static boolean deviceSupportedPictureInPictureMode(@NonNull final Context context) {
return context.getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
}
}
10 changes: 5 additions & 5 deletions android/java/org/chromium/chrome/browser/util/TabUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,12 @@ public static int getTransition(Tab tab) {
}

/**
* Returns {@code true} when current tab URL matches the URL of a
* YouTube video. Current tab or current tab URL might be {@code null}
* if the model is not initialized yet.
* Returns {@code true} when current tab URL matches the URL of a YouTube video. Current tab or
* current tab URL might be {@code null} if the model is not initialized yet.
*
* @param currentTab Current tab holding the URL to check.
* @return {@code true} if the current tab URL matches the URL of a
* YouTube video, {@code false} otherwise.
* @return {@code true} if the current tab URL matches the URL of a YouTube video, {@code false}
* otherwise.
*/
public static boolean isYouTubeVideo(@Nullable final Tab currentTab) {
if (currentTab == null || currentTab.getUrl() == null) {
Expand Down
Loading

0 comments on commit 2ac1422

Please sign in to comment.