mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-08 04:13:06 +02:00
Update strings.
Fix start gps. Open location settngs if gps is not available. Show a toast when clicking on start/stop gps.
This commit is contained in:
@@ -35,6 +35,7 @@ import com.google.android.apps.mytracks.settings.SettingsActivity;
|
||||
import com.google.android.apps.mytracks.util.AnalyticsUtils;
|
||||
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
|
||||
import com.google.android.apps.mytracks.util.EulaUtils;
|
||||
import com.google.android.apps.mytracks.util.GoogleLocationUtils;
|
||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||
import com.google.android.apps.mytracks.util.ListItemUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
@@ -55,6 +56,7 @@ import android.database.Cursor;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.Settings;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
@@ -65,6 +67,7 @@ import android.support.v4.widget.ResourceCursorAdapter;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -509,7 +512,19 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
case R.id.track_list_search:
|
||||
return ApiAdapterFactory.getApiAdapter().handleSearchMenuSelection(this);
|
||||
case R.id.track_list_start_gps:
|
||||
if (!trackDataHub.isGpsProviderEnabled()) {
|
||||
intent = GoogleLocationUtils.isAvailable(TrackListActivity.this) ? new Intent(
|
||||
GoogleLocationUtils.ACTION_GOOGLE_LOCATION_SETTINGS)
|
||||
: new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
startGps = !startGps;
|
||||
Toast toast = Toast.makeText(
|
||||
this, startGps ? R.string.gps_starting : R.string.gps_stopping, Toast.LENGTH_SHORT);
|
||||
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
toast.show();
|
||||
handleStartGps();
|
||||
updateMenuItems(recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT);
|
||||
return true;
|
||||
@@ -634,7 +649,6 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
*/
|
||||
private void updateMenuItems(boolean isRecording) {
|
||||
if (startGpsMenuItem != null) {
|
||||
startGpsMenuItem.setIcon(startGps ? R.drawable.menu_stop_gps : R.drawable.menu_start_gps);
|
||||
startGpsMenuItem.setTitle(startGps ? R.string.menu_stop_gps : R.string.menu_start_gps);
|
||||
startGpsMenuItem.setVisible(!isRecording);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,10 @@ public class DataSource {
|
||||
return myTracksLocationManager.isAllowed();
|
||||
}
|
||||
|
||||
public boolean isGpsProviderEnabled() {
|
||||
return myTracksLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a content observer.
|
||||
*
|
||||
|
||||
@@ -244,6 +244,10 @@ public class TrackDataHub implements DataSourceListener {
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isGpsProviderEnabled() {
|
||||
return dataSource.isGpsProviderEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the selected track is recording.
|
||||
*/
|
||||
|
||||
@@ -93,8 +93,9 @@ public class MyTracksLocationManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the Google location settings allows access to location
|
||||
* data.
|
||||
* Returns true if allowed to access the location manager. Returns true if
|
||||
* there is no Google location settings or the Google location settings allows
|
||||
* access to location data.
|
||||
*/
|
||||
public boolean isAllowed() {
|
||||
return isAllowed;
|
||||
|
||||
Reference in New Issue
Block a user