A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/signalapp/Signal-Android/commit/1669731329bcc32c84e33035a67a2fc22444c24b below:

Support for using Signal without Play Services · signalapp/Signal-Android@1669731 · GitHub

1 1

package org.thoughtcrime.securesms;

2 2 3 3

import android.content.ActivityNotFoundException;

4 +

import android.content.Context;

4 5

import android.content.DialogInterface;

5 6

import android.content.Intent;

6 7

import android.net.Uri;

20 21

import android.widget.Toast;

21 22 22 23

import com.google.android.gms.common.ConnectionResult;

24 +

import com.google.android.gms.common.GoogleApiAvailability;

23 25

import com.google.android.gms.common.GooglePlayServicesUtil;

24 26

import com.google.i18n.phonenumbers.AsYouTypeFormatter;

25 27

import com.google.i18n.phonenumbers.NumberParseException;

@@ -44,6 +46,13 @@ public class RegistrationActivity extends BaseActionBarActivity {

44 46

private static final int PICK_COUNTRY = 1;

45 47

private static final String TAG = RegistrationActivity.class.getSimpleName();

46 48 49 +

private enum PlayServicesStatus {

50 +

SUCCESS,

51 +

MISSING,

52 +

NEEDS_UPDATE,

53 +

TRANSIENT_ERROR

54 +

}

55 + 47 56

private AsYouTypeFormatter countryFormatter;

48 57

private ArrayAdapter<String> countrySpinnerAdapter;

49 58

private Spinner countrySpinner;

@@ -211,35 +220,81 @@ public void onClick(View v) {

211 220

return;

212 221

}

213 222 214 -

int gcmStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(self);

223 +

PlayServicesStatus gcmStatus = checkPlayServices(self);

215 224 216 -

if (gcmStatus != ConnectionResult.SUCCESS) {

217 -

if (GooglePlayServicesUtil.isUserRecoverableError(gcmStatus)) {

218 -

GooglePlayServicesUtil.getErrorDialog(gcmStatus, self, 9000).show();

219 -

} else {

220 -

Dialogs.showAlertDialog(self, getString(R.string.RegistrationActivity_unsupported),

221 -

getString(R.string.RegistrationActivity_sorry_this_device_is_not_supported_for_data_messaging));

222 -

}

223 -

return;

225 +

if (gcmStatus == PlayServicesStatus.SUCCESS) {

226 +

promptForRegistrationStart(self, e164number, true);

227 +

} else if (gcmStatus == PlayServicesStatus.MISSING) {

228 +

promptForNoPlayServices(self, e164number);

229 +

} else if (gcmStatus == PlayServicesStatus.NEEDS_UPDATE) {

230 +

GoogleApiAvailability.getInstance().getErrorDialog(self, ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED, 0);

231 +

} else {

232 +

Dialogs.showAlertDialog(self, getString(R.string.RegistrationActivity_play_services_error),

233 +

getString(R.string.RegistrationActivity_google_play_services_is_updating_or_unavailable));

224 234

}

235 +

}

225 236 226 -

AlertDialog.Builder dialog = new AlertDialog.Builder(self);

237 +

private void promptForRegistrationStart(final Context context, final String e164number, final boolean gcmSupported) {

238 +

AlertDialog.Builder dialog = new AlertDialog.Builder(context);

227 239

dialog.setTitle(PhoneNumberFormatter.getInternationalFormatFromE164(e164number));

228 240

dialog.setMessage(R.string.RegistrationActivity_we_will_now_verify_that_the_following_number_is_associated_with_your_device_s);

229 241

dialog.setPositiveButton(getString(R.string.RegistrationActivity_continue),

230 242

new DialogInterface.OnClickListener() {

231 243

@Override

232 244

public void onClick(DialogInterface dialog, int which) {

233 -

Intent intent = new Intent(self, RegistrationProgressActivity.class);

234 -

intent.putExtra("e164number", e164number);

235 -

intent.putExtra("master_secret", masterSecret);

245 +

Intent intent = new Intent(context, RegistrationProgressActivity.class);

246 +

intent.putExtra(RegistrationProgressActivity.NUMBER_EXTRA, e164number);

247 +

intent.putExtra(RegistrationProgressActivity.MASTER_SECRET_EXTRA, masterSecret);

248 +

intent.putExtra(RegistrationProgressActivity.GCM_SUPPORTED_EXTRA, gcmSupported);

236 249

startActivity(intent);

237 250

finish();

238 251

}

239 252

});

240 253

dialog.setNegativeButton(getString(R.string.RegistrationActivity_edit), null);

241 254

dialog.show();

242 255

}

256 + 257 +

private void promptForNoPlayServices(final Context context, final String e164number) {

258 +

AlertDialog.Builder dialog = new AlertDialog.Builder(context);

259 +

dialog.setTitle(R.string.RegistrationActivity_missing_google_play_services);

260 +

dialog.setMessage(R.string.RegistrationActivity_this_device_is_missing_google_play_services);

261 +

dialog.setPositiveButton(R.string.RegistrationActivity_i_understand, new DialogInterface.OnClickListener() {

262 +

@Override

263 +

public void onClick(DialogInterface dialog, int which) {

264 +

promptForRegistrationStart(context, e164number, false);

265 +

}

266 +

});

267 +

dialog.setNegativeButton(android.R.string.cancel, null);

268 +

dialog.show();

269 +

}

270 + 271 +

private PlayServicesStatus checkPlayServices(Context context) {

272 +

int gcmStatus = 0;

273 + 274 +

try {

275 +

gcmStatus = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);

276 +

} catch (Throwable t) {

277 +

Log.w(TAG, t);

278 +

return PlayServicesStatus.MISSING;

279 +

}

280 + 281 +

Log.w(TAG, "Play Services: " + gcmStatus);

282 + 283 +

switch (gcmStatus) {

284 +

case ConnectionResult.SUCCESS:

285 +

return PlayServicesStatus.SUCCESS;

286 +

case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:

287 +

return PlayServicesStatus.NEEDS_UPDATE;

288 +

case ConnectionResult.SERVICE_DISABLED:

289 +

case ConnectionResult.SERVICE_MISSING:

290 +

case ConnectionResult.SERVICE_INVALID:

291 +

case ConnectionResult.API_UNAVAILABLE:

292 +

case ConnectionResult.SERVICE_MISSING_PERMISSION:

293 +

return PlayServicesStatus.MISSING;

294 +

default:

295 +

return PlayServicesStatus.TRANSIENT_ERROR;

296 +

}

297 +

}

243 298

}

244 299 245 300

private class CountryCodeChangedListener implements TextWatcher {


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4