Skip to content

Commit

Permalink
Merge pull request #69 from sky-map-team/allowautomodeevenforphoneswh…
Browse files Browse the repository at this point in the history
…ichreportnocompass

Change the way we deal with devices lacking a sensor.
  • Loading branch information
jaydeetay committed Mar 9, 2016
2 parents f063181 + 921fcb2 commit 0023b4b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.google.android.stardroid"
minSdkVersion 15
targetSdkVersion 23
versionCode 1405
versionName "1.8.1"
versionCode 1407
versionName "1.8.2"
buildConfigField 'String', 'GOOGLE_ANALYTICS_CODE', '""'
}
signingConfigs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import com.google.android.stardroid.activities.util.ActivityLightLevelChanger.NightModeable;
import com.google.android.stardroid.activities.util.ActivityLightLevelManager;
import com.google.android.stardroid.activities.util.FullscreenControlsManager;
import com.google.android.stardroid.base.Lists;
import com.google.android.stardroid.control.AstronomerModel;
import com.google.android.stardroid.control.AstronomerModel.Pointing;
import com.google.android.stardroid.control.ControllerGroup;
Expand Down Expand Up @@ -141,7 +142,6 @@ public void run() {
private RendererController rendererController;
private boolean nightMode = false;
private boolean searchMode = false;
private boolean disableAutoMode = false;
private GeocentricCoordinates searchTarget = GeocentricCoordinates.getInstance(0, 0);
private SharedPreferences sharedPreferences;
private GLSurfaceView skyView;
Expand Down Expand Up @@ -213,6 +213,7 @@ public void onCreate(Bundle icicle) {
this);

initializeModelViewController();
checkForSensorsAndMaybeWarn();

// Search related
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
Expand Down Expand Up @@ -254,24 +255,22 @@ private void checkForSensorsAndMaybeWarn() {
return;
}
// Missing at least one sensor. Warn the user.
disableAutoMode = true;
handler.post(new Runnable() {
@Override
public void run() {
if (!sharedPreferences.getBoolean(NO_WARN_ABOUT_MISSING_SENSORS, false)) {
Log.d(TAG, "showing no sensor dialog");
// TODO(jontayler): refactor to use dialog fragments.
showDialog(DialogFactory.DIALOG_ID_NO_SENSORS);
// First time, force manual mode.
sharedPreferences.edit().putBoolean(AUTO_MODE_PREF_KEY, false).apply();
setAutoMode(false);
} else {
Log.d(TAG, "showing no sensor toast");
Toast.makeText(
DynamicStarMapActivity.this, R.string.no_sensor_warning, Toast.LENGTH_LONG).show();
// Don't force manual mode second time through - leave it up to the user.
}
// Force manual mode and remove the button
sharedPreferences.edit().putBoolean(AUTO_MODE_PREF_KEY, false).apply();
setAutoMode(false);
findViewById(R.id.layer_manual_auto_toggle).setVisibility(View.INVISIBLE);
disableAutoMode = true;
}
});
}
Expand Down Expand Up @@ -596,7 +595,6 @@ private void initializeModelViewController() {
Log.i(TAG, "Set up controllers @ " + System.currentTimeMillis());
controller = ControllerGroup.createControllerGroup(this);
controller.setModel(model);
checkForSensorsAndMaybeWarn();
wireUpScreenControls(); // TODO(johntaylor) move these?
magneticSwitcher = new MagneticDeclinationCalculatorSwitcher(model, sharedPreferences);
wireUpTimePlayer(); // TODO(widdows) move these?
Expand Down Expand Up @@ -625,19 +623,13 @@ public void onClick(View v) {
buttonViews.add(button);
}
buttonViews.add(findViewById(R.id.manual_auto_toggle));
ButtonLayerView manualButtonLayer = (ButtonLayerView) findViewById(R.id.layer_manual_auto_toggle);

List<View> viewsToShowOrHide = new ArrayList<>();
if (!disableAutoMode) {
// We don't want this coming back on a screen tap if the phone doesn't support manual mode.
viewsToShowOrHide.add(manualButtonLayer);
}
viewsToShowOrHide.add(providerButtons);
ButtonLayerView manualButtonLayer = (ButtonLayerView) findViewById(
R.id.layer_manual_auto_toggle);

fullscreenControlsManager = new FullscreenControlsManager(
this,
findViewById(R.id.main_sky_view),
viewsToShowOrHide,
Lists.<View>asList(manualButtonLayer, providerButtons),
buttonViews);

MapMover mapMover = new MapMover(model, controller, this);
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,19 @@
<string name="puppidvelids" translation_description="Meteor Shower">Puppid-Velids</string>
<string name="ursids" translation_description="Meteor Shower">Ursids</string>

<string name="no_sensor_warning">Your device lacks orientation sensors - automode unavailable</string>
<string name="warning_dialog_title">Warning</string>
<string name="no_sensor_warning">Your device may lack orientation sensors - automode may not work</string>
<string name="warning_dialog_title">Bad news!</string>
<string name="missing_sensor_dialog_text">\n
Unfortunately your device does not have one of the
Unfortunately your device might not have one of the
sensors that Sky Map needs.\n\n
To show you the sky in the direction your phone is pointing Sky Map
needs both a built-in compass and an accelerometer.\n\n
You can still use Sky Map on this device,
but only in manual mode where you drag, rotate and stretch the map manually with your fingers.
needs both a built-in compass and an accelerometer. Your device reports that it is missing
one of them. The good news is that some devices (for example some Moto E phones) falsely claim
not to have a compass but actually do.\n\n

If your device really is missing a sensor then auto-mode will not work. However, you
can still use Sky Map on this device in manual mode where you drag, rotate and stretch the
map with your fingers.
</string>
<string name="do_not_show_again">Do not show this message again</string>
</resources>

0 comments on commit 0023b4b

Please sign in to comment.