use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.
the class SmartBarEditor method findInterceptingView.
/**
* Find intersecting view in mButtonViews
*
* @param pos - pointer location
* @param v - view being dragged
* @return intersecting view or null
*/
private View findInterceptingView(float pos, View v) {
for (String buttonTag : mHost.getCurrentSequence()) {
SmartButtonView otherButton = mHost.findCurrentButton(buttonTag);
OpaLayout otherOpa = (OpaLayout) otherButton.getParent();
if (otherOpa == v) {
continue;
}
if (mSquatters.contains(otherOpa)) {
continue;
}
otherOpa.getLocationOnScreen(sLocation);
float otherPos = sLocation[mHost.isVertical() ? 1 : 0];
float otherDimension = mHost.isVertical() ? v.getHeight() : v.getWidth();
if (pos > (otherPos + otherDimension / 4) && pos < (otherPos + otherDimension)) {
mSquatters.add(otherOpa);
return otherOpa;
}
}
return null;
}
use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.
the class SmartBarEditor method switchId.
/**
* Switches positions of two views and updates their mButtonViews entry
*
* @param targetView - view to be replaced animate out
* @param view - view being dragged
*/
private void switchId(View replaceView, View dragView) {
final OpaLayout squatter = (OpaLayout) replaceView;
final OpaLayout dragger = (OpaLayout) dragView;
final boolean vertical = mHost.isVertical();
ViewGroup parent = (ViewGroup) replaceView.getParent();
float slideTo = vertical ? mDragOrigin - parent.getTop() : mDragOrigin - parent.getLeft();
replaceView.getLocationOnScreen(sLocation);
mDragOrigin = sLocation[vertical ? 1 : 0];
final int targetIndex = mHost.getCurrentSequence().indexOf(squatter.getButton().getTag());
final int draggedIndex = mHost.getCurrentSequence().indexOf(dragger.getButton().getTag());
Collections.swap(mHost.getCurrentSequence(), draggedIndex, targetIndex);
SmartButtonView hidden1 = (SmartButtonView) getHiddenNavButtons().findViewWithTag(squatter.getButton().getTag());
SmartButtonView hidden2 = (SmartButtonView) getHiddenNavButtons().findViewWithTag(dragger.getButton().getTag());
OpaLayout hidden1Opa = (OpaLayout) hidden1.getParent();
OpaLayout hidden2Opa = (OpaLayout) hidden2.getParent();
swapConfigs(hidden1Opa, hidden2Opa);
Animator anim = getButtonSlideAnimator(squatter, vertical, slideTo);
anim.setInterpolator(new OvershootInterpolator());
anim.setDuration(250);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mSquatters.remove(squatter);
}
});
anim.start();
}
use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.
the class SmartBarEditor method onIconPicked.
@Override
protected void onIconPicked(String type, String packageName, String iconName) {
final String buttonFocus = getEditButtonTag();
SmartButtonView currentButton = mHost.findCurrentButton(buttonFocus);
SmartButtonView otherButton = (SmartButtonView) getHiddenNavButtons().findViewWithTag(buttonFocus);
ButtonConfig currentConfig = currentButton.getButtonConfig();
ButtonConfig otherConfig = otherButton.getButtonConfig();
OpaLayout currentOpa = (OpaLayout) currentButton.getParent();
OpaLayout otherOpa = (OpaLayout) otherButton.getParent();
currentConfig.setCustomIconUri(type, packageName, iconName);
otherConfig.setCustomIconUri(type, packageName, iconName);
currentButton.setButtonConfig(currentConfig);
otherButton.setButtonConfig(otherConfig);
mHost.setButtonDrawable(currentButton);
SmartBarHelper.updateButtonScalingAndPadding(currentOpa, isLandscape());
mHost.setButtonDrawable(otherButton);
SmartBarHelper.updateButtonScalingAndPadding(otherOpa, !isLandscape());
onCommitChanges();
}
use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.
the class SmartBarEditor method onCommitChanges.
@Override
public void onCommitChanges() {
ArrayList<ButtonConfig> buttonConfigs = new ArrayList<ButtonConfig>();
final int size = mHost.getCurrentSequence().size();
for (int i = 0; i < size; i++) {
String tag = mHost.getCurrentSequence().get(i);
SmartButtonView v = mHost.findCurrentButton(tag);
if (v == null)
continue;
ButtonConfig config = v.getButtonConfig();
if (config == null)
continue;
buttonConfigs.add(config);
}
Config.setConfig(mContext, ActionConstants.getDefaults(ActionConstants.SMARTBAR), buttonConfigs);
}
use of com.android.systemui.navigation.smartbar.SmartButtonView in project android_packages_apps_DUI by DirtyUnicorns.
the class SmartBarView method setDisabledFlags.
@Override
public void setDisabledFlags(int disabledFlags, boolean force) {
super.setDisabledFlags(disabledFlags, force);
if (mEditor != null) {
mEditor.changeEditMode(BaseEditor.MODE_OFF);
}
final boolean disableHome = ((disabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);
final boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0) && ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0);
OpaLayout opaBack = (OpaLayout) getBackButton().getParent();
opaBack.setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
OpaLayout opaHome = (OpaLayout) getHomeButton().getParent();
opaHome.setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);
// to disable custom buttons as well
for (String buttonTag : mCurrentSequence) {
SmartButtonView v = findCurrentButton(buttonTag);
OpaLayout opa = (OpaLayout) v.getParent();
if (v != null && v != getBackButton() && v != getHomeButton()) {
if (disableHome || disableBack || disableRecent) {
opa.setVisibility(View.INVISIBLE);
} else {
opa.setVisibility(View.VISIBLE);
}
}
}
}
Aggregations