ShareActionProvider.java
6.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package android.support.v7.widget;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources.Theme;
import android.os.Build.VERSION;
import android.support.v4.view.ActionProvider;
import android.support.v7.appcompat.R.attr;
import android.support.v7.appcompat.R.string;
import android.support.v7.content.res.AppCompatResources;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.SubMenu;
import android.view.View;
public class ShareActionProvider
extends ActionProvider
{
public static final String DEFAULT_SHARE_HISTORY_FILE_NAME = "share_history.xml";
final Context a;
String b = "share_history.xml";
OnShareTargetSelectedListener c;
private int d = 4;
private final b e = new b();
private ActivityChooserModel.OnChooseActivityListener f;
public ShareActionProvider(Context paramContext)
{
super(paramContext);
this.a = paramContext;
}
private void a()
{
if (this.c == null) {
return;
}
if (this.f == null) {
this.f = new a();
}
ActivityChooserModel localActivityChooserModel = ActivityChooserModel.a(this.a, this.b);
ActivityChooserModel.OnChooseActivityListener localOnChooseActivityListener = this.f;
synchronized (localActivityChooserModel.b)
{
localActivityChooserModel.i = localOnChooseActivityListener;
return;
}
}
static void a(Intent paramIntent)
{
if (Build.VERSION.SDK_INT >= 21)
{
paramIntent.addFlags(134742016);
return;
}
paramIntent.addFlags(524288);
}
public boolean hasSubMenu()
{
return true;
}
public View onCreateActionView()
{
ActivityChooserView localActivityChooserView = new ActivityChooserView(this.a);
if (!localActivityChooserView.isInEditMode()) {
localActivityChooserView.setActivityChooserModel(ActivityChooserModel.a(this.a, this.b));
}
TypedValue localTypedValue = new TypedValue();
this.a.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, localTypedValue, true);
localActivityChooserView.setExpandActivityOverflowButtonDrawable(AppCompatResources.getDrawable(this.a, localTypedValue.resourceId));
localActivityChooserView.setProvider(this);
localActivityChooserView.setDefaultActionButtonContentDescription(R.string.abc_shareactionprovider_share_with_application);
localActivityChooserView.setExpandActivityOverflowButtonContentDescription(R.string.abc_shareactionprovider_share_with);
return localActivityChooserView;
}
public void onPrepareSubMenu(SubMenu paramSubMenu)
{
paramSubMenu.clear();
ActivityChooserModel localActivityChooserModel = ActivityChooserModel.a(this.a, this.b);
PackageManager localPackageManager = this.a.getPackageManager();
int j = localActivityChooserModel.a();
int k = Math.min(j, this.d);
int i = 0;
ResolveInfo localResolveInfo;
while (i < k)
{
localResolveInfo = localActivityChooserModel.a(i);
paramSubMenu.add(0, i, i, localResolveInfo.loadLabel(localPackageManager)).setIcon(localResolveInfo.loadIcon(localPackageManager)).setOnMenuItemClickListener(this.e);
i += 1;
}
if (k < j)
{
paramSubMenu = paramSubMenu.addSubMenu(0, k, k, this.a.getString(R.string.abc_activity_chooser_view_see_all));
i = 0;
while (i < j)
{
localResolveInfo = localActivityChooserModel.a(i);
paramSubMenu.add(0, i, i, localResolveInfo.loadLabel(localPackageManager)).setIcon(localResolveInfo.loadIcon(localPackageManager)).setOnMenuItemClickListener(this.e);
i += 1;
}
}
}
public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener paramOnShareTargetSelectedListener)
{
this.c = paramOnShareTargetSelectedListener;
a();
}
public void setShareHistoryFileName(String paramString)
{
this.b = paramString;
a();
}
public void setShareIntent(Intent paramIntent)
{
if (paramIntent != null)
{
??? = paramIntent.getAction();
if (("android.intent.action.SEND".equals(???)) || ("android.intent.action.SEND_MULTIPLE".equals(???))) {
a(paramIntent);
}
}
ActivityChooserModel localActivityChooserModel = ActivityChooserModel.a(this.a, this.b);
synchronized (localActivityChooserModel.b)
{
if (localActivityChooserModel.f == paramIntent) {
return;
}
localActivityChooserModel.f = paramIntent;
localActivityChooserModel.h = true;
localActivityChooserModel.d();
return;
}
}
public static abstract interface OnShareTargetSelectedListener
{
public abstract boolean onShareTargetSelected(ShareActionProvider paramShareActionProvider, Intent paramIntent);
}
final class a
implements ActivityChooserModel.OnChooseActivityListener
{
a() {}
public final boolean onChooseActivity(ActivityChooserModel paramActivityChooserModel, Intent paramIntent)
{
if (ShareActionProvider.this.c != null) {
ShareActionProvider.this.c.onShareTargetSelected(ShareActionProvider.this, paramIntent);
}
return false;
}
}
final class b
implements MenuItem.OnMenuItemClickListener
{
b() {}
public final boolean onMenuItemClick(MenuItem paramMenuItem)
{
paramMenuItem = ActivityChooserModel.a(ShareActionProvider.this.a, ShareActionProvider.this.b).b(paramMenuItem.getItemId());
if (paramMenuItem != null)
{
String str = paramMenuItem.getAction();
if (("android.intent.action.SEND".equals(str)) || ("android.intent.action.SEND_MULTIPLE".equals(str))) {
ShareActionProvider.a(paramMenuItem);
}
ShareActionProvider.this.a.startActivity(paramMenuItem);
}
return true;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v7/widget/ShareActionProvider.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/