Merge pull request #5927 from krlvm/daynight
Migrate to Android DayNight Theme, fix Light Theme, minor UI improvements
|
@ -6,50 +6,50 @@
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.VideoAudioSettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.VideoAudioSettingsFragment"
|
||||||
android:icon="?attr/ic_headset"
|
android:icon="@drawable/ic_headset"
|
||||||
android:title="@string/settings_category_video_audio_title"
|
android:title="@string/settings_category_video_audio_title"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.DownloadSettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.DownloadSettingsFragment"
|
||||||
android:icon="?attr/ic_file_download"
|
android:icon="@drawable/ic_file_download"
|
||||||
android:title="@string/settings_category_downloads_title"
|
android:title="@string/settings_category_downloads_title"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.AppearanceSettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.AppearanceSettingsFragment"
|
||||||
android:icon="?attr/ic_palette"
|
android:icon="@drawable/ic_palette"
|
||||||
android:title="@string/settings_category_appearance_title"
|
android:title="@string/settings_category_appearance_title"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.HistorySettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.HistorySettingsFragment"
|
||||||
android:icon="?attr/ic_history"
|
android:icon="@drawable/ic_history"
|
||||||
android:title="@string/settings_category_history_title"
|
android:title="@string/settings_category_history_title"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.ContentSettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.ContentSettingsFragment"
|
||||||
android:icon="?attr/ic_language"
|
android:icon="@drawable/ic_language"
|
||||||
android:title="@string/content"
|
android:title="@string/content"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.NotificationSettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.NotificationSettingsFragment"
|
||||||
android:icon="?attr/ic_play_arrow"
|
android:icon="@drawable/ic_play_arrow"
|
||||||
android:title="@string/settings_category_notification_title"
|
android:title="@string/settings_category_notification_title"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.UpdateSettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.UpdateSettingsFragment"
|
||||||
android:icon="?attr/ic_settings_update"
|
android:icon="@drawable/ic_cloud_download"
|
||||||
android:key="update_pref_screen_key"
|
android:key="update_pref_screen_key"
|
||||||
android:title="@string/settings_category_updates_title"
|
android:title="@string/settings_category_updates_title"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.schabi.newpipe.settings.DebugSettingsFragment"
|
android:fragment="org.schabi.newpipe.settings.DebugSettingsFragment"
|
||||||
android:icon="?attr/ic_bug_report"
|
android:icon="@drawable/ic_bug_report"
|
||||||
android:key="@string/debug_pref_screen_key"
|
android:key="@string/debug_pref_screen_key"
|
||||||
android:title="@string/settings_category_debug_title"
|
android:title="@string/settings_category_debug_title"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
|
@ -133,6 +133,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
||||||
TLSSocketFactoryCompat.setAsDefault();
|
TLSSocketFactoryCompat.setAsDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThemeHelper.setDayNightMode(this);
|
||||||
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
|
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
|
||||||
|
|
||||||
assureCorrectAppLanguage(this);
|
assureCorrectAppLanguage(this);
|
||||||
|
@ -180,27 +182,27 @@ public class MainActivity extends AppCompatActivity {
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_SUBSCRIPTIONS, ORDER,
|
.add(R.id.menu_tabs_group, ITEM_ID_SUBSCRIPTIONS, ORDER,
|
||||||
R.string.tab_subscriptions)
|
R.string.tab_subscriptions)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_channel));
|
.setIcon(R.drawable.ic_tv);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_FEED, ORDER, R.string.fragment_feed_title)
|
.add(R.id.menu_tabs_group, ITEM_ID_FEED, ORDER, R.string.fragment_feed_title)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_rss));
|
.setIcon(R.drawable.ic_rss_feed);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_BOOKMARKS, ORDER, R.string.tab_bookmarks)
|
.add(R.id.menu_tabs_group, ITEM_ID_BOOKMARKS, ORDER, R.string.tab_bookmarks)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_bookmark));
|
.setIcon(R.drawable.ic_bookmark);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_DOWNLOADS, ORDER, R.string.downloads)
|
.add(R.id.menu_tabs_group, ITEM_ID_DOWNLOADS, ORDER, R.string.downloads)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_file_download));
|
.setIcon(R.drawable.ic_file_download);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_HISTORY, ORDER, R.string.action_history)
|
.add(R.id.menu_tabs_group, ITEM_ID_HISTORY, ORDER, R.string.action_history)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_history));
|
.setIcon(R.drawable.ic_history);
|
||||||
|
|
||||||
//Settings and About
|
//Settings and About
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_options_about_group, ITEM_ID_SETTINGS, ORDER, R.string.settings)
|
.add(R.id.menu_options_about_group, ITEM_ID_SETTINGS, ORDER, R.string.settings)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_settings));
|
.setIcon(R.drawable.ic_settings);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_options_about_group, ITEM_ID_ABOUT, ORDER, R.string.tab_about)
|
.add(R.id.menu_options_about_group, ITEM_ID_ABOUT, ORDER, R.string.tab_about)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_info_outline));
|
.setIcon(R.drawable.ic_info_outline);
|
||||||
|
|
||||||
toggle = new ActionBarDrawerToggle(this, mainBinding.getRoot(),
|
toggle = new ActionBarDrawerToggle(this, mainBinding.getRoot(),
|
||||||
toolbarLayoutBinding.toolbar, R.string.drawer_open, R.string.drawer_close);
|
toolbarLayoutBinding.toolbar, R.string.drawer_open, R.string.drawer_close);
|
||||||
|
@ -346,7 +348,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showServices() {
|
private void showServices() {
|
||||||
drawerHeaderBinding.drawerArrow.setImageResource(R.drawable.ic_arrow_drop_up_white_24dp);
|
drawerHeaderBinding.drawerArrow.setImageResource(R.drawable.ic_arrow_drop_up);
|
||||||
|
|
||||||
for (final StreamingService s : NewPipe.getServices()) {
|
for (final StreamingService s : NewPipe.getServices()) {
|
||||||
final String title = s.getServiceInfo().getName()
|
final String title = s.getServiceInfo().getName()
|
||||||
|
@ -412,7 +414,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showTabs() throws ExtractionException {
|
private void showTabs() throws ExtractionException {
|
||||||
drawerHeaderBinding.drawerArrow.setImageResource(R.drawable.ic_arrow_drop_down_white_24dp);
|
drawerHeaderBinding.drawerArrow.setImageResource(R.drawable.ic_arrow_drop_down);
|
||||||
|
|
||||||
//Tabs
|
//Tabs
|
||||||
final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
|
final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
|
||||||
|
@ -430,27 +432,27 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_SUBSCRIPTIONS, ORDER, R.string.tab_subscriptions)
|
.add(R.id.menu_tabs_group, ITEM_ID_SUBSCRIPTIONS, ORDER, R.string.tab_subscriptions)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_channel));
|
.setIcon(R.drawable.ic_tv);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_FEED, ORDER, R.string.fragment_feed_title)
|
.add(R.id.menu_tabs_group, ITEM_ID_FEED, ORDER, R.string.fragment_feed_title)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_rss));
|
.setIcon(R.drawable.ic_rss_feed);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_BOOKMARKS, ORDER, R.string.tab_bookmarks)
|
.add(R.id.menu_tabs_group, ITEM_ID_BOOKMARKS, ORDER, R.string.tab_bookmarks)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_bookmark));
|
.setIcon(R.drawable.ic_bookmark);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_DOWNLOADS, ORDER, R.string.downloads)
|
.add(R.id.menu_tabs_group, ITEM_ID_DOWNLOADS, ORDER, R.string.downloads)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_file_download));
|
.setIcon(R.drawable.ic_file_download);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, ITEM_ID_HISTORY, ORDER, R.string.action_history)
|
.add(R.id.menu_tabs_group, ITEM_ID_HISTORY, ORDER, R.string.action_history)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_history));
|
.setIcon(R.drawable.ic_history);
|
||||||
|
|
||||||
//Settings and About
|
//Settings and About
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_options_about_group, ITEM_ID_SETTINGS, ORDER, R.string.settings)
|
.add(R.id.menu_options_about_group, ITEM_ID_SETTINGS, ORDER, R.string.settings)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_settings));
|
.setIcon(R.drawable.ic_settings);
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_options_about_group, ITEM_ID_ABOUT, ORDER, R.string.tab_about)
|
.add(R.id.menu_options_about_group, ITEM_ID_ABOUT, ORDER, R.string.tab_about)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_info_outline));
|
.setIcon(R.drawable.ic_info_outline);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -91,7 +91,6 @@ import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
|
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
|
||||||
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
|
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
|
||||||
import static org.schabi.newpipe.util.ThemeHelper.resolveResourceIdFromAttr;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the url from the intent and open it in the chosen preferred player.
|
* Get the url from the intent and open it in the chosen preferred player.
|
||||||
|
@ -231,7 +230,7 @@ public class RouterActivity extends AppCompatActivity {
|
||||||
new AlertDialog.Builder(context)
|
new AlertDialog.Builder(context)
|
||||||
.setTitle(R.string.unsupported_url)
|
.setTitle(R.string.unsupported_url)
|
||||||
.setMessage(R.string.unsupported_url_dialog_message)
|
.setMessage(R.string.unsupported_url_dialog_message)
|
||||||
.setIcon(ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_share))
|
.setIcon(R.drawable.ic_share)
|
||||||
.setPositiveButton(R.string.open_in_browser,
|
.setPositiveButton(R.string.open_in_browser,
|
||||||
(dialog, which) -> ShareUtils.openUrlInBrowser(this, url))
|
(dialog, which) -> ShareUtils.openUrlInBrowser(this, url))
|
||||||
.setNegativeButton(R.string.share,
|
.setNegativeButton(R.string.share,
|
||||||
|
@ -427,16 +426,16 @@ public class RouterActivity extends AppCompatActivity {
|
||||||
|
|
||||||
final AdapterChoiceItem videoPlayer = new AdapterChoiceItem(
|
final AdapterChoiceItem videoPlayer = new AdapterChoiceItem(
|
||||||
getString(R.string.video_player_key), getString(R.string.video_player),
|
getString(R.string.video_player_key), getString(R.string.video_player),
|
||||||
resolveResourceIdFromAttr(context, R.attr.ic_play_arrow));
|
R.drawable.ic_play_arrow);
|
||||||
final AdapterChoiceItem showInfo = new AdapterChoiceItem(
|
final AdapterChoiceItem showInfo = new AdapterChoiceItem(
|
||||||
getString(R.string.show_info_key), getString(R.string.show_info),
|
getString(R.string.show_info_key), getString(R.string.show_info),
|
||||||
resolveResourceIdFromAttr(context, R.attr.ic_info_outline));
|
R.drawable.ic_info_outline);
|
||||||
final AdapterChoiceItem popupPlayer = new AdapterChoiceItem(
|
final AdapterChoiceItem popupPlayer = new AdapterChoiceItem(
|
||||||
getString(R.string.popup_player_key), getString(R.string.popup_player),
|
getString(R.string.popup_player_key), getString(R.string.popup_player),
|
||||||
resolveResourceIdFromAttr(context, R.attr.ic_popup));
|
R.drawable.ic_picture_in_picture);
|
||||||
final AdapterChoiceItem backgroundPlayer = new AdapterChoiceItem(
|
final AdapterChoiceItem backgroundPlayer = new AdapterChoiceItem(
|
||||||
getString(R.string.background_player_key), getString(R.string.background_player),
|
getString(R.string.background_player_key), getString(R.string.background_player),
|
||||||
resolveResourceIdFromAttr(context, R.attr.ic_headset));
|
R.drawable.ic_headset);
|
||||||
|
|
||||||
if (linkType == LinkType.STREAM) {
|
if (linkType == LinkType.STREAM) {
|
||||||
if (isExtVideoEnabled) {
|
if (isExtVideoEnabled) {
|
||||||
|
@ -481,7 +480,7 @@ public class RouterActivity extends AppCompatActivity {
|
||||||
|
|
||||||
returnList.add(new AdapterChoiceItem(getString(R.string.download_key),
|
returnList.add(new AdapterChoiceItem(getString(R.string.download_key),
|
||||||
getString(R.string.download),
|
getString(R.string.download),
|
||||||
resolveResourceIdFromAttr(context, R.attr.ic_file_download)));
|
R.drawable.ic_file_download));
|
||||||
|
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,8 +394,7 @@ public class DownloadDialog extends DialogFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbar.setTitle(R.string.download_dialog_title);
|
toolbar.setTitle(R.string.download_dialog_title);
|
||||||
toolbar.setNavigationIcon(
|
toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
|
||||||
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_arrow_back));
|
|
||||||
toolbar.inflateMenu(R.menu.dialog_url);
|
toolbar.inflateMenu(R.menu.dialog_url);
|
||||||
toolbar.setNavigationOnClickListener(v -> requireDialog().dismiss());
|
toolbar.setNavigationOnClickListener(v -> requireDialog().dismiss());
|
||||||
toolbar.setNavigationContentDescription(R.string.cancel);
|
toolbar.setNavigationContentDescription(R.string.cancel);
|
||||||
|
|
|
@ -137,6 +137,8 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
assureCorrectAppLanguage(this);
|
assureCorrectAppLanguage(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
ThemeHelper.setDayNightMode(this);
|
||||||
ThemeHelper.setTheme(this);
|
ThemeHelper.setTheme(this);
|
||||||
|
|
||||||
activityErrorBinding = ActivityErrorBinding.inflate(getLayoutInflater());
|
activityErrorBinding = ActivityErrorBinding.inflate(getLayoutInflater());
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.schabi.newpipe.fragments;
|
package org.schabi.newpipe.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -30,7 +29,6 @@ import org.schabi.newpipe.settings.tabs.Tab;
|
||||||
import org.schabi.newpipe.settings.tabs.TabsManager;
|
import org.schabi.newpipe.settings.tabs.TabsManager;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.ServiceHelper;
|
import org.schabi.newpipe.util.ServiceHelper;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -87,10 +85,10 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
|
|
||||||
binding = FragmentMainBinding.bind(rootView);
|
binding = FragmentMainBinding.bind(rootView);
|
||||||
|
|
||||||
binding.mainTabLayout.setTabIconTint(ColorStateList.valueOf(
|
|
||||||
ThemeHelper.resolveColorFromAttr(requireContext(), R.attr.colorAccent)));
|
|
||||||
binding.mainTabLayout.setupWithViewPager(binding.pager);
|
binding.mainTabLayout.setupWithViewPager(binding.pager);
|
||||||
binding.mainTabLayout.addOnTabSelectedListener(this);
|
binding.mainTabLayout.addOnTabSelectedListener(this);
|
||||||
|
binding.mainTabLayout.setTabRippleColor(binding.mainTabLayout.getTabRippleColor()
|
||||||
|
.withAlpha(32));
|
||||||
|
|
||||||
setupTabs();
|
setupTabs();
|
||||||
}
|
}
|
||||||
|
|
|
@ -923,21 +923,21 @@ public final class VideoDetailFragment
|
||||||
if (shouldShowComments()) {
|
if (shouldShowComments()) {
|
||||||
pageAdapter.addFragment(
|
pageAdapter.addFragment(
|
||||||
CommentsFragment.getInstance(serviceId, url, title), COMMENTS_TAB_TAG);
|
CommentsFragment.getInstance(serviceId, url, title), COMMENTS_TAB_TAG);
|
||||||
tabIcons.add(R.drawable.ic_comment_white_24dp);
|
tabIcons.add(R.drawable.ic_comment);
|
||||||
tabContentDescriptions.add(R.string.comments_tab_description);
|
tabContentDescriptions.add(R.string.comments_tab_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showRelatedItems && binding.relatedItemsLayout == null) {
|
if (showRelatedItems && binding.relatedItemsLayout == null) {
|
||||||
// temp empty fragment. will be updated in handleResult
|
// temp empty fragment. will be updated in handleResult
|
||||||
pageAdapter.addFragment(new EmptyFragment(false), RELATED_TAB_TAG);
|
pageAdapter.addFragment(new EmptyFragment(false), RELATED_TAB_TAG);
|
||||||
tabIcons.add(R.drawable.ic_art_track_white_24dp);
|
tabIcons.add(R.drawable.ic_art_track);
|
||||||
tabContentDescriptions.add(R.string.related_items_tab_description);
|
tabContentDescriptions.add(R.string.related_items_tab_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showDescription) {
|
if (showDescription) {
|
||||||
// temp empty fragment. will be updated in handleResult
|
// temp empty fragment. will be updated in handleResult
|
||||||
pageAdapter.addFragment(new EmptyFragment(false), DESCRIPTION_TAB_TAG);
|
pageAdapter.addFragment(new EmptyFragment(false), DESCRIPTION_TAB_TAG);
|
||||||
tabIcons.add(R.drawable.ic_description_white_24dp);
|
tabIcons.add(R.drawable.ic_description);
|
||||||
tabContentDescriptions.add(R.string.description_tab_description);
|
tabContentDescriptions.add(R.string.description_tab_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2280,11 +2280,10 @@ public final class VideoDetailFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOverlayPlayPauseImage(final boolean playerIsPlaying) {
|
private void setOverlayPlayPauseImage(final boolean playerIsPlaying) {
|
||||||
final int attr = playerIsPlaying
|
final int drawable = playerIsPlaying
|
||||||
? R.attr.ic_pause
|
? R.drawable.ic_pause
|
||||||
: R.attr.ic_play_arrow;
|
: R.drawable.ic_play_arrow;
|
||||||
binding.overlayPlayPauseButton.setImageResource(
|
binding.overlayPlayPauseButton.setImageResource(drawable);
|
||||||
ThemeHelper.resolveResourceIdFromAttr(activity, attr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOverlayLook(final AppBarLayout appBar,
|
private void setOverlayLook(final AppBarLayout appBar,
|
||||||
|
|
|
@ -61,7 +61,6 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
|
|
||||||
import static org.schabi.newpipe.ktx.ViewUtils.animate;
|
import static org.schabi.newpipe.ktx.ViewUtils.animate;
|
||||||
import static org.schabi.newpipe.ktx.ViewUtils.animateHideRecyclerViewAllowingScrolling;
|
import static org.schabi.newpipe.ktx.ViewUtils.animateHideRecyclerViewAllowingScrolling;
|
||||||
import static org.schabi.newpipe.util.ThemeHelper.resolveResourceIdFromAttr;
|
|
||||||
|
|
||||||
public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
||||||
private CompositeDisposable disposables;
|
private CompositeDisposable disposables;
|
||||||
|
@ -307,7 +306,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
||||||
getResources().getColor(R.color.transparent_background_color));
|
getResources().getColor(R.color.transparent_background_color));
|
||||||
headerBinding.uploaderAvatarView.setImageDrawable(
|
headerBinding.uploaderAvatarView.setImageDrawable(
|
||||||
AppCompatResources.getDrawable(requireContext(),
|
AppCompatResources.getDrawable(requireContext(),
|
||||||
resolveResourceIdFromAttr(requireContext(), R.attr.ic_radio))
|
R.drawable.ic_radio)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
IMAGE_LOADER.displayImage(avatarUrl, headerBinding.uploaderAvatarView,
|
IMAGE_LOADER.displayImage(avatarUrl, headerBinding.uploaderAvatarView,
|
||||||
|
@ -461,13 +460,13 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int iconAttr = playlistEntity == null
|
final int drawable = playlistEntity == null
|
||||||
? R.attr.ic_playlist_add : R.attr.ic_playlist_check;
|
? R.drawable.ic_playlist_add : R.drawable.ic_playlist_add_check;
|
||||||
|
|
||||||
final int titleRes = playlistEntity == null
|
final int titleRes = playlistEntity == null
|
||||||
? R.string.bookmark_playlist : R.string.unbookmark_playlist;
|
? R.string.bookmark_playlist : R.string.unbookmark_playlist;
|
||||||
|
|
||||||
playlistBookmarkButton.setIcon(resolveResourceIdFromAttr(activity, iconAttr));
|
playlistBookmarkButton.setIcon(drawable);
|
||||||
playlistBookmarkButton.setTitle(titleRes);
|
playlistBookmarkButton.setTitle(titleRes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,6 +487,9 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
+ lastSearchedString);
|
+ lastSearchedString);
|
||||||
}
|
}
|
||||||
searchEditText.setText(searchString);
|
searchEditText.setText(searchString);
|
||||||
|
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
searchEditText.setHintTextColor(searchEditText.getTextColors().withAlpha(128));
|
||||||
|
}
|
||||||
|
|
||||||
if (TextUtils.isEmpty(searchString) || TextUtils.isEmpty(searchEditText.getText())) {
|
if (TextUtils.isEmpty(searchString) || TextUtils.isEmpty(searchEditText.getText())) {
|
||||||
searchToolbarContainer.setTranslationX(100);
|
searchToolbarContainer.setTranslationX(100);
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
package org.schabi.newpipe.fragments.list.search;
|
package org.schabi.newpipe.fragments.list.search;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.AttrRes;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
@ -117,16 +115,8 @@ public class SuggestionListAdapter
|
||||||
queryView = rootView.findViewById(R.id.suggestion_search);
|
queryView = rootView.findViewById(R.id.suggestion_search);
|
||||||
insertView = rootView.findViewById(R.id.suggestion_insert);
|
insertView = rootView.findViewById(R.id.suggestion_insert);
|
||||||
|
|
||||||
historyResId = resolveResourceIdFromAttr(rootView.getContext(), R.attr.ic_history);
|
historyResId = R.drawable.ic_history;
|
||||||
searchResId = resolveResourceIdFromAttr(rootView.getContext(), R.attr.ic_search);
|
searchResId = R.drawable.ic_search;
|
||||||
}
|
|
||||||
|
|
||||||
private static int resolveResourceIdFromAttr(final Context context,
|
|
||||||
@AttrRes final int attr) {
|
|
||||||
final TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
|
|
||||||
final int attributeResourceId = a.getResourceId(0, 0);
|
|
||||||
a.recycle();
|
|
||||||
return attributeResourceId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFrom(final SuggestionItem item) {
|
private void updateFrom(final SuggestionItem item) {
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.schabi.newpipe.util.KoreUtil;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.OnClickGesture;
|
import org.schabi.newpipe.util.OnClickGesture;
|
||||||
import org.schabi.newpipe.util.StreamDialogEntry;
|
import org.schabi.newpipe.util.StreamDialogEntry;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -312,14 +311,13 @@ public class StatisticsPlaylistFragment
|
||||||
if (sortMode == StatisticSortMode.LAST_PLAYED) {
|
if (sortMode == StatisticSortMode.LAST_PLAYED) {
|
||||||
sortMode = StatisticSortMode.MOST_PLAYED;
|
sortMode = StatisticSortMode.MOST_PLAYED;
|
||||||
setTitle(getString(R.string.title_most_played));
|
setTitle(getString(R.string.title_most_played));
|
||||||
headerBinding.sortButtonIcon.setImageResource(
|
headerBinding.sortButtonIcon.setImageResource(R.drawable.ic_history);
|
||||||
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_history));
|
|
||||||
headerBinding.sortButtonText.setText(R.string.title_last_played);
|
headerBinding.sortButtonText.setText(R.string.title_last_played);
|
||||||
} else {
|
} else {
|
||||||
sortMode = StatisticSortMode.LAST_PLAYED;
|
sortMode = StatisticSortMode.LAST_PLAYED;
|
||||||
setTitle(getString(R.string.title_last_played));
|
setTitle(getString(R.string.title_last_played));
|
||||||
headerBinding.sortButtonIcon.setImageResource(
|
headerBinding.sortButtonIcon.setImageResource(
|
||||||
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_filter_list));
|
R.drawable.ic_filter_list);
|
||||||
headerBinding.sortButtonText.setText(R.string.title_most_played);
|
headerBinding.sortButtonText.setText(R.string.title_most_played);
|
||||||
}
|
}
|
||||||
startLoading(true);
|
startLoading(true);
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package org.schabi.newpipe.local.subscription
|
package org.schabi.newpipe.local.subscription
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.annotation.AttrRes
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import org.schabi.newpipe.R
|
import org.schabi.newpipe.R
|
||||||
import org.schabi.newpipe.util.ThemeHelper
|
|
||||||
|
|
||||||
enum class FeedGroupIcon(
|
enum class FeedGroupIcon(
|
||||||
/**
|
/**
|
||||||
|
@ -13,51 +10,51 @@ enum class FeedGroupIcon(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attribute that points to a drawable resource. "R.attr" is used here to support multiple themes.
|
* The drawable resource.
|
||||||
*/
|
*/
|
||||||
@AttrRes val drawableResourceAttr: Int
|
@DrawableRes val drawableResource: Int
|
||||||
) {
|
) {
|
||||||
ALL(0, R.attr.ic_asterisk),
|
ALL(0, R.drawable.ic_asterisk),
|
||||||
MUSIC(1, R.attr.ic_music_note),
|
MUSIC(1, R.drawable.ic_music_note),
|
||||||
EDUCATION(2, R.attr.ic_school),
|
EDUCATION(2, R.drawable.ic_school),
|
||||||
FITNESS(3, R.attr.ic_fitness_center),
|
FITNESS(3, R.drawable.ic_fitness_center),
|
||||||
SPACE(4, R.attr.ic_telescope),
|
SPACE(4, R.drawable.ic_telescope),
|
||||||
COMPUTER(5, R.attr.ic_computer),
|
COMPUTER(5, R.drawable.ic_computer),
|
||||||
GAMING(6, R.attr.ic_videogame_asset),
|
GAMING(6, R.drawable.ic_videogame_asset),
|
||||||
SPORTS(7, R.attr.ic_sports),
|
SPORTS(7, R.drawable.ic_directions_bike),
|
||||||
NEWS(8, R.attr.ic_megaphone),
|
NEWS(8, R.drawable.ic_megaphone),
|
||||||
FAVORITES(9, R.attr.ic_heart),
|
FAVORITES(9, R.drawable.ic_favorite),
|
||||||
CAR(10, R.attr.ic_car),
|
CAR(10, R.drawable.ic_directions_car),
|
||||||
MOTORCYCLE(11, R.attr.ic_motorcycle),
|
MOTORCYCLE(11, R.drawable.ic_motorcycle),
|
||||||
TREND(12, R.attr.ic_trending_up),
|
TREND(12, R.drawable.ic_trending_up),
|
||||||
MOVIE(13, R.attr.ic_movie),
|
MOVIE(13, R.drawable.ic_movie),
|
||||||
BACKUP(14, R.attr.ic_backup),
|
BACKUP(14, R.drawable.ic_backup),
|
||||||
ART(15, R.attr.ic_palette),
|
ART(15, R.drawable.ic_palette),
|
||||||
PERSON(16, R.attr.ic_person),
|
PERSON(16, R.drawable.ic_person),
|
||||||
PEOPLE(17, R.attr.ic_people),
|
PEOPLE(17, R.drawable.ic_people),
|
||||||
MONEY(18, R.attr.ic_money),
|
MONEY(18, R.drawable.ic_attach_money),
|
||||||
KIDS(19, R.attr.ic_child_care),
|
KIDS(19, R.drawable.ic_child_care),
|
||||||
FOOD(20, R.attr.ic_fastfood),
|
FOOD(20, R.drawable.ic_fastfood),
|
||||||
SMILE(21, R.attr.ic_smile),
|
SMILE(21, R.drawable.ic_insert_emoticon),
|
||||||
EXPLORE(22, R.attr.ic_explore),
|
EXPLORE(22, R.drawable.ic_explore),
|
||||||
RESTAURANT(23, R.attr.ic_restaurant),
|
RESTAURANT(23, R.drawable.ic_restaurant),
|
||||||
MIC(24, R.attr.ic_mic),
|
MIC(24, R.drawable.ic_mic),
|
||||||
HEADSET(25, R.attr.ic_headset),
|
HEADSET(25, R.drawable.ic_headset),
|
||||||
RADIO(26, R.attr.ic_radio),
|
RADIO(26, R.drawable.ic_radio),
|
||||||
SHOPPING_CART(27, R.attr.ic_shopping_cart),
|
SHOPPING_CART(27, R.drawable.ic_shopping_cart),
|
||||||
WATCH_LATER(28, R.attr.ic_watch_later),
|
WATCH_LATER(28, R.drawable.ic_watch_later),
|
||||||
WORK(29, R.attr.ic_work),
|
WORK(29, R.drawable.ic_work),
|
||||||
HOT(30, R.attr.ic_kiosk_hot),
|
HOT(30, R.drawable.ic_whatshot),
|
||||||
CHANNEL(31, R.attr.ic_channel),
|
CHANNEL(31, R.drawable.ic_tv),
|
||||||
BOOKMARK(32, R.attr.ic_bookmark),
|
BOOKMARK(32, R.drawable.ic_bookmark),
|
||||||
PETS(33, R.attr.ic_pets),
|
PETS(33, R.drawable.ic_pets),
|
||||||
WORLD(34, R.attr.ic_world),
|
WORLD(34, R.drawable.ic_public),
|
||||||
STAR(35, R.attr.ic_stars),
|
STAR(35, R.drawable.ic_stars),
|
||||||
SUN(36, R.attr.ic_sunny),
|
SUN(36, R.drawable.ic_wb_sunny),
|
||||||
RSS(37, R.attr.ic_rss);
|
RSS(37, R.drawable.ic_rss_feed);
|
||||||
|
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
fun getDrawableRes(context: Context): Int {
|
fun getDrawableRes(): Int {
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(context, drawableResourceAttr)
|
return drawableResource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import androidx.fragment.app.DialogFragment;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
|
||||||
|
|
||||||
import icepick.Icepick;
|
import icepick.Icepick;
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
|
@ -41,7 +40,7 @@ public class ImportConfirmationDialog extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
|
public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
|
||||||
assureCorrectAppLanguage(getContext());
|
assureCorrectAppLanguage(getContext());
|
||||||
return new AlertDialog.Builder(getContext(), ThemeHelper.getDialogTheme(getContext()))
|
return new AlertDialog.Builder(getContext())
|
||||||
.setMessage(R.string.import_network_expensive_warning)
|
.setMessage(R.string.import_network_expensive_warning)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
|
|
@ -62,7 +62,6 @@ import org.schabi.newpipe.util.FilePickerActivityHelper
|
||||||
import org.schabi.newpipe.util.NavigationHelper
|
import org.schabi.newpipe.util.NavigationHelper
|
||||||
import org.schabi.newpipe.util.OnClickGesture
|
import org.schabi.newpipe.util.OnClickGesture
|
||||||
import org.schabi.newpipe.util.ShareUtils
|
import org.schabi.newpipe.util.ShareUtils
|
||||||
import org.schabi.newpipe.util.ThemeHelper
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
@ -257,7 +256,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
feedGroupsCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter)
|
feedGroupsCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter)
|
||||||
feedGroupsSortMenuItem = HeaderWithMenuItem(
|
feedGroupsSortMenuItem = HeaderWithMenuItem(
|
||||||
getString(R.string.feed_groups_header_title),
|
getString(R.string.feed_groups_header_title),
|
||||||
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_sort),
|
R.drawable.ic_sort,
|
||||||
menuItemOnClickListener = ::openReorderDialog
|
menuItemOnClickListener = ::openReorderDialog
|
||||||
)
|
)
|
||||||
add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel)))
|
add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel)))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.schabi.newpipe.local.subscription.dialog
|
package org.schabi.newpipe.local.subscription.dialog
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -12,6 +13,7 @@ import androidx.core.content.getSystemService
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.core.widget.ImageViewCompat
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
|
@ -123,6 +125,14 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
|
||||||
_feedGroupCreateBinding = DialogFeedGroupCreateBinding.bind(view)
|
_feedGroupCreateBinding = DialogFeedGroupCreateBinding.bind(view)
|
||||||
_searchLayoutBinding = feedGroupCreateBinding.subscriptionsHeaderSearchContainer
|
_searchLayoutBinding = feedGroupCreateBinding.subscriptionsHeaderSearchContainer
|
||||||
|
|
||||||
|
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
// KitKat doesn't apply container's theme to <include> content
|
||||||
|
val contrastColor = ColorStateList.valueOf(resources.getColor(R.color.contrastColor))
|
||||||
|
searchLayoutBinding.toolbarSearchEditText.setTextColor(contrastColor)
|
||||||
|
searchLayoutBinding.toolbarSearchEditText.setHintTextColor(contrastColor.withAlpha(128))
|
||||||
|
ImageViewCompat.setImageTintList(searchLayoutBinding.toolbarSearchClearIcon, contrastColor)
|
||||||
|
}
|
||||||
|
|
||||||
viewModel = ViewModelProvider(
|
viewModel = ViewModelProvider(
|
||||||
this,
|
this,
|
||||||
FeedGroupDialogViewModel.Factory(
|
FeedGroupDialogViewModel.Factory(
|
||||||
|
@ -306,7 +316,7 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
|
||||||
groupSortOrder = feedGroupEntity?.sortOrder ?: -1
|
groupSortOrder = feedGroupEntity?.sortOrder ?: -1
|
||||||
|
|
||||||
val feedGroupIcon = if (selectedIcon == null) icon else selectedIcon!!
|
val feedGroupIcon = if (selectedIcon == null) icon else selectedIcon!!
|
||||||
feedGroupCreateBinding.iconPreview.setImageResource(feedGroupIcon.getDrawableRes(requireContext()))
|
feedGroupCreateBinding.iconPreview.setImageResource(feedGroupIcon.getDrawableRes())
|
||||||
|
|
||||||
if (feedGroupCreateBinding.groupNameInput.text.isNullOrBlank()) {
|
if (feedGroupCreateBinding.groupNameInput.text.isNullOrBlank()) {
|
||||||
feedGroupCreateBinding.groupNameInput.setText(name)
|
feedGroupCreateBinding.groupNameInput.setText(name)
|
||||||
|
@ -404,7 +414,7 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
|
||||||
|
|
||||||
if (groupId == NO_GROUP_SELECTED) {
|
if (groupId == NO_GROUP_SELECTED) {
|
||||||
val icon = selectedIcon ?: FeedGroupIcon.ALL
|
val icon = selectedIcon ?: FeedGroupIcon.ALL
|
||||||
feedGroupCreateBinding.iconPreview.setImageResource(icon.getDrawableRes(requireContext()))
|
feedGroupCreateBinding.iconPreview.setImageResource(icon.getDrawableRes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ data class FeedGroupCardItem(
|
||||||
|
|
||||||
override fun bind(viewBinding: FeedGroupCardItemBinding, position: Int) {
|
override fun bind(viewBinding: FeedGroupCardItemBinding, position: Int) {
|
||||||
viewBinding.title.text = name
|
viewBinding.title.text = name
|
||||||
viewBinding.icon.setImageResource(icon.getDrawableRes(viewBinding.root.context))
|
viewBinding.icon.setImageResource(icon.getDrawableRes())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initializeViewBinding(view: View) = FeedGroupCardItemBinding.bind(view)
|
override fun initializeViewBinding(view: View) = FeedGroupCardItemBinding.bind(view)
|
||||||
|
|
|
@ -32,7 +32,7 @@ data class FeedGroupReorderItem(
|
||||||
|
|
||||||
override fun bind(viewBinding: FeedGroupReorderItemBinding, position: Int) {
|
override fun bind(viewBinding: FeedGroupReorderItemBinding, position: Int) {
|
||||||
viewBinding.groupName.text = name
|
viewBinding.groupName.text = name
|
||||||
viewBinding.groupIcon.setImageResource(icon.getDrawableRes(viewBinding.root.context))
|
viewBinding.groupIcon.setImageResource(icon.getDrawableRes())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bind(viewHolder: GroupieViewHolder<FeedGroupReorderItemBinding>, position: Int, payloads: MutableList<Any>) {
|
override fun bind(viewHolder: GroupieViewHolder<FeedGroupReorderItemBinding>, position: Int, payloads: MutableList<Any>) {
|
||||||
|
|
|
@ -86,7 +86,7 @@ class FeedImportExportItem(
|
||||||
private fun setupImportFromItems(listHolder: ViewGroup) {
|
private fun setupImportFromItems(listHolder: ViewGroup) {
|
||||||
val previousBackupItem = addItemView(
|
val previousBackupItem = addItemView(
|
||||||
listHolder.context.getString(R.string.previous_export),
|
listHolder.context.getString(R.string.previous_export),
|
||||||
ThemeHelper.resolveResourceIdFromAttr(listHolder.context, R.attr.ic_backup), listHolder
|
R.drawable.ic_backup, listHolder
|
||||||
)
|
)
|
||||||
previousBackupItem.setOnClickListener { onImportPreviousSelected() }
|
previousBackupItem.setOnClickListener { onImportPreviousSelected() }
|
||||||
|
|
||||||
|
@ -115,8 +115,7 @@ class FeedImportExportItem(
|
||||||
private fun setupExportToItems(listHolder: ViewGroup) {
|
private fun setupExportToItems(listHolder: ViewGroup) {
|
||||||
val previousBackupItem = addItemView(
|
val previousBackupItem = addItemView(
|
||||||
listHolder.context.getString(R.string.file),
|
listHolder.context.getString(R.string.file),
|
||||||
ThemeHelper.resolveResourceIdFromAttr(listHolder.context, R.attr.ic_save),
|
R.drawable.ic_save, listHolder
|
||||||
listHolder
|
|
||||||
)
|
)
|
||||||
previousBackupItem.setOnClickListener { onExportSelected() }
|
previousBackupItem.setOnClickListener { onExportSelected() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class PickerIconItem(
|
||||||
val icon: FeedGroupIcon
|
val icon: FeedGroupIcon
|
||||||
) : BindableItem<PickerIconItemBinding>() {
|
) : BindableItem<PickerIconItemBinding>() {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
val iconRes: Int = icon.getDrawableRes(context)
|
val iconRes: Int = icon.getDrawableRes()
|
||||||
|
|
||||||
override fun getLayout(): Int = R.layout.picker_icon_item
|
override fun getLayout(): Int = R.layout.picker_icon_item
|
||||||
|
|
||||||
|
|
|
@ -50,11 +50,11 @@ public final class NotificationConstants {
|
||||||
R.drawable.exo_icon_fastforward,
|
R.drawable.exo_icon_fastforward,
|
||||||
R.drawable.exo_icon_previous,
|
R.drawable.exo_icon_previous,
|
||||||
R.drawable.exo_icon_next,
|
R.drawable.exo_icon_next,
|
||||||
R.drawable.ic_pause_white_24dp,
|
R.drawable.ic_pause,
|
||||||
R.drawable.ic_hourglass_top_white_24dp,
|
R.drawable.ic_hourglass_top,
|
||||||
R.drawable.exo_icon_repeat_all,
|
R.drawable.exo_icon_repeat_all,
|
||||||
R.drawable.exo_icon_shuffle_on,
|
R.drawable.exo_icon_shuffle_on,
|
||||||
R.drawable.ic_close_white_24dp,
|
R.drawable.ic_close,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -273,14 +273,14 @@ public final class NotificationUtil {
|
||||||
|| player.getCurrentState() == Player.STATE_BLOCKED
|
|| player.getCurrentState() == Player.STATE_BLOCKED
|
||||||
|| player.getCurrentState() == Player.STATE_BUFFERING) {
|
|| player.getCurrentState() == Player.STATE_BUFFERING) {
|
||||||
// null intent -> show hourglass icon that does nothing when clicked
|
// null intent -> show hourglass icon that does nothing when clicked
|
||||||
return new NotificationCompat.Action(R.drawable.ic_hourglass_top_white_24dp_png,
|
return new NotificationCompat.Action(R.drawable.ic_hourglass_top,
|
||||||
player.getContext().getString(R.string.notification_action_buffering),
|
player.getContext().getString(R.string.notification_action_buffering),
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
case NotificationConstants.PLAY_PAUSE:
|
case NotificationConstants.PLAY_PAUSE:
|
||||||
if (player.getCurrentState() == Player.STATE_COMPLETED) {
|
if (player.getCurrentState() == Player.STATE_COMPLETED) {
|
||||||
return getAction(player, R.drawable.ic_replay_white_24dp_png,
|
return getAction(player, R.drawable.ic_replay,
|
||||||
R.string.exo_controls_pause_description, ACTION_PLAY_PAUSE);
|
R.string.exo_controls_pause_description, ACTION_PLAY_PAUSE);
|
||||||
} else if (player.isPlaying()
|
} else if (player.isPlaying()
|
||||||
|| player.getCurrentState() == Player.STATE_PREFLIGHT
|
|| player.getCurrentState() == Player.STATE_PREFLIGHT
|
||||||
|
@ -315,7 +315,7 @@ public final class NotificationUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
case NotificationConstants.CLOSE:
|
case NotificationConstants.CLOSE:
|
||||||
return getAction(player, R.drawable.ic_close_white_24dp_png,
|
return getAction(player, R.drawable.ic_close,
|
||||||
R.string.close, ACTION_CLOSE);
|
R.string.close, ACTION_CLOSE);
|
||||||
|
|
||||||
case NotificationConstants.NOTHING:
|
case NotificationConstants.NOTHING:
|
||||||
|
|
|
@ -589,15 +589,15 @@ public final class PlayQueueActivity extends AppCompatActivity
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Player.STATE_PAUSED:
|
case Player.STATE_PAUSED:
|
||||||
queueControlBinding.controlPlayPause
|
queueControlBinding.controlPlayPause
|
||||||
.setImageResource(R.drawable.ic_play_arrow_white_24dp);
|
.setImageResource(R.drawable.ic_play_arrow);
|
||||||
break;
|
break;
|
||||||
case Player.STATE_PLAYING:
|
case Player.STATE_PLAYING:
|
||||||
queueControlBinding.controlPlayPause
|
queueControlBinding.controlPlayPause
|
||||||
.setImageResource(R.drawable.ic_pause_white_24dp);
|
.setImageResource(R.drawable.ic_pause);
|
||||||
break;
|
break;
|
||||||
case Player.STATE_COMPLETED:
|
case Player.STATE_COMPLETED:
|
||||||
queueControlBinding.controlPlayPause
|
queueControlBinding.controlPlayPause
|
||||||
.setImageResource(R.drawable.ic_replay_white_24dp);
|
.setImageResource(R.drawable.ic_replay);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -670,8 +670,7 @@ public final class PlayQueueActivity extends AppCompatActivity
|
||||||
//2) Icon change accordingly to current App Theme
|
//2) Icon change accordingly to current App Theme
|
||||||
// using rootView.getContext() because getApplicationContext() didn't work
|
// using rootView.getContext() because getApplicationContext() didn't work
|
||||||
final Context context = queueControlBinding.getRoot().getContext();
|
final Context context = queueControlBinding.getRoot().getContext();
|
||||||
item.setIcon(ThemeHelper.resolveResourceIdFromAttr(context,
|
item.setIcon(player.isMuted() ? R.drawable.ic_volume_off : R.drawable.ic_volume_up);
|
||||||
player.isMuted() ? R.attr.ic_volume_off : R.attr.ic_volume_up));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.provider.Settings;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -51,6 +52,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageButton;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.view.DisplayCutoutCompat;
|
import androidx.core.view.DisplayCutoutCompat;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
|
@ -447,9 +449,12 @@ public final class Player implements
|
||||||
binding.playbackSeekBar.getProgressDrawable()
|
binding.playbackSeekBar.getProgressDrawable()
|
||||||
.setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY));
|
.setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY));
|
||||||
|
|
||||||
qualityPopupMenu = new PopupMenu(context, binding.qualityTextView);
|
final ContextThemeWrapper themeWrapper = new ContextThemeWrapper(getContext(),
|
||||||
|
R.style.DarkPopupMenu);
|
||||||
|
|
||||||
|
qualityPopupMenu = new PopupMenu(themeWrapper, binding.qualityTextView);
|
||||||
playbackSpeedPopupMenu = new PopupMenu(context, binding.playbackSpeed);
|
playbackSpeedPopupMenu = new PopupMenu(context, binding.playbackSpeed);
|
||||||
captionPopupMenu = new PopupMenu(context, binding.captionTextView);
|
captionPopupMenu = new PopupMenu(themeWrapper, binding.captionTextView);
|
||||||
|
|
||||||
binding.progressBarLoadingPanel.getIndeterminateDrawable()
|
binding.progressBarLoadingPanel.getIndeterminateDrawable()
|
||||||
.setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY));
|
.setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY));
|
||||||
|
@ -956,7 +961,7 @@ public final class Player implements
|
||||||
= LinearLayout.LayoutParams.MATCH_PARENT;
|
= LinearLayout.LayoutParams.MATCH_PARENT;
|
||||||
binding.secondaryControls.setVisibility(View.INVISIBLE);
|
binding.secondaryControls.setVisibility(View.INVISIBLE);
|
||||||
binding.moreOptionsButton.setImageDrawable(AppCompatResources.getDrawable(context,
|
binding.moreOptionsButton.setImageDrawable(AppCompatResources.getDrawable(context,
|
||||||
R.drawable.ic_expand_more_white_24dp));
|
R.drawable.ic_expand_more));
|
||||||
binding.share.setVisibility(View.VISIBLE);
|
binding.share.setVisibility(View.VISIBLE);
|
||||||
binding.openInBrowser.setVisibility(View.VISIBLE);
|
binding.openInBrowser.setVisibility(View.VISIBLE);
|
||||||
binding.switchMute.setVisibility(View.VISIBLE);
|
binding.switchMute.setVisibility(View.VISIBLE);
|
||||||
|
@ -2020,7 +2025,7 @@ public final class Player implements
|
||||||
animate(binding.loadingPanel, true, 0);
|
animate(binding.loadingPanel, true, 0);
|
||||||
animate(binding.surfaceForeground, true, 100);
|
animate(binding.surfaceForeground, true, 100);
|
||||||
|
|
||||||
binding.playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp);
|
binding.playPauseButton.setImageResource(R.drawable.ic_play_arrow);
|
||||||
animatePlayButtons(false, 100);
|
animatePlayButtons(false, 100);
|
||||||
binding.getRoot().setKeepScreenOn(false);
|
binding.getRoot().setKeepScreenOn(false);
|
||||||
|
|
||||||
|
@ -2049,7 +2054,7 @@ public final class Player implements
|
||||||
|
|
||||||
animate(binding.playPauseButton, false, 80, AnimationType.SCALE_AND_ALPHA, 0,
|
animate(binding.playPauseButton, false, 80, AnimationType.SCALE_AND_ALPHA, 0,
|
||||||
() -> {
|
() -> {
|
||||||
binding.playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp);
|
binding.playPauseButton.setImageResource(R.drawable.ic_pause);
|
||||||
animatePlayButtons(true, 200);
|
animatePlayButtons(true, 200);
|
||||||
if (!isQueueVisible) {
|
if (!isQueueVisible) {
|
||||||
binding.playPauseButton.requestFocus();
|
binding.playPauseButton.requestFocus();
|
||||||
|
@ -2090,7 +2095,7 @@ public final class Player implements
|
||||||
|
|
||||||
animate(binding.playPauseButton, false, 80, AnimationType.SCALE_AND_ALPHA, 0,
|
animate(binding.playPauseButton, false, 80, AnimationType.SCALE_AND_ALPHA, 0,
|
||||||
() -> {
|
() -> {
|
||||||
binding.playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp);
|
binding.playPauseButton.setImageResource(R.drawable.ic_play_arrow);
|
||||||
animatePlayButtons(true, 200);
|
animatePlayButtons(true, 200);
|
||||||
if (!isQueueVisible) {
|
if (!isQueueVisible) {
|
||||||
binding.playPauseButton.requestFocus();
|
binding.playPauseButton.requestFocus();
|
||||||
|
@ -2129,7 +2134,7 @@ public final class Player implements
|
||||||
|
|
||||||
animate(binding.playPauseButton, false, 0, AnimationType.SCALE_AND_ALPHA, 0,
|
animate(binding.playPauseButton, false, 0, AnimationType.SCALE_AND_ALPHA, 0,
|
||||||
() -> {
|
() -> {
|
||||||
binding.playPauseButton.setImageResource(R.drawable.ic_replay_white_24dp);
|
binding.playPauseButton.setImageResource(R.drawable.ic_replay);
|
||||||
animatePlayButtons(true, DEFAULT_CONTROLS_DURATION);
|
animatePlayButtons(true, DEFAULT_CONTROLS_DURATION);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2221,7 +2226,7 @@ public final class Player implements
|
||||||
Log.d(TAG, "ExoPlayer - onRepeatModeChanged() called with: "
|
Log.d(TAG, "ExoPlayer - onRepeatModeChanged() called with: "
|
||||||
+ "repeatMode = [" + repeatMode + "]");
|
+ "repeatMode = [" + repeatMode + "]");
|
||||||
}
|
}
|
||||||
setRepeatModeButton(binding.repeatButton, repeatMode);
|
setRepeatModeButton(((AppCompatImageButton) binding.repeatButton), repeatMode);
|
||||||
onShuffleOrRepeatModeChanged();
|
onShuffleOrRepeatModeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2249,7 +2254,7 @@ public final class Player implements
|
||||||
NotificationUtil.getInstance().createNotificationIfNeededAndUpdate(this, false);
|
NotificationUtil.getInstance().createNotificationIfNeededAndUpdate(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRepeatModeButton(final ImageButton imageButton, final int repeatMode) {
|
private void setRepeatModeButton(final AppCompatImageButton imageButton, final int repeatMode) {
|
||||||
switch (repeatMode) {
|
switch (repeatMode) {
|
||||||
case REPEAT_MODE_OFF:
|
case REPEAT_MODE_OFF:
|
||||||
imageButton.setImageResource(R.drawable.exo_controls_repeat_off);
|
imageButton.setImageResource(R.drawable.exo_controls_repeat_off);
|
||||||
|
@ -2290,7 +2295,7 @@ public final class Player implements
|
||||||
|
|
||||||
private void setMuteButton(final ImageButton button, final boolean isMuted) {
|
private void setMuteButton(final ImageButton button, final boolean isMuted) {
|
||||||
button.setImageDrawable(AppCompatResources.getDrawable(context, isMuted
|
button.setImageDrawable(AppCompatResources.getDrawable(context, isMuted
|
||||||
? R.drawable.ic_volume_off_white_24dp : R.drawable.ic_volume_up_white_24dp));
|
? R.drawable.ic_volume_off : R.drawable.ic_volume_up));
|
||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
@ -2728,7 +2733,7 @@ public final class Player implements
|
||||||
}
|
}
|
||||||
seekBy(retrieveSeekDurationFromPreferences(this));
|
seekBy(retrieveSeekDurationFromPreferences(this));
|
||||||
triggerProgressUpdate();
|
triggerProgressUpdate();
|
||||||
showAndAnimateControl(R.drawable.ic_fast_forward_white_24dp, true);
|
showAndAnimateControl(R.drawable.ic_fast_forward, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fastRewind() {
|
public void fastRewind() {
|
||||||
|
@ -2737,7 +2742,7 @@ public final class Player implements
|
||||||
}
|
}
|
||||||
seekBy(-retrieveSeekDurationFromPreferences(this));
|
seekBy(-retrieveSeekDurationFromPreferences(this));
|
||||||
triggerProgressUpdate();
|
triggerProgressUpdate();
|
||||||
showAndAnimateControl(R.drawable.ic_fast_rewind_white_24dp, true);
|
showAndAnimateControl(R.drawable.ic_fast_rewind, true);
|
||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
@ -3685,8 +3690,8 @@ public final class Player implements
|
||||||
|| DeviceUtils.isTablet(context))
|
|| DeviceUtils.isTablet(context))
|
||||||
? View.VISIBLE : View.GONE);
|
? View.VISIBLE : View.GONE);
|
||||||
binding.screenRotationButton.setImageDrawable(AppCompatResources.getDrawable(context,
|
binding.screenRotationButton.setImageDrawable(AppCompatResources.getDrawable(context,
|
||||||
isFullscreen ? R.drawable.ic_fullscreen_exit_white_24dp
|
isFullscreen ? R.drawable.ic_fullscreen_exit
|
||||||
: R.drawable.ic_fullscreen_white_24dp));
|
: R.drawable.ic_fullscreen));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setResizeMode(@AspectRatioFrameLayout.ResizeMode final int resizeMode) {
|
private void setResizeMode(@AspectRatioFrameLayout.ResizeMode final int resizeMode) {
|
||||||
|
|
|
@ -147,10 +147,10 @@ public class PlayerGestureListener
|
||||||
|
|
||||||
player.getVolumeImageView().setImageDrawable(
|
player.getVolumeImageView().setImageDrawable(
|
||||||
AppCompatResources.getDrawable(service, currentProgressPercent <= 0
|
AppCompatResources.getDrawable(service, currentProgressPercent <= 0
|
||||||
? R.drawable.ic_volume_off_white_24dp
|
? R.drawable.ic_volume_off
|
||||||
: currentProgressPercent < 0.25 ? R.drawable.ic_volume_mute_white_24dp
|
: currentProgressPercent < 0.25 ? R.drawable.ic_volume_mute
|
||||||
: currentProgressPercent < 0.75 ? R.drawable.ic_volume_down_white_24dp
|
: currentProgressPercent < 0.75 ? R.drawable.ic_volume_down
|
||||||
: R.drawable.ic_volume_up_white_24dp)
|
: R.drawable.ic_volume_up)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (player.getVolumeRelativeLayout().getVisibility() != View.VISIBLE) {
|
if (player.getVolumeRelativeLayout().getVisibility() != View.VISIBLE) {
|
||||||
|
@ -189,10 +189,10 @@ public class PlayerGestureListener
|
||||||
player.getBrightnessImageView().setImageDrawable(
|
player.getBrightnessImageView().setImageDrawable(
|
||||||
AppCompatResources.getDrawable(service,
|
AppCompatResources.getDrawable(service,
|
||||||
currentProgressPercent < 0.25
|
currentProgressPercent < 0.25
|
||||||
? R.drawable.ic_brightness_low_white_24dp
|
? R.drawable.ic_brightness_low
|
||||||
: currentProgressPercent < 0.75
|
: currentProgressPercent < 0.75
|
||||||
? R.drawable.ic_brightness_medium_white_24dp
|
? R.drawable.ic_brightness_medium
|
||||||
: R.drawable.ic_brightness_high_white_24dp)
|
: R.drawable.ic_brightness_high)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (player.getBrightnessRelativeLayout().getVisibility() != View.VISIBLE) {
|
if (player.getBrightnessRelativeLayout().getVisibility() != View.VISIBLE) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import androidx.preference.Preference;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.util.Constants;
|
import org.schabi.newpipe.util.Constants;
|
||||||
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
||||||
private static final boolean CAPTIONING_SETTINGS_ACCESSIBLE =
|
private static final boolean CAPTIONING_SETTINGS_ACCESSIBLE =
|
||||||
|
@ -83,6 +84,8 @@ public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
||||||
defaultPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, true).apply();
|
defaultPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, true).apply();
|
||||||
defaultPreferences.edit().putString(themeKey, newValue.toString()).apply();
|
defaultPreferences.edit().putString(themeKey, newValue.toString()).apply();
|
||||||
|
|
||||||
|
ThemeHelper.setDayNightMode(getContext(), newValue.toString());
|
||||||
|
|
||||||
if (!newValue.equals(beginningThemeKey) && getActivity() != null) {
|
if (!newValue.equals(beginningThemeKey) && getActivity() != null) {
|
||||||
// if it's not the current theme
|
// if it's not the current theme
|
||||||
ActivityCompat.recreate(getActivity());
|
ActivityCompat.recreate(getActivity());
|
||||||
|
|
|
@ -145,10 +145,8 @@ public class PeertubeInstanceListFragment extends Fragment {
|
||||||
final MenuItem restoreItem = menu
|
final MenuItem restoreItem = menu
|
||||||
.add(Menu.NONE, MENU_ITEM_RESTORE_ID, Menu.NONE, R.string.restore_defaults);
|
.add(Menu.NONE, MENU_ITEM_RESTORE_ID, Menu.NONE, R.string.restore_defaults);
|
||||||
restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
|
restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(),
|
||||||
final int restoreIcon = ThemeHelper
|
R.drawable.ic_settings_backup_restore));
|
||||||
.resolveResourceIdFromAttr(requireContext(), R.attr.ic_restore_defaults);
|
|
||||||
restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(), restoreIcon));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -188,7 +186,7 @@ public class PeertubeInstanceListFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreDefaults() {
|
private void restoreDefaults() {
|
||||||
new AlertDialog.Builder(requireContext(), ThemeHelper.getDialogTheme(requireContext()))
|
new AlertDialog.Builder(requireContext())
|
||||||
.setTitle(R.string.restore_defaults)
|
.setTitle(R.string.restore_defaults)
|
||||||
.setMessage(R.string.restore_defaults_confirmation)
|
.setMessage(R.string.restore_defaults_confirmation)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
|
|
@ -14,7 +14,6 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
|
||||||
|
|
||||||
public final class AddTabDialog {
|
public final class AddTabDialog {
|
||||||
private final AlertDialog dialog;
|
private final AlertDialog dialog;
|
||||||
|
@ -60,7 +59,7 @@ public final class AddTabDialog {
|
||||||
private DialogListAdapter(final Context context, final ChooseTabListItem[] items) {
|
private DialogListAdapter(final Context context, final ChooseTabListItem[] items) {
|
||||||
this.inflater = LayoutInflater.from(context);
|
this.inflater = LayoutInflater.from(context);
|
||||||
this.items = items;
|
this.items = items;
|
||||||
this.fallbackIcon = ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_kiosk_hot);
|
this.fallbackIcon = R.drawable.ic_whatshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -112,10 +112,8 @@ public class ChooseTabsFragment extends Fragment {
|
||||||
final MenuItem restoreItem = menu.add(Menu.NONE, MENU_ITEM_RESTORE_ID, Menu.NONE,
|
final MenuItem restoreItem = menu.add(Menu.NONE, MENU_ITEM_RESTORE_ID, Menu.NONE,
|
||||||
R.string.restore_defaults);
|
R.string.restore_defaults);
|
||||||
restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
|
restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(),
|
||||||
final int restoreIcon = ThemeHelper.resolveResourceIdFromAttr(requireContext(),
|
R.drawable.ic_settings_backup_restore));
|
||||||
R.attr.ic_restore_defaults);
|
|
||||||
restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(), restoreIcon));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,7 +140,7 @@ public class ChooseTabsFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreDefaults() {
|
private void restoreDefaults() {
|
||||||
new AlertDialog.Builder(requireContext(), ThemeHelper.getDialogTheme(requireContext()))
|
new AlertDialog.Builder(requireContext())
|
||||||
.setTitle(R.string.restore_defaults)
|
.setTitle(R.string.restore_defaults)
|
||||||
.setMessage(R.string.restore_defaults_confirmation)
|
.setMessage(R.string.restore_defaults_confirmation)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
@ -241,7 +239,7 @@ public class ChooseTabsFragment extends Fragment {
|
||||||
case KIOSK:
|
case KIOSK:
|
||||||
returnList.add(new ChooseTabListItem(tab.getTabId(),
|
returnList.add(new ChooseTabListItem(tab.getTabId(),
|
||||||
getString(R.string.kiosk_page_summary),
|
getString(R.string.kiosk_page_summary),
|
||||||
ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_kiosk_hot)));
|
R.drawable.ic_whatshot));
|
||||||
break;
|
break;
|
||||||
case CHANNEL:
|
case CHANNEL:
|
||||||
returnList.add(new ChooseTabListItem(tab.getTabId(),
|
returnList.add(new ChooseTabListItem(tab.getTabId(),
|
||||||
|
@ -252,8 +250,7 @@ public class ChooseTabsFragment extends Fragment {
|
||||||
if (!tabList.contains(tab)) {
|
if (!tabList.contains(tab)) {
|
||||||
returnList.add(new ChooseTabListItem(tab.getTabId(),
|
returnList.add(new ChooseTabListItem(tab.getTabId(),
|
||||||
getString(R.string.default_kiosk_page_summary),
|
getString(R.string.default_kiosk_page_summary),
|
||||||
ThemeHelper.resolveResourceIdFromAttr(context,
|
R.drawable.ic_whatshot));
|
||||||
R.attr.ic_kiosk_hot)));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PLAYLIST:
|
case PLAYLIST:
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.schabi.newpipe.local.playlist.LocalPlaylistFragment;
|
||||||
import org.schabi.newpipe.local.subscription.SubscriptionFragment;
|
import org.schabi.newpipe.local.subscription.SubscriptionFragment;
|
||||||
import org.schabi.newpipe.util.KioskTranslator;
|
import org.schabi.newpipe.util.KioskTranslator;
|
||||||
import org.schabi.newpipe.util.ServiceHelper;
|
import org.schabi.newpipe.util.ServiceHelper;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -188,7 +187,7 @@ public abstract class Tab {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
@Override
|
@Override
|
||||||
public int getTabIconRes(final Context context) {
|
public int getTabIconRes(final Context context) {
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_blank_page);
|
return R.drawable.ic_crop_portrait;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -213,7 +212,7 @@ public abstract class Tab {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
@Override
|
@Override
|
||||||
public int getTabIconRes(final Context context) {
|
public int getTabIconRes(final Context context) {
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_channel);
|
return R.drawable.ic_tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -239,7 +238,7 @@ public abstract class Tab {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
@Override
|
@Override
|
||||||
public int getTabIconRes(final Context context) {
|
public int getTabIconRes(final Context context) {
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_rss);
|
return R.drawable.ic_rss_feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -264,7 +263,7 @@ public abstract class Tab {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
@Override
|
@Override
|
||||||
public int getTabIconRes(final Context context) {
|
public int getTabIconRes(final Context context) {
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_bookmark);
|
return R.drawable.ic_bookmark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -289,7 +288,7 @@ public abstract class Tab {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
@Override
|
@Override
|
||||||
public int getTabIconRes(final Context context) {
|
public int getTabIconRes(final Context context) {
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_history);
|
return R.drawable.ic_history;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -409,7 +408,7 @@ public abstract class Tab {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
@Override
|
@Override
|
||||||
public int getTabIconRes(final Context context) {
|
public int getTabIconRes(final Context context) {
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_channel);
|
return R.drawable.ic_tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -541,7 +540,7 @@ public abstract class Tab {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
@Override
|
@Override
|
||||||
public int getTabIconRes(final Context context) {
|
public int getTabIconRes(final Context context) {
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(context, R.attr.ic_bookmark);
|
return R.drawable.ic_bookmark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -63,20 +63,20 @@ public final class KioskTranslator {
|
||||||
case "Top 50":
|
case "Top 50":
|
||||||
case "New & hot":
|
case "New & hot":
|
||||||
case "conferences":
|
case "conferences":
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_kiosk_hot);
|
return R.drawable.ic_whatshot;
|
||||||
case "Local":
|
case "Local":
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_kiosk_local);
|
return R.drawable.ic_home;
|
||||||
case "Recently added":
|
case "Recently added":
|
||||||
case "recent":
|
case "recent":
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_kiosk_recent);
|
return R.drawable.ic_add_circle_outline;
|
||||||
case "Most liked":
|
case "Most liked":
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_thumb_up);
|
return R.drawable.ic_thumb_up;
|
||||||
case "live":
|
case "live":
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_live_tv);
|
return R.drawable.ic_live_tv;
|
||||||
case "Featured":
|
case "Featured":
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_stars);
|
return R.drawable.ic_stars;
|
||||||
case "Radio":
|
case "Radio":
|
||||||
return ThemeHelper.resolveResourceIdFromAttr(c, R.attr.ic_radio);
|
return R.drawable.ic_radio;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
|
||||||
import androidx.annotation.AttrRes;
|
import androidx.annotation.AttrRes;
|
||||||
|
@ -31,6 +30,7 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.StyleRes;
|
import androidx.annotation.StyleRes;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
|
@ -47,6 +47,9 @@ public final class ThemeHelper {
|
||||||
* Apply the selected theme (on NewPipe settings) in the context
|
* Apply the selected theme (on NewPipe settings) in the context
|
||||||
* with the default style (see {@link #setTheme(Context, int)}).
|
* with the default style (see {@link #setTheme(Context, int)}).
|
||||||
*
|
*
|
||||||
|
* ThemeHelper.setDayNightMode should be called before
|
||||||
|
* the applying theme for the first time in session
|
||||||
|
*
|
||||||
* @param context context that the theme will be applied
|
* @param context context that the theme will be applied
|
||||||
*/
|
*/
|
||||||
public static void setTheme(final Context context) {
|
public static void setTheme(final Context context) {
|
||||||
|
@ -57,6 +60,9 @@ public final class ThemeHelper {
|
||||||
* Apply the selected theme (on NewPipe settings) in the context,
|
* Apply the selected theme (on NewPipe settings) in the context,
|
||||||
* themed according with the styles defined for the service .
|
* themed according with the styles defined for the service .
|
||||||
*
|
*
|
||||||
|
* ThemeHelper.setDayNightMode should be called before
|
||||||
|
* the applying theme for the first time in session
|
||||||
|
*
|
||||||
* @param context context that the theme will be applied
|
* @param context context that the theme will be applied
|
||||||
* @param serviceId the theme will be styled to the service with this id,
|
* @param serviceId the theme will be styled to the service with this id,
|
||||||
* pass -1 to get the default style
|
* pass -1 to get the default style
|
||||||
|
@ -120,6 +126,7 @@ public final class ThemeHelper {
|
||||||
|
|
||||||
final String selectedThemeKey = getSelectedThemeKey(context);
|
final String selectedThemeKey = getSelectedThemeKey(context);
|
||||||
|
|
||||||
|
|
||||||
int baseTheme = R.style.DarkTheme; // default to dark theme
|
int baseTheme = R.style.DarkTheme; // default to dark theme
|
||||||
if (selectedThemeKey.equals(lightThemeKey)) {
|
if (selectedThemeKey.equals(lightThemeKey)) {
|
||||||
baseTheme = R.style.LightTheme;
|
baseTheme = R.style.LightTheme;
|
||||||
|
@ -202,20 +209,6 @@ public final class ThemeHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a resource id from a resource styled according to the context's theme.
|
|
||||||
*
|
|
||||||
* @param context Android app context
|
|
||||||
* @param attr attribute reference of the resource
|
|
||||||
* @return resource ID
|
|
||||||
*/
|
|
||||||
public static int resolveResourceIdFromAttr(final Context context, @AttrRes final int attr) {
|
|
||||||
final TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
|
|
||||||
final int attributeResourceId = a.getResourceId(0, 0);
|
|
||||||
a.recycle();
|
|
||||||
return attributeResourceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a color from an attr styled according to the context's theme.
|
* Get a color from an attr styled according to the context's theme.
|
||||||
*
|
*
|
||||||
|
@ -288,4 +281,21 @@ public final class ThemeHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setDayNightMode(final Context context) {
|
||||||
|
setDayNightMode(context, ThemeHelper.getSelectedThemeKey(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDayNightMode(final Context context, final String selectedThemeKey) {
|
||||||
|
final Resources res = context.getResources();
|
||||||
|
|
||||||
|
if (selectedThemeKey.equals(res.getString(R.string.light_theme_key))) {
|
||||||
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||||
|
} else if (selectedThemeKey.equals(res.getString(R.string.dark_theme_key))
|
||||||
|
|| selectedThemeKey.equals(res.getString(R.string.black_theme_key))) {
|
||||||
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||||
|
} else {
|
||||||
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,10 +224,9 @@ public class MissionsFragment extends Fragment {
|
||||||
mList.setAdapter(mAdapter);
|
mList.setAdapter(mAdapter);
|
||||||
|
|
||||||
if (mSwitch != null) {
|
if (mSwitch != null) {
|
||||||
mSwitch.setIcon(ThemeHelper.resolveResourceIdFromAttr(
|
mSwitch.setIcon(mLinear
|
||||||
requireContext(), mLinear
|
? R.drawable.ic_apps
|
||||||
? R.attr.ic_grid
|
: R.drawable.ic_list);
|
||||||
: R.attr.ic_list));
|
|
||||||
mSwitch.setTitle(mLinear ? R.string.grid : R.string.list);
|
mSwitch.setTitle(mLinear ? R.string.grid : R.string.list);
|
||||||
mPrefs.edit().putBoolean("linear", mLinear).apply();
|
mPrefs.edit().putBoolean("linear", mLinear).apply();
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,12 +182,12 @@ public class Utility {
|
||||||
public static int getIconForFileType(FileType type) {
|
public static int getIconForFileType(FileType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MUSIC:
|
case MUSIC:
|
||||||
return R.drawable.ic_headset_white_24dp;
|
return R.drawable.ic_headset;
|
||||||
default:
|
default:
|
||||||
case VIDEO:
|
case VIDEO:
|
||||||
return R.drawable.ic_movie_white_24dp;
|
return R.drawable.ic_movie;
|
||||||
case SUBTITLE:
|
case SUBTITLE:
|
||||||
return R.drawable.ic_subtitles_white_24dp;
|
return R.drawable.ic_subtitles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 358 B |
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 511 B After Width: | Height: | Size: 511 B |
Before Width: | Height: | Size: 244 B After Width: | Height: | Size: 244 B |
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |