android.util.MutableBoolean Java Examples

The following examples show how to use android.util.MutableBoolean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: input-samples   Author: android   File: DatasetAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void parseAutofillFields(AssistStructure.ViewNode viewNode,
        HashMap<String, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
        Map<String, FilledAutofillField> filledAutofillFieldsByTypeName,
        Dataset.Builder builder, MutableBoolean setValueAtLeastOnce) {
    String[] rawHints = viewNode.getAutofillHints();
    if (rawHints == null || rawHints.length == 0) {
        logv("No af hints at ViewNode - %s", viewNode.getIdEntry());
        return;
    }
    String fieldTypeName = AutofillHints.getFieldTypeNameFromAutofillHints(
            fieldTypesByAutofillHint, Arrays.asList(rawHints));
    if (fieldTypeName == null) {
        return;
    }
    FilledAutofillField field = filledAutofillFieldsByTypeName.get(fieldTypeName);
    if (field == null) {
        return;
    }
    bindValueToNode(viewNode, field, builder, setValueAtLeastOnce);
}
 
Example #2
Source Project: android_9.0.0_r45   Author: lulululbj   File: TunerSession.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean isConfigFlagSet(int flag) {
    Slog.v(TAG, "isConfigFlagSet " + ConfigFlag.toString(flag));
    synchronized (mLock) {
        checkNotClosedLocked();

        MutableInt halResult = new MutableInt(Result.UNKNOWN_ERROR);
        MutableBoolean flagState = new MutableBoolean(false);
        try {
            mHwSession.isConfigFlagSet(flag, (int result, boolean value) -> {
                halResult.value = result;
                flagState.value = value;
            });
        } catch (RemoteException ex) {
            throw new RuntimeException("Failed to check flag " + ConfigFlag.toString(flag), ex);
        }
        Convert.throwOnError("isConfigFlagSet", halResult.value);

        return flagState.value;
    }
}
 
Example #3
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: ScrollingHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static PointF nextScrollingLocation(OBControl con, MutableBoolean finished)
{
    Object data = con.propertyValue("scrolling_data");
    if(data == null)
    {
        finished.value = true;
        return OBMisc.copyPoint(con.position());
    }
    Map<String,Object> scrollingData = (ArrayMap<String,Object>)data;

    long currentTime = SystemClock.uptimeMillis();
    long lastTime = (long)scrollingData.get("last_action");
    float tick = (float)scrollingData.get("tick") ;
    scrollingData.put("last_action",currentTime);
    return nextScrollingLocationByFrac(con, (currentTime-lastTime)*1.0f/(1000.0f*tick), finished);
}
 
Example #4
Source Project: android-AutofillFramework   Author: googlearchive   File: DatasetAdapter.java    License: Apache License 2.0 6 votes vote down vote up
private void parseAutofillFields(AssistStructure.ViewNode viewNode,
        HashMap<String, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
        Map<String, FilledAutofillField> filledAutofillFieldsByTypeName,
        Dataset.Builder builder, MutableBoolean setValueAtLeastOnce) {
    String[] rawHints = viewNode.getAutofillHints();
    if (rawHints == null || rawHints.length == 0) {
        logv("No af hints at ViewNode - %s", viewNode.getIdEntry());
        return;
    }
    String fieldTypeName = AutofillHints.getFieldTypeNameFromAutofillHints(
            fieldTypesByAutofillHint, Arrays.asList(rawHints));
    if (fieldTypeName == null) {
        return;
    }
    FilledAutofillField field = filledAutofillFieldsByTypeName.get(fieldTypeName);
    if (field == null) {
        return;
    }
    bindValueToNode(viewNode, field, builder, setValueAtLeastOnce);
}
 
Example #5
Source Project: input-samples   Author: android   File: DatasetAdapter.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Build an autofill {@link Dataset} using saved data and the client's AssistStructure.
 */
private boolean bindDataset(HashMap<String, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
        DatasetWithFilledAutofillFields datasetWithFilledAutofillFields,
        Dataset.Builder datasetBuilder) {
    MutableBoolean setValueAtLeastOnce = new MutableBoolean(false);
    Map<String, FilledAutofillField> filledAutofillFieldsByTypeName =
            datasetWithFilledAutofillFields.filledAutofillFields.stream()
                    .collect(toMap(FilledAutofillField::getFieldTypeName, Function.identity()));
    mClientParser.parse((node) ->
            parseAutofillFields(node, fieldTypesByAutofillHint, filledAutofillFieldsByTypeName,
                    datasetBuilder, setValueAtLeastOnce)
    );
    return setValueAtLeastOnce.value;
}
 
Example #6
Source Project: input-samples   Author: android   File: DatasetAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private boolean bindDatasetToFocusedNode(FilledAutofillField field,
        FieldType fieldType, Dataset.Builder builder) {
    MutableBoolean setValueAtLeastOnce = new MutableBoolean(false);
    mClientParser.parse((node) -> {
        if (node.isFocused() && node.getAutofillId() != null) {
            bindValueToNode(node, field, builder, setValueAtLeastOnce);
        }
    });
    return setValueAtLeastOnce.value;
}
 
