Skip to content

Commit 763eeda

Browse files
committed
optimize remote settings on mobile
1 parent 1a45f38 commit 763eeda

File tree

9 files changed

+84
-25
lines changed

9 files changed

+84
-25
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## 更新日誌
22

3+
### v1.3.9.1
4+
5+
* 優化手機上遠程配置
6+
37
### v1.3.9.0
48

59
* 支持socks代理

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
注意:
1818

1919
* 遇到問題可以先考慮重啟/恢復默認/清除數據/重新安裝等方式自助解決
20-
* 如果APP運行在手機上,建議在其他設備上進行遠程配置
2120
* 視頻源可以設置為本地文件,格式如:file:///mnt/sdcard/tmp/channels.m3u
2221
/channels.m3u
22+
* 目前設置代理後,需要重啟生效。代理屬於全局代理,也就是視頻請求及其他請求都會使用代理。
2323

2424
目前支持的配置格式:
2525

@@ -30,18 +30,20 @@
3030
```
3131
* m3u
3232
```
33-
#EXTM3U
34-
#EXTINF:-1 tvg-name="標準標題" tvg-logo="图标" group-title="組名",標題
33+
#EXTM3U x-tvg-url=""
34+
#EXTINF:-1 tvg-id="" tvg-name="標準標題" tvg-logo="图标" group-title="組名",標題
35+
#EXTVLCOPT:http-user-agent=
36+
#EXTVLCOPT:http-referrer=
3537
視頻地址
3638
```
3739
* json
3840
```json
3941
[
4042
{
4143
"group": "組名",
42-
"logo": "图标",
4344
"name": "標準標題",
4445
"title": "標題",
46+
"logo": "图标",
4547
"uris": [
4648
"視頻地址"
4749
],
@@ -80,13 +82,9 @@ adb install my-tv-0.apk
8082

8183
## TODO
8284

83-
* 支持回看
8485
* 詳細EPG
86+
* 支持回看
8587
* 淺色菜單
86-
* 無效的頻道?
87-
* 如果上次播放頻道不在收藏?
88-
* 當list為空,顯示group/空group不顯示?
89-
* 遠程配置使用webView
9088

9189
## 讚賞
9290

app/src/main/java/com/lizongying/mytv0/ChannelFragment.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ class ChannelFragment : Fragment() {
5959
fun show(tvViewModel: TVModel) {
6060
handler.removeCallbacks(hideRunnable)
6161
handler.removeCallbacks(playRunnable)
62-
binding.content.text = (tvViewModel.tv.id.plus(1)).toString()
62+
if (_binding != null) {
63+
binding.content.text = (tvViewModel.tv.id.plus(1)).toString()
64+
}
6365
view?.visibility = View.VISIBLE
6466
handler.postDelayed(hideRunnable, delay)
6567
}

app/src/main/java/com/lizongying/mytv0/GroupAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class GroupAdapter(
7474
defaultFocused = true
7575
}
7676

77-
val onFocusChangeListener = View.OnFocusChangeListener { _, hasFocus ->
77+
val onFocusChangeListener = View.OnFocusChangeListener { v, hasFocus ->
7878
listener?.onItemFocusChange(listTVModel, hasFocus)
7979

8080
if (hasFocus) {

app/src/main/java/com/lizongying/mytv0/MainActivity.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ import android.os.Handler
1111
import android.os.Looper
1212
import android.util.Log
1313
import android.view.GestureDetector
14+
import android.view.Gravity
1415
import android.view.KeyEvent
1516
import android.view.MotionEvent
1617
import android.view.View
1718
import android.view.WindowManager
19+
import android.widget.PopupWindow
20+
import android.widget.RelativeLayout
1821
import androidx.appcompat.app.AppCompatActivity
1922
import androidx.core.view.WindowCompat
2023
import androidx.core.view.WindowInsetsCompat
2124
import androidx.core.view.WindowInsetsControllerCompat
2225
import androidx.fragment.app.Fragment
2326
import androidx.lifecycle.ViewModelProvider
27+
import com.lizongying.mytv0.databinding.SettingsWebBinding
2428
import java.util.Locale
2529
import kotlin.math.abs
2630

@@ -633,6 +637,26 @@ class MainActivity : AppCompatActivity() {
633637
settingActive()
634638
}
635639

640+
fun showWebViewPopup(url: String) {
641+
val binding = SettingsWebBinding.inflate(layoutInflater)
642+
643+
val webView = binding.web
644+
webView.settings.javaScriptEnabled = true
645+
webView.loadUrl(url)
646+
647+
val popupWindow = PopupWindow(
648+
binding.root,
649+
RelativeLayout.LayoutParams.MATCH_PARENT,
650+
RelativeLayout.LayoutParams.MATCH_PARENT
651+
)
652+
653+
popupWindow.showAtLocation(this.window.decorView, Gravity.CENTER, 0, 0)
654+
655+
binding.close.setOnClickListener {
656+
popupWindow.dismiss()
657+
}
658+
}
659+
636660
fun onKey(keyCode: Int): Boolean {
637661
Log.d(TAG, "keyCode $keyCode")
638662
when (keyCode) {

app/src/main/java/com/lizongying/mytv0/ModalFragment.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.lizongying.mytv0
22

3-
import android.content.Intent
4-
import android.net.Uri
3+
import android.content.res.Configuration
54
import android.os.Bundle
65
import android.os.Handler
76
import android.os.Looper
7+
import android.util.Log
88
import android.view.LayoutInflater
99
import android.view.View
1010
import android.view.ViewGroup
@@ -54,12 +54,15 @@ class ModalFragment : DialogFragment() {
5454
.into(binding.modalImage)
5555
binding.modalText.text = u.removePrefix("http://")
5656
binding.modalText.visibility = View.VISIBLE
57-
binding.modal.setOnClickListener {
58-
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(u))
59-
try {
60-
startActivity(intent)
61-
} catch (e: Exception) {
62-
e.printStackTrace()
57+
if (!isTV()) {
58+
binding.modal.setOnClickListener {
59+
try {
60+
val mainActivity = (activity as MainActivity)
61+
mainActivity.showWebViewPopup(u)
62+
handler.postDelayed(hideAppreciateModal, 0)
63+
} catch (e: Exception) {
64+
Log.e(TAG, "onViewCreated", e)
65+
}
6366
}
6467
}
6568
} else {
@@ -78,6 +81,11 @@ class ModalFragment : DialogFragment() {
7881
}
7982
}
8083

84+
private fun isTV(): Boolean {
85+
val uiMode = resources.configuration.uiMode and Configuration.UI_MODE_TYPE_MASK
86+
return uiMode == Configuration.UI_MODE_TYPE_TELEVISION
87+
}
88+
8189
override fun onDestroyView() {
8290
super.onDestroyView()
8391
_binding = null

app/src/main/java/com/lizongying/mytv0/models/Sources.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ class Sources {
101101
}
102102

103103
fun getSource(idx: Int): Source? {
104-
if (idx >= size()) {
105-
return null
106-
}
107-
108-
if (sourcesValue.isEmpty()) {
104+
if (idx < 0 || idx >= size()) {
109105
return null
110106
}
111107

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:id="@+id/settings_web"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:background="@color/blur">
8+
9+
<androidx.appcompat.widget.AppCompatButton
10+
android:id="@+id/close"
11+
android:layout_width="60dp"
12+
android:layout_height="50dp"
13+
android:padding="10dp"
14+
android:text="X"
15+
app:layout_constraintEnd_toEndOf="parent"
16+
app:layout_constraintTop_toTopOf="parent" />
17+
18+
<WebView
19+
android:id="@+id/web"
20+
android:layout_width="0dp"
21+
android:layout_height="0dp"
22+
app:layout_constraintTop_toBottomOf="@id/close"
23+
app:layout_constraintStart_toStartOf="parent"
24+
app:layout_constraintEnd_toEndOf="parent"
25+
app:layout_constraintBottom_toBottomOf="parent"
26+
/>
27+
</androidx.constraintlayout.widget.ConstraintLayout>

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version_code": 16976128, "version_name": "v1.3.9.0"}
1+
{"version_code": 16976129, "version_name": "v1.3.9.1"}

0 commit comments

Comments
 (0)