Add preference specific for profile

This commit is contained in:
Victor Shcherb 2012-08-22 20:43:17 +02:00
parent d1d190b338
commit fc4cd3d762
4 changed files with 36 additions and 42 deletions

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical" >
<TextView android:id="@+id/TextView" android:layout_width="fill_parent" android:textSize="18dp" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginRight="5dp"
android:gravity="center" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:text="@string/select_navigation_mode"></TextView>
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:gravity="center" android:layout_height="wrap_content" android:orientation="horizontal">
<Button android:contentDescription="@string/app_mode_car" android:id="@+id/CarButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/car_icon" android:layout_marginLeft="10dp" />
<Button android:contentDescription="@string/app_mode_bicycle" android:id="@+id/BicycleButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:background="@drawable/bicycle_icon"/>
<Button android:contentDescription="@string/app_mode_pedestrian" android:id="@+id/PedestrianButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:background="@drawable/pedestrian_icon"/>
</LinearLayout>
</LinearLayout>

View file

@ -9,6 +9,7 @@
1. All your modified/created strings are in the top of the file (to make easier find what's translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="select_navigation_mode">Select transportation mode</string>
<string name="monitor_preferences">Tracking</string>
<string name="day_night_info_description">Sunrise : %1$s \nSunset : %2$s</string>
<string name="day_night_info">Day/night info</string>

View file

@ -25,13 +25,13 @@ import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
import net.osmand.plus.activities.CustomTitleBar.CustomTitleBarView;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.views.SeekBarPreference;
import net.osmand.render.RenderingRulesStorage;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
@ -52,10 +52,9 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.ToggleButton;
public class SettingsActivity extends PreferenceActivity implements OnPreferenceChangeListener, OnPreferenceClickListener {
@ -647,53 +646,33 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
title = title.substring(1);
}
Builder builder = new AlertDialog.Builder(this);
View view = getLayoutInflater().inflate(R.layout.calculate_route, null);
View view = getLayoutInflater().inflate(R.layout.navigate_mode, null);
builder.setView(view);
final AlertDialog dlg = builder.show();
final ToggleButton[] buttons = new ToggleButton[ApplicationMode.values().length];
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton);
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
final Button[] buttons = new Button[ApplicationMode.values().length];
buttons[ApplicationMode.CAR.ordinal()] = (Button) view.findViewById(R.id.CarButton);
buttons[ApplicationMode.BICYCLE.ordinal()] = (Button) view.findViewById(R.id.BicycleButton);
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (Button) view.findViewById(R.id.PedestrianButton);
final Dialog scrDialog = scr.getDialog();
final String tlt = " " + title;
for (int i = 0; i < buttons.length; i++) {
if (buttons[i] != null) {
final int ind = i;
ToggleButton b = buttons[i];
b.setChecked(appMode == ApplicationMode.values()[i]);
b.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
final Button b = buttons[i];
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
for (int j = 0; j < buttons.length; j++) {
if (buttons[j] != null) {
if (buttons[j].isChecked() != (ind == j)) {
buttons[j].setChecked(ind == j);
}
}
}
} else {
// revert state
boolean revert = true;
for (int j = 0; j < buttons.length; j++) {
if (buttons[j] != null) {
if (buttons[j].isChecked()) {
revert = false;
break;
}
}
}
if (revert) {
buttons[ind].setChecked(true);
}
}
public void onClick(View v) {
ApplicationMode selected = ApplicationMode.values()[ind];
osmandSettings.APPLICATION_MODE.set(selected);
updateAllSettings();
scrDialog.setTitle(tlt + " [" + selected.toHumanString(SettingsActivity.this) + "]");
dlg.dismiss();
}
});
}
}
scr.getDialog().setTitle(" " + title + " [" + osmandSettings.APPLICATION_MODE.get().toHumanString(this) + "]");
scrDialog.setTitle(tlt);
scr.getDialog().setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {

View file

@ -117,10 +117,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements LockInfoCont
} else {
offlineData.setSummary(offlineData.getSummary() + " " + app.getString(R.string.gpx_index_settings_descr));
}
PreferenceScreen general = (PreferenceScreen) screen.findPreference(SettingsActivity.SCREEN_ID_GENERAL_SETTINGS);
//general.addPreference(activity.createEditTextPreference(settings.LIVE_MONITORING_URL, R.string.live_monitoring_url,
// R.string.live_monitoring_url_descr));
PreferenceCategory cat = new PreferenceCategory(activity);
cat.setTitle(R.string.save_track_to_gpx);