Search in sources :

Example 6 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class VerticalViewActivity method onCreate.

/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    intetrstialTimeoutSec = ADS.FULL_SCREEN_TIMEOUT_SEC;
    DocumentController.doRotation(this);
    AppState.get().load(this);
    FileMetaCore.checkOrCreateMetaInfo(this);
    if (AppState.get().isRememberMode && AppState.get().isAlwaysOpenAsMagazine) {
        super.onCreate(savedInstanceState);
        if (AppState.get().isDayNotInvert) {
            setTheme(R.style.StyledIndicatorsWhite);
        } else {
            setTheme(R.style.StyledIndicatorsBlack);
        }
        finish();
        ExtUtils.showDocumentInner(this, getIntent().getData(), getIntent().getIntExtra(DocumentController.EXTRA_PAGE, 0));
        return;
    } else {
        if (getIntent().getData() != null) {
            String path = getIntent().getData().getPath();
            final BookSettings bs = SettingsManager.getBookSettings(path);
            // AppState.get().setNextScreen(bs.isNextScreen);
            if (bs != null) {
                // AppState.get().isLocked = bs.isLocked;
                AppState.get().autoScrollSpeed = bs.speed;
                AppState.get().isCut = bs.isTextFormat() ? false : bs.splitPages;
                AppState.get().isCrop = bs.cropPages;
                AppState.get().isDouble = false;
                AppState.get().isDoubleCoverAlone = false;
                AppState.get().isLocked = bs.isLocked;
                TempHolder.get().pageDelta = bs.pageDelta;
                if (AppState.get().isCropPDF && !bs.isTextFormat()) {
                    AppState.get().isCrop = true;
                }
            }
            BookCSS.get().detectLang(path);
        }
        getController().beforeCreate(this);
        BrightnessHelper.applyBrigtness(this);
        if (AppState.get().isDayNotInvert) {
            setTheme(R.style.StyledIndicatorsWhite);
        } else {
            setTheme(R.style.StyledIndicatorsBlack);
        }
        super.onCreate(savedInstanceState);
    }
    if (PasswordDialog.isNeedPasswordDialog(this)) {
        return;
    }
    setContentView(R.layout.activity_vertical_view);
    Android6.checkPermissions(this);
    getController().createWrapper(this);
    frameLayout = (FrameLayout) findViewById(R.id.documentView);
    view = new PdfSurfaceView(getController());
    frameLayout.addView(view.getView());
    getController().afterCreate(this);
    // ADS.activate(this, adView);
    handler = new Handler();
    getController().onBookLoaded(new Runnable() {

        @Override
        public void run() {
            handler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    isInitPosistion = Dips.screenHeight() > Dips.screenWidth();
                    isInitOrientation = AppState.get().orientation;
                }
            }, 1000);
        }
    });
}
Also used : PdfSurfaceView(org.ebookdroid.ui.viewer.viewers.PdfSurfaceView) BookSettings(org.ebookdroid.common.settings.books.BookSettings) Handler(android.os.Handler)

Example 7 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class AbstractScrollController method onLayoutChanged.

/**
 * {@inheritDoc}
 *
 * @see org.ebookdroid.core.AbstractViewController#onLayoutChanged(boolean, boolean, android.graphics.Rect,
 *      android.graphics.Rect)
 */
@Override
public final boolean onLayoutChanged(final boolean layoutChanged, final boolean layoutLocked, final Rect oldLaout, final Rect newLayout) {
    final BookSettings bs = SettingsManager.getBookSettings();
    final int page = model != null ? model.getCurrentViewPageIndex() : -1;
    final float offsetX = bs != null ? bs.offsetX : 0;
    final float offsetY = bs != null ? bs.offsetY : 0;
    if (super.onLayoutChanged(layoutChanged, layoutLocked, oldLaout, newLayout)) {
        if (isShown && layoutChanged && page != -1) {
            goToPage(page, offsetX, offsetY);
        }
        return true;
    }
    return false;
}
Also used : BookSettings(org.ebookdroid.common.settings.books.BookSettings)

Example 8 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class AbstractViewController method show.

/**
 * {@inheritDoc}
 *
 * @see org.ebookdroid.ui.viewer.IViewController#show()
 */
