Loading core/java/com/android/internal/app/ResolverActivity.java +91 −22 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.content.PackageMonitor; import android.app.ActivityManager; import android.app.AppGlobals; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading Loading @@ -115,6 +114,7 @@ public class ResolverActivity extends Activity { private static final String TAG = "ResolverActivity"; private static final boolean DEBUG = false; private Runnable mPostListBuildRunnable; private boolean mRegistered; private final PackageMonitor mPackageMonitor = new PackageMonitor() { Loading Loading @@ -419,7 +419,9 @@ public class ResolverActivity extends Activity { protected CharSequence getTitleForAction(String action, int defaultTitleRes) { final ActionTitle title = mResolvingHome ? ActionTitle.HOME : ActionTitle.forAction(action); final boolean named = mAdapter.hasFilteredItem(); // While there may already be a filtered item, we can only use it in the title if the list // is already sorted and all information relevant to it is already in the list. final boolean named = mAdapter.getFilteredPosition() > 0; if (title == ActionTitle.DEFAULT && defaultTitleRes != 0) { return getString(defaultTitleRes); } else { Loading Loading @@ -510,6 +512,9 @@ public class ResolverActivity extends Activity { if (!isChangingConfigurations() && mPickOptionRequest != null) { mPickOptionRequest.cancel(); } if (mPostListBuildRunnable != null) { getMainThreadHandler().removeCallbacks(mPostListBuildRunnable); } } @Override Loading Loading @@ -590,6 +595,9 @@ public class ResolverActivity extends Activity { } TargetInfo target = mAdapter.targetInfoForPosition(which, filtered); if (target == null) { return; } if (onTargetSelected(target, always)) { if (always && filtered) { MetricsLogger.action( Loading Loading @@ -880,15 +888,15 @@ public class ResolverActivity extends Activity { } setContentView(mLayoutId); if (count > 0 || !rebuildCompleted) { mAdapterView = (AbsListView) findViewById(R.id.resolver_list); onPrepareAdapterView(mAdapterView, mAdapter, mAlwaysUseOption); } else { if (count == 0 && mAdapter.mPlaceholderCount == 0) { final TextView empty = (TextView) findViewById(R.id.empty); empty.setVisibility(View.VISIBLE); mAdapterView = (AbsListView) findViewById(R.id.resolver_list); mAdapterView.setVisibility(View.GONE); } else { mAdapterView.setVisibility(View.VISIBLE); onPrepareAdapterView(mAdapterView, mAdapter, mAlwaysUseOption); } return false; } Loading Loading @@ -917,16 +925,23 @@ public class ResolverActivity extends Activity { } public void setTitleAndIcon() { if (mTitle == null) { mTitle = getTitleForAction(getTargetIntent().getAction(), mDefaultTitleResId); if (mAdapter.getCount() == 0 && mAdapter.mPlaceholderCount == 0) { final TextView titleView = (TextView) findViewById(R.id.title); if (titleView != null) { titleView.setVisibility(View.GONE); } } CharSequence title = mTitle != null ? mTitle : getTitleForAction(getTargetIntent().getAction(), mDefaultTitleResId); if (!TextUtils.isEmpty(mTitle)) { if (!TextUtils.isEmpty(title)) { final TextView titleView = (TextView) findViewById(R.id.title); if (titleView != null) { titleView.setText(mTitle); titleView.setText(title); } setTitle(mTitle); setTitle(title); // Try to initialize the title icon if we have a view for it and a title to match final ImageView titleIcon = (ImageView) findViewById(R.id.title_icon); Loading Loading @@ -963,9 +978,17 @@ public class ResolverActivity extends Activity { } } if (mAdapter.hasFilteredItem()) { if (mAdapter.getFilteredPosition() >= 0) { setAlwaysButtonEnabled(true, mAdapter.getFilteredPosition(), false); mOnceButton.setEnabled(true); return; } // When the items load in, if an item was already selected, enable the buttons if (mAdapterView != null && mAdapterView.getCheckedItemPosition() != ListView.INVALID_POSITION) { setAlwaysButtonEnabled(true, mAdapterView.getCheckedItemPosition(), true); mOnceButton.setEnabled(true); } } Loading Loading @@ -1234,6 +1257,7 @@ public class ResolverActivity extends Activity { private DisplayResolveInfo mOtherProfile; private boolean mHasExtendedInfo; private ResolverListController mResolverListController; private int mPlaceholderCount; protected final LayoutInflater mInflater; Loading Loading @@ -1265,6 +1289,10 @@ public class ResolverActivity extends Activity { } } public void setPlaceholderCount(int count) { mPlaceholderCount = count; } public DisplayResolveInfo getFilteredItem() { if (mFilterLastUsed && mLastChosenPosition >= 0) { // Not using getItem since it offsets to dodge this position for the list Loading Loading @@ -1350,6 +1378,7 @@ public class ResolverActivity extends Activity { } if (N > 1) { setPlaceholderCount(currentResolveList.size()); AsyncTask<List<ResolvedComponentInfo>, Void, List<ResolvedComponentInfo>> sortingTask = Loading @@ -1366,13 +1395,26 @@ public class ResolverActivity extends Activity { @Override protected void onPostExecute(List<ResolvedComponentInfo> sortedComponents) { processSortedList(sortedComponents); onPrepareAdapterView(mAdapterView, mAdapter, mAlwaysUseOption); if (mProfileView != null) { bindProfileView(); } notifyDataSetChanged(); } }; sortingTask.execute(currentResolveList); if (mPostListBuildRunnable == null) { mPostListBuildRunnable = new Runnable() { @Override public void run() { setTitleAndIcon(); resetAlwaysOrOnceButtonBar(); onListRebuilt(); disableLastChosenIfNeeded(); mPostListBuildRunnable = null; } }; getMainThreadHandler().post(mPostListBuildRunnable); } return false; } else { processSortedList(currentResolveList); Loading Loading @@ -1563,21 +1605,33 @@ public class ResolverActivity extends Activity { } } @Nullable public ResolveInfo resolveInfoForPosition(int position, boolean filtered) { return (filtered ? getItem(position) : mDisplayList.get(position)) .getResolveInfo(); TargetInfo target = targetInfoForPosition(position, filtered); if (target != null) { return target.getResolveInfo(); } return null; } @Nullable public TargetInfo targetInfoForPosition(int position, boolean filtered) { return filtered ? getItem(position) : mDisplayList.get(position); if (filtered) { return getItem(position); } if (mDisplayList.size() > position) { return mDisplayList.get(position); } return null; } public int getCount() { int result = mDisplayList.size(); int totalSize = mDisplayList == null || mDisplayList.isEmpty() ? mPlaceholderCount : mDisplayList.size(); if (mFilterLastUsed && mLastChosenPosition >= 0) { result--; totalSize--; } return result; return totalSize; } public int getUnfilteredCount() { Loading @@ -1592,11 +1646,16 @@ public class ResolverActivity extends Activity { return mDisplayList.get(index); } @Nullable public TargetInfo getItem(int position) { if (mFilterLastUsed && mLastChosenPosition >= 0 && position >= mLastChosenPosition) { position++; } if (mDisplayList.size() > position) { return mDisplayList.get(position); } else { return null; } } public long getItemId(int position) { Loading Loading @@ -1660,6 +1719,11 @@ public class ResolverActivity extends Activity { private void onBindView(View view, TargetInfo info) { final ViewHolder holder = (ViewHolder) view.getTag(); if (info == null) { holder.icon.setImageDrawable( getDrawable(R.drawable.resolver_icon_placeholder)); return; } final CharSequence label = info.getDisplayLabel(); if (!TextUtils.equals(holder.text.getText(), label)) { holder.text.setText(info.getDisplayLabel()); Loading Loading @@ -1770,6 +1834,11 @@ public class ResolverActivity extends Activity { // Header views don't count. return; } // If we're still loading, we can't yet enable the buttons. if (mAdapter.resolveInfoForPosition(position, true) == null) { return; } final int checkedPos = mAdapterView.getCheckedItemPosition(); final boolean hasValidSelection = checkedPos != ListView.INVALID_POSITION; if (mAlwaysUseOption && (!hasValidSelection || mLastSelected != checkedPos)) { Loading core/res/res/drawable/resolver_icon_placeholder.xml 0 → 100644 +19 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="#10000000"/> <size android:width="36dp" android:height="36dp"/> </shape> No newline at end of file core/res/res/layout/chooser_grid.xml +1 −2 Original line number Diff line number Diff line Loading @@ -53,8 +53,7 @@ android:visibility="gone" android:scaleType="fitCenter" android:layout_below="@id/profile_button" android:layout_alignParentLeft="true" /> android:layout_alignParentLeft="true"/> <TextView android:id="@+id/title" android:layout_height="wrap_content" android:layout_width="wrap_content" Loading core/res/res/layout/resolver_list_with_default.xml +1 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="20dp" android:src="@drawable/resolver_icon_placeholder" android:scaleType="fitCenter" /> <TextView Loading core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2860,4 +2860,7 @@ <java-symbol type="drawable" name="btn_event_material"/> <java-symbol type="string" name="time_picker_text_input_mode_description"/> <java-symbol type="string" name="time_picker_radial_mode_description"/> <!-- resolver activity --> <java-symbol type="drawable" name="resolver_icon_placeholder" /> </resources> Loading
core/java/com/android/internal/app/ResolverActivity.java +91 −22 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.content.PackageMonitor; import android.app.ActivityManager; import android.app.AppGlobals; import android.content.ComponentName; import android.content.Context; import android.content.Intent; Loading Loading @@ -115,6 +114,7 @@ public class ResolverActivity extends Activity { private static final String TAG = "ResolverActivity"; private static final boolean DEBUG = false; private Runnable mPostListBuildRunnable; private boolean mRegistered; private final PackageMonitor mPackageMonitor = new PackageMonitor() { Loading Loading @@ -419,7 +419,9 @@ public class ResolverActivity extends Activity { protected CharSequence getTitleForAction(String action, int defaultTitleRes) { final ActionTitle title = mResolvingHome ? ActionTitle.HOME : ActionTitle.forAction(action); final boolean named = mAdapter.hasFilteredItem(); // While there may already be a filtered item, we can only use it in the title if the list // is already sorted and all information relevant to it is already in the list. final boolean named = mAdapter.getFilteredPosition() > 0; if (title == ActionTitle.DEFAULT && defaultTitleRes != 0) { return getString(defaultTitleRes); } else { Loading Loading @@ -510,6 +512,9 @@ public class ResolverActivity extends Activity { if (!isChangingConfigurations() && mPickOptionRequest != null) { mPickOptionRequest.cancel(); } if (mPostListBuildRunnable != null) { getMainThreadHandler().removeCallbacks(mPostListBuildRunnable); } } @Override Loading Loading @@ -590,6 +595,9 @@ public class ResolverActivity extends Activity { } TargetInfo target = mAdapter.targetInfoForPosition(which, filtered); if (target == null) { return; } if (onTargetSelected(target, always)) { if (always && filtered) { MetricsLogger.action( Loading Loading @@ -880,15 +888,15 @@ public class ResolverActivity extends Activity { } setContentView(mLayoutId); if (count > 0 || !rebuildCompleted) { mAdapterView = (AbsListView) findViewById(R.id.resolver_list); onPrepareAdapterView(mAdapterView, mAdapter, mAlwaysUseOption); } else { if (count == 0 && mAdapter.mPlaceholderCount == 0) { final TextView empty = (TextView) findViewById(R.id.empty); empty.setVisibility(View.VISIBLE); mAdapterView = (AbsListView) findViewById(R.id.resolver_list); mAdapterView.setVisibility(View.GONE); } else { mAdapterView.setVisibility(View.VISIBLE); onPrepareAdapterView(mAdapterView, mAdapter, mAlwaysUseOption); } return false; } Loading Loading @@ -917,16 +925,23 @@ public class ResolverActivity extends Activity { } public void setTitleAndIcon() { if (mTitle == null) { mTitle = getTitleForAction(getTargetIntent().getAction(), mDefaultTitleResId); if (mAdapter.getCount() == 0 && mAdapter.mPlaceholderCount == 0) { final TextView titleView = (TextView) findViewById(R.id.title); if (titleView != null) { titleView.setVisibility(View.GONE); } } CharSequence title = mTitle != null ? mTitle : getTitleForAction(getTargetIntent().getAction(), mDefaultTitleResId); if (!TextUtils.isEmpty(mTitle)) { if (!TextUtils.isEmpty(title)) { final TextView titleView = (TextView) findViewById(R.id.title); if (titleView != null) { titleView.setText(mTitle); titleView.setText(title); } setTitle(mTitle); setTitle(title); // Try to initialize the title icon if we have a view for it and a title to match final ImageView titleIcon = (ImageView) findViewById(R.id.title_icon); Loading Loading @@ -963,9 +978,17 @@ public class ResolverActivity extends Activity { } } if (mAdapter.hasFilteredItem()) { if (mAdapter.getFilteredPosition() >= 0) { setAlwaysButtonEnabled(true, mAdapter.getFilteredPosition(), false); mOnceButton.setEnabled(true); return; } // When the items load in, if an item was already selected, enable the buttons if (mAdapterView != null && mAdapterView.getCheckedItemPosition() != ListView.INVALID_POSITION) { setAlwaysButtonEnabled(true, mAdapterView.getCheckedItemPosition(), true); mOnceButton.setEnabled(true); } } Loading Loading @@ -1234,6 +1257,7 @@ public class ResolverActivity extends Activity { private DisplayResolveInfo mOtherProfile; private boolean mHasExtendedInfo; private ResolverListController mResolverListController; private int mPlaceholderCount; protected final LayoutInflater mInflater; Loading Loading @@ -1265,6 +1289,10 @@ public class ResolverActivity extends Activity { } } public void setPlaceholderCount(int count) { mPlaceholderCount = count; } public DisplayResolveInfo getFilteredItem() { if (mFilterLastUsed && mLastChosenPosition >= 0) { // Not using getItem since it offsets to dodge this position for the list Loading Loading @@ -1350,6 +1378,7 @@ public class ResolverActivity extends Activity { } if (N > 1) { setPlaceholderCount(currentResolveList.size()); AsyncTask<List<ResolvedComponentInfo>, Void, List<ResolvedComponentInfo>> sortingTask = Loading @@ -1366,13 +1395,26 @@ public class ResolverActivity extends Activity { @Override protected void onPostExecute(List<ResolvedComponentInfo> sortedComponents) { processSortedList(sortedComponents); onPrepareAdapterView(mAdapterView, mAdapter, mAlwaysUseOption); if (mProfileView != null) { bindProfileView(); } notifyDataSetChanged(); } }; sortingTask.execute(currentResolveList); if (mPostListBuildRunnable == null) { mPostListBuildRunnable = new Runnable() { @Override public void run() { setTitleAndIcon(); resetAlwaysOrOnceButtonBar(); onListRebuilt(); disableLastChosenIfNeeded(); mPostListBuildRunnable = null; } }; getMainThreadHandler().post(mPostListBuildRunnable); } return false; } else { processSortedList(currentResolveList); Loading Loading @@ -1563,21 +1605,33 @@ public class ResolverActivity extends Activity { } } @Nullable public ResolveInfo resolveInfoForPosition(int position, boolean filtered) { return (filtered ? getItem(position) : mDisplayList.get(position)) .getResolveInfo(); TargetInfo target = targetInfoForPosition(position, filtered); if (target != null) { return target.getResolveInfo(); } return null; } @Nullable public TargetInfo targetInfoForPosition(int position, boolean filtered) { return filtered ? getItem(position) : mDisplayList.get(position); if (filtered) { return getItem(position); } if (mDisplayList.size() > position) { return mDisplayList.get(position); } return null; } public int getCount() { int result = mDisplayList.size(); int totalSize = mDisplayList == null || mDisplayList.isEmpty() ? mPlaceholderCount : mDisplayList.size(); if (mFilterLastUsed && mLastChosenPosition >= 0) { result--; totalSize--; } return result; return totalSize; } public int getUnfilteredCount() { Loading @@ -1592,11 +1646,16 @@ public class ResolverActivity extends Activity { return mDisplayList.get(index); } @Nullable public TargetInfo getItem(int position) { if (mFilterLastUsed && mLastChosenPosition >= 0 && position >= mLastChosenPosition) { position++; } if (mDisplayList.size() > position) { return mDisplayList.get(position); } else { return null; } } public long getItemId(int position) { Loading Loading @@ -1660,6 +1719,11 @@ public class ResolverActivity extends Activity { private void onBindView(View view, TargetInfo info) { final ViewHolder holder = (ViewHolder) view.getTag(); if (info == null) { holder.icon.setImageDrawable( getDrawable(R.drawable.resolver_icon_placeholder)); return; } final CharSequence label = info.getDisplayLabel(); if (!TextUtils.equals(holder.text.getText(), label)) { holder.text.setText(info.getDisplayLabel()); Loading Loading @@ -1770,6 +1834,11 @@ public class ResolverActivity extends Activity { // Header views don't count. return; } // If we're still loading, we can't yet enable the buttons. if (mAdapter.resolveInfoForPosition(position, true) == null) { return; } final int checkedPos = mAdapterView.getCheckedItemPosition(); final boolean hasValidSelection = checkedPos != ListView.INVALID_POSITION; if (mAlwaysUseOption && (!hasValidSelection || mLastSelected != checkedPos)) { Loading
core/res/res/drawable/resolver_icon_placeholder.xml 0 → 100644 +19 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2017 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="#10000000"/> <size android:width="36dp" android:height="36dp"/> </shape> No newline at end of file
core/res/res/layout/chooser_grid.xml +1 −2 Original line number Diff line number Diff line Loading @@ -53,8 +53,7 @@ android:visibility="gone" android:scaleType="fitCenter" android:layout_below="@id/profile_button" android:layout_alignParentLeft="true" /> android:layout_alignParentLeft="true"/> <TextView android:id="@+id/title" android:layout_height="wrap_content" android:layout_width="wrap_content" Loading
core/res/res/layout/resolver_list_with_default.xml +1 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="20dp" android:src="@drawable/resolver_icon_placeholder" android:scaleType="fitCenter" /> <TextView Loading
core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2860,4 +2860,7 @@ <java-symbol type="drawable" name="btn_event_material"/> <java-symbol type="string" name="time_picker_text_input_mode_description"/> <java-symbol type="string" name="time_picker_radial_mode_description"/> <!-- resolver activity --> <java-symbol type="drawable" name="resolver_icon_placeholder" /> </resources>