Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d81cc4ab authored by Adam Powell's avatar Adam Powell
Browse files

Easy "Just once" launches from ResolverActivity

Allow a second tap of a selected item in ResolverActivity to launch
the target as "just once" for sloppier/quicker choices.

Change-Id: If05fc7c1ac622195f6253e6ca0868fd87954dd46
parent 1825b984
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
    private int mIconDpi;
    private int mIconSize;
    private int mMaxColumns;
    private int mLastSelected = GridView.INVALID_POSITION;

    private boolean mRegistered;
    private final PackageMonitor mPackageMonitor = new PackageMonitor() {
@@ -247,6 +248,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte
        if (mAlwaysUseOption) {
            final int checkedPos = mGrid.getCheckedItemPosition();
            final boolean enabled = checkedPos != GridView.INVALID_POSITION;
            mLastSelected = checkedPos;
            mAlwaysButton.setEnabled(enabled);
            mOnceButton.setEnabled(enabled);
            if (enabled) {
@@ -257,14 +259,15 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if (mAlwaysUseOption) {
        final int checkedPos = mGrid.getCheckedItemPosition();
            final boolean enabled = checkedPos != GridView.INVALID_POSITION;
            mAlwaysButton.setEnabled(enabled);
            mOnceButton.setEnabled(enabled);
            if (enabled) {
        final boolean hasValidSelection = checkedPos != GridView.INVALID_POSITION;
        if (!hasValidSelection || (mAlwaysUseOption && mLastSelected != checkedPos)) {
            mAlwaysButton.setEnabled(hasValidSelection);
            mOnceButton.setEnabled(hasValidSelection);
            if (hasValidSelection) {
                mGrid.smoothScrollToPosition(checkedPos);
            }
            mLastSelected = checkedPos;
        } else {
            startSelected(position, false);
        }