@Override
public final void show() {
    if (!isInitialized) {
        return;
    }
    if (!isShown) {
        isShown = true;
        invalidatePageSizes(InvalidateSizeReason.INIT, null);
        final BookSettings bs = SettingsManager.getBookSettings();
        final Page page = pageToGo.getActualPage(model, bs);
        final int toPage = page != null ? page.index.viewIndex : 0;
        goToPage(toPage, bs.offsetX, bs.offsetY);
    }
}
Also used : BookSettings(org.ebookdroid.common.settings.books.BookSettings)

Example 9 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class HScrollController method invalidatePageSizes.

/**
 * {@inheritDoc}
 *
 * @see org.ebookdroid.ui.viewer.IViewController#invalidatePageSizes(org.ebookdroid.ui.viewer.IViewController.InvalidateSizeReason,
 *      org.ebookdroid.core.Page)
 */
@Override
public final synchronized void invalidatePageSizes(final InvalidateSizeReason reason, final Page changedPage) {
    if (!isInitialized) {
        return;
    }
    if (reason == InvalidateSizeReason.PAGE_ALIGN) {
        return;
    }
    final int height = getHeight();
    final int width = getWidth();
    final BookSettings bookSettings = SettingsManager.getBookSettings();
    final PageAlign pageAlign = DocumentViewMode.getPageAlign(bookSettings);
    if (changedPage == null) {
        float widthAccum = 0;
        for (final Page page : model.getPages()) {
            final RectF pageBounds = calcPageBounds(pageAlign, page.getAspectRatio(), width, height);
            pageBounds.offset(widthAccum, 0);
            page.setBounds(pageBounds);
            widthAccum += pageBounds.width() + 3;
        }
    } else {
        float widthAccum = changedPage.getBounds(1.0f).left;
        for (final Page page : model.getPages(changedPage.index.viewIndex)) {
            final RectF pageBounds = calcPageBounds(pageAlign, page.getAspectRatio(), width, height);
            pageBounds.offset(widthAccum, 0);
            page.setBounds(pageBounds);
            widthAccum += pageBounds.width() + 3;
        }
    }
}
Also used : PageAlign(org.ebookdroid.common.settings.types.PageAlign) RectF(android.graphics.RectF) BookSettings(org.ebookdroid.common.settings.books.BookSettings)

Example 10 with BookSettings

use of org.ebookdroid.common.settings.books.BookSettings in project LibreraReader by foobnix.

the class Page method getPageRegion.

public RectF getPageRegion(final RectF pageBounds, final RectF sourceRect) {
    final BookSettings bs = SettingsManager.getBookSettings();
    final RectF cb = nodes.root.croppedBounds;
    if (bs != null && bs.cropPages && cb != null) {
        final Matrix m = MatrixUtils.get();
        final RectF psb = nodes.root.pageSliceBounds;
        m.postTranslate(psb.left - cb.left, psb.top - cb.top);
        m.postScale(psb.width() / cb.width(), psb.height() / cb.height());
        m.mapRect(sourceRect);
    }
    if (type == PageType.LEFT_PAGE && sourceRect.left >= 0.5f) {
        return null;
    }
    if (type == PageType.RIGHT_PAGE && sourceRect.right < 0.5f) {
        return null;
    }
    return getTargetRect(type, pageBounds, sourceRect);
}
Also used : RectF(android.graphics.RectF) Matrix(android.graphics.Matrix) BookSettings(org.ebookdroid.common.settings.books.BookSettings)

Aggregations

BookSettings (org.ebookdroid.common.settings.books.BookSettings)15 RectF (android.graphics.RectF)3 PageIndex (org.ebookdroid.core.PageIndex)3 Matrix (android.graphics.Matrix)2 FileMeta (com.foobnix.dao2.FileMeta)2 PageAlign (org.ebookdroid.common.settings.types.PageAlign)2 SuppressLint (android.annotation.SuppressLint)1 Handler (android.os.Handler)1 RecyclerView (android.support.v7.widget.RecyclerView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 Button (android.widget.Button)1 CompoundButton (android.widget.CompoundButton)1 EditText (android.widget.EditText)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1