UpdateActivity.java
10.5 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
package net.hockeyapp.android;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;
import android.provider.Settings.SettingNotFoundException;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;
import java.util.Locale;
import net.hockeyapp.android.listeners.DownloadFileListener;
import net.hockeyapp.android.objects.ErrorObject;
import net.hockeyapp.android.tasks.DownloadFileTask;
import net.hockeyapp.android.tasks.GetFileSizeTask;
import net.hockeyapp.android.utils.AsyncTaskUtils;
import net.hockeyapp.android.utils.HockeyLog;
import net.hockeyapp.android.utils.Util;
import net.hockeyapp.android.utils.VersionHelper;
public class UpdateActivity
extends Activity
implements View.OnClickListener, UpdateActivityInterface, UpdateInfoListener
{
public static final String EXTRA_JSON = "json";
public static final String EXTRA_URL = "url";
private ErrorObject a;
private Context b;
protected DownloadFileTask mDownloadTask;
protected VersionHelper mVersionHelper;
@SuppressLint({"InlinedApi"})
private boolean a()
{
try
{
if ((Build.VERSION.SDK_INT >= 17) && (Build.VERSION.SDK_INT < 21))
{
if (Settings.Global.getInt(getContentResolver(), "install_non_market_apps") != 1) {
break label51;
}
return true;
}
int i = Settings.Secure.getInt(getContentResolver(), "install_non_market_apps");
if (i != 1) {
return false;
}
}
catch (Settings.SettingNotFoundException localSettingNotFoundException) {}
return true;
label51:
return false;
}
protected void configureView()
{
((TextView)findViewById(R.id.label_title)).setText(getAppName());
final TextView localTextView = (TextView)findViewById(R.id.label_version);
final String str1 = "Version " + this.mVersionHelper.getVersionString();
final String str2 = this.mVersionHelper.getFileDateString();
Object localObject = "Unknown size";
long l = this.mVersionHelper.getFileSizeBytes();
if (l >= 0L) {
localObject = String.format(Locale.US, "%.2f", new Object[] { Float.valueOf((float)l / 1048576.0F) }) + " MB";
}
for (;;)
{
localTextView.setText(getString(R.string.hockeyapp_update_version_details_label, new Object[] { str1, str2, localObject }));
((Button)findViewById(R.id.button_update)).setOnClickListener(this);
localObject = (WebView)findViewById(R.id.web_update_details);
((WebView)localObject).clearCache(true);
((WebView)localObject).destroyDrawingCache();
((WebView)localObject).loadDataWithBaseURL("https://sdk.hockeyapp.net/", getReleaseNotes(), "text/html", "utf-8", null);
return;
AsyncTaskUtils.execute(new GetFileSizeTask(this, getIntent().getStringExtra("url"), new DownloadFileListener()
{
public final void downloadSuccessful(DownloadFileTask paramAnonymousDownloadFileTask)
{
if ((paramAnonymousDownloadFileTask instanceof GetFileSizeTask))
{
long l = ((GetFileSizeTask)paramAnonymousDownloadFileTask).getSize();
paramAnonymousDownloadFileTask = String.format(Locale.US, "%.2f", new Object[] { Float.valueOf((float)l / 1048576.0F) }) + " MB";
localTextView.setText(UpdateActivity.this.getString(R.string.hockeyapp_update_version_details_label, new Object[] { str1, str2, paramAnonymousDownloadFileTask }));
}
}
}));
}
}
protected void createDownloadTask(String paramString, DownloadFileListener paramDownloadFileListener)
{
this.mDownloadTask = new DownloadFileTask(this, paramString, paramDownloadFileListener);
}
public void enableUpdateButton()
{
findViewById(R.id.button_update).setEnabled(true);
}
public String getAppName()
{
try
{
Object localObject = getPackageManager();
localObject = ((PackageManager)localObject).getApplicationLabel(((PackageManager)localObject).getApplicationInfo(getPackageName(), 0)).toString();
return (String)localObject;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException) {}
return "";
}
public int getCurrentVersionCode()
{
try
{
int i = getPackageManager().getPackageInfo(getPackageName(), 128).versionCode;
return i;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException) {}
return -1;
}
@SuppressLint({"InflateParams"})
public View getLayoutView()
{
return getLayoutInflater().inflate(R.layout.hockeyapp_activity_update, null);
}
protected String getReleaseNotes()
{
return this.mVersionHelper.getReleaseNotes(false);
}
public void onClick(View paramView)
{
prepareDownload();
paramView.setEnabled(false);
}
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
setTitle("App Update");
setContentView(getLayoutView());
this.b = this;
this.mVersionHelper = new VersionHelper(this, getIntent().getStringExtra("json"), this);
configureView();
this.mDownloadTask = ((DownloadFileTask)getLastNonConfigurationInstance());
if (this.mDownloadTask != null) {
this.mDownloadTask.attach(this);
}
}
protected Dialog onCreateDialog(int paramInt)
{
return onCreateDialog(paramInt, null);
}
protected Dialog onCreateDialog(int paramInt, Bundle paramBundle)
{
switch (paramInt)
{
default:
return null;
}
new AlertDialog.Builder(this).setMessage("An error has occured").setCancelable(false).setTitle("Error").setIcon(17301543).setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public final void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
{
UpdateActivity.a(UpdateActivity.this);
paramAnonymousDialogInterface.cancel();
}
}).create();
}
protected void onPrepareDialog(int paramInt, Dialog paramDialog)
{
switch (paramInt)
{
default:
return;
}
paramDialog = (AlertDialog)paramDialog;
if (this.a != null)
{
paramDialog.setMessage(this.a.getMessage());
return;
}
paramDialog.setMessage("An unknown error has occured.");
}
public void onRequestPermissionsResult(int paramInt, String[] paramArrayOfString, int[] paramArrayOfInt)
{
enableUpdateButton();
if ((paramArrayOfString.length == 0) || (paramArrayOfInt.length == 0)) {}
while (paramInt != 1) {
return;
}
if (paramArrayOfInt[0] == 0)
{
prepareDownload();
return;
}
HockeyLog.warn("User denied write permission, can't continue with updater task.");
paramArrayOfString = UpdateManager.getLastListener();
if (paramArrayOfString != null)
{
paramArrayOfString.onUpdatePermissionsNotGranted();
return;
}
new AlertDialog.Builder(this.b).setTitle(getString(R.string.hockeyapp_permission_update_title)).setMessage(getString(R.string.hockeyapp_permission_update_message)).setNegativeButton(getString(R.string.hockeyapp_permission_dialog_negative_button), null).setPositiveButton(getString(R.string.hockeyapp_permission_dialog_positive_button), new DialogInterface.OnClickListener()
{
public final void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
{
jdField_this.prepareDownload();
}
}).create().show();
}
public Object onRetainNonConfigurationInstance()
{
if (this.mDownloadTask != null) {
this.mDownloadTask.detach();
}
return this.mDownloadTask;
}
protected void prepareDownload()
{
if (!Util.isConnectedToNetwork(this.b))
{
this.a = new ErrorObject();
this.a.setMessage(getString(R.string.hockeyapp_error_no_network_message));
runOnUiThread(new Runnable()
{
public final void run()
{
UpdateActivity.this.showDialog(0);
}
});
return;
}
int i;
if (this.b.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
i = 1;
}
while (i == 0) {
if (Build.VERSION.SDK_INT >= 23)
{
requestPermissions(new String[] { "android.permission.WRITE_EXTERNAL_STORAGE" }, 1);
return;
i = 0;
}
else
{
this.a = new ErrorObject();
this.a.setMessage("The permission to access the external storage permission is not set. Please contact the developer.");
runOnUiThread(new Runnable()
{
public final void run()
{
UpdateActivity.this.showDialog(0);
}
});
return;
}
}
if (!a())
{
this.a = new ErrorObject();
this.a.setMessage("The installation from unknown sources is not enabled. Please check the device settings.");
runOnUiThread(new Runnable()
{
public final void run()
{
UpdateActivity.this.showDialog(0);
}
});
return;
}
startDownloadTask();
}
protected void startDownloadTask()
{
startDownloadTask(getIntent().getStringExtra("url"));
}
protected void startDownloadTask(String paramString)
{
createDownloadTask(paramString, new DownloadFileListener()
{
public final void downloadFailed(DownloadFileTask paramAnonymousDownloadFileTask, Boolean paramAnonymousBoolean)
{
if (paramAnonymousBoolean.booleanValue())
{
UpdateActivity.this.startDownloadTask();
return;
}
UpdateActivity.this.enableUpdateButton();
}
public final void downloadSuccessful(DownloadFileTask paramAnonymousDownloadFileTask)
{
UpdateActivity.this.enableUpdateButton();
}
});
AsyncTaskUtils.execute(this.mDownloadTask);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/net/hockeyapp/android/UpdateActivity.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/