diff --git a/app/build.gradle b/app/build.gradle index b5ed88e..0f3b4cd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,10 +7,10 @@ android { defaultConfig { applicationId "com.workaround.spectv" - minSdk 28 + minSdk 25 targetSdk 32 - versionCode 1 - versionName "1.0" + versionCode 2 + versionName "1.2.1gigem1" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 148ee52..d5bb7e8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,7 @@ android:exported="true" android:icon="@drawable/app_icon_your_company" android:label="@string/title_activity_main" + android:launchMode="singleTask" android:logo="@drawable/app_icon_your_company" android:screenOrientation="landscape"> @@ -31,7 +32,15 @@ + + + + + + - \ No newline at end of file + diff --git a/app/src/main/java/com/workaround/spectv/MainActivity.java b/app/src/main/java/com/workaround/spectv/MainActivity.java index 97625ce..0d333c6 100644 --- a/app/src/main/java/com/workaround/spectv/MainActivity.java +++ b/app/src/main/java/com/workaround/spectv/MainActivity.java @@ -2,8 +2,10 @@ import android.annotation.SuppressLint; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Color; +import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; @@ -67,7 +69,30 @@ public class MainActivity extends FragmentActivity { "$('video')[0].volume = 1.0;" + // Load Guide "Spectv.preloadGuide();" + - "clearInterval(loopVar)"+ + "clearInterval(loopVar);"+ + + // Watfor for and click the Still there? Continue button. + "var observer = new MutationObserver(function(mutations) {" + + "for (mutation of mutations) {" + + "for (addedNode of mutation.addedNodes) {" + + "var button = document.evaluate(" + + "\"//button[contains(text(), 'Continue')]\"," + + "addedNode, null," + + "XPathResult.FIRST_ORDERED_NODE_TYPE," + + "null).singleNodeValue;" + + "if (button) {" + + "console.log('clicking continue button');" + + "button.click();" + + "return;" + + "}" + + "}" + + "};" + + "});" + + "observer.observe(document.body, {" + + "subtree: true," + + "childList: true" + + "});" + + "}" + "}" + @@ -111,7 +136,7 @@ public class MainActivity extends FragmentActivity { "$('.channel-content-list-container').focus();" + "}" + "$('.channel-content-list-container').unbind('click');" + - "$('.channel-content-list-container').on('click', function(event) {event.preventDefault(); event.stopImmediatePropagation(); Spectv.navToChannel(new URL(event.target.href).searchParams.get('tmsGuideServiceId'))});" + + "$('.channel-content-list-container').on('click', function(event) {event.preventDefault(); event.stopImmediatePropagation(); Spectv.navToChannel(new URL(event.target.href).searchParams.get('tmsGuideServiceId'), true)});" + "}" + "catch (error) {" + @@ -127,7 +152,16 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); sharedPref = this.getSharedPreferences("com.workaround.spectv.pref", Context.MODE_PRIVATE); sharedPrefEdit = sharedPref.edit(); - lastChannelURL = sharedPref.getString("lastChannel", ""); + Uri intentData = getIntent().getData(); + if (intentData != null) + lastChannelURL = intentData.toString(); + else { + String channelId = getIntent().getStringExtra("channelId"); + if (channelId != null) + lastChannelURL = baseLiveChannelURL + channelId; + else + lastChannelURL = sharedPref.getString("lastChannel", ""); + } initPlayer(); initGuide(); @@ -136,6 +170,21 @@ public void onCreate(Bundle savedInstanceState) { spectrumGuide.addJavascriptInterface(this, "Spectv"); } + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + String channelId; + Uri intentData = intent.getData(); + if (intentData != null) { + String uriStr = intentData.toString(); + int equals = uriStr.lastIndexOf("="); + channelId = uriStr.substring(equals+1); + } else { + channelId = intent.getStringExtra("channelId"); + } + navToChannel(channelId, false); + } + @SuppressLint("RestrictedApi") @Override public boolean dispatchKeyEvent(KeyEvent event) { @@ -229,7 +278,7 @@ public void run() { } @JavascriptInterface - public void navToChannel(String channelId) { + public void navToChannel(String channelId, boolean doBack) { try { runOnUiThread(new Runnable() { @Override @@ -237,7 +286,8 @@ public void run() { saveLastChannel(channelId); spectrumPlayer.loadUrl(baseLiveChannelURL + channelId); spectrumGuide.setVisibility(View.GONE); - spectrumGuide.evaluateJavascript("history.back();", null); + if (doBack) + spectrumGuide.evaluateJavascript("history.back();", null); } }); } catch (Exception e) { @@ -378,4 +428,4 @@ public void onPageFinished(WebView view, String url) { } -} \ No newline at end of file +}