1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-21 18:42:35 +01:00

new app icon & made player fullscreen work better

This commit is contained in:
Christian Schabesberger 2015-09-20 13:19:28 +02:00
parent d3cc518529
commit c59754499f
15 changed files with 320 additions and 22 deletions

View File

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -2,12 +2,16 @@ package org.schabi.newpipe;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.Menu;
@ -17,8 +21,11 @@ import android.view.Surface;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.VideoView;
/**
@ -50,6 +57,7 @@ public class PlayVideoActivity extends AppCompatActivity {
private static final String POSITION = "position";
private static final long HIDING_DELAY = 3000;
private static final long TAB_HIDING_DELAY = 100;
private String videoUrl = "";
@ -61,6 +69,8 @@ public class PlayVideoActivity extends AppCompatActivity {
private View decorView;
private boolean uiIsHidden = false;
private static long lastUiShowTime = 0;
private boolean isLandscape = true;
private boolean hasSoftKeys = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -68,6 +78,9 @@ public class PlayVideoActivity extends AppCompatActivity {
setContentView(R.layout.activity_play_video);
isLandscape = checkIfLandscape();
hasSoftKeys = checkIfhasSoftKeys();
actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent();
@ -91,6 +104,7 @@ public class PlayVideoActivity extends AppCompatActivity {
videoView.seekTo(position);
if (position == 0) {
videoView.start();
showUi();
} else {
videoView.pause();
}
@ -113,16 +127,21 @@ public class PlayVideoActivity extends AppCompatActivity {
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
uiIsHidden = false;
if (visibility == View.VISIBLE && uiIsHidden) {
showUi();
} else {
uiIsHidden = true;
hideUi();
}
}
});
showUi();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
}
@Override
@ -166,8 +185,16 @@ public class PlayVideoActivity extends AppCompatActivity {
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
public void onConfigurationChanged(Configuration config) {
super.onConfigurationChanged(config);
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
isLandscape = true;
adjustMediaControllMetrics();
} else if (config.orientation == Configuration.ORIENTATION_PORTRAIT){
isLandscape = false;
adjustMediaControllMetrics();
}
}
@Override
@ -187,15 +214,15 @@ public class PlayVideoActivity extends AppCompatActivity {
private void showUi() {
try {
uiIsHidden = false;
mediaController.show();
mediaController.show(100000);
actionBar.show();
//decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
//| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
adjustMediaControllMetrics();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if ((System.currentTimeMillis() - lastUiShowTime) > HIDING_DELAY) {
if ((System.currentTimeMillis() - lastUiShowTime) >= HIDING_DELAY) {
hideUi();
}
}
@ -210,8 +237,75 @@ public class PlayVideoActivity extends AppCompatActivity {
uiIsHidden = true;
actionBar.hide();
mediaController.hide();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
//decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
//| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
private void adjustMediaControllMetrics() {
MediaController.LayoutParams mediaControllerLayout
= new MediaController.LayoutParams(MediaController.LayoutParams.MATCH_PARENT,
MediaController.LayoutParams.WRAP_CONTENT);
if(!hasSoftKeys) {
mediaControllerLayout.setMargins(20, 0, 20, 20);
} else {
int width = getNavigationBarWidth();
int height = getNavigationBarHeight();
mediaControllerLayout.setMargins(width + 20, 0, width + 20, height + 20);
}
mediaController.setLayoutParams(mediaControllerLayout);
}
private boolean checkIfhasSoftKeys(){
if(Build.VERSION.SDK_INT >= 17) {
return getNavigationBarHeight() != 0 || getNavigationBarWidth() != 0;
} else {
return true;
}
}
private int getNavigationBarHeight() {
if(Build.VERSION.SDK_INT >= 17) {
Display d = getWindowManager().getDefaultDisplay();
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
d.getRealMetrics(realDisplayMetrics);
DisplayMetrics displayMetrics = new DisplayMetrics();
d.getMetrics(displayMetrics);
int realHeight = realDisplayMetrics.heightPixels;
int displayHeight = displayMetrics.heightPixels;
return (realHeight - displayHeight);
} else {
return 50;
}
}
private int getNavigationBarWidth() {
if(Build.VERSION.SDK_INT >= 17) {
Display d = getWindowManager().getDefaultDisplay();
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
d.getRealMetrics(realDisplayMetrics);
DisplayMetrics displayMetrics = new DisplayMetrics();
d.getMetrics(displayMetrics);
int realWidth = realDisplayMetrics.widthPixels;
int displayWidth = displayMetrics.widthPixels;
return (realWidth - displayWidth);
} else {
return 50;
}
}
public boolean checkIfLandscape() {
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
return displayMetrics.heightPixels < displayMetrics.widthPixels;
}
}

View File

@ -1,16 +1,20 @@
package org.schabi.newpipe;
import android.content.ContentProviderOperation;
import android.content.res.Configuration;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.WindowManager;
import org.schabi.newpipe.youtube.YoutubeExtractor;
@ -39,12 +43,12 @@ public class VideoItemDetailActivity extends AppCompatActivity {
private String videoUrl;
private int currentStreamingService = -1;
private boolean isLandscape;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_videoitem_detail);
// Show the Up button in the action bar.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarHandler.getHandler().setupNavMenu(this);

View File

@ -15,6 +15,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;

View File

@ -2,15 +2,19 @@ package org.schabi.newpipe;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.support.v7.widget.SearchView;
import android.widget.ImageView;

View File

@ -13,6 +13,7 @@ import android.widget.ListView;
import android.widget.Toast;
import java.net.URL;
import java.util.List;
import java.util.Vector;

View File

@ -9,17 +9,20 @@
<VideoView android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
android:layout_gravity="center"
android:focusable="false"/>
<Button android:id="@+id/content_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null" />
android:background="@null"
android:focusable="false"/>
<ProgressBar android:id="@+id/play_video_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:layout_gravity="center"/>
android:layout_gravity="center"
android:focusable="false"/>
</FrameLayout>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -21,6 +21,8 @@
<item name="windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/NewPipePlayerActionBarTheme</item>
<item name="actionBarStyle">@style/NewPipePlayerActionBarTheme</item>
<item name="colorAccent">@color/primaryColorYoutube</item>
<item name="android:colorAccent">@color/primaryColorYoutube</item>
</style>
<style name="NewPipePlayerActionBarTheme" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse" >

View File

@ -21,6 +21,7 @@
<item name="windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/NewPipePlayerActionBarTheme</item>
<item name="actionBarStyle">@style/NewPipePlayerActionBarTheme</item>
<item name="colorAccent">@color/primaryColorYoutube</item>
</style>
<style name="NewPipePlayerActionBarTheme" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse" >

188
assets/new_newpipe_icon.svg Normal file
View File

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="500"
height="500"
viewBox="0 0 499.99998 499.99998"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="new_newpipe_icon.svg">
<defs
id="defs4">
<linearGradient
inkscape:collect="always"
id="linearGradient4191">
<stop
style="stop-color:#000000;stop-opacity:0.42142856"
offset="0"
id="stop4193" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4195" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient4181">
<stop
style="stop-color:#000000;stop-opacity:0.18214285"
offset="0"
id="stop4183" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4185" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4181"
id="linearGradient4187"
x1="33.701958"
y1="1049.5769"
x2="222.74532"
y2="802.2912"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,-1,0,1604.7196)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4191"
id="linearGradient4197"
x1="156.3342"
y1="806.3598"
x2="137.34325"
y2="1076.3597"
gradientUnits="userSpaceOnUse" />
<filter
style="color-interpolation-filters:sRGB;"
inkscape:label="Drop Shadow"
id="filter4234">
<feFlood
flood-opacity="0.498039"
flood-color="rgb(0,0,0)"
result="flood"
id="feFlood4236" />
<feComposite
in="flood"
in2="SourceGraphic"
operator="in"
result="composite1"
id="feComposite4238" />
<feGaussianBlur
in="composite1"
stdDeviation="10"
result="blur"
id="feGaussianBlur4240" />
<feOffset
dx="10"
dy="10"
result="offset"
id="feOffset4242" />
<feComposite
in="SourceGraphic"
in2="offset"
operator="over"
result="composite2"
id="feComposite4244" />
</filter>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#909090"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="306.78283"
inkscape:cy="188.96397"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
units="px" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-552.36209)">
<g
id="g4228"
style="filter:url(#filter4234)"
transform="matrix(0.91500077,0,0,0.91500077,34.121548,64.699974)">
<path
transform="scale(1,-1)"
inkscape:transform-center-y="-0.99541504"
inkscape:transform-center-x="-69.868733"
d="m 466.34766,-802.35761 -216.69307,124.67654 -216.319598,125.32344 0.373489,-249.99997 -0.37349,-250 216.319579,125.32345 z"
inkscape:randomized="0"
inkscape:rounded="0"
inkscape:flatsided="false"
sodipodi:arg2="1.0471975"
sodipodi:arg1="-9.6439996e-10"
sodipodi:r2="143.96407"
sodipodi:r1="288.67511"
sodipodi:cy="-802.3576"
sodipodi:cx="177.67255"
sodipodi:sides="3"
id="path4177"
style="opacity:0.997;fill:#ff0d0d;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="star" />
<path
sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0"
id="path4179"
d="m 466.3167,802.35759 -432.596061,0 -0.161527,-249.85824 z"
style="fill:url(#linearGradient4187);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0"
id="path4189"
d="M 466.3432,802.35759 33.687658,802.35807 33.334206,1052.362 Z"
style="fill:url(#linearGradient4197);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
transform="scale(1,-1)"
inkscape:transform-center-y="-0.99541504"
inkscape:transform-center-x="-69.868733"
d="M 466.01266,-802.36206 249.31959,-677.68553 33,-552.36208 33.373489,-802.36205 33,-1052.362 249.31958,-927.0386 Z"
inkscape:randomized="0"
inkscape:rounded="0"
inkscape:flatsided="false"
sodipodi:arg2="1.0471975"
sodipodi:arg1="-9.6439996e-10"
sodipodi:r2="143.96407"
sodipodi:r1="288.67511"
sodipodi:cy="-802.36206"
sodipodi:cx="177.33755"
sodipodi:sides="3"
id="path4177-3"
style="opacity:0.997;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="star" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.2 KiB