ShareImageDialogFragment.java
7.84 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package com.bitstrips.imoji.browser.fragments;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bitstrips.imoji.ImojiApplication;
import com.bitstrips.imoji.analytics.Action;
import com.bitstrips.imoji.analytics.AnalyticsHelper;
import com.bitstrips.imoji.analytics.AnalyticsWrapper;
import com.bitstrips.imoji.analytics.Category;
import com.bitstrips.imoji.analytics.LegacyAnalyticsService;
import com.bitstrips.imoji.models.Sticker;
import com.bitstrips.imoji.ui.ResolveInfosSorter;
import com.bitstrips.imoji.util.FileUtil;
import com.bitstrips.imoji.util.PreferenceUtils;
import com.bitstrips.imoji.util.ShareUtils;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
public class ShareImageDialogFragment
extends DialogFragment
{
public static final String ANALYTICS_KEY = "ShareImageDialogFragment.analytics.wrapper";
public static final String FILE_PATH_KEY = "filePath";
public static final String INTENT_KEY = "intent";
public static final String SAVE_BUTTON_TAG = "save";
public static final String STICKER_KEY = "sticker";
public static final String TAG = "ShareImageDialog";
Sticker j;
@Inject
FileUtil k;
@Inject
PreferenceUtils l;
@Inject
LegacyAnalyticsService m;
private Intent o;
private String p;
private OnShareListener q;
static
{
if (!ShareImageDialogFragment.class.desiredAssertionStatus()) {}
for (boolean bool = true;; bool = false)
{
n = bool;
return;
}
}
protected View createButton(LayoutInflater paramLayoutInflater, String paramString, Drawable paramDrawable)
{
paramLayoutInflater = paramLayoutInflater.inflate(2130903201, null);
((ImageView)paramLayoutInflater.findViewById(2131689935)).setImageDrawable(paramDrawable);
((TextView)paramLayoutInflater.findViewById(2131689936)).setText(paramString);
return paramLayoutInflater;
}
protected View createShareToAppButton(LayoutInflater paramLayoutInflater, ResolveInfo paramResolveInfo)
{
String str2 = paramResolveInfo.loadLabel(getActivity().getPackageManager()).toString();
final String str1 = paramResolveInfo.activityInfo.packageName;
paramLayoutInflater = createButton(paramLayoutInflater, str2, paramResolveInfo.loadIcon(getActivity().getPackageManager()));
paramLayoutInflater.setTag(str1);
paramLayoutInflater.setOnClickListener(new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
ShareImageDialogFragment.this.l.increaseShareImageAppPriority(str1);
ShareImageDialogFragment localShareImageDialogFragment = ShareImageDialogFragment.this;
String str = str1;
paramAnonymousView = null;
if (localShareImageDialogFragment.getArguments().getSerializable("ShareImageDialogFragment.analytics.wrapper") != null) {
paramAnonymousView = (AnalyticsWrapper)localShareImageDialogFragment.getArguments().getSerializable("ShareImageDialogFragment.analytics.wrapper");
}
Object localObject = paramAnonymousView;
if (paramAnonymousView == null) {
localObject = new AnalyticsWrapper().labelForImojiShare(localShareImageDialogFragment.j, "search");
}
AnalyticsHelper.sendShareEvents(localShareImageDialogFragment.m, str, (AnalyticsWrapper)localObject, localShareImageDialogFragment.l, Category.CLICK, Action.SHARE);
ShareImageDialogFragment.this.shareToApp(str1);
ShareImageDialogFragment.this.notifyShare();
ShareImageDialogFragment.this.dismiss();
}
});
return paramLayoutInflater;
}
protected void notifyShare()
{
if (this.q != null) {
this.q.onShare(this.j);
}
}
public void onAttach(Context paramContext)
{
super.onAttach(paramContext);
if ((paramContext instanceof OnShareListener)) {
this.q = ((OnShareListener)paramContext);
}
}
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
((ImojiApplication)getContext().getApplicationContext()).inject(this);
this.o = ((Intent)getArguments().get("intent"));
this.j = ((Sticker)getArguments().getSerializable("sticker"));
this.p = getArguments().getString("filePath");
setStyle(2, 16973836);
}
public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
{
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(getResources().getColor(2131624117)));
paramViewGroup = paramLayoutInflater.inflate(2130903202, paramViewGroup, false);
if ((!n) && (paramViewGroup == null)) {
throw new AssertionError();
}
paramViewGroup.findViewById(2131689938).setOnClickListener(new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
ShareImageDialogFragment.this.dismiss();
}
});
((ImageView)paramViewGroup.findViewById(2131689792)).setImageURI(Uri.parse(this.p));
paramBundle = (LinearLayout)paramViewGroup.findViewById(2131689940);
Object localObject = getActivity().getResources().getStringArray(2131296258);
localObject = this.l.getShareImagePackagePriorityMap((String[])localObject);
localObject = ResolveInfosSorter.sort(getActivity().getPackageManager().queryIntentActivities(this.o, 0), (Map)localObject).iterator();
while (((Iterator)localObject).hasNext()) {
paramBundle.addView(createShareToAppButton(paramLayoutInflater, (ResolveInfo)((Iterator)localObject).next()));
}
localObject = getResources().getDrawable(2130837742);
paramLayoutInflater = createButton(paramLayoutInflater, getResources().getString(2131231022), (Drawable)localObject);
paramLayoutInflater.setTag("save");
paramLayoutInflater.setOnClickListener(new View.OnClickListener()
{
public final void onClick(View paramAnonymousView)
{
if (ShareImageDialogFragment.a(ShareImageDialogFragment.this) != null) {
ShareImageDialogFragment.a(ShareImageDialogFragment.this).onRequestStoragePermissions();
}
}
});
paramBundle.addView(paramLayoutInflater);
return paramViewGroup;
}
public void onDetach()
{
super.onDetach();
this.q = null;
}
public void onWritePermission(boolean paramBoolean)
{
if (paramBoolean)
{
notifyShare();
this.p = this.k.saveImoji(this.p);
MediaScannerConnection.scanFile(getActivity(), new String[] { this.p }, new String[] { "image/png" }, null);
Toast.makeText(getActivity(), 2131231024, 1).show();
if ((getActivity() != null) && (!getActivity().isFinishing()) && (!isDetached())) {
dismissAllowingStateLoss();
}
}
}
protected void shareToApp(String paramString)
{
ShareUtils.intentForApp(this.o, paramString);
startActivity(this.o);
}
public static abstract interface OnShareListener
{
public abstract void onRequestStoragePermissions();
public abstract void onShare(Sticker paramSticker);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/browser/fragments/ShareImageDialogFragment.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/