Commit fbfacf33 authored by wanglei's avatar wanglei

...

parent 82c203d5
...@@ -19,10 +19,6 @@ ...@@ -19,10 +19,6 @@
android:theme="@style/Theme.PDFViewerScannerWhite" android:theme="@style/Theme.PDFViewerScannerWhite"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
tools:targetApi="34"> tools:targetApi="34">
<activity
android:name=".ui.main.MainActivity2"
android:exported="false"
android:launchMode="singleTask" />
<meta-data <meta-data
android:name="com.google.android.gms.version" android:name="com.google.android.gms.version"
......
...@@ -26,6 +26,13 @@ object ConstObject { ...@@ -26,6 +26,13 @@ object ConstObject {
const val DO_LOCK_PDF = "do_lock_pdf" const val DO_LOCK_PDF = "do_lock_pdf"
const val DO_UNLOCK_PDF = "do_unlock_pdf" const val DO_UNLOCK_PDF = "do_unlock_pdf"
const val DOCUMENT_UI_TYPE = "document"
const val RECENT_UI_TYPE = "recent"
const val BOOKMARK_UI_TYPE = "bookmark"
const val UI_MODE_NORMAL = "ui_mode_normal"
const val UI_MODE_SELECT = "ui_mode_select"
var ifAgreePrivacy = false var ifAgreePrivacy = false
get() { get() {
return AppPreferences.getInstance().getBoolean("ifAgreePrivacy", field) return AppPreferences.getInstance().getBoolean("ifAgreePrivacy", field)
...@@ -34,7 +41,7 @@ object ConstObject { ...@@ -34,7 +41,7 @@ object ConstObject {
field = value field = value
AppPreferences.getInstance().put("ifAgreePrivacy", value, true) AppPreferences.getInstance().put("ifAgreePrivacy", value, true)
} }
var haveSaveDemo=false var haveSaveDemo = false
get() { get() {
return AppPreferences.getInstance().getBoolean("haveSaveDemo", field) return AppPreferences.getInstance().getBoolean("haveSaveDemo", field)
} }
......
package com.base.pdfviewerscannerwhite.ui.main
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.angcyo.tablayout.DslTabIndicator
import com.angcyo.tablayout.delegate2.ViewPager2Delegate
import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.FragmentBookmarkBinding
import com.base.pdfviewerscannerwhite.helper.BaseFragment
class BookmarkFragment : BaseFragment<FragmentBookmarkBinding>() {
override val binding: FragmentBookmarkBinding by lazy {
FragmentBookmarkBinding.inflate(layoutInflater)
}
private val pdfPage: DocumentPageFragment by lazy {
DocumentPageFragment(DocumentBean.TYPE_PDF)
}
private val wordPage: DocumentPageFragment by lazy {
DocumentPageFragment(DocumentBean.TYPE_WORD)
}
private val excelPage: DocumentPageFragment by lazy {
DocumentPageFragment()
}
private val pptPage: DocumentPageFragment by lazy {
DocumentPageFragment()
}
private val fragments by lazy {
mutableListOf(pdfPage, wordPage, excelPage, pptPage)
}
override fun setView() {
initPageViewer()
initTabLayout()
}
private fun initPageViewer() {
binding.viewPager2.run {
isUserInputEnabled = true
adapter = object : FragmentStateAdapter(this@BookmarkFragment) {
override fun getItemCount(): Int {
return fragments.size
}
override fun createFragment(position: Int): Fragment {
return fragments[position]
}
}
}
binding.viewPager2.registerOnPageChangeCallback(object :
ViewPager2.OnPageChangeCallback() {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
super.onPageScrolled(position, positionOffset, positionOffsetPixels)
if (position == 3 && positionOffset > 0) {
binding.viewPager2.setCurrentItem(position, false)
}
}
override fun onPageSelected(position: Int) {
}
})
}
private fun initTabLayout() {
val colorPdf = ContextCompat.getColor(requireContext(), R.color.color_f02f2b)
val colorWord = ContextCompat.getColor(requireContext(), R.color.color_0592ee)
val colorExcel = ContextCompat.getColor(requireContext(), R.color.color_149b55)
val colorPpt = ContextCompat.getColor(requireContext(), R.color.color_ffa127)
binding.tabLayoutDocument.apply {
tabIndicator.indicatorWidth =
this.resources.getDimensionPixelOffset(R.dimen.dp_50)
tabIndicator.indicatorHeight =
this.resources.getDimensionPixelOffset(R.dimen.dp_4)
tabIndicator.indicatorStyle =
DslTabIndicator.INDICATOR_STYLE_BOTTOM
configTabLayoutConfig {
onSelectIndexChange = { fromIndex, selectIndexList, reselect, fromUser ->
val toIndex = selectIndexList.first()
when (toIndex) {
0 -> {
tabSelectColor = colorPdf
tabIndicator.indicatorColor = colorPdf
binding.viewPager2.currentItem = 0
}
1 -> {
tabSelectColor = colorWord
tabIndicator.indicatorColor = colorWord
binding.viewPager2.currentItem = 1
}
2 -> {
tabSelectColor = colorExcel
tabIndicator.indicatorColor = colorExcel
binding.viewPager2.currentItem = 2
}
3 -> {
tabSelectColor = colorPpt
tabIndicator.indicatorColor = colorPpt
binding.viewPager2.currentItem = 3
}
}
dslSelector.updateStyle()
}
}
}
ViewPager2Delegate.install(binding.viewPager2, binding.tabLayoutDocument)
}
}
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ui.main package com.base.pdfviewerscannerwhite.ui.main
import android.os.Bundle import android.annotation.SuppressLint
import android.view.View
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.adapter.FragmentStateAdapter
...@@ -8,11 +9,18 @@ import androidx.viewpager2.widget.ViewPager2 ...@@ -8,11 +9,18 @@ import androidx.viewpager2.widget.ViewPager2
import com.angcyo.tablayout.DslTabIndicator import com.angcyo.tablayout.DslTabIndicator
import com.angcyo.tablayout.delegate2.ViewPager2Delegate import com.angcyo.tablayout.delegate2.ViewPager2Delegate
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_UI_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_UI_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.RECENT_UI_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_MODE_NORMAL
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_MODE_SELECT
import com.base.pdfviewerscannerwhite.bean.DocumentBean import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.FragmentDocumentBinding import com.base.pdfviewerscannerwhite.databinding.FragmentDocumentBinding
import com.base.pdfviewerscannerwhite.helper.BaseFragment import com.base.pdfviewerscannerwhite.helper.BaseFragment
class DocumentFragment : BaseFragment<FragmentDocumentBinding>() { class DocumentFragment(
val type: String = ""
) : BaseFragment<FragmentDocumentBinding>() {
private val pdfPage: DocumentPageFragment by lazy { private val pdfPage: DocumentPageFragment by lazy {
DocumentPageFragment(DocumentBean.TYPE_PDF) DocumentPageFragment(DocumentBean.TYPE_PDF)
...@@ -22,26 +30,99 @@ class DocumentFragment : BaseFragment<FragmentDocumentBinding>() { ...@@ -22,26 +30,99 @@ class DocumentFragment : BaseFragment<FragmentDocumentBinding>() {
DocumentPageFragment(DocumentBean.TYPE_WORD) DocumentPageFragment(DocumentBean.TYPE_WORD)
} }
private val excelPage: DocumentPageFragment by lazy { private val excelPage: DocumentPageFragment by lazy {
DocumentPageFragment() DocumentPageFragment(DocumentBean.TYPE_EXCEL)
} }
private val pptPage: DocumentPageFragment by lazy { private val pptPage: DocumentPageFragment by lazy {
DocumentPageFragment() DocumentPageFragment(DocumentBean.TYPE_PPT)
} }
private val fragments by lazy { private val fragments by lazy {
mutableListOf(pdfPage, wordPage, excelPage, pptPage) mutableListOf(pdfPage, wordPage, excelPage, pptPage)
} }
private var currentFragment: Fragment = pdfPage
override val binding: FragmentDocumentBinding by lazy { override val binding: FragmentDocumentBinding by lazy {
FragmentDocumentBinding.inflate(layoutInflater) FragmentDocumentBinding.inflate(layoutInflater)
} }
var uiMode = UI_MODE_NORMAL
@SuppressLint("SetTextI18n")
override fun setView() { override fun setView() {
when (type) {
DOCUMENT_UI_TYPE -> {
binding.tvTittle.text = "Document"
}
RECENT_UI_TYPE -> {
binding.tvTittle.text = "Recent"
binding.ivPaixu.visibility = View.INVISIBLE
}
BOOKMARK_UI_TYPE -> {
binding.tvTittle.text = "Bookmark"
}
}
initPageViewer() initPageViewer()
initTabLayout() initTabLayout()
} }
override fun onViewStateRestored(savedInstanceState: Bundle?) { override fun setListener() {
super.onViewStateRestored(savedInstanceState) super.setListener()
binding.flFanhui.setOnClickListener {
(requireActivity() as MainActivity).onBackPressedDispatcher.onBackPressed()
}
binding.ivXuanze.setOnClickListener {
changeSelectUI()
}
binding.ivAllSelector.setOnClickListener {
binding.ivAllSelector.isSelected = !binding.ivAllSelector.isSelected
changePageSelect(binding.ivAllSelector.isSelected)
}
}
private fun changeSelectUI() {
binding.viewPager2.isUserInputEnabled = false
(requireActivity() as MainActivity).callback.isEnabled = true
uiMode = UI_MODE_SELECT
binding.ivPaixu.visibility = View.INVISIBLE
binding.ivXuanze.visibility = View.INVISIBLE
binding.ivSearch.visibility = View.INVISIBLE
binding.tvTittle.visibility = View.INVISIBLE
binding.flFanhui.visibility = View.VISIBLE
binding.ivAllSelector.visibility = View.VISIBLE
(requireActivity() as MainActivity).changeSelectUI()
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).changeSelectUi(true)
}
}
fun cancelSelectUI() {
binding.viewPager2.isUserInputEnabled = true
(requireActivity() as MainActivity).callback.isEnabled = false
uiMode = UI_MODE_NORMAL
binding.flFanhui.visibility = View.INVISIBLE
binding.ivAllSelector.visibility = View.INVISIBLE
if (type != RECENT_UI_TYPE) {
binding.ivPaixu.visibility = View.VISIBLE
}
binding.ivXuanze.visibility = View.VISIBLE
binding.ivSearch.visibility = View.VISIBLE
binding.tvTittle.visibility = View.VISIBLE
(requireActivity() as MainActivity).cancelSelectUI()
}
private fun changePageSelect(select: Boolean) {
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).changItemSelect(select)
}
} }
...@@ -71,6 +152,7 @@ class DocumentFragment : BaseFragment<FragmentDocumentBinding>() { ...@@ -71,6 +152,7 @@ class DocumentFragment : BaseFragment<FragmentDocumentBinding>() {
} }
override fun onPageSelected(position: Int) { override fun onPageSelected(position: Int) {
currentFragment = fragments[position]
} }
}) })
} }
...@@ -123,4 +205,5 @@ class DocumentFragment : BaseFragment<FragmentDocumentBinding>() { ...@@ -123,4 +205,5 @@ class DocumentFragment : BaseFragment<FragmentDocumentBinding>() {
ViewPager2Delegate.install(binding.viewPager2, binding.tabLayoutDocument) ViewPager2Delegate.install(binding.viewPager2, binding.tabLayoutDocument)
} }
} }
\ No newline at end of file
...@@ -83,7 +83,7 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu ...@@ -83,7 +83,7 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu
} }
var documentMoreAction: (item: DocumentBean) -> Unit = { item -> var documentMoreAction: (item: DocumentBean) -> Unit = { item ->
val mainActivity = (requireActivity() as MainActivity2) val mainActivity = (requireActivity() as MainActivity)
if (item.type == TYPE_PDF) { if (item.type == TYPE_PDF) {
requireContext().showPdfHomeMoreDialog( requireContext().showPdfHomeMoreDialog(
item, adapter, this, mainActivity item, adapter, this, mainActivity
......
package com.base.pdfviewerscannerwhite.ui.main package com.base.pdfviewerscannerwhite.ui.main
import android.annotation.SuppressLint
import android.net.Uri import android.net.Uri
import android.view.View import android.view.View
import android.view.inputmethod.EditorInfo
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.core.content.ContextCompat
import androidx.core.widget.addTextChangedListener
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.angcyo.tablayout.DslTabIndicator
import com.angcyo.tablayout.delegate2.ViewPager2Delegate
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_UI_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_UI_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.RECENT_UI_TYPE
import com.base.pdfviewerscannerwhite.bean.DocumentBean import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.ActivityMainBinding import com.base.pdfviewerscannerwhite.databinding.ActivityMain2Binding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.ui.adapter.DocumentAdapter
import com.base.pdfviewerscannerwhite.ui.main.DocumentPageFragment.Companion.jumpDocument
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
import com.base.pdfviewerscannerwhite.ui.view.RateDialog.showRateDialog
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.showKeyBoard
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime2
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
import com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import com.base.pdfviewerscannerwhite.utils.updateMediaStore
@SuppressLint("SetTextI18n") class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
private val TAG = "MainActivity"
private lateinit var mainPresenter: MainPresenter private lateinit var mainPresenter: MainPresenter
override val binding: ActivityMain2Binding by lazy {
override val binding: ActivityMainBinding by lazy { ActivityMain2Binding.inflate(layoutInflater)
ActivityMainBinding.inflate(layoutInflater)
}
private val pdfFragment: DocumentPageFragment by lazy {
DocumentPageFragment(DocumentBean.TYPE_PDF)
} }
private val wordFragment: DocumentPageFragment by lazy { private val documentFragment: DocumentFragment by lazy {
DocumentPageFragment(DocumentBean.TYPE_WORD) DocumentFragment(DOCUMENT_UI_TYPE)
} }
private val excelFragment: DocumentPageFragment by lazy { private val recentFragment: DocumentFragment by lazy {
DocumentPageFragment(DocumentBean.TYPE_EXCEL) DocumentFragment(RECENT_UI_TYPE)
} }
private val pptFragment: DocumentPageFragment by lazy { private val bookmarkFragment: DocumentFragment by lazy {
DocumentPageFragment(DocumentBean.TYPE_PPT) DocumentFragment(BOOKMARK_UI_TYPE)
} }
private val toolFragment: ToolFragment by lazy { private val toolFragment: Fragment by lazy {
ToolFragment() ToolFragment()
} }
private var currentFragment: Fragment = pdfFragment
private val fragments by lazy {
mutableListOf(pdfFragment, wordFragment, excelFragment, pptFragment, toolFragment)
}
private lateinit var searchAdapter: DocumentAdapter
private var currentFragment: Fragment = documentFragment
override fun initView() { override fun initView() {
mainPresenter = MainPresenter(this, this) mainPresenter = MainPresenter(this, this)
mainPresenter.initScannerLauncher(this)
binding.viewPager2.offscreenPageLimit = 4
binding.viewPager2.run {
isUserInputEnabled = true
adapter = object : FragmentStateAdapter(this@MainActivity) {
override fun getItemCount(): Int {
return fragments.size
} }
override fun createFragment(position: Int): Fragment { var isDocumentAdd: Boolean = false
return fragments[position] var isRecentAdd: Boolean = false
} var isBookmarkAdd: Boolean = false
} var isToolAdd: Boolean = false
}
binding.viewPager2.registerOnPageChangeCallback(object :
ViewPager2.OnPageChangeCallback() {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
super.onPageScrolled(position, positionOffset, positionOffsetPixels)
if (position == 3 && positionOffset > 0) {
binding.viewPager2.setCurrentItem(position, false)
}
}
override fun onPageSelected(position: Int) {
currentFragment = fragments[position]
}
})
initTabLayout() lateinit var callback: OnBackPressedCallback
initSearchAdapter() override fun initListener() {
super.initListener()
if (!checkStorePermission()) { callback = object : OnBackPressedCallback(false) {
showStoragePermission(launcher) override fun handleOnBackPressed() {
updateMediaStore() if (currentFragment is DocumentFragment) {
val documentFragment = (currentFragment as DocumentFragment)
if (documentFragment.uiMode == ConstObject.UI_MODE_SELECT) {
documentFragment.cancelSelectUI()
} }
} }
private fun initSearchAdapter() {
searchAdapter = DocumentAdapter()
binding.rvSearch.adapter = searchAdapter
searchAdapter.moreAction = { item ->
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).documentMoreAction.invoke(item)
}
}
searchAdapter.itemClick = {
jumpDocument(it)
} }
} }
onBackPressedDispatcher.addCallback(callback)
private fun initTabLayout() { binding.llDocument.setOnClickListener {
val colorPdf = ContextCompat.getColor(this, R.color.color_f02f2b) changeTabSelect(it)
val colorWord = ContextCompat.getColor(this, R.color.color_0592ee)
val colorExcel = ContextCompat.getColor(this, R.color.color_149b55)
val colorPpt = ContextCompat.getColor(this, R.color.color_ffa127)
binding.tabLayoutDocument.apply {
tabIndicator.indicatorWidth =
this.resources.getDimensionPixelOffset(R.dimen.dp_50)
tabIndicator.indicatorHeight =
this.resources.getDimensionPixelOffset(R.dimen.dp_4)
tabIndicator.indicatorStyle =
DslTabIndicator.INDICATOR_STYLE_BOTTOM
configTabLayoutConfig {
onSelectIndexChange = { fromIndex, selectIndexList, reselect, fromUser ->
val toIndex = selectIndexList.first()
LogEx.logDebug(
TAG,
"toIndex=$toIndex fromIndex=$fromIndex selectIndexList=$selectIndexList reselect=$reselect fromUser=$fromUser"
)
when (toIndex) {
0 -> {
tabSelectColor = colorPdf
tabIndicator.indicatorColor = colorPdf
binding.viewPager2.currentItem = 0
}
1 -> {
tabSelectColor = colorWord
tabIndicator.indicatorColor = colorWord
binding.viewPager2.currentItem = 1
}
2 -> { supportFragmentManager.beginTransaction().apply {
tabSelectColor = colorExcel if (!isDocumentAdd) {
tabIndicator.indicatorColor = colorExcel add(R.id.fl_container, documentFragment)
binding.viewPager2.currentItem = 2
} }
3 -> { hide(bookmarkFragment)
tabSelectColor = colorPpt hide(toolFragment)
tabIndicator.indicatorColor = colorPpt hide(recentFragment)
binding.viewPager2.currentItem = 3 show(documentFragment)
commit()
} }
currentFragment = documentFragment
isDocumentAdd = true
} }
dslSelector.updateStyle()
}
}
}
ViewPager2Delegate.install(binding.viewPager2, binding.tabLayoutDocument)
}
private var latViewPagerIndex = -1
private lateinit var callback: OnBackPressedCallback
private fun callTab() {
LogEx.logDebug(TAG, "callTab")
if (uiMode == HOME_UI_MODE_DOCUMENT) {
binding.llDocument.callOnClick() binding.llDocument.callOnClick()
binding.llRecent.setOnClickListener {
changeTabSelect(it)
supportFragmentManager.beginTransaction().apply {
if (!isRecentAdd) {
add(R.id.fl_container, recentFragment)
} }
hide(documentFragment)
hide(bookmarkFragment)
hide(toolFragment)
show(recentFragment)
commit()
} }
currentFragment = recentFragment
@SuppressLint("ClickableViewAccessibility", "SetTextI18n") isRecentAdd = true
override fun initListener() {
super.initListener()
callback = object : OnBackPressedCallback(true /* enabled */) {
override fun handleOnBackPressed() {
if (uiMode == HOME_UI_MODE_SELECT) {
when (lastUIMode) {
HOME_UI_MODE_DOCUMENT -> changeDocumentUI()
HOME_UI_MODE_RECENT -> changeRecentUI()
HOME_UI_MODE_BOOKMARK -> changeBookmarkUI()
}
}
if (uiMode == HOME_UI_MODE_SEARCH) {
cancelSearchUI()
when (lastUIMode) {
HOME_UI_MODE_DOCUMENT -> changeDocumentUI()
HOME_UI_MODE_RECENT -> changeRecentUI()
HOME_UI_MODE_BOOKMARK -> changeBookmarkUI()
}
} }
binding.llBookmark.setOnClickListener {
changeTabSelect(it)
supportFragmentManager.beginTransaction().apply {
if (!isBookmarkAdd) {
add(R.id.fl_container, bookmarkFragment)
} }
hide(documentFragment)
hide(recentFragment)
hide(toolFragment)
show(bookmarkFragment)
commit()
} }
onBackPressedDispatcher.addCallback(callback) currentFragment = bookmarkFragment
binding.flFanhui.setOnClickListener { isBookmarkAdd = true
onBackPressedDispatcher.onBackPressed()
}
binding.llDocument.setOnClickListener {
changeDocumentUI()
}
binding.llRecent.setOnClickListener {
changeRecentUI()
}
binding.llBookmark.setOnClickListener {
changeBookmarkUI()
} }
binding.llTool.setOnClickListener { binding.llTool.setOnClickListener {
changeToolUI() changeTabSelect(it)
} supportFragmentManager.beginTransaction().apply {
binding.ivScan.setOnClickListener { if (!isToolAdd) {
mainPresenter.starGmsScan(this) add(R.id.fl_container, toolFragment)
} }
binding.ivXuanze.setOnClickListener { hide(documentFragment)
changeSelectUI() hide(recentFragment)
hide(bookmarkFragment)
show(toolFragment)
commit()
} }
binding.tvTittle.setOnClickListener { currentFragment = toolFragment
isToolAdd = true
}
binding.vTabLayoutPlace.setOnClickListener {
} }
binding.llDelete.setOnClickListener { binding.llDelete.setOnClickListener {
if (currentFragment is DocumentPageFragment) { if (currentFragment is DocumentPageFragment) {
...@@ -243,46 +137,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView { ...@@ -243,46 +137,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
} }
} }
} }
binding.ivAllSelector.setOnClickListener {
binding.ivAllSelector.isSelected = !binding.ivAllSelector.isSelected
changePageSelect(binding.ivAllSelector.isSelected)
}
binding.llShare.setOnClickListener { binding.llShare.setOnClickListener {
shareDocument() shareDocument()
} }
binding.ivSearch.setOnClickListener {
changeSearchUI()
}
binding.editSearch.addTextChangedListener {
} }
binding.editSearch.setOnEditorActionListener { v, actionId, event ->
LogEx.logDebug(TAG, "$actionId")
if (actionId == EditorInfo.IME_ACTION_DONE) {
LogEx.logDebug(TAG, "IME_ACTION_DONE")
searchDocument()
}
false
}
callTab()
}
private fun searchDocument() {
if (binding.editSearch.text.isNotEmpty()) {
val search = binding.editSearch.text.toString()
if (currentFragment is DocumentPageFragment) {
val item = (currentFragment as DocumentPageFragment).getSearchItems(search)
if (item.isNotEmpty()) {
item.map { it.uiType = 4 }
searchAdapter.submitList(item)
} else {
binding.llEmpty.visibility = View.VISIBLE
}
}
}
}
private fun shareDocument() { private fun shareDocument() {
if (currentFragment is DocumentPageFragment) { if (currentFragment is DocumentPageFragment) {
...@@ -295,12 +154,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView { ...@@ -295,12 +154,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
} }
} }
private fun changePageSelect(select: Boolean) {
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).changItemSelect(select)
}
}
private fun changeTabSelect(selectView: View) { private fun changeTabSelect(selectView: View) {
binding.llDocument.isSelected = selectView == binding.llDocument binding.llDocument.isSelected = selectView == binding.llDocument
binding.llRecent.isSelected = selectView == binding.llRecent binding.llRecent.isSelected = selectView == binding.llRecent
...@@ -309,234 +162,39 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView { ...@@ -309,234 +162,39 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
} }
fun changeRipple() = binding.root.postDelayed({ fun changeSelectUI() {
val selectRipple = ContextCompat.getDrawable(this@MainActivity, R.drawable.ripple_select)
val normalRipple = ContextCompat.getDrawable(this@MainActivity, R.drawable.ripple_normal)
if (binding.llDocument.isSelected) {
binding.llDocument.background = selectRipple
} else {
binding.llDocument.background = normalRipple
}
if (binding.llRecent.isSelected) {
binding.llRecent.background = selectRipple
} else {
binding.llRecent.background = normalRipple
}
if (binding.llBookmark.isSelected) {
binding.llBookmark.background = selectRipple
} else {
binding.llBookmark.background = normalRipple
}
if (binding.llTool.isSelected) {
binding.llTool.background = selectRipple
} else {
binding.llTool.background = normalRipple
}
}, 200)
@SuppressLint("SetTextI18n")
override fun handleActivityGmsScanResult(imageUri: Uri, pdfUri: Uri) {
toast("handleActivityGmsScanResult")
if (BuildConfig.DEBUG) {
binding.tvDebugLog.text = "imageUri=$imageUri\npdfUri=$pdfUri"
}
showDocumentRenameDialog(name = "PDF_${System.currentTimeMillis().toFormatTime2()}") {
}
}
@SuppressLint("NotifyDataSetChanged")
override fun refreshSearchRv() {
searchAdapter.notifyDataSetChanged()
}
override fun deleteDocument(item: DocumentBean) {
LogEx.logDebug(TAG, "deleteDocument $item")
searchAdapter.remove(item)
}
override fun onResume() {
super.onResume()
showRateDialog()
}
private var uiMode = HOME_UI_MODE_DOCUMENT
private fun cancelSelectUI() {
binding.viewPager2.isUserInputEnabled = true
callback.isEnabled = false
if (latViewPagerIndex != -1) {
binding.viewPager2.setCurrentItem(latViewPagerIndex, false)
latViewPagerIndex = -1
}
binding.vTabLayoutPlace.visibility = View.GONE
binding.flFanhui.visibility = View.GONE
binding.llDelete.visibility = View.GONE
binding.llShare.visibility = View.GONE
binding.ivAllSelector.visibility = View.GONE
binding.ivSearch.visibility = View.VISIBLE
binding.tvTittle.visibility = View.VISIBLE
binding.llDocument.visibility = View.VISIBLE
binding.llRecent.visibility = View.VISIBLE
binding.llBookmark.visibility = View.VISIBLE
binding.llTool.visibility = View.VISIBLE
binding.ivXuanze.visibility = View.VISIBLE
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).changeSelectUi(false)
}
}
fun changeDocumentUI() {
LogEx.logDebug(TAG, "changeDocumentUI")
uiMode = HOME_UI_MODE_DOCUMENT
binding.tvTittle.text = "Document"
cancelSelectUI()
binding.ivXuanze.visibility = View.VISIBLE
binding.ivScan.visibility = View.VISIBLE
binding.ivPaixu.visibility = View.VISIBLE
binding.ivScan.visibility = View.VISIBLE
changeTabSelect(binding.llDocument)
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).setAllList()
}
}
fun changeRecentUI() {
LogEx.logDebug(TAG, "changeRecentUI")
uiMode = HOME_UI_MODE_RECENT
binding.tvTittle.text = "Recent"
cancelSelectUI()
binding.clTabLayout.visibility = View.VISIBLE
binding.ivPaixu.visibility = View.VISIBLE
binding.ivScan.visibility = View.VISIBLE
binding.ivScan.visibility = View.VISIBLE
changeTabSelect(binding.llRecent)
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).setRecentList()
}
}
fun changeBookmarkUI() {
LogEx.logDebug(TAG, "changeBookmarkUI")
uiMode = HOME_UI_MODE_BOOKMARK
cancelSelectUI()
binding.tvTittle.text = "Bookmark"
binding.clTabLayout.visibility = View.VISIBLE
binding.ivScan.visibility = View.VISIBLE
binding.ivScan.visibility = View.VISIBLE
changeTabSelect(binding.llBookmark)
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).setBookmarkList()
}
}
private fun changeToolUI() {
LogEx.logDebug(TAG, "changeToolUI")
uiMode = HOME_UI_MODE_TOOL
callback.isEnabled = false
binding.viewPager2.isUserInputEnabled = true
binding.tvTittle.text = "Tool"
binding.ivScan.visibility = View.GONE
binding.clTabLayout.visibility = View.GONE
latViewPagerIndex = binding.viewPager2.currentItem
binding.viewPager2.setCurrentItem(5, false)
changeTabSelect(binding.llTool)
}
private var lastUIMode = HOME_UI_MODE_DOCUMENT
private fun changeSelectUI() {
LogEx.logDebug(TAG, "changeSelectUI")
callback.isEnabled = true
lastUIMode = uiMode
uiMode = HOME_UI_MODE_SELECT
binding.ivPaixu.visibility = View.INVISIBLE
binding.ivXuanze.visibility = View.INVISIBLE
binding.ivSearch.visibility = View.INVISIBLE
binding.tvTittle.visibility = View.INVISIBLE
binding.ivScan.visibility = View.INVISIBLE binding.ivScan.visibility = View.INVISIBLE
binding.llDocument.visibility = View.INVISIBLE binding.llDocument.visibility = View.INVISIBLE
binding.llRecent.visibility = View.INVISIBLE binding.llRecent.visibility = View.INVISIBLE
binding.llBookmark.visibility = View.INVISIBLE binding.llBookmark.visibility = View.INVISIBLE
binding.llTool.visibility = View.INVISIBLE binding.llTool.visibility = View.INVISIBLE
binding.flFanhui.visibility = View.VISIBLE
binding.llDelete.visibility = View.VISIBLE binding.llDelete.visibility = View.VISIBLE
binding.llShare.visibility = View.VISIBLE binding.llShare.visibility = View.VISIBLE
binding.ivAllSelector.visibility = View.VISIBLE
binding.viewPager2.isUserInputEnabled = false
binding.vTabLayoutPlace.visibility = View.VISIBLE
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).changeSelectUi(true)
}
} }
private fun changeSearchUI() { fun cancelSelectUI() {
callback.isEnabled = true binding.llDelete.visibility = View.INVISIBLE
lastUIMode = uiMode binding.llShare.visibility = View.INVISIBLE
uiMode = HOME_UI_MODE_SEARCH
binding.tvTittle.visibility = View.INVISIBLE binding.ivScan.visibility = View.VISIBLE
binding.ivPaixu.visibility = View.INVISIBLE binding.llDocument.visibility = View.VISIBLE
binding.ivXuanze.visibility = View.INVISIBLE binding.llRecent.visibility = View.VISIBLE
binding.llMainContent.visibility = View.INVISIBLE binding.llBookmark.visibility = View.VISIBLE
binding.llTool.visibility = View.VISIBLE
binding.editSearch.visibility = View.VISIBLE
binding.flFanhui.visibility = View.VISIBLE
binding.flSearch.visibility = View.VISIBLE
binding.flSearch.setOnClickListener {}
binding.editSearch.requestFocus()
showKeyBoard(binding.editSearch)
} }
private fun cancelSearchUI() {
binding.flFanhui.visibility = View.GONE
binding.flSearch.visibility = View.GONE
binding.editSearch.visibility = View.GONE
binding.llEmpty.visibility = View.GONE
searchAdapter.submitList(listOf())
binding.editSearch.setText("")
hideKeyboard(binding.editSearch)
binding.llMainContent.visibility = View.VISIBLE override fun handleActivityGmsScanResult(imageUri: Uri, pdfUri: Uri) {
binding.tvTittle.visibility = View.VISIBLE
binding.ivPaixu.visibility = View.VISIBLE
binding.ivXuanze.visibility = View.VISIBLE
if (currentFragment is DocumentPageFragment) {
(currentFragment as DocumentPageFragment).changeHomeUI()
} }
override fun refreshSearchRv() {
} }
companion object { override fun deleteDocument(item: DocumentBean) {
const val HOME_UI_MODE_DOCUMENT = "home_ui_mode_document"
const val HOME_UI_MODE_RECENT = "home_ui_mode_recent"
const val HOME_UI_MODE_BOOKMARK = "home_ui_mode_bookmark"
const val HOME_UI_MODE_TOOL = "home_ui_mode_tool"
const val HOME_UI_MODE_SELECT = "home_ui_mode_select"
const val HOME_UI_MODE_SEARCH = "home_ui_mode_search"
} }
} }
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ui.main
import android.net.Uri
import android.view.View
import androidx.fragment.app.Fragment
import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.ActivityMain2Binding
import com.base.pdfviewerscannerwhite.helper.BaseActivity
class MainActivity2 : BaseActivity<ActivityMain2Binding>(), MainView {
override val binding: ActivityMain2Binding by lazy {
ActivityMain2Binding.inflate(layoutInflater)
}
private val documentFragment: DocumentFragment by lazy {
DocumentFragment()
}
private val recentFragment: RecentFragment by lazy {
RecentFragment()
}
private val bookmarkFragment: BookmarkFragment by lazy {
BookmarkFragment()
}
private val toolFragment: ToolFragment by lazy {
ToolFragment()
}
private var currentFragment: Fragment = documentFragment
override fun initView() {
}
var isDocumentAdd: Boolean = false
var isRecentAdd: Boolean = false
var isBookmarkAdd: Boolean = false
var isToolAdd: Boolean = false
override fun initListener() {
super.initListener()
binding.llDocument.setOnClickListener {
changeTabSelect(it)
supportFragmentManager.beginTransaction().apply {
if (!isDocumentAdd) {
add(R.id.fl_container, documentFragment)
}
hide(bookmarkFragment)
hide(toolFragment)
hide(recentFragment)
show(documentFragment)
commit()
}
currentFragment = documentFragment
isDocumentAdd = true
}
binding.llDocument.callOnClick()
binding.llRecent.setOnClickListener {
changeTabSelect(it)
supportFragmentManager.beginTransaction().apply {
if (!isRecentAdd) {
add(R.id.fl_container, recentFragment)
}
hide(documentFragment)
hide(bookmarkFragment)
hide(toolFragment)
show(recentFragment)
commit()
}
currentFragment = recentFragment
isRecentAdd = true
}
binding.llBookmark.setOnClickListener {
changeTabSelect(it)
supportFragmentManager.beginTransaction().apply {
if (!isBookmarkAdd) {
add(R.id.fl_container, bookmarkFragment)
}
hide(documentFragment)
hide(recentFragment)
hide(toolFragment)
show(bookmarkFragment)
commit()
}
currentFragment = bookmarkFragment
isBookmarkAdd = true
}
binding.llTool.setOnClickListener {
changeTabSelect(it)
supportFragmentManager.beginTransaction().apply {
if (!isToolAdd) {
add(R.id.fl_container, toolFragment)
}
hide(documentFragment)
hide(recentFragment)
hide(bookmarkFragment)
show(toolFragment)
commit()
}
currentFragment = toolFragment
isToolAdd = true
}
}
private fun changeTabSelect(selectView: View) {
binding.llDocument.isSelected = selectView == binding.llDocument
binding.llRecent.isSelected = selectView == binding.llRecent
binding.llBookmark.isSelected = selectView == binding.llBookmark
binding.llTool.isSelected = selectView == binding.llTool
}
override fun handleActivityGmsScanResult(imageUri: Uri, pdfUri: Uri) {
}
override fun refreshSearchRv() {
}
override fun deleteDocument(item: DocumentBean) {
}
}
\ No newline at end of file
//package com.base.pdfviewerscannerwhite.ui.main
//
//import android.annotation.SuppressLint
//import android.net.Uri
//import android.view.View
//import android.view.inputmethod.EditorInfo
//import androidx.activity.OnBackPressedCallback
//import androidx.core.content.ContextCompat
//import androidx.core.widget.addTextChangedListener
//import androidx.fragment.app.Fragment
//import androidx.viewpager2.adapter.FragmentStateAdapter
//import androidx.viewpager2.widget.ViewPager2
//import com.angcyo.tablayout.DslTabIndicator
//import com.angcyo.tablayout.delegate2.ViewPager2Delegate
//import com.base.pdfviewerscannerwhite.BuildConfig
//import com.base.pdfviewerscannerwhite.R
//import com.base.pdfviewerscannerwhite.bean.DocumentBean
//import com.base.pdfviewerscannerwhite.databinding.ActivityMainBinding
//import com.base.pdfviewerscannerwhite.helper.BaseActivity
//import com.base.pdfviewerscannerwhite.ui.adapter.DocumentAdapter
//import com.base.pdfviewerscannerwhite.ui.main.DocumentPageFragment.Companion.jumpDocument
//import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
//import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog
//import com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
//import com.base.pdfviewerscannerwhite.ui.view.RateDialog.showRateDialog
//import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments
//import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
//import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.showKeyBoard
//import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime2
//import com.base.pdfviewerscannerwhite.utils.LogEx
//import com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
//import com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
//import com.base.pdfviewerscannerwhite.utils.updateMediaStore
//
//@SuppressLint("SetTextI18n")
//class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
//
// private val TAG = "MainActivity"
// private lateinit var mainPresenter: MainPresenter
//
// override val binding: ActivityMainBinding by lazy {
// ActivityMainBinding.inflate(layoutInflater)
// }
// private val pdfFragment: DocumentPageFragment by lazy {
// DocumentPageFragment(DocumentBean.TYPE_PDF)
// }
// private val wordFragment: DocumentPageFragment by lazy {
// DocumentPageFragment(DocumentBean.TYPE_WORD)
// }
// private val excelFragment: DocumentPageFragment by lazy {
// DocumentPageFragment(DocumentBean.TYPE_EXCEL)
// }
// private val pptFragment: DocumentPageFragment by lazy {
// DocumentPageFragment(DocumentBean.TYPE_PPT)
// }
// private val toolFragment: ToolFragment by lazy {
// ToolFragment()
// }
// private var currentFragment: Fragment = pdfFragment
// private val fragments by lazy {
// mutableListOf(pdfFragment, wordFragment, excelFragment, pptFragment, toolFragment)
// }
// private lateinit var searchAdapter: DocumentAdapter
//
// override fun initView() {
//
// mainPresenter = MainPresenter(this, this)
// mainPresenter.initScannerLauncher(this)
//
// binding.viewPager2.offscreenPageLimit = 4
// binding.viewPager2.run {
// isUserInputEnabled = true
// adapter = object : FragmentStateAdapter(this@MainActivity) {
// override fun getItemCount(): Int {
// return fragments.size
// }
//
// override fun createFragment(position: Int): Fragment {
// return fragments[position]
// }
// }
// }
// binding.viewPager2.registerOnPageChangeCallback(object :
// ViewPager2.OnPageChangeCallback() {
//
// override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
// super.onPageScrolled(position, positionOffset, positionOffsetPixels)
// if (position == 3 && positionOffset > 0) {
// binding.viewPager2.setCurrentItem(position, false)
// }
// }
//
// override fun onPageSelected(position: Int) {
// currentFragment = fragments[position]
// }
// })
//
// initTabLayout()
// initSearchAdapter()
//
// if (!checkStorePermission()) {
// showStoragePermission(launcher)
// updateMediaStore()
// }
// }
//
// private fun initSearchAdapter() {
// searchAdapter = DocumentAdapter()
// binding.rvSearch.adapter = searchAdapter
// searchAdapter.moreAction = { item ->
// if (currentFragment is DocumentPageFragment) {
// (currentFragment as DocumentPageFragment).documentMoreAction.invoke(item)
// }
// }
// searchAdapter.itemClick = {
// jumpDocument(it)
// }
//
// }
//
// private fun initTabLayout() {
// val colorPdf = ContextCompat.getColor(this, R.color.color_f02f2b)
// val colorWord = ContextCompat.getColor(this, R.color.color_0592ee)
// val colorExcel = ContextCompat.getColor(this, R.color.color_149b55)
// val colorPpt = ContextCompat.getColor(this, R.color.color_ffa127)
// binding.tabLayoutDocument.apply {
// tabIndicator.indicatorWidth =
// this.resources.getDimensionPixelOffset(R.dimen.dp_50)
// tabIndicator.indicatorHeight =
// this.resources.getDimensionPixelOffset(R.dimen.dp_4)
// tabIndicator.indicatorStyle =
// DslTabIndicator.INDICATOR_STYLE_BOTTOM
//
// configTabLayoutConfig {
// onSelectIndexChange = { fromIndex, selectIndexList, reselect, fromUser ->
// val toIndex = selectIndexList.first()
// LogEx.logDebug(
// TAG,
// "toIndex=$toIndex fromIndex=$fromIndex selectIndexList=$selectIndexList reselect=$reselect fromUser=$fromUser"
// )
//
// when (toIndex) {
// 0 -> {
// tabSelectColor = colorPdf
// tabIndicator.indicatorColor = colorPdf
// binding.viewPager2.currentItem = 0
// }
//
// 1 -> {
// tabSelectColor = colorWord
// tabIndicator.indicatorColor = colorWord
// binding.viewPager2.currentItem = 1
// }
//
// 2 -> {
// tabSelectColor = colorExcel
// tabIndicator.indicatorColor = colorExcel
// binding.viewPager2.currentItem = 2
// }
//
// 3 -> {
// tabSelectColor = colorPpt
// tabIndicator.indicatorColor = colorPpt
// binding.viewPager2.currentItem = 3
// }
// }
// dslSelector.updateStyle()
// }
// }
// }
// ViewPager2Delegate.install(binding.viewPager2, binding.tabLayoutDocument)
// }
//
// private var latViewPagerIndex = -1
//
// private lateinit var callback: OnBackPressedCallback
//
// private fun callTab() {
// LogEx.logDebug(TAG, "callTab")
// if (uiMode == HOME_UI_MODE_DOCUMENT) {
// binding.llDocument.callOnClick()
// }
// }
//
// @SuppressLint("ClickableViewAccessibility", "SetTextI18n")
// override fun initListener() {
// super.initListener()
// callback = object : OnBackPressedCallback(true /* enabled */) {
// override fun handleOnBackPressed() {
// if (uiMode == HOME_UI_MODE_SELECT) {
// when (lastUIMode) {
// HOME_UI_MODE_DOCUMENT -> changeDocumentUI()
// HOME_UI_MODE_RECENT -> changeRecentUI()
// HOME_UI_MODE_BOOKMARK -> changeBookmarkUI()
// }
// }
// if (uiMode == HOME_UI_MODE_SEARCH) {
// cancelSearchUI()
// when (lastUIMode) {
// HOME_UI_MODE_DOCUMENT -> changeDocumentUI()
// HOME_UI_MODE_RECENT -> changeRecentUI()
// HOME_UI_MODE_BOOKMARK -> changeBookmarkUI()
// }
// }
// }
//
// }
// onBackPressedDispatcher.addCallback(callback)
// binding.flFanhui.setOnClickListener {
// onBackPressedDispatcher.onBackPressed()
// }
// binding.llDocument.setOnClickListener {
// changeDocumentUI()
// }
// binding.llRecent.setOnClickListener {
// changeRecentUI()
// }
// binding.llBookmark.setOnClickListener {
// changeBookmarkUI()
// }
// binding.llTool.setOnClickListener {
// changeToolUI()
// }
// binding.ivScan.setOnClickListener {
// mainPresenter.starGmsScan(this)
// }
// binding.ivXuanze.setOnClickListener {
// changeSelectUI()
// }
// binding.tvTittle.setOnClickListener {
//
// }
// binding.vTabLayoutPlace.setOnClickListener {
//
// }
// binding.llDelete.setOnClickListener {
// if (currentFragment is DocumentPageFragment) {
// val fragment = (currentFragment as DocumentPageFragment)
// showDeleteDialog {
// val list = fragment.getSelectItems()
// mainPresenter.deleteList(list)
// fragment.removeList(list)
// }
// }
// }
// binding.ivAllSelector.setOnClickListener {
// binding.ivAllSelector.isSelected = !binding.ivAllSelector.isSelected
// changePageSelect(binding.ivAllSelector.isSelected)
// }
// binding.llShare.setOnClickListener {
// shareDocument()
// }
// binding.ivSearch.setOnClickListener {
// changeSearchUI()
// }
// binding.editSearch.addTextChangedListener {
//
// }
// binding.editSearch.setOnEditorActionListener { v, actionId, event ->
// LogEx.logDebug(TAG, "$actionId")
// if (actionId == EditorInfo.IME_ACTION_DONE) {
// LogEx.logDebug(TAG, "IME_ACTION_DONE")
// searchDocument()
// }
// false
// }
// callTab()
// }
//
//
// private fun searchDocument() {
// if (binding.editSearch.text.isNotEmpty()) {
// val search = binding.editSearch.text.toString()
// if (currentFragment is DocumentPageFragment) {
// val item = (currentFragment as DocumentPageFragment).getSearchItems(search)
// if (item.isNotEmpty()) {
// item.map { it.uiType = 4 }
// searchAdapter.submitList(item)
// } else {
// binding.llEmpty.visibility = View.VISIBLE
// }
// }
// }
// }
//
//
// private fun shareDocument() {
// if (currentFragment is DocumentPageFragment) {
// val documentFragment = (currentFragment as DocumentPageFragment)
// val items = documentFragment.getSelectItems()
// if (items.isNotEmpty()) {
// shareMutDocuments(documentFragment.type, items.map { it.uri } as ArrayList<Uri>)
// }
//
// }
// }
//
// private fun changePageSelect(select: Boolean) {
// if (currentFragment is DocumentPageFragment) {
// (currentFragment as DocumentPageFragment).changItemSelect(select)
// }
// }
//
// private fun changeTabSelect(selectView: View) {
// binding.llDocument.isSelected = selectView == binding.llDocument
// binding.llRecent.isSelected = selectView == binding.llRecent
// binding.llBookmark.isSelected = selectView == binding.llBookmark
// binding.llTool.isSelected = selectView == binding.llTool
//
// }
//
// fun changeRipple() = binding.root.postDelayed({
// val selectRipple = ContextCompat.getDrawable(this@MainActivity, R.drawable.ripple_select)
// val normalRipple = ContextCompat.getDrawable(this@MainActivity, R.drawable.ripple_normal)
//
// if (binding.llDocument.isSelected) {
// binding.llDocument.background = selectRipple
// } else {
// binding.llDocument.background = normalRipple
// }
//
// if (binding.llRecent.isSelected) {
// binding.llRecent.background = selectRipple
// } else {
// binding.llRecent.background = normalRipple
// }
//
// if (binding.llBookmark.isSelected) {
// binding.llBookmark.background = selectRipple
// } else {
// binding.llBookmark.background = normalRipple
// }
//
// if (binding.llTool.isSelected) {
// binding.llTool.background = selectRipple
// } else {
// binding.llTool.background = normalRipple
// }
// }, 200)
//
// @SuppressLint("SetTextI18n")
// override fun handleActivityGmsScanResult(imageUri: Uri, pdfUri: Uri) {
// toast("handleActivityGmsScanResult")
// if (BuildConfig.DEBUG) {
// binding.tvDebugLog.text = "imageUri=$imageUri\npdfUri=$pdfUri"
// }
// showDocumentRenameDialog(name = "PDF_${System.currentTimeMillis().toFormatTime2()}") {
//
// }
// }
//
// @SuppressLint("NotifyDataSetChanged")
// override fun refreshSearchRv() {
// searchAdapter.notifyDataSetChanged()
// }
//
// override fun deleteDocument(item: DocumentBean) {
// LogEx.logDebug(TAG, "deleteDocument $item")
// searchAdapter.remove(item)
// }
//
// override fun onResume() {
// super.onResume()
//
// showRateDialog()
// }
//
// private var uiMode = HOME_UI_MODE_DOCUMENT
//
// private fun cancelSelectUI() {
// binding.viewPager2.isUserInputEnabled = true
// callback.isEnabled = false
//
// if (latViewPagerIndex != -1) {
// binding.viewPager2.setCurrentItem(latViewPagerIndex, false)
// latViewPagerIndex = -1
// }
//
// binding.vTabLayoutPlace.visibility = View.GONE
// binding.flFanhui.visibility = View.GONE
// binding.llDelete.visibility = View.GONE
// binding.llShare.visibility = View.GONE
// binding.ivAllSelector.visibility = View.GONE
//
//
// binding.ivSearch.visibility = View.VISIBLE
// binding.tvTittle.visibility = View.VISIBLE
// binding.llDocument.visibility = View.VISIBLE
// binding.llRecent.visibility = View.VISIBLE
// binding.llBookmark.visibility = View.VISIBLE
// binding.llTool.visibility = View.VISIBLE
// binding.ivXuanze.visibility = View.VISIBLE
//
// if (currentFragment is DocumentPageFragment) {
// (currentFragment as DocumentPageFragment).changeSelectUi(false)
// }
// }
//
// fun changeDocumentUI() {
// LogEx.logDebug(TAG, "changeDocumentUI")
// uiMode = HOME_UI_MODE_DOCUMENT
// binding.tvTittle.text = "Document"
//
// cancelSelectUI()
//
// binding.ivXuanze.visibility = View.VISIBLE
// binding.ivScan.visibility = View.VISIBLE
// binding.ivPaixu.visibility = View.VISIBLE
// binding.ivScan.visibility = View.VISIBLE
//
// changeTabSelect(binding.llDocument)
//
// if (currentFragment is DocumentPageFragment) {
// (currentFragment as DocumentPageFragment).setAllList()
// }
// }
//
// fun changeRecentUI() {
// LogEx.logDebug(TAG, "changeRecentUI")
// uiMode = HOME_UI_MODE_RECENT
// binding.tvTittle.text = "Recent"
//
// cancelSelectUI()
//
// binding.clTabLayout.visibility = View.VISIBLE
// binding.ivPaixu.visibility = View.VISIBLE
// binding.ivScan.visibility = View.VISIBLE
// binding.ivScan.visibility = View.VISIBLE
//
// changeTabSelect(binding.llRecent)
//
// if (currentFragment is DocumentPageFragment) {
// (currentFragment as DocumentPageFragment).setRecentList()
// }
// }
//
// fun changeBookmarkUI() {
// LogEx.logDebug(TAG, "changeBookmarkUI")
// uiMode = HOME_UI_MODE_BOOKMARK
//
// cancelSelectUI()
//
// binding.tvTittle.text = "Bookmark"
// binding.clTabLayout.visibility = View.VISIBLE
// binding.ivScan.visibility = View.VISIBLE
// binding.ivScan.visibility = View.VISIBLE
// changeTabSelect(binding.llBookmark)
// if (currentFragment is DocumentPageFragment) {
// (currentFragment as DocumentPageFragment).setBookmarkList()
// }
// }
//
// private fun changeToolUI() {
// LogEx.logDebug(TAG, "changeToolUI")
// uiMode = HOME_UI_MODE_TOOL
// callback.isEnabled = false
// binding.viewPager2.isUserInputEnabled = true
//
// binding.tvTittle.text = "Tool"
// binding.ivScan.visibility = View.GONE
// binding.clTabLayout.visibility = View.GONE
// latViewPagerIndex = binding.viewPager2.currentItem
// binding.viewPager2.setCurrentItem(5, false)
// changeTabSelect(binding.llTool)
// }
//
// private var lastUIMode = HOME_UI_MODE_DOCUMENT
// private fun changeSelectUI() {
// LogEx.logDebug(TAG, "changeSelectUI")
// callback.isEnabled = true
// lastUIMode = uiMode
// uiMode = HOME_UI_MODE_SELECT
// binding.ivPaixu.visibility = View.INVISIBLE
// binding.ivXuanze.visibility = View.INVISIBLE
// binding.ivSearch.visibility = View.INVISIBLE
// binding.tvTittle.visibility = View.INVISIBLE
// binding.ivScan.visibility = View.INVISIBLE
//
// binding.llDocument.visibility = View.INVISIBLE
// binding.llRecent.visibility = View.INVISIBLE
// binding.llBookmark.visibility = View.INVISIBLE
// binding.llTool.visibility = View.INVISIBLE
//
// binding.flFanhui.visibility = View.VISIBLE
// binding.llDelete.visibility = View.VISIBLE
// binding.llShare.visibility = View.VISIBLE
//
// binding.ivAllSelector.visibility = View.VISIBLE
// binding.viewPager2.isUserInputEnabled = false
// binding.vTabLayoutPlace.visibility = View.VISIBLE
//
// if (currentFragment is DocumentPageFragment) {
// (currentFragment as DocumentPageFragment).changeSelectUi(true)
// }
// }
//
// private fun changeSearchUI() {
// callback.isEnabled = true
// lastUIMode = uiMode
// uiMode = HOME_UI_MODE_SEARCH
//
// binding.tvTittle.visibility = View.INVISIBLE
// binding.ivPaixu.visibility = View.INVISIBLE
// binding.ivXuanze.visibility = View.INVISIBLE
// binding.llMainContent.visibility = View.INVISIBLE
//
// binding.editSearch.visibility = View.VISIBLE
// binding.flFanhui.visibility = View.VISIBLE
// binding.flSearch.visibility = View.VISIBLE
// binding.flSearch.setOnClickListener {}
// binding.editSearch.requestFocus()
// showKeyBoard(binding.editSearch)
// }
//
// private fun cancelSearchUI() {
// binding.flFanhui.visibility = View.GONE
// binding.flSearch.visibility = View.GONE
// binding.editSearch.visibility = View.GONE
// binding.llEmpty.visibility = View.GONE
// searchAdapter.submitList(listOf())
// binding.editSearch.setText("")
// hideKeyboard(binding.editSearch)
//
// binding.llMainContent.visibility = View.VISIBLE
// binding.tvTittle.visibility = View.VISIBLE
// binding.ivPaixu.visibility = View.VISIBLE
// binding.ivXuanze.visibility = View.VISIBLE
//
// if (currentFragment is DocumentPageFragment) {
// (currentFragment as DocumentPageFragment).changeHomeUI()
// }
// }
//
// companion object {
// const val HOME_UI_MODE_DOCUMENT = "home_ui_mode_document"
// const val HOME_UI_MODE_RECENT = "home_ui_mode_recent"
// const val HOME_UI_MODE_BOOKMARK = "home_ui_mode_bookmark"
// const val HOME_UI_MODE_TOOL = "home_ui_mode_tool"
// const val HOME_UI_MODE_SELECT = "home_ui_mode_select"
// const val HOME_UI_MODE_SEARCH = "home_ui_mode_search"
// }
//}
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ui.main
import android.os.Bundle
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.angcyo.tablayout.DslTabIndicator
import com.angcyo.tablayout.delegate2.ViewPager2Delegate
import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.FragmentRecentBinding
import com.base.pdfviewerscannerwhite.helper.BaseFragment
class RecentFragment : BaseFragment<FragmentRecentBinding>() {
override val binding: FragmentRecentBinding by lazy {
FragmentRecentBinding.inflate(layoutInflater)
}
private val pdfPage: DocumentPageFragment by lazy {
DocumentPageFragment(DocumentBean.TYPE_PDF)
}
private val wordPage: DocumentPageFragment by lazy {
DocumentPageFragment(DocumentBean.TYPE_WORD)
}
private val excelPage: DocumentPageFragment by lazy {
DocumentPageFragment()
}
private val pptPage: DocumentPageFragment by lazy {
DocumentPageFragment()
}
private val fragments by lazy {
mutableListOf(pdfPage, wordPage, excelPage, pptPage)
}
override fun setView() {
initPageViewer()
initTabLayout()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
private fun initPageViewer() {
binding.viewPager2.run {
isUserInputEnabled = true
adapter = object : FragmentStateAdapter(this@RecentFragment) {
override fun getItemCount(): Int {
return fragments.size
}
override fun createFragment(position: Int): Fragment {
return fragments[position]
}
}
}
binding.viewPager2.registerOnPageChangeCallback(object :
ViewPager2.OnPageChangeCallback() {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
super.onPageScrolled(position, positionOffset, positionOffsetPixels)
if (position == 3 && positionOffset > 0) {
binding.viewPager2.setCurrentItem(position, false)
}
}
override fun onPageSelected(position: Int) {
}
})
}
private fun initTabLayout() {
val colorPdf = ContextCompat.getColor(requireContext(), R.color.color_f02f2b)
val colorWord = ContextCompat.getColor(requireContext(), R.color.color_0592ee)
val colorExcel = ContextCompat.getColor(requireContext(), R.color.color_149b55)
val colorPpt = ContextCompat.getColor(requireContext(), R.color.color_ffa127)
binding.tabLayoutDocument.apply {
tabIndicator.indicatorWidth =
this.resources.getDimensionPixelOffset(R.dimen.dp_50)
tabIndicator.indicatorHeight =
this.resources.getDimensionPixelOffset(R.dimen.dp_4)
tabIndicator.indicatorStyle =
DslTabIndicator.INDICATOR_STYLE_BOTTOM
configTabLayoutConfig {
onSelectIndexChange = { fromIndex, selectIndexList, reselect, fromUser ->
val toIndex = selectIndexList.first()
when (toIndex) {
0 -> {
tabSelectColor = colorPdf
tabIndicator.indicatorColor = colorPdf
binding.viewPager2.currentItem = 0
}
1 -> {
tabSelectColor = colorWord
tabIndicator.indicatorColor = colorWord
binding.viewPager2.currentItem = 1
}
2 -> {
tabSelectColor = colorExcel
tabIndicator.indicatorColor = colorExcel
binding.viewPager2.currentItem = 2
}
3 -> {
tabSelectColor = colorPpt
tabIndicator.indicatorColor = colorPpt
binding.viewPager2.currentItem = 3
}
}
dslSelector.updateStyle()
}
}
}
ViewPager2Delegate.install(binding.viewPager2, binding.tabLayoutDocument)
}
companion object {
}
}
\ No newline at end of file
...@@ -11,7 +11,6 @@ import com.base.pdfviewerscannerwhite.bean.ConstObject.ifAgreePrivacy ...@@ -11,7 +11,6 @@ import com.base.pdfviewerscannerwhite.bean.ConstObject.ifAgreePrivacy
import com.base.pdfviewerscannerwhite.databinding.ActivitySplashBinding import com.base.pdfviewerscannerwhite.databinding.ActivitySplashBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.ui.main.MainActivity import com.base.pdfviewerscannerwhite.ui.main.MainActivity
import com.base.pdfviewerscannerwhite.ui.main.MainActivity2
import com.base.pdfviewerscannerwhite.utils.BarUtils import com.base.pdfviewerscannerwhite.utils.BarUtils
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
...@@ -113,7 +112,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView { ...@@ -113,7 +112,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
LogEx.logDebug(TAG, "jumpNext") LogEx.logDebug(TAG, "jumpNext")
binding.progressBar.progress = 100 binding.progressBar.progress = 100
binding.root.postDelayed({ binding.root.postDelayed({
startActivity(Intent(this, MainActivity2::class.java)) startActivity(Intent(this, MainActivity::class.java))
finish() finish()
}, 200) }, 200)
} }
......
...@@ -22,7 +22,6 @@ import com.base.pdfviewerscannerwhite.databinding.DialogPageNumberBinding ...@@ -22,7 +22,6 @@ import com.base.pdfviewerscannerwhite.databinding.DialogPageNumberBinding
import com.base.pdfviewerscannerwhite.databinding.DialogStoragePermissionBinding import com.base.pdfviewerscannerwhite.databinding.DialogStoragePermissionBinding
import com.base.pdfviewerscannerwhite.ui.main.DocumentPageFragment import com.base.pdfviewerscannerwhite.ui.main.DocumentPageFragment
import com.base.pdfviewerscannerwhite.ui.main.MainActivity import com.base.pdfviewerscannerwhite.ui.main.MainActivity
import com.base.pdfviewerscannerwhite.ui.main.MainActivity2
import com.base.pdfviewerscannerwhite.utils.ActivityLauncher import com.base.pdfviewerscannerwhite.utils.ActivityLauncher
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.documentShare import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.documentShare
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
...@@ -103,7 +102,7 @@ object DialogView { ...@@ -103,7 +102,7 @@ object DialogView {
fun Context.showDocumentHomeMoreDialog( fun Context.showDocumentHomeMoreDialog(
item: DocumentBean, item: DocumentBean,
documentFragment: DocumentPageFragment, documentFragment: DocumentPageFragment,
mainActivity: MainActivity2, mainActivity: MainActivity,
): BottomSheetDialog { ): BottomSheetDialog {
val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog) val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog)
val binding = DialogDocumentHomeMoreBinding.inflate(LayoutInflater.from(this)) val binding = DialogDocumentHomeMoreBinding.inflate(LayoutInflater.from(this))
......
...@@ -20,7 +20,6 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils ...@@ -20,7 +20,6 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView
import com.base.pdfviewerscannerwhite.ui.main.DocumentPageFragment import com.base.pdfviewerscannerwhite.ui.main.DocumentPageFragment
import com.base.pdfviewerscannerwhite.ui.main.MainActivity import com.base.pdfviewerscannerwhite.ui.main.MainActivity
import com.base.pdfviewerscannerwhite.ui.main.MainActivity2
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentDetail import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentDetail
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog
...@@ -42,7 +41,7 @@ object PdfDialog { ...@@ -42,7 +41,7 @@ object PdfDialog {
item: DocumentBean, item: DocumentBean,
adapter: DocumentAdapter, adapter: DocumentAdapter,
documentFragment: DocumentPageFragment, documentFragment: DocumentPageFragment,
mainActivity: MainActivity2 mainActivity: MainActivity
): BottomSheetDialog { ): BottomSheetDialog {
val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog) val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog)
val binding = DialogPdfHomeMoreBinding.inflate(LayoutInflater.from(this)) val binding = DialogPdfHomeMoreBinding.inflate(LayoutInflater.from(this))
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
android:id="@+id/main" android:id="@+id/main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.main.MainActivity2"> tools:context=".ui.main.MainActivity">
<FrameLayout <FrameLayout
android:id="@+id/fl_container" android:id="@+id/fl_container"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.RecentFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_top"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="@+id/fl_fanhui"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/fanhui_b"
tools:ignore="ContentDescription" />
</FrameLayout>
<EditText
android:id="@+id/edit_search"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="20dp"
android:background="@drawable/bg_f8f9fe_10"
android:hint="Enter the file name to search for"
android:imeOptions="actionDone"
android:paddingHorizontal="18dp"
android:singleLine="true"
android:textColor="@color/black"
android:textColorHint="#B8B9BD"
android:textSize="14sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_search"
app:layout_constraintStart_toEndOf="@id/fl_fanhui"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="Autofill,HardcodedText,RtlSymmetry,TextFields" />
<TextView
android:id="@+id/tv_tittle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:text="Bookmark"
android:textColor="@color/black"
android:textSize="19sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/iv_paixu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/h_paixu"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_xuanze"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/iv_xuanze"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/h_xuanze"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_search"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/iv_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/h_sousuo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/iv_all_selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg_selector_select"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/iv_search"
app:layout_constraintStart_toStartOf="@id/iv_search"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/ll_main_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/cl_top">
<!-- 外层FrameLayout设置背景用来限定水波纹大小-->
<FrameLayout
android:id="@+id/cl_tabLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#00000000">
<com.angcyo.tablayout.DslTabLayout
android:id="@+id/tabLayout_document"
android:layout_width="match_parent"
android:layout_height="50dp"
app:tab_badge_gravity="center"
app:tab_badge_offset_x="20dp"
app:tab_draw_indicator="true"
app:tab_enable_text_color="true"
app:tab_indicator_drawable="@drawable/indicator_bottom_line"
app:tab_indicator_height="3dp"
app:tab_item_is_equ_width="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ripple_select"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="PDF"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/ripple_select"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:paddingVertical="5dp"
android:text="Word"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ripple_select"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="Excel"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ripple_select"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="PPT"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
</com.angcyo.tablayout.DslTabLayout>
<View
android:id="@+id/v_tabLayout_place"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</FrameLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.RecentFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_top"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="@+id/fl_fanhui"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/fanhui_b"
tools:ignore="ContentDescription" />
</FrameLayout>
<EditText
android:id="@+id/edit_search"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="20dp"
android:background="@drawable/bg_f8f9fe_10"
android:hint="Enter the file name to search for"
android:imeOptions="actionDone"
android:paddingHorizontal="18dp"
android:singleLine="true"
android:textColor="@color/black"
android:textColorHint="#B8B9BD"
android:textSize="14sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_search"
app:layout_constraintStart_toEndOf="@id/fl_fanhui"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="Autofill,HardcodedText,RtlSymmetry,TextFields" />
<TextView
android:id="@+id/tv_tittle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:text="Recent"
android:textColor="@color/black"
android:textSize="19sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/iv_xuanze"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/h_xuanze"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_search"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/iv_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/h_sousuo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/iv_all_selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg_selector_select"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/iv_search"
app:layout_constraintStart_toStartOf="@id/iv_search"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/ll_main_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/cl_top">
<!-- 外层FrameLayout设置背景用来限定水波纹大小-->
<FrameLayout
android:id="@+id/cl_tabLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#00000000">
<com.angcyo.tablayout.DslTabLayout
android:id="@+id/tabLayout_document"
android:layout_width="match_parent"
android:layout_height="50dp"
app:tab_badge_gravity="center"
app:tab_badge_offset_x="20dp"
app:tab_draw_indicator="true"
app:tab_enable_text_color="true"
app:tab_indicator_drawable="@drawable/indicator_bottom_line"
app:tab_indicator_height="3dp"
app:tab_item_is_equ_width="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ripple_select"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="PDF"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/ripple_select"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:paddingVertical="5dp"
android:text="Word"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ripple_select"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="Excel"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ripple_select"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="PPT"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
</com.angcyo.tablayout.DslTabLayout>
<View
android:id="@+id/v_tabLayout_place"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</FrameLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment