Merge remote-tracking branch 'origin/dev' into dev
@ -41,6 +41,8 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
@ -79,6 +81,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
setSupportActionBar(findViewById(R.id.toolbar));
|
||||
setupDrawer();
|
||||
setupDrawerFooter();
|
||||
}
|
||||
|
||||
private void setupDrawer() {
|
||||
@ -123,6 +126,16 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void setupDrawerFooter() {
|
||||
ImageButton settings = findViewById(R.id.drawer_settings);
|
||||
ImageButton downloads = findViewById(R.id.drawer_downloads);
|
||||
ImageButton history = findViewById(R.id.drawer_history);
|
||||
|
||||
settings.setOnClickListener(view -> NavigationHelper.openSettings(this) );
|
||||
downloads.setOnClickListener(view -> NavigationHelper.openDownloads(this));
|
||||
history.setOnClickListener(view -> NavigationHelper.openHistory(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@ -1,150 +0,0 @@
|
||||
package org.schabi.newpipe.fragments.detail;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.util.ListHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 18.08.15.
|
||||
* <p>
|
||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||
* DetailsMenuHandler.java is part of NewPipe.
|
||||
* <p>
|
||||
* NewPipe 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.
|
||||
* <p>
|
||||
* NewPipe 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.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
class ActionBarHandler {
|
||||
private static final String TAG = "ActionBarHandler";
|
||||
|
||||
private AppCompatActivity activity;
|
||||
private int selectedVideoStream = -1;
|
||||
|
||||
private SharedPreferences defaultPreferences;
|
||||
|
||||
private Menu menu;
|
||||
|
||||
// Only callbacks are listed here, there are more actions which don't need a callback.
|
||||
// those are edited directly. Typically VideoDetailFragment will implement those callbacks.
|
||||
private OnActionListener onShareListener;
|
||||
private OnActionListener onOpenInBrowserListener;
|
||||
private OnActionListener onPlayWithKodiListener;
|
||||
|
||||
// Triggered when a stream related action is triggered.
|
||||
public interface OnActionListener {
|
||||
void onActionSelected(int selectedStreamId);
|
||||
}
|
||||
|
||||
public ActionBarHandler(AppCompatActivity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public void setupStreamList(final List<VideoStream> videoStreams, Spinner toolbarSpinner) {
|
||||
if (activity == null) return;
|
||||
|
||||
selectedVideoStream = ListHelper.getDefaultResolutionIndex(activity, videoStreams);
|
||||
|
||||
boolean isExternalPlayerEnabled = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(activity.getString(R.string.use_external_video_player_key), false);
|
||||
toolbarSpinner.setAdapter(new SpinnerToolbarAdapter(activity, videoStreams, isExternalPlayerEnabled));
|
||||
toolbarSpinner.setSelection(selectedVideoStream);
|
||||
toolbarSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
selectedVideoStream = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setupMenu(Menu menu, MenuInflater inflater) {
|
||||
this.menu = menu;
|
||||
|
||||
// CAUTION set item properties programmatically otherwise it would not be accepted by
|
||||
// appcompat itemsinflater.inflate(R.menu.videoitem_detail, menu);
|
||||
|
||||
defaultPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
inflater.inflate(R.menu.video_detail_menu, menu);
|
||||
|
||||
updateItemsVisibility();
|
||||
}
|
||||
|
||||
public void updateItemsVisibility(){
|
||||
showPlayWithKodiAction(defaultPreferences.getBoolean(activity.getString(R.string.show_play_with_kodi_key), false));
|
||||
}
|
||||
|
||||
public boolean onItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.menu_item_share: {
|
||||
if (onShareListener != null) {
|
||||
onShareListener.onActionSelected(selectedVideoStream);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case R.id.menu_item_openInBrowser: {
|
||||
if (onOpenInBrowserListener != null) {
|
||||
onOpenInBrowserListener.onActionSelected(selectedVideoStream);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case R.id.action_play_with_kodi:
|
||||
if (onPlayWithKodiListener != null) {
|
||||
onPlayWithKodiListener.onActionSelected(selectedVideoStream);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
Log.e(TAG, "Menu Item not known");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getSelectedVideoStream() {
|
||||
return selectedVideoStream;
|
||||
}
|
||||
|
||||
public void setOnShareListener(OnActionListener listener) {
|
||||
onShareListener = listener;
|
||||
}
|
||||
|
||||
public void setOnOpenInBrowserListener(OnActionListener listener) {
|
||||
onOpenInBrowserListener = listener;
|
||||
}
|
||||
|
||||
public void setOnPlayWithKodiListener(OnActionListener listener) {
|
||||
onPlayWithKodiListener = listener;
|
||||
}
|
||||
|
||||
public void showPlayWithKodiAction(boolean visible) {
|
||||
menu.findItem(R.id.action_play_with_kodi).setVisible(visible);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 453 B |
BIN
app/src/main/res/drawable-hdpi/ic_settings_white_24dp.png
Normal file
|
After Width: | Height: | Size: 460 B |
BIN
app/src/main/res/drawable-mdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 322 B |
BIN
app/src/main/res/drawable-mdpi/ic_settings_white_24dp.png
Normal file
|
After Width: | Height: | Size: 326 B |
BIN
app/src/main/res/drawable-xhdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 557 B |
BIN
app/src/main/res/drawable-xhdpi/ic_settings_white_24dp.png
Normal file
|
After Width: | Height: | Size: 562 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 827 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_settings_white_24dp.png
Normal file
|
After Width: | Height: | Size: 843 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_settings_white_24dp.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
@ -21,10 +20,6 @@
|
||||
<include layout="@layout/toolbar_layout" />
|
||||
</FrameLayout>
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/navigation"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
app:menu="@menu/drawer_items" />
|
||||
<include layout="@layout/drawer_laoyut"/>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
65
app/src/main/res/layout/drawer_laoyut.xml
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout android:id="@+id/navigation_layout"
|
||||
android:orientation="vertical"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="?attr/android:windowBackground">
|
||||
|
||||
<View
|
||||
android:id="@+id/drawer_header"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_alignLeft="@id/navigation"
|
||||
android:layout_alignRight="@id/navigation"
|
||||
android:layout_alignStart="@id/navigation"
|
||||
android:layout_alignEnd="@id/navigation"
|
||||
android:background="?attr/colorPrimary"/>
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/navigation"
|
||||
android:layout_below="@id/drawer_header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:menu="@menu/drawer_items"
|
||||
app:elevation="0dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/navigation_drawer_footer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="60dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignLeft="@id/navigation"
|
||||
android:layout_alignRight="@id/navigation"
|
||||
android:layout_alignStart="@id/navigation"
|
||||
android:layout_alignEnd="@id/navigation"
|
||||
|
||||
android:layout_alignParentBottom="true">
|
||||
<ImageButton
|
||||
android:id="@+id/drawer_settings"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="?attr/settings"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/drawer_downloads"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="?attr/download" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/drawer_history"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="?attr/history"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@ -310,7 +310,7 @@
|
||||
android:layout_height="55dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:contentDescription="@string/append_playlist"
|
||||
@ -327,7 +327,7 @@
|
||||
android:layout_height="55dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:contentDescription="@string/play_audio"
|
||||
@ -344,7 +344,7 @@
|
||||
android:layout_height="55dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:contentDescription="@string/open_in_popup_mode"
|
||||
@ -361,7 +361,7 @@
|
||||
android:layout_height="55dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:contentDescription="@string/controls_download_desc"
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
<attr name="search_add" format="reference"/>
|
||||
<attr name="options" format="reference"/>
|
||||
<attr name="play" format="reference"/>
|
||||
<attr name="settings" format="reference"/>
|
||||
<attr name="ic_hot" format="reference"/>
|
||||
<attr name="ic_channel" format="reference"/>
|
||||
<attr name="ic_bookmark" format="reference"/>
|
||||
@ -39,4 +40,6 @@
|
||||
<attr name="separator_color" format="color"/>
|
||||
<attr name="queue_background_color" format="color"/>
|
||||
<attr name="contrast_background_color" format="color"/>
|
||||
<attr name="windowBackground" format="color"/>
|
||||
<attr name="colorPrimary" format="color"/>
|
||||
</resources>
|
||||
@ -15,6 +15,7 @@
|
||||
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
|
||||
<item name="colorAccent">@color/light_youtube_accent_color</item>
|
||||
<item name="android:windowBackground">@color/light_background_color</item>
|
||||
<item name="windowBackground">@color/light_background_color</item>
|
||||
|
||||
<item name="thumbs_up">@drawable/ic_thumb_up_black_24dp</item>
|
||||
<item name="thumbs_down">@drawable/ic_thumb_down_black_24dp</item>
|
||||
@ -40,6 +41,7 @@
|
||||
<item name="search_add">@drawable/ic_arrow_top_left_black_24dp</item>
|
||||
<item name="options">@drawable/ic_more_vert_black_24dp</item>
|
||||
<item name="play">@drawable/ic_play_arrow_black_24dp</item>
|
||||
<item name="settings">@drawable/ic_settings_black_24dp</item>
|
||||
<item name="ic_hot">@drawable/ic_whatshot_black_24dp</item>
|
||||
<item name="ic_channel">@drawable/ic_channel_black_24dp</item>
|
||||
<item name="ic_bookmark">@drawable/ic_bookmark_black_24dp</item>
|
||||
@ -66,6 +68,7 @@
|
||||
<item name="colorPrimaryDark">@color/dark_youtube_dark_color</item>
|
||||
<item name="colorAccent">@color/dark_youtube_accent_color</item>
|
||||
<item name="android:windowBackground">@color/dark_background_color</item>
|
||||
<item name="windowBackground">@color/dark_background_color</item>
|
||||
|
||||
<item name="thumbs_up">@drawable/ic_thumb_up_white_24dp</item>
|
||||
<item name="thumbs_down">@drawable/ic_thumb_down_white_24dp</item>
|
||||
@ -91,6 +94,7 @@
|
||||
<item name="search_add">@drawable/ic_arrow_top_left_white_24dp</item>
|
||||
<item name="options">@drawable/ic_more_vert_white_24dp</item>
|
||||
<item name="play">@drawable/ic_play_arrow_white_24dp</item>
|
||||
<item name="settings">@drawable/ic_settings_white_24dp</item>
|
||||
<item name="ic_hot">@drawable/ic_whatshot_white_24dp</item>
|
||||
<item name="ic_channel">@drawable/ic_channel_white_24dp</item>
|
||||
<item name="ic_bookmark">@drawable/ic_bookmark_white_24dp</item>
|
||||
@ -114,6 +118,7 @@
|
||||
|
||||
<style name="BlackTheme" parent="DarkTheme">
|
||||
<item name="android:windowBackground">@color/black_background_color</item>
|
||||
<item name="windowBackground">@color/black_background_color</item>
|
||||
|
||||
<item name="separator_color">@color/black_separator_color</item>
|
||||
<item name="contrast_background_color">@color/black_contrast_background_color</item>
|
||||
|
||||