Fix issue #16
This commit is contained in:
parent
4ffa027e8d
commit
9af7934448
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="app.fedilab.fedilabtube">
|
||||
|
||||
|
||||
<application
|
||||
android:name=".FedilabTube"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:replace="android:allowBackup">
|
||||
|
||||
<activity
|
||||
android:name=".PeertubeActivity"
|
||||
tools:node="mergeOnlyAttributes">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<!-- The app is a good candidate for URL in https://domain.name/videos/watch/xxxxx-->
|
||||
<data
|
||||
android:host="*"
|
||||
android:pathPrefix="/videos/watch/"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="app.fedilab.fedilabtube">
|
||||
|
||||
|
||||
<application
|
||||
android:name=".FedilabTube"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:replace="android:allowBackup">
|
||||
|
||||
<activity
|
||||
android:name=".PeertubeActivity"
|
||||
tools:node="mergeOnlyAttributes">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<!-- The app is a good candidate for URL in https://domain.name/videos/watch/xxxxx-->
|
||||
<data
|
||||
android:host="*"
|
||||
android:pathPrefix="/videos/watch/"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
|
@ -94,6 +94,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import app.fedilab.fedilabtube.client.APIResponse;
|
||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||
|
@ -207,7 +209,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
|
||||
mode = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL);
|
||||
|
||||
Bundle b = getIntent().getExtras();
|
||||
Intent intent = getIntent();
|
||||
|
||||
Bundle b = intent.getExtras();
|
||||
if (b != null) {
|
||||
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
|
||||
videoUuid = b.getString("video_uuid", null);
|
||||
|
@ -216,6 +220,16 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
peertube = b.getParcelable("video");
|
||||
}
|
||||
|
||||
if(intent.getData() != null) { //Comes from a link
|
||||
String url = intent.getData().toString();
|
||||
Pattern link = Pattern.compile("(https?://[\\da-z.-]+\\.[a-z.]{2,10})/videos/watch/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$");
|
||||
Matcher matcherLink = link.matcher(url);
|
||||
if (matcherLink.find()) {
|
||||
peertubeInstance = matcherLink.group(1).replace("https://","").replace("http://","");
|
||||
sepiaSearch = true; // Sepia search flag is used because, at this time we don't know if the video is federated.
|
||||
videoUuid = matcherLink.group(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
|
||||
binding.writeCommentContainerReply.setVisibility(View.GONE);
|
||||
|
|
|
@ -661,6 +661,9 @@ public class Helper {
|
|||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userName = sharedpreferences.getString(Helper.PREF_KEY_NAME, "");
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, "");
|
||||
if( video == null) {
|
||||
return false;
|
||||
}
|
||||
Account account = video.getAccount();
|
||||
ChannelData.Channel channel = video.getChannel();
|
||||
if (account != null && instance != null && userName != null) {
|
||||
|
|
Loading…
Reference in New Issue