use of com.android.camera.ui.RotateLayout in project android_packages_apps_Snap by LineageOS.
the class CaptureUI method addFilterMode.
public void addFilterMode() {
if (mSettingsManager.getValue(SettingsManager.KEY_COLOR_EFFECT) == null)
return;
int rotation = CameraUtil.getDisplayRotation(mActivity);
boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
if (!mIsDefaultToPortrait) {
rotation = (rotation + 90) % 360;
}
WindowManager wm = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
CharSequence[] entries = mSettingsManager.getEntries(SettingsManager.KEY_COLOR_EFFECT);
Resources r = mActivity.getResources();
int height = (int) (r.getDimension(R.dimen.filter_mode_height) + 2 * r.getDimension(R.dimen.filter_mode_padding) + 1);
int width = (int) (r.getDimension(R.dimen.filter_mode_width) + 2 * r.getDimension(R.dimen.filter_mode_padding) + 1);
int gridRes;
boolean portrait = (rotation == 0) || (rotation == 180);
int size = height;
if (!portrait) {
gridRes = R.layout.vertical_grid;
size = width;
} else {
gridRes = R.layout.horiz_grid;
}
int[] thumbnails = mSettingsManager.getResource(SettingsManager.KEY_COLOR_EFFECT, SettingsManager.RESOURCE_TYPE_THUMBNAIL);
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
FrameLayout gridOuterLayout = (FrameLayout) inflater.inflate(gridRes, null, false);
gridOuterLayout.setBackgroundColor(android.R.color.transparent);
removeFilterMenu(false);
mFilterMenuStatus = FILTER_MENU_ON;
mFilterLayout = new LinearLayout(mActivity);
ViewGroup.LayoutParams params = null;
if (!portrait) {
params = new ViewGroup.LayoutParams(size, FrameLayout.LayoutParams.MATCH_PARENT);
mFilterLayout.setLayoutParams(params);
((ViewGroup) mRootView).addView(mFilterLayout);
} else {
params = new ViewGroup.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, size);
mFilterLayout.setLayoutParams(params);
((ViewGroup) mRootView).addView(mFilterLayout);
mFilterLayout.setY(display.getHeight() - 2 * size);
}
gridOuterLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
LinearLayout gridLayout = (LinearLayout) gridOuterLayout.findViewById(R.id.layout);
final View[] views = new View[entries.length];
int init = mSettingsManager.getValueIndex(SettingsManager.KEY_COLOR_EFFECT);
for (int i = 0; i < entries.length; i++) {
RotateLayout filterBox = (RotateLayout) inflater.inflate(R.layout.filter_mode_view, null, false);
ImageView imageView = (ImageView) filterBox.findViewById(R.id.image);
final int j = i;
filterBox.setOnTouchListener(new View.OnTouchListener() {
private long startTime;
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
startTime = System.currentTimeMillis();
} else if (event.getAction() == MotionEvent.ACTION_UP) {
if (System.currentTimeMillis() - startTime < CLICK_THRESHOLD) {
mSettingsManager.setValueIndex(SettingsManager.KEY_COLOR_EFFECT, j);
for (View v1 : views) {
v1.setActivated(v1 == v);
}
}
}
return true;
}
});
views[j] = imageView;
imageView.setActivated(i == init);
TextView label = (TextView) filterBox.findViewById(R.id.label);
imageView.setImageResource(thumbnails[i]);
label.setText(entries[i]);
gridLayout.addView(filterBox);
}
mFilterLayout.addView(gridOuterLayout);
}
use of com.android.camera.ui.RotateLayout in project android_packages_apps_Snap by LineageOS.
the class VideoUI method showPopup.
public void showPopup(ListView popup, int level, boolean animate) {
FrameLayout.LayoutParams layoutParams;
hideUI();
popup.setVisibility(View.VISIBLE);
if (level == 1) {
if (mMenuLayout == null) {
mMenuLayout = new RotateLayout(mActivity, null);
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
layoutParams = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
} else {
layoutParams = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
}
mMenuLayout.setLayoutParams(layoutParams);
((ViewGroup) mRootView).addView(mMenuLayout);
}
mMenuLayout.setOrientation(mOrientation, true);
mMenuLayout.addView(popup);
}
if (level == 2) {
if (mSubMenuLayout == null) {
mSubMenuLayout = new RotateLayout(mActivity, null);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT);
mSubMenuLayout.setLayoutParams(params);
((ViewGroup) mRootView).addView(mSubMenuLayout);
}
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
layoutParams = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
} else {
layoutParams = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
}
int screenHeight = (mOrientation == 0 || mOrientation == 180) ? mRootView.getHeight() : mRootView.getWidth();
int height = ((ListSubMenu) popup).getPreCalculatedHeight();
int yBase = ((ListSubMenu) popup).getYBase();
int y = Math.max(0, yBase);
if (yBase + height > screenHeight)
y = Math.max(0, screenHeight - height);
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
layoutParams.setMargins(CameraActivity.SETTING_LIST_WIDTH_1, y, 0, 0);
} else {
layoutParams.setMargins(0, y, CameraActivity.SETTING_LIST_WIDTH_1, 0);
}
mSubMenuLayout.setLayoutParams(layoutParams);
mSubMenuLayout.addView(popup);
mSubMenuLayout.setOrientation(mOrientation, true);
}
if (animate) {
if (level == 1)
mVideoMenu.animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true);
if (level == 2)
mVideoMenu.animateFadeIn(popup);
} else {
popup.setAlpha(1f);
}
}
use of com.android.camera.ui.RotateLayout in project android_packages_apps_Snap by LineageOS.
the class PhotoMenu method addSceneMode.
public void addSceneMode() {
final IconListPreference pref = (IconListPreference) mPreferenceGroup.findPreference(CameraSettings.KEY_SCENE_MODE);
if (pref == null)
return;
int rotation = CameraUtil.getDisplayRotation(mActivity);
boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
if (!mIsDefaultToPortrait) {
rotation = (rotation + 90) % 360;
}
WindowManager wm = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
CharSequence[] entries = pref.getEntries();
CharSequence[] entryValues = pref.getEntryValues();
int[] thumbnails = pref.getThumbnailIds();
Resources r = mActivity.getResources();
int height = (int) (r.getDimension(R.dimen.scene_mode_height) + 2 * r.getDimension(R.dimen.scene_mode_padding) + 1);
int width = (int) (r.getDimension(R.dimen.scene_mode_width) + 2 * r.getDimension(R.dimen.scene_mode_padding) + 1);
int gridRes = 0;
boolean portrait = (rotation == 0) || (rotation == 180);
int size = height;
if (portrait) {
gridRes = R.layout.vertical_grid;
size = width;
} else {
gridRes = R.layout.horiz_grid;
}
previewMenuSize = size;
mUI.hideUI();
mPreviewMenuStatus = PREVIEW_MENU_ON;
mSceneStatus = MODE_SCENE;
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
FrameLayout basic = (FrameLayout) inflater.inflate(gridRes, null, false);
mUI.dismissSceneModeMenu();
LinearLayout previewMenuLayout = new LinearLayout(mActivity);
mUI.setPreviewMenuLayout(previewMenuLayout);
ViewGroup.LayoutParams params = null;
if (portrait) {
params = new ViewGroup.LayoutParams(size, LayoutParams.MATCH_PARENT);
previewMenuLayout.setLayoutParams(params);
((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
} else {
params = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, size);
previewMenuLayout.setLayoutParams(params);
((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
previewMenuLayout.setY(display.getHeight() - size);
}
basic.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
LinearLayout layout = (LinearLayout) basic.findViewById(R.id.layout);
final View[] views = new View[entries.length];
int init = pref.getCurrentIndex();
for (int i = 0; i < entries.length; i++) {
RotateLayout layout2 = (RotateLayout) inflater.inflate(R.layout.scene_mode_view, null, false);
ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
TextView label = (TextView) layout2.findViewById(R.id.label);
final int j = i;
layout2.setOnTouchListener(new View.OnTouchListener() {
private long startTime;
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
startTime = System.currentTimeMillis();
} else if (event.getAction() == MotionEvent.ACTION_UP) {
if (System.currentTimeMillis() - startTime < CLICK_THRESHOLD) {
pref.setValueIndex(j);
onSettingChanged(pref);
updateSceneModeIcon(pref);
for (View v1 : views) {
v1.setActivated(v1 == v);
}
}
}
return true;
}
});
views[j] = layout2;
layout2.setActivated(i == init);
imageView.setImageResource(thumbnails[i]);
label.setText(entries[i]);
layout.addView(layout2);
// ASD only available when developer options are enabled.
if (entryValues[i].equals("asd")) {
layout2.setVisibility(mActivity.isDeveloperMenuEnabled() ? View.VISIBLE : View.GONE);
} else if (entryValues[i].equals("hdr")) {
ListPreference autoHdrPref = mPreferenceGroup.findPreference(CameraSettings.KEY_AUTO_HDR);
if (autoHdrPref != null && autoHdrPref.getValue().equalsIgnoreCase("enable")) {
layout2.setVisibility(View.GONE);
}
} else if (CameraApp.mIsLowMemoryDevice && (entryValues[i].equals(mActivity.getResources().getString(R.string.pref_camera_advanced_feature_value_refocus_on)) || entryValues[i].equals(mActivity.getResources().getString(R.string.pref_camera_advanced_feature_value_optizoom_on)))) {
layout2.setVisibility(View.GONE);
}
}
previewMenuLayout.addView(basic);
mPreviewMenu = basic;
}
use of com.android.camera.ui.RotateLayout in project android_packages_apps_Snap by LineageOS.
the class TsMakeupManager method showMakeupView.
public void showMakeupView() {
mMakeupUIStatus = MAKEUP_UI_STATUS_OFF;
mMakeupLayoutRoot.setVisibility(View.GONE);
mMakeupLayoutRoot.removeAllViews();
if (mMakeupSingleRoot != null) {
mMakeupSingleRoot.removeAllViews();
mMakeupSingleRoot = null;
}
if (mMakeupLevelRoot != null) {
mMakeupLevelRoot.removeAllViews();
mMakeupLevelRoot = null;
}
if (mMakeupSingleRoot != null && mMakeupSingleRoot.getVisibility() == View.VISIBLE) {
showSingleView(MAKEUP_NONE);
return;
}
if (mMakeupUIStatus == MAKEUP_UI_STATUS_DISMISS)
return;
mMakeupLayoutRoot.setVisibility(View.VISIBLE);
final IconListPreference pref = (IconListPreference) mPreferenceGroup.findPreference(CameraSettings.KEY_TS_MAKEUP_LEVEL);
if (pref == null)
return;
if (mMakeupLevelRoot != null) {
mMakeupLevelRoot.removeAllViews();
mMakeupLevelRoot = null;
}
mMakeupLayoutRoot.removeAllViews();
mMakeupUIStatus = MAKEUP_UI_STATUS_ON;
int rotation = CameraUtil.getDisplayRotation(mActivity);
boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
if (!mIsDefaultToPortrait) {
rotation = (rotation + 90) % 360;
}
CharSequence[] entries = pref.getEntries();
int[] thumbnails = pref.getThumbnailIds();
WindowManager wm = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Resources r = mActivity.getResources();
int margin = (int) (r.getDimension(R.dimen.tsmakeup_mode_paddingBottom));
int levelBgSize = (int) (r.getDimension(R.dimen.tsmakeup_mode_level_size));
Log.d(TAG, "TsMakeupManager.showMakeupView(): rotation is " + rotation + ", WH is (" + width + ", " + height + "), margin is " + margin + ", levelBgSize is " + levelBgSize);
int gridRes = 0;
boolean portrait = (rotation == 0) || (rotation == 180);
int size = height;
if (portrait) {
gridRes = R.layout.ts_makeup_level_view_port;
size = width;
} else {
gridRes = R.layout.ts_makeup_level_view_land;
size = height;
}
int itemWidth = size / entries.length;
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout layout = (LinearLayout) inflater.inflate(gridRes, null, false);
mMakeupLevelRoot = layout;
mUI.setMakeupMenuLayout(layout);
LinearLayout.LayoutParams params = null;
if (portrait) {
params = new LayoutParams(itemWidth, itemWidth);
params.gravity = Gravity.CENTER_VERTICAL;
} else {
params = new LayoutParams(itemWidth, itemWidth);
params.gravity = Gravity.CENTER_HORIZONTAL;
}
RelativeLayout.LayoutParams rootParams = null;
if (rotation == 0) {
rootParams = new RelativeLayout.LayoutParams(size, levelBgSize);
// rootParams.bottomMargin = margin;
rootParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
} else if (rotation == 90) {
rootParams = new RelativeLayout.LayoutParams(levelBgSize, size);
// rootParams.rightMargin = margin;
rootParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
} else if (rotation == 180) {
rootParams = new RelativeLayout.LayoutParams(size, levelBgSize);
// rootParams.topMargin = margin;
rootParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
} else if (rotation == 270) {
rootParams = new RelativeLayout.LayoutParams(levelBgSize, size);
// rootParams.leftMargin = margin;
rootParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
}
final View[] views = new View[entries.length];
int init = pref.getCurrentIndex();
for (int i = 0; i < entries.length; i++) {
RotateLayout layout2 = (RotateLayout) inflater.inflate(R.layout.ts_makeup_item_view, null, false);
ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
TextView label = (TextView) layout2.findViewById(R.id.label);
final int j = i;
layout2.setOnTouchListener(new View.OnTouchListener() {
private long startTime;
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
startTime = System.currentTimeMillis();
} else if (event.getAction() == MotionEvent.ACTION_UP) {
if (System.currentTimeMillis() - startTime < CLICK_THRESHOLD) {
pref.setValueIndex(j);
changeMakeupIcon(pref.getValue());
mMakeupLevelListener.onMakeupLevel(pref.getKey(), pref.getValue());
for (View v1 : views) {
v1.setSelected(false);
}
View border = v.findViewById(R.id.image);
border.setSelected(true);
showSingleView(pref.getValue());
mUI.adjustOrientation();
if (!pref.getValue().equalsIgnoreCase("off")) {
String toast = mActivity.getString(R.string.text_tsmakeup_beautify_toast);
RotateTextToast.makeText(mActivity, toast, Toast.LENGTH_SHORT).show();
}
}
}
return true;
}
});
View border = layout2.findViewById(R.id.image);
views[j] = border;
if (i == init) {
border.setSelected(true);
}
imageView.setImageResource(thumbnails[i]);
label.setText(entries[i]);
layout.addView(layout2, params);
}
mMakeupLayoutRoot.addView(layout, rootParams);
}
use of com.android.camera.ui.RotateLayout in project android_packages_apps_Snap by LineageOS.
the class PhotoUI method showPopup.
public void showPopup(ListView popup, int level, boolean animate) {
FrameLayout.LayoutParams params;
hideUI();
popup.setVisibility(View.VISIBLE);
if (level == 1) {
if (mMenuLayout == null) {
mMenuLayout = new RotateLayout(mActivity, null);
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
} else {
params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
}
mMenuLayout.setLayoutParams(params);
((ViewGroup) mRootView).addView(mMenuLayout);
}
mMenuLayout.setOrientation(mOrientation, true);
mMenuLayout.addView(popup);
}
if (level == 2) {
if (mSubMenuLayout == null) {
mSubMenuLayout = new RotateLayout(mActivity, null);
((ViewGroup) mRootView).addView(mSubMenuLayout);
}
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
} else {
params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
}
int screenHeight = (mOrientation == 0 || mOrientation == 180) ? mRootView.getHeight() : mRootView.getWidth();
int height = ((ListSubMenu) popup).getPreCalculatedHeight();
int yBase = ((ListSubMenu) popup).getYBase();
int y = Math.max(0, yBase);
if (yBase + height > screenHeight)
y = Math.max(0, screenHeight - height);
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
params.setMargins(CameraActivity.SETTING_LIST_WIDTH_1, y, 0, 0);
} else {
params.setMargins(0, y, CameraActivity.SETTING_LIST_WIDTH_1, 0);
}
mSubMenuLayout.setLayoutParams(params);
mSubMenuLayout.addView(popup);
mSubMenuLayout.setOrientation(mOrientation, true);
}
if (animate) {
if (level == 1)
mMenu.animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true);
if (level == 2)
mMenu.animateFadeIn(popup);
} else {
popup.setAlpha(1f);
}
}
Aggregations