1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

Set up custom Main Page tabs

This commit is contained in:
Somethingweirdhere 2018-06-10 21:57:35 +02:00 committed by Christian Schabesberger
parent 8ecbe4c8ad
commit 6675d3e2cd
25 changed files with 458 additions and 177 deletions

View File

@ -95,4 +95,5 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:$okHttpLibVersion" implementation "com.squareup.okhttp3:okhttp:$okHttpLibVersion"
debugImplementation "com.facebook.stetho:stetho-okhttp3:$stethoLibVersion" debugImplementation "com.facebook.stetho:stetho-okhttp3:$stethoLibVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
} }

View File

@ -22,15 +22,18 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.schabi.newpipe.BaseFragment; import org.schabi.newpipe.BaseFragment;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.kiosk.KioskList; import org.schabi.newpipe.extractor.kiosk.KioskList;
import org.schabi.newpipe.fragments.list.channel.ChannelFragment; import org.schabi.newpipe.fragments.list.channel.ChannelFragment;
import org.schabi.newpipe.local.feed.FeedFragment; import org.schabi.newpipe.local.feed.FeedFragment;
import org.schabi.newpipe.fragments.list.kiosk.KioskFragment; import org.schabi.newpipe.fragments.list.kiosk.KioskFragment;
import org.schabi.newpipe.local.bookmark.BookmarkFragment; 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.local.subscription.SubscriptionFragment;
import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.UserAction; 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.ServiceHelper;
import org.schabi.newpipe.util.ThemeHelper; 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 class MainFragment extends BaseFragment implements TabLayout.OnTabSelectedListener {
public int currentServiceId = -1; public int currentServiceId = -1;
private ViewPager viewPager; private ViewPager viewPager;
private List<String> 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 // Constants
@ -60,6 +81,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
savedInstanceStateBundle = savedInstanceState;
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
@ -67,6 +89,9 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
currentServiceId = ServiceHelper.getSelectedServiceId(activity); currentServiceId = ServiceHelper.getSelectedServiceId(activity);
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs.registerOnSharedPreferenceChangeListener(listener);
return inflater.inflate(R.layout.fragment_main, container, false); 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) { protected void initViews(View rootView, Bundle savedInstanceState) {
super.initViews(rootView, 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); viewPager = rootView.findViewById(R.id.pager);
/* Nested fragment, use child fragment here to maintain backstack in view 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.setAdapter(adapter);
viewPager.setOffscreenPageLimit(adapter.getCount()); viewPager.setOffscreenPageLimit(adapter.getCount());
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
}
int channelIcon = ThemeHelper.resolveResourceIdFromAttr(activity, R.attr.ic_channel); private void getTabOrder() {
int whatsHotIcon = ThemeHelper.resolveResourceIdFromAttr(activity, R.attr.ic_hot); tabs.clear();
int bookmarkIcon = ThemeHelper.resolveResourceIdFromAttr(activity, R.attr.ic_bookmark);
//assign proper icons to tabs String save = prefs.getString("saveUsedTabs", "1\n2\n4\n");
/* String tabsArray[] = save.trim().split("\n");
if (isSubscriptionsPageOnlySelected()) {
tabLayout.getTabAt(0).setIcon(channelIcon); KioskList kl = null;
tabLayout.getTabAt(1).setIcon(bookmarkIcon);
} else { try {
tabLayout.getTabAt(0).setIcon(whatsHotIcon); StreamingService service = NewPipe.getService(currentServiceId);
tabLayout.getTabAt(1).setIcon(channelIcon); kl = service.getKioskList();
tabLayout.getTabAt(2).setIcon(bookmarkIcon); } 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 onTabReselected(TabLayout.Tab tab) {
} }
public void mainPageChanged() {
getTabOrder();
adapter.notifyDataSetChanged();
}
private class PagerAdapter extends FragmentPagerAdapter { private class PagerAdapter extends FragmentPagerAdapter {
PagerAdapter(FragmentManager fm) { PagerAdapter(FragmentManager fm) {
super(fm); super(fm);
@ -158,30 +206,83 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
@Override @Override
public Fragment getItem(int position) { 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(); return new BlankFragment();
} }
@Override @Override
public CharSequence getPageTitle(int position) { public int getItemPosition(Object object) {
//return getString(this.tabTitles[position]); // Causes adapter to reload all Fragments when
return ""; // notifyDataSetChanged is called
return POSITION_NONE;
} }
@Override @Override
public int getCount() { public int getCount() {
//return number of framgents return tabs.size();
return 10;
} }
} }
/*//////////////////////////////////////////////////////////////////////////
// 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));
}
} }

View File

@ -96,6 +96,14 @@ public class StatisticsPlaylistFragment
return inflater.inflate(R.layout.fragment_playlist, container, false); 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 // Fragment LifeCycle - Views
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,13 @@
package org.schabi.newpipe.settings; 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.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
@ -20,26 +27,122 @@ import java.util.List;
public class ContentSettingsDialog extends DialogFragment { public class ContentSettingsDialog extends DialogFragment {
public AllAdapter allAdapter;
public UsedAdapter usedAdapter;
List<String> usedTabs = new ArrayList<>(); List<String> usedTabs = new ArrayList<>();
public String[] allTabs = new String[7];
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
return inflater.inflate(R.layout.dialog_contentsettings, container); return inflater.inflate(R.layout.dialog_contentsettings, container);
} }
@Override @Override
public void onViewCreated(@NonNull View rootView, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View rootView, @Nullable Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState); super.onViewCreated(rootView, savedInstanceState);
tabNames();
initButtons(rootView);
initUsedTabs();
RecyclerView allTabs = rootView.findViewById(R.id.tabs); RecyclerView allTabs = rootView.findViewById(R.id.tabs);
allTabs.setLayoutManager(new LinearLayoutManager(getContext())); 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); RecyclerView usedTabs = rootView.findViewById(R.id.usedTabs);
usedTabs.setLayoutManager(new LinearLayoutManager(getContext())); usedTabs.setLayoutManager(new LinearLayoutManager(getContext()));
usedAdapter = new UsedAdapter();
usedTabs.setAdapter(usedAdapter);
usedTabs.addItemDecoration(new DividerItemDecoration(getActivity()));
} }
public class allAdapter extends RecyclerView.Adapter<allAdapter.TabViewHolder>{ 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<AllAdapter.TabViewHolder>{
@Override @Override
public TabViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public TabViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
@ -54,45 +157,142 @@ public class ContentSettingsDialog extends DialogFragment {
holder.bind(position); holder.bind(position);
} }
// Return the size of your dataset (invoked by the layout manager)
@Override @Override
public int getItemCount() { public int getItemCount() {
return 5; return allTabs.length;
} }
class TabViewHolder extends RecyclerView.ViewHolder { class TabViewHolder extends RecyclerView.ViewHolder {
TextView text; TextView text;
Button add; Button add;
Button up;
Button down;
public TabViewHolder(View itemView) { public TabViewHolder(View itemView) {
super(itemView); super(itemView);
text = itemView.findViewById(R.id.tabName); text = itemView.findViewById(R.id.tabName);
add = itemView.findViewById(R.id.buttonAddRemove); add = itemView.findViewById(R.id.buttonAddRemove);
up = itemView.findViewById(R.id.buttonUp);
down = itemView.findViewById(R.id.buttonDown);
} }
void bind(int position) { void bind(int position) {
up.setBackgroundResource(0);
down.setBackgroundResource(0);
text.setText(allTabs[position]);
add.setBackgroundResource(R.drawable.ic_add); add.setBackgroundResource(R.drawable.ic_add);
switch (position) { add.setOnClickListener(v -> {
case 0: addTab(position);
text.setText("Test"); });
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
}
} }
} }
} }
public class UsedAdapter extends RecyclerView.Adapter<UsedAdapter.TabViewHolder>{
@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);
}
}
}
} }

View File

@ -2,6 +2,7 @@ package org.schabi.newpipe.settings;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -10,9 +11,11 @@ import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.util.Log; import android.util.Log;
import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import com.nononsenseapps.filepicker.Utils; import com.nononsenseapps.filepicker.Utils;
@ -99,75 +102,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
addPreferencesFromResource(R.xml.content_settings); 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)); Preference contentPreference = findPreference(getString(R.string.main_page_content_key));
contentPreference.setOnPreferenceClickListener((Preference p) -> { contentPreference.setOnPreferenceClickListener((Preference p) -> {
new ContentSettingsDialog().show(getFragmentManager(),""); new ContentSettingsDialog().show(getFragmentManager(),"select_content");
return true; return true;
}); });

View File

@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.fragments.MainFragment;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 B

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

View File

@ -1,38 +1,61 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent"> android:layout_height="wrap_content"
android:minWidth="550dp"
<TextView android:orientation="vertical"
android:id="@+id/firstText" android:padding="12dp">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/selection"
android:textStyle="bold" />
<android.support.v7.widget.RecyclerView
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<TextView
android:id="@+id/secondText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/chosenTabs"
android:textStyle="bold" />
<android.support.v7.widget.RecyclerView
android:id="@+id/usedTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@id/buttonLayout"
android:orientation="vertical">
<TextView
android:id="@+id/firstText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:paddingTop="2dp"
android:text="@string/selection"
android:textStyle="bold" />
<android.support.v7.widget.RecyclerView
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="@color/black_background_color">
</android.support.v7.widget.RecyclerView>
<TextView
android:id="@+id/secondText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:paddingTop="2dp"
android:text="@string/chosenTabs"
android:textStyle="bold" />
<android.support.v7.widget.RecyclerView
android:id="@+id/usedTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="@color/black_background_color" />
</LinearLayout>
<LinearLayout
android:id="@+id/buttonLayout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end" android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="4dp"> android:padding="4dp">
@ -40,21 +63,21 @@
android:id="@+id/cancelText" android:id="@+id/cancelText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="4dp" android:padding="4dp"
android:paddingLeft="6dp" android:paddingLeft="6dp"
android:paddingRight="6dp" android:paddingRight="6dp"
android:text="@string/cancel" android:text="@string/cancel"
android:textColor="@color/black_settings_accent_color" /> android:textColor="@color/black_settings_accent_color"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/confirmText" android:id="@+id/confirmText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="4dp" android:padding="4dp"
android:text="@string/accept" android:text="@string/accept"
android:textColor="@color/black_settings_accent_color" /> android:textColor="@color/black_settings_accent_color"
android:textStyle="bold" />
</LinearLayout> </LinearLayout>
</LinearLayout> </RelativeLayout>

View File

@ -8,36 +8,46 @@
android:id="@+id/tabName" android:id="@+id/tabName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="22dp" android:layout_marginLeft="2dp"
android:layout_marginStart="22dp" /> 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" />
<Button <Button
android:id="@+id/buttonAddRemove" android:id="@+id/buttonAddRemove"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="22dp"
android:background="@color/dark_background_color"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginRight="22dp" /> android:layout_centerVertical="true"
android:layout_marginEnd="0dp"
android:layout_marginRight="0dp"
android:background="@color/black_background_color" />
<Button <Button
android:id="@+id/buttonDown" android:id="@+id/buttonDown"
android:layout_width="20dp" android:layout_width="30dp"
android:layout_height="20dp" android:layout_height="30dp"
android:layout_alignParentTop="true" android:layout_centerVertical="true"
android:layout_toStartOf="@+id/buttonAddRemove" android:layout_toLeftOf="@+id/buttonUp"
android:background="@color/dark_background_color" android:layout_toStartOf="@+id/buttonUp"
android:layout_toLeftOf="@+id/buttonAddRemove" /> android:background="@color/black_background_color" />
<Button <Button
android:id="@+id/buttonUp" android:id="@+id/buttonUp"
android:layout_width="20dp" android:layout_width="30dp"
android:layout_height="20dp" android:layout_height="30dp"
android:layout_alignParentTop="true" android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/buttonDown" android:layout_toLeftOf="@+id/buttonAddRemove"
android:layout_toStartOf="@+id/buttonDown" android:layout_toStartOf="@+id/buttonAddRemove"
android:background="@color/dark_background_color" /> android:background="@color/black_background_color" />
</RelativeLayout> </RelativeLayout>

View File

@ -29,7 +29,7 @@
<color name="dark_queue_background_color">#af000000</color> <color name="dark_queue_background_color">#af000000</color>
<!-- Black Theme --> <!-- Black Theme -->
<color name="black_background_color">#000</color> <color name="black_background_color">#000000</color>
<color name="black_settings_accent_color">@color/dark_settings_accent_color</color> <color name="black_settings_accent_color">@color/dark_settings_accent_color</color>
<color name="black_separator_color">#1effffff</color> <color name="black_separator_color">#1effffff</color>
<color name="black_contrast_background_color">#23454545</color> <color name="black_contrast_background_color">#23454545</color>