From b47209483a36ab5d14b7e9ed1816ce0f8959cedf Mon Sep 17 00:00:00 2001
From: LagradOst <11805592+LagradOst@users.noreply.github.com>
Date: Tue, 10 Oct 2023 18:05:31 +0200
Subject: [PATCH] reverted to instant outline
---
.../lagradost/cloudstream3/MainActivity.kt | 55 +++++----
app/src/main/res/drawable/outline.xml | 4 +-
.../main/res/drawable/outline_drawable.xml | 4 +-
.../res/drawable/outline_drawable_less.xml | 2 +-
app/src/main/res/layout/fragment_result.xml | 2 +-
app/src/main/res/layout/result_episode.xml | 4 +-
.../main/res/layout/result_episode_both.xml | 9 --
.../res/layout/result_episode_both_old.xml | 14 +++
.../res/layout/result_episode_both_tv.xml | 21 ----
.../res/layout/result_episode_both_tv_old.xml | 21 ++++
.../main/res/layout/result_episode_large.xml | 1 +
.../res/layout/result_episode_large_tv.xml | 111 -----------------
.../layout/result_episode_large_tv_old.xml | 112 ++++++++++++++++++
app/src/main/res/layout/result_episode_tv.xml | 60 ----------
.../main/res/layout/result_episode_tv_old.xml | 59 +++++++++
app/src/main/res/values/styles.xml | 9 +-
16 files changed, 246 insertions(+), 242 deletions(-)
delete mode 100644 app/src/main/res/layout/result_episode_both.xml
create mode 100644 app/src/main/res/layout/result_episode_both_old.xml
delete mode 100644 app/src/main/res/layout/result_episode_both_tv.xml
create mode 100644 app/src/main/res/layout/result_episode_both_tv_old.xml
delete mode 100644 app/src/main/res/layout/result_episode_large_tv.xml
create mode 100644 app/src/main/res/layout/result_episode_large_tv_old.xml
delete mode 100644 app/src/main/res/layout/result_episode_tv.xml
create mode 100644 app/src/main/res/layout/result_episode_tv_old.xml
diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt
index 51032a6e..4e0d93c9 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt
@@ -283,6 +283,7 @@ var app = Requests(responseParser = object : ResponseParser {
class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
companion object {
const val TAG = "MAINACT"
+ const val ANIMATED_OUTLINE : Boolean = false
var lastError: String? = null
/**
@@ -1070,7 +1071,22 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
}
}
-
+ private fun centerView(view : View?) {
+ if(view == null) return
+ try {
+ Log.v(TAG, "centerView: $view")
+ val r = Rect(0, 0, 0, 0)
+ view.getDrawingRect(r)
+ val x = r.centerX()
+ val y = r.centerY()
+ val dx = r.width() / 2 //screenWidth / 2
+ val dy = screenHeight / 2
+ val r2 = Rect(x - dx, y - dy, x + dx, y + dy)
+ view.requestRectangleOnScreen(r2, false)
+ // TvFocus.current =TvFocus.current.copy(y=y.toFloat())
+ } catch (_: Throwable) {
+ }
+ }
override fun onCreate(savedInstanceState: Bundle?) {
app.initClient(this)
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
@@ -1125,43 +1141,26 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
val newLocalBinding = ActivityMainTvBinding.inflate(layoutInflater, null, false)
setContentView(newLocalBinding.root)
- if(isTrueTvSettings()) {
+ if(isTrueTvSettings() && ANIMATED_OUTLINE) {
TvFocus.focusOutline = WeakReference(newLocalBinding.focusOutline)
+ newLocalBinding.root.viewTreeObserver.addOnScrollChangedListener {
+ TvFocus.updateFocusView(TvFocus.lastFocus.get(), same = true)
+ }
newLocalBinding.root.viewTreeObserver.addOnGlobalFocusChangeListener { _, newFocus ->
- // println("refocus $oldFocus -> $newFocus")
- try {
- val r = Rect(0, 0, 0, 0)
- newFocus.getDrawingRect(r)
- val x = r.centerX()
- val y = r.centerY()
- val dx = 0 //screenWidth / 2
- val dy = screenHeight / 2
- val r2 = Rect(x - dx, y - dy, x + dx, y + dy)
- newFocus.requestRectangleOnScreen(r2, false)
- // TvFocus.current =TvFocus.current.copy(y=y.toFloat())
- } catch (_: Throwable) {
- }
TvFocus.updateFocusView(newFocus)
- /*var focus = newFocus
-
- while(focus != null) {
- if(focus is ScrollingView && focus.canScrollVertically()) {
- focus.scrollBy()
- }
- when(focus.parent) {
- is View -> focus = newFocus
- else -> break
- }
- }*/
}
} else {
newLocalBinding.focusOutline.isVisible = false
}
- newLocalBinding.root.viewTreeObserver.addOnScrollChangedListener {
- TvFocus.updateFocusView(TvFocus.lastFocus.get(), same = true)
+ if(isTrueTvSettings()) {
+ newLocalBinding.root.viewTreeObserver.addOnGlobalFocusChangeListener { _, newFocus ->
+ centerView(newFocus)
+ }
}
+
+
ActivityMainBinding.bind(newLocalBinding.root) // this may crash
} else {
val newLocalBinding = ActivityMainBinding.inflate(layoutInflater, null, false)
diff --git a/app/src/main/res/drawable/outline.xml b/app/src/main/res/drawable/outline.xml
index 30077a98..7b436c7d 100644
--- a/app/src/main/res/drawable/outline.xml
+++ b/app/src/main/res/drawable/outline.xml
@@ -2,11 +2,9 @@
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/outline_drawable.xml b/app/src/main/res/drawable/outline_drawable.xml
index 8eec2d0b..16eba83c 100644
--- a/app/src/main/res/drawable/outline_drawable.xml
+++ b/app/src/main/res/drawable/outline_drawable.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/outline_drawable_less.xml b/app/src/main/res/drawable/outline_drawable_less.xml
index db74a092..aa3a8d0d 100644
--- a/app/src/main/res/drawable/outline_drawable_less.xml
+++ b/app/src/main/res/drawable/outline_drawable_less.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_result.xml b/app/src/main/res/layout/fragment_result.xml
index 87de7186..9d748c5a 100644
--- a/app/src/main/res/layout/fragment_result.xml
+++ b/app/src/main/res/layout/fragment_result.xml
@@ -875,7 +875,7 @@
android:descendantFocusability="afterDescendants"
android:paddingBottom="100dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
- tools:listitem="@layout/result_episode_both_tv" />
+ tools:listitem="@layout/result_episode" />
diff --git a/app/src/main/res/layout/result_episode.xml b/app/src/main/res/layout/result_episode.xml
index 80ff4bec..b56cdb1d 100644
--- a/app/src/main/res/layout/result_episode.xml
+++ b/app/src/main/res/layout/result_episode.xml
@@ -11,7 +11,9 @@
android:nextFocusRight="@id/download_button"
app:cardBackgroundColor="@color/transparent"
app:cardCornerRadius="@dimen/rounded_image_radius"
- app:cardElevation="0dp">
+ app:cardElevation="0dp"
+ android:foreground="@drawable/outline_drawable"
+ >
diff --git a/app/src/main/res/layout/result_episode_both.xml b/app/src/main/res/layout/result_episode_both.xml
deleted file mode 100644
index 61102e84..00000000
--- a/app/src/main/res/layout/result_episode_both.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/result_episode_both_old.xml b/app/src/main/res/layout/result_episode_both_old.xml
new file mode 100644
index 00000000..6472ecc1
--- /dev/null
+++ b/app/src/main/res/layout/result_episode_both_old.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/result_episode_both_tv.xml b/app/src/main/res/layout/result_episode_both_tv.xml
deleted file mode 100644
index 13888b7e..00000000
--- a/app/src/main/res/layout/result_episode_both_tv.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/result_episode_both_tv_old.xml b/app/src/main/res/layout/result_episode_both_tv_old.xml
new file mode 100644
index 00000000..f273a118
--- /dev/null
+++ b/app/src/main/res/layout/result_episode_both_tv_old.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/result_episode_large.xml b/app/src/main/res/layout/result_episode_large.xml
index 75292965..76e8c434 100644
--- a/app/src/main/res/layout/result_episode_large.xml
+++ b/app/src/main/res/layout/result_episode_large.xml
@@ -8,6 +8,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
+ android:foreground="@drawable/outline_drawable"
android:nextFocusRight="@id/download_button"
app:cardBackgroundColor="?attr/boxItemBackground"
diff --git a/app/src/main/res/layout/result_episode_large_tv.xml b/app/src/main/res/layout/result_episode_large_tv.xml
deleted file mode 100644
index 5a9dee30..00000000
--- a/app/src/main/res/layout/result_episode_large_tv.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/result_episode_large_tv_old.xml b/app/src/main/res/layout/result_episode_large_tv_old.xml
new file mode 100644
index 00000000..3a7cef3c
--- /dev/null
+++ b/app/src/main/res/layout/result_episode_large_tv_old.xml
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/result_episode_tv.xml b/app/src/main/res/layout/result_episode_tv.xml
deleted file mode 100644
index 53590b6b..00000000
--- a/app/src/main/res/layout/result_episode_tv.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/result_episode_tv_old.xml b/app/src/main/res/layout/result_episode_tv_old.xml
new file mode 100644
index 00000000..62546cf9
--- /dev/null
+++ b/app/src/main/res/layout/result_episode_tv_old.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index c00970d3..c047c749 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -86,8 +86,8 @@