/** * {@inheritDoc} * * @see org.emdev.ui.AbstractActivityController#beforeRecreate(android.app.Activity) */ @Override public void beforeRecreate(final ViewerActivity activity) { final AppSettings newSettings = AppSettings.current(); activity.setRequestedOrientation(newSettings.rotation.getOrientation()); IUIManager.instance.setTitleVisible(activity, newSettings.showTitle, true); TouchManager.loadFromSettings(newSettings); KeyBindingsManager.loadFromSettings(newSettings); }
/** Instantiates a new base viewer activity. */ public ViewerActivityController(final ViewerActivity activity) { super(activity, BEFORE_CREATE, BEFORE_RECREATE, AFTER_CREATE, ON_POST_CREATE, ON_DESTROY); intent = activity.getIntent(); history = new NavigationHistory(this); executor = new AsyncTaskExecutor(256, 1, 5, 1, "BookExecutor-" + id); SettingsManager.addListener(this); }
/** * {@inheritDoc} * * @see * org.ebookdroid.common.settings.listeners.IAppSettingsChangeListener#onAppSettingsChanged(org.ebookdroid.common.settings.AppSettings, * org.ebookdroid.common.settings.AppSettings, * org.ebookdroid.common.settings.AppSettings.Diff) */ @Override public void onAppSettingsChanged( final AppSettings oldSettings, final AppSettings newSettings, final AppSettings.Diff diff) { final ViewerActivity activity = getManagedComponent(); if (diff.isRotationChanged()) { if (bookSettings != null) { activity.setRequestedOrientation(bookSettings.getOrientation(newSettings)); } else { activity.setRequestedOrientation(newSettings.rotation.getOrientation()); } } if (diff.isFullScreenChanged()) { IUIManager.instance.setFullScreenMode( activity, activity.view.getView(), newSettings.fullScreen); } if (!diff.isFirstTime() && diff.isShowTitleChanged()) { IUIManager.instance.setTitleVisible(activity, newSettings.showTitle, false); } if (diff.isKeepScreenOnChanged()) { activity.view.getView().setKeepScreenOn(newSettings.keepScreenOn); } if (diff.isTapConfigChanged()) { TouchManager.loadFromSettings(newSettings); } if (diff.isKeyBindingChanged()) { KeyBindingsManager.loadFromSettings(newSettings); } if (diff.isPagesInMemoryChanged()) { getDocumentController().updateMemorySettings(); } IUIManager.instance.invalidateOptionsMenu(getManagedComponent()); }
/** * {@inheritDoc} * * @see org.emdev.ui.AbstractActivityController#afterCreate(android.app.Activity, boolean) */ @Override public void afterCreate(final ViewerActivity activity, final boolean recreated) { final AppSettings appSettings = AppSettings.current(); IUIManager.instance.setFullScreenMode( activity, getManagedComponent().view.getView(), appSettings.fullScreen); createAction(R.id.mainmenu_crop) .putValue("view", activity.getManualCropControls()) .putValue("mode", DocumentViewMode.SINGLE_PAGE); createAction(R.id.mainmenu_zoom).putValue("view", activity.getZoomControls()); createAction(R.id.mainmenu_search).putValue("view", activity.getSearchControls()); createAction(R.id.actions_toggleTouchManagerView).putValue("view", activity.getTouchView()); createAction(R.id.mainmenu_force_portrait).putValue("mode", BookRotationType.PORTRAIT); createAction(R.id.mainmenu_force_landscape).putValue("mode", BookRotationType.LANDSCAPE); if (recreated) { return; } documentModel = ActivityControllerStub.DM_STUB; searchModel = new SearchModel(this); if (intent == null) { showErrorDlg(R.string.msg_bad_intent, intent); return; } final Uri data = intent.getData(); if (data == null) { showErrorDlg(R.string.msg_no_intent_data, intent); return; } scheme = ContentScheme.getScheme(intent); if (scheme == ContentScheme.UNKNOWN) { showErrorDlg(R.string.msg_bad_intent, intent); return; } bookTitle = scheme.getResourceName(activity.getContentResolver(), data); codecType = CodecType.getByUri(bookTitle); if (codecType == null) { bookTitle = ContentScheme.getDefaultResourceName(data, ""); codecType = CodecType.getByUri(bookTitle); } if (codecType == null) { final String type = intent.getType(); LCTX.i("Book mime type: " + type); if (LengthUtils.isNotEmpty(type)) { codecType = CodecType.getByMimeType(type); } } LCTX.i("Book codec type: " + codecType); LCTX.i("Book title: " + bookTitle); if (codecType == null) { showErrorDlg(R.string.msg_unknown_intent_data_type, data); return; } documentModel = new DocumentModel(codecType); documentModel.addListener(ViewerActivityController.this); progressModel = new DecodingProgressModel(); progressModel.addListener(ViewerActivityController.this); final Uri uri = data; if (scheme.temporary) { m_fileName = scheme.key; CacheManager.clear(scheme.key); } else { m_fileName = PathFromUri.retrieve(activity.getContentResolver(), uri); } bookSettings = SettingsManager.create(id, m_fileName, scheme.temporary, intent); SettingsManager.applyBookSettingsChanges(null, bookSettings); }