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

Commit ac5086ac authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Make "Always" and "Just once" buttons work properly in tabbed view"...

Merge "Make "Always" and "Just once" buttons work properly in tabbed view" into rvc-dev am: e6750fd5

Change-Id: Ie7f047f542157cc7c755b8f84b7e413c5dd17c5b
parents d55a06e7 e6750fd5
Loading
Loading
Loading
Loading
+39 −12
Original line number Diff line number Diff line
@@ -854,6 +854,11 @@ public class ResolverActivity extends Activity implements

    private void setAlwaysButtonEnabled(boolean hasValidSelection, int checkedPos,
            boolean filtered) {
        if (mMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) {
            // Never allow the inactive profile to always open an app.
            mAlwaysButton.setEnabled(false);
            return;
        }
        boolean enabled = false;
        ResolveInfo ri = null;
        if (hasValidSelection) {
@@ -877,6 +882,7 @@ public class ResolverActivity extends Activity implements
            }
        }

        if (ri != null) {
            ActivityInfo activityInfo = ri.activityInfo;

            boolean hasRecordPermission =
@@ -891,6 +897,7 @@ public class ResolverActivity extends Activity implements
                                ResolverActivity.EXTRA_IS_AUDIO_CAPTURE_DEVICE, false);
                enabled = !hasAudioCapture;
            }
        }
        mAlwaysButton.setEnabled(enabled);
    }

@@ -1567,10 +1574,26 @@ public class ResolverActivity extends Activity implements

        viewPager.setVisibility(View.VISIBLE);
        tabHost.setCurrentTab(mMultiProfilePagerAdapter.getCurrentPage());
        mMultiProfilePagerAdapter.setOnProfileSelectedListener(tabHost::setCurrentTab);
        mMultiProfilePagerAdapter.setOnProfileSelectedListener(
                index -> {
                    tabHost.setCurrentTab(index);
                    resetButtonBar();
                    resetCheckedItem();
                });
        findViewById(R.id.resolver_tab_divider).setVisibility(View.VISIBLE);
    }

    private void resetCheckedItem() {
        if (!isIntentPicker()) {
            return;
        }
        mLastSelected = ListView.INVALID_POSITION;
        ListView inactiveListView = (ListView) mMultiProfilePagerAdapter.getInactiveAdapterView();
        if (inactiveListView.getCheckedItemCount() > 0) {
            inactiveListView.setItemChecked(inactiveListView.getCheckedItemPosition(), false);
        }
    }

    private void resetTabsHeaderStyle(TabWidget tabWidget) {
        for (int i = 0; i < tabWidget.getChildCount(); i++) {
            TextView title = tabWidget.getChildAt(i).findViewById(android.R.id.title);
@@ -1677,6 +1700,10 @@ public class ResolverActivity extends Activity implements
    }

    private void resetAlwaysOrOnceButtonBar() {
        // Disable both buttons initially
        setAlwaysButtonEnabled(false, ListView.INVALID_POSITION, false);
        mOnceButton.setEnabled(false);

        int filteredPosition = mMultiProfilePagerAdapter.getActiveListAdapter()
                .getFilteredPosition();
        if (useLayoutWithDefault() && filteredPosition != ListView.INVALID_POSITION) {