Skip to content

Commit e37336e

Browse files
authored
Merge pull request #10918 from Stypox/non-transitive-r
Migrate to non-transitive R classes
2 parents 879d7a2 + f4fb960 commit e37336e

9 files changed

Lines changed: 101 additions & 68 deletions

File tree

app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ErrorUtil {
5454
*/
5555
@JvmStatic
5656
fun showSnackbar(context: Context, errorInfo: ErrorInfo) {
57-
val rootView = if (context is Activity) context.findViewById<View>(R.id.content) else null
57+
val rootView = (context as? Activity)?.findViewById<View>(android.R.id.content)
5858
showSnackbar(context, rootView, errorInfo)
5959
}
6060

@@ -71,7 +71,7 @@ class ErrorUtil {
7171
fun showSnackbar(fragment: Fragment, errorInfo: ErrorInfo) {
7272
var rootView = fragment.view
7373
if (rootView == null && fragment.activity != null) {
74-
rootView = fragment.requireActivity().findViewById(R.id.content)
74+
rootView = fragment.requireActivity().findViewById(android.R.id.content)
7575
}
7676
showSnackbar(fragment.requireContext(), rootView, errorInfo)
7777
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ private void updateTabLayoutPosition() {
245245
// change the background and icon color of the tab layout:
246246
// service-colored at the top, app-background-colored at the bottom
247247
tabLayout.setBackgroundColor(ThemeHelper.resolveColorFromAttr(requireContext(),
248-
bottom ? R.attr.colorSecondary : R.attr.colorPrimary));
248+
bottom ? android.R.attr.windowBackground : R.attr.colorPrimary));
249249

250250
@ColorInt final int iconColor = bottom
251-
? ThemeHelper.resolveColorFromAttr(requireContext(), R.attr.colorAccent)
251+
? ThemeHelper.resolveColorFromAttr(requireContext(), android.R.attr.colorAccent)
252252
: Color.WHITE;
253253
tabLayout.setTabRippleColor(ColorStateList.valueOf(iconColor).withAlpha(32));
254254
tabLayout.setTabIconTint(ColorStateList.valueOf(iconColor));

app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
549549

550550
var typeface = Typeface.DEFAULT
551551
var backgroundSupplier = { ctx: Context ->
552-
resolveDrawable(ctx, R.attr.selectableItemBackground)
552+
resolveDrawable(ctx, android.R.attr.selectableItemBackground)
553553
}
554554
if (doCheck) {
555555
// If the uploadDate is null or true we should highlight the item
@@ -562,7 +562,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
562562
LayerDrawable(
563563
arrayOf(
564564
resolveDrawable(ctx, R.attr.dashed_border),
565-
resolveDrawable(ctx, R.attr.selectableItemBackground)
565+
resolveDrawable(ctx, android.R.attr.selectableItemBackground)
566566
)
567567
)
568568
}

app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,16 @@ private void onStateChanged(final int state) {
569569
private void onPlayModeChanged(final int repeatMode, final boolean shuffled) {
570570
switch (repeatMode) {
571571
case com.google.android.exoplayer2.Player.REPEAT_MODE_OFF:
572-
queueControlBinding.controlRepeat
573-
.setImageResource(R.drawable.exo_controls_repeat_off);
572+
queueControlBinding.controlRepeat.setImageResource(
573+
com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_off);
574574
break;
575575
case com.google.android.exoplayer2.Player.REPEAT_MODE_ONE:
576-
queueControlBinding.controlRepeat
577-
.setImageResource(R.drawable.exo_controls_repeat_one);
576+
queueControlBinding.controlRepeat.setImageResource(
577+
com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_one);
578578
break;
579579
case com.google.android.exoplayer2.Player.REPEAT_MODE_ALL:
580-
queueControlBinding.controlRepeat
581-
.setImageResource(R.drawable.exo_controls_repeat_all);
580+
queueControlBinding.controlRepeat.setImageResource(
581+
com.google.android.exoplayer2.ui.R.drawable.exo_controls_repeat_all);
582582
break;
583583
}
584584

app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,14 @@ private void changePitchControlMode(final boolean semitones) {
342342
final Map<Boolean, TextView> pitchCtrlModeComponentMapping =
343343
getPitchControlModeComponentMappings();
344344
pitchCtrlModeComponentMapping.forEach((v, textView) -> textView.setBackground(
345-
resolveDrawable(requireContext(), R.attr.selectableItemBackground)));
345+
resolveDrawable(requireContext(), android.R.attr.selectableItemBackground)));
346346

347347
// Mark the selected textview
348348
final TextView textView = pitchCtrlModeComponentMapping.get(semitones);
349349
if (textView != null) {
350350
textView.setBackground(new LayerDrawable(new Drawable[]{
351351
resolveDrawable(requireContext(), R.attr.dashed_border),
352-
resolveDrawable(requireContext(), R.attr.selectableItemBackground)
352+
resolveDrawable(requireContext(), android.R.attr.selectableItemBackground)
353353
}));
354354
}
355355

@@ -415,14 +415,14 @@ private void setStepSizeToUI(final double newStepSize) {
415415
// Bring all textviews into a normal state
416416
final Map<Double, TextView> stepSiteComponentMapping = getStepSizeComponentMappings();
417417
stepSiteComponentMapping.forEach((v, textView) -> textView.setBackground(
418-
resolveDrawable(requireContext(), R.attr.selectableItemBackground)));
418+
resolveDrawable(requireContext(), android.R.attr.selectableItemBackground)));
419419

420420
// Mark the selected textview
421421
final TextView textView = stepSiteComponentMapping.get(newStepSize);
422422
if (textView != null) {
423423
textView.setBackground(new LayerDrawable(new Drawable[]{
424424
resolveDrawable(requireContext(), R.attr.dashed_border),
425-
resolveDrawable(requireContext(), R.attr.selectableItemBackground)
425+
resolveDrawable(requireContext(), android.R.attr.selectableItemBackground)
426426
}));
427427
}
428428

app/src/main/java/org/schabi/newpipe/player/notification/NotificationActionData.java

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,41 +69,48 @@ public static NotificationActionData fromNotificationActionEnum(
6969
switch (selectedAction) {
7070
case NotificationConstants.PREVIOUS:
7171
return new NotificationActionData(ACTION_PLAY_PREVIOUS,
72-
ctx.getString(R.string.exo_controls_previous_description), baseActionIcon);
72+
ctx.getString(com.google.android.exoplayer2.ui.R.string
73+
.exo_controls_previous_description), baseActionIcon);
7374

7475
case NotificationConstants.NEXT:
7576
return new NotificationActionData(ACTION_PLAY_NEXT,
76-
ctx.getString(R.string.exo_controls_next_description), baseActionIcon);
77+
ctx.getString(com.google.android.exoplayer2.ui.R.string
78+
.exo_controls_next_description), baseActionIcon);
7779

7880
case NotificationConstants.REWIND:
7981
return new NotificationActionData(ACTION_FAST_REWIND,
80-
ctx.getString(R.string.exo_controls_rewind_description), baseActionIcon);
82+
ctx.getString(com.google.android.exoplayer2.ui.R.string
83+
.exo_controls_rewind_description), baseActionIcon);
8184

8285
case NotificationConstants.FORWARD:
8386
return new NotificationActionData(ACTION_FAST_FORWARD,
84-
ctx.getString(R.string.exo_controls_fastforward_description),
85-
baseActionIcon);
87+
ctx.getString(com.google.android.exoplayer2.ui.R.string
88+
.exo_controls_fastforward_description), baseActionIcon);
8689

8790
case NotificationConstants.SMART_REWIND_PREVIOUS:
8891
if (player.getPlayQueue() != null && player.getPlayQueue().size() > 1) {
8992
return new NotificationActionData(ACTION_PLAY_PREVIOUS,
90-
ctx.getString(R.string.exo_controls_previous_description),
91-
R.drawable.exo_notification_previous);
93+
ctx.getString(com.google.android.exoplayer2.ui.R.string
94+
.exo_controls_previous_description),
95+
com.google.android.exoplayer2.ui.R.drawable.exo_notification_previous);
9296
} else {
9397
return new NotificationActionData(ACTION_FAST_REWIND,
94-
ctx.getString(R.string.exo_controls_rewind_description),
95-
R.drawable.exo_controls_rewind);
98+
ctx.getString(com.google.android.exoplayer2.ui.R.string
99+
.exo_controls_rewind_description),
100+
com.google.android.exoplayer2.ui.R.drawable.exo_controls_rewind);
96101
}
97102

98103
case NotificationConstants.SMART_FORWARD_NEXT:
99104
if (player.getPlayQueue() != null && player.getPlayQueue().size() > 1) {
100105
return new NotificationActionData(ACTION_PLAY_NEXT,
101-
ctx.getString(R.string.exo_controls_next_description),
102-
R.drawable.exo_notification_next);
106+
ctx.getString(com.google.android.exoplayer2.ui.R.string
107+
.exo_controls_next_description),
108+
com.google.android.exoplayer2.ui.R.drawable.exo_notification_next);
103109
} else {
104110
return new NotificationActionData(ACTION_FAST_FORWARD,
105-
ctx.getString(R.string.exo_controls_fastforward_description),
106-
R.drawable.exo_controls_fastforward);
111+
ctx.getString(com.google.android.exoplayer2.ui.R.string
112+
.exo_controls_fastforward_description),
113+
com.google.android.exoplayer2.ui.R.drawable.exo_controls_fastforward);
107114
}
108115

109116
case NotificationConstants.PLAY_PAUSE_BUFFERING:
@@ -119,45 +126,56 @@ public static NotificationActionData fromNotificationActionEnum(
119126
case NotificationConstants.PLAY_PAUSE:
120127
if (player.getCurrentState() == Player.STATE_COMPLETED) {
121128
return new NotificationActionData(ACTION_PLAY_PAUSE,
122-
ctx.getString(R.string.exo_controls_pause_description),
129+
ctx.getString(com.google.android.exoplayer2.ui.R.string
130+
.exo_controls_pause_description),
123131
R.drawable.ic_replay);
124132
} else if (player.isPlaying()
125133
|| player.getCurrentState() == Player.STATE_PREFLIGHT
126134
|| player.getCurrentState() == Player.STATE_BLOCKED
127135
|| player.getCurrentState() == Player.STATE_BUFFERING) {
128136
return new NotificationActionData(ACTION_PLAY_PAUSE,
129-
ctx.getString(R.string.exo_controls_pause_description),
130-
R.drawable.exo_notification_pause);
137+
ctx.getString(com.google.android.exoplayer2.ui.R.string
138+
.exo_controls_pause_description),
139+
com.google.android.exoplayer2.ui.R.drawable.exo_notification_pause);
131140
} else {
132141
return new NotificationActionData(ACTION_PLAY_PAUSE,
133-
ctx.getString(R.string.exo_controls_play_description),
134-
R.drawable.exo_notification_play);
142+
ctx.getString(com.google.android.exoplayer2.ui.R.string
143+
.exo_controls_play_description),
144+
com.google.android.exoplayer2.ui.R.drawable.exo_notification_play);
135145
}
136146

137147
case NotificationConstants.REPEAT:
138148
if (player.getRepeatMode() == REPEAT_MODE_ALL) {
139149
return new NotificationActionData(ACTION_REPEAT,
140-
ctx.getString(R.string.exo_controls_repeat_all_description),
141-
R.drawable.exo_media_action_repeat_all);
150+
ctx.getString(com.google.android.exoplayer2.ui.R.string
151+
.exo_controls_repeat_all_description),
152+
com.google.android.exoplayer2.ext.mediasession.R.drawable
153+
.exo_media_action_repeat_all);
142154
} else if (player.getRepeatMode() == REPEAT_MODE_ONE) {
143155
return new NotificationActionData(ACTION_REPEAT,
144-
ctx.getString(R.string.exo_controls_repeat_one_description),
145-
R.drawable.exo_media_action_repeat_one);
156+
ctx.getString(com.google.android.exoplayer2.ui.R.string
157+
.exo_controls_repeat_one_description),
158+
com.google.android.exoplayer2.ext.mediasession.R.drawable
159+
.exo_media_action_repeat_one);
146160
} else /* player.getRepeatMode() == REPEAT_MODE_OFF */ {
147161
return new NotificationActionData(ACTION_REPEAT,
148-
ctx.getString(R.string.exo_controls_repeat_off_description),
149-
R.drawable.exo_media_action_repeat_off);
162+
ctx.getString(com.google.android.exoplayer2.ui.R.string
163+
.exo_controls_repeat_off_description),
164+
com.google.android.exoplayer2.ext.mediasession.R.drawable
165+
.exo_media_action_repeat_off);
150166
}
151167

152168
case NotificationConstants.SHUFFLE:
153169
if (player.getPlayQueue() != null && player.getPlayQueue().isShuffled()) {
154170
return new NotificationActionData(ACTION_SHUFFLE,
155-
ctx.getString(R.string.exo_controls_shuffle_on_description),
156-
R.drawable.exo_controls_shuffle_on);
171+
ctx.getString(com.google.android.exoplayer2.ui.R.string
172+
.exo_controls_shuffle_on_description),
173+
com.google.android.exoplayer2.ui.R.drawable.exo_controls_shuffle_on);
157174
} else {
158175
return new NotificationActionData(ACTION_SHUFFLE,
159-
ctx.getString(R.string.exo_controls_shuffle_off_description),
160-
R.drawable.exo_controls_shuffle_off);
176+
ctx.getString(com.google.android.exoplayer2.ui.R.string
177+
.exo_controls_shuffle_off_description),
178+
com.google.android.exoplayer2.ui.R.drawable.exo_controls_shuffle_off);
161179
}
162180

163181
case NotificationConstants.CLOSE:

app/src/main/java/org/schabi/newpipe/player/notification/NotificationConstants.java

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ private NotificationConstants() {
7878
@DrawableRes
7979
public static final int[] ACTION_ICONS = {
8080
0,
81-
R.drawable.exo_icon_previous,
82-
R.drawable.exo_icon_next,
83-
R.drawable.exo_icon_rewind,
84-
R.drawable.exo_icon_fastforward,
85-
R.drawable.exo_icon_previous,
86-
R.drawable.exo_icon_next,
81+
com.google.android.exoplayer2.ui.R.drawable.exo_icon_previous,
82+
com.google.android.exoplayer2.ui.R.drawable.exo_icon_next,
83+
com.google.android.exoplayer2.ui.R.drawable.exo_icon_rewind,
84+
com.google.android.exoplayer2.ui.R.drawable.exo_icon_fastforward,
85+
com.google.android.exoplayer2.ui.R.drawable.exo_icon_previous,
86+
com.google.android.exoplayer2.ui.R.drawable.exo_icon_next,
8787
R.drawable.ic_pause,
8888
R.drawable.ic_hourglass_top,
89-
R.drawable.exo_icon_repeat_all,
90-
R.drawable.exo_icon_shuffle_on,
89+
com.google.android.exoplayer2.ui.R.drawable.exo_icon_repeat_all,
90+
com.google.android.exoplayer2.ui.R.drawable.exo_icon_shuffle_on,
9191
R.drawable.ic_close,
9292
};
9393

@@ -122,29 +122,41 @@ private NotificationConstants() {
122122
public static String getActionName(@NonNull final Context context, @Action final int action) {
123123
switch (action) {
124124
case PREVIOUS:
125-
return context.getString(R.string.exo_controls_previous_description);
125+
return context.getString(com.google.android.exoplayer2.ui.R.string
126+
.exo_controls_previous_description);
126127
case NEXT:
127-
return context.getString(R.string.exo_controls_next_description);
128+
return context.getString(com.google.android.exoplayer2.ui.R.string
129+
.exo_controls_next_description);
128130
case REWIND:
129-
return context.getString(R.string.exo_controls_rewind_description);
131+
return context.getString(com.google.android.exoplayer2.ui.R.string
132+
.exo_controls_rewind_description);
130133
case FORWARD:
131-
return context.getString(R.string.exo_controls_fastforward_description);
134+
return context.getString(com.google.android.exoplayer2.ui.R.string
135+
.exo_controls_fastforward_description);
132136
case SMART_REWIND_PREVIOUS:
133137
return Localization.concatenateStrings(
134-
context.getString(R.string.exo_controls_rewind_description),
135-
context.getString(R.string.exo_controls_previous_description));
138+
context.getString(com.google.android.exoplayer2.ui.R.string
139+
.exo_controls_rewind_description),
140+
context.getString(com.google.android.exoplayer2.ui.R.string
141+
.exo_controls_previous_description));
136142
case SMART_FORWARD_NEXT:
137143
return Localization.concatenateStrings(
138-
context.getString(R.string.exo_controls_fastforward_description),
139-
context.getString(R.string.exo_controls_next_description));
144+
context.getString(com.google.android.exoplayer2.ui.R.string
145+
.exo_controls_fastforward_description),
146+
context.getString(com.google.android.exoplayer2.ui.R.string
147+
.exo_controls_next_description));
140148
case PLAY_PAUSE:
141149
return Localization.concatenateStrings(
142-
context.getString(R.string.exo_controls_play_description),
143-
context.getString(R.string.exo_controls_pause_description));
150+
context.getString(com.google.android.exoplayer2.ui.R.string
151+
.exo_controls_play_description),
152+
context.getString(com.google.android.exoplayer2.ui.R.string
153+
.exo_controls_pause_description));
144154
case PLAY_PAUSE_BUFFERING:
145155
return Localization.concatenateStrings(
146-
context.getString(R.string.exo_controls_play_description),
147-
context.getString(R.string.exo_controls_pause_description),
156+
context.getString(com.google.android.exoplayer2.ui.R.string
157+
.exo_controls_play_description),
158+
context.getString(com.google.android.exoplayer2.ui.R.string
159+
.exo_controls_pause_description),
148160
context.getString(R.string.notification_action_buffering));
149161
case REPEAT:
150162
return context.getString(R.string.notification_action_repeat);

0 commit comments

Comments
 (0)