use of com.android.gallery3d.filtershow.category.MainPanel in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method showRepresentation.
public void showRepresentation(FilterRepresentation representation) {
if (representation == null) {
return;
}
Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
if (currentPanel instanceof MainPanel && ((MainPanel) currentPanel).hasEditorPanel()) {
if (representation.equals(MasterImage.getImage().getCurrentFilterRepresentation())) {
return;
}
// cancel previous filter.
cancelCurrentFilter();
showDefaultImageView();
removeSeekBarPanel();
}
if (representation instanceof FilterRotateRepresentation) {
FilterRotateRepresentation r = (FilterRotateRepresentation) representation;
r.rotateCW();
}
if (representation instanceof FilterMirrorRepresentation) {
FilterMirrorRepresentation r = (FilterMirrorRepresentation) representation;
r.cycle();
}
if (representation.isBooleanFilter()) {
ImagePreset preset = MasterImage.getImage().getPreset();
if (preset.getRepresentation(representation) != null) {
// remove
ImagePreset copy = new ImagePreset(preset);
copy.removeFilter(representation);
FilterRepresentation filterRepresentation = representation.copy();
MasterImage.getImage().setPreset(copy, filterRepresentation, true);
MasterImage.getImage().setCurrentFilterRepresentation(null);
setActionBar();
showActionBar(true);
return;
}
}
if (representation.getFilterType() == FilterRepresentation.TYPE_DUALCAM) {
DisplayMetrics dm = getResources().getDisplayMetrics();
float[] mTmpPoint = new float[2];
mTmpPoint[0] = dm.widthPixels / 2;
mTmpPoint[1] = dm.heightPixels / 2;
Matrix m = MasterImage.getImage().getScreenToImageMatrix(true);
m.mapPoints(mTmpPoint);
if (representation instanceof FilterDualCamBasicRepresentation) {
((FilterDualCamBasicRepresentation) representation).setPoint((int) mTmpPoint[0], (int) mTmpPoint[1]);
}
if (representation instanceof FilterDualCamFusionRepresentation) {
((FilterDualCamFusionRepresentation) representation).setPoint((int) mTmpPoint[0], (int) mTmpPoint[1]);
}
}
if (representation.getFilterType() == FilterRepresentation.TYPE_WATERMARK) {
if (MasterImage.getImage().getCurrentFilterRepresentation() != null && representation.getSerializationName().equals(MasterImage.getImage().getCurrentFilterRepresentation().getSerializationName())) {
return;
}
showWaterMark(representation);
}
if (TrueScannerActs.SERIALIZATION_NAME.equals(representation.getSerializationName())) {
Bitmap b = MasterImage.getImage().getOriginalBitmapHighres();
int w = b.getWidth();
int h = b.getHeight();
if (w < h) {
w = h;
h = b.getWidth();
}
if (w <= TrueScannerActs.MIN_WIDTH || h <= TrueScannerActs.MIN_HEIGHT) {
Toast.makeText(this, getString(R.string.image_size_too_small), Toast.LENGTH_SHORT).show();
return;
}
}
useFilterRepresentation(representation);
loadEditorPanel(representation);
}
use of com.android.gallery3d.filtershow.category.MainPanel in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method onBackPressed.
@Override
public void onBackPressed() {
showComparisonButton();
Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
if (currentPanel instanceof MainPanel) {
if (mImageShow.hasModifications()) {
if (mBackAlertDialogBuilder == null) {
createBackDialog();
}
mBackAlertDialogBuilder.show();
} else {
done();
}
setActionBar();
invalidateOptionsMenu();
if (MasterImage.getImage().getScaleFactor() < 1)
setScaleImage(false);
adjustCompareButton(false);
} else {
isComingFromEditorScreen = true;
backToMain();
}
}
use of com.android.gallery3d.filtershow.category.MainPanel in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method removeSeekBarPanel.
private void removeSeekBarPanel() {
Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
if (currentPanel instanceof MainPanel) {
((MainPanel) currentPanel).removeEditorPanelFragment();
if (mCurrentEditor != null) {
mCurrentEditor.detach();
}
mCurrentEditor = null;
}
}
use of com.android.gallery3d.filtershow.category.MainPanel in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method backToMain.
public void backToMain() {
removeSeekBarPanel();
showActionBar(true);
Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
if (currentPanel instanceof MainPanel) {
return;
}
mIsReloadByConfigurationChanged = false;
loadMainPanel();
showDefaultImageView();
showComparisonButton();
}
use of com.android.gallery3d.filtershow.category.MainPanel in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method loadEditorPanel.
public void loadEditorPanel(final FilterRepresentation representation) {
final int currentId = representation.getEditorId();
// show representation
if (mCurrentEditor != null) {
mCurrentEditor.detach();
}
mCurrentEditor = mEditorPlaceHolder.showEditor(currentId);
if (mCurrentEditor.showsActionBar()) {
setActionBar();
showActionBar(true);
} else {
// showActionBar(false);
}
if (representation.getFilterType() == FilterRepresentation.TYPE_WATERMARK_CATEGORY) {
loadWaterMarkPanel((FilterWatermarkRepresentation) representation);
return;
}
if (currentId == ImageOnlyEditor.ID) {
mCurrentEditor.reflectCurrentFilter();
return;
}
if (currentId == EditorTruePortraitImageOnly.ID) {
mCurrentEditor.reflectCurrentFilter();
setActionBarForEffects(mCurrentEditor);
return;
}
if (currentId == EditorCrop.ID) {
loadEditorCropPanel();
return;
}
if (useStraightenPanel(currentId)) {
new Runnable() {
@Override
public void run() {
StraightenPanel panel = new StraightenPanel();
Bundle bundle = new Bundle();
bundle.putInt(StraightenPanel.EDITOR_ID, currentId);
bundle.putString(StraightenPanel.EDITOR_NAME, representation.getName());
panel.setArguments(bundle);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
transaction.commit();
}
}.run();
return;
}
if (currentId == TrueScannerEditor.ID) {
new Runnable() {
@Override
public void run() {
TrueScannerPanel panel = new TrueScannerPanel();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
transaction.commit();
}
}.run();
return;
}
if (currentId == EditorTruePortraitMask.ID) {
new Runnable() {
@Override
public void run() {
setActionBarForEffects(mCurrentEditor);
TruePortraitMaskEditorPanel panel = new TruePortraitMaskEditorPanel();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
transaction.commit();
}
}.run();
return;
}
Runnable showEditor = new Runnable() {
@Override
public void run() {
EditorPanel panel = new EditorPanel();
panel.setEditor(currentId);
setActionBarForEffects(mCurrentEditor);
Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
if (main instanceof MainPanel) {
((MainPanel) main).setEditorPanelFragment(panel);
}
}
};
Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
boolean doAnimation = false;
if (mShowingImageStatePanel && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
doAnimation = true;
}
if (doAnimation && main != null && main instanceof MainPanel) {
MainPanel mainPanel = (MainPanel) main;
View container = mainPanel.getView().findViewById(R.id.category_panel_container);
View bottom = mainPanel.getView().findViewById(R.id.bottom_panel);
int panelHeight = container.getHeight() + bottom.getHeight();
ViewPropertyAnimator anim = mainPanel.getView().animate();
anim.translationY(panelHeight).start();
final Handler handler = new Handler();
handler.postDelayed(showEditor, anim.getDuration());
} else {
showEditor.run();
}
}
Aggregations