diff --git a/README.md b/README.md index db85a71..f0efb17 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,4 @@ Finished: ✔ Collect favorite videos in the local database (本地收藏夹) -Not Finished Yet: - -✖ Show embedded video in the WebView (在WebView中显示嵌入视频) - -✖ Watch/Download videos (If someone provide me java library for capturing the m3u8 video from video page) **I know this option may break the rules of the Avgle, so if someone provide me such a library, I will not publish it. However, I will do it in another branch.** +✔ watch full video(在WebView中显示嵌入视频) \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8813709..224008f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -10,20 +11,30 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_avgle_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme"> - + + + tools:ignore="LockedOrientationActivity" /> + android:screenOrientation="portrait" + tools:ignore="LockedOrientationActivity" /> + android:screenOrientation="sensorLandscape" + tools:ignore="LockedOrientationActivity" /> + android:screenOrientation="portrait" + tools:ignore="LockedOrientationActivity"> diff --git a/app/src/main/java/com/absolutelycold/axgle/EmbedVideoActivity.java b/app/src/main/java/com/absolutelycold/axgle/EmbedVideoActivity.java new file mode 100644 index 0000000..e6d1b39 --- /dev/null +++ b/app/src/main/java/com/absolutelycold/axgle/EmbedVideoActivity.java @@ -0,0 +1,65 @@ +package com.absolutelycold.axgle; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.content.res.Configuration; +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.webkit.WebChromeClient; +import android.webkit.WebView; +import android.webkit.WebViewClient; + +import java.util.HashMap; + +public class EmbedVideoActivity extends AppCompatActivity { + + private String embeddedUrl; + private WebView webView; + private View decorView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_embed_video); + Intent intent = getIntent(); + embeddedUrl = intent.getStringExtra("embeddedUrl"); + + String frameVideo = ""; + + getSupportActionBar().hide(); + decorView = getWindow().getDecorView(); + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + decorView.setBackgroundColor(Color.BLACK); + + webView = findViewById(R.id.embed_video_web_view); + webView.setBackgroundColor(Color.TRANSPARENT); + + + webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); + webView.getSettings().setSupportMultipleWindows(true); + //webView.setWebViewClient(new WebViewClient()); + webView.setWebChromeClient(new WebChromeClient()); + webView.getSettings().setDomStorageEnabled(true); + webView.loadDataWithBaseURL("https://absolutelycold.github.io", frameVideo, "text/html", null, null); + //webView.loadDataWithBaseURL(null, frameVideo, "text/html", "utf-8", null); + //webView.loadUrl(embeddedUrl, extraHeader); + } + + @Override + protected void onPostResume() { + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + super.onPostResume(); + } + + @Override + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + } +} diff --git a/app/src/main/java/com/absolutelycold/axgle/MainActivity.java b/app/src/main/java/com/absolutelycold/axgle/MainActivity.java index 2df39ab..1e4641e 100644 --- a/app/src/main/java/com/absolutelycold/axgle/MainActivity.java +++ b/app/src/main/java/com/absolutelycold/axgle/MainActivity.java @@ -17,6 +17,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.WindowManager; import android.widget.CompoundButton; import android.widget.Switch; import android.widget.Toast; diff --git a/app/src/main/java/com/absolutelycold/axgle/ShowVideoPreviewActivity.java b/app/src/main/java/com/absolutelycold/axgle/ShowVideoPreviewActivity.java index 55eb123..542d0d3 100644 --- a/app/src/main/java/com/absolutelycold/axgle/ShowVideoPreviewActivity.java +++ b/app/src/main/java/com/absolutelycold/axgle/ShowVideoPreviewActivity.java @@ -43,6 +43,7 @@ protected void onCreate(Bundle savedInstanceState) { decorView = getWindow().getDecorView(); decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); decorView.setBackgroundColor(Color.BLACK); + if (savedInstanceState != null) { this.previewVideoUrl = savedInstanceState.getString("preview_video_url"); this.embeddedUrl = savedInstanceState.getString("embedded_url"); @@ -79,7 +80,6 @@ public void onClick(View view) { } }); videoView = findViewById(R.id.video_preview); - //System.out.println("Play Url: " + previewVideoUrl); } @@ -120,8 +120,8 @@ public void onSortOptionSelected(int position) { orderDialogFragment.dismiss(); break; case 1: - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(embeddedUrl)); + Intent intent = new Intent(this, EmbedVideoActivity.class); + intent.putExtra("embeddedUrl", embeddedUrl); startActivity(intent); break; case 2: @@ -142,4 +142,12 @@ protected void onSaveInstanceState(@NonNull Bundle outState) { outState.putString("video_url", videoUrl); outState.putString("embedded_url", embeddedUrl); } + + @Override + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + } + + } diff --git a/app/src/main/res/layout/activity_embed_video.xml b/app/src/main/res/layout/activity_embed_video.xml new file mode 100644 index 0000000..bc423c7 --- /dev/null +++ b/app/src/main/res/layout/activity_embed_video.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file