Example #7
Source Project: android_9.0.0_r45   Author: lulululbj   File: GestureLauncherService.java    License: Apache License 2.0 5 votes vote down vote up
public boolean interceptPowerKeyDown(KeyEvent event, boolean interactive,
        MutableBoolean outLaunched) {
    boolean launched = false;
    boolean intercept = false;
    long powerTapInterval;
    synchronized (this) {
        powerTapInterval = event.getEventTime() - mLastPowerDown;
        if (mCameraDoubleTapPowerEnabled
                && powerTapInterval < CAMERA_POWER_DOUBLE_TAP_MAX_TIME_MS) {
            launched = true;
            intercept = interactive;
            mPowerButtonConsecutiveTaps++;
        } else if (powerTapInterval < POWER_SHORT_TAP_SEQUENCE_MAX_INTERVAL_MS) {
            mPowerButtonConsecutiveTaps++;
        } else {
            mPowerButtonConsecutiveTaps = 1;
        }
        mLastPowerDown = event.getEventTime();
    }
    if (DBG && mPowerButtonConsecutiveTaps > 1) {
        Slog.i(TAG, Long.valueOf(mPowerButtonConsecutiveTaps) +
                " consecutive power button taps detected");
    }
    if (launched) {
        Slog.i(TAG, "Power button double tap gesture detected, launching camera. Interval="
                + powerTapInterval + "ms");
        launched = handleCameraGesture(false /* useWakelock */,
                StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP);
        if (launched) {
            mMetricsLogger.action(MetricsEvent.ACTION_DOUBLE_TAP_POWER_CAMERA_GESTURE,
                    (int) powerTapInterval);
        }
    }
    mMetricsLogger.histogram("power_consecutive_short_tap_count", mPowerButtonConsecutiveTaps);
    mMetricsLogger.histogram("power_double_tap_interval", (int) powerTapInterval);
    outLaunched.value = launched;
    return intercept && launched;
}
 
Example #8
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: ScrollingHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static PointF nextScrollingLocationByFrac(OBControl con, float frac, MutableBoolean finished)
{
    PointF loc = OBMisc.copyPoint(con.position());
    Object data = con.propertyValue("scrolling_data");
    if(data == null)
    {
        finished.value = true;
        return loc;
    }
    Map<String,Object> scrollingData = (ArrayMap<String,Object>)data;
    float speedX = (float)scrollingData.get("speed_x");
    float speedY = (float)scrollingData.get("speed_y");
    float minSpeedX = (float)scrollingData.get("min_speed_x");
    float minSpeedY = (float)scrollingData.get("min_speed_y");
    if(speedX == 0 && speedY == 0)
    {
        finished.value = true;
        return loc;
    }
    loc.x += speedX * frac;
    loc.y += speedY * frac;
    double decay = (double)scrollingData.get("decay");
    double decayFrac = Math.pow(decay,frac);
    speedX *= decayFrac;
    speedY *= decayFrac;
    if(minSpeedX >= Math.abs(speedX))
        speedX = 0;
    if(minSpeedY >= Math.abs(speedY))
        speedY = 0;
    scrollingData.put("speed_x", speedX);
    scrollingData.put("speed_y", speedY);
    finished.value = speedX == 0 && speedY == 0;
    return loc;
}
 
Example #9
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: OC_Library.java    License: Apache License 2.0 5 votes vote down vote up
public void checkGroupIcon(PointF pt, final OBGroup curGroup, final OBControl curIcon) throws Exception
{
    long currTime = SystemClock.currentThreadTimeMillis();
    PointF lastPosition = (PointF) curGroup.propertyValue("touch_loc");
    if (curIcon != null && (currTime - (long) curGroup.propertyValue("time")) < 1
            && Math.abs(lastPosition.x - pt.x) < snapDist && pointTouchAccepted(pt)
            && pointTouchAccepted(lastPosition))
    {
        curIcon.highlight();
        openBookForIcon(curIcon);
        OBUtils.runOnOtherThreadDelayed(1, new OBUtils.RunLambda()
        {
            public void run() throws Exception
            {
                curIcon.lowlight();
            }
        });
    }
    long time = setStatus(STATUS_WAITING_FOR_DRAG);
    if (!curGroup.isEnabled())
        return;
    curGroup.setProperty("time", time);
    MutableBoolean finished = new MutableBoolean(false);
    while (!this._aborting && !finished.value && time == (long)curGroup.propertyValue("time"))
    {
        if (time == (long)curGroup.propertyValue("time"))
        {
            PointF pos = ScrollingHelper.nextScrollingLocation(curGroup, finished);
            if (!setBookLine(curGroup, pos.x))
                finished.value = true;

        }
        waitForSecs(0.001f);
    }
    if (!this._aborting)
        snapClosest(time, curGroup, false);
}
 
Example #10
Source Project: android-AutofillFramework   Author: googlearchive   File: DatasetAdapter.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Build an autofill {@link Dataset} using saved data and the client's AssistStructure.
 */
