Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreferencesFragement #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</activity>

<activity android:name=".activity.TrackLogger" android:label="@string/tracklogger" android:launchMode="singleTop"/>
<activity android:name=".activity.Preferences" android:label="@string/prefs" />
<activity android:name=".activity.SetPreferenceActivity" android:label="@string/prefs" />
<activity android:name=".activity.WaypointList" android:label="@string/wplist" />
<activity android:name=".activity.TrackDetail" android:label="@string/trackdetail" />
<activity android:name=".activity.OpenStreetMapUpload" android:label="@string/osm_upload">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
break;
case R.id.displaytrackmap_menu_settings:
// Start settings activity
startActivity(new Intent(this, Preferences.class));
Intent intent = new Intent();
intent.setClass(DisplayTrackMap.this, SetPreferenceActivity.class);
startActivityForResult(intent, 0);
break;
}
return super.onOptionsItemSelected(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.provider.Settings;

Expand All @@ -25,7 +25,7 @@
* @author Nicolas Guillaumin
*
*/
public class Preferences extends PreferenceActivity {
public class Preferences extends PreferenceFragment {

@SuppressWarnings("unused")
private static final String TAG = Preferences.class.getSimpleName();
Expand All @@ -41,13 +41,13 @@ public class Preferences extends PreferenceActivity {
private static final String LAYOUT_FILE_EXTENSION = ".xml";

@Override
protected void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);

// Set summary of some preferences to their actual values
// and register a change listener to set again the summary in case of change
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

// External storage directory
EditTextPreference storageDirPref = (EditTextPreference) findPreference(OSMTracker.Preferences.KEY_STORAGE_DIR);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package me.guillaumin.android.osmtracker.activity;

import android.app.Activity;
import android.os.Bundle;

public class SetPreferenceActivity extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);

getFragmentManager().beginTransaction().replace(android.R.id.content,
new Preferences()).commit();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ActivityInfo;
import android.location.LocationManager;
import android.net.Uri;
Expand Down Expand Up @@ -336,8 +335,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
break;
case R.id.tracklogger_menu_settings:
// Start settings activity
startActivity(new Intent(this, Preferences.class));
Intent intent = new Intent();
intent.setClass(TrackLogger.this, SetPreferenceActivity.class);
startActivityForResult(intent, 0);
break;
case R.id.tracklogger_menu_waypointlist:
// Start Waypoint list activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ public void onClick(DialogInterface dialog, int which) {
}).create().show();
break;
case R.id.trackmgr_menu_settings:
// Start settings activity
startActivity(new Intent(this, Preferences.class));
Intent intent = new Intent();
intent.setClass(TrackManager.this, SetPreferenceActivity.class);
startActivityForResult(intent, 0);
break;
case R.id.trackmgr_menu_about:
// Start About activity
Expand Down