Merge heads

This commit is contained in:
youtaol
2012-06-13 09:50:40 +08:00
21 changed files with 398 additions and 95 deletions
+1
View File
@@ -204,6 +204,7 @@ limitations under the License.
android:name="com.google.android.apps.mytracks.io.maps.ChooseMapActivity" />
<activity android:name="com.google.android.apps.mytracks.io.maps.SendMapsActivity" />
<activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.AccountChooserActivity" />
<activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.ConfirmSharingActivity" />
<activity android:name="com.google.android.apps.mytracks.io.sendtogoogle.UploadResultActivity" />
<activity android:name="com.google.android.apps.mytracks.settings.BackupSettingsActivity" />
<activity android:name="com.google.android.apps.mytracks.settings.ChartSettingsActivity" />
@@ -39,7 +39,6 @@ limitations under the License.
android:layout_width="0dp" >
<RadioButton
android:id="@+id/choose_upload_service_new_map"
android:text="@string/send_google_new_map"
style="@style/TextMedium" />
<RadioButton
android:id="@+id/choose_upload_service_existing_map"
@@ -54,7 +53,7 @@ limitations under the License.
style="@style/ChooseUploadServiceImageView" />
<CheckBox
android:id="@+id/choose_upload_service_fusion_tables"
android:text="@string/send_google_fusion_tables"
android:text="@string/send_google_fusion_tables_new_public_table"
style="@style/ChooseUploadServiceCheckBox" />
</TableRow>
<TableRow>
+39
View File
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2012 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/ScrollView" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingLeft="14dp"
android:paddingRight="10dp"
android:paddingTop="2dp" >
<TextView
android:id="@+id/confirm_sharing_text_view"
android:autoLink="web"
style="@style/TextMedium" />
<CheckBox
android:id="@+id/confirm_sharing_check_box"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_width="fill_parent"
android:text="@string/generic_do_not_show_again"
style="@style/TextMedium" />
</LinearLayout>
</ScrollView>
+12
View File
@@ -72,6 +72,18 @@ limitations under the License.
<TextView
android:text="@string/help_share_friends_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_maps_public_unlisted_question"
style="@style/HelpQuestion" />
<TextView
android:id="@+id/help_maps_public_unlisted_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_google_services_question"
style="@style/HelpQuestion" />
<TextView
android:id="@+id/help_google_services_answer"
style="@style/HelpAnswer" />
<TextView
android:text="@string/help_share_visibility_question"
style="@style/HelpQuestion" />
+1
View File
@@ -16,6 +16,7 @@ limitations under the License.
-->
<resources>
<!-- DO NOT TRANSLATE ANY STRINGS IN THIS FILE. -->
<string name="maps_public_unlisted_url">support.google.com/maps/bin/answer.py?answer=62845</string>
<string name="marker_statistics_icon_url">http://maps.google.com/mapfiles/ms/micons/ylw-pushpin.png</string>
<string name="marker_waypoint_icon_url">http://maps.google.com/mapfiles/ms/micons/blue-pushpin.png</string>
<string name="my_tracks_privacy_url">www.google.com/policies/privacy/</string>
+2 -1
View File
@@ -31,6 +31,7 @@ limitations under the License.
<string name="chart_show_speed_key">chartShowSpeed</string>
<string name="default_activity_key">defaultActivity</string>
<string name="default_map_public_key">defaultMapPublic</string>
<string name="google_account_key">googleAccount</string>
<string name="max_recording_distance_key">maxRecordingDistance</string>
<string name="metric_units_key">metricUnits</string>
<string name="min_recording_distance_key">minRecordingDistance</string>
@@ -44,8 +45,8 @@ limitations under the License.
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
<string name="send_to_maps_key">sendToMaps</string>
<string name="sensor_type_key">sensorType</string>
<string name="sharing_account_key">sharingAccount</string>
<string name="show_check_units_dialog_key">showCheckUnitsDialog</string>
<string name="show_confirm_sharing_dialog_key">showConfrimSharingDialog</string>
<string name="show_welcome_dialog_key">showWelcomeDialog</string>
<string name="split_frequency_key">splitFrequency</string>
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
+90 -38
View File
@@ -615,6 +615,11 @@ limitations under the License.
%1$s description. E.g., 'At the top'.">
Description: %1$s
</string>
<string name="generic_do_not_show_again"
translation_description="When showing a confirmation message, the message in the footer checkbox
to not show the message again.">
Do no show this again.
</string>
<string name="generic_error_title"
translation_description="The title on an alert dialog indicating error.">
Error
@@ -696,8 +701,9 @@ limitations under the License.
translation_description="In the 'Help' page, the answer on delete tracks.">
From the track list, select \"Delete all\" when not recording. This permanently deletes the
recorded tracks from memory. If you have saved tracks or backups on the SD card, you must delete
them separately. Tracks uploaded to Google Maps, Google Fusion Tables, and Google Doc must also
be deleted separately.
them separately. You can access the SD card using any file manager app from the Play Store or
using a USB cable to connect your phone to your computer. Tracks uploaded to Google Maps,
Google Fusion Tables, and Google Docs must also be deleted separately.
</string>
<string name="help_delete_tracks_question"
translation_description="In the 'Help' page, the question on delete tracks.">
@@ -724,6 +730,19 @@ limitations under the License.
translation_description="In the 'Help' page, the question on elevation precision.">
How precise is the elevation measurement?
</string>
<string name="help_google_services_answer"
translation_description="In the 'Help' page, the answer on locations of google services.
%1$s url. E.g., 'maps.google.com'.
%2$s url. E.g., 'google.com/fusiontables'.
%3$s url. E.g., 'docs.google.com'.">
For Google Maps, go to %1$s and click on \"My Places\". For Google Fusion Tables, go to %2$s.
For Google Docs, go to %3$s.
</string>
<string name="help_google_services_question"
translation_description="In the 'Help' page, the question on locations of google services.">
Where are the tracks after sending to Google?
</string>
<string name="help_gps_signal_answer"
translation_description="In the 'Help' page, the answer on the GPS signal message.">
For My Tracks to work, your phone needs to be in line-of-sight contact with the GPS satellites.
@@ -739,13 +758,23 @@ limitations under the License.
translation_description="In the 'Help' page, the answer on location precision.">
Under optimal conditions, the location error can be +/- 20 feet (6 meters). However, precision
depends on the quality of the GPS signal. The blue circle around the orange location arrow
indicates estimated precision. (You may need to zoom in or out to see the circle.) You can
indicates estimated precision. (You may need to zoom in or zoom out to see the circle.) You can
change the GPS precision at Settings -> Recording -> GPS accuracy.
</string>
<string name="help_location_precision_question"
translation_description="In the 'Help' page, the question on location precision.">
How precise are the recorded tracks?
</string>
<string name="help_maps_public_unlisted_answer"
translation_description="In the 'Help' page, the answer on public versus unlisted maps.
%1$s url. E.g., 'support.google.com/maps/bin/answer.py?answer=62845'.">
See %1$s.
</string>
<string name="help_maps_public_unlisted_question"
translation_description="In the 'Help' page, the question on public versus unlsited maps.">
What is the difference between public and unlisted when sending a track to Google Maps?
</string>
<string name="help_marker_answer"
translation_description="In the 'Help' page, the answer on markers.">
Markers are used to annotate a location.
@@ -783,9 +812,10 @@ limitations under the License.
</string>
<string name="help_share_visibility_answer"
translation_description="In the 'Help' page, the answer on share visibility.">
By default, tracks sent to Google Maps and Google Fusion Tables are public, while tracks sent to
Google Docs are private. You can change the visibility of your tracks in Google Maps, Google
Fusion, and Google Docs.
By default, tracks sent to Google Maps are unlisted, tracks sent to Google Fusion Tables are
public, and tracks sent to Google Docs are private. For Google Maps, you can change the
default between public and unlisted via Settings -> Sharing. After uploading tracks, you can
change their visibility in Google Maps, Google Fusion Tables, and Google Docs.
</string>
<string name="help_share_visibility_question"
translation_description="In the 'Help' page, the question on share visibility.">
@@ -793,8 +823,8 @@ limitations under the License.
</string>
<string name="help_split_marker_answer"
translation_description="In the 'Help' page, the answer on split markers.">
The split markers are used to segment a track to calculate statistics for each segment. Split
markers are inserted by setting the split frequency in the menu.
Split markers are used to segment a track to calculate statistics for each segment. Split
markers are inserted by setting the split frequency from the menu.
</string>
<string name="help_split_marker_question"
translation_description="In the 'Help' page, the question on split markers.">
@@ -1199,12 +1229,6 @@ limitations under the License.
global system search settings.">
Tracks and markers
</string>
<string name="search_hint"
translation_description="The hint shown on the search box until the user types a search query.
See suggestion at http://developer.android.com/guide/topics/search/search-dialog.html about
keeping this consistent with other Android apps.">
Search My Tracks
</string>
<string name="search_list_empty_message"
translation_description="Message when the search result is empty.">
No tracks or markers matched your search.
@@ -1251,19 +1275,28 @@ limitations under the License.
Use existing map
</string>
<string name="send_google_fusion_tables"
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
checkbox option to send to Google Fusion Tables.">
translation_description="When sending a track to Google, the Google Fusion Tables name.">
Google Fusion Tables
</string>
<string name="send_google_fusion_tables_new_public_table"
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
checkbox option to send to Google Fusion Tables as a new public table.">
Google Fusion Tables\n(new public table)
</string>
<string name="send_google_maps"
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
checkbox option to send to Google Maps.">
Google Maps
</string>
<string name="send_google_new_map"
<string name="send_google_new_public_map"
translation_description="When sending a track to Google Maps, the radio option to create a
new map as opposed to use an existing map.">
Create new map
new public map as opposed to use an existing map.">
Create new public map
</string>
<string name="send_google_new_unlisted_map"
translation_description="When sending a track to Google Maps, the radio option to create a
new unlisted map as opposed to use an existing map.">
Create new unlisted map
</string>
<string name="send_google_no_account_message"
translation_description="When sending to Google, the dialog message when no Google account is
@@ -1800,14 +1833,6 @@ limitations under the License.
Character limit: ~26 (1 line)">
Sharing
</string>
<string name="settings_sharing_account"
translation_description="In the 'Sharing' settings, the option to switch account.">
Switch account
</string>
<string name="settings_sharing_account_summary"
translation_description="In the 'Sharing' settings, the summary for 'Switch account'.">
Account used when sending a track to Google.
</string>
<string name="settings_sharing_allow_access"
translation_description="In the 'Sharing' settings, the checkbox option to allow third party
apps access to the My Tracks data.
@@ -1836,23 +1861,36 @@ limitations under the License.
Other apps can read, write, start/stop recording My Tracks data.
</string>
<string name="settings_sharing_map_public"
translation_description="In the 'Sharing' settings, the checkbox option to make a new map
created in Google Maps public.
translation_description="In the 'Sharing' settings, the title of the option to make new maps
created in Google Maps public, as opposed to unlisted. See
http://support.google.com/maps/bin/answer.py?answer=62845 for public versus unlisted.
Character limit: ~23 (1 line)">
Make new maps public
</string>
<string name="settings_sharing_map_public_summary_off"
<string name="settings_sharing_map_public_summary"
translation_description="In the 'Sharing' settings, the summary for the 'Make new maps public'
checkbox option when it is unchecked explaining that new maps created in Google Maps will
be unlisted, as opposed to public.">
New maps created in Google Maps will be unlisted.
option explaining that new maps created in Google Maps will be public, as opposed to unlisted.
See http://support.google.com/maps/bin/answer.py?answer=62845 for public versus unlisted.
%1$s url. E.g., 'support.google.com/maps/bin/answer.py?answer=62845'.">
New maps created in Google Maps will be public. See %1$s for more info.
</string>
<string name="settings_sharing_map_public_summary_on"
translation_description="In the 'Sharing' settings, the summary for the 'Make new maps public'
checkbox option when it is checked explaining that new maps created in Google Maps will
be public, as opposed to unlisted.">
New maps created in Google Maps will be public.
<string name="settings_sharing_map_unlisted"
translation_description="In the 'Sharing' settings, the title of the option to make new maps
created in Google Maps unlisted, as opposed to public. See
http://support.google.com/maps/bin/answer.py?answer=62845 for public versus unlisted.
Character limit: ~23 (1 line)">
Make new maps unlisted
</string>
<string name="settings_sharing_map_unlisted_summary"
translation_description="In the 'Sharing' settings, the summary for the 'Make new maps unlisted'
option explaining that new maps created in Google Maps will be unlisted, as opposed to public.
See http://support.google.com/maps/bin/answer.py?answer=62845 for public versus unlisted.
%1$s url. E.g., 'support.google.com/maps/bin/answer.py?answer=62845'.">
New maps created in Google Maps will be unlisted. See %1$s for more info.
</string>
<!-- Settings Show -->
@@ -1903,6 +1941,12 @@ limitations under the License.
Preferred units
</string>
<!-- Settings Switch Account -->
<string name="settings_switch_account"
translation_description="In the 'Settings' page, the option to switch account.">
Switch account
</string>
<!-- Settings Voice -->
<string name="settings_voice_frequency_title"
translation_description="The title of the 'Voice frequency' dialog.">
@@ -1910,6 +1954,14 @@ limitations under the License.
</string>
<!-- Share Track -->
<string name="share_track_confirm_message"
translation_description="The confirmation message when sharing a track with friends.
%1$s url. E.g., 'support.google.com/maps/bin/answer.py?answer=62845'.">
This will upload your track to Google Maps so that you can share the map url with friends. The
map will be either public or unlisted depending on your setting at Settings -> Sharing. For more
info on public versus unlisted, see %1$s.
</string>
<string name="share_track_picker_title"
translation_description="When sharing a track with friends, the title on the picker to ask
the user to select an application.">
+2
View File
@@ -36,6 +36,7 @@ limitations under the License.
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:layout_width">0dp</item>
<item name="android:maxLines">5</item>
</style>
<!-- The style for choose upload service image view -->
<style name="ChooseUploadServiceImageView">
@@ -71,6 +72,7 @@ limitations under the License.
</style>
<!-- The style for the help answer -->
<style name="HelpAnswer" parent="@style/TextSmall">
<item name="android:autoLink">web</item>
<item name="android:paddingBottom">8dp</item>
</style>
<!-- The style for help question -->
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/search_hint"
android:hint="@string/menu_search"
android:imeOptions="actionSearch"
android:includeInGlobalSearch="true"
android:label="@string/my_tracks_app_name"
+4
View File
@@ -44,6 +44,10 @@ limitations under the License.
android:key="@string/settings_backup_key"
android:persistent="false"
android:title="@string/settings_backup" />
<ListPreference
android:defaultValue=""
android:key="@string/google_account_key"
android:title="@string/settings_switch_account" />
<Preference
android:key="@string/settings_reset_key"
android:persistent="false"
+2 -10
View File
@@ -16,17 +16,9 @@ limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/settings_sharing" >
<ListPreference
android:defaultValue=""
android:key="@string/sharing_account_key"
android:summary="@string/settings_sharing_account_summary"
android:title="@string/settings_sharing_account" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/default_map_public_key"
android:summaryOff="@string/settings_sharing_map_public_summary_off"
android:summaryOn="@string/settings_sharing_map_public_summary_on"
android:title="@string/settings_sharing_map_public" />
android:defaultValue="false"
android:key="@string/default_map_public_key" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/allow_access_key"
@@ -22,6 +22,7 @@ import com.google.android.maps.mytracks.R;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
/**
* An activity that displays the help page.
@@ -35,6 +36,16 @@ public class HelpActivity extends AbstractMyTracksActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
TextView mapsPublicUnlisted = (TextView) findViewById(R.id.help_maps_public_unlisted_answer);
mapsPublicUnlisted.setText(getString(
R.string.help_maps_public_unlisted_answer, getString(R.string.maps_public_unlisted_url)));
TextView googleServices = (TextView) findViewById(R.id.help_google_services_answer);
googleServices.setText(getString(R.string.help_google_services_answer,
getString(R.string.send_google_maps_url),
getString(R.string.send_google_fusion_tables_url),
getString(R.string.send_google_docs_url)));
findViewById(R.id.help_ok).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
finish();
@@ -16,8 +16,8 @@
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.io.sendtogoogle.AccountChooserActivity;
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
import com.google.android.apps.mytracks.io.sendtogoogle.ConfirmSharingActivity;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.maps.mytracks.R;
@@ -117,7 +117,7 @@ public class ChooseActivityDialogFragment extends DialogFragment {
sendRequest.setNewMap(true);
sendRequest.setSharingAppPackageName(packageName);
sendRequest.setSharingAppClassName(className);
Intent intent = IntentUtils.newIntent(getActivity(), AccountChooserActivity.class)
Intent intent = IntentUtils.newIntent(getActivity(), ConfirmSharingActivity.class)
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
startActivity(intent);
dismiss();
@@ -90,8 +90,14 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
});
mapsOptionTableRow = (TableRow) view.findViewById(R.id.choose_upload_service_maps_options);
RadioButton newMapRadioButton = (RadioButton) view.findViewById(
R.id.choose_upload_service_new_map);
boolean defaultMapPublic = PreferencesUtils.getBoolean(getActivity(),
R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT);
newMapRadioButton.setText(defaultMapPublic ? R.string.send_google_new_public_map
: R.string.send_google_new_unlisted_map);
existingMapRadioButton = (RadioButton) view.findViewById(
R.id.choose_upload_service_existing_map);
@@ -90,15 +90,15 @@ public class AccountChooserActivity extends Activity {
if (accounts.length == 1) {
sendRequest.setAccount(accounts[0]);
PreferencesUtils.setString(this, R.string.sharing_account_key, accounts[0].name);
PreferencesUtils.setString(this, R.string.google_account_key, accounts[0].name);
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
return;
}
String sharingAccount = PreferencesUtils.getString(this, R.string.sharing_account_key,
PreferencesUtils.SHARING_ACCOUNT_DEFAULT);
String googleAccount = PreferencesUtils.getString(this, R.string.google_account_key,
PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT);
for (int i = 0; i < accounts.length; i++) {
if (accounts[i].name.equals(sharingAccount)) {
if (accounts[i].name.equals(googleAccount)) {
sendRequest.setAccount(accounts[i]);
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
return;
@@ -160,7 +160,7 @@ public class AccountChooserActivity extends Activity {
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
Account account = accounts[position];
PreferencesUtils.setString(
AccountChooserActivity.this, R.string.sharing_account_key, account.name);
AccountChooserActivity.this, R.string.google_account_key, account.name);
sendRequest.setAccount(account);
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
}
@@ -0,0 +1,105 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.apps.mytracks.io.sendtogoogle;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
/**
* An interstitial to confirm sharing with friends.
*
* @author Jimmy Shih
*/
public class ConfirmSharingActivity extends Activity {
private static final int DIALOG_ID = 0;
private SendRequest sendRequest;
private CheckBox checkBox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sendRequest = getIntent().getParcelableExtra(SendRequest.SEND_REQUEST_KEY);
if (PreferencesUtils.getBoolean(this, R.string.show_confirm_sharing_dialog_key,
PreferencesUtils.SHOW_CONFIRM_SHARING_DIALOG_DEFAULT)) {
showDialog(DIALOG_ID);
} else {
startNextActivity();
}
}
@Override
protected Dialog onCreateDialog(int id) {
if (id != DIALOG_ID) {
return null;
}
View view = getLayoutInflater().inflate(R.layout.confirm_sharing, null);
TextView textView = (TextView) view.findViewById(R.id.confirm_sharing_text_view);
textView.setText(getString(
R.string.share_track_confirm_message, getString(R.string.maps_public_unlisted_url)));
checkBox = (CheckBox) view.findViewById(R.id.confirm_sharing_check_box);
DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int button) {
PreferencesUtils.setBoolean(ConfirmSharingActivity.this,
R.string.show_confirm_sharing_dialog_key, !checkBox.isChecked());
startNextActivity();
}
};
DialogInterface.OnClickListener cancelListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int button) {
finish();
}
};
Dialog dialog = DialogUtils.createConfirmationDialog(
this, -1, view, okListener, cancelListener);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
finish();
}
});
return dialog;
}
/**
* Starts the next activity for sharing with friends and finishes this
* activity.
*/
private void startNextActivity() {
Intent intent = IntentUtils.newIntent(this, AccountChooserActivity.class)
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
startActivity(intent);
finish();
}
}
@@ -22,17 +22,24 @@ import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.util.Log;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
/**
* An activity for accessing settings.
*
@@ -44,6 +51,7 @@ public class SettingsActivity extends AbstractSettingsActivity {
private static final String TAG = SettingsActivity.class.getSimpleName();
private static final int DIALOG_CONFIRM_RESET_ID = 0;
private ListPreference googleAccountListPreference;
private Preference resetPreference;
@SuppressWarnings("deprecation")
@@ -123,6 +131,29 @@ public class SettingsActivity extends AbstractSettingsActivity {
}
});
googleAccountListPreference = (ListPreference) findPreference(getString(R.string.google_account_key));
List<String> entries = new ArrayList<String>();
Account[] accounts = AccountManager.get(this).getAccountsByType(Constants.ACCOUNT_TYPE);
for (Account account : accounts) {
entries.add(account.name);
}
googleAccountListPreference.setEntries(entries.toArray(new CharSequence[entries.size()]));
googleAccountListPreference.setEntryValues(entries.toArray(
new CharSequence[entries.size()]));
if (entries.size() == 1) {
googleAccountListPreference.setValueIndex(0);
}
String googleAccount = PreferencesUtils.getString(this, R.string.google_account_key,
PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT);
updateSwitchAccountSummary(googleAccount);
googleAccountListPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
updateSwitchAccountSummary((String) newValue);
return true;
}
});
resetPreference = findPreference(getString(R.string.settings_reset_key));
resetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
@@ -143,6 +174,17 @@ public class SettingsActivity extends AbstractSettingsActivity {
: R.string.settings_reset_summary);
}
/**
* Updates the switch account summary.
*
* @param value the value
*/
private void updateSwitchAccountSummary(String value) {
googleAccountListPreference.setSummary(
PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT.equals(value) ? getString(R.string.value_unknown)
: value);
}
@Override
protected Dialog onCreateDialog(int id) {
if (id != DIALOG_CONFIRM_RESET_ID) {
@@ -16,23 +16,17 @@
package com.google.android.apps.mytracks.settings;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import java.util.ArrayList;
import java.util.List;
/**
* An activity for accessing the sharing settings.
*
@@ -42,6 +36,7 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
private static final int DIALOG_CONFIRM_ALLOW_ACCESS_ID = 0;
private CheckBoxPreference defaultMapPublicCheckBoxPreference;
private CheckBoxPreference allowAccessCheckBoxPreference;
@SuppressWarnings("deprecation")
@@ -50,6 +45,26 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
super.onCreate(bundle);
addPreferencesFromResource(R.xml.sharing_settings);
defaultMapPublicCheckBoxPreference = (CheckBoxPreference) findPreference(
getString(R.string.default_map_public_key));
defaultMapPublicCheckBoxPreference.setSummaryOn(getString(
R.string.settings_sharing_map_public_summary,
getString(R.string.maps_public_unlisted_url)));
defaultMapPublicCheckBoxPreference.setSummaryOff(getString(
R.string.settings_sharing_map_unlisted_summary,
getString(R.string.maps_public_unlisted_url)));
boolean defaultMapPublic = PreferencesUtils.getBoolean(
this, R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT);
updateDefaultMapPublicTitle(defaultMapPublic);
defaultMapPublicCheckBoxPreference.setOnPreferenceChangeListener(
new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
updateDefaultMapPublicTitle((Boolean) newValue);
return true;
}
});
allowAccessCheckBoxPreference = (CheckBoxPreference) findPreference(
getString(R.string.allow_access_key));
allowAccessCheckBoxPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@@ -63,21 +78,6 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
}
}
});
ListPreference sharingAccountListPreference = (ListPreference) findPreference(
getString(R.string.sharing_account_key));
List<String> entries = new ArrayList<String>();
Account[] accounts = AccountManager.get(this).getAccountsByType(Constants.ACCOUNT_TYPE);
for (Account account : accounts) {
entries.add(account.name);
}
sharingAccountListPreference.setEntries(entries.toArray(new CharSequence[entries.size()]));
sharingAccountListPreference.setEntryValues(entries.toArray(
new CharSequence[entries.size()]));
if (entries.size() == 1) {
sharingAccountListPreference.setValueIndex(0);
}
}
@Override
@@ -88,10 +88,20 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
return DialogUtils.createConfirmationDialog(this,
R.string.settings_sharing_allow_access_confirm_message,
new DialogInterface.OnClickListener() {
@Override
@Override
public void onClick(DialogInterface dialog, int button) {
allowAccessCheckBoxPreference.setChecked(true);
}
});
}
/**
* Updates the title for the default map public check box preference.
*
* @param value the value
*/
private void updateDefaultMapPublicTitle(boolean value) {
defaultMapPublicCheckBoxPreference.setTitle(value ? R.string.settings_sharing_map_public
: R.string.settings_sharing_map_unlisted);
}
}
@@ -23,6 +23,7 @@ import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
/**
* Utilities for creating dialogs.
@@ -37,19 +38,40 @@ public class DialogUtils {
* Creates a confirmation dialog.
*
* @param context the context
* @param messageId the confirmation message id
* @param onClickListener the listener to invoke when the user clicks OK
* @param messageId the message id
* @param okListener the listener when OK is clicked
*/
public static Dialog createConfirmationDialog(
Context context, int messageId, DialogInterface.OnClickListener onClickListener) {
return new AlertDialog.Builder(context)
Context context, int messageId, DialogInterface.OnClickListener okListener) {
return createConfirmationDialog(context, messageId, null, okListener, null);
}
/**
* Creates a confirmation dialog.
*
* @param context the context
* @param messageId the messageId
* @param view the view
* @param okListener the listener when OK is clicked
* @param cancelListener the listener when cancel is clicked
*/
public static Dialog createConfirmationDialog(
Context context, int messageId, View view, DialogInterface.OnClickListener okListener,
DialogInterface.OnClickListener cancelListener) {
AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setCancelable(true)
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(context.getString(messageId))
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, onClickListener)
.setTitle(R.string.generic_confirm_title)
.create();
.setNegativeButton(android.R.string.cancel, cancelListener)
.setPositiveButton(android.R.string.ok, okListener)
.setTitle(R.string.generic_confirm_title);
if (messageId != -1) {
builder.setMessage(messageId);
}
if (view != null) {
builder.setView(view);
}
return builder.create();
}
/**
@@ -51,8 +51,9 @@ public class PreferencesUtils {
public static final boolean CHART_SHOW_SPEED_DEFAULT = true;
public static final String DEFAULT_ACTIVITY_DEFAULT = "";
public static final boolean DEFAULT_MAP_PUBLIC_DEFAULT = true;
public static final boolean DEFAULT_MAP_PUBLIC_DEFAULT = false;
public static final int FREQUENCY_OFF = 0;
public static final String GOOGLE_ACCOUNT_DEFAULT = "";
public static final int MAX_RECORDING_DISTANCE_DEFAULT = 200;
public static final boolean METRIC_UNITS_DEFAULT = true;
public static final int MIN_RECORDING_DISTANCE_DEFAULT = 5;
@@ -72,8 +73,8 @@ public class PreferencesUtils {
public static final boolean SEND_TO_DOCS_DEFAULT = true;
public static final boolean SEND_TO_FUSION_TABLES_DEFAULT = true;
public static final boolean SEND_TO_MAPS_DEFAULT = true;
public static final String SHARING_ACCOUNT_DEFAULT = "";
public static final boolean SHOW_CHECK_UNITS_DIALOG_DEFAULT = true;
public static final boolean SHOW_CONFIRM_SHARING_DIALOG_DEFAULT = true;
public static final boolean SHOW_WELCOME_DIALOG_DEFAULT = true;
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
@@ -79,8 +79,11 @@ public class TrackNameUtils {
if (location != null) {
return getReverseGeoCoding(context, location);
} else {
// assume startTime != -1L when location == null
return StringUtils.formatDateTime(context, startTime);
// Use the startTime if available
if (startTime != -1L) {
return StringUtils.formatDateTime(context, startTime);
}
return null;
}
}
}