Skip to content

Commit

Permalink
Update the calibration dialog. (sky-map-team#453)
Browse files Browse the repository at this point in the history
* Change the calibration video.

* Reword the calibration dialog, especially when it's user-initiated and
move the text out of the html to make it translatable.

* Updates the calibration dialog again. Provides a landscape version.
Have been unable to get the imaged properly centered though and need to
test this on different form factors.

* Remove the code that hacked the calibration dialog's appearance.

* Crop the image a bit.
  • Loading branch information
jaydeetay authored Dec 28, 2021
1 parent ce8cfcf commit b296f6e
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 35 deletions.
6 changes: 6 additions & 0 deletions app/src/main/assets/html/animated_gif_wrapper.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html style="margin: 0;">
<body">
<!-- To work around Android's rubbish animated gif support -->
<img src="file:///android_asset/html/calib.gif"/>
</body>
</html>
Binary file modified app/src/main/assets/html/calib.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 0 additions & 19 deletions app/src/main/assets/html/how_to_calibrate.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,31 @@ protected void onCreate(Bundle savedInstanceState) {
.compassCalibrationModule(new CompassCalibrationModule(this)).build().inject(this);

setContentView(R.layout.activity_compass_calibration);
WebView web = (WebView) findViewById(R.id.compass_calib_activity_webview);
web.loadUrl("file:///android_asset/html/how_to_calibrate.html");
WebView web = findViewById(R.id.compass_calib_activity_webview);
web.loadUrl("file:///android_asset/html/animated_gif_wrapper.html");

checkBoxView = (CheckBox) findViewById(R.id.compass_calib_activity_donotshow);
checkBoxView = findViewById(R.id.compass_calib_activity_donotshow);
boolean hideCheckbox = getIntent().getBooleanExtra(HIDE_CHECKBOX, false);
String whatToDoText;
if (hideCheckbox) {
// Dialog was user-initiated.
checkBoxView.setVisibility(View.GONE);
View reasonText = findViewById(R.id.compass_calib_activity_explain_why);
reasonText.setVisibility(View.GONE);
whatToDoText = getString(R.string.compass_calib_what_to_do_user);
} else {
checkBoxView.setVisibility(View.VISIBLE);
View reasonText = findViewById(R.id.compass_calib_activity_explain_why);
reasonText.setVisibility(View.VISIBLE);
whatToDoText = getString(R.string.compass_calib_what_to_do);
}
TextView explanationText = findViewById(R.id.compass_calib_what_to_do);
explanationText.setText(String.format(whatToDoText,
"https://www.youtube.com/watch?v=-Uq7AmSAjt8"));

if (sensorManager != null) {
magneticSensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
}
magneticSensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
if (magneticSensor == null) {
((TextView) findViewById(R.id.compass_calib_activity_compass_accuracy)).setText(
getString(R.string.sensor_absent));
Expand All @@ -62,17 +76,19 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onResume() {
super.onResume();
if (magneticSensor != null) {
if (magneticSensor != null && sensorManager != null) {
sensorManager.registerListener(this, magneticSensor, SensorManager.SENSOR_DELAY_UI);
}
}

@Override
public void onPause() {
super.onPause();
sensorManager.unregisterListener(this);
if (sensorManager != null) {
sensorManager.unregisterListener(this);
}
if (checkBoxView.isChecked()) {
sharedPreferences.edit().putBoolean(DONT_SHOW_CALIBRATION_DIALOG, true).commit();
sharedPreferences.edit().putBoolean(DONT_SHOW_CALIBRATION_DIALOG, true).apply();
}
}

Expand Down
89 changes: 89 additions & 0 deletions app/src/main/res/layout-land/activity_compass_calibration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.google.android.stardroid.activities.CompassCalibrationActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<WebView
android:id="@+id/compass_calib_activity_webview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/white" />

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/text_margin"
android:layout_weight="2">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/compass_calibration_activity_warning"
android:id="@+id/compass_calib_activity_explain_why"/>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/compass_calibration_activity_heading_compass"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/compass_calib_activity_compass_accuracy"
android:text="accuracy: unknown"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:paddingRight="5dp"/>

</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/compass_calibration_activity_warning"
android:autoLink="web"
android:id="@+id/compass_calib_what_to_do"/>

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/compass_calibration_activity_do_not_show_this_again"
android:id="@+id/compass_calib_activity_donotshow"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@android:string/ok"
android:layout_gravity="center_horizontal"
android:nestedScrollingEnabled="false"
android:onClick="onOkClicked"/>

</LinearLayout>


</LinearLayout>
</androidx.core.widget.NestedScrollView>
16 changes: 12 additions & 4 deletions app/src/main/res/layout/activity_compass_calibration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
android:layout_height="match_parent"
android:orientation="vertical">

<WebView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/compass_calib_activity_webview"
android:background="@android:color/black"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -46,11 +52,13 @@

</LinearLayout>

<WebView
android:layout_width="match_parent"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/compass_calib_activity_webview"
android:background="@android:color/black"/>
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/compass_calibration_activity_warning"
android:autoLink="web"
android:id="@+id/compass_calib_what_to_do"/>

<CheckBox
android:layout_width="wrap_content"
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,20 @@
<string name="menu_calibrate">Calibrate</string>
<string name="compass_calibration_activity_heading_compass">Compass -</string>
<string name="compass_calibration_activity_do_not_show_this_again">Do not show this again</string>
<string name="compass_calibration_activity_warning">Your compass needs to be calibrated</string>
<string name="compass_calibration_activity_warning">Your compass may need to be
calibrated</string>
<string name="compass_calib_what_to_do"
translation_description="Information for the user on how to calibrate the compass when the dialog auto-opens. Placeholder is the video URL">Your phone is reporting to Sky
Map that its internal compass is uncalibrated.
This is not a Sky Map issue but we can help you try to fix it. To calibrate the compass try moving your phone in a figure of eight
motion as demonstrated in this video %s until the accuracy reads \'high\'.</string>
<string name="compass_calib_what_to_do_user"
transation_description="Information for the user on how to calibrate the compass when they invoke the calibration dialog. Placeholder is the video URL">Your phone\'s
compass
accuracy is shown above.
If it is not \'high\' then the compass may need calibrating. This is not a Sky Map issue, but
a property of your phone. To calibrate the compass try moving your phone in a figure of eight
motion as demonstrated in this video %s.</string>
<string name="sensor_reverse_preference_title">Reverse Magnetic Z</string>
<string name="sensor_reverse_preference_summary">Fix for phones with incorrectly implemented sensors - requires restart</string>
<string name="whats_new_dialog_title">What\'s new</string>
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/res/values/whatsnew.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
<string name="whats_new_text" translation_description="Description of new features in this version in html">
<![CDATA[
<h1>New in version %s</h1>
\t • Added Comet Leonard which will be visible through binoculars for a few days around Christmas <br/>
\t • Major re-working and simplification of the code - this should allow more features to be added in the future! <br/>
\t • Persian Translations (Credit: MLDFRJDN) <br/>
\t • Assorted other translation fixes (e.g. credit VegaDark for Spanish, Aga-C for Polish, VasilisKos for Greek, FTNo for Norwegian and more. <br/>
\t • Clarified the calibration dialog text. <br/>
]]>
</string>
</resources>

0 comments on commit b296f6e

Please sign in to comment.