Skip to content

Commit a59660f

Browse files
authored
Merge pull request #8340 from litetex/fix-add-to-playlist
Fix "Add to playlist" not working and cleanup "RouterActivity" choice handling
2 parents 75e5fe7 + be5af0b commit a59660f

File tree

7 files changed

+221
-159
lines changed

7 files changed

+221
-159
lines changed

app/src/main/java/org/schabi/newpipe/RouterActivity.java

Lines changed: 164 additions & 120 deletions
Large diffs are not rendered by default.

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,7 @@ protected void initListeners() {
663663
binding.detailControlsCrashThePlayer.setOnClickListener(
664664
v -> VideoDetailPlayerCrasher.onCrashThePlayer(
665665
this.getContext(),
666-
this.player,
667-
getLayoutInflater())
666+
this.player)
668667
);
669668
}
670669

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailPlayerCrasher.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package org.schabi.newpipe.fragments.detail;
22

3+
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW;
4+
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_DECODING_FAILED;
5+
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_UNSPECIFIED;
6+
37
import android.content.Context;
48
import android.util.Log;
59
import android.view.ContextThemeWrapper;
@@ -29,10 +33,6 @@
2933
import java.util.Map;
3034
import java.util.function.Supplier;
3135

32-
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW;
33-
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_DECODING_FAILED;
34-
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_UNSPECIFIED;
35-
3636
/**
3737
* Outsourced logic for crashing the player in the {@link VideoDetailFragment}.
3838
*/
@@ -97,8 +97,7 @@ private static Context getThemeWrapperContext(final Context context) {
9797

9898
public static void onCrashThePlayer(
9999
@NonNull final Context context,
100-
@Nullable final Player player,
101-
@NonNull final LayoutInflater layoutInflater
100+
@Nullable final Player player
102101
) {
103102
if (player == null) {
104103
Log.d(TAG, "Player is not available");
@@ -109,16 +108,15 @@ public static void onCrashThePlayer(
109108
}
110109

111110
// -- Build the dialog/UI --
112-
113111
final Context themeWrapperContext = getThemeWrapperContext(context);
114-
115112
final LayoutInflater inflater = LayoutInflater.from(themeWrapperContext);
116-
final RadioGroup radioGroup = SingleChoiceDialogViewBinding.inflate(layoutInflater)
117-
.list;
118113

119-
final AlertDialog alertDialog = new AlertDialog.Builder(getThemeWrapperContext(context))
114+
final SingleChoiceDialogViewBinding binding =
115+
SingleChoiceDialogViewBinding.inflate(inflater);
116+
117+
final AlertDialog alertDialog = new AlertDialog.Builder(themeWrapperContext)
120118
.setTitle("Choose an exception")
121-
.setView(radioGroup)
119+
.setView(binding.getRoot())
122120
.setCancelable(true)
123121
.setNegativeButton(R.string.cancel, null)
124122
.create();
@@ -136,11 +134,9 @@ public static void onCrashThePlayer(
136134
);
137135
radioButton.setOnClickListener(v -> {
138136
tryCrashPlayerWith(player, entry.getValue().get());
139-
if (alertDialog != null) {
140-
alertDialog.cancel();
141-
}
137+
alertDialog.cancel();
142138
});
143-
radioGroup.addView(radioButton);
139+
binding.list.addView(radioButton);
144140
}
145141

146142
alertDialog.show();

app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import android.view.ViewGroup;
1111
import android.widget.CheckBox;
1212
import android.widget.ImageView;
13-
import android.widget.LinearLayout;
1413
import android.widget.RadioButton;
1514
import android.widget.RadioGroup;
1615
import android.widget.TextView;
@@ -25,6 +24,8 @@
2524
import androidx.preference.PreferenceViewHolder;
2625

2726
import org.schabi.newpipe.R;
27+
import org.schabi.newpipe.databinding.ListRadioIconItemBinding;
28+
import org.schabi.newpipe.databinding.SingleChoiceDialogViewBinding;
2829
import org.schabi.newpipe.player.MainPlayer;
2930
import org.schabi.newpipe.player.NotificationConstants;
3031
import org.schabi.newpipe.util.DeviceUtils;
@@ -189,13 +190,12 @@ void updateInfo() {
189190

190191
void openActionChooserDialog() {
191192
final LayoutInflater inflater = LayoutInflater.from(getContext());
192-
final LinearLayout rootLayout = (LinearLayout) inflater.inflate(
193-
R.layout.single_choice_dialog_view, null, false);
194-
final RadioGroup radioGroup = rootLayout.findViewById(android.R.id.list);
193+
final SingleChoiceDialogViewBinding binding =
194+
SingleChoiceDialogViewBinding.inflate(inflater);
195195

196196
final AlertDialog alertDialog = new AlertDialog.Builder(getContext())
197197
.setTitle(SLOT_TITLES[i])
198-
.setView(radioGroup)
198+
.setView(binding.getRoot())
199199
.setCancelable(true)
200200
.create();
201201

@@ -207,8 +207,8 @@ void openActionChooserDialog() {
207207

208208
for (int id = 0; id < NotificationConstants.SLOT_ALLOWED_ACTIONS[i].length; ++id) {
209209
final int action = NotificationConstants.SLOT_ALLOWED_ACTIONS[i][id];
210-
final RadioButton radioButton
211-
= (RadioButton) inflater.inflate(R.layout.list_radio_icon_item, null);
210+
final RadioButton radioButton = ListRadioIconItemBinding.inflate(inflater)
211+
.getRoot();
212212

213213
// if present set action icon with correct color
214214
if (NotificationConstants.ACTION_ICONS[action] != 0) {
@@ -230,7 +230,7 @@ void openActionChooserDialog() {
230230
radioButton.setLayoutParams(new RadioGroup.LayoutParams(
231231
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
232232
radioButton.setOnClickListener(radioButtonsClickListener);
233-
radioGroup.addView(radioButton);
233+
binding.list.addView(radioButton);
234234
}
235235
alertDialog.show();
236236

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:id="@android:id/list"
1+
<?xml version="1.0" encoding="utf-8"?><!-- -->
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
43
android:layout_width="match_parent"
5-
android:layout_height="wrap_content"
6-
android:paddingTop="?attr/listPreferredItemPaddingLeft" />
4+
android:layout_height="match_parent"
5+
android:fadeScrollbars="false">
6+
7+
<RadioGroup
8+
android:id="@android:id/list"
9+
android:layout_width="match_parent"
10+
android:layout_height="wrap_content"
11+
android:paddingTop="?attr/listPreferredItemPaddingLeft" />
12+
</ScrollView>
13+
14+

app/src/main/res/values-v21/styles.xml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,31 @@
1212
<style name="Base" parent="Base.V21"/>
1313

1414
<!-- Light Theme -->
15-
<style name="Base.V21.LightTheme" parent="Base.V19.LightTheme">
15+
<style name="Base.V21.LightTheme" parent="Base.V19.LightTheme" />
1616

17-
</style>
1817
<style name="Base.LightTheme" parent="Base.V21.LightTheme" />
1918

2019
<!-- Dark Theme -->
21-
<style name="Base.V21.DarkTheme" parent="Base.V19.DarkTheme">
20+
<style name="Base.V21.DarkTheme" parent="Base.V19.DarkTheme" />
2221

23-
</style>
2422
<style name="Base.DarkTheme" parent="Base.V21.DarkTheme" />
2523

2624
<!-- Black Theme -->
27-
<style name="Base.V21.BlackTheme" parent="Base.V19.BlackTheme">
25+
<style name="Base.V21.BlackTheme" parent="Base.V19.BlackTheme" />
2826

29-
</style>
3027
<style name="Base.BlackTheme" parent="Base.V21.BlackTheme" />
3128

29+
<!-- Router Activity -->
30+
<style name="Base.V21.RouterActivityThemeLight" parent="Base.RouterActivityThemeLight">
31+
<item name="android:statusBarColor">@android:color/transparent</item>
32+
</style>
33+
34+
<style name="RouterActivityThemeLight" parent="Base.V21.RouterActivityThemeLight" />
35+
36+
<style name="Base.V21.RouterActivityThemeDark" parent="Base.RouterActivityThemeDark">
37+
<item name="android:statusBarColor">@android:color/transparent</item>
38+
</style>
39+
40+
<style name="RouterActivityThemeDark" parent="Base.V21.RouterActivityThemeDark" />
41+
3242
</resources>

app/src/main/res/values/styles.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,25 @@
130130
<item name="colorAccent">@color/black_settings_accent_color</item>
131131
</style>
132132

133-
<style name="RouterActivityThemeLight" parent="LightTheme">
133+
<!-- Router Activity -->
134+
<style name="Base.RouterActivityThemeLight" parent="LightTheme">
134135
<item name="android:windowNoTitle">true</item>
135136
<item name="android:windowBackground">@android:color/transparent</item>
136137
<item name="android:colorBackgroundCacheHint">@null</item>
137138
<item name="android:windowIsTranslucent">true</item>
138139
<item name="android:windowAnimationStyle">@null</item>
139140
</style>
140141

141-
<style name="RouterActivityThemeDark" parent="DarkTheme">
142+
<style name="RouterActivityThemeLight" parent="Base.RouterActivityThemeLight" />
143+
144+
<style name="Base.RouterActivityThemeDark" parent="DarkTheme">
142145
<item name="android:windowNoTitle">true</item>
143146
<item name="android:windowBackground">@android:color/transparent</item>
144147
<item name="android:colorBackgroundCacheHint">@null</item>
145148
<item name="android:windowIsTranslucent">true</item>
146149
<item name="android:windowAnimationStyle">@null</item>
147150
</style>
148151

152+
<style name="RouterActivityThemeDark" parent="Base.RouterActivityThemeDark" />
153+
149154
</resources>

0 commit comments

Comments
 (0)