1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-15 14:24:59 +00:00

fixed landscape layout problem & added watch with kodi function

This commit is contained in:
Christian Schabesberger 2015-09-15 20:11:42 +02:00
parent b6b0cf15eb
commit 08648caaff
14 changed files with 80 additions and 18 deletions

View File

@ -4,7 +4,9 @@ import android.app.DownloadManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.preference.Preference;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
@ -40,6 +42,8 @@ import java.io.File;
public class ActionBarHandler { public class ActionBarHandler {
private static final String TAG = ActionBarHandler.class.toString(); private static final String TAG = ActionBarHandler.class.toString();
private static final String KORE_PACKET = "org.xbmc.kore";
private static ActionBarHandler handler = null; private static ActionBarHandler handler = null;
private Context context = null; private Context context = null;
@ -49,6 +53,8 @@ public class ActionBarHandler {
private int selectedStream = -1; private int selectedStream = -1;
private String videoTitle = ""; private String videoTitle = "";
SharedPreferences defaultPreferences = null;
public static ActionBarHandler getHandler() { public static ActionBarHandler getHandler() {
if(handler == null) { if(handler == null) {
handler = new ActionBarHandler(); handler = new ActionBarHandler();
@ -73,7 +79,7 @@ public class ActionBarHandler {
this.streams = streams; this.streams = streams;
selectedStream = 0; selectedStream = 0;
String[] itemArray = new String[streams.length]; String[] itemArray = new String[streams.length];
String defaultResolution = PreferenceManager.getDefaultSharedPreferences(context) String defaultResolution = defaultPreferences
.getString(context.getString(R.string.defaultResolutionPreference), .getString(context.getString(R.string.defaultResolutionPreference),
context.getString(R.string.defaultResolutionListItem)); context.getString(R.string.defaultResolutionListItem));
int defaultResolutionPos = 0; int defaultResolutionPos = 0;
@ -104,15 +110,21 @@ public class ActionBarHandler {
// CAUTION set item properties programmatically otherwise it would not be accepted by // CAUTION set item properties programmatically otherwise it would not be accepted by
// appcompat itemsinflater.inflate(R.menu.videoitem_detail, menu); // appcompat itemsinflater.inflate(R.menu.videoitem_detail, menu);
defaultPreferences = PreferenceManager.getDefaultSharedPreferences(context);
inflater.inflate(R.menu.videoitem_detail, menu); inflater.inflate(R.menu.videoitem_detail, menu);
MenuItem playItem = menu.findItem(R.id.menu_item_play); MenuItem playItem = menu.findItem(R.id.menu_item_play);
MenuItem shareItem = menu.findItem(R.id.menu_item_share); MenuItem shareItem = menu.findItem(R.id.menu_item_share);
MenuItem castItem = menu.findItem(R.id.action_play_with_kodi);
MenuItemCompat.setShowAsAction(playItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS MenuItemCompat.setShowAsAction(playItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS
| MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
MenuItemCompat.setShowAsAction(shareItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM MenuItemCompat.setShowAsAction(shareItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM
| MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
castItem.setVisible(defaultPreferences
.getBoolean(context.getString(R.string.showPlayWidthKodiPreference), false));
return true; return true;
} }
@ -143,6 +155,10 @@ public class ActionBarHandler {
Intent intent = new Intent(context, SettingsActivity.class); Intent intent = new Intent(context, SettingsActivity.class);
context.startActivity(intent); context.startActivity(intent);
} }
break;
case R.id.action_play_with_kodi:
playWithKodi();
break;
default: default:
Log.e(TAG, "Menu Item not known"); Log.e(TAG, "Menu Item not known");
} }
@ -216,8 +232,7 @@ public class ActionBarHandler {
DownloadManager.Request request = new DownloadManager.Request( DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(streams[selectedStream].url)); Uri.parse(streams[selectedStream].url));
request.setDestinationUri(Uri.fromFile(new File( request.setDestinationUri(Uri.fromFile(new File(
PreferenceManager.getDefaultSharedPreferences(context) defaultPreferences.getString("download_path_preference", "/storage/emulated/0/NewPipe")
.getString("download_path_preference", "/storage/emulated/0/NewPipe")
+ "/" + videoTitle + suffix))); + "/" + videoTitle + suffix)));
try { try {
dm.enqueue(request); dm.enqueue(request);
@ -236,4 +251,35 @@ public class ActionBarHandler {
context.startActivity(Intent.createChooser(intent, context.getString(R.string.chooseBrowser))); context.startActivity(Intent.createChooser(intent, context.getString(R.string.chooseBrowser)));
} }
} }
public void playWithKodi() {
if(!videoTitle.isEmpty()) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage(KORE_PACKET);
intent.setData(Uri.parse(webisteUrl.replace("https", "http")));
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(R.string.koreNotFound)
.setPositiveButton(R.string.installeKore, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(context.getString(R.string.fdroidKoreUrl)));
context.startActivity(intent);
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.create().show();
}
}
}
} }

View File

@ -156,7 +156,11 @@ public class VideoItemDetailFragment extends Fragment {
ImageView uploaderThumbnailView = (ImageView) a.findViewById(R.id.detailUploaderThumbnailView); ImageView uploaderThumbnailView = (ImageView) a.findViewById(R.id.detailUploaderThumbnailView);
ImageView thumbsUpPic = (ImageView) a.findViewById(R.id.detailThumbsUpImgView); ImageView thumbsUpPic = (ImageView) a.findViewById(R.id.detailThumbsUpImgView);
ImageView thumbsDownPic = (ImageView) a.findViewById(R.id.detailThumbsDownImgView); ImageView thumbsDownPic = (ImageView) a.findViewById(R.id.detailThumbsDownImgView);
View textSeperationLine = a.findViewById(R.id.textSeperationLine);
if(textSeperationLine != null) {
textSeperationLine.setVisibility(View.VISIBLE);
}
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
videoTitleView.setVisibility(View.VISIBLE); videoTitleView.setVisibility(View.VISIBLE);
uploaderView.setVisibility(View.VISIBLE); uploaderView.setVisibility(View.VISIBLE);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B

View File

@ -59,7 +59,7 @@
android:visibility="invisible" android:visibility="invisible"
android:text="Herr von Gurken" /> android:text="Herr von Gurken" />
<View <View android:id="@+id/textSeperationLine"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="@android:color/darker_gray" android:background="@android:color/darker_gray"

View File

@ -4,12 +4,12 @@
<item android:id="@+id/menu_item_play" <item android:id="@+id/menu_item_play"
android:title="@string/play" android:title="@string/play"
app:showAsAction="always" app:showAsAction="always"
android:icon="@drawable/ai_play"/> android:icon="@drawable/ic_play_arrow_black"/>
<item android:id="@+id/menu_item_share" <item android:id="@+id/menu_item_share"
android:title="@string/share" android:title="@string/share"
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:icon="@drawable/ai_share"/> android:icon="@drawable/ic_share_black"/>
<item android:id="@+id/menu_item_openInBrowser" <item android:id="@+id/menu_item_openInBrowser"
app:showAsAction="never" app:showAsAction="never"
@ -22,4 +22,9 @@
<item android:id="@+id/action_settings" <item android:id="@+id/action_settings"
app:showAsAction="never" app:showAsAction="never"
android:title="@string/settings"/> android:title="@string/settings"/>
<item android:id="@+id/action_play_with_kodi"
android:title="@string/playWithKodiTitle"
app:showAsAction="ifRoom"
android:icon="@drawable/ic_cast_black"/>
</menu> </menu>

View File

@ -28,4 +28,10 @@
<string name="autoPlayThroughIntentTitle">Automatisch abspielen durch Intent.</string> <string name="autoPlayThroughIntentTitle">Automatisch abspielen durch Intent.</string>
<string name="autoPlayThroughIntentSummary">Startet ein Video automatisch wenn es von einer anderen App aufgerufen wurde.</string> <string name="autoPlayThroughIntentSummary">Startet ein Video automatisch wenn es von einer anderen App aufgerufen wurde.</string>
<string name="defaultResolutionPreferenceTitle">Standard Auflösung</string> <string name="defaultResolutionPreferenceTitle">Standard Auflösung</string>
<string name="playWithKodiTitle">Mit Kodi abspielen</string>
<string name="koreNotFound">Kore app wurde nicht gefunden. Kore wird benötigt, um Videos mit Kodi wieder zu geben.</string>
<string name="installeKore">Kore installieren</string>
<string name="fdroidKoreUrl">https://f-droid.org/repository/browse/?fdfilter=Kore&amp;fdid=org.xbmc.kore</string>
<string name="showPlayWithKodiTitle">Zeige \"Mit Kodi abspielen\" Option</string>
<string name="showPlayWithKodiSummary">Zeigt eine Option an, über die man Videos mit dem Kodi Mediacenter abspielen kann.</string>
</resources> </resources>

View File

@ -1,12 +0,0 @@
<resources>
<!-- Declare custom theme attributes that allow changing which styles are
used for button bars depending on the API level.
?android:attr/buttonBarStyle is new as of API 11 so this is
necessary to support previous API levels. -->
<declare-styleable name="ButtonBarContainerTheme">
<attr name="metaButtonBarStyle" format="reference" />
<attr name="metaButtonBarButtonStyle" format="reference" />
</declare-styleable>
</resources>

View File

@ -11,4 +11,5 @@
<item>144p</item> <item>144p</item>
</string-array> </string-array>
<string name="defaultResolutionListItem">360p</string> <string name="defaultResolutionListItem">360p</string>
<string name="showPlayWidthKodiPreference">show_play_with_kodi_preference</string>
</resources> </resources>

View File

@ -28,4 +28,10 @@
<string name="autoPlayThroughIntentTitle">Autoplay through Intent</string> <string name="autoPlayThroughIntentTitle">Autoplay through Intent</string>
<string name="autoPlayThroughIntentSummary">Automatically starts a video when it was called from another app.</string> <string name="autoPlayThroughIntentSummary">Automatically starts a video when it was called from another app.</string>
<string name="defaultResolutionPreferenceTitle">Default Resolution</string> <string name="defaultResolutionPreferenceTitle">Default Resolution</string>
<string name="playWithKodiTitle">Play with Kodi</string>
<string name="koreNotFound">Kore app not found. Kore is needed to play videos with Kodi media center.</string>
<string name="installeKore">Install Kore</string>
<string name="fdroidKoreUrl">https://f-droid.org/repository/browse/?fdfilter=Kore&amp;fdid=org.xbmc.kore</string>
<string name="showPlayWithKodiTitle">Show \"Play with Kodi\" option</string>
<string name="showPlayWithKodiSummary">Displays an option to play a video via Kodi media center.</string>
</resources> </resources>

View File

@ -28,4 +28,10 @@
android:entryValues="@array/resolutionList" android:entryValues="@array/resolutionList"
android:defaultValue="@string/defaultResolutionListItem"/> android:defaultValue="@string/defaultResolutionListItem"/>
<CheckBoxPreference
android:key="@string/showPlayWidthKodiPreference"
android:title="@string/showPlayWithKodiTitle"
android:summary="@string/showPlayWithKodiSummary"
android:defaultValue="false" />
</PreferenceScreen> </PreferenceScreen>