diff --git a/app/build.gradle b/app/build.gradle
index 67f413d4..c3227c91 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -227,7 +227,7 @@ dependencies {
implementation "com.squareup.retrofit2:converter-wire:$retrofit_version"
implementation 'com.google.code.gson:gson:2.10'
- implementation "cn.dreamtobe.kpswitch:library:1.6.2"
+ implementation 'com.github.DSAppTeam:PanelSwitchHelper:v1.5.2'
implementation "org.litepal.android:kotlin:3.0.0"
implementation 'cn.jzvd:jiaozivideoplayer:7.7.2.3300'
implementation "com.jrummyapps:colorpicker:2.1.7"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 51911371..535d8545 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -301,6 +301,7 @@
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
keyword = v.text.toString()
- if (!keyword.isNullOrBlank()) KeyboardUtil.hideKeyboard(v)
+ if (!keyword.isNullOrBlank()) hideSoftInput()
return@setOnEditorActionListener true
}
return@setOnEditorActionListener false
@@ -129,7 +130,7 @@ class NewSearchActivity : BaseActivity(), TabLayout.OnTabSelectedListener {
keyword = intent.getStringExtra(EXTRA_KEYWORD)
editText.post {
if (keyword.isNullOrBlank()) {
- KeyboardUtil.showKeyboard(editText)
+ editText.showSoftInput()
}
}
}
@@ -189,7 +190,7 @@ class NewSearchActivity : BaseActivity(), TabLayout.OnTabSelectedListener {
if (state == State.SEARCH) {
state = State.INPUT
invalidateState()
- KeyboardUtil.showKeyboard(editText)
+ editText.showSoftInput()
} else {
finish()
}
@@ -238,7 +239,7 @@ class NewSearchActivity : BaseActivity(), TabLayout.OnTabSelectedListener {
editText.apply {
setText(item.content)
clearFocus()
- KeyboardUtil.hideKeyboard(this)
+ hideSoftInput()
}
keyword = item.content
}
diff --git a/app/src/main/java/com/huanchengfly/tieba/post/activities/ReplyActivity.kt b/app/src/main/java/com/huanchengfly/tieba/post/activities/ReplyActivity.kt
index e0b92899..93355aee 100644
--- a/app/src/main/java/com/huanchengfly/tieba/post/activities/ReplyActivity.kt
+++ b/app/src/main/java/com/huanchengfly/tieba/post/activities/ReplyActivity.kt
@@ -19,7 +19,6 @@ import android.view.ViewGroup
import android.webkit.WebView
import android.widget.FrameLayout
import android.widget.GridView
-import android.widget.RelativeLayout
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.appcompat.widget.Toolbar
@@ -28,10 +27,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager
import butterknife.BindView
-import cn.dreamtobe.kpswitch.util.KPSwitchConflictUtil
-import cn.dreamtobe.kpswitch.util.KPSwitchConflictUtil.SubPanelAndTrigger
-import cn.dreamtobe.kpswitch.util.KeyboardUtil
-import cn.dreamtobe.kpswitch.widget.KPSwitchFSPanelFrameLayout
+import com.effective.android.panel.PanelSwitchHelper
+import com.effective.android.panel.utils.hideSoftInput
+import com.effective.android.panel.view.panel.PanelView
import com.google.android.material.tabs.TabLayout
import com.huanchengfly.tieba.post.R
import com.huanchengfly.tieba.post.adapters.InsertPhotoAdapter
@@ -49,24 +47,27 @@ import com.huanchengfly.tieba.post.models.ReplyInfoBean
import com.huanchengfly.tieba.post.models.database.Draft
import com.huanchengfly.tieba.post.toastShort
import com.huanchengfly.tieba.post.ui.widgets.edittext.widget.UndoableEditText
-import com.huanchengfly.tieba.post.ui.widgets.theme.TintConstraintLayout
import com.huanchengfly.tieba.post.ui.widgets.theme.TintImageView
+import com.huanchengfly.tieba.post.ui.widgets.theme.TintLinearLayout
import com.huanchengfly.tieba.post.utils.*
import org.litepal.LitePal.where
+
class ReplyActivity : BaseActivity(), View.OnClickListener,
InsertPhotoAdapter.PickMediasLauncherProvider {
- @BindView(R.id.activity_reply_edit_text)
+ private var mHelper: PanelSwitchHelper? = null
+
+ @BindView(R.id.edit_text)
lateinit var editText: UndoableEditText
- @BindView(R.id.activity_reply_panel_root)
- lateinit var panelFrameLayout: KPSwitchFSPanelFrameLayout
+ @BindView(R.id.activity_reply_layout)
+ lateinit var rootLayout: TintLinearLayout
@BindView(R.id.activity_reply_emoticon)
- lateinit var emoticonView: RelativeLayout
+ lateinit var emoticonView: PanelView
@BindView(R.id.activity_reply_insert_photo)
- lateinit var insertImageView: FrameLayout
+ lateinit var insertImageView: PanelView
@BindView(R.id.activity_reply_edit_emoticon)
lateinit var emoticonBtn: TintImageView
@@ -106,6 +107,52 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
insertPhotoAdapter.setFileList(photoInfoBeans)
}
+ override fun onStart() {
+ super.onStart()
+ if (mHelper == null) {
+ mHelper = PanelSwitchHelper.Builder(this)
+ .logTrack(true)
+ .build(false)
+
+ if (appPreferences.postOrReplyWarning) {
+ showDialog {
+ setTitle(R.string.title_dialog_reply_warning)
+ setMessage(R.string.message_dialog_reply_warning)
+ setNegativeButton(R.string.btn_cancel_reply) { _, _ ->
+ finish()
+ }
+ setNeutralButton(R.string.btn_continue_reply, null)
+ setPositiveButton(R.string.button_official_client_reply) { _, _ ->
+ val intent = Intent(ACTION_VIEW).setData(getDispatchUri())
+ val resolveInfos =
+ packageManager.queryIntentActivities(
+ intent,
+ PackageManager.MATCH_DEFAULT_ONLY
+ )
+ .filter { it.resolvePackageName != packageName }
+ try {
+ if (resolveInfos.isNotEmpty()) {
+ startActivity(intent)
+ } else {
+ toastShort(R.string.toast_official_client_not_install)
+ }
+ } catch (e: ActivityNotFoundException) {
+ toastShort(R.string.toast_official_client_not_install)
+ }
+ finish()
+ }
+ }
+ }
+ }
+ }
+
+ override fun onBackPressed() {
+ if (mHelper?.hookSystemBackByPanelSwitcher() == true) {
+ return
+ }
+ super.onBackPressed()
+ }
+
override fun getPickMediasLauncher(): ActivityResultLauncher =
pickMediasLauncher
@@ -115,10 +162,9 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- if (ThemeUtil.THEME_TRANSLUCENT == ThemeUtil.getTheme()) {
- val constraintLayout = findViewById(R.id.activity_reply_layout)
- constraintLayout.setBackgroundTintResId(0)
- ThemeUtil.setTranslucentBackground(constraintLayout)
+ if (ThemeUtil.isTranslucentTheme()) {
+ rootLayout.setBackgroundTintResId(0)
+ ThemeUtil.setTranslucentBackground(rootLayout)
}
Util.setStatusBarTransparent(this)
val decor = window.decorView as ViewGroup
@@ -129,30 +175,6 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
initData()
initView()
- if (appPreferences.postOrReplyWarning) showDialog {
- setTitle(R.string.title_dialog_reply_warning)
- setMessage(R.string.message_dialog_reply_warning)
- setNegativeButton(R.string.btn_cancel_reply) { _, _ ->
- finish()
- }
- setNeutralButton(R.string.btn_continue_reply, null)
- setPositiveButton(R.string.button_official_client_reply) { _, _ ->
- val intent = Intent(ACTION_VIEW).setData(getDispatchUri())
- val resolveInfos =
- packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
- .filter { it.resolvePackageName != packageName }
- try {
- if (resolveInfos.isNotEmpty()) {
- startActivity(intent)
- } else {
- toastShort(R.string.toast_official_client_not_install)
- }
- } catch (e: ActivityNotFoundException) {
- toastShort(R.string.toast_official_client_not_install)
- }
- finish()
- }
- }
}
private fun getDispatchUri(): Uri? {
@@ -184,7 +206,6 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
override fun onPause() {
super.onPause()
- panelFrameLayout.recordKeyboardStatus(window)
if (replyInfoBean != null && !replySuccess) {
Draft(
replyInfoBean!!.hash(),
@@ -282,8 +303,9 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
}
})
mItemTouchHelper.attachToRecyclerView(insertView)
- findViewById(R.id.activity_reply_root).setOnClickListener(this)
- findViewById(R.id.activity_reply_layout).setOnClickListener(this)
+ findViewById(R.id.content_view).setOnClickListener(this)
+ findViewById(R.id.panel_container).setOnClickListener(this)
+ rootLayout.setOnClickListener(this)
toolbar.setNavigationIcon(R.drawable.ic_reply_toolbar_round_close)
if (replyInfoBean!!.pid == null && replyInfoBean!!.floorNum == null) {
insertImageBtn.visibility = View.VISIBLE
@@ -452,13 +474,6 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
if (sendItem != null) sendItem!!.isEnabled = canSend()
}
})
- KeyboardUtil.attach(this, panelFrameLayout)
- KPSwitchConflictUtil.attach(
- panelFrameLayout,
- editText,
- SubPanelAndTrigger(emoticonView, emoticonBtn),
- SubPanelAndTrigger(insertImageView, insertImageBtn)
- )
EmoticonUtil.GlobalOnItemClickManagerUtil.attachToEditText(editText)
}
@@ -576,8 +591,8 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
finish()
}.doIfFailure {
if (loadingDialog != null) loadingDialog!!.cancel()
- KeyboardUtil.hideKeyboard(panelFrameLayout)
- showErrorSnackBar(panelFrameLayout, it)
+ hideSoftInput()
+ showErrorSnackBar(rootLayout, it)
}
}
}
@@ -600,7 +615,7 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
override fun onClick(v: View) {
when (v.id) {
- R.id.activity_reply_root -> finish()
+ R.id.content_view -> finish()
R.id.activity_reply_edit_undo -> editText.undo()
R.id.activity_reply_edit_redo -> editText.redo()
R.id.activity_reply_edit_clear -> editText.setText(null)
diff --git a/app/src/main/java/com/huanchengfly/tieba/post/activities/SearchPostActivity.kt b/app/src/main/java/com/huanchengfly/tieba/post/activities/SearchPostActivity.kt
index ae4348d7..7711b412 100644
--- a/app/src/main/java/com/huanchengfly/tieba/post/activities/SearchPostActivity.kt
+++ b/app/src/main/java/com/huanchengfly/tieba/post/activities/SearchPostActivity.kt
@@ -14,7 +14,8 @@ import androidx.appcompat.widget.ListPopupWindow
import androidx.core.widget.TextViewCompat
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView
-import cn.dreamtobe.kpswitch.util.KeyboardUtil
+import com.effective.android.panel.utils.hideSoftInput
+import com.effective.android.panel.utils.showSoftInput
import com.google.android.material.textfield.TextInputLayout
import com.huanchengfly.tieba.post.R
import com.huanchengfly.tieba.post.adapters.SearchPostAdapter
@@ -124,7 +125,7 @@ class SearchPostActivity : BaseActivity() {
editText.setText(keyword)
}
editText.post {
- KeyboardUtil.showKeyboard(editText)
+ editText.showSoftInput()
}
}
@@ -167,7 +168,7 @@ class SearchPostActivity : BaseActivity() {
override fun onBackPressed() {
if (state == State.SEARCH) {
state = State.INPUT
- KeyboardUtil.showKeyboard(editText)
+ editText.showSoftInput()
} else {
finish()
}
@@ -336,7 +337,7 @@ class SearchPostActivity : BaseActivity() {
editText.apply {
setText(item.content)
clearFocus()
- KeyboardUtil.hideKeyboard(this)
+ hideSoftInput()
}
keyword = item.content
}
diff --git a/app/src/main/res/layout/activity_reply.xml b/app/src/main/res/layout/activity_reply.xml
index de14e2c3..b3e51ff3 100644
--- a/app/src/main/res/layout/activity_reply.xml
+++ b/app/src/main/res/layout/activity_reply.xml
@@ -14,182 +14,164 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
-
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ app:animationSpeed="standard">
-
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ app:edit_view="@id/edit_text">
-
-
+ android:layout_gravity="bottom"
+ android:background="@drawable/bg_round"
+ android:orientation="vertical"
+ app:backgroundTint="@color/default_color_background">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:background="@color/transparent"
+ android:stateListAnimator="@animator/appbar_elevation"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+ android:layout_height="wrap_content"
+ app:panel_layout="@layout/layout_panel_photo"
+ app:panel_trigger="@id/activity_reply_edit_insert_photo" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_panel_emoticon.xml b/app/src/main/res/layout/layout_panel_emoticon.xml
new file mode 100644
index 00000000..d6617187
--- /dev/null
+++ b/app/src/main/res/layout/layout_panel_emoticon.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_panel_photo.xml b/app/src/main/res/layout/layout_panel_photo.xml
new file mode 100644
index 00000000..acfe53ff
--- /dev/null
+++ b/app/src/main/res/layout/layout_panel_photo.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 9022077e..4f01b20b 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -9,4 +9,4 @@ org.gradle.caching=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2g -XX:+UseParallelGC -Dfile.encoding=UTF-8
org.gradle.parallel=true
-#org.gradle.unsafe.configuration-cache=true
+org.gradle.unsafe.configuration-cache=true