Skip to content

Commit fa37184

Browse files
Migrate app themes to Material 3
1 parent abfde87 commit fa37184

17 files changed

Lines changed: 272 additions & 280 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
import android.content.Context;
1111
import android.content.SharedPreferences;
12-
import android.content.res.ColorStateList;
13-
import android.graphics.Color;
1412
import android.os.Bundle;
1513
import android.util.Log;
1614
import android.view.LayoutInflater;
@@ -21,7 +19,6 @@
2119
import android.view.ViewGroup;
2220
import android.widget.RelativeLayout;
2321

24-
import androidx.annotation.ColorInt;
2522
import androidx.annotation.NonNull;
2623
import androidx.annotation.Nullable;
2724
import androidx.appcompat.app.ActionBar;
@@ -44,7 +41,6 @@
4441
import org.schabi.newpipe.settings.tabs.TabsManager;
4542
import org.schabi.newpipe.util.NavigationHelper;
4643
import org.schabi.newpipe.util.ServiceHelper;
47-
import org.schabi.newpipe.util.ThemeHelper;
4844
import org.schabi.newpipe.views.ScrollableTabLayout;
4945

5046
import java.util.ArrayList;
@@ -242,18 +238,6 @@ private void updateTabLayoutPosition() {
242238

243239
tabLayout.setLayoutParams(tabParams);
244240
viewPager.setLayoutParams(pagerParams);
245-
246-
// change the background and icon color of the tab layout:
247-
// service-colored at the top, app-background-colored at the bottom
248-
tabLayout.setBackgroundColor(ThemeHelper.resolveColorFromAttr(requireContext(),
249-
bottom ? android.R.attr.windowBackground : R.attr.colorPrimary));
250-
251-
@ColorInt final int iconColor = bottom
252-
? ThemeHelper.resolveColorFromAttr(requireContext(), android.R.attr.colorAccent)
253-
: Color.WHITE;
254-
tabLayout.setTabRippleColor(ColorStateList.valueOf(iconColor).withAlpha(32));
255-
tabLayout.setTabIconTint(ColorStateList.valueOf(iconColor));
256-
tabLayout.setSelectedTabIndicatorColor(iconColor);
257241
}
258242

259243
@Override

app/src/main/java/org/schabi/newpipe/ui/components/common/ScaffoldWithToolbar.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack
88
import androidx.compose.material3.ExperimentalMaterial3Api
99
import androidx.compose.material3.Icon
1010
import androidx.compose.material3.IconButton
11-
import androidx.compose.material3.MaterialTheme
1211
import androidx.compose.material3.Scaffold
1312
import androidx.compose.material3.Text
1413
import androidx.compose.material3.TopAppBar
15-
import androidx.compose.material3.TopAppBarDefaults
1614
import androidx.compose.runtime.Composable
1715
import androidx.compose.ui.tooling.preview.Preview
1816

