From 08648caaff83b779bccbc2f1c9f649b2f8302740 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Tue, 15 Sep 2015 20:11:42 +0200 Subject: [PATCH] fixed landscape layout problem & added watch with kodi function --- .../org/schabi/newpipe/ActionBarHandler.java | 52 +++++++++++++++++- .../newpipe/VideoItemDetailFragment.java | 4 ++ app/src/main/res/drawable/ai_play.png | Bin 1433 -> 0 bytes app/src/main/res/drawable/ai_share.png | Bin 2019 -> 0 bytes app/src/main/res/drawable/ic_cast_black.png | Bin 0 -> 869 bytes .../main/res/drawable/ic_play_arrow_black.png | Bin 0 -> 320 bytes app/src/main/res/drawable/ic_share_black.png | Bin 0 -> 888 bytes .../fragment_videoitem_detail.xml | 2 +- app/src/main/res/menu/videoitem_detail.xml | 9 ++- app/src/main/res/values-de/strings.xml | 6 ++ app/src/main/res/values/attrs.xml | 12 ---- app/src/main/res/values/settings_keys.xml | 1 + app/src/main/res/values/strings.xml | 6 ++ app/src/main/res/xml/settings_screen.xml | 6 ++ 14 files changed, 80 insertions(+), 18 deletions(-) delete mode 100644 app/src/main/res/drawable/ai_play.png delete mode 100644 app/src/main/res/drawable/ai_share.png create mode 100644 app/src/main/res/drawable/ic_cast_black.png create mode 100644 app/src/main/res/drawable/ic_play_arrow_black.png create mode 100644 app/src/main/res/drawable/ic_share_black.png rename app/src/main/res/{layout-sw600dp => layout-land}/fragment_videoitem_detail.xml (99%) delete mode 100644 app/src/main/res/values/attrs.xml diff --git a/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java b/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java index 856e853b1..1be21537f 100644 --- a/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java +++ b/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java @@ -4,7 +4,9 @@ import android.app.DownloadManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.net.Uri; +import android.preference.Preference; import android.preference.PreferenceManager; import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBar; @@ -40,6 +42,8 @@ import java.io.File; public class ActionBarHandler { private static final String TAG = ActionBarHandler.class.toString(); + private static final String KORE_PACKET = "org.xbmc.kore"; + private static ActionBarHandler handler = null; private Context context = null; @@ -49,6 +53,8 @@ public class ActionBarHandler { private int selectedStream = -1; private String videoTitle = ""; + SharedPreferences defaultPreferences = null; + public static ActionBarHandler getHandler() { if(handler == null) { handler = new ActionBarHandler(); @@ -73,7 +79,7 @@ public class ActionBarHandler { this.streams = streams; selectedStream = 0; String[] itemArray = new String[streams.length]; - String defaultResolution = PreferenceManager.getDefaultSharedPreferences(context) + String defaultResolution = defaultPreferences .getString(context.getString(R.string.defaultResolutionPreference), context.getString(R.string.defaultResolutionListItem)); int defaultResolutionPos = 0; @@ -104,15 +110,21 @@ public class ActionBarHandler { // CAUTION set item properties programmatically otherwise it would not be accepted by // appcompat itemsinflater.inflate(R.menu.videoitem_detail, menu); + defaultPreferences = PreferenceManager.getDefaultSharedPreferences(context); + inflater.inflate(R.menu.videoitem_detail, menu); MenuItem playItem = menu.findItem(R.id.menu_item_play); 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.SHOW_AS_ACTION_WITH_TEXT); MenuItemCompat.setShowAsAction(shareItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); + castItem.setVisible(defaultPreferences + .getBoolean(context.getString(R.string.showPlayWidthKodiPreference), false)); + return true; } @@ -143,6 +155,10 @@ public class ActionBarHandler { Intent intent = new Intent(context, SettingsActivity.class); context.startActivity(intent); } + break; + case R.id.action_play_with_kodi: + playWithKodi(); + break; default: Log.e(TAG, "Menu Item not known"); } @@ -216,8 +232,7 @@ public class ActionBarHandler { DownloadManager.Request request = new DownloadManager.Request( Uri.parse(streams[selectedStream].url)); request.setDestinationUri(Uri.fromFile(new File( - PreferenceManager.getDefaultSharedPreferences(context) - .getString("download_path_preference", "/storage/emulated/0/NewPipe") + defaultPreferences.getString("download_path_preference", "/storage/emulated/0/NewPipe") + "/" + videoTitle + suffix))); try { dm.enqueue(request); @@ -236,4 +251,35 @@ public class ActionBarHandler { 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(); + } + } + } } diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java index 842118490..23ca053f8 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java @@ -156,7 +156,11 @@ public class VideoItemDetailFragment extends Fragment { ImageView uploaderThumbnailView = (ImageView) a.findViewById(R.id.detailUploaderThumbnailView); ImageView thumbsUpPic = (ImageView) a.findViewById(R.id.detailThumbsUpImgView); 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); videoTitleView.setVisibility(View.VISIBLE); uploaderView.setVisibility(View.VISIBLE); diff --git a/app/src/main/res/drawable/ai_play.png b/app/src/main/res/drawable/ai_play.png deleted file mode 100644 index 1d6b6229755f7c6b12cb71d02e01802a319c3db5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1433 zcmV;K1!nq*P)RJ0>CYj&7oeG059*q0h~t}yk0Q@}gG<;A*FQ|1a&ti!-lz=ef+ zR3rKcQ>@*H*Whhro)gBTzNE3{$L0!mF7j`G%nyqzF^2{lKI7hN99^hAGxo zV0Eqmshk{P>H((-TV0mr8J0@O6{c86foFk5IR>Y^a)&9_1h78C_>@tpFvZ#o+?0Hj z%A$0bdcYLn)y&ewV^v}`gele`-0IS_n!*%oC$KiRQcV>H#N! zSAa`WJpgs5_AtddKzKECL7K;)F0>M+Sl>xefS|@M`AD!o6sg)@G(N z>o{(8sY=UXinSO2g|Eab~K+Rls|| z*TC(Cdl{Hvs>>Sw-RjcZf%}H3J_~?HfPHx2eqa2|)PFT|;J!0c{jMb(W>)=y`-Z6< zW5BmmeBi!eYRf{x!LSpAS2GLCw)0L?`Pm)!r!K< z4H7sr)$BO%8t^jV2GHsmrus|+9{|q)zZdT1ycnjsY$N<$w5@a_gYYv`9S#7G5zftQ zGDzUeRN4vPE#M`>XQZYXrgAm`PXND`Zlo(NbNTHgoHa1c5CsVgQ%;8nKRT`fz9`&F z5-xM;odVtlUI6|q+)Gl1DXmR}*=S$sMsjeOOJjm?rsX&z5+pE8T{}vciB=Id`i~Ts zxo*U*ASwuX#hkN{_Di%X)|zR@=+>_Qem0^)@K->GRhsMqj(YX(8?92(}Y(b z%km6MCFBUxR$z6m0jZpnVcJi41)>p=B21HnTacFI8-{AoWtgT37uBrDIs#Rrt1xW` z?#$e~Dl^|O9VA>x#aD-_KIaP4W-7nbSoN75re>~NSAAlbjuBpgEH2uOnl?t*8nV1}Ba$RZk|arz nBuSDaNs=Trtl>o!`#yd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rC!t0zN_A%(=iXfX03D4LotBI`g z1S<0%>YO#+UF^z{cg1dCV*Ch?em4@oH(IvPpc;ACdZD|;$cE;rplg85BRsx6ZWo}vX9&J*E)*T2e{J(KT*AU)rDfLA>^ zOH-{V8)U;K>Nwu4=G2~ch(7PZMMIU(g$FzQCbra1Hi9a9utVoP8IZ4Io1mxYL>SJ! zfS-TXK(!_gF$d5LOq}jIdqScwA9j|CsWZ?GqC~g`+(3*hkhj=|Qp3M_?(F8x$G*$e zUYI;f2|UPqpldh?p5pBgt3n)(f+v`w06I+=YGsTkd1bB`(_s4Z&BbO~Zy7B=*;W@u zwLj_huh8&An}y+}D=q`hoSmuU#aEE`0TkQ|+7-3+i&4AFGNsHWwLwVGve*NBD0j#- zXUowcVZi!6my>UPKIbB+(#cJ!%^2*P`mM!Ft&TZEYJ;>8nJy9C49E0|bzMCA);yNB z)ilNsk>D87A@J2z+R)>Ygo%5mTF?ga!5OkN%7Al{?@bBRK4mCmv&5Jhjb6 zzZ=^^>HG82Y6WL}g8k0jv`V3Y6ICmUijZ|IA>sDqw)(oEGQr{(z0l)6;ZsP1BmWNh_sJXS$>sBxzH~|+GROr_a{ASgocdo*-k*;E diff --git a/app/src/main/res/drawable/ic_cast_black.png b/app/src/main/res/drawable/ic_cast_black.png new file mode 100644 index 0000000000000000000000000000000000000000..9dbfcd941727c3b3d3f12fc83c48046b000cd6d4 GIT binary patch literal 869 zcmV-r1DgDaP)6InX+~W{s1%9Trh+u>OK1`8S`&b#6qkfw8no3WrS2j z+de3XBuM`iwJ~*3iW)?Un4jav+_rk&d&gPKIOo85-sSmmm}l-i^S%cZi^XEGSS%LH z0=Cmg4`Ce5Doi&awi19Ok$| zP%i-=X{@1u{ZtU5otY&izLBqUCr)QCx9E+kFixrdqr`6RGZ{sq+Jspso6C%NDm=t* z!Z5drTEZR*&k2|@jc(wrr-I*d{3bBbg zqwW*eB42U@+=qc6gG%P9lE@H;JwJH@5lT_1QZggr8}3jN@<}G{4_`(7C0EJh5m7S5 zO5&dUu}z3TCoygO2$hZ{UbM4vhlB{!$0jhxIwf^oN&Kg_JY~HtAp#K!iE-nLO6rLC zZ;HhfDeGMc5omx|1zsqrLS_92i^&naBK`uc1Y;NI7ws(i2h32`C*mv+p@AU8E)W*I vAo_Z$I7RUin5L8Zh3~$_VzF2(7K`N{_zPlQnKI~100000NkvXXu0mjfgPMLk literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/ic_play_arrow_black.png b/app/src/main/res/drawable/ic_play_arrow_black.png new file mode 100644 index 0000000000000000000000000000000000000000..d12d495622fd5d3a5e91fb6032a88a0492557aaa GIT binary patch literal 320 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%&M7z{u|D;uuoF_;!|IV6&qH>wc3d zf(=X;8n{9lxC0pV3s}T;nne-? z)~>paPb2Pm^0|K<=BZzL=UhB(GofEdzxb2E^TH}`gTLOMTxqQ$XU@Gn_$BM&>AQ0e zeqmy>mM7*}PBNfg!`- M>FVdQ&MBb@05rae3;+NC literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/ic_share_black.png b/app/src/main/res/drawable/ic_share_black.png new file mode 100644 index 0000000000000000000000000000000000000000..5a8544ce5d6c8bf471c8fbd54cf4f88254ea9ccb GIT binary patch literal 888 zcmV-;1Bd*HP)9LMqRypZ5w`JO>))98$f6)oE2rdCPO(4t&OEy|HVqeUTEVJbno>6L`orcEYB zO@<!#gj`DvJ3WY+U zOXmgB9rTlB8$sA6%WE_c81+o!A$fUBQ49J#&EJTj15zm0gJ7>4#oCY}dJ?5-IY5eN zpBhw}M2c)2g=+DTB0D3FI(>*kub|EX;?NxGY$6V=qfQQS=oocQ5r>XYXB~0qXVl3e z4tVzmNT;dsiN1Pi)h5PviagRT!#CK8B$bZVC8K2!qANxqb ze#NtY#_=pZYi128*dhH~rkNeY&<>B`tGoCTF*HdH08qt9fnCb+E*1Ewj3MJ(e#-+~ zR7EGBvc?{}{Kz!VQ|a$qwzFkC7SC}5s@=!e##izkZb7x%_y94q$UP_!vCL%;d&aNH zC-7Aruae<6&hXeGLoabIdX!b`T>2=%Bwm5@oF)bU+{qV~xs2nhR?GF%E-l>5TjY#$ z*@VwtMyz>kYo5!e5PQ1kGR{6?PWxQK$A~#ab7_#^3~}m^0WPCPFJegBTpG+H4$TMs z?(%xj?=Ew}e*kqhf_{YNg8mYBBTjun9ja7wia2$|>y)C%hlq0X|_d z%}}r7A-edCpE%%<>&)^3Q7%gIgYj>?Z%_*QmGGkRxNVXm0{T@jVtnnFXe1CCSu$?c zC>7{OgcO^`%dnRyK|kxfF7pWa614L+0CA`db%qd! z22p1macB&6(m{WK;h-O(4#c4p>Li?IGzvlf-`xdNN+Lzpgi=#T5q*SO<*Xp~_>M9Z zt7h5$>vKEGU1h>@c*+QbhsfaN4d(()1WJrH1{phVkQ7lup-?CkD#AaVcIHkIiEiWo O0000 - + android:icon="@drawable/ic_play_arrow_black"/> + android:icon="@drawable/ic_share_black"/> + + \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 4e24b42c1..da39d8f3b 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -28,4 +28,10 @@ Automatisch abspielen durch Intent. Startet ein Video automatisch wenn es von einer anderen App aufgerufen wurde. Standard Auflösung + Mit Kodi abspielen + Kore app wurde nicht gefunden. Kore wird benötigt, um Videos mit Kodi wieder zu geben. + Kore installieren + https://f-droid.org/repository/browse/?fdfilter=Kore&fdid=org.xbmc.kore + Zeige \"Mit Kodi abspielen\" Option + Zeigt eine Option an, über die man Videos mit dem Kodi Mediacenter abspielen kann. diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml deleted file mode 100644 index 7ce840eb6..000000000 --- a/app/src/main/res/values/attrs.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 464207fb6..5ad6be083 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -11,4 +11,5 @@ 144p 360p + show_play_with_kodi_preference \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9eb05d869..40d964e90 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,4 +28,10 @@ Autoplay through Intent Automatically starts a video when it was called from another app. Default Resolution + Play with Kodi + Kore app not found. Kore is needed to play videos with Kodi media center. + Install Kore + https://f-droid.org/repository/browse/?fdfilter=Kore&fdid=org.xbmc.kore + Show \"Play with Kodi\" option + Displays an option to play a video via Kodi media center. diff --git a/app/src/main/res/xml/settings_screen.xml b/app/src/main/res/xml/settings_screen.xml index e453128bc..a20d21711 100644 --- a/app/src/main/res/xml/settings_screen.xml +++ b/app/src/main/res/xml/settings_screen.xml @@ -28,4 +28,10 @@ android:entryValues="@array/resolutionList" android:defaultValue="@string/defaultResolutionListItem"/> + + \ No newline at end of file