Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion SettingsLib/ButtonPreference/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
namespace 'com.android.settingslib.widget.preference.button'

defaultConfig {
minSdk 21
minSdk 23
versionCode 1
versionName "1.0"
}
Expand Down
1 change: 1 addition & 0 deletions SettingsLib/CollapsingToolbarBaseActivity/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

def SettingsLibCollapsingToolbarBaseActivity = '../fwb/packages/SettingsLib/CollapsingToolbarBaseActivity'
Expand Down
2 changes: 1 addition & 1 deletion SettingsLib/LayoutPreference/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
namespace 'com.android.settingslib.widget.preference.layout'

defaultConfig {
minSdk 21
minSdk 23
versionCode 1
versionName "1.0"
}
Expand Down
2 changes: 1 addition & 1 deletion SettingsLib/SettingsTheme/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
namespace 'com.android.settingslib.widget.theme'

defaultConfig {
minSdk 21
minSdk 23
versionCode 1
versionName "1.0"
}
Expand Down
2 changes: 1 addition & 1 deletion SettingsLib/SettingsThemeFlags/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
namespace 'com.android.settingslib.widget.theme.flags'

defaultConfig {
minSdk 21
minSdk 23
}

sourceSets {
Expand Down
2 changes: 1 addition & 1 deletion SettingsLib/TwoTargetPreference/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
namespace 'com.android.settingslib.widget.preference.twotarget'

defaultConfig {
minSdk 21
minSdk 23
versionCode 1
versionName "1.0"
}
Expand Down
2 changes: 1 addition & 1 deletion SettingsLib/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare -r SHORT_OPTS=u:,t:
declare -r LONG_OPTS=set-repo-url:,set-repo-tag:,get-repo-url,get-repo-tag,apply-patches-only
declare -r FWB_DIR='fwb'
declare REPO_URL='https://android.googlesource.com/platform/frameworks/base.git'
declare REPO_TAG='android-16.0.0_r1'
declare REPO_TAG='android-16.0.0_r4'
declare -a LIBS=(
'BannerMessagePreference'
'ButtonPreference'
Expand Down
18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# https://mvnrepository.com/artifact/androidx.room/room-runtime
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/room/room-compiler/
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/room/room-runtime/
room = "2.7.0-beta01"
room = "2.8.0-alpha01"
# https://mvnrepository.com/artifact/com.google.dagger/hilt-android
# https://mvnrepository.com/artifact/com.google.dagger/hilt-compiler
# https://android.googlesource.com/platform/external/dagger2
Expand All @@ -33,10 +33,10 @@ kover = "0.9.1"
[libraries]
# https://mvnrepository.com/artifact/androidx.activity/activity
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/activity/activity/
activity = { module = "androidx.activity:activity", version = "1.11.0-alpha01" }
activity = { module = "androidx.activity:activity", version = "1.12.0-alpha08" }
# https://mvnrepository.com/artifact/androidx.annotation/annotation
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/annotation/annotation-jvm/
annotation = { module = "androidx.annotation:annotation", version = "1.9.0-rc01" }
annotation = { module = "androidx.annotation:annotation", version = "1.9.1" } # TODO: AOSP sources use 1.11.0-alpha01; upgrade when available in Maven Central
# https://mvnrepository.com/artifact/androidx.appcompat/appcompat
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/appcompat/appcompat/
appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.1" } # TODO: AOSP sources use 1.8.0-alpha01; upgrade when available in Maven Central }
Expand All @@ -46,16 +46,16 @@ arch-core-testing = { module = "androidx.arch.core:core-testing", version = "2.2
awaitility = { module = "org.awaitility:awaitility", version = "4.3.0" }
# https://mvnrepository.com/artifact/androidx.biometric/biometric
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/biometric/biometric/
biometric = { module = "androidx.biometric:biometric", version = "1.4.0-alpha02" }
biometric = { module = "androidx.biometric:biometric", version = "1.4.0-alpha04" }
# https://mvnrepository.com/artifact/androidx.collection/collection
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/collection/collection-jvm/
collection = { module = "androidx.collection:collection", version = "1.5.0-beta03" }
collection = { module = "androidx.collection:collection", version = "1.5.0" }
# https://mvnrepository.com/artifact/androidx.coordinatorlayout/coordinatorlayout
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/coordinatorlayout/coordinatorlayout/
coordinatorlayout = { module = "androidx.coordinatorlayout:coordinatorlayout", version = "1.3.0-alpha02" }
# https://mvnrepository.com/artifact/androidx.core/core
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/core/core/
core = { module = "androidx.core:core", version = "1.16.0-beta01" }
core = { module = "androidx.core:core", version = "1.17.0" } # TODO: AOSP sources use 1.19.0-alpha01; upgrade when available in Maven Central }
# https://mvnrepository.com/artifact/com.google.errorprone/error_prone_core
errorprone = { module = "com.google.errorprone:error_prone_core", version = "2.42.0" }
# https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core
Expand All @@ -70,10 +70,10 @@ hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hil
junit = { module = "junit:junit", version = "4.13.2" }
# https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-livedata
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/lifecycle/lifecycle-livedata/
livedata = { module = "androidx.lifecycle:lifecycle-livedata", version = "2.9.0-alpha12" }
livedata = { module = "androidx.lifecycle:lifecycle-livedata", version = "2.10.0-alpha04" }
# https://mvnrepository.com/artifact/com.google.android.material/material
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/extras/material-design-x/com/google/android/material/material/
material = { module = "com.google.android.material:material", version = "1.13.0-alpha08" }
material = { module = "com.google.android.material:material", version = "1.14.0-alpha02" }
# https://mvnrepository.com/artifact/org.mockito/mockito-core
mockito = { module = "org.mockito:mockito-core", version = "5.20.0" }
# https://mvnrepository.com/artifact/androidx.preference/preference
Expand Down Expand Up @@ -101,7 +101,7 @@ test-rules = { module = "androidx.test:rules", version = "1.7.0" }
test-runner = { module = "androidx.test:runner", version = "1.7.0" }
# https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-viewmodel
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/lifecycle/lifecycle-viewmodel-android/
viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version = "2.9.0-alpha12" }
viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version = "2.10.0-alpha04" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down
11 changes: 11 additions & 0 deletions res/values-v36/themes_expressive.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,16 @@

<item name="scheduleCardCollapsedBackgroundColor">@color/settingslib_materialColorSurfaceBright</item>
<item name="scheduleCardExpandedBackgroundColor">@color/settingslib_materialColorSurfaceDim</item>

<item name="expressiveTwoTargetPreferenceTheme">@style/ExpressiveTwoTargetPreferenceTheme.Custom</item>
</style>

<style name="ExpressiveTwoTargetPreferenceTheme.Custom" parent="ExpressiveTwoTargetPreferenceTheme">
<item name="expressiveTwoTargetDividerStyle">@style/ExpressiveTwoTargetDividerStyle.Custom</item>
</style>

<style name="ExpressiveTwoTargetDividerStyle.Custom" parent="ExpressiveTwoTargetDividerStyle">
<!-- Remove unnecessary padding at the start of the divider in the expressive theme. -->
<item name="android:paddingStart">0dip</item>
</style>
</resources>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.iusmac.sevensim.ui.components;

import android.annotation.DrawableRes;
import android.app.ActionBar;
import android.os.Bundle;
import android.view.MenuItem;
Expand Down Expand Up @@ -37,7 +38,7 @@ public abstract class CollapsingToolbarBaseActivity extends FragmentActivity {
private CollapsingToolbarDelegate mToolbardelegate;
private ToolbarDecorator mToolbarDecorator;
private ViewModel mViewModel;
private Optional<View> mActionButton = Optional.empty();
private Optional<View> mTrailingButtons = Optional.empty();

@Override
protected void onCreate(final @Nullable Bundle savedInstanceState) {
Expand All @@ -46,6 +47,8 @@ protected void onCreate(final @Nullable Bundle savedInstanceState) {
EdgeToEdgeUtils.enable(this);
super.onCreate(savedInstanceState);

getToolbarDelegate().registerToolbarCollapseBehavior(this);

final boolean isExpressiveTheme = SettingsThemeHelper.isExpressiveTheme(this);
if (isExpressiveTheme) {
setTheme(R.style.Theme_SubSettingsBase_Expressive_Custom);
Expand Down Expand Up @@ -78,10 +81,14 @@ protected void onCreate(final @Nullable Bundle savedInstanceState) {
getAppBarLayout().setExpanded(true);
}
if (isExpressiveTheme) {
mActionButton = Optional.ofNullable(getToolbarDelegate().getToolbar().findViewById(
com.android.settingslib.collapsingtoolbar.R.id.action_button));
// Hide the action button by default when expressive theme is enabled.
setActionButtonEnabled(false);
mTrailingButtons = Optional.<View>ofNullable(getToolbarDelegate().getToolbar()
// Use action button view to find the trailing buttons parent
.findViewById(com.android.settingslib.collapsingtoolbar.R.id.action_button))
.map((v) -> (View) v.getParent());
// Hide the trailing buttons view by default when expressive theme is enabled to
// avoid the blank space at the end of the Toolbar added in XML, which we can't
// edit. This will allow for the Toolbar's title & subtitle to fully expand
setTrailingButtonsEnabled(false);
}
// Our use case requires the CollapsingToolbar to be permanently lifted above the
// scrollable content (safe to disable; less animations, better performance)
Expand Down Expand Up @@ -129,6 +136,52 @@ public void setSubtitle(final @StringRes int subtitleId) {
setSubtitle(getText(subtitleId));
}

/**
* Show/Hide the primary button on the Toolbar.
* @param enabled true to show the button, otherwise it's hidden.
*/
public void setPrimaryButtonEnabled(final boolean enabled) {
getToolbarDelegate().setPrimaryButtonEnabled(enabled);
}

/** Set the icon to the primary button */
public void setPrimaryButtonIcon(final @DrawableRes int drawableRes) {
getToolbarDelegate().setPrimaryButtonIcon(this, drawableRes);
}

/** Set the OnClick listener to the primary button. */
public void setPrimaryButtonOnClickListener(final @Nullable View.OnClickListener listener) {
getToolbarDelegate().setPrimaryButtonOnClickListener(listener);
}

/** Set the content description to the primary button */
public void setPrimaryButtonContentDescription(final @Nullable CharSequence contentDescription) {
getToolbarDelegate().setPrimaryButtonContentDescription(contentDescription);
}

/**
* Show/Hide the secondary button on the Toolbar.
* @param enabled true to show the button, otherwise it's hidden.
*/
public void setSecondaryButtonEnabled(final boolean enabled) {
getToolbarDelegate().setSecondaryButtonEnabled(enabled);
}

/** Set the icon to the secondary button */
public void setSecondaryButtonIcon(final @DrawableRes int drawableRes) {
getToolbarDelegate().setSecondaryButtonIcon(this, drawableRes);
}

/** Set the OnClick listener to the secondary button */
public void setSecondaryButtonOnClickListener(final @Nullable View.OnClickListener listener) {
getToolbarDelegate().setSecondaryButtonOnClickListener(listener);
}

/** Set the content description to the secondary button */
public void setSecondaryButtonContentDescription(final @Nullable CharSequence contentDescription) {
getToolbarDelegate().setSecondaryButtonContentDescription(contentDescription);
}

/**
* Show/Hide the action button on the Toolbar.
*
Expand All @@ -137,13 +190,46 @@ public void setSubtitle(final @StringRes int subtitleId) {
* @param enabled {@code true} to show the button, otherwise it's hidden.
*/
public void setActionButtonEnabled(final boolean enabled) {
mActionButton.ifPresent((v) ->
// Note that, the action button is wrapped by a parent view that has padding and we
// can't edit the layout in XML, so we want to hide it too to avoid empty spaces
((View) v.getParent()).setVisibility(enabled ? View.VISIBLE : View.GONE));
getToolbarDelegate().setActionButtonEnabled(enabled);
}

/**
* Enable/Disable the action button on the Toolbar (being clickable or not).
* @param clickable true to enable the button, otherwise it's disabled.
*/
public void setActionButtonClickable(final boolean clickable) {
getToolbarDelegate().setActionButtonClickable(clickable);
}

/** Set the icon to the action button */
public void setActionButtonIcon(final @DrawableRes int drawableRes) {
getToolbarDelegate().setActionButtonIcon(this, drawableRes);
}

/** Set the text to the action button */
public void setActionButtonText(final @Nullable CharSequence text) {
getToolbarDelegate().setActionButtonText(text);
}

/** Set the OnClick listener to the action button */
public void setActionButtonListener(final @Nullable View.OnClickListener listener) {
getToolbarDelegate().setActionButtonOnClickListener(listener);
}

/** Set the content description to the action button */
public void setActionButtonContentDescription(final @Nullable CharSequence contentDescription) {
getToolbarDelegate().setActionButtonContentDescription(contentDescription);
}

/**
* Show/Hide the Toolbar's trailing buttons (action/primary/secondary) view.
*
* @param enabled {@code true} to show the trailing buttons view, otherwise it's hidden.
*/
public void setTrailingButtonsEnabled(final boolean enabled) {
mTrailingButtons.ifPresent((v) -> v.setVisibility(enabled ? View.VISIBLE : View.GONE));
}

@Override
public boolean onNavigateUp() {
if (!super.onNavigateUp()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Switch;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceViewHolder;

import com.android.settingslib.widget.SettingsThemeHelper;
import com.android.settingslib.widget.TwoTargetPreference;

import com.github.iusmac.sevensim.R;
Expand Down Expand Up @@ -99,16 +97,6 @@ public void onBindViewHolder(final PreferenceViewHolder holder) {
mSwitch.setChecked(mChecked);
mSwitch.setEnabled(mEnableSwitch);
}

if (SettingsThemeHelper.isExpressiveTheme(holder.itemView.getContext())) {
final View divider = holder.findViewById(
com.android.settingslib.widget.preference.twotarget.R.id.two_target_divider);
if (divider != null) {
// Remove unnecessary padding at the start of the divider in the expressive theme
divider.setPaddingRelative(0, divider.getPaddingTop(), divider.getPaddingEnd(),
divider.getPaddingBottom());
}
}
}

@Override
Expand Down
Loading