[android] add: Settings for GPS tracker.

This commit is contained in:
Alexander Marchuk 2015-12-03 19:40:32 +03:00 committed by Constantin Shalnev
parent 2b1547666c
commit 757513820c
5 changed files with 83 additions and 0 deletions

View file

@ -42,6 +42,8 @@
<string name="pref_tts_language" translatable="false">TtsLanguage</string>
<string name="pref_3d" translatable="false">3D</string>
<string name="pref_3d_buildings" translatable="false">3DBuildings</string>
<string name="pref_track_record_enabled" translatable="false">TrackRecordEnabled</string>
<string name="pref_track_record_length" translatable="false">TrackRecordLength</string>
<string name="pref_showcase_switched_on" translatable="false">DisplayShowcase</string>
<string name="notification_ticker_ltr" translatable="false">%1$s: %2$s</string>

View file

@ -23,4 +23,21 @@
<item>1</item>
<item>2</item>
</string-array>
<string-array name="track_lengths">
<item>@string/duration_1_hour</item>
<item>@string/duration_2_hours</item>
<item>@string/duration_6_hours</item>
<item>@string/duration_12_hours</item>
<item>@string/duration_1_day</item>
</string-array>
<string-array name="track_lengths_values"
translatable="false">
<item>1</item>
<item>2</item>
<item>6</item>
<item>12</item>
<item>24</item>
</string-array>
</resources>

View file

@ -43,4 +43,19 @@
android:title="@string/yopme_pref_title"
android:summary="@string/yopme_pref_summary"
android:order="6"/>
<SwitchPreference
android:key="@string/pref_track_record_enabled"
android:title="@string/pref_track_record_enabled_title"
android:order="7"
android:switchTextOn=""
android:switchTextOff=""/>
<ListPreference
android:key="@string/pref_track_record_length"
android:title="@string/pref_track_record_length_title"
android:dependency="@string/pref_track_record_enabled"
android:entries="@array/track_lengths"
android:entryValues="@array/track_lengths_values"
android:order="8"/>
</PreferenceScreen>

View file

@ -39,4 +39,17 @@
android:title="@string/yopme_pref_title"
android:summary="@string/yopme_pref_summary"
android:order="6"/>
<CheckBoxPreference
android:key="@string/pref_track_record_enabled"
android:title="@string/pref_track_record_enabled_title"
android:order="7"/>
<ListPreference
android:key="@string/pref_track_record_length"
android:title="@string/pref_track_record_length_title"
android:dependency="@string/pref_track_record_enabled"
android:entries="@array/track_lengths"
android:entryValues="@array/track_lengths_values"
android:order="8"/>
</PreferenceScreen>

View file

@ -14,8 +14,10 @@ import com.mapswithme.country.ActiveCountryTree;
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import com.mapswithme.maps.location.TrackRecorder;
import com.mapswithme.util.Config;
import com.mapswithme.util.Yota;
import com.mapswithme.util.concurrency.UiThread;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.Statistics;
@ -151,6 +153,40 @@ public class MapPrefsFragment extends BaseXmlSettingsFragment
});
else
getPreferenceScreen().removePreference(pref);
pref = findPreference(getString(R.string.pref_track_record_enabled));
((TwoStatePreference)pref).setChecked(TrackRecorder.isEnabled());
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
{
TrackRecorder.setEnabled((Boolean)newValue);
return true;
}
});
pref = findPreference(getString(R.string.pref_track_record_length));
String value = String.valueOf(TrackRecorder.getDuration());
((ListPreference)pref).setValue(value);
pref.setSummary(((ListPreference)pref).getEntry());
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(final Preference preference, Object newValue)
{
TrackRecorder.setDuration(Integer.valueOf((String)newValue));
UiThread.runLater(new Runnable()
{
@Override
public void run()
{
preference.setSummary(((ListPreference)preference).getEntry());
}
});
return true;
}
});
}
@Override