add header/footer to drawer

This commit is contained in:
Christian Schabesberger 2018-02-16 14:45:52 +01:00
parent 8adca3725d
commit 86f041b803
17 changed files with 93 additions and 11 deletions

View File

@ -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();

View File

@ -1,6 +1,7 @@
package org.schabi.newpipe.settings;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import org.schabi.newpipe.R;

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 843 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -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>

View 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>

View File

@ -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"

View File

@ -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>

View File

@ -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>