forked from commonsguy/cw-omnibus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better support for devices without the Play Store
- Loading branch information
1 parent
2bce24e
commit 472d67f
Showing
11 changed files
with
538 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
MapsV2/Basic/src/com/commonsware/android/mapsv2/basic/AbstractMapActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/*** | ||
Copyright (c) 2012 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. | ||
From _The Busy Coder's Guide to Android Development_ | ||
http://commonsware.com/Android | ||
*/ | ||
|
||
package com.commonsware.android.mapsv2.basic; | ||
|
||
import android.app.Dialog; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v4.app.DialogFragment; | ||
import android.widget.Toast; | ||
import com.actionbarsherlock.app.SherlockFragmentActivity; | ||
import com.actionbarsherlock.view.Menu; | ||
import com.actionbarsherlock.view.MenuItem; | ||
import com.google.android.gms.common.ConnectionResult; | ||
import com.google.android.gms.common.GooglePlayServicesUtil; | ||
|
||
public class AbstractMapActivity extends SherlockFragmentActivity { | ||
protected static final String TAG_ERROR_DIALOG_FRAGMENT="errorDialog"; | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
getSupportMenuInflater().inflate(R.menu.activity_main, menu); | ||
|
||
return(super.onCreateOptionsMenu(menu)); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
if (item.getItemId() == R.id.legal) { | ||
startActivity(new Intent(this, LegalNoticesActivity.class)); | ||
|
||
return(true); | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
protected boolean readyToGo() { | ||
int status= | ||
GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); | ||
|
||
if (status == ConnectionResult.SUCCESS) { | ||
return(true); | ||
} | ||
else if (GooglePlayServicesUtil.isUserRecoverableError(status)) { | ||
ErrorDialogFragment.newInstance(status) | ||
.show(getSupportFragmentManager(), | ||
TAG_ERROR_DIALOG_FRAGMENT); | ||
} | ||
else { | ||
Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); | ||
finish(); | ||
} | ||
|
||
return(false); | ||
} | ||
|
||
public static class ErrorDialogFragment extends DialogFragment { | ||
static final String ARG_STATUS="status"; | ||
|
||
static ErrorDialogFragment newInstance(int status) { | ||
Bundle args=new Bundle(); | ||
|
||
args.putInt(ARG_STATUS, status); | ||
|
||
ErrorDialogFragment result=new ErrorDialogFragment(); | ||
|
||
result.setArguments(args); | ||
|
||
return(result); | ||
} | ||
|
||
@Override | ||
public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
Bundle args=getArguments(); | ||
|
||
return GooglePlayServicesUtil.getErrorDialog(args.getInt(ARG_STATUS), | ||
getActivity(), 0); | ||
} | ||
|
||
@Override | ||
public void onDismiss(DialogInterface dlg) { | ||
if (getActivity() != null) { | ||
getActivity().finish(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
MapsV2/Location/src/com/commonsware/android/mapsv2/location/AbstractMapActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/*** | ||
Copyright (c) 2012 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. | ||
From _The Busy Coder's Guide to Android Development_ | ||
http://commonsware.com/Android | ||
*/ | ||
|
||
package com.commonsware.android.mapsv2.location; | ||
|
||
import android.app.Dialog; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v4.app.DialogFragment; | ||
import android.widget.Toast; | ||
import com.actionbarsherlock.app.SherlockFragmentActivity; | ||
import com.actionbarsherlock.view.Menu; | ||
import com.actionbarsherlock.view.MenuItem; | ||
import com.google.android.gms.common.ConnectionResult; | ||
import com.google.android.gms.common.GooglePlayServicesUtil; | ||
|
||
public class AbstractMapActivity extends SherlockFragmentActivity { | ||
protected static final String TAG_ERROR_DIALOG_FRAGMENT="errorDialog"; | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
getSupportMenuInflater().inflate(R.menu.activity_main, menu); | ||
|
||
return(super.onCreateOptionsMenu(menu)); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
if (item.getItemId() == R.id.legal) { | ||
startActivity(new Intent(this, LegalNoticesActivity.class)); | ||
|
||
return(true); | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
protected boolean readyToGo() { | ||
int status= | ||
GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); | ||
|
||
if (status == ConnectionResult.SUCCESS) { | ||
return(true); | ||
} | ||
else if (GooglePlayServicesUtil.isUserRecoverableError(status)) { | ||
ErrorDialogFragment.newInstance(status) | ||
.show(getSupportFragmentManager(), | ||
TAG_ERROR_DIALOG_FRAGMENT); | ||
} | ||
else { | ||
Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show(); | ||
finish(); | ||
} | ||
|
||
return(false); | ||
} | ||
|
||
public static class ErrorDialogFragment extends DialogFragment { | ||
static final String ARG_STATUS="status"; | ||
|
||
static ErrorDialogFragment newInstance(int status) { | ||
Bundle args=new Bundle(); | ||
|
||
args.putInt(ARG_STATUS, status); | ||
|
||
ErrorDialogFragment result=new ErrorDialogFragment(); | ||
|
||
result.setArguments(args); | ||
|
||
return(result); | ||
} | ||
|
||
@Override | ||
public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
Bundle args=getArguments(); | ||
|
||
return GooglePlayServicesUtil.getErrorDialog(args.getInt(ARG_STATUS), | ||
getActivity(), 0); | ||
} | ||
|
||
@Override | ||
public void onDismiss(DialogInterface dlg) { | ||
if (getActivity() != null) { | ||
getActivity().finish(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.