private boolean bindDataset(HashMap<String, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
        DatasetWithFilledAutofillFields datasetWithFilledAutofillFields,
        Dataset.Builder datasetBuilder) {
    MutableBoolean setValueAtLeastOnce = new MutableBoolean(false);
    Map<String, FilledAutofillField> filledAutofillFieldsByTypeName =
            datasetWithFilledAutofillFields.filledAutofillFields.stream()
                    .collect(toMap(FilledAutofillField::getFieldTypeName, Function.identity()));
    mClientParser.parse((node) ->
            parseAutofillFields(node, fieldTypesByAutofillHint, filledAutofillFieldsByTypeName,
                    datasetBuilder, setValueAtLeastOnce)
    );
    return setValueAtLeastOnce.value;
}
 
Example #11
Source Project: android-AutofillFramework   Author: googlearchive   File: DatasetAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private boolean bindDatasetToFocusedNode(FilledAutofillField field,
        FieldType fieldType, Dataset.Builder builder) {
    MutableBoolean setValueAtLeastOnce = new MutableBoolean(false);
    mClientParser.parse((node) -> {
        if (node.isFocused() && node.getAutofillId() != null) {
            bindValueToNode(node, field, builder, setValueAtLeastOnce);
        }
    });
    return setValueAtLeastOnce.value;
}
 
Example #12
Source Project: input-samples   Author: android   File: DatasetAdapter.java    License: Apache License 2.0 4 votes vote down vote up
void bindValueToNode(AssistStructure.ViewNode viewNode,
        FilledAutofillField field, Dataset.Builder builder,
        MutableBoolean setValueAtLeastOnce) {
    AutofillId autofillId = viewNode.getAutofillId();
    if (autofillId == null) {
        logw("Autofill ID null for %s", viewNode.toString());
        return;
    }
    int autofillType = viewNode.getAutofillType();
    switch (autofillType) {
        case View.AUTOFILL_TYPE_LIST:
            CharSequence[] options = viewNode.getAutofillOptions();
            int listValue = -1;
            if (options != null) {
                listValue = indexOf(viewNode.getAutofillOptions(), field.getTextValue());
            }
            if (listValue != -1) {
                builder.setValue(autofillId, AutofillValue.forList(listValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_DATE:
            Long dateValue = field.getDateValue();
            if (dateValue != null) {
                builder.setValue(autofillId, AutofillValue.forDate(dateValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_TEXT:
            String textValue = field.getTextValue();
            if (textValue != null) {
                builder.setValue(autofillId, AutofillValue.forText(textValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_TOGGLE:
            Boolean toggleValue = field.getToggleValue();
            if (toggleValue != null) {
                builder.setValue(autofillId, AutofillValue.forToggle(toggleValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_NONE:
        default:
            logw("Invalid autofill type - %d", autofillType);
            break;
    }
}
 
Example #13
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: ScrollingHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean scrollControlByFrac(OBControl con, float frac)
{
    MutableBoolean finished = new MutableBoolean(true);
    con.setPosition(nextScrollingLocationByFrac(con, frac, finished));
    return finished.value;
}
 
Example #14
Source Project: GLEXP-Team-onebillion   Author: XPRIZE   File: ScrollingHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean scrollControl(OBControl con)
{
    MutableBoolean finished = new MutableBoolean(true);
    con.setPosition(nextScrollingLocation(con, finished));
    return finished.value;
}
 
Example #15
Source Project: android-AutofillFramework   Author: googlearchive   File: DatasetAdapter.java    License: Apache License 2.0 4 votes vote down vote up
void bindValueToNode(AssistStructure.ViewNode viewNode,
        FilledAutofillField field, Dataset.Builder builder,
        MutableBoolean setValueAtLeastOnce) {
    AutofillId autofillId = viewNode.getAutofillId();
    if (autofillId == null) {
        logw("Autofill ID null for %s", viewNode.toString());
        return;
    }
    int autofillType = viewNode.getAutofillType();
    switch (autofillType) {
        case View.AUTOFILL_TYPE_LIST:
            CharSequence[] options = viewNode.getAutofillOptions();
            int listValue = -1;
            if (options != null) {
                listValue = indexOf(viewNode.getAutofillOptions(), field.getTextValue());
            }
            if (listValue != -1) {
                builder.setValue(autofillId, AutofillValue.forList(listValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_DATE:
            Long dateValue = field.getDateValue();
            if (dateValue != null) {
                builder.setValue(autofillId, AutofillValue.forDate(dateValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_TEXT:
            String textValue = field.getTextValue();
            if (textValue != null) {
                builder.setValue(autofillId, AutofillValue.forText(textValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_TOGGLE:
            Boolean toggleValue = field.getToggleValue();
            if (toggleValue != null) {
                builder.setValue(autofillId, AutofillValue.forToggle(toggleValue));
                setValueAtLeastOnce.value = true;
            }
            break;
        case View.AUTOFILL_TYPE_NONE:
        default:
            logw("Invalid autofill type - %d", autofillType);
            break;
    }
}