@@ -28,14 +26,6 @@ fun ScaffoldWithToolbar(
2826
topBar = {
2927
TopAppBar(
3028
title = { Text(text = title) },
31-
// TODO decide whether to use default colors instead
32-
colors = TopAppBarDefaults.topAppBarColors(
33-
containerColor = MaterialTheme.colorScheme.primaryContainer,
34-
scrolledContainerColor = MaterialTheme.colorScheme.primaryContainer,
35-
navigationIconContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
36-
titleContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
37-
actionIconContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
38-
),
3929
navigationIcon = {
4030
IconButton(onClick = onBackClick) {
4131
Icon(

app/src/main/java/org/schabi/newpipe/ui/screens/AboutScreen.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ fun AboutScreen(padding: PaddingValues) {
4444
tabIndex = pagerState.currentPage
4545
}
4646

47-
TabRow(
48-
selectedTabIndex = tabIndex,
49-
containerColor = MaterialTheme.colorScheme.primaryContainer
50-
) {
47+
TabRow(selectedTabIndex = tabIndex) {
5148
TITLES.forEachIndexed { index, titleId ->
5249
Tab(
5350
text = { Text(text = stringResource(titleId)) },

app/src/main/res/layout-land/activity_player_queue_control.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
android:id="@+id/appbar"
1313
android:layout_width="match_parent"
1414
android:layout_height="wrap_content"
15-
android:theme="@style/ThemeOverlay.AppCompat.DayNight.ActionBar"
16-
app:popupTheme="@style/ThemeOverlay.AppCompat.DayNight.ActionBar">
15+
android:theme="@style/ThemeOverlay.Material3.ActionBar"
16+
app:popupTheme="@style/ThemeOverlay.Material3.ActionBar">
1717

1818
<androidx.appcompat.widget.Toolbar
1919
android:id="@+id/toolbar"
2020
android:layout_width="match_parent"
2121
android:layout_height="?attr/actionBarSize"
2222
android:layout_weight="1"
2323
android:background="?attr/colorPrimary"
24-
android:theme="@style/ToolbarTheme"
2524
app:layout_scrollFlags="scroll|enterAlways"
2625
app:title="@string/app_name" />
2726

app/src/main/res/layout/activity_player_queue_control.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
android:id="@+id/appbar"
1313
android:layout_width="match_parent"
1414
android:layout_height="wrap_content"
15-
android:theme="@style/ThemeOverlay.AppCompat.DayNight.ActionBar"
16-
app:popupTheme="@style/ThemeOverlay.AppCompat.DayNight.ActionBar">
15+
android:theme="@style/ThemeOverlay.Material3.ActionBar"
16+
app:popupTheme="@style/ThemeOverlay.Material3.ActionBar">
1717

1818
<androidx.appcompat.widget.Toolbar
1919
android:id="@+id/toolbar"
2020
android:layout_width="match_parent"
2121
android:layout_height="?attr/actionBarSize"
2222
android:layout_weight="1"
2323
android:background="?attr/colorPrimary"
24-
android:theme="@style/ToolbarTheme"
2524
app:layout_scrollFlags="scroll|enterAlways"
2625
app:title="@string/app_name" />
2726

app/src/main/res/layout/fragment_channel.xml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
android:layout_width="match_parent"
66
android:layout_height="match_parent">
77

8-
<!-- since ToolbarTheme sets the tint to icons, it would make images all white,
9-
therefore app:tint="@null" is used to undo that setting -->
108
<com.google.android.material.appbar.AppBarLayout
119
android:id="@+id/app_bar_layout"
1210
android:layout_width="match_parent"
1311
android:layout_height="wrap_content"
14-
android:theme="@style/ToolbarTheme"
1512
app:elevation="0dp">
1613

1714
<org.schabi.newpipe.views.CustomCollapsingToolbarLayout
@@ -37,7 +34,6 @@
3734
android:scaleType="fitCenter"
3835
android:src="@drawable/placeholder_channel_banner"
3936
app:layout_constraintTop_toTopOf="parent"
40-
app:tint="@null"
4137
tools:ignore="ContentDescription" />
4238

4339
<com.google.android.material.imageview.ShapeableImageView
@@ -54,8 +50,7 @@
5450
app:layout_constraintVertical_bias="1.0"
5551
app:shapeAppearance="@style/CircularImageView"
5652
app:strokeColor="#ffffff"
57-
app:strokeWidth="2dp"
58-
app:tint="@null" />
53+
app:strokeWidth="2dp" />
5954

6055
<com.google.android.material.imageview.ShapeableImageView
6156
android:id="@+id/sub_channel_avatar_view"
@@ -69,7 +64,6 @@
6964
app:shapeAppearance="@style/CircularImageView"
7065
app:strokeColor="#ffffff"
7166
app:strokeWidth="2dp"
72-
app:tint="@null"
7367
tools:visibility="visible" />
7468

7569
<org.schabi.newpipe.views.NewPipeTextView
@@ -146,12 +140,8 @@
146140
android:id="@+id/tab_layout"
147141
android:layout_width="match_parent"
148142
android:layout_height="wrap_content"
149-
android:background="?attr/colorPrimary"
150143
app:tabGravity="fill"
151-
app:tabIndicatorColor="@color/white"
152-
app:tabMode="scrollable"
153-
app:tabRippleColor="@color/white"
154-
app:tabTextColor="@color/white" />
144+
app:tabMode="scrollable" />
155145

156146
<androidx.viewpager.widget.ViewPager
157147
android:id="@+id/view_pager"
@@ -174,8 +164,7 @@
174164
android:layout_height="wrap_content"
175165
android:layout_centerInParent="true"
176166
android:visibility="gone"
177-
tools:visibility="visible"
178-
/>
167+
tools:visibility="visible" />
179168

180169
<!--ERROR PANEL-->
181170
<include

app/src/main/res/layout/fragment_main.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
android:layout_width="match_parent"
55
android:layout_height="match_parent">
66

7-
87
<org.schabi.newpipe.views.ScrollableTabLayout
98
android:id="@+id/main_tab_layout"
109
android:layout_width="match_parent"
1110
android:layout_height="wrap_content"
1211
android:layout_alignParentTop="true"
13-
android:background="?attr/colorPrimary"
14-
app:tabRippleColor="@color/white"
15-
app:tabIconTint="@color/white"
16-
app:tabIndicatorColor="@color/white"
1712
app:tabGravity="fill"
1813
app:tabMinWidth="60dp" />
1914

app/src/main/res/layout/toolbar_layout.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
43
xmlns:tools="http://schemas.android.com/tools"
54
android:layout_width="match_parent"
65
android:layout_height="wrap_content"
@@ -10,10 +9,8 @@
109
android:id="@+id/toolbar"
1110
android:layout_width="match_parent"
1211
android:layout_height="?attr/actionBarSize"
13-
android:background="?attr/colorPrimary"
1412
android:gravity="center_vertical"
15-
android:minHeight="?attr/actionBarSize"
16-
android:theme="@style/ToolbarTheme">
13+
android:minHeight="?attr/actionBarSize">
1714

1815
<include
1916
android:id="@+id/toolbar_search_container"

app/src/main/res/layout/toolbar_search_layout.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
43
xmlns:tools="http://schemas.android.com/tools"
54
android:layout_width="match_parent"
65
android:layout_height="?attr/actionBarSize"
@@ -18,12 +17,10 @@
1817
android:focusable="true"
1918
android:focusableInTouchMode="true"
2019
android:hint="@string/search"
21-
android:textColor="?attr/toolbarSearchColor"
2220
android:imeOptions="actionSearch|flagNoFullscreen"
2321
android:inputType="textFilter|textNoSuggestions"
2422
android:maxLines="1"
2523
android:nextFocusDown="@+id/suggestions_list"
26-
android:theme="@style/ToolbarSearchInputTheme"
2724
tools:ignore="RtlHardcoded" />
2825

2926
<FrameLayout
@@ -49,7 +46,6 @@
4946
android:contentDescription="@string/search"
5047
android:scaleType="fitCenter"
5148
android:src="@drawable/ic_close"
52-
app:tint="?attr/toolbarSearchColor"
5349
tools:ignore="RtlHardcoded" />
5450
</FrameLayout>
5551

app/src/main/res/values-night/colors.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)