Merge "Add two APIs in SettingsLibActivityEmbedding"

This commit is contained in:
TreeHugger Robot
2022-02-16 14:47:43 +00:00
committed by Android (Google) Code Review
3 changed files with 35 additions and 1 deletions

View File

@@ -14,6 +14,8 @@ android_library {
static_libs: [
"androidx.annotation_annotation",
"androidx.core_core",
"windowExtLib",
"SettingsLibUtils",
],
sdk_version: "system_current",

View File

@@ -16,8 +16,14 @@
package com.android.settingslib.activityembedding;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.core.os.BuildCompat;
import androidx.window.embedding.SplitController;
import com.android.settingslib.utils.BuildCompatUtils;
@@ -44,6 +50,33 @@ public class ActivityEmbeddingUtils {
return false;
}
/**
* Whether current activity is embedded in the Settings app or not.
*/
public static boolean isActivityEmbedded(Activity activity) {
return SplitController.getInstance().isActivityEmbedded(activity);
}
/**
* Whether current activity is suggested to show back button or not.
*/
public static boolean shouldHideBackButton(Activity activity, boolean isSecondaryLayerPage) {
if (!BuildCompat.isAtLeastT()) {
return false;
}
if (!isSecondaryLayerPage) {
return false;
}
final String shouldHideBackButton = Settings.Global.getString(activity.getContentResolver(),
"settings_hide_secondary_page_back_button_in_two_pane");
if (TextUtils.isEmpty(shouldHideBackButton)
|| TextUtils.equals("true", shouldHideBackButton)) {
return isActivityEmbedded(activity);
}
return false;
}
private ActivityEmbeddingUtils() {
}
}

View File

@@ -48,7 +48,6 @@ android_library {
"SettingsLibCollapsingToolbarBaseActivity",
"SettingsLibTwoTargetPreference",
"SettingsLibSettingsTransition",
"SettingsLibActivityEmbedding",
"SettingsLibButtonPreference",
"setupdesign",
],