Skip to content

Commit 8aef204

Browse files
Clean up theming code
1 parent c7ee483 commit 8aef204

11 files changed

Lines changed: 20 additions & 108 deletions

File tree

app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import org.schabi.newpipe.util.SimpleOnSeekBarChangeListener;
7171
import org.schabi.newpipe.util.StreamItemAdapter;
7272
import org.schabi.newpipe.util.StreamItemAdapter.StreamInfoWrapper;
73-
import org.schabi.newpipe.util.ThemeHelper;
7473

7574
import java.io.File;
7675
import java.io.IOException;
@@ -212,7 +211,6 @@ public void onCreate(@Nullable final Bundle savedInstanceState) {
212211
// dialog is being dismissed in onViewCreated()
213212
context = getContext();
214213

215-
setStyle(STYLE_NO_TITLE, ThemeHelper.getDialogTheme(context));
216214
Bridge.restoreInstanceState(this, savedInstanceState);
217215

218216
this.audioTrackAdapter = new AudioTrackAdapter(wrappedAudioTracks);

app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistCreationDialog.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.schabi.newpipe.database.stream.model.StreamEntity;
1515
import org.schabi.newpipe.databinding.DialogEditTextBinding;
1616
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
17-
import org.schabi.newpipe.util.ThemeHelper;
1817

1918
import java.util.List;
2019

@@ -45,30 +44,25 @@ public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
4544
return super.onCreateDialog(savedInstanceState);
4645
}
4746

48-
final DialogEditTextBinding dialogBinding =
49-
DialogEditTextBinding.inflate(getLayoutInflater());
50-
dialogBinding.getRoot().getContext().setTheme(ThemeHelper.getDialogTheme(requireContext()));
47+
final var dialogBinding = DialogEditTextBinding.inflate(getLayoutInflater());
5148
dialogBinding.dialogEditText.setHint(R.string.name);
5249
dialogBinding.dialogEditText.setInputType(InputType.TYPE_CLASS_TEXT);
5350

54-
final Builder dialogBuilder = new Builder(requireContext(),
55-
ThemeHelper.getDialogTheme(requireContext()))
51+
return new Builder(requireContext())
5652
.setTitle(R.string.create_playlist)
5753
.setView(dialogBinding.getRoot())
5854
.setCancelable(true)
5955
.setNegativeButton(R.string.cancel, null)
6056
.setPositiveButton(R.string.create, (dialogInterface, i) -> {
6157
final String name = dialogBinding.dialogEditText.getText().toString();
62-
final LocalPlaylistManager playlistManager =
63-
new LocalPlaylistManager(NewPipeDatabase.getInstance(requireContext()));
58+
final var db = NewPipeDatabase.getInstance(requireContext());
6459
final Toast successToast = Toast.makeText(getActivity(),
65-
R.string.playlist_creation_success,
66-
Toast.LENGTH_SHORT);
60+
R.string.playlist_creation_success, Toast.LENGTH_SHORT);
6761

68-
playlistManager.createPlaylist(name, getStreamEntities())
62+
new LocalPlaylistManager(db).createPlaylist(name, getStreamEntities())
6963
.observeOn(AndroidSchedulers.mainThread())
7064
.subscribe(longs -> successToast.show());
71-
});
72-
return dialogBuilder.create();
65+
})
66+
.create();
7367
}
7468
}

app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import org.schabi.newpipe.local.subscription.item.ImportSubscriptionsHintPlaceho
3939
import org.schabi.newpipe.local.subscription.item.PickerIconItem
4040
import org.schabi.newpipe.local.subscription.item.PickerSubscriptionItem
4141
import org.schabi.newpipe.util.DeviceUtils
42-
import org.schabi.newpipe.util.ThemeHelper
4342
import java.io.Serializable
4443

4544
class FeedGroupDialog : DialogFragment(), BackPressable {
@@ -80,7 +79,6 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
8079
super.onCreate(savedInstanceState)
8180
Bridge.restoreInstanceState(this, savedInstanceState)
8281

83-
setStyle(STYLE_NO_TITLE, ThemeHelper.getMinWidthDialogTheme(requireContext()))
8482
groupId = arguments?.getLong(KEY_GROUP_ID, NO_GROUP_SELECTED) ?: NO_GROUP_SELECTED
8583
}
8684

app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import org.schabi.newpipe.databinding.DialogFeedGroupReorderBinding
2121
import org.schabi.newpipe.local.subscription.dialog.FeedGroupReorderDialogViewModel.DialogEvent.ProcessingEvent
2222
import org.schabi.newpipe.local.subscription.dialog.FeedGroupReorderDialogViewModel.DialogEvent.SuccessEvent
2323
import org.schabi.newpipe.local.subscription.item.FeedGroupReorderItem
24-
import org.schabi.newpipe.util.ThemeHelper
2524
import java.util.Collections
2625

2726
class FeedGroupReorderDialog : DialogFragment() {
@@ -39,8 +38,6 @@ class FeedGroupReorderDialog : DialogFragment() {
3938
override fun onCreate(savedInstanceState: Bundle?) {
4039
super.onCreate(savedInstanceState)
4140
Bridge.restoreInstanceState(this, savedInstanceState)
42-
43-
setStyle(STYLE_NO_TITLE, ThemeHelper.getMinWidthDialogTheme(requireContext()))
4441
}
4542

4643
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import android.widget.TextView;
1111

1212
import androidx.annotation.NonNull;
13-
import androidx.annotation.Nullable;
1413
import androidx.compose.ui.platform.ComposeView;
1514
import androidx.fragment.app.DialogFragment;
1615
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -22,7 +21,6 @@
2221
import org.schabi.newpipe.local.subscription.SubscriptionManager;
2322
import org.schabi.newpipe.ui.emptystate.EmptyStateSpec;
2423
import org.schabi.newpipe.ui.emptystate.EmptyStateUtil;
25-
import org.schabi.newpipe.util.ThemeHelper;
2624
import org.schabi.newpipe.util.image.CoilHelper;
2725

2826
import java.util.List;
@@ -77,12 +75,6 @@ public void setOnCancelListener(final OnCancelListener listener) {
7775
// Init
7876
//////////////////////////////////////////////////////////////////////////*/
7977

80-
@Override
81-
public void onCreate(@Nullable final Bundle savedInstanceState) {
82-
super.onCreate(savedInstanceState);
83-
setStyle(STYLE_NO_TITLE, ThemeHelper.getMinWidthDialogTheme(requireContext()));
84-
}
85-
8678
@Override
8779
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container,
8880
final Bundle savedInstanceState) {

app/src/main/java/org/schabi/newpipe/settings/SelectFeedGroupFragment.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.schabi.newpipe.settings;
22

3-
import android.content.DialogInterface;
43
import android.os.Bundle;
54
import android.view.LayoutInflater;
65
import android.view.View;
@@ -10,7 +9,6 @@
109
import android.widget.TextView;
1110

1211
import androidx.annotation.NonNull;
13-
import androidx.annotation.Nullable;
1412
import androidx.fragment.app.DialogFragment;
1513
import androidx.recyclerview.widget.LinearLayoutManager;
1614
import androidx.recyclerview.widget.RecyclerView;
@@ -20,7 +18,6 @@
2018
import org.schabi.newpipe.database.AppDatabase;
2119
import org.schabi.newpipe.database.feed.model.FeedGroupEntity;
2220
import org.schabi.newpipe.error.ErrorUtil;
23-
import org.schabi.newpipe.util.ThemeHelper;
2421

2522
import java.util.List;
2623
import java.util.Vector;
@@ -52,10 +49,7 @@
5249
*/
5350

5451
public class SelectFeedGroupFragment extends DialogFragment {
55-
56-
private OnSelectedListener onSelectedListener = null;
57-
private OnCancelListener onCancelListener = null;
58-
52+
private OnSelectedListener onSelectedListener;
5953
private ProgressBar progressBar;
6054
private TextView emptyView;
6155
private RecyclerView recyclerView;
@@ -66,20 +60,10 @@ public void setOnSelectedListener(final OnSelectedListener listener) {
6660
onSelectedListener = listener;
6761
}
6862

69-
public void setOnCancelListener(final OnCancelListener listener) {
70-
onCancelListener = listener;
71-
}
72-
7363
/*//////////////////////////////////////////////////////////////////////////
7464
// Init
7565
//////////////////////////////////////////////////////////////////////////*/
7666

77-
@Override
78-
public void onCreate(@Nullable final Bundle savedInstanceState) {
79-
super.onCreate(savedInstanceState);
80-
setStyle(STYLE_NO_TITLE, ThemeHelper.getMinWidthDialogTheme(requireContext()));
81-
}
82-
8367
@Override
8468
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container,
8569
final Bundle savedInstanceState) {
@@ -109,14 +93,6 @@ public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup
10993
// Handle actions
11094
//////////////////////////////////////////////////////////////////////////*/
11195

112-
@Override
113-
public void onCancel(@NonNull final DialogInterface dialogInterface) {
114-
super.onCancel(dialogInterface);
115-
if (onCancelListener != null) {
116-
onCancelListener.onCancel();
117-
}
118-
}
119-
12096
private void clickedItem(final int position) {
12197
if (onSelectedListener != null) {
12298
final FeedGroupEntity entry = feedGroups.get(position);

app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import android.widget.TextView;
99

1010
import androidx.annotation.NonNull;
11-
import androidx.annotation.Nullable;
1211
import androidx.appcompat.content.res.AppCompatResources;
1312
import androidx.fragment.app.DialogFragment;
1413
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -20,7 +19,6 @@
2019
import org.schabi.newpipe.extractor.StreamingService;
2120
import org.schabi.newpipe.util.KioskTranslator;
2221
import org.schabi.newpipe.util.ServiceHelper;
23-
import org.schabi.newpipe.util.ThemeHelper;
2422

2523
import java.util.List;
2624
import java.util.Vector;
@@ -59,12 +57,6 @@ public void setOnSelectedListener(final OnSelectedListener listener) {
5957
// Init
6058
//////////////////////////////////////////////////////////////////////////*/
6159

62-
@Override
63-
public void onCreate(@Nullable final Bundle savedInstanceState) {
64-
super.onCreate(savedInstanceState);
65-
setStyle(STYLE_NO_TITLE, ThemeHelper.getMinWidthDialogTheme(requireContext()));
66-
}
67-
6860
@Override
6961
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
7062
final Bundle savedInstanceState) {

app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,29 +90,6 @@ public static boolean isLightThemeSelected(final Context context) {
9090
&& !isDeviceDarkThemeEnabled(context));
9191
}
9292

93-
/**
94-
* Return a dialog theme styled according to the (default) selected theme.
95-
*
96-
* @param context context to get the selected theme
97-
* @return the dialog style (the default one)
98-
*/
99-
@StyleRes
100-
public static int getDialogTheme(final Context context) {
101-
return isLightThemeSelected(context) ? R.style.LightDialogTheme : R.style.DarkDialogTheme;
102-
}
103-
104-
/**
105-
* Return a min-width dialog theme styled according to the (default) selected theme.
106-
*
107-
* @param context context to get the selected theme
108-
* @return the dialog style (the default one)
109-
*/
110-
@StyleRes
111-
public static int getMinWidthDialogTheme(final Context context) {
112-
return isLightThemeSelected(context) ? R.style.LightDialogMinWidthTheme
113-
: R.style.DarkDialogMinWidthTheme;
114-
}
115-
11693
/**
11794
* Return the selected theme styled according to the serviceId.
11895
*

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
<Button
7272
android:id="@+id/select_channel_button"
73-
style="@style/Widget.AppCompat.Button.Borderless"
73+
style="@style/Widget.Material3.Button.TextButton"
7474
android:layout_width="match_parent"
7575
android:layout_height="wrap_content"
7676
android:layout_marginStart="8dp"
@@ -107,8 +107,7 @@
107107
android:id="@+id/subscriptions_header_toolbar"
108108
android:layout_width="match_parent"
109109
android:layout_height="?attr/actionBarSize"
110-
android:gravity="center_vertical"
111-
android:theme="@style/ContrastToolbarTheme">
110+
android:gravity="center_vertical">
112111

113112
<LinearLayout
114113
android:id="@+id/subscriptions_header_info_container"
@@ -157,7 +156,7 @@
157156

158157
<org.schabi.newpipe.views.NewPipeTextView
159158
android:id="@+id/delete_screen_message"
160-
style="@style/TextAppearance.AppCompat.Subhead"
159+
style="@style/TextAppearance.Material3.ActionBar.Subtitle"
161160
android:layout_width="wrap_content"
162161
android:layout_height="wrap_content"
163162
android:layout_gravity="start"

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
android:layout_width="match_parent"
55
android:layout_height="wrap_content"
6-
android:orientation="horizontal"
7-
android:theme="@style/ContrastTintTheme">
6+
android:orientation="horizontal">
87

98
<LinearLayout
109
android:id="@+id/suggestion_search"

0 commit comments

Comments
 (0)