Set up custom Main Page tabs
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -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<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
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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<String> 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<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
|
||||
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<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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 223 B |
After Width: | Height: | Size: 267 B |
After Width: | Height: | Size: 261 B |
After Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 210 B |
After Width: | Height: | Size: 201 B |
After Width: | Height: | Size: 230 B |
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 197 B |
After Width: | Height: | Size: 425 B |
After Width: | Height: | Size: 415 B |
After Width: | Height: | Size: 380 B |
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 351 B |
After Width: | Height: | Size: 470 B |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 611 B |
|
@ -1,38 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/firstText"
|
||||
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" />
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="550dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp">
|
||||
|
||||
<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_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:padding="4dp">
|
||||
|
||||
|
@ -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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/confirmText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="4dp"
|
||||
android:text="@string/accept"
|
||||
android:textColor="@color/black_settings_accent_color" />
|
||||
android:textColor="@color/black_settings_accent_color"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -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" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonAddRemove"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginEnd="22dp"
|
||||
android:background="@color/dark_background_color"
|
||||
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
|
||||
android:id="@+id/buttonDown"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toStartOf="@+id/buttonAddRemove"
|
||||
android:background="@color/dark_background_color"
|
||||
android:layout_toLeftOf="@+id/buttonAddRemove" />
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/buttonUp"
|
||||
android:layout_toStartOf="@+id/buttonUp"
|
||||
android:background="@color/black_background_color" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonUp"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toLeftOf="@+id/buttonDown"
|
||||
android:layout_toStartOf="@+id/buttonDown"
|
||||
android:background="@color/dark_background_color" />
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/buttonAddRemove"
|
||||
android:layout_toStartOf="@+id/buttonAddRemove"
|
||||
android:background="@color/black_background_color" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -29,7 +29,7 @@
|
|||
<color name="dark_queue_background_color">#af000000</color>
|
||||
|
||||
<!-- 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_separator_color">#1effffff</color>
|
||||
<color name="black_contrast_background_color">#23454545</color>
|
||||
|
|