Commit 2327df15 authored by wanglei's avatar wanglei

...

parent 9e47eb95
......@@ -61,6 +61,7 @@
<activity
android:name=".ui.document.word.WordActivity"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/Theme.PDFViewerScannerWhite"
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
......
......@@ -261,11 +261,10 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
fileType = intent?.getIntExtra(Constant.INTENT_TYPE_KEY, -1) ?: -1
engine = intent?.getIntExtra(Constant.INTENT_ENGINE_KEY, DocEngine.INTERNAL.value) ?: DocEngine.INTERNAL.value
binding.mDocView.openDoc(this, pathOrUri, docSourceType, fileType, false, DocEngine.values().first { it.value == engine })
binding.mDocView.openDoc(this, pathOrUri, docSourceType, fileType, false)
LogEx.logDebug(TAG, "initData-pathOrUri = $pathOrUri")
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType")
LogEx.logDebug(TAG, "initData-engine = $engine")
}
......
......@@ -107,11 +107,10 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
fileType = intent?.getIntExtra(Constant.INTENT_TYPE_KEY, -1) ?: -1
engine = intent?.getIntExtra(Constant.INTENT_ENGINE_KEY, DocEngine.INTERNAL.value) ?: DocEngine.INTERNAL.value
binding.mDocView.openDoc(this, pathOrUri, docSourceType, fileType, false, DocEngine.values().first { it.value == engine })
binding.mDocView.openDoc(this, pathOrUri, docSourceType, fileType, false)
LogEx.logDebug(TAG, "initData-docUrl = $pathOrUri")
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType")
LogEx.logDebug(TAG, "initData-engine = $engine")
}
private fun showTopLayout() {
......
......@@ -69,13 +69,11 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
LogEx.logDebug(TAG, "show")
}
}
}
private fun setVerticalSeekbar(current: Int, max: Int) {
binding.verticalSeekbar.showThumb = true
binding.verticalSeekbar.thumbContainerColor= Color.TRANSPARENT
binding.verticalSeekbar.thumbContainerColor = Color.TRANSPARENT
binding.verticalSeekbar.thumbPlaceholderDrawable =
ContextCompat.getDrawable(this, R.mipmap.fanye)
if (binding.verticalSeekbar.maxValue != max - 1) {
......@@ -93,6 +91,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
cancelSearchUI()
return@addCallback
}
LogEx.logDebug(TAG, "finishToMain")
finishToMain()
}
binding.flFanhui.setOnClickListener {
......@@ -103,11 +102,11 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
}
binding.ivMore.setOnClickListener {
showDocumentMore(wordDocumentBean, totalPageNumber - 1) { pageIndex ->
val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl)
val wpControl: WPControl? = (binding.mDocView.iOffice?.control?.appControl as WPControl?)
if (pageIndex > currentPageNumber) {
wpControl.wpView.showPage(pageIndex, APP_PAGE_DOWN_ID)
wpControl?.wpView?.showPage(pageIndex, APP_PAGE_DOWN_ID)
} else {
wpControl.wpView.showPage(pageIndex, APP_PAGE_UP_ID)
wpControl?.wpView?.showPage(pageIndex, APP_PAGE_UP_ID)
}
// wpControl.actionEvent(APP_PAGE_UP_ID, null)
}
......@@ -120,8 +119,8 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
binding.tvPageCount.visibility = View.VISIBLE
haveSearchResult = false
hideBottomLayout()
val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl)
(wpControl.find as WPFind).resetSearchResult()
val wpControl: WPControl? = (binding.mDocView.iOffice?.control?.appControl as WPControl?)
(wpControl?.find as WPFind?)?.resetSearchResult()
}
binding.editSearch.setOnEditorActionListener { v, actionId, event ->
......@@ -133,23 +132,23 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
false
}
binding.flPre.setOnClickListener {
val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl)
(wpControl.find as WPFind).findBackward()
val wpControl: WPControl? = (binding.mDocView.iOffice?.control?.appControl as WPControl?)
(wpControl?.find as WPFind?)?.findBackward()
}
binding.flNext.setOnClickListener {
val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl)
(wpControl.find as WPFind).findForward()
val wpControl: WPControl? = (binding.mDocView.iOffice?.control?.appControl as WPControl?)
(wpControl?.find as WPFind).findForward()
}
binding.verticalSeekbar.setOnReleaseListener { progress ->
val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl)
val wpControl: WPControl? = (binding.mDocView.iOffice?.control?.appControl as WPControl?)
LogEx.logDebug(TAG, "progress=$progress")
val pageIndex = totalPageNumber - 1 - progress
if (progress > currentPageNumber) {
wpControl.wpView.showPage(pageIndex, APP_PAGE_DOWN_ID)
wpControl?.wpView?.showPage(pageIndex, APP_PAGE_DOWN_ID)
} else {
wpControl.wpView.showPage(pageIndex, APP_PAGE_UP_ID)
wpControl?.wpView?.showPage(pageIndex, APP_PAGE_UP_ID)
}
}
}
......@@ -160,10 +159,10 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
if (text.isNullOrEmpty()) {
return
}
val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl)
val flag = (wpControl.find as WPFind).find(text.toString())
haveSearchResult = flag
if (flag) {
val wpControl: WPControl? = (binding.mDocView.iOffice?.control?.appControl as WPControl?)
val flag = (wpControl?.find as WPFind?)?.find(text.toString())
haveSearchResult = flag ?: false
if (flag == true) {
hideKeyboard(binding.editSearch)
showBottomLayout()
} else {
......@@ -291,7 +290,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
fileType = intent?.getIntExtra(Constant.INTENT_TYPE_KEY, -1) ?: -1
engine = intent?.getIntExtra(Constant.INTENT_ENGINE_KEY, DocEngine.INTERNAL.value) ?: DocEngine.INTERNAL.value
binding.mDocView.openDoc(this, pathOrUri, docSourceType, fileType, false, DocEngine.values().first { it.value == engine })
binding.mDocView.openDoc(this, pathOrUri, docSourceType, fileType, false)
LogEx.logDebug(TAG, "initData-docUrl = $pathOrUri")
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType")
......@@ -317,4 +316,8 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
}
}
override fun onDestroy() {
super.onDestroy()
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.base.pdfviewerscannerwhite.ui.main
import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.View
import androidx.activity.OnBackPressedCallback
import androidx.fragment.app.Fragment
......@@ -23,10 +24,12 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
private val TAG="MainActivity"
lateinit var mainPresenter: MainPresenter
override val binding: ActivityMain2Binding by lazy {
ActivityMain2Binding.inflate(layoutInflater)
......@@ -46,6 +49,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
private var currentFragment: Fragment = documentFragment
override fun initView() {
LogEx.logDebug(TAG,"initView")
mainPresenter = MainPresenter(this, this, lifecycleScope)
}
......@@ -61,6 +65,11 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
}
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
LogEx.logDebug(TAG,"onSaveInstanceState")
}
var isDocumentAdd: Boolean = false
var isRecentAdd: Boolean = false
var isBookmarkAdd: Boolean = false
......@@ -92,6 +101,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
changeTabSelect(it)
supportFragmentManager.beginTransaction().apply {
if (!isDocumentAdd) {
add(R.id.fl_container, documentFragment)
}
......
......@@ -53,13 +53,10 @@ open class DocViewerActivity : AppCompatActivity() {
this,
docUrl,
docSourceType,
fileType,
false,
DocEngine.values().first { it.value == engine })
fileType, false)
Log.e(TAG, "initData-docUrl = $docUrl")
Log.e(TAG, "initData-docSourceType = $docSourceType")
Log.e(TAG, "initData-fileType = $fileType")
Log.e(TAG, "initData-engine = $engine")
}
}
\ No newline at end of file
......@@ -43,9 +43,7 @@ public abstract class IOffice implements IMainFrame {
if (componentWidth == 0 || componentHeight == 0) {
return null;
}
if (bitmap == null
|| bitmap.getWidth() != componentWidth
|| bitmap.getHeight() != componentHeight) {
if (bitmap == null || bitmap.getWidth() != componentWidth || bitmap.getHeight() != componentHeight) {
// custom picture size
if (bitmap != null) {
bitmap.recycle();
......@@ -82,10 +80,13 @@ public abstract class IOffice implements IMainFrame {
}
private void saveBitmapToFile(Bitmap bitmap) {
Log.e(TAG,"saveBitmapToFile1");
if (bitmap == null) {
Log.e(TAG,"saveBitmapToFile2");
return;
}
if (tempFilePath == null) {
Log.e(TAG,"saveBitmapToFile3");
// 存在外部目录相册中会显示
// String state = Environment.getExternalStorageState();
// if (Environment.MEDIA_MOUNTED.equals(state)) {
......@@ -101,6 +102,7 @@ public abstract class IOffice implements IMainFrame {
File file = new File(tempFilePath + File.separatorChar + "export_image.jpg");
try {
if (file.exists()) {
Log.e(TAG,"saveBitmapToFile4");
file.delete();
}
file.createNewFile();
......
......@@ -38,7 +38,6 @@ public class APageListView extends AdapterView<Adapter> {
}
/**
*
*/
......@@ -721,6 +720,7 @@ public class APageListView extends AdapterView<Adapter> {
*
*/
public float getZoom() {
Log.e("APageListView", "getZoom");
return zoom;
}
......@@ -728,6 +728,7 @@ public class APageListView extends AdapterView<Adapter> {
*
*/
public float getFitZoom() {
Log.e("APageListView", "getFitZoom");
return getFitZoom(0);
}
......
......@@ -174,6 +174,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener {
*
*/
public float getZoom() {
Log.e("PrintWord","getZoom");
return listView.getZoom();
}
......@@ -181,6 +182,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener {
*
*/
public float getFitZoom() {
Log.e("PrintWord","getFitZoom");
return listView.getFitZoom();
}
......
......@@ -40,6 +40,7 @@ import com.cherry.lib.doc.office.system.IControl;
import com.cherry.lib.doc.office.system.IDialogAction;
import com.cherry.lib.doc.office.system.SysKit;
import com.cherry.lib.doc.office.system.beans.pagelist.APageListView;
import com.cherry.lib.doc.office.thirdpart.emf.io.Tag;
import com.cherry.lib.doc.office.wp.view.LayoutKit;
import com.cherry.lib.doc.office.wp.view.NormalRoot;
import com.cherry.lib.doc.office.wp.view.PageRoot;
......@@ -112,6 +113,7 @@ public class Word extends LinearLayout implements IWord {
if (normalRoot != null) {
normalRoot.doLayout(0, 0, mWidth, mHeight, Integer.MAX_VALUE, 0);
} else {
Log.e("Word", "init");
pageRoot.doLayout(0, 0, mWidth, mHeight, Integer.MAX_VALUE, 0);
}
initFinish = true;
......@@ -140,6 +142,7 @@ public class Word extends LinearLayout implements IWord {
}
try {
if (getCurrentRootType() == WPViewConstant.PAGE_ROOT) {
Log.e("Wod", "onDraw zoom=" + zoom);
pageRoot.draw(canvas, 0, 0, zoom);
drawPageNubmer(canvas, zoom);
} else if (getCurrentRootType() == WPViewConstant.NORMAL_ROOT) {
......@@ -172,7 +175,9 @@ public class Word extends LinearLayout implements IWord {
*
*/
private void toPicture(IOfficeToPicture otp) {
Log.e("Word", "toPicture1");
if (getCurrentRootType() == WPViewConstant.PRINT_ROOT) {
Log.e("Word", "toPicture2");
WPPageListItem item = (WPPageListItem) printWord.getListView().getCurrentPageView();
item.addRepaintImageView(null);
return;
......@@ -181,12 +186,15 @@ public class Word extends LinearLayout implements IWord {
PictureKit.instance().setDrawPictrue(true);
Bitmap bitmap = otp.getBitmap(getWidth(), getHeight());
if (bitmap == null) {
Log.e("Word", "toPicture3");
return;
}
float paintZoom = getZoom();
Log.e("Word", "paintZoom=" + paintZoom);
float tX = -getScrollX();
float tY = -getScrollY();
if (bitmap.getWidth() != getWidth() || bitmap.getHeight() != getHeight()) {
Log.e("Word", "toPicture4");
float newZoom = Math.min((float) bitmap.getWidth() / getWidth(),
(float) bitmap.getHeight() / getHeight())
* getZoom();
......@@ -275,7 +283,7 @@ public class Word extends LinearLayout implements IWord {
return;
}
eventManage.stopFling();
LayoutKit.instance().layoutAllPage(pageRoot, zoom);
LayoutKit.instance().layoutAllPage(pageRoot, zoom, 1);
if (currentRootType == WPViewConstant.PAGE_ROOT) {
Rectangle r = getVisibleRect();
int sX = r.x;
......@@ -374,9 +382,10 @@ public class Word extends LinearLayout implements IWord {
} else if (getCurrentRootType() == WPViewConstant.PAGE_ROOT) {
if (pageRoot == null) {
pageRoot = new PageRoot(this);
Log.e("Word", "switchView1");
pageRoot.doLayout(0, 0, mWidth, mHeight, Integer.MAX_VALUE, 0);
} else {
LayoutKit.instance().layoutAllPage(pageRoot, zoom);
LayoutKit.instance().layoutAllPage(pageRoot, zoom, 2);
}
setOnTouchListener(eventManage);
if (printWord != null) {
......@@ -385,6 +394,7 @@ public class Word extends LinearLayout implements IWord {
} else if (getCurrentRootType() == WPViewConstant.PRINT_ROOT) {
if (pageRoot == null) {
pageRoot = new PageRoot(this);
Log.e("Word", "switchView2");
pageRoot.doLayout(0, 0, mWidth, mHeight, Integer.MAX_VALUE, 0);
}
if (printWord == null) {
......@@ -438,11 +448,13 @@ public class Word extends LinearLayout implements IWord {
* @param zoom The zoom to set.
*/
public void setZoom(float zoom, int pointX, int pointY) {
Log.e("Word", "setZoom " + "zoom=" + zoom + " pointX=" + pointX + " pointY=" + pointY);
float oldZoom = 1.0f;
if (currentRootType == WPViewConstant.PAGE_ROOT) {
oldZoom = this.zoom;
this.zoom = zoom;
LayoutKit.instance().layoutAllPage(pageRoot, zoom);
Log.e("Word", "setZoom zoom=" + this.zoom);
LayoutKit.instance().layoutAllPage(pageRoot, zoom, 3);
} else if (currentRootType == WPViewConstant.PRINT_ROOT) {
printWord.setZoom(zoom, pointX, pointY);
return;
......@@ -889,9 +901,11 @@ public class Word extends LinearLayout implements IWord {
* @return Returns the zoom.
*/
public float getZoom() {
Log.e("Word", "getZoom currentRootType=" + currentRootType);
if (currentRootType == WPViewConstant.NORMAL_ROOT) {
return normalZoom;
} else if (currentRootType == WPViewConstant.PAGE_ROOT) {
Log.e("Word", "getZoom zoom=" + zoom);
return zoom;
} else if (currentRootType == WPViewConstant.PRINT_ROOT) {
if (printWord != null) {
......
......@@ -64,12 +64,18 @@ public class LayoutKit {
* @param root
* @param zoom
*/
public void layoutAllPage(PageRoot root, float zoom) {
public void layoutAllPage(PageRoot root, float zoom, int where) {
Log.e("LayoutKit", "layoutAllPage zoom=" + zoom + " where=" + where);
if (root == null || root.getChildView() == null) {
Log.e("LayoutKit", "中断1");
return;
}
Word word = (Word) root.getContainer();
if (word.getContext() != null && (screenWidthPixels == 0 || screenHeightPixels == 0)) {
// if (word.getContext() != null && (screenWidthPixels == 0 || screenHeightPixels == 0)) {
if (screenWidthPixels == 0) {
}
if (word.getContext() != null) {
// 获取资源对象
Resources resources = word.getContext().getResources();
boolean isLandscape = resources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
......@@ -89,14 +95,17 @@ public class LayoutKit {
IView pv = root.getChildView();
int pvWidth = pv.getWidth();
float scale = 1;
Log.e(TAG, "layoutAllPage screenWidthPixels=" + screenWidthPixels + " pvWidth" + pvWidth);
if (screenWidthPixels != 0 && pvWidth != 0) {
scale = screenWidthPixels * 1f / pvWidth;
if (zoom == 1f) {
Log.e(TAG, "layoutAllPage scale=" + scale);
word.setZoom(scale, 0, 0);
}
}
Log.d(TAG, "layoutAllPage screenWidthPixels = " + screenWidthPixels + "; isLandscape " + isLandscape + ", pvWidth = " + pvWidth + "; scale = " + scale);
}
Log.e("LayoutKit", "中断2");
int dx = WPViewConstant.PAGE_SPACE;
int dy = WPViewConstant.PAGE_SPACE;
IView pv = root.getChildView();
......
......@@ -72,7 +72,7 @@ public class WPLayouter
PageView pv = (PageView)ViewFactory.createView(root.getControl(), section, null, WPViewConstant.PAGE_VIEW);
root.appendChlidView(pv);
layoutPage(pv);
LayoutKit.instance().layoutAllPage(root, 1.0f);
LayoutKit.instance().layoutAllPage(root, 1.0f,5);
}
/**
......
......@@ -113,10 +113,9 @@ class DocView : FrameLayout {
fun openDoc(
activity: Activity, docUrl: String?, docSourceType: Int,
engine: DocEngine = this.engine
) {
mActivity = activity
openDoc(activity, docUrl, docSourceType, -1, false, engine)
openDoc(activity, docUrl, docSourceType, -1, false)
}
@SuppressLint("ObsoleteSdkInt")
......@@ -126,7 +125,6 @@ class DocView : FrameLayout {
docSourceType: Int,
fileType: Int,
viewPdfInPage: Boolean = false,
engine: DocEngine = this.engine
) {
var fileType = fileType
var docUrl = docUrl
......
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