Skip to content

Commit

Permalink
Optino to reset SDL config, and show user a message if gyroscope is a…
Browse files Browse the repository at this point in the history
…bsent
  • Loading branch information
pelya committed Mar 9, 2013
1 parent a54f508 commit 7c1805a
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 4 deletions.
52 changes: 52 additions & 0 deletions project/java/Settings.java
Expand Up @@ -70,6 +70,8 @@ Java source code (C) 2009-2012 Sergii Pylypenko
import android.hardware.SensorEventListener;
import android.hardware.SensorEvent;
import android.hardware.Sensor;
import android.widget.Toast;


// TODO: too much code here, split into multiple files, possibly auto-generated menus?
class Settings
Expand Down Expand Up @@ -554,6 +556,7 @@ void run (final MainActivity p)
new RemapHwKeysConfig(),
new ScreenGesturesConfig(),
new VideoSettingsConfig(),
new ResetToDefaultsConfig(),
new OkButton(),
};
showMenuOptionsList(p, options);
Expand Down Expand Up @@ -2333,6 +2336,8 @@ void run (final MainActivity p)
{
if( !Globals.AppUsesGyroscope || !AccelerometerReader.gyro.available(p) )
{
Toast toast = Toast.makeText(p, p.getResources().getString(R.string.calibrate_gyroscope_not_supported), Toast.LENGTH_LONG);
toast.show();
goBack(p);
return;
}
Expand Down Expand Up @@ -2462,6 +2467,53 @@ public void run()
}
}

static class ResetToDefaultsConfig extends Menu
{
String title(final MainActivity p)
{
return p.getResources().getString(R.string.reset_config);
}
boolean enabled()
{
return true;
}
void run (final MainActivity p)
{
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.reset_config_ask));
builder.setMessage(p.getResources().getString(R.string.reset_config_ask));

builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
DeleteSdlConfigOnUpgradeAndRestart(p); // Never returns
dialog.dismiss();
goBack(p);
}
});
builder.setNegativeButton(p.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss();
goBack(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
goBack(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
}


// ===============================================================================================

public static boolean deleteRecursively(File dir)
Expand Down
5 changes: 3 additions & 2 deletions project/java/translations/generate.sh
Expand Up @@ -14,8 +14,9 @@ grep '<string name=' values/strings.xml | while read str; do
trans=`grep "<string name=\"$var\">" $dir/strings.xml`
transtext=`echo $trans | sed 's/<string name=["][^"]*["]>\([^<]*\).*/\1/'`
if [ -z "$transtext" ] ; then
transtext=`./translate.py en $lang "$text"`
echo "$transtext" | grep 'Suspected Terms of Service Abuse' > /dev/null && transtext="$text"
#transtext=`./translate.py en $lang "$text"`
#echo "$transtext" | grep 'Suspected Terms of Service Abuse' > /dev/null && transtext="$text"
transtext="$text"
grep -v "^[<]/resources[>]\$" $dir/strings.xml > $dir/strings.1.xml
echo "<string name=\"$var\">$transtext</string>" >> $dir/strings.1.xml
echo "</resources>" >> $dir/strings.1.xml
Expand Down
6 changes: 6 additions & 0 deletions project/java/translations/values-fr/strings.xml
Expand Up @@ -165,4 +165,10 @@
<string name="not_enough_ram">Not enough RAM</string>
<string name="not_enough_ram_size">This app needs %1$d Mb RAM, your device has %2$d Mb</string>
<string name="ignore">Ignore</string>
<string name="calibrate_gyroscope">Calibrate gyroscope</string>
<string name="calibrate_gyroscope_text">Put your phone on a flat surface</string>
<string name="reset_config">Reset config to defaults</string>
<string name="cancel">Cancel</string>
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</string>
<string name="reset_config_ask">Reset all options to default values?</string>
</resources>
8 changes: 7 additions & 1 deletion project/java/translations/values-ru/strings.xml
Expand Up @@ -17,7 +17,7 @@
<string name="storage_sd">SD карта - %d Мб</string>
<string name="storage_question">Куда сохранять данные приложения</string>
<string name="optional_downloads">Дополнительные загрузки</string>
<string name="ok">ОК</string>
<string name="ok">Продолжить</string>
<string name="controls_arrows">Стрелки / джойстик / Dpad</string>
<string name="controls_trackball">Трекбол</string>
<string name="controls_accel">Акселерометр</string>
Expand Down Expand Up @@ -137,4 +137,10 @@
<string name="not_enough_ram_size">Для запуска приложения нужно %1$d Мб оперативной памяти, на этом устройстве есть %2$d Мб</string>
<string name="ignore">Игнорировать</string>

<string name="calibrate_gyroscope">Калибровать гироскоп</string>
<string name="calibrate_gyroscope_text">Положите устройство на ровную поверхность</string>
<string name="reset_config">Сбросить все настройки</string>
<string name="cancel">Отменить</string>
<string name="calibrate_gyroscope_not_supported">Гироскоп отсутствует</string>
<string name="reset_config_ask">Сбросить все настройки в значения по умолчанию?</string>
</resources>
6 changes: 6 additions & 0 deletions project/java/translations/values-uk/strings.xml
Expand Up @@ -136,4 +136,10 @@
<string name="not_enough_ram">Not enough RAM</string>
<string name="not_enough_ram_size">This app needs %1$d Mb RAM, your device has %2$d Mb</string>
<string name="ignore">Ignore</string>
<string name="calibrate_gyroscope">Calibrate gyroscope</string>
<string name="calibrate_gyroscope_text">Put your phone on a flat surface</string>
<string name="reset_config">Reset config to defaults</string>
<string name="cancel">Cancel</string>
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</string>
<string name="reset_config_ask">Reset all options to default values?</string>
</resources>
7 changes: 6 additions & 1 deletion project/java/translations/values/strings.xml
Expand Up @@ -27,6 +27,7 @@
<string name="optional_downloads">Downloads</string>
<string name="downloads">Downloads</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>

<string name="controls_arrows">Arrows / joystick / dpad</string>
<string name="controls_trackball">Trackball</string>
Expand Down Expand Up @@ -166,6 +167,10 @@
<string name="ignore">Ignore</string>

<string name="calibrate_gyroscope">Calibrate gyroscope</string>
<string name="calibrate_gyroscope_text">Put your phone on a flat surface</string>
<string name="calibrate_gyroscope_text">Put your device on a flat surface</string>
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</string>

<string name="reset_config">Reset config to defaults</string>
<string name="reset_config_ask">Reset all options to default values?</string>

</resources>

0 comments on commit 7c1805a

Please sign in to comment.