Skip to content

Commit

Permalink
recover install client method
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXiaoM committed Feb 20, 2025
1 parent 959eef4 commit c718ae8
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
25 changes: 25 additions & 0 deletions FCL/src/main/java/com/tungsten/fcl/fragment/RuntimeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class RuntimeFragment : FCLFragment(), View.OnClickListener {
var java17: Boolean = false
var java21: Boolean = false
var jna: Boolean = false
var client: Boolean = false

override fun onCreateView(
inflater: LayoutInflater,
Expand Down Expand Up @@ -75,6 +76,7 @@ class RuntimeFragment : FCLFragment(), View.OnClickListener {
java17 = RuntimeUtils.isLatest(FCLPath.JAVA_17_PATH, "/assets/app_runtime/java/jre17")
java21 = RuntimeUtils.isLatest(FCLPath.JAVA_21_PATH, "/assets/app_runtime/java/jre21")
jna = RuntimeUtils.isLatest(FCLPath.JNA_PATH, "/assets/app_runtime/jna")
client = RuntimeUtils.isLatest(FCLPath.SHARED_COMMON_DIR, "/assets/minecraft")
} catch (e: IOException) {
e.printStackTrace()
}
Expand All @@ -100,6 +102,7 @@ class RuntimeFragment : FCLFragment(), View.OnClickListener {
java17State.setBackgroundDrawable(if (java17) stateDone else stateUpdate)
java21State.setBackgroundDrawable(if (java21) stateDone else stateUpdate)
jnaState.setBackgroundDrawable(if (jna) stateDone else stateUpdate)
clientState.setBackgroundDrawable(if (client) stateDone else stateUpdate)
}
}
}
Expand Down Expand Up @@ -364,6 +367,28 @@ class RuntimeFragment : FCLFragment(), View.OnClickListener {
}
}.start()
}
if (!client) {
clientState.visibility = View.GONE
clientProgress.visibility = View.VISIBLE
Thread {
try {
RuntimeUtils.install(
context,
FCLPath.SHARED_COMMON_DIR,
"minecraft"
)
client = true
} catch (e: IOException) {
e.printStackTrace()
}
activity?.runOnUiThread {
clientState.visibility = View.VISIBLE
clientProgress.visibility = View.GONE
refreshDrawables()
check()
}
}.start()
}
}
}

Expand Down
41 changes: 41 additions & 0 deletions FCL/src/main/res/layout/fragment_runtime.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,47 @@

</androidx.appcompat.widget.LinearLayoutCompat>

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="horizontal">

<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/splash_runtime_client"
android:layout_gravity="center"/>

<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>

<com.tungsten.fcllibrary.component.view.FCLProgressBar
android:visibility="gone"
android:layout_width="24dp"
android:layout_height="24dp"
android:id="@+id/client_progress"
android:layout_gravity="center"
android:layout_marginStart="10dp"/>

<com.tungsten.fcllibrary.component.view.FCLImageView
app:auto_src_tint="false"
android:backgroundTint="@android:color/darker_gray"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/client_state"
android:layout_gravity="center"
android:layout_marginStart="10dp"/>

</androidx.appcompat.widget.LinearLayoutCompat>

</androidx.appcompat.widget.LinearLayoutCompat>

</ScrollView>
Expand Down

0 comments on commit c718ae8

Please sign in to comment.