系统中图片分享菜单的
packages/apps/SnapdragonGallery/res/values-zh-rCN/strings.xml: <string name="share_dialogue_title">分享选择</string>
查看其字符调用的位置有:
packages/apps/SnapdragonGallery/src/com/android/gallery3d/ui/ActionModeHandler.java
if (action == R.id.action_share) {
String shareTitle = mActivity.getResources().
getString(R.string.share_dialogue_title);
mActivity.isTopMenuShow = true;
mActivity.startActivity(Intent.createChooser(
shareIntent, shareTitle));
return true;
}
可以知道其具体使用函数就是:Intent.createChooser(shareIntent, shareTitle)
继续跟踪到Intent.java中;
frameworks/base/core/java/android/content/Intent.java
/**
* Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
*
* <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
* target intent, also optionally supplying a title. If the target
* intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
* {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
* set in the returned chooser intent, with its ClipData set appropriately:
* either a direct reflection of {@link #getClipData()} if that is non-null,
* or a new ClipData built from {@link #getData()}.
*
* @param target The Intent that the user will be selecting an activity
* to perform.
* @param title Optional title that will be displayed in the chooser,
* only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
* @return Return a new Intent object that you can hand to
* {@link Context#startActivity(Intent) Context.startActivity()} and
* related methods.
*/
public static Intent createChooser(Intent target, CharSequence title) {
return createChooser(target, title, null);
}
/**
* Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
*
* <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
* target intent, also optionally supplying a title. If the target
* intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
* {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
* set in the returned chooser intent, with its ClipData set appropriately:
* either a direct reflection of {@link #getClipData()} if that is non-null,
* or a new ClipData built from {@link #getData()}.</p>
*
* <p>The caller may optionally supply an {@link IntentSender} to receive a callback
* when the user makes a choice. This can be useful if the calling application wants
* to remember the last chosen target and surface it as a more prominent or one-touch
* affordance elsewhere in the UI for next time.</p>
*
* @param target The Intent that the user will be selecting an activity
* to perform.
* @param title Optional title that will be displayed in the chooser,
* only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
* @param sender Optional IntentSender to be called when a choice is made.
* @return Return a new Intent object that you can hand to
* {@link Context#startActivity(Intent) Context.startActivity()} and
* related methods.
*/
public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
Intent intent = new Intent(ACTION_CHOOSER);
intent.putExtra(EXTRA_INTENT, target);
if (title != null) {
intent.putExtra(EXTRA_TITLE, title);
}
if (sender != null) {
intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
}
// Migrate any clip data and flags from target.
int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
| FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
| FLAG_GRANT_PREFIX_URI_PERMISSION);
if (permFlags != 0) {
ClipData targetClipData = target.getClipData();
if (targetClipData == null && target.getData() != null) {
ClipData.Item item = new ClipData.Item(target.getData());
String[] mimeTypes;
if (target.getType() != null) {
mimeTypes = new String[] { target.getType() };
} else {
mimeTypes = new String[] { };
}
targetClipData = new ClipData(null, mimeTypes, item);
}
if (targetClipData != null) {
intent.setClipData(targetClipData);
intent.addFlags(permFlags);
}
}
return intent;
}
查看其接收广播的函数:
frameworks/base/core/java/com/android/internal/app/IntentForwarderActivity.java
/**
* Check whether the intent can be forwarded to target user. Return the intent used for
* forwarding if it can be forwarded, {@code null} otherwise.
*/
Intent canForward(Intent incomingIntent, int targetUserId) {
Intent forwardIntent = new Intent(incomingIntent);
forwardIntent.addFlags(
Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
sanitizeIntent(forwardIntent);
Intent intentToCheck = forwardIntent;
if (Intent.ACTION_CHOOSER.equals(forwardIntent.getAction())) {
// The EXTRA_INITIAL_INTENTS may not be allowed to be forwarded.
if (forwardIntent.hasExtra(Intent.EXTRA_INITIAL_INTENTS)) {
Slog.wtf(TAG, "An chooser intent with extra initial intents cannot be forwarded to"
+ " a different user");
return null;
}
if (forwardIntent.hasExtra(Intent.EXTRA_REPLACEMENT_EXTRAS)) {
Slog.wtf(TAG, "A chooser intent with replacement extras cannot be forwarded to a"
+ " different user");
return null;
}
intentToCheck = forwardIntent.getParcelableExtra(Intent.EXTRA_INTENT);
if (intentToCheck == null) {
Slog.wtf(TAG, "Cannot forward a chooser intent with no extra "
+ Intent.EXTRA_INTENT);
return null;
}
}
if (forwardIntent.getSelector() != null) {
intentToCheck = forwardIntent.getSelector();
}
String resolvedType = intentToCheck.resolveTypeIfNeeded(getContentResolver());
sanitizeIntent(intentToCheck);
try {
if (mInjector.getIPackageManager().
canForwardTo(intentToCheck, resolvedType, getUserId(), targetUserId)) {
return forwardIntent;
}
} catch (RemoteException e) {
Slog.e(TAG, "PackageManagerService is dead?");
}
return null;
}
在frameworks/base/core/res/AndroidManifest.xml中有:
<activity android:name="com.android.internal.app.ChooserActivity"
android:theme="@style/Theme.DeviceDefault.Resolver"
android:finishOnCloseSystemDialogs="true"
android:excludeFromRecents="true"
android:documentLaunchMode="never"
android:relinquishTaskIdentity="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
android:process=":ui"
android:visibleToInstantApps="true">
<intent-filter>
<action android:name="android.intent.action.CHOOSER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE" />
</intent-filter>
</activity>
根据Intent的静态引用跳转到对应的frameworks/base/core/java/com/android/internal/app/ChooserActivity.java
同时根据命令也可以查找到对应的ACtivity
adb shell "dumpsys window|grep mCurrentFocus
mCurrentFocus=Window{76503b u0 android/com.android.internal.app.ChooserActivity}码片
需要注意:该函数继承制:ResolverActrivity
public class ChooserActivity extends ResolverActivity
查找到对应文件的布局文件:
@Override
public int getLayoutResource() {
return R.layout.chooser_grid;
}
主要是查找到矩阵框中字符的大小显示, 故先找到其Adapter函数中:
RowViewHolder createViewHolder(ViewGroup parent) {
final ViewGroup row = (ViewGroup) mLayoutInflater.inflate(R.layout.chooser_row,
parent, false);
final RowViewHolder holder = new RowViewHolder(row, mColumnCount);
final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
for (int i = 0; i < mColumnCount; i++) {
final View v = mChooserListAdapter.createView(row);
final int column = i;
v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startSelected(holder.itemIndices[column], false, true);
}
});
v.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
showTargetDetails(
mChooserListAdapter.resolveInfoForPosition(
holder.itemIndices[column], true));
return true;
}
});
row.addView(v);
holder.cells[i] = v;
// Force height to be a given so we don't have visual disruption during scaling.
LayoutParams lp = v.getLayoutParams();
v.measure(spec, spec);
if (lp == null) {
lp = new LayoutParams(LayoutParams.MATCH_PARENT, v.getMeasuredHeight());
row.setLayoutParams(lp);
} else {
lp.height = v.getMeasuredHeight();
}
if (i != (mColumnCount - 1)) {
row.addView(new Space(ChooserActivity.this),
new LinearLayout.LayoutParams(0, 0, 1));
}
}
// Pre-measure so we can scale later.
holder.measure();
LayoutParams lp = row.getLayoutParams();
if (lp == null) {
lp = new LayoutParams(LayoutParams.MATCH_PARENT, holder.measuredRowHeight);
row.setLayoutParams(lp);
} else {
lp.height = holder.measuredRowHeight;
}
row.setTag(holder);
return holder;
}
其对应的属性布局位于frameworks/base/core/res/res/layout/resolve_grid_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="76dp"
android:layout_height="wrap_content"
android:minHeight="100dp"
android:gravity="center"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:focusable="true"
android:background="?attr/selectableItemBackgroundBorderless">
<FrameLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginBottom="3dp"
android:scaleType="fitCenter" />
<ImageView android:id="@+id/target_badge"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="end|bottom"
android:visibility="gone"
android:scaleType="fitCenter" />
</FrameLayout>
<!-- Activity name -->
<TextView android:id="@android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:textAppearance="?attr/textAppearanceSmall"
android:textColor="?attr/textColorPrimary"
android:textSize="10sp"
android:fontFamily="sans-serif-condensed"
android:gravity="top|center_horizontal"
android:minLines="2"
android:maxLines="2"
android:ellipsize="marquee" />
<!-- Extended activity info to distinguish between duplicate activity names -->
<TextView android:id="@android:id/text2"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="10sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:minLines="2"
android:maxLines="2"
android:gravity="top|center_horizontal"
android:ellipsize="marquee"
android:visibility="gone" />
</LinearLayout>
将字符大小修改即可.