Skip to content

Commit

Permalink
Some updates to RTL layout and display cutout and ripple effect
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Jun 7, 2021
1 parent 99b3d1c commit 6bef76b
Show file tree
Hide file tree
Showing 61 changed files with 497 additions and 434 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package space.celestia.ui.linkpreview

import android.content.Context
import android.graphics.Color
import android.os.Build
import android.util.AttributeSet
import android.util.TypedValue
Expand Down Expand Up @@ -71,10 +72,14 @@ class LPLinkView(context: Context, val attrs: AttributeSet) : CardView(context,
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleLabelSize)
titleView.setTextColor(ContextCompat.getColor(context, titleLabelColor))
titleView.text = metaData.title
titleView.textAlignment = TEXT_ALIGNMENT_VIEW_START
titleView.setBackgroundColor(Color.TRANSPARENT)
val urlView = TextView(context)
urlView.text = metaData.url.host
urlView.setTextSize(TypedValue.COMPLEX_UNIT_PX, footerLabelSize)
urlView.setTextColor(ContextCompat.getColor(context, footerLabelColor))
urlView.textAlignment = TEXT_ALIGNMENT_VIEW_START
urlView.setBackgroundColor(Color.TRANSPARENT)

(urlView.layoutParams as? MarginLayoutParams)?.topMargin = textContentSpacing

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="space.celestia.mobilecelestia"
android:versionCode="191"
android:versionCode="198"
android:versionName="1.3.5">

<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Expand Down
33 changes: 19 additions & 14 deletions app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.DocumentsContract
import android.util.LayoutDirection
import android.util.Log
import android.view.*
import android.widget.Toast
Expand Down Expand Up @@ -404,7 +405,6 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),

val ltr = resources.configuration.layoutDirection != View.LAYOUT_DIRECTION_RTL
val safeInsetEnd = if (ltr) cutout.safeInsetRight else cutout.safeInsetLeft
val safeInsetStart = if (ltr) cutout.safeInsetLeft else cutout.safeInsetRight

val bottomView = findViewById<View>(R.id.toolbar_bottom_container)
val toolbarGuideLine = findViewById<Guideline>(R.id.toolbar_width_guideline)
Expand All @@ -413,11 +413,7 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),
endGuideLine.setGuidelineEnd((300 * density).toInt() + safeInsetEnd)
toolbarGuideLine.setGuidelineEnd((220 * density).toInt() + safeInsetEnd)

(bottomView.layoutParams as? ConstraintLayout.LayoutParams)?.let {
it.marginStart = safeInsetStart + (16 * density).toInt()
it.bottomMargin = cutout.safeInsetBottom + (8 * density).toInt()
bottomView.layoutParams = it
}
bottomView.layoutParams.height = cutout.safeInsetBottom + (72 * density).toInt()
}

private fun removeCelestiaFragment() {
Expand Down Expand Up @@ -1411,14 +1407,23 @@ class MainActivity : AppCompatActivity(R.layout.activity_main),
}

private fun showTimeControl() {
showBottomFragment(
BottomControlFragment.newInstance(
listOf(
CelestiaAction.Slower,
CelestiaAction.PlayPause,
CelestiaAction.Faster,
CelestiaAction.Reverse
)))
val actions: List<CelestiaAction>
if (resources.configuration.layoutDirection == LayoutDirection.RTL) {
actions = listOf(
CelestiaAction.Faster,
CelestiaAction.PlayPause,
CelestiaAction.Slower,
CelestiaAction.Reverse
)
} else {
actions = listOf(
CelestiaAction.Slower,
CelestiaAction.PlayPause,
CelestiaAction.Faster,
CelestiaAction.Reverse
)
}
showBottomFragment(BottomControlFragment.newInstance(actions))
}

private fun showScriptControl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import space.celestia.mobilecelestia.R
import space.celestia.mobilecelestia.common.RightSubFragment
import space.celestia.mobilecelestia.common.EndSubFragment
import space.celestia.mobilecelestia.core.CelestiaBrowserItem

class BrowserCommonFragment : RightSubFragment() {
class BrowserCommonFragment : EndSubFragment() {

private var listener: Listener? = null
private var browserItem: CelestiaBrowserItem? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
package space.celestia.mobilecelestia.browser

import android.os.Bundle
import space.celestia.mobilecelestia.common.RightNavgationFragment
import space.celestia.mobilecelestia.common.EndNavgationFragment

class BrowserNavigationFragment : RightNavgationFragment() {
class BrowserNavigationFragment : EndNavgationFragment() {
private var path: String = ""

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ package space.celestia.mobilecelestia.browser

import android.os.Bundle
import space.celestia.mobilecelestia.R
import space.celestia.mobilecelestia.common.RightNavgationFragment
import space.celestia.mobilecelestia.common.EndNavgationFragment
import space.celestia.mobilecelestia.core.CelestiaBrowserItem
import space.celestia.mobilecelestia.core.CelestiaSelection
import space.celestia.mobilecelestia.info.InfoFragment
import space.celestia.mobilecelestia.info.model.InfoDescriptionItem

class SubsystemBrowserFragment : RightNavgationFragment(), BrowserRootFragment {
class SubsystemBrowserFragment : EndNavgationFragment(), BrowserRootFragment {
private var currentPath = ""
private var rootPath = ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,28 +197,28 @@ class CelestiaFragment: InsetAwareFragment(), SurfaceHolder.Callback, CelestiaCo
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

handleInsetChanged(view, currentSafeInsets)
handleInsetsChanged(view, currentSafeInsets)
}

override fun onInsetChanged(view: View, newInset: EdgeInsets) {
super.onInsetChanged(view, newInset)
override fun onInsetChanged(view: View, newInsets: EdgeInsets) {
super.onInsetChanged(view, newInsets)

handleInsetChanged(view, newInset)
handleInsetsChanged(view, newInsets)
}

private fun handleInsetChanged(view: View, newInset: EdgeInsets) {
private fun handleInsetsChanged(view: View, newInsets: EdgeInsets) {
if (!loadSuccess) {
savedInsets = newInset
savedInsets = newInsets
return
}

val insets = newInset.scaleBy(scaleFactor)
val insets = newInsets.scaleBy(scaleFactor)
CelestiaView.callOnRenderThread {
core.setSafeAreaInsets(insets)
}

val ltr = resources.configuration.layoutDirection != View.LAYOUT_DIRECTION_RTL
val safeInsetEnd = if (ltr) newInset.right else newInset.left
val safeInsetEnd = if (ltr) newInsets.right else newInsets.left

val controlView = view.findViewById<FrameLayout>(currentControlViewID) ?: return
val params = controlView.layoutParams as? ConstraintLayout.LayoutParams
Expand Down Expand Up @@ -375,7 +375,7 @@ class CelestiaFragment: InsetAwareFragment(), SurfaceHolder.Callback, CelestiaCo

Log.d(TAG, "Ready to display")

handleInsetChanged(thisView, currentSafeInsets)
handleInsetsChanged(thisView, currentSafeInsets)
}

override fun onCreateContextMenu(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ open class InsetAwareFragment: Fragment() {
})
}

open fun onInsetChanged(view: View, newInset: EdgeInsets) {}
open fun onInsetChanged(view: View, newInsets: EdgeInsets) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ abstract class NavigationFragment: InsetAwareFragment(), Poppable, Toolbar.OnMen
}
} else {
if (canGoBack) {
toolbar.setNavigationIcon(R.drawable.ic_action_arrow_back)
toolbar.setNavigationIcon(R.drawable.ic_action_back_tint)
} else {
toolbar.navigationIcon = null
}
Expand Down
Loading

0 comments on commit 6bef76b

Please sign in to comment.