-
-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: automatically switch bar view when board window attach or d…
…etach Broadcast the window attach / detach event via InputBroadcaster.
- Loading branch information
1 parent
281d31a
commit 8fe83c8
Showing
11 changed files
with
136 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.osfans.trime.ime.bar | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import splitties.views.dsl.constraintlayout.centerInParent | ||
import splitties.views.dsl.constraintlayout.constraintLayout | ||
import splitties.views.dsl.constraintlayout.lParams | ||
import splitties.views.dsl.core.Ui | ||
import splitties.views.dsl.core.add | ||
import splitties.views.dsl.core.matchParent | ||
|
||
class TabUi(override val ctx: Context) : Ui { | ||
private var external: View? = null | ||
|
||
override val root = constraintLayout { } | ||
|
||
fun addExternal(view: View) { | ||
if (external != null) { | ||
throw IllegalStateException("TabBar external view is already present") | ||
} | ||
external = view | ||
root.run { | ||
add( | ||
view, | ||
lParams(matchParent, matchParent) { | ||
centerInParent() | ||
}, | ||
) | ||
} | ||
} | ||
|
||
fun removeExternal() { | ||
external?.let { | ||
root.removeView(it) | ||
external = null | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/osfans/trime/ime/broadcast/InputBroadcastReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.osfans.trime.ime.broadcast | ||
|
||
import com.osfans.trime.core.RimeNotification.OptionNotification | ||
import com.osfans.trime.ime.window.BoardWindow | ||
|
||
interface InputBroadcastReceiver { | ||
fun onRimeOptionUpdated(value: OptionNotification.Value) {} | ||
|
||
fun onWindowAttached(window: BoardWindow) {} | ||
|
||
fun onWindowDetached(window: BoardWindow) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/osfans/trime/ime/symbol/LiquidLayout.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.osfans.trime.ime.symbol | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.core.view.setPadding | ||
import com.osfans.trime.data.theme.Theme | ||
import com.osfans.trime.ime.keyboard.KeyboardSwitcher | ||
import splitties.dimensions.dp | ||
import splitties.views.dsl.constraintlayout.bottomOfParent | ||
import splitties.views.dsl.constraintlayout.centerHorizontally | ||
import splitties.views.dsl.constraintlayout.lParams | ||
import splitties.views.dsl.constraintlayout.matchConstraints | ||
import splitties.views.dsl.constraintlayout.topOfParent | ||
import splitties.views.dsl.core.add | ||
import splitties.views.dsl.recyclerview.recyclerView | ||
|
||
@SuppressLint("ViewConstructor") | ||
class LiquidLayout(context: Context, theme: Theme) : ConstraintLayout(context) { | ||
val boardView = | ||
recyclerView { | ||
val space = dp(3) | ||
addItemDecoration(SpacesItemDecoration(space)) | ||
setPadding(space) | ||
} | ||
|
||
val tabsUi = LiquidTabsUi(context, theme) | ||
|
||
init { | ||
add( | ||
boardView, | ||
lParams(matchConstraints, KeyboardSwitcher.currentKeyboard.keyboardHeight) { | ||
topOfParent() | ||
centerHorizontally() | ||
bottomOfParent() | ||
}, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.