From 6675d3e2cd4263b7c09f50322b27885fb1b7b5bd Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Sun, 10 Jun 2018 21:57:35 +0200 Subject: [PATCH] Set up custom Main Page tabs --- app/build.gradle | 1 + .../newpipe/fragments/MainFragment.java | 165 +++++++++--- .../history/StatisticsPlaylistFragment.java | 8 + .../settings/ContentSettingsDialog.java | 244 ++++++++++++++++-- .../settings/ContentSettingsFragment.java | 71 +---- .../schabi/newpipe/util/ServiceHelper.java | 1 + app/src/main/res/drawable-hdpi/ic_add.png | Bin 246 -> 223 bytes .../res/drawable-hdpi/ic_arrow_down_white.png | Bin 0 -> 267 bytes .../res/drawable-hdpi/ic_arrow_up_white.png | Bin 0 -> 261 bytes app/src/main/res/drawable-hdpi/ic_remove.png | Bin 0 -> 363 bytes app/src/main/res/drawable-mdpi/ic_add.png | Bin 176 -> 152 bytes .../res/drawable-mdpi/ic_arrow_down_white.png | Bin 0 -> 210 bytes .../res/drawable-mdpi/ic_arrow_up_white.png | Bin 0 -> 201 bytes app/src/main/res/drawable-mdpi/ic_remove.png | Bin 0 -> 230 bytes app/src/main/res/drawable-xhdpi/ic_add.png | Bin 220 -> 197 bytes .../drawable-xhdpi/ic_arrow_down_white.png | Bin 0 -> 425 bytes .../res/drawable-xhdpi/ic_arrow_up_white.png | Bin 0 -> 415 bytes app/src/main/res/drawable-xhdpi/ic_remove.png | Bin 0 -> 380 bytes app/src/main/res/drawable-xxhdpi/ic_add.png | Bin 371 -> 351 bytes .../drawable-xxhdpi/ic_arrow_down_white.png | Bin 0 -> 470 bytes .../res/drawable-xxhdpi/ic_arrow_up_white.png | Bin 0 -> 458 bytes .../main/res/drawable-xxhdpi/ic_remove.png | Bin 0 -> 611 bytes .../res/layout/dialog_contentsettings.xml | 93 ++++--- .../res/layout/dialog_contentsettingtab.xml | 50 ++-- app/src/main/res/values/colors.xml | 2 +- 25 files changed, 458 insertions(+), 177 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_arrow_down_white.png create mode 100644 app/src/main/res/drawable-hdpi/ic_arrow_up_white.png create mode 100644 app/src/main/res/drawable-hdpi/ic_remove.png create mode 100644 app/src/main/res/drawable-mdpi/ic_arrow_down_white.png create mode 100644 app/src/main/res/drawable-mdpi/ic_arrow_up_white.png create mode 100644 app/src/main/res/drawable-mdpi/ic_remove.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_arrow_down_white.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_arrow_up_white.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_remove.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_arrow_down_white.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_arrow_up_white.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_remove.png diff --git a/app/build.gradle b/app/build.gradle index f22492aef..a690a9add 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -95,4 +95,5 @@ dependencies { implementation "com.squareup.okhttp3:okhttp:$okHttpLibVersion" debugImplementation "com.facebook.stetho:stetho-okhttp3:$stethoLibVersion" + implementation 'com.android.support.constraint:constraint-layout:1.1.2' } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index 1665f7c5f..56a2862bb 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -22,15 +22,18 @@ import android.view.View; import android.view.ViewGroup; import org.schabi.newpipe.BaseFragment; +import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.StreamingService; +import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.kiosk.KioskList; import org.schabi.newpipe.fragments.list.channel.ChannelFragment; import org.schabi.newpipe.local.feed.FeedFragment; import org.schabi.newpipe.fragments.list.kiosk.KioskFragment; import org.schabi.newpipe.local.bookmark.BookmarkFragment; +import org.schabi.newpipe.local.history.StatisticsPlaylistFragment; import org.schabi.newpipe.local.subscription.SubscriptionFragment; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; @@ -39,10 +42,28 @@ import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.ServiceHelper; import org.schabi.newpipe.util.ThemeHelper; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.schabi.newpipe.util.NavigationHelper.MAIN_FRAGMENT_TAG; + public class MainFragment extends BaseFragment implements TabLayout.OnTabSelectedListener { public int currentServiceId = -1; private ViewPager viewPager; + private List tabs = new ArrayList<>(); + static PagerAdapter adapter; + TabLayout tabLayout; + private SharedPreferences prefs; + private Bundle savedInstanceStateBundle; + + SharedPreferences.OnSharedPreferenceChangeListener listener = (prefs, key) -> { + if(key.equals("saveUsedTabs")||key.equals("service")) { + mainPageChanged(); + } + }; + /*////////////////////////////////////////////////////////////////////////// // Constants @@ -60,6 +81,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte @Override public void onCreate(Bundle savedInstanceState) { + savedInstanceStateBundle = savedInstanceState; super.onCreate(savedInstanceState); setHasOptionsMenu(true); } @@ -67,6 +89,9 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { currentServiceId = ServiceHelper.getSelectedServiceId(activity); + + prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + prefs.registerOnSharedPreferenceChangeListener(listener); return inflater.inflate(R.layout.fragment_main, container, false); } @@ -74,31 +99,49 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte protected void initViews(View rootView, Bundle savedInstanceState) { super.initViews(rootView, savedInstanceState); - TabLayout tabLayout = rootView.findViewById(R.id.main_tab_layout); + getTabOrder(); + + tabLayout = rootView.findViewById(R.id.main_tab_layout); viewPager = rootView.findViewById(R.id.pager); /* Nested fragment, use child fragment here to maintain backstack in view pager. */ - PagerAdapter adapter = new PagerAdapter(getChildFragmentManager()); + adapter = new PagerAdapter(getChildFragmentManager()); viewPager.setAdapter(adapter); viewPager.setOffscreenPageLimit(adapter.getCount()); tabLayout.setupWithViewPager(viewPager); + } - int channelIcon = ThemeHelper.resolveResourceIdFromAttr(activity, R.attr.ic_channel); - int whatsHotIcon = ThemeHelper.resolveResourceIdFromAttr(activity, R.attr.ic_hot); - int bookmarkIcon = ThemeHelper.resolveResourceIdFromAttr(activity, R.attr.ic_bookmark); + private void getTabOrder() { + tabs.clear(); - //assign proper icons to tabs - /* - if (isSubscriptionsPageOnlySelected()) { - tabLayout.getTabAt(0).setIcon(channelIcon); - tabLayout.getTabAt(1).setIcon(bookmarkIcon); - } else { - tabLayout.getTabAt(0).setIcon(whatsHotIcon); - tabLayout.getTabAt(1).setIcon(channelIcon); - tabLayout.getTabAt(2).setIcon(bookmarkIcon); + String save = prefs.getString("saveUsedTabs", "1\n2\n4\n"); + String tabsArray[] = save.trim().split("\n"); + + KioskList kl = null; + + try { + StreamingService service = NewPipe.getService(currentServiceId); + kl = service.getKioskList(); + } catch (Exception e) { + ErrorActivity.reportError(activity, e, + activity.getClass(), + null, + ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR, + "none", "", R.string.app_ui_crash)); + } + + for(String tabNumber:tabsArray) { + if(tabNumber.equals("1")) { + if (kl != null) { + for(String ks : kl.getAvailableKiosks()) { + tabs.add(tabNumber+"\t"+ks); + } + } + } else { + tabs.add(tabNumber); + } } - */ } /*////////////////////////////////////////////////////////////////////////// @@ -151,6 +194,11 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte public void onTabReselected(TabLayout.Tab tab) { } + public void mainPageChanged() { + getTabOrder(); + adapter.notifyDataSetChanged(); + } + private class PagerAdapter extends FragmentPagerAdapter { PagerAdapter(FragmentManager fm) { super(fm); @@ -158,30 +206,83 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte @Override public Fragment getItem(int position) { - //return proper fragments + String tabNumber = tabs.get(position); + + if(tabNumber.startsWith("1\t")) { + String kiosk[] = tabNumber.split("\t"); + if(kiosk.length==2) { + KioskFragment fragment = null; + try { + tabLayout.getTabAt(position).setIcon(KioskTranslator.getKioskIcons(kiosk[1], getContext())); + + fragment = KioskFragment.getInstance(currentServiceId, kiosk[1]); + fragment.useAsFrontPage(true); + return fragment; + } catch (Exception e) { + ErrorActivity.reportError(activity, e, + activity.getClass(), + null, + ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR, + "none", "", R.string.app_ui_crash)); + } + } + } else if(tabNumber.startsWith("6\t")) { + String channelInfo[] = tabNumber.split("\t"); + if(channelInfo.length==4) { + tabLayout.getTabAt(position).setIcon(R.drawable.ic_channel_white_24dp); + + ChannelFragment fragment = ChannelFragment.getInstance(Integer.parseInt(channelInfo[3]), channelInfo[1], channelInfo[2]); + fragment.useAsFrontPage(true); + return fragment; + } else { + return new BlankFragment(); + } + } else { + switch (tabNumber) { + case "0": + tabLayout.getTabAt(position).setIcon(R.drawable.ic_whatshot_white_24dp); + + return new BlankFragment(); + case "2": + tabLayout.getTabAt(position).setIcon(R.drawable.ic_channel_white_24dp); + + SubscriptionFragment sfragment = new SubscriptionFragment(); + sfragment.useAsFrontPage(true); + return sfragment; + case "3": + tabLayout.getTabAt(position).setIcon(R.drawable.ic_rss_feed_white_24dp); + + FeedFragment ffragment = new FeedFragment(); + ffragment.useAsFrontPage(true); + return ffragment; + case "4": + tabLayout.getTabAt(position).setIcon(R.drawable.ic_bookmark_white_24dp); + + BookmarkFragment bFragment = new BookmarkFragment(); + bFragment.useAsFrontPage(true); + return bFragment; + case "5": + tabLayout.getTabAt(position).setIcon(R.drawable.ic_history_white_24dp); + + StatisticsPlaylistFragment cFragment = new StatisticsPlaylistFragment(); + cFragment.useAsFrontPage(true); + return cFragment; + } + } + return new BlankFragment(); - } + } @Override - public CharSequence getPageTitle(int position) { - //return getString(this.tabTitles[position]); - return ""; + public int getItemPosition(Object object) { + // Causes adapter to reload all Fragments when + // notifyDataSetChanged is called + return POSITION_NONE; } @Override public int getCount() { - //return number of framgents - return 10; + return tabs.size(); } } - - /*////////////////////////////////////////////////////////////////////////// - // Main page content - //////////////////////////////////////////////////////////////////////////*/ - - private boolean isSubscriptionsPageOnlySelected() { - return PreferenceManager.getDefaultSharedPreferences(activity) - .getString(getString(R.string.main_page_content_key), getString(R.string.blank_page_key)) - .equals(getString(R.string.subscription_page_key)); - } } diff --git a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java index c2c813a4d..04d9c9dfe 100644 --- a/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java @@ -96,6 +96,14 @@ public class StatisticsPlaylistFragment return inflater.inflate(R.layout.fragment_playlist, container, false); } + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + if (activity != null && isVisibleToUser) { + setTitle(activity.getString(R.string.title_activity_history)); + } + } + /////////////////////////////////////////////////////////////////////////// // Fragment LifeCycle - Views /////////////////////////////////////////////////////////////////////////// diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsDialog.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsDialog.java index 6cc63dd5e..bea5a0fba 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsDialog.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsDialog.java @@ -1,6 +1,13 @@ package org.schabi.newpipe.settings; +import android.app.Dialog; +import android.content.Context; +import android.content.SharedPreferences; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; @@ -20,26 +27,122 @@ import java.util.List; public class ContentSettingsDialog extends DialogFragment { + + public AllAdapter allAdapter; + public UsedAdapter usedAdapter; + List usedTabs = new ArrayList<>(); + public String[] allTabs = new String[7]; + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.dialog_contentsettings, container); } + @Override public void onViewCreated(@NonNull View rootView, @Nullable Bundle savedInstanceState) { super.onViewCreated(rootView, savedInstanceState); + + tabNames(); + initButtons(rootView); + initUsedTabs(); + RecyclerView allTabs = rootView.findViewById(R.id.tabs); allTabs.setLayoutManager(new LinearLayoutManager(getContext())); - allTabs.setAdapter(new allAdapter()); + allAdapter = new AllAdapter(); + allTabs.setAdapter(allAdapter); + allTabs.addItemDecoration(new DividerItemDecoration(getActivity())); RecyclerView usedTabs = rootView.findViewById(R.id.usedTabs); usedTabs.setLayoutManager(new LinearLayoutManager(getContext())); + usedAdapter = new UsedAdapter(); + usedTabs.setAdapter(usedAdapter); + usedTabs.addItemDecoration(new DividerItemDecoration(getActivity())); } - public class allAdapter extends RecyclerView.Adapter{ + private void initButtons(View rootView){ + rootView.findViewById(R.id.cancelText).setOnClickListener((v -> { + dismiss(); + })); + + rootView.findViewById(R.id.confirmText).setOnClickListener((v -> { + StringBuilder save = new StringBuilder(); + if(usedTabs.size()==0) { + save = new StringBuilder("0"); + } else { + for(String s: usedTabs) { + save.append(s); + save.append("\n"); + } + } + + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString("saveUsedTabs", save.toString()); + editor.commit(); + dismiss(); + })); + } + + private void initUsedTabs() { + String save = PreferenceManager.getDefaultSharedPreferences(getContext()).getString("saveUsedTabs", "1\n2\n4\n"); + String tabs[] = save.trim().split("\n"); + usedTabs.addAll(Arrays.asList(tabs)); + } + + private void tabNames() { + allTabs[0] = getString(R.string.blank_page_summary); + allTabs[1] = getString(R.string.kiosk_page_summary); + allTabs[2] = getString(R.string.subscription_page_summary); + allTabs[3] = getString(R.string.feed_page_summary); + allTabs[4] = getString(R.string.tab_bookmarks); + allTabs[5] = getString(R.string.title_activity_history); + allTabs[6] = getString(R.string.channel_page_summary); + } + + private void addTab(int position) { + if(position!=6) { + usedTabs.add(String.valueOf(position)); + usedAdapter.notifyDataSetChanged(); + } else { + SelectChannelFragment selectChannelFragment = new SelectChannelFragment(); + selectChannelFragment.setOnSelectedLisener((String url, String name, int service) -> { + usedTabs.add(position+"\t"+url+"\t"+name+"\t"+service); + usedAdapter.notifyDataSetChanged(); + }); + selectChannelFragment.show(getFragmentManager(), "select_channel"); + } + } + + private void removeTab(int position) { + usedTabs.remove(position); + usedAdapter.notifyDataSetChanged(); + } + + private void upTab(int position){ + String first = usedTabs.get(position - 1); + String second = usedTabs.get(position); + + usedTabs.set(position - 1, second); + usedTabs.set(position, first); + + usedAdapter.notifyDataSetChanged(); + } + + private void downTab(int position){ + String first = usedTabs.get(position + 1); + String second = usedTabs.get(position); + + usedTabs.set(position + 1, second); + usedTabs.set(position, first); + + usedAdapter.notifyDataSetChanged(); + } + + public class AllAdapter extends RecyclerView.Adapter{ @Override public TabViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { @@ -54,45 +157,142 @@ public class ContentSettingsDialog extends DialogFragment { holder.bind(position); } - - // Return the size of your dataset (invoked by the layout manager) @Override public int getItemCount() { - return 5; + return allTabs.length; } class TabViewHolder extends RecyclerView.ViewHolder { TextView text; Button add; + Button up; + Button down; public TabViewHolder(View itemView) { super(itemView); text = itemView.findViewById(R.id.tabName); add = itemView.findViewById(R.id.buttonAddRemove); + up = itemView.findViewById(R.id.buttonUp); + down = itemView.findViewById(R.id.buttonDown); } void bind(int position) { + up.setBackgroundResource(0); + down.setBackgroundResource(0); + text.setText(allTabs[position]); add.setBackgroundResource(R.drawable.ic_add); - switch (position) { - case 0: - text.setText("Test"); - break; - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - case 6: - break; - } + add.setOnClickListener(v -> { + addTab(position); + }); + } } } + + public class UsedAdapter extends RecyclerView.Adapter{ + + @Override + public TabViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + + LayoutInflater inflater = LayoutInflater.from(getContext()); + View view = inflater.inflate(R.layout.dialog_contentsettingtab, parent, false); + return new TabViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull TabViewHolder holder, int position) { + holder.bind(position); + } + + @Override + public int getItemCount() { + return usedTabs.size(); + } + + class TabViewHolder extends RecyclerView.ViewHolder { + + TextView text; + Button remove; + Button up; + Button down; + + public TabViewHolder(View itemView) { + super(itemView); + + text = itemView.findViewById(R.id.tabName); + remove = itemView.findViewById(R.id.buttonAddRemove); + up = itemView.findViewById(R.id.buttonUp); + down = itemView.findViewById(R.id.buttonDown); + } + + void bind(int position) { + if(position!=0) { + up.setBackgroundResource(R.drawable.ic_arrow_up_white); + up.setOnClickListener(v -> { + upTab(position); + }); + } else up.setBackgroundResource(0); + + if(position!=usedTabs.size()-1) { + down.setBackgroundResource(R.drawable.ic_arrow_down_white); + down.setOnClickListener(v -> { + downTab(position); + }); + } else down.setBackgroundResource(0); + + if(usedTabs.get(position).startsWith("6\t")) { + String channelInfo[] = usedTabs.get(position).split("\t"); + String channelName = ""; + if(channelInfo.length==4) channelName = channelInfo[2]; + String textToSet = allTabs[6]+": "+channelName; + text.setText(textToSet); + } else { + text.setText(allTabs[Integer.parseInt(usedTabs.get(position))]); + } + + remove.setBackgroundResource(R.drawable.ic_remove); + remove.setOnClickListener(v -> { + removeTab(position); + }); + + } + } + } + + public class DividerItemDecoration extends RecyclerView.ItemDecoration { + + private final int[] ATTRS = new int[]{android.R.attr.listDivider}; + + private Drawable divider; + + public DividerItemDecoration(Context context) { + final TypedArray styledAttributes = context.obtainStyledAttributes(ATTRS); + divider = styledAttributes.getDrawable(0); + styledAttributes.recycle(); + } + + + @Override + public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { + int left = parent.getPaddingLeft(); + int right = parent.getWidth() - parent.getPaddingRight(); + + int childCount = parent.getChildCount(); + for (int i = 0; i < childCount; i++) { + View child = parent.getChildAt(i); + + RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); + + int top = child.getBottom() + params.bottomMargin; + int bottom = top + divider.getIntrinsicHeight(); + + divider.setBounds(left, top, right, bottom); + divider.draw(c); + } + } + } + + } diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index cf535ed09..d856dbe48 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.settings; import android.app.Activity; import android.app.AlertDialog; +import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; @@ -10,9 +11,11 @@ import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; import android.support.v7.preference.ListPreference; import android.support.v7.preference.Preference; import android.util.Log; +import android.widget.LinearLayout; import android.widget.Toast; import com.nononsenseapps.filepicker.Utils; @@ -99,75 +102,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment { addPreferencesFromResource(R.xml.content_settings); - /* - - final ListPreference mainPageContentPref = (ListPreference) findPreference(getString(R.string.main_page_content_key)); - mainPageContentPref.setOnPreferenceChangeListener((Preference preference, Object newValueO) -> { - final String newValue = newValueO.toString(); - - final String mainPrefOldValue = - defaultPreferences.getString(getString(R.string.main_page_content_key), "blank_page"); - final String mainPrefOldSummary = getMainPagePrefSummery(mainPrefOldValue, mainPageContentPref); - - if(newValue.equals(getString(R.string.kiosk_page_key))) { - SelectKioskFragment selectKioskFragment = new SelectKioskFragment(); - selectKioskFragment.setOnSelectedLisener((String kioskId, int service_id) -> { - defaultPreferences.edit() - .putInt(getString(R.string.main_page_selected_service), service_id).apply(); - defaultPreferences.edit() - .putString(getString(R.string.main_page_selectd_kiosk_id), kioskId).apply(); - String serviceName = ""; - try { - serviceName = NewPipe.getService(service_id).getServiceInfo().getName(); - } catch (ExtractionException e) { - onError(e); - } - String kioskName = KioskTranslator.getTranslatedKioskName(kioskId, - getContext()); - - String summary = - String.format(getString(R.string.service_kiosk_string), - serviceName, - kioskName); - - mainPageContentPref.setSummary(summary); - }); - selectKioskFragment.setOnCancelListener(() -> { - mainPageContentPref.setSummary(mainPrefOldSummary); - mainPageContentPref.setValue(mainPrefOldValue); - }); - selectKioskFragment.show(getFragmentManager(), "select_kiosk"); - } else if(newValue.equals(getString(R.string.channel_page_key))) { - SelectChannelFragment selectChannelFragment = new SelectChannelFragment(); - selectChannelFragment.setOnSelectedLisener((String url, String name, int service) -> { - defaultPreferences.edit() - .putInt(getString(R.string.main_page_selected_service), service).apply(); - defaultPreferences.edit() - .putString(getString(R.string.main_page_selected_channel_url), url).apply(); - defaultPreferences.edit() - .putString(getString(R.string.main_page_selected_channel_name), name).apply(); - - mainPageContentPref.setSummary(name); - }); - selectChannelFragment.setOnCancelListener(() -> { - mainPageContentPref.setSummary(mainPrefOldSummary); - mainPageContentPref.setValue(mainPrefOldValue); - }); - selectChannelFragment.show(getFragmentManager(), "select_channel"); - } else { - mainPageContentPref.setSummary(getMainPageSummeryByKey(newValue)); - } - - defaultPreferences.edit().putBoolean(Constants.KEY_MAIN_PAGE_CHANGE, true).apply(); - - return true; - }); - - */ - Preference contentPreference = findPreference(getString(R.string.main_page_content_key)); contentPreference.setOnPreferenceClickListener((Preference p) -> { - new ContentSettingsDialog().show(getFragmentManager(),""); + new ContentSettingsDialog().show(getFragmentManager(),"select_content"); return true; }); diff --git a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java index 7c781eb14..15350c180 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java @@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.fragments.MainFragment; import java.util.concurrent.TimeUnit; diff --git a/app/src/main/res/drawable-hdpi/ic_add.png b/app/src/main/res/drawable-hdpi/ic_add.png index 85172125ec3e2d2b559c145390254b0752e832d2..1ae5b2dc41be9b20a87e14da5270f22ef5c1c66b 100644 GIT binary patch delta 195 zcmV;!06hQp0p9_TB!8w!L_t(|+U=G*3WY!n0JZYdh~EDsA_xjL&pWLVQphT}3-RG+ z2Br*TV3i~Z0002&an9u%v!^Xzh@Cj7?V}=O*;1UuSzRM?0tg_000Iag!05I)vpxu@ zBIYye<^9{{%yF~)>Mvr}{&qTe5?5>c3c@fDMcakC5Isd8i$E4hAcrhc5Ept|Gth3L z&=eAA^*#8@3G?VonXUr>0Dw=7F~>RH`@^o9S4y2y)3=oSlwnsAA`n7&q`V{|AzuOk z1Q0*~0R#}Jaoa3KYkkQDthMLT`s!!Lm)mABbMq4C+;dHB^;6p^ABonfK61YzFisMs z$r~%Km2s`T^u0)wCdPQpmsl2i%^Uni5kLR|1Q0;r-v!2&w@qvMP2DyC003L%4Q?SV UNtDZ4jsO4v07*qoM6N<$f=MM@-2eap diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_down_white.png b/app/src/main/res/drawable-hdpi/ic_arrow_down_white.png new file mode 100644 index 0000000000000000000000000000000000000000..33939600dc2d073a03e4497711fa9a1197976ac3 GIT binary patch literal 267 zcmV+m0rdWfP)?2_s$!CLf|`ZSY(tFw$6h((bst}CysR<$O&<~e6SNfogd_cZ|8%ZIH&W0PDt40 zot=p3{7Fv4cHY^EF`ajGLSQc6=>$gS4?2O>`A#P=JKy1iq`5pHgb+eVG9HZfEM%y3 RpMU@W002ovPDHLkV1m?ech3L- literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_up_white.png b/app/src/main/res/drawable-hdpi/ic_arrow_up_white.png new file mode 100644 index 0000000000000000000000000000000000000000..0972a9bca6204b20bb5622004e0bf350fb3ee4e1 GIT binary patch literal 261 zcmV+g0s8)lP)1_T`n|v!^#-4!qM6Z|8f#!vjQq>*=s^FM4o3Rc5b=gY&fqu+_wg^R?M&;==hm z|3viQyuBtGowwD*pU&H9;(_yHn-FwfzX@UIb(`qqyj~L>o$uR(qVw`iC_69P#31M8 zni%N(vnC8V-`<2V=i8bv>iqpC=(5mO+U9KK%nLqX0RR91;LZF1c%LkAkrJ0^00000 LNkvXXu0mjfTI6^a literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/ic_remove.png b/app/src/main/res/drawable-hdpi/ic_remove.png new file mode 100644 index 0000000000000000000000000000000000000000..75e65bc9c7c7f1791b65c3a2635abc3ead693dca GIT binary patch literal 363 zcmV-x0hIoUP)yZ zpN?328K5E$>*(g0&m6;o5_E6I8Gy-*|w<4~Zst^3PT6UK}SX z*zu&l2bw}~VrSow?7=BJYf6pw~Y%s;#6e^SYCl8nUBaY97mXgKk)%81A|8#oP! zW0jhGM?~V)O4tWgp)jg>fEG}@0EGXr0hj@hBy?X%L_t(|+GAiC1*2dTkO}_(|1S>2&QL5i5Dsty;xka}JnDc^ z2aGy^*7+P8E<$oZ0RgpQl=_fT>^vkLAOUp*E?k0SK@kD9;-k4>)B&Ro7?uu@plLoI d1*2fZ005wS_%I=I!mgp=*2M`T6F75na#(tSz~RP$0}c)E_zYN?goP*1RNyH( zvVz%7*5DPxtY^hJ5*hUpXBZu1n*4PmpR#P?*F2iidZEGkz@=d#Wzp$Py}&o>YN diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_down_white.png b/app/src/main/res/drawable-mdpi/ic_arrow_down_white.png new file mode 100644 index 0000000000000000000000000000000000000000..40a0f499ef07d39a3a2a26678d8d28c058afa4e0 GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJnVv3=Ar-gYhTP_DP~Z_!OO`9Y z)YxU6XgFzw;}(bC3->pYb4L(VRUOSW4t&9@HP_r!b#IQgw)FuzlEKr} K&t;ucLK6TKV^+QZ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_up_white.png b/app/src/main/res/drawable-mdpi/ic_arrow_up_white.png new file mode 100644 index 0000000000000000000000000000000000000000..fe67b46738ca43b8d76c8e6e73f67eeb0b211b80 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJ37#&FAr-gYPP@q4pdjFU@NC4< zn>~j)tRK#FXi`y{Q~u+!+WGr&*}f)hO$r?=B_2Di>3pjHS=sPChta0iN{=VXZ`M57 zXK=pas+!!S>n}_`PKw#ynN_e*cxR%~nS6H-6@Gci{HDm=XI{UEvHs4Xz4Ke(t@!q! zPy5uSOx`|QK<>^DgO?9GdT*!~S6cnK;UG}L^xwz5nMLbLInZqkp00i_>zopr02)A3 A)Bpeg literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_remove.png b/app/src/main/res/drawable-mdpi/ic_remove.png new file mode 100644 index 0000000000000000000000000000000000000000..a1816d4c66c05fb2234d32c8319b197f9a5a4b0b GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJwVp1HAr-gYPIcsJFyLXSZT(`b zR587w|J}l0%cT_KmSjy{_BBDQY57|n-n`xCQjGR$9J^8f(3W4K(B_=Z2c}AP%{vzv zrTreXC{!q{7r)OUB|c}W@FOPseF3}L-Uz%Z@axF>Fh}6(Lx06t2j!i%G~aK@;P!tr z=dSRq4+q|I=3021^5TuVG$ZT7D@BX{JF7T6Pp)Y7usN>qrgPEribc#05n=7+I_td$#vd#(Ua0X9TKbLh*2~7aH`CXC# literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_add.png b/app/src/main/res/drawable-xhdpi/ic_add.png index cbe4b60000a1d1be03ca0f9b3896ef50fd594f57..9ea0eeb7e9601666687cb2df5cf42fca4ff85c9c 100644 GIT binary patch delta 169 zcmcb^c$9I1N_~%~i(^Q|t+&?=xf&E0+Aj9peDEN1j+LKB`wPEk7ew?#LoWS(5YHO# zY{4^0#dFemQ-^Ta{FB7T;C5HKI9kKhLt9njSS^3?pZ5iMC3HA0uAVr?8elF{r5}E)DOgu{f delta 192 zcmX@gc!zOGHO(?=$P&o^oH&3wdu1vriTSI-{*g? z^(-K~%=Up{Gsyto&T-G@yGywp^I!mSi diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_down_white.png b/app/src/main/res/drawable-xhdpi/ic_arrow_down_white.png new file mode 100644 index 0000000000000000000000000000000000000000..86bc5db3b3c9ce752b93e4ad1dbb395383c0416c GIT binary patch literal 425 zcmV;a0apHrP)kfi2426v$5O@q9Pu(A%5w<{lCmcy@_u)kV4|h)A6<{ion?P>FF*`1JD(iV*UiFjyIzfJF##Pmn>k z{Z5_W%Rp`O^Nhx!kLKqY6v5>^L3z>k0gB+_p75WaXEF|Z?+Gf3!t>M#wmZSCpJ%ia z+Gu{B(KtwU#wM^%m{W{l{5&JY*hTa6%*G+@w%>415Nuo>00000000000J7i(rKBTA TWkLv}00000NkvXXu0mjffs($V^SF?dYOSjNh zrFq(WUH^Z}>Ee1cH>ZWSB}`i0F!F4T!BP?LnQ7PG>D1Z)bwh!TVPEnx70<|=XT?jG z2l>vL_k80F{})%Zmo|o6%=Xkty)XT2>#ykT%|>AXE6t6cZI#-!Y{%@MQ+h({&&+;n z5Ig(c(LD<;y$hRh{nZQGM|!FE^9q=Cd)LYy5v`7UXY+HX*M#Xi)g@Bz zTN>ow6aKNC`R_S--RfxTl$f)xIoDer++(T!VYWo(w)j~eV!Zu(DtS`R@0WdHlGXog z>$3AxWSY(jMEqmE5N-z;Uih@xe*=)RDxbf>=zRM%%ik@%mGhjfcidKg zbLR8Hr)l#G41mHLYnv9^oL?$?WZt~#;Vv{#miRa%bmRPem#2I_zO zdggt$ncivGzwpi5w+rOFmQKH9ZR9)8`%fSvER;I>`Maf+em-Wpz8oav>FVdQ&MBb@ E0O&Bi`2YX_ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_remove.png b/app/src/main/res/drawable-xhdpi/ic_remove.png new file mode 100644 index 0000000000000000000000000000000000000000..ffbdaa6ed2fdb34ba1a2771f0fe47e083171adf1 GIT binary patch literal 380 zcmV-?0fYXDP)Mm|RbbMj|KFe`sX1oQGoBDj&? z6TzK)N(8s^2@(9tM@H~1zaxS_`Gg35Kc|r&wgb+dq avC0=)0YW3ghy3&a0000F6*CiU#9 zk>R0Ro}3B{OdJgiObQJQ92m^Bc>4wW_Rih7nY;KkM*-*NvlV|geeYv?^R{Ph#ewsE z4Eo+4#PQ+w@e9FS6O!NA_AfmDW!{9>zdj09hyLo0 zn7fbDGHt$6$=;5)MsfS+eU*3kBceE2flGyp8_BePgg&ebxsLQ0L*WHc>n+a delta 320 zcmcc5^qFabO1+h*i(^Q|t+%%gvkwJ`G+eZ}y{qfNJjDr$oKLRrwAc}{;_j{b+vSSg z3j!~=Pp;y-<7qg9-+4-QAOi##L|iG|yJpp^x0jA2f0S9SIeC-L{oC8_F8{g1XtyGh z<(Jz1uXepNK6`#?C&x$6f@LfM42&!e42%K}3=n2L61!o!^xfN)C6_qwEwSunu~_Eu zI_CKNKld)mR$KR<+n71)eKzBxjTL^!9{X3ne{oGU>7DUU?>P)i910CU;=}gs3)>YB zT~^=w?Yivth0A-6-}kTmTPrB|X!3;QOSA90wQST+`k1PF{o~`kqU-;#3)s7YG)@*} zl$b2X$YJ=vhx3E|-CNeP4&OU>r}v%g-aq&FAYMGMGhTIRru4_`(n64cr>mdKI;Vst E09)vf3;+NC diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_down_white.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_down_white.png new file mode 100644 index 0000000000000000000000000000000000000000..7e901e098ffbd5fcf985fbe67b7374208c3f7ba4 GIT binary patch literal 470 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>V4Ume;uunK>+N;JJSIZ{hrleZ zCAtsHUKY&}c>B{~(V{bR&EhgAD{*x-@y^?NfBLe;QtLndpUn%@4+jm;W-QB`{!I1k z>dIGVtnZ&?-{AXs-m^*14%?*aoj$icetUvPu}|@~Iql~wZ+`vod40zGXS!!kPLeZQ zo_hRu^!tN}KO1L%n4w>P@9o3&?v?vv1oNG4{{Qp%tp5M$&JxqyA7xeEERHR+{1fh< zZY`y2P<<@__Rh`1Zsrf)>DTKBW?3m-|I97ZJK^-g;rCihX_@50C_!D(a5U6*&Ca`fW?Z zy!(;rN51^=vr^pl-25Kr>koh2tP^AB-H%XTbNRFMtCo$Dw<9Cfw>FSI{rf7`Op#y&#*%gdjQR*5OrrB;p4!{4yXi{B_*QFqku!B0_Z jB!QbP0l+XkK4a?h) literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_up_white.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_up_white.png new file mode 100644 index 0000000000000000000000000000000000000000..bc71e23de06a99326ed125a7c052dcd5ccec5f48 GIT binary patch literal 458 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>V4Udb;uunK>+SV}Sxkl^4uRA2 zSiYX#_0Hk<^t?NzZ|!}RT?7{Ds$Sfq^8Ao+;GI2ZEWYQN0d*sQKuc-t_RMKE(bAP~ zKb2?NU8;GybKm`&XR@c&pWwD%zVnIY^YeUWU+z4Wzg)A-@~-ZGv*my8UR*Y>{OSKK ze~vpBsN1}>|G)j|efg$zr_|e(f6o8U&O6Ui7V?l`T8`E9`g32+yLqQo|65v6;1^HC zIj7pjtFwHlnJaMMbEy-<`RkmFHgJLG?^+z@*#o(s|Ln96%M9Ql0w zP0Kl(`Zazpu6#cJvZc><|9d})6Q6&-ZaHYPf4!f?mCwIlv>ddxFH`q<^wZEf(dc~t zRnEy(b#we?-1vOEjOl#-4NjZ=iRvHzw9P&6SsGd3*xU(m-!kuA+B19lxzgvqc@aU$ cz|ipU2iv^Kc`Mj0uY<)sUHx3vIVCg!0H1T#vj6}9 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_remove.png b/app/src/main/res/drawable-xxhdpi/ic_remove.png new file mode 100644 index 0000000000000000000000000000000000000000..d35469d3c1ba16c9d9d2a2445c2681c22695b9ff GIT binary patch literal 611 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>VAAq*aSW-r^>)s|tV0eWuCY_} zxLLXXvMdx3X!*DBfm^}jbH1@(*;^bOU)-wSq;KFPWtGt}x3av5@6OzA^UrF>UF2u_ z08K*zTP)|F=f5&1U-A63si|rq#i@}|^So~S+50r*XHbUIjX%jND%EeZXxB)I6=Xe4 zs4R~8d?%

z*0A=f@}I=KJrq%)C4~-aYHysTfY#w?`g%xr4}f_pk?xQ)^Qd*OiD| z^waVFUJevE^y%(mPUGdbUM}0|q$SF$+mx0U86hTncg0-qteI!?bwBKN7oPNL#qzRQ z=g)@byWV}dBI2#aixm}bE3RG4*z!2geevZ!b=lr9Yq=7Ws<%(B2;MrmLV3&NK=%yw z#eEn2++-Kd?XhyQmMm>4`}CUQZOS#lTZIdhw>)-m&p194s=(TO!FlItXC#)KdiK5Y z#3ae)5UZbG8}uJChdWulU7*Z<%hA1aYjKEVvreFO>5o0X4NnMd{rp<-^k<2bmA6*1 z*{xZ)Sn<}*%lYmvUfBOT>EzD2wRrjczGKT5i_|YzytoCZoo`EXpG*e3tmOqhtD*(6 zB~Kiz7hj+Fyzt7soHr8mJeS2rc;=O0O zXFCboO*zK8{zb;}AJ^7gx1aT(D#l>Z;u6{1-oD!M - - - - - - - - - - - + + + + + + + + + + + + + + @@ -40,21 +63,21 @@ android:id="@+id/cancelText" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_weight="1" android:padding="4dp" android:paddingLeft="6dp" android:paddingRight="6dp" android:text="@string/cancel" - android:textColor="@color/black_settings_accent_color" /> + android:textColor="@color/black_settings_accent_color" + android:textStyle="bold" /> + android:textColor="@color/black_settings_accent_color" + android:textStyle="bold" /> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_contentsettingtab.xml b/app/src/main/res/layout/dialog_contentsettingtab.xml index baad35b7b..09d59a6d9 100644 --- a/app/src/main/res/layout/dialog_contentsettingtab.xml +++ b/app/src/main/res/layout/dialog_contentsettingtab.xml @@ -8,36 +8,46 @@ android:id="@+id/tabName" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="22dp" - android:layout_marginStart="22dp" /> + android:layout_marginLeft="2dp" + android:layout_marginStart="0dp" + android:paddingBottom="2dp" + android:paddingLeft="2dp" + android:paddingStart="3dp" + android:paddingTop="2dp" + android:textColor="@color/background_title_color" + android:textSize="24sp" + android:layout_toStartOf="@id/buttonDown" + android:layout_toLeftOf="@id/buttonDown" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" />