Implement UI for subscriptions import/export
- Nice and easy to use import/export options in the subscriptions fragment - Includes instructions for each service (in the import fragment/screen)
|
@ -246,13 +246,6 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
|
||||||
// Utils
|
// Utils
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
if (DEBUG) Log.d(TAG, "setTitle() called with: title = [" + title + "]");
|
|
||||||
if (activity != null && activity.getSupportActionBar() != null) {
|
|
||||||
activity.getSupportActionBar().setTitle(title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void openUrlInBrowser(String url) {
|
protected void openUrlInBrowser(String url) {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||||
startActivity(Intent.createChooser(intent, activity.getString(R.string.share_dialog_title)));
|
startActivity(Intent.createChooser(intent, activity.getString(R.string.share_dialog_title)));
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
if (DEBUG) Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu + "], inflater = [" + inflater + "]");
|
if (DEBUG) Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu + "], inflater = [" + inflater + "]");
|
||||||
inflater.inflate(R.menu.main_fragment_menu, menu);
|
inflater.inflate(R.menu.main_fragment_menu, menu);
|
||||||
SubMenu kioskMenu = menu.addSubMenu(getString(R.string.kiosk));
|
SubMenu kioskMenu = menu.addSubMenu(Menu.NONE, Menu.NONE, 200, getString(R.string.kiosk));
|
||||||
try {
|
try {
|
||||||
createKioskMenu(kioskMenu, inflater);
|
createKioskMenu(kioskMenu, inflater);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -141,8 +141,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
|
||||||
@Override
|
@Override
|
||||||
public void selected(StreamInfoItem selectedItem) {
|
public void selected(StreamInfoItem selectedItem) {
|
||||||
onItemSelected(selectedItem);
|
onItemSelected(selectedItem);
|
||||||
NavigationHelper.openVideoDetailFragment(
|
NavigationHelper.openVideoDetailFragment(useAsFrontPage ? getParentFragment().getFragmentManager() : getFragmentManager(),
|
||||||
useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(),
|
|
||||||
selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName());
|
selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,8 +155,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
|
||||||
@Override
|
@Override
|
||||||
public void selected(ChannelInfoItem selectedItem) {
|
public void selected(ChannelInfoItem selectedItem) {
|
||||||
onItemSelected(selectedItem);
|
onItemSelected(selectedItem);
|
||||||
NavigationHelper.openChannelFragment(
|
NavigationHelper.openChannelFragment(useAsFrontPage ? getParentFragment().getFragmentManager() : getFragmentManager(),
|
||||||
useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(),
|
|
||||||
selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName());
|
selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -166,8 +164,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
|
||||||
@Override
|
@Override
|
||||||
public void selected(PlaylistInfoItem selectedItem) {
|
public void selected(PlaylistInfoItem selectedItem) {
|
||||||
onItemSelected(selectedItem);
|
onItemSelected(selectedItem);
|
||||||
NavigationHelper.openPlaylistFragment(
|
NavigationHelper.openPlaylistFragment(useAsFrontPage ? getParentFragment().getFragmentManager() : getFragmentManager(),
|
||||||
useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(),
|
|
||||||
selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName());
|
selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -230,7 +227,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
|
||||||
ActionBar supportActionBar = activity.getSupportActionBar();
|
ActionBar supportActionBar = activity.getSupportActionBar();
|
||||||
if (supportActionBar != null) {
|
if (supportActionBar != null) {
|
||||||
supportActionBar.setDisplayShowTitleEnabled(true);
|
supportActionBar.setDisplayShowTitleEnabled(true);
|
||||||
if(useAsFrontPage) {
|
if (useAsFrontPage) {
|
||||||
supportActionBar.setDisplayHomeAsUpEnabled(false);
|
supportActionBar.setDisplayHomeAsUpEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
@ -277,9 +274,8 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showListFooter(final boolean show) {
|
public void showListFooter(final boolean show) {
|
||||||
itemsList.post(new Runnable() {
|
itemsList.post(() -> {
|
||||||
@Override
|
if (infoListAdapter != null && itemsList != null) {
|
||||||
public void run() {
|
|
||||||
infoListAdapter.showFooter(show);
|
infoListAdapter.showFooter(show);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package org.schabi.newpipe.fragments.subscription;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
|
import icepick.Icepick;
|
||||||
|
import icepick.State;
|
||||||
|
|
||||||
|
public class ImportConfirmationDialog extends DialogFragment {
|
||||||
|
@State
|
||||||
|
protected Intent resultServiceIntent;
|
||||||
|
|
||||||
|
public void setResultServiceIntent(Intent resultServiceIntent) {
|
||||||
|
this.resultServiceIntent = resultServiceIntent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void show(@NonNull Fragment fragment, @NonNull Intent resultServiceIntent) {
|
||||||
|
if (fragment.getFragmentManager() == null) return;
|
||||||
|
|
||||||
|
final ImportConfirmationDialog confirmationDialog = new ImportConfirmationDialog();
|
||||||
|
confirmationDialog.setResultServiceIntent(resultServiceIntent);
|
||||||
|
confirmationDialog.show(fragment.getFragmentManager(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||||
|
return new AlertDialog.Builder(getContext(), ThemeHelper.getDialogTheme(getContext()))
|
||||||
|
.setMessage(R.string.import_network_expensive_warning)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
|
||||||
|
if (resultServiceIntent != null && getContext() != null) {
|
||||||
|
getContext().startService(resultServiceIntent);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if (resultServiceIntent == null) throw new IllegalStateException("Result intent is null");
|
||||||
|
|
||||||
|
Icepick.restoreInstanceState(this, savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
Icepick.saveInstanceState(this, outState);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,30 +1,62 @@
|
||||||
package org.schabi.newpipe.fragments.subscription;
|
package org.schabi.newpipe.fragments.subscription;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.nononsenseapps.filepicker.Utils;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.database.subscription.SubscriptionEntity;
|
import org.schabi.newpipe.database.subscription.SubscriptionEntity;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
|
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||||
import org.schabi.newpipe.fragments.BaseStateFragment;
|
import org.schabi.newpipe.fragments.BaseStateFragment;
|
||||||
import org.schabi.newpipe.info_list.InfoListAdapter;
|
import org.schabi.newpipe.info_list.InfoListAdapter;
|
||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
|
import org.schabi.newpipe.subscription.SubscriptionService;
|
||||||
|
import org.schabi.newpipe.subscription.services.SubscriptionsExportService;
|
||||||
|
import org.schabi.newpipe.subscription.services.SubscriptionsImportService;
|
||||||
|
import org.schabi.newpipe.util.FilePickerActivityHelper;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.OnClickGesture;
|
import org.schabi.newpipe.util.OnClickGesture;
|
||||||
|
import org.schabi.newpipe.util.ServiceHelper;
|
||||||
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
import org.schabi.newpipe.views.CollapsibleView;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
|
@ -33,18 +65,29 @@ import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
import static org.schabi.newpipe.subscription.services.SubscriptionsImportService.KEY_MODE;
|
||||||
|
import static org.schabi.newpipe.subscription.services.SubscriptionsImportService.KEY_VALUE;
|
||||||
|
import static org.schabi.newpipe.subscription.services.SubscriptionsImportService.PREVIOUS_EXPORT_MODE;
|
||||||
|
import static org.schabi.newpipe.util.AnimationUtils.animateRotation;
|
||||||
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
||||||
|
|
||||||
public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEntity>> {
|
public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEntity>> {
|
||||||
private View headerRootLayout;
|
private static final int REQUEST_EXPORT_CODE = 666;
|
||||||
|
private static final int REQUEST_IMPORT_CODE = 667;
|
||||||
|
|
||||||
private InfoListAdapter infoListAdapter;
|
|
||||||
private RecyclerView itemsList;
|
private RecyclerView itemsList;
|
||||||
|
|
||||||
@State
|
@State
|
||||||
protected Parcelable itemsListState;
|
protected Parcelable itemsListState;
|
||||||
|
private InfoListAdapter infoListAdapter;
|
||||||
|
|
||||||
|
private View headerRootLayout;
|
||||||
|
private View whatsNewItemListHeader;
|
||||||
|
private View importExportListHeader;
|
||||||
|
|
||||||
|
@State
|
||||||
|
protected Parcelable importExportOptionsState;
|
||||||
|
private CollapsibleView importExportOptions;
|
||||||
|
|
||||||
/* Used for independent events */
|
|
||||||
private CompositeDisposable disposables = new CompositeDisposable();
|
private CompositeDisposable disposables = new CompositeDisposable();
|
||||||
private SubscriptionService subscriptionService;
|
private SubscriptionService subscriptionService;
|
||||||
|
|
||||||
|
@ -52,39 +95,48 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
|
||||||
// Fragment LifeCycle
|
// Fragment LifeCycle
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||||
super.setUserVisibleHint(isVisibleToUser);
|
super.setUserVisibleHint(isVisibleToUser);
|
||||||
if(isVisibleToUser && activity != null) {
|
if (isVisibleToUser) {
|
||||||
activity.getSupportActionBar()
|
setTitle(getString(R.string.tab_subscriptions));
|
||||||
.setTitle(R.string.tab_subscriptions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
infoListAdapter = new InfoListAdapter(activity);
|
infoListAdapter = new InfoListAdapter(activity);
|
||||||
subscriptionService = SubscriptionService.getInstance();
|
subscriptionService = SubscriptionService.getInstance(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||||
activity.getSupportActionBar().setDisplayShowTitleEnabled(true);
|
|
||||||
activity.setTitle(R.string.tab_subscriptions);
|
|
||||||
if(useAsFrontPage) {
|
|
||||||
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
|
||||||
}
|
|
||||||
return inflater.inflate(R.layout.fragment_subscription, container, false);
|
return inflater.inflate(R.layout.fragment_subscription, container, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
setupBroadcastReceiver();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
itemsListState = itemsList.getLayoutManager().onSaveInstanceState();
|
itemsListState = itemsList.getLayoutManager().onSaveInstanceState();
|
||||||
|
importExportOptionsState = importExportOptions.onSaveInstanceState();
|
||||||
|
|
||||||
|
if (subscriptionBroadcastReceiver != null && activity != null) {
|
||||||
|
LocalBroadcastManager.getInstance(activity).unregisterReceiver(subscriptionBroadcastReceiver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,9 +155,131 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
/*/////////////////////////////////////////////////////////////////////////
|
||||||
|
// Menu
|
||||||
|
/////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
|
||||||
|
ActionBar supportActionBar = activity.getSupportActionBar();
|
||||||
|
if (supportActionBar != null) {
|
||||||
|
supportActionBar.setDisplayShowTitleEnabled(true);
|
||||||
|
setTitle(getString(R.string.tab_subscriptions));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Subscriptions import/export
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
private BroadcastReceiver subscriptionBroadcastReceiver;
|
||||||
|
|
||||||
|
private void setupBroadcastReceiver() {
|
||||||
|
if (activity == null) return;
|
||||||
|
|
||||||
|
if (subscriptionBroadcastReceiver != null) {
|
||||||
|
LocalBroadcastManager.getInstance(activity).unregisterReceiver(subscriptionBroadcastReceiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
final IntentFilter filters = new IntentFilter();
|
||||||
|
filters.addAction(SubscriptionsExportService.EXPORT_COMPLETE_ACTION);
|
||||||
|
filters.addAction(SubscriptionsImportService.IMPORT_COMPLETE_ACTION);
|
||||||
|
subscriptionBroadcastReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (importExportOptions != null) importExportOptions.collapse();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LocalBroadcastManager.getInstance(activity).registerReceiver(subscriptionBroadcastReceiver, filters);
|
||||||
|
}
|
||||||
|
|
||||||
|
private View addItemView(final String title, @DrawableRes final int icon, ViewGroup container) {
|
||||||
|
final View itemRoot = View.inflate(getContext(), R.layout.subscription_import_export_item, null);
|
||||||
|
final TextView titleView = itemRoot.findViewById(android.R.id.text1);
|
||||||
|
final ImageView iconView = itemRoot.findViewById(android.R.id.icon1);
|
||||||
|
|
||||||
|
titleView.setText(title);
|
||||||
|
iconView.setImageResource(icon);
|
||||||
|
|
||||||
|
container.addView(itemRoot);
|
||||||
|
return itemRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupImportFromItems(final ViewGroup listHolder) {
|
||||||
|
final View previousBackupItem = addItemView(getString(R.string.previous_export), ThemeHelper.resolveResourceIdFromAttr(getContext(), R.attr.ic_backup), listHolder);
|
||||||
|
previousBackupItem.setOnClickListener(item -> onImportPreviousSelected());
|
||||||
|
|
||||||
|
final int iconColor = ThemeHelper.isLightThemeSelected(getContext()) ? Color.BLACK : Color.WHITE;
|
||||||
|
final String[] services = getResources().getStringArray(R.array.service_list);
|
||||||
|
for (String serviceName : services) {
|
||||||
|
try {
|
||||||
|
final StreamingService service = NewPipe.getService(serviceName);
|
||||||
|
|
||||||
|
final SubscriptionExtractor subscriptionExtractor = service.getSubscriptionExtractor();
|
||||||
|
if (subscriptionExtractor == null) continue;
|
||||||
|
|
||||||
|
final List<SubscriptionExtractor.ContentSource> supportedSources = subscriptionExtractor.getSupportedSources();
|
||||||
|
if (supportedSources.isEmpty()) continue;
|
||||||
|
|
||||||
|
final View itemView = addItemView(serviceName, ServiceHelper.getIcon(service.getServiceId()), listHolder);
|
||||||
|
final ImageView iconView = itemView.findViewById(android.R.id.icon1);
|
||||||
|
iconView.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
|
itemView.setOnClickListener(selectedItem -> onImportFromServiceSelected(service.getServiceId()));
|
||||||
|
} catch (ExtractionException e) {
|
||||||
|
throw new RuntimeException("Services array contains an entry that it's not a valid service name (" + serviceName + ")", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupExportToItems(final ViewGroup listHolder) {
|
||||||
|
final View previousBackupItem = addItemView(getString(R.string.file), ThemeHelper.resolveResourceIdFromAttr(getContext(), R.attr.ic_save), listHolder);
|
||||||
|
previousBackupItem.setOnClickListener(item -> onExportSelected());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onImportFromServiceSelected(int serviceId) {
|
||||||
|
if (getParentFragment() == null) return;
|
||||||
|
NavigationHelper.openSubscriptionsImportFragment(getParentFragment().getFragmentManager(), serviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onImportPreviousSelected() {
|
||||||
|
startActivityForResult(FilePickerActivityHelper.chooseSingleFile(activity), REQUEST_IMPORT_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onExportSelected() {
|
||||||
|
final String date = new SimpleDateFormat("yyyyMMddHHmm", Locale.ENGLISH).format(new Date());
|
||||||
|
final String exportName = "newpipe_subscriptions_" + date + ".json";
|
||||||
|
final File exportFile = new File(Environment.getExternalStorageDirectory(), exportName);
|
||||||
|
|
||||||
|
startActivityForResult(FilePickerActivityHelper.chooseFileToSave(activity, exportFile.getAbsolutePath()), REQUEST_EXPORT_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (data != null && data.getData() != null && resultCode == Activity.RESULT_OK) {
|
||||||
|
if (requestCode == REQUEST_EXPORT_CODE) {
|
||||||
|
final File exportFile = Utils.getFileForUri(data.getData());
|
||||||
|
if (!exportFile.getParentFile().canWrite() || !exportFile.getParentFile().canRead()) {
|
||||||
|
Toast.makeText(activity, R.string.invalid_directory, Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
activity.startService(new Intent(activity, SubscriptionsExportService.class)
|
||||||
|
.putExtra(SubscriptionsExportService.KEY_FILE_PATH, exportFile.getAbsolutePath()));
|
||||||
|
}
|
||||||
|
} else if (requestCode == REQUEST_IMPORT_CODE) {
|
||||||
|
final String path = Utils.getFileForUri(data.getData()).getAbsolutePath();
|
||||||
|
ImportConfirmationDialog.show(this, new Intent(activity, SubscriptionsImportService.class)
|
||||||
|
.putExtra(KEY_MODE, PREVIOUS_EXPORT_MODE)
|
||||||
|
.putExtra(KEY_VALUE, path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*/////////////////////////////////////////////////////////////////////////
|
||||||
// Fragment Views
|
// Fragment Views
|
||||||
///////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initViews(View rootView, Bundle savedInstanceState) {
|
protected void initViews(View rootView, Bundle savedInstanceState) {
|
||||||
|
@ -116,9 +290,27 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
|
||||||
itemsList.setLayoutManager(new LinearLayoutManager(activity));
|
itemsList.setLayoutManager(new LinearLayoutManager(activity));
|
||||||
|
|
||||||
infoListAdapter.setHeader(headerRootLayout = activity.getLayoutInflater().inflate(R.layout.subscription_header, itemsList, false));
|
infoListAdapter.setHeader(headerRootLayout = activity.getLayoutInflater().inflate(R.layout.subscription_header, itemsList, false));
|
||||||
infoListAdapter.useMiniItemVariants(true);
|
whatsNewItemListHeader = headerRootLayout.findViewById(R.id.whats_new);
|
||||||
|
importExportListHeader = headerRootLayout.findViewById(R.id.import_export);
|
||||||
|
importExportOptions = headerRootLayout.findViewById(R.id.import_export_options);
|
||||||
|
|
||||||
|
infoListAdapter.useMiniItemVariants(true);
|
||||||
itemsList.setAdapter(infoListAdapter);
|
itemsList.setAdapter(infoListAdapter);
|
||||||
|
|
||||||
|
setupImportFromItems(headerRootLayout.findViewById(R.id.import_from_options));
|
||||||
|
setupExportToItems(headerRootLayout.findViewById(R.id.export_to_options));
|
||||||
|
|
||||||
|
if (importExportOptionsState != null) {
|
||||||
|
importExportOptions.onRestoreInstanceState(importExportOptionsState);
|
||||||
|
importExportOptionsState = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
importExportOptions.addListener(getExpandIconSyncListener(headerRootLayout.findViewById(R.id.import_export_expand_icon)));
|
||||||
|
importExportOptions.ready();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CollapsibleView.StateListener getExpandIconSyncListener(final ImageView iconView) {
|
||||||
|
return newState -> animateRotation(iconView, 250, newState == CollapsibleView.COLLAPSED ? 0 : 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -130,12 +322,14 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
|
||||||
public void selected(ChannelInfoItem selectedItem) {
|
public void selected(ChannelInfoItem selectedItem) {
|
||||||
// Requires the parent fragment to find holder for fragment replacement
|
// Requires the parent fragment to find holder for fragment replacement
|
||||||
NavigationHelper.openChannelFragment(getParentFragment().getFragmentManager(),
|
NavigationHelper.openChannelFragment(getParentFragment().getFragmentManager(),
|
||||||
selectedItem.getServiceId(), selectedItem.url, selectedItem.getName());
|
selectedItem.getServiceId(), selectedItem.getUrl(), selectedItem.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
headerRootLayout.setOnClickListener(view ->
|
//noinspection ConstantConditions
|
||||||
|
whatsNewItemListHeader.setOnClickListener(v ->
|
||||||
NavigationHelper.openWhatsNewFragment(getParentFragment().getFragmentManager()));
|
NavigationHelper.openWhatsNewFragment(getParentFragment().getFragmentManager()));
|
||||||
|
importExportListHeader.setOnClickListener(v -> importExportOptions.switchState());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetFragment() {
|
private void resetFragment() {
|
||||||
|
@ -189,6 +383,7 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
|
||||||
infoListAdapter.clearStreamItemList();
|
infoListAdapter.clearStreamItemList();
|
||||||
|
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
|
whatsNewItemListHeader.setVisibility(View.GONE);
|
||||||
showEmptyState();
|
showEmptyState();
|
||||||
} else {
|
} else {
|
||||||
infoListAdapter.addInfoItemList(getSubscriptionItems(result));
|
infoListAdapter.addInfoItemList(getSubscriptionItems(result));
|
||||||
|
@ -196,7 +391,7 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
|
||||||
itemsList.getLayoutManager().onRestoreInstanceState(itemsListState);
|
itemsList.getLayoutManager().onRestoreInstanceState(itemsListState);
|
||||||
itemsListState = null;
|
itemsListState = null;
|
||||||
}
|
}
|
||||||
|
whatsNewItemListHeader.setVisibility(View.VISIBLE);
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,12 +426,6 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
|
||||||
animateView(itemsList, true, 200);
|
animateView(itemsList, true, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showEmptyState() {
|
|
||||||
super.showEmptyState();
|
|
||||||
animateView(itemsList, false, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Fragment Error Handling
|
// Fragment Error Handling
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -0,0 +1,210 @@
|
||||||
|
package org.schabi.newpipe.fragments.subscription;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
|
import android.support.v4.text.util.LinkifyCompat;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.text.util.Linkify;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.nononsenseapps.filepicker.Utils;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.BaseFragment;
|
||||||
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
|
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
|
||||||
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
|
import org.schabi.newpipe.report.UserAction;
|
||||||
|
import org.schabi.newpipe.subscription.services.SubscriptionsImportService;
|
||||||
|
import org.schabi.newpipe.util.Constants;
|
||||||
|
import org.schabi.newpipe.util.FilePickerActivityHelper;
|
||||||
|
import org.schabi.newpipe.util.ServiceHelper;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import icepick.State;
|
||||||
|
|
||||||
|
import static org.schabi.newpipe.extractor.subscription.SubscriptionExtractor.ContentSource.CHANNEL_URL;
|
||||||
|
import static org.schabi.newpipe.subscription.services.SubscriptionsImportService.CHANNEL_URL_MODE;
|
||||||
|
import static org.schabi.newpipe.subscription.services.SubscriptionsImportService.INPUT_STREAM_MODE;
|
||||||
|
import static org.schabi.newpipe.subscription.services.SubscriptionsImportService.KEY_MODE;
|
||||||
|
import static org.schabi.newpipe.subscription.services.SubscriptionsImportService.KEY_VALUE;
|
||||||
|
|
||||||
|
public class SubscriptionsImportFragment extends BaseFragment {
|
||||||
|
private static final int REQUEST_IMPORT_FILE_CODE = 666;
|
||||||
|
|
||||||
|
@State
|
||||||
|
protected int currentServiceId = Constants.NO_SERVICE_ID;
|
||||||
|
|
||||||
|
private List<SubscriptionExtractor.ContentSource> supportedSources;
|
||||||
|
private String relatedUrl;
|
||||||
|
@StringRes
|
||||||
|
private int instructionsString;
|
||||||
|
|
||||||
|
public static SubscriptionsImportFragment getInstance(int serviceId) {
|
||||||
|
SubscriptionsImportFragment instance = new SubscriptionsImportFragment();
|
||||||
|
instance.setInitialData(serviceId);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitialData(int serviceId) {
|
||||||
|
this.currentServiceId = serviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Views
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
private TextView infoTextView;
|
||||||
|
|
||||||
|
private EditText inputText;
|
||||||
|
private Button inputButton;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Fragment LifeCycle
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setupServiceVariables();
|
||||||
|
if (supportedSources.isEmpty() && currentServiceId != Constants.NO_SERVICE_ID) {
|
||||||
|
ErrorActivity.reportError(activity, Collections.emptyList(), null, null, ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE,
|
||||||
|
NewPipe.getNameOfService(currentServiceId), "Service don't support importing", R.string.general_error));
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||||
|
super.setUserVisibleHint(isVisibleToUser);
|
||||||
|
if (isVisibleToUser) {
|
||||||
|
setTitle(getString(R.string.import_title));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
return inflater.inflate(R.layout.fragment_import, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*/////////////////////////////////////////////////////////////////////////
|
||||||
|
// Fragment Views
|
||||||
|
/////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initViews(View rootView, Bundle savedInstanceState) {
|
||||||
|
super.initViews(rootView, savedInstanceState);
|
||||||
|
|
||||||
|
inputButton = rootView.findViewById(R.id.input_button);
|
||||||
|
inputText = rootView.findViewById(R.id.input_text);
|
||||||
|
|
||||||
|
infoTextView = rootView.findViewById(R.id.info_text_view);
|
||||||
|
|
||||||
|
// TODO: Support services that can import from more than one source (show the option to the user)
|
||||||
|
if (supportedSources.contains(CHANNEL_URL)) {
|
||||||
|
inputButton.setText(R.string.import_title);
|
||||||
|
inputText.setVisibility(View.VISIBLE);
|
||||||
|
inputText.setHint(ServiceHelper.getImportInstructionsHint(currentServiceId));
|
||||||
|
} else {
|
||||||
|
inputButton.setText(R.string.import_file_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (instructionsString != 0) {
|
||||||
|
if (TextUtils.isEmpty(relatedUrl)) {
|
||||||
|
setInfoText(getString(instructionsString));
|
||||||
|
} else {
|
||||||
|
setInfoText(getString(instructionsString, relatedUrl));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setInfoText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionBar supportActionBar = activity.getSupportActionBar();
|
||||||
|
if (supportActionBar != null) {
|
||||||
|
supportActionBar.setDisplayShowTitleEnabled(true);
|
||||||
|
setTitle(getString(R.string.import_title));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initListeners() {
|
||||||
|
super.initListeners();
|
||||||
|
inputButton.setOnClickListener(v -> onImportClicked());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onImportClicked() {
|
||||||
|
if (inputText.getVisibility() == View.VISIBLE) {
|
||||||
|
final String value = inputText.getText().toString();
|
||||||
|
if (!value.isEmpty()) onImportUrl(value);
|
||||||
|
} else {
|
||||||
|
onImportFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onImportUrl(String value) {
|
||||||
|
ImportConfirmationDialog.show(this, new Intent(activity, SubscriptionsImportService.class)
|
||||||
|
.putExtra(KEY_MODE, CHANNEL_URL_MODE)
|
||||||
|
.putExtra(KEY_VALUE, value)
|
||||||
|
.putExtra(Constants.KEY_SERVICE_ID, currentServiceId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onImportFile() {
|
||||||
|
startActivityForResult(FilePickerActivityHelper.chooseSingleFile(activity), REQUEST_IMPORT_FILE_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (data == null) return;
|
||||||
|
|
||||||
|
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_IMPORT_FILE_CODE && data.getData() != null) {
|
||||||
|
final String path = Utils.getFileForUri(data.getData()).getAbsolutePath();
|
||||||
|
ImportConfirmationDialog.show(this, new Intent(activity, SubscriptionsImportService.class)
|
||||||
|
.putExtra(KEY_MODE, INPUT_STREAM_MODE)
|
||||||
|
.putExtra(KEY_VALUE, path)
|
||||||
|
.putExtra(Constants.KEY_SERVICE_ID, currentServiceId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Subscriptions
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private void setupServiceVariables() {
|
||||||
|
if (currentServiceId != Constants.NO_SERVICE_ID) {
|
||||||
|
try {
|
||||||
|
final SubscriptionExtractor extractor = NewPipe.getService(currentServiceId).getSubscriptionExtractor();
|
||||||
|
supportedSources = extractor.getSupportedSources();
|
||||||
|
relatedUrl = extractor.getRelatedUrl();
|
||||||
|
instructionsString = ServiceHelper.getImportInstructions(currentServiceId);
|
||||||
|
return;
|
||||||
|
} catch (ExtractionException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
supportedSources = Collections.emptyList();
|
||||||
|
relatedUrl = null;
|
||||||
|
instructionsString = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setInfoText(String infoString) {
|
||||||
|
infoTextView.setText(infoString);
|
||||||
|
LinkifyCompat.addLinks(infoTextView, Linkify.WEB_URLS);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,22 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2018 Mauricio Colli <mauriciocolli@outlook.com>
|
||||||
|
* AnimationUtils.java is part of NewPipe
|
||||||
|
*
|
||||||
|
* License: GPL-3.0+
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.schabi.newpipe.util;
|
package org.schabi.newpipe.util;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
@ -19,7 +38,9 @@ public class AnimationUtils {
|
||||||
private static final boolean DEBUG = MainActivity.DEBUG;
|
private static final boolean DEBUG = MainActivity.DEBUG;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
ALPHA, SCALE_AND_ALPHA, LIGHT_SCALE_AND_ALPHA, SLIDE_AND_ALPHA, LIGHT_SLIDE_AND_ALPHA
|
ALPHA,
|
||||||
|
SCALE_AND_ALPHA, LIGHT_SCALE_AND_ALPHA,
|
||||||
|
SLIDE_AND_ALPHA, LIGHT_SLIDE_AND_ALPHA
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void animateView(View view, boolean enterOrExit, long duration) {
|
public static void animateView(View view, boolean enterOrExit, long duration) {
|
||||||
|
@ -168,6 +189,58 @@ public class AnimationUtils {
|
||||||
viewPropertyAnimator.start();
|
viewPropertyAnimator.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ValueAnimator animateHeight(final View view, long duration, int targetHeight) {
|
||||||
|
final int height = view.getHeight();
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "animateHeight: duration = [" + duration + "], from " + height + " to → " + targetHeight + " in: " + view);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueAnimator animator = ValueAnimator.ofFloat(height, targetHeight);
|
||||||
|
animator.setInterpolator(new FastOutSlowInInterpolator());
|
||||||
|
animator.setDuration(duration);
|
||||||
|
animator.addUpdateListener(animation -> {
|
||||||
|
final float value = (float) animation.getAnimatedValue();
|
||||||
|
view.getLayoutParams().height = (int) value;
|
||||||
|
view.requestLayout();
|
||||||
|
});
|
||||||
|
animator.addListener(new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
view.getLayoutParams().height = targetHeight;
|
||||||
|
view.requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationCancel(Animator animation) {
|
||||||
|
view.getLayoutParams().height = targetHeight;
|
||||||
|
view.requestLayout();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
animator.start();
|
||||||
|
|
||||||
|
return animator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void animateRotation(final View view, long duration, int targetRotation) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "animateRotation: duration = [" + duration + "], from " + view.getRotation() + " to → " + targetRotation + " in: " + view);
|
||||||
|
}
|
||||||
|
view.animate().setListener(null).cancel();
|
||||||
|
|
||||||
|
view.animate().rotation(targetRotation).setDuration(duration).setInterpolator(new FastOutSlowInInterpolator())
|
||||||
|
.setListener(new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationCancel(Animator animation) {
|
||||||
|
view.setRotation(targetRotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
view.setRotation(targetRotation);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Internals
|
// Internals
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
|
@ -1,10 +1,32 @@
|
||||||
package org.schabi.newpipe.util;
|
package org.schabi.newpipe.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.Loader;
|
||||||
|
import android.support.v7.util.SortedList;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.nononsenseapps.filepicker.AbstractFilePickerFragment;
|
||||||
|
import com.nononsenseapps.filepicker.FilePickerFragment;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class FilePickerActivityHelper extends com.nononsenseapps.filepicker.FilePickerActivity {
|
public class FilePickerActivityHelper extends com.nononsenseapps.filepicker.FilePickerActivity {
|
||||||
|
|
||||||
|
private CustomFilePickerFragment currentFragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
if(ThemeHelper.isLightThemeSelected(this)) {
|
if(ThemeHelper.isLightThemeSelected(this)) {
|
||||||
|
@ -14,4 +36,98 @@ public class FilePickerActivityHelper extends com.nononsenseapps.filepicker.File
|
||||||
}
|
}
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
// If at top most level, normal behaviour
|
||||||
|
if (currentFragment.isBackTop()) {
|
||||||
|
super.onBackPressed();
|
||||||
|
} else {
|
||||||
|
// Else go up
|
||||||
|
currentFragment.goUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AbstractFilePickerFragment<File> getFragment(@Nullable String startPath, int mode, boolean allowMultiple, boolean allowCreateDir, boolean allowExistingFile, boolean singleClick) {
|
||||||
|
final CustomFilePickerFragment fragment = new CustomFilePickerFragment();
|
||||||
|
fragment.setArgs(startPath != null ? startPath : Environment.getExternalStorageDirectory().getPath(),
|
||||||
|
mode, allowMultiple, allowCreateDir, allowExistingFile, singleClick);
|
||||||
|
return currentFragment = fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Intent chooseSingleFile(@NonNull Context context) {
|
||||||
|
return new Intent(context, FilePickerActivityHelper.class)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, false)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_SINGLE_CLICK, true)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_MODE, FilePickerActivityHelper.MODE_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Intent chooseFileToSave(@NonNull Context context, @Nullable String startPath) {
|
||||||
|
return new Intent(context, FilePickerActivityHelper.class)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, true)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_EXISTING_FILE, true)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_START_PATH, startPath)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_MODE, FilePickerActivityHelper.MODE_NEW_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Internal
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
public static class CustomFilePickerFragment extends FilePickerFragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
final RecyclerView.ViewHolder viewHolder = super.onCreateViewHolder(parent, viewType);
|
||||||
|
|
||||||
|
final View view = viewHolder.itemView.findViewById(android.R.id.text1);
|
||||||
|
if (view instanceof TextView) {
|
||||||
|
((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.file_picker_items_text_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
return viewHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClickOk(@NonNull View view) {
|
||||||
|
if (mode == MODE_NEW_FILE && getNewFileName().isEmpty()) {
|
||||||
|
if (mToast != null) mToast.cancel();
|
||||||
|
mToast = Toast.makeText(getActivity(), R.string.file_name_empty_error, Toast.LENGTH_SHORT);
|
||||||
|
mToast.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onClickOk(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getBackTop() {
|
||||||
|
if (getArguments() == null) return Environment.getExternalStorageDirectory();
|
||||||
|
|
||||||
|
final String path = getArguments().getString(KEY_START_PATH, "/");
|
||||||
|
if (path.contains(Environment.getExternalStorageDirectory().getPath())) {
|
||||||
|
return Environment.getExternalStorageDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
return getPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBackTop() {
|
||||||
|
return compareFiles(mCurrentPath, getBackTop()) == 0 || compareFiles(mCurrentPath, new File("/")) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFinished(Loader<SortedList<File>> loader, SortedList<File> data) {
|
||||||
|
super.onLoadFinished(loader, data);
|
||||||
|
layoutManager.scrollToPosition(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.schabi.newpipe.util;
|
package org.schabi.newpipe.util;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -11,6 +12,7 @@ import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -38,6 +40,7 @@ import org.schabi.newpipe.fragments.list.search.SearchFragment;
|
||||||
import org.schabi.newpipe.fragments.local.bookmark.LastPlayedFragment;
|
import org.schabi.newpipe.fragments.local.bookmark.LastPlayedFragment;
|
||||||
import org.schabi.newpipe.fragments.local.bookmark.LocalPlaylistFragment;
|
import org.schabi.newpipe.fragments.local.bookmark.LocalPlaylistFragment;
|
||||||
import org.schabi.newpipe.fragments.local.bookmark.MostPlayedFragment;
|
import org.schabi.newpipe.fragments.local.bookmark.MostPlayedFragment;
|
||||||
|
import org.schabi.newpipe.fragments.subscription.SubscriptionsImportFragment;
|
||||||
import org.schabi.newpipe.history.HistoryActivity;
|
import org.schabi.newpipe.history.HistoryActivity;
|
||||||
import org.schabi.newpipe.player.BackgroundPlayer;
|
import org.schabi.newpipe.player.BackgroundPlayer;
|
||||||
import org.schabi.newpipe.player.BackgroundPlayerActivity;
|
import org.schabi.newpipe.player.BackgroundPlayerActivity;
|
||||||
|
@ -247,6 +250,12 @@ public class NavigationHelper {
|
||||||
// Through FragmentManager
|
// Through FragmentManager
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@SuppressLint("CommitTransaction")
|
||||||
|
private static FragmentTransaction defaultTransaction(FragmentManager fragmentManager) {
|
||||||
|
return fragmentManager.beginTransaction()
|
||||||
|
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out);
|
||||||
|
}
|
||||||
|
|
||||||
public static void gotoMainFragment(FragmentManager fragmentManager) {
|
public static void gotoMainFragment(FragmentManager fragmentManager) {
|
||||||
ImageLoader.getInstance().clearMemoryCache();
|
ImageLoader.getInstance().clearMemoryCache();
|
||||||
|
|
||||||
|
@ -258,8 +267,7 @@ public class NavigationHelper {
|
||||||
InfoCache.getInstance().trimCache();
|
InfoCache.getInstance().trimCache();
|
||||||
|
|
||||||
fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
fragmentManager.beginTransaction()
|
defaultTransaction(fragmentManager)
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, new MainFragment())
|
.replace(R.id.fragment_holder, new MainFragment())
|
||||||
.addToBackStack(MAIN_FRAGMENT_TAG)
|
.addToBackStack(MAIN_FRAGMENT_TAG)
|
||||||
.commit();
|
.commit();
|
||||||
|
@ -276,8 +284,7 @@ public class NavigationHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openSearchFragment(FragmentManager fragmentManager, int serviceId, String query) {
|
public static void openSearchFragment(FragmentManager fragmentManager, int serviceId, String query) {
|
||||||
fragmentManager.beginTransaction()
|
defaultTransaction(fragmentManager)
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, SearchFragment.getInstance(serviceId, query))
|
.replace(R.id.fragment_holder, SearchFragment.getInstance(serviceId, query))
|
||||||
.addToBackStack(SEARCH_FRAGMENT_TAG)
|
.addToBackStack(SEARCH_FRAGMENT_TAG)
|
||||||
.commit();
|
.commit();
|
||||||
|
@ -301,8 +308,7 @@ public class NavigationHelper {
|
||||||
VideoDetailFragment instance = VideoDetailFragment.getInstance(serviceId, url, title);
|
VideoDetailFragment instance = VideoDetailFragment.getInstance(serviceId, url, title);
|
||||||
instance.setAutoplay(autoPlay);
|
instance.setAutoplay(autoPlay);
|
||||||
|
|
||||||
fragmentManager.beginTransaction()
|
defaultTransaction(fragmentManager)
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, instance)
|
.replace(R.id.fragment_holder, instance)
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
|
@ -310,8 +316,7 @@ public class NavigationHelper {
|
||||||
|
|
||||||
public static void openChannelFragment(FragmentManager fragmentManager, int serviceId, String url, String name) {
|
public static void openChannelFragment(FragmentManager fragmentManager, int serviceId, String url, String name) {
|
||||||
if (name == null) name = "";
|
if (name == null) name = "";
|
||||||
fragmentManager.beginTransaction()
|
defaultTransaction(fragmentManager)
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, ChannelFragment.getInstance(serviceId, url, name))
|
.replace(R.id.fragment_holder, ChannelFragment.getInstance(serviceId, url, name))
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
|
@ -319,25 +324,21 @@ public class NavigationHelper {
|
||||||
|
|
||||||
public static void openPlaylistFragment(FragmentManager fragmentManager, int serviceId, String url, String name) {
|
public static void openPlaylistFragment(FragmentManager fragmentManager, int serviceId, String url, String name) {
|
||||||
if (name == null) name = "";
|
if (name == null) name = "";
|
||||||
fragmentManager.beginTransaction()
|
defaultTransaction(fragmentManager)
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, PlaylistFragment.getInstance(serviceId, url, name))
|
.replace(R.id.fragment_holder, PlaylistFragment.getInstance(serviceId, url, name))
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openWhatsNewFragment(FragmentManager fragmentManager) {
|
public static void openWhatsNewFragment(FragmentManager fragmentManager) {
|
||||||
fragmentManager.beginTransaction()
|
defaultTransaction(fragmentManager)
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, new FeedFragment())
|
.replace(R.id.fragment_holder, new FeedFragment())
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openKioskFragment(FragmentManager fragmentManager, int serviceId, String kioskId)
|
public static void openKioskFragment(FragmentManager fragmentManager, int serviceId, String kioskId) throws ExtractionException {
|
||||||
throws ExtractionException {
|
defaultTransaction(fragmentManager)
|
||||||
fragmentManager.beginTransaction()
|
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, KioskFragment.getInstance(serviceId, kioskId))
|
.replace(R.id.fragment_holder, KioskFragment.getInstance(serviceId, kioskId))
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
|
@ -345,28 +346,33 @@ public class NavigationHelper {
|
||||||
|
|
||||||
public static void openLocalPlaylistFragment(FragmentManager fragmentManager, long playlistId, String name) {
|
public static void openLocalPlaylistFragment(FragmentManager fragmentManager, long playlistId, String name) {
|
||||||
if (name == null) name = "";
|
if (name == null) name = "";
|
||||||
fragmentManager.beginTransaction()
|
defaultTransaction(fragmentManager)
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, LocalPlaylistFragment.getInstance(playlistId, name))
|
.replace(R.id.fragment_holder, LocalPlaylistFragment.getInstance(playlistId, name))
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openLastPlayedFragment(FragmentManager fragmentManager) {
|
public static void openLastPlayedFragment(FragmentManager fragmentManager) {
|
||||||
fragmentManager.beginTransaction()
|
defaultTransaction(fragmentManager)
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, new LastPlayedFragment())
|
.replace(R.id.fragment_holder, new LastPlayedFragment())
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openMostPlayedFragment(FragmentManager fragmentManager) {
|
public static void openMostPlayedFragment(FragmentManager fragmentManager) {
|
||||||
fragmentManager.beginTransaction()
|
defaultTransaction(fragmentManager)
|
||||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out, R.animator.custom_fade_in, R.animator.custom_fade_out)
|
|
||||||
.replace(R.id.fragment_holder, new MostPlayedFragment())
|
.replace(R.id.fragment_holder, new MostPlayedFragment())
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void openSubscriptionsImportFragment(FragmentManager fragmentManager, int serviceId) {
|
||||||
|
defaultTransaction(fragmentManager)
|
||||||
|
.replace(R.id.fragment_holder, SubscriptionsImportFragment.getInstance(serviceId))
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Through Intents
|
// Through Intents
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.schabi.newpipe.util;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
|
|
||||||
import org.schabi.newpipe.BuildConfig;
|
import org.schabi.newpipe.BuildConfig;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
@ -26,6 +27,39 @@ public class ServiceHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a resource string with instructions for importing subscriptions for each service.
|
||||||
|
*
|
||||||
|
* @return the string resource containing the instructions or -1 if the service don't support it
|
||||||
|
*/
|
||||||
|
@StringRes
|
||||||
|
public static int getImportInstructions(int serviceId) {
|
||||||
|
switch (serviceId) {
|
||||||
|
case 0:
|
||||||
|
return R.string.import_youtube_instructions;
|
||||||
|
case 1:
|
||||||
|
return R.string.import_soundcloud_instructions;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For services that support importing from a channel url, return a hint that will
|
||||||
|
* be used in the EditText that the user will type in his channel url.
|
||||||
|
*
|
||||||
|
* @return the hint's string resource or -1 if the service don't support it
|
||||||
|
*/
|
||||||
|
@StringRes
|
||||||
|
public static int getImportInstructionsHint(int serviceId) {
|
||||||
|
switch (serviceId) {
|
||||||
|
case 1:
|
||||||
|
return R.string.import_soundcloud_instructions_hint;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int getSelectedServiceId(Context context) {
|
public static int getSelectedServiceId(Context context) {
|
||||||
if (BuildConfig.BUILD_TYPE.equals("release")) return DEFAULT_FALLBACK_SERVICE.getServiceId();
|
if (BuildConfig.BUILD_TYPE.equals("release")) return DEFAULT_FALLBACK_SERVICE.getServiceId();
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2018 Mauricio Colli <mauriciocolli@outlook.com>
|
||||||
|
* ThemeHelper.java is part of NewPipe
|
||||||
|
*
|
||||||
|
* License: GPL-3.0+
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.schabi.newpipe.util;
|
package org.schabi.newpipe.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -5,6 +24,9 @@ import android.content.res.TypedArray;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.AttrRes;
|
import android.support.annotation.AttrRes;
|
||||||
import android.support.annotation.StyleRes;
|
import android.support.annotation.StyleRes;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
@ -41,16 +63,57 @@ public class ThemeHelper {
|
||||||
* @param context context to get the preference
|
* @param context context to get the preference
|
||||||
*/
|
*/
|
||||||
public static boolean isLightThemeSelected(Context context) {
|
public static boolean isLightThemeSelected(Context context) {
|
||||||
return getSelectedTheme(context).equals(context.getResources().getString(R.string.light_theme_key));
|
return getSelectedThemeString(context).equals(context.getResources().getString(R.string.light_theme_key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and return a wrapped context with the default selected theme set.
|
||||||
|
*
|
||||||
|
* @param baseContext the base context for the wrapper
|
||||||
|
* @return a wrapped-styled context
|
||||||
|
*/
|
||||||
|
public static Context getThemedContext(Context baseContext) {
|
||||||
|
return new ContextThemeWrapper(baseContext, getThemeForService(baseContext, -1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the selected theme without being styled to any service (see {@link #getThemeForService(Context, int)}).
|
||||||
|
*
|
||||||
|
* @param context context to get the selected theme
|
||||||
|
* @return the selected style (the default one)
|
||||||
|
*/
|
||||||
|
@StyleRes
|
||||||
|
public static int getDefaultTheme(Context context) {
|
||||||
|
return getThemeForService(context, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a dialog theme styled according to the (default) selected theme.
|
||||||
|
*
|
||||||
|
* @param context context to get the selected theme
|
||||||
|
* @return the dialog style (the default one)
|
||||||
|
*/
|
||||||
|
@StyleRes
|
||||||
|
public static int getDialogTheme(Context context) {
|
||||||
|
return isLightThemeSelected(context) ? R.style.LightDialogTheme : R.style.DarkDialogTheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the selected theme styled according to the serviceId.
|
||||||
|
*
|
||||||
|
* @param context context to get the selected theme
|
||||||
|
* @param serviceId return a theme styled to this service,
|
||||||
|
* -1 to get the default
|
||||||
|
* @return the selected style (styled)
|
||||||
|
*/
|
||||||
@StyleRes
|
@StyleRes
|
||||||
public static int getThemeForService(Context context, int serviceId) {
|
public static int getThemeForService(Context context, int serviceId) {
|
||||||
String lightTheme = context.getResources().getString(R.string.light_theme_key);
|
String lightTheme = context.getResources().getString(R.string.light_theme_key);
|
||||||
String darkTheme = context.getResources().getString(R.string.dark_theme_key);
|
String darkTheme = context.getResources().getString(R.string.dark_theme_key);
|
||||||
String blackTheme = context.getResources().getString(R.string.black_theme_key);
|
String blackTheme = context.getResources().getString(R.string.black_theme_key);
|
||||||
|
|
||||||
String selectedTheme = getSelectedTheme(context);
|
String selectedTheme = getSelectedThemeString(context);
|
||||||
|
|
||||||
int defaultTheme = R.style.DarkTheme;
|
int defaultTheme = R.style.DarkTheme;
|
||||||
if (selectedTheme.equals(lightTheme)) defaultTheme = R.style.LightTheme;
|
if (selectedTheme.equals(lightTheme)) defaultTheme = R.style.LightTheme;
|
||||||
|
@ -83,19 +146,13 @@ public class ThemeHelper {
|
||||||
return defaultTheme;
|
return defaultTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSelectedTheme(Context context) {
|
|
||||||
String themeKey = context.getString(R.string.theme_key);
|
|
||||||
String defaultTheme = context.getResources().getString(R.string.default_theme_value);
|
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getString(themeKey, defaultTheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
@StyleRes
|
@StyleRes
|
||||||
public static int getSettingsThemeStyle(Context context) {
|
public static int getSettingsThemeStyle(Context context) {
|
||||||
String lightTheme = context.getResources().getString(R.string.light_theme_key);
|
String lightTheme = context.getResources().getString(R.string.light_theme_key);
|
||||||
String darkTheme = context.getResources().getString(R.string.dark_theme_key);
|
String darkTheme = context.getResources().getString(R.string.dark_theme_key);
|
||||||
String blackTheme = context.getResources().getString(R.string.black_theme_key);
|
String blackTheme = context.getResources().getString(R.string.black_theme_key);
|
||||||
|
|
||||||
String selectedTheme = getSelectedTheme(context);
|
String selectedTheme = getSelectedThemeString(context);
|
||||||
|
|
||||||
if (selectedTheme.equals(lightTheme)) return R.style.LightSettingsTheme;
|
if (selectedTheme.equals(lightTheme)) return R.style.LightSettingsTheme;
|
||||||
else if (selectedTheme.equals(blackTheme)) return R.style.BlackSettingsTheme;
|
else if (selectedTheme.equals(blackTheme)) return R.style.BlackSettingsTheme;
|
||||||
|
@ -113,4 +170,24 @@ public class ThemeHelper {
|
||||||
a.recycle();
|
a.recycle();
|
||||||
return attributeResourceId;
|
return attributeResourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a color from an attr styled according to the the context's theme.
|
||||||
|
*/
|
||||||
|
public static int resolveColorFromAttr(Context context, @AttrRes int attrColor) {
|
||||||
|
final TypedValue value = new TypedValue();
|
||||||
|
context.getTheme().resolveAttribute(attrColor, value, true);
|
||||||
|
|
||||||
|
if (value.resourceId != 0) {
|
||||||
|
return ContextCompat.getColor(context, value.resourceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getSelectedThemeString(Context context) {
|
||||||
|
String themeKey = context.getString(R.string.theme_key);
|
||||||
|
String defaultTheme = context.getResources().getString(R.string.default_theme_value);
|
||||||
|
return PreferenceManager.getDefaultSharedPreferences(context).getString(themeKey, defaultTheme);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
230
app/src/main/java/org/schabi/newpipe/views/CollapsibleView.java
Normal file
|
@ -0,0 +1,230 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2018 Mauricio Colli <mauriciocolli@outlook.com>
|
||||||
|
* CollapsibleView.java is part of NewPipe
|
||||||
|
*
|
||||||
|
* License: GPL-3.0+
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.schabi.newpipe.views;
|
||||||
|
|
||||||
|
import android.animation.ValueAnimator;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.support.annotation.IntDef;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.annotation.RequiresApi;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.util.AnimationUtils;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import icepick.Icepick;
|
||||||
|
import icepick.State;
|
||||||
|
|
||||||
|
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||||
|
import static org.schabi.newpipe.MainActivity.DEBUG;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A view that can be fully collapsed and expanded.
|
||||||
|
*/
|
||||||
|
public class CollapsibleView extends LinearLayout {
|
||||||
|
private static final String TAG = CollapsibleView.class.getSimpleName();
|
||||||
|
|
||||||
|
public CollapsibleView(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollapsibleView(Context context, @Nullable AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollapsibleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
public CollapsibleView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Collapse/expand logic
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
private static final int ANIMATION_DURATION = 420;
|
||||||
|
public static final int COLLAPSED = 0, EXPANDED = 1;
|
||||||
|
|
||||||
|
@Retention(SOURCE)
|
||||||
|
@IntDef({COLLAPSED, EXPANDED})
|
||||||
|
public @interface ViewMode {}
|
||||||
|
|
||||||
|
@State @ViewMode int currentState = COLLAPSED;
|
||||||
|
private boolean readyToChangeState;
|
||||||
|
|
||||||
|
private int targetHeight = -1;
|
||||||
|
private ValueAnimator currentAnimator;
|
||||||
|
private List<StateListener> listeners = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method recalculates the height of this view so it <b>must</b> be called when
|
||||||
|
* some child changes (e.g. add new views, change text).
|
||||||
|
*/
|
||||||
|
public void ready() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, getDebugLogString("ready() called"));
|
||||||
|
}
|
||||||
|
|
||||||
|
measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST), MeasureSpec.UNSPECIFIED);
|
||||||
|
targetHeight = getMeasuredHeight();
|
||||||
|
|
||||||
|
getLayoutParams().height = currentState == COLLAPSED ? 0 : targetHeight;
|
||||||
|
requestLayout();
|
||||||
|
broadcastState();
|
||||||
|
|
||||||
|
readyToChangeState = true;
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, getDebugLogString("ready() *after* measuring"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void collapse() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, getDebugLogString("collapse() called"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!readyToChangeState) return;
|
||||||
|
|
||||||
|
final int height = getHeight();
|
||||||
|
if (height == 0) {
|
||||||
|
setCurrentState(COLLAPSED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentAnimator != null && currentAnimator.isRunning()) currentAnimator.cancel();
|
||||||
|
currentAnimator = AnimationUtils.animateHeight(this, ANIMATION_DURATION, 0);
|
||||||
|
|
||||||
|
setCurrentState(COLLAPSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void expand() {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, getDebugLogString("expand() called"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!readyToChangeState) return;
|
||||||
|
|
||||||
|
final int height = getHeight();
|
||||||
|
if (height == this.targetHeight) {
|
||||||
|
setCurrentState(EXPANDED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentAnimator != null && currentAnimator.isRunning()) currentAnimator.cancel();
|
||||||
|
currentAnimator = AnimationUtils.animateHeight(this, ANIMATION_DURATION, this.targetHeight);
|
||||||
|
setCurrentState(EXPANDED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchState() {
|
||||||
|
if (!readyToChangeState) return;
|
||||||
|
|
||||||
|
if (currentState == COLLAPSED) {
|
||||||
|
expand();
|
||||||
|
} else {
|
||||||
|
collapse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewMode
|
||||||
|
public int getCurrentState() {
|
||||||
|
return currentState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentState(@ViewMode int currentState) {
|
||||||
|
this.currentState = currentState;
|
||||||
|
broadcastState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void broadcastState() {
|
||||||
|
for (StateListener listener : listeners) {
|
||||||
|
listener.onStateChanged(currentState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a listener which will be listening for changes in this view (i.e. collapsed or expanded).
|
||||||
|
*/
|
||||||
|
public void addListener(final StateListener listener) {
|
||||||
|
if (listeners.contains(listener)) {
|
||||||
|
throw new IllegalStateException("Trying to add the same listener multiple times");
|
||||||
|
}
|
||||||
|
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a listener so it doesn't receive more state changes.
|
||||||
|
*/
|
||||||
|
public void removeListener(final StateListener listener) {
|
||||||
|
listeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple interface used for listening state changes of the {@link CollapsibleView}.
|
||||||
|
*/
|
||||||
|
public interface StateListener {
|
||||||
|
/**
|
||||||
|
* Called when the state changes.
|
||||||
|
*
|
||||||
|
* @param newState the state that the {@link CollapsibleView} transitioned to,<br/>
|
||||||
|
* it's an integer being either {@link #COLLAPSED} or {@link #EXPANDED}
|
||||||
|
*/
|
||||||
|
void onStateChanged(@ViewMode int newState);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// State Saving
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Parcelable onSaveInstanceState() {
|
||||||
|
return Icepick.saveInstanceState(this, super.onSaveInstanceState());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRestoreInstanceState(Parcelable state) {
|
||||||
|
super.onRestoreInstanceState(Icepick.restoreInstanceState(this, state));
|
||||||
|
|
||||||
|
ready();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Internal
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
public String getDebugLogString(String description) {
|
||||||
|
return String.format("%-100s → %s",
|
||||||
|
description, "readyToChangeState = [" + readyToChangeState + "], currentState = [" + currentState + "], targetHeight = [" + targetHeight + "]," +
|
||||||
|
" mW x mH = [" + getMeasuredWidth() + "x" + getMeasuredHeight() + "]" +
|
||||||
|
" W x H = [" + getWidth() + "x" + getHeight() + "]");
|
||||||
|
}
|
||||||
|
}
|
BIN
app/src/main/res/drawable-hdpi/ic_backup_black_24dp.png
Normal file
After Width: | Height: | Size: 337 B |
BIN
app/src/main/res/drawable-hdpi/ic_backup_white_24dp.png
Normal file
After Width: | Height: | Size: 345 B |
BIN
app/src/main/res/drawable-hdpi/ic_import_export_black_24dp.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
app/src/main/res/drawable-hdpi/ic_import_export_white_24dp.png
Normal file
After Width: | Height: | Size: 172 B |
BIN
app/src/main/res/drawable-hdpi/ic_save_black_24dp.png
Normal file
After Width: | Height: | Size: 240 B |
BIN
app/src/main/res/drawable-hdpi/ic_save_white_24dp.png
Normal file
After Width: | Height: | Size: 247 B |
BIN
app/src/main/res/drawable-mdpi/ic_backup_black_24dp.png
Normal file
After Width: | Height: | Size: 226 B |
BIN
app/src/main/res/drawable-mdpi/ic_backup_white_24dp.png
Normal file
After Width: | Height: | Size: 235 B |
BIN
app/src/main/res/drawable-mdpi/ic_import_export_black_24dp.png
Normal file
After Width: | Height: | Size: 128 B |
BIN
app/src/main/res/drawable-mdpi/ic_import_export_white_24dp.png
Normal file
After Width: | Height: | Size: 132 B |
BIN
app/src/main/res/drawable-mdpi/ic_save_black_24dp.png
Normal file
After Width: | Height: | Size: 167 B |
BIN
app/src/main/res/drawable-mdpi/ic_save_white_24dp.png
Normal file
After Width: | Height: | Size: 168 B |
BIN
app/src/main/res/drawable-xhdpi/ic_backup_black_24dp.png
Normal file
After Width: | Height: | Size: 386 B |
BIN
app/src/main/res/drawable-xhdpi/ic_backup_white_24dp.png
Normal file
After Width: | Height: | Size: 405 B |
BIN
app/src/main/res/drawable-xhdpi/ic_import_export_black_24dp.png
Normal file
After Width: | Height: | Size: 186 B |
BIN
app/src/main/res/drawable-xhdpi/ic_import_export_white_24dp.png
Normal file
After Width: | Height: | Size: 202 B |
BIN
app/src/main/res/drawable-xhdpi/ic_save_black_24dp.png
Normal file
After Width: | Height: | Size: 264 B |
BIN
app/src/main/res/drawable-xhdpi/ic_save_white_24dp.png
Normal file
After Width: | Height: | Size: 273 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_backup_black_24dp.png
Normal file
After Width: | Height: | Size: 561 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_backup_white_24dp.png
Normal file
After Width: | Height: | Size: 589 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_import_export_black_24dp.png
Normal file
After Width: | Height: | Size: 230 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_import_export_white_24dp.png
Normal file
After Width: | Height: | Size: 252 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_save_black_24dp.png
Normal file
After Width: | Height: | Size: 368 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_save_white_24dp.png
Normal file
After Width: | Height: | Size: 391 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_backup_black_24dp.png
Normal file
After Width: | Height: | Size: 733 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_backup_white_24dp.png
Normal file
After Width: | Height: | Size: 770 B |
After Width: | Height: | Size: 302 B |
After Width: | Height: | Size: 328 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_save_black_24dp.png
Normal file
After Width: | Height: | Size: 477 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_save_white_24dp.png
Normal file
After Width: | Height: | Size: 504 B |
55
app/src/main/res/layout/fragment_import.xml
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/info_text_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@+id/inputs_panel"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
tools:text="@string/import_soundcloud_instructions"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/inputs_panel"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/input_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:inputType="text"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:hint="@string/import_soundcloud_instructions_hint"
|
||||||
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/input_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
tools:text="@string/import_title"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="4dp"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:background="?attr/toolbar_shadow_drawable"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -9,10 +9,12 @@
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/items_list"
|
android:id="@+id/items_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
app:layoutManager="LinearLayoutManager"
|
app:layoutManager="LinearLayoutManager"
|
||||||
tools:listitem="@layout/list_channel_item"/>
|
android:visibility="gone"
|
||||||
|
tools:listitem="@layout/list_channel_item"
|
||||||
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
<!--ERROR PANEL-->
|
<!--ERROR PANEL-->
|
||||||
<include
|
<include
|
||||||
|
@ -21,6 +23,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_below="@id/items_list"
|
||||||
android:layout_marginTop="50dp"
|
android:layout_marginTop="50dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
@ -31,6 +34,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_below="@id/items_list"
|
||||||
android:layout_marginTop="50dp"
|
android:layout_marginTop="50dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
|
|
@ -1,43 +1,139 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="12dp"
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="12dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/whats_new"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="6dp"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true">
|
android:focusable="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/whatsNewIcon"
|
android:id="@+id/whats_new_icon"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="28dp"
|
android:layout_height="24dp"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_gravity="center"
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
android:layout_marginRight="12dp"
|
android:layout_marginRight="12dp"
|
||||||
android:src="?attr/rss"
|
android:src="?attr/rss"
|
||||||
tools:ignore="ContentDescription,RtlHardcoded"/>
|
tools:ignore="ContentDescription,RtlHardcoded"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/whatsNew"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:layout_toRightOf="@+id/whatsNewIcon"
|
|
||||||
android:gravity="left|center"
|
android:gravity="left|center"
|
||||||
android:text="@string/fragment_whats_new"
|
android:text="@string/fragment_whats_new"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:ignore="RtlHardcoded"/>
|
tools:ignore="RtlHardcoded"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/import_export"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/import_export_icon"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:src="?attr/ic_import_export"
|
||||||
|
tools:ignore="ContentDescription,RtlHardcoded"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_toRightOf="@+id/import_export_icon"
|
||||||
|
android:layout_toLeftOf="@+id/import_export_expand_icon"
|
||||||
|
android:gravity="left|center"
|
||||||
|
android:text="@string/import_export_title"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="RtlHardcoded"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/import_export_expand_icon"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginRight="24dp"
|
||||||
|
android:src="?attr/expand"
|
||||||
|
tools:ignore="ContentDescription,RtlHardcoded"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<org.schabi.newpipe.views.CollapsibleView
|
||||||
|
android:id="@+id/import_export_options"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:ignore="RtlSymmetry">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/import_from_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/subscription_import_export_item_height"
|
||||||
|
android:gravity="left|center"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingLeft="72dp"
|
||||||
|
android:text="@string/import_from"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textSize="13sp"
|
||||||
|
tools:ignore="RtlHardcoded"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/import_from_options"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="72dp"
|
||||||
|
android:layout_marginStart="72dp"
|
||||||
|
android:orientation="vertical"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/export_to_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/subscription_import_export_item_height"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="left|center"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingLeft="72dp"
|
||||||
|
android:text="@string/export_to"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textSize="13sp"
|
||||||
|
tools:ignore="RtlHardcoded"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/export_to_options"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="72dp"
|
||||||
|
android:layout_marginStart="72dp"
|
||||||
|
android:orientation="vertical"/>
|
||||||
|
</org.schabi.newpipe.views.CollapsibleView>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_below="@+id/whatsNew"
|
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:background="?attr/separator_color"/>
|
android:background="?attr/separator_color"/>
|
||||||
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
|
33
app/src/main/res/layout/subscription_import_export_item.xml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@android:id/icon1"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="@dimen/subscription_import_export_item_icon_size"
|
||||||
|
android:layout_marginTop="@dimen/subscription_import_export_item_icon_margin"
|
||||||
|
android:layout_marginBottom="@dimen/subscription_import_export_item_icon_margin"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
tools:ignore="ContentDescription,RtlHardcoded"
|
||||||
|
tools:src="@drawable/place_holder_youtube"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/text1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/subscription_import_export_item_height"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingLeft="6dp"
|
||||||
|
android:paddingRight="6dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textSize="13sp"
|
||||||
|
tools:text="@string/youtube"/>
|
||||||
|
</LinearLayout>
|
|
@ -46,4 +46,6 @@
|
||||||
<!-- Elements Size -->
|
<!-- Elements Size -->
|
||||||
<dimen name="playlist_item_thumbnail_stream_count_width">70dp</dimen>
|
<dimen name="playlist_item_thumbnail_stream_count_width">70dp</dimen>
|
||||||
|
|
||||||
|
<!-- File picker dimensions -->
|
||||||
|
<dimen name="file_picker_items_text_size">16sp</dimen>
|
||||||
</resources>
|
</resources>
|
|
@ -32,6 +32,9 @@
|
||||||
<attr name="ic_bookmark" format="reference"/>
|
<attr name="ic_bookmark" format="reference"/>
|
||||||
<attr name="ic_playlist_add" format="reference"/>
|
<attr name="ic_playlist_add" format="reference"/>
|
||||||
<attr name="ic_playlist_check" format="reference"/>
|
<attr name="ic_playlist_check" format="reference"/>
|
||||||
|
<attr name="ic_import_export" format="reference"/>
|
||||||
|
<attr name="ic_save" format="reference"/>
|
||||||
|
<attr name="ic_backup" format="reference"/>
|
||||||
|
|
||||||
<!-- Can't refer to colors directly into drawable's xml-->
|
<!-- Can't refer to colors directly into drawable's xml-->
|
||||||
<attr name="toolbar_shadow_drawable" format="reference"/>
|
<attr name="toolbar_shadow_drawable" format="reference"/>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
<!-- Light Theme -->
|
<!-- Light Theme -->
|
||||||
<color name="light_background_color">#EEEEEE</color>
|
<color name="light_background_color">#EEEEEE</color>
|
||||||
|
<color name="light_dialog_background_color">#EEEEEE</color>
|
||||||
<color name="light_settings_accent_color">#e53935</color>
|
<color name="light_settings_accent_color">#e53935</color>
|
||||||
<color name="light_separator_color">#32000000</color>
|
<color name="light_separator_color">#32000000</color>
|
||||||
<color name="light_ripple_color">#48868686</color>
|
<color name="light_ripple_color">#48868686</color>
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
|
|
||||||
<!-- Dark Theme -->
|
<!-- Dark Theme -->
|
||||||
<color name="dark_background_color">#222222</color>
|
<color name="dark_background_color">#222222</color>
|
||||||
|
<color name="dark_dialog_background_color">#424242</color>
|
||||||
<color name="dark_settings_accent_color">#ff5252</color>
|
<color name="dark_settings_accent_color">#ff5252</color>
|
||||||
<color name="dark_separator_color">#0affffff</color>
|
<color name="dark_separator_color">#0affffff</color>
|
||||||
<color name="dark_ripple_color">#48ffffff</color>
|
<color name="dark_ripple_color">#48ffffff</color>
|
||||||
|
|
|
@ -25,6 +25,11 @@
|
||||||
<!-- Miscellaneous -->
|
<!-- Miscellaneous -->
|
||||||
<dimen name="popup_default_width">180dp</dimen>
|
<dimen name="popup_default_width">180dp</dimen>
|
||||||
<dimen name="popup_minimum_width">150dp</dimen>
|
<dimen name="popup_minimum_width">150dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="subscription_import_export_item_height">42dp</dimen>
|
||||||
|
<dimen name="subscription_import_export_item_icon_size">24dp</dimen>
|
||||||
|
<!-- (item_height - item_icon_size) / 2-->
|
||||||
|
<dimen name="subscription_import_export_item_icon_margin">9dp</dimen>
|
||||||
<!-- Video Item Detail View Dimensions-->
|
<!-- Video Item Detail View Dimensions-->
|
||||||
<!-- Text Size -->
|
<!-- Text Size -->
|
||||||
<dimen name="video_item_detail_title_text_size">15sp</dimen>
|
<dimen name="video_item_detail_title_text_size">15sp</dimen>
|
||||||
|
@ -75,4 +80,7 @@
|
||||||
|
|
||||||
<!-- Kiosk view Dimensions-->
|
<!-- Kiosk view Dimensions-->
|
||||||
<dimen name="kiosk_title_text_size">30sp</dimen>
|
<dimen name="kiosk_title_text_size">30sp</dimen>
|
||||||
|
|
||||||
|
<!-- File picker dimensions -->
|
||||||
|
<dimen name="file_picker_items_text_size">14sp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -48,6 +48,9 @@
|
||||||
<item name="ic_bookmark">@drawable/ic_bookmark_black_24dp</item>
|
<item name="ic_bookmark">@drawable/ic_bookmark_black_24dp</item>
|
||||||
<item name="ic_playlist_add">@drawable/ic_playlist_add_black_24dp</item>
|
<item name="ic_playlist_add">@drawable/ic_playlist_add_black_24dp</item>
|
||||||
<item name="ic_playlist_check">@drawable/ic_playlist_add_check_black_24dp</item>
|
<item name="ic_playlist_check">@drawable/ic_playlist_add_check_black_24dp</item>
|
||||||
|
<item name="ic_import_export">@drawable/ic_import_export_black_24dp</item>
|
||||||
|
<item name="ic_save">@drawable/ic_save_black_24dp</item>
|
||||||
|
<item name="ic_backup">@drawable/ic_backup_black_24dp</item>
|
||||||
|
|
||||||
<item name="separator_color">@color/light_separator_color</item>
|
<item name="separator_color">@color/light_separator_color</item>
|
||||||
<item name="contrast_background_color">@color/light_contrast_background_color</item>
|
<item name="contrast_background_color">@color/light_contrast_background_color</item>
|
||||||
|
@ -102,6 +105,9 @@
|
||||||
<item name="ic_bookmark">@drawable/ic_bookmark_white_24dp</item>
|
<item name="ic_bookmark">@drawable/ic_bookmark_white_24dp</item>
|
||||||
<item name="ic_playlist_add">@drawable/ic_playlist_add_white_24dp</item>
|
<item name="ic_playlist_add">@drawable/ic_playlist_add_white_24dp</item>
|
||||||
<item name="ic_playlist_check">@drawable/ic_playlist_add_check_white_24dp</item>
|
<item name="ic_playlist_check">@drawable/ic_playlist_add_check_white_24dp</item>
|
||||||
|
<item name="ic_import_export">@drawable/ic_import_export_white_24dp</item>
|
||||||
|
<item name="ic_save">@drawable/ic_save_white_24dp</item>
|
||||||
|
<item name="ic_backup">@drawable/ic_backup_white_24dp</item>
|
||||||
|
|
||||||
<item name="separator_color">@color/dark_separator_color</item>
|
<item name="separator_color">@color/dark_separator_color</item>
|
||||||
<item name="contrast_background_color">@color/dark_contrast_background_color</item>
|
<item name="contrast_background_color">@color/dark_contrast_background_color</item>
|
||||||
|
@ -130,6 +136,23 @@
|
||||||
<item name="android:windowAnimationStyle">@style/SwitchAnimation</item>
|
<item name="android:windowAnimationStyle">@style/SwitchAnimation</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- Dialogs -->
|
||||||
|
<style name="LightDialogTheme" parent="Theme.AppCompat.Light.Dialog">
|
||||||
|
<item name="colorPrimary">@color/light_youtube_primary_color</item>
|
||||||
|
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
|
||||||
|
<item name="colorAccent">@color/light_youtube_accent_color</item>
|
||||||
|
<item name="android:windowBackground">@color/light_dialog_background_color</item>
|
||||||
|
<item name="windowBackground">@color/light_dialog_background_color</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="DarkDialogTheme" parent="Theme.AppCompat.Dialog">
|
||||||
|
<item name="colorPrimary">@color/dark_youtube_primary_color</item>
|
||||||
|
<item name="colorPrimaryDark">@color/dark_youtube_dark_color</item>
|
||||||
|
<item name="colorAccent">@color/dark_youtube_accent_color</item>
|
||||||
|
<item name="android:windowBackground">@color/dark_dialog_background_color</item>
|
||||||
|
<item name="windowBackground">@color/dark_dialog_background_color</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<style name="LightSettingsTheme" parent="LightTheme">
|
<style name="LightSettingsTheme" parent="LightTheme">
|
||||||
<item name="colorAccent">@color/light_settings_accent_color</item>
|
<item name="colorAccent">@color/light_settings_accent_color</item>
|
||||||
|
|
|
@ -9,47 +9,35 @@
|
||||||
|
|
||||||
|
|
||||||
<!--File picker styles-->
|
<!--File picker styles-->
|
||||||
|
|
||||||
<style name="FilePickerThemeLight" parent="NNF_BaseTheme.Light">
|
<style name="FilePickerThemeLight" parent="NNF_BaseTheme.Light">
|
||||||
<item name="colorPrimary">@color/light_youtube_primary_color</item>
|
<item name="colorPrimary">@color/light_youtube_primary_color</item>
|
||||||
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
|
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
|
||||||
<item name="colorAccent">@color/light_youtube_accent_color</item>
|
<item name="colorAccent">@color/light_settings_accent_color</item>
|
||||||
<item name="android:background">@color/light_background_color</item>
|
<item name="android:windowBackground">@color/light_background_color</item>
|
||||||
<item name="nnf_separator_color">@color/light_separator_color</item>
|
<item name="nnf_separator_color">@color/light_separator_color</item>
|
||||||
|
|
||||||
<item name="alertDialogTheme">@style/FilePickerAlertDialogThemeLight</item>
|
<item name="alertDialogTheme">@style/FilePickerAlertDialogThemeLight</item>
|
||||||
<item name="nnf_toolbarTheme">@style/FilePickerToolbarLight</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="FilePickerAlertDialogThemeLight" parent="Theme.AppCompat.Dialog.Alert">
|
<style name="FilePickerAlertDialogThemeLight" parent="Theme.AppCompat.Dialog.Alert">
|
||||||
<item name="colorPrimary">@color/light_youtube_primary_color</item>
|
<item name="colorPrimary">@color/light_youtube_primary_color</item>
|
||||||
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
|
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
|
||||||
<item name="colorAccent">@color/light_youtube_accent_color</item>
|
<item name="colorAccent">@color/light_settings_accent_color</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="FilePickerToolbarLight" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
|
<style name="FilePickerThemeDark" parent="NNF_BaseTheme">
|
||||||
<item name="android:background">@color/light_youtube_primary_color</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="FilePickerThemeDark" parent="FilePickerThemeLight">
|
|
||||||
<item name="colorPrimary">@color/dark_youtube_primary_color</item>
|
<item name="colorPrimary">@color/dark_youtube_primary_color</item>
|
||||||
<item name="colorPrimaryDark">@color/dark_youtube_dark_color</item>
|
<item name="colorPrimaryDark">@color/dark_youtube_dark_color</item>
|
||||||
<item name="colorAccent">@color/dark_youtube_accent_color</item>
|
<item name="colorAccent">@color/dark_settings_accent_color</item>
|
||||||
<item name="android:background">@color/dark_background_color</item>
|
<item name="android:windowBackground">@color/dark_background_color</item>
|
||||||
<item name="android:textColorPrimary">@color/dark_youtube_accent_color</item>
|
|
||||||
<item name="nnf_separator_color">@color/black_separator_color</item>
|
<item name="nnf_separator_color">@color/black_separator_color</item>
|
||||||
|
|
||||||
<item name="alertDialogTheme">@style/FilePickerAlertDialogThemeDark</item>
|
<item name="alertDialogTheme">@style/FilePickerAlertDialogThemeDark</item>
|
||||||
<item name="nnf_toolbarTheme">@style/FilePickerToolbarDark</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="FilePickerAlertDialogThemeDark" parent="Theme.AppCompat.Dialog.Alert">
|
<style name="FilePickerAlertDialogThemeDark" parent="Theme.AppCompat.Dialog.Alert">
|
||||||
<item name="colorPrimary">@color/dark_youtube_primary_color</item>
|
<item name="colorPrimary">@color/dark_youtube_primary_color</item>
|
||||||
<item name="colorPrimaryDark">@color/dark_youtube_dark_color</item>
|
<item name="colorPrimaryDark">@color/dark_youtube_dark_color</item>
|
||||||
<item name="colorAccent">@color/dark_youtube_accent_color</item>
|
<item name="colorAccent">@color/dark_settings_accent_color</item>
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="FilePickerToolbarDark" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
|
|
||||||
<item name="android:background">@color/dark_youtube_primary_color</item>
|
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|