forked from upstream-mirrors/OpenTracks
Modify the sharing flow to first show a list of applications.
Store preferred account as a sharing setting. Remove share url only option. Apply share url only if twitter is selected.
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp" >
|
||||||
|
<ImageView
|
||||||
|
android:contentDescription="@string/icon_application"
|
||||||
|
android:id="@+id/choose_activity_list_item_icon"
|
||||||
|
android:layout_height="@android:dimen/app_icon_size"
|
||||||
|
android:layout_width="@android:dimen/app_icon_size"
|
||||||
|
android:scaleType="fitCenter" />
|
||||||
|
<LinearLayout
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/choose_activity_list_item_text1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItemSmall" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/choose_activity_list_item_text2"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
@@ -21,7 +21,7 @@ limitations under the License.
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:stretchColumns="1" >
|
android:stretchColumns="1" >
|
||||||
<TableRow android:id="@+id/send_google_maps_row" >
|
<TableRow>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:contentDescription="@string/send_google_maps"
|
android:contentDescription="@string/send_google_maps"
|
||||||
android:src="@drawable/google_maps_icon"
|
android:src="@drawable/google_maps_icon"
|
||||||
@@ -47,7 +47,7 @@ limitations under the License.
|
|||||||
style="@style/TextMedium" />
|
style="@style/TextMedium" />
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow android:id="@+id/send_google_fusion_tables_row" >
|
<TableRow>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:contentDescription="@string/send_google_fusion_tables"
|
android:contentDescription="@string/send_google_fusion_tables"
|
||||||
android:src="@drawable/google_fusion_tables_icon"
|
android:src="@drawable/google_fusion_tables_icon"
|
||||||
@@ -57,7 +57,7 @@ limitations under the License.
|
|||||||
android:text="@string/send_google_fusion_tables"
|
android:text="@string/send_google_fusion_tables"
|
||||||
style="@style/UploadServiceChooserCheckBox" />
|
style="@style/UploadServiceChooserCheckBox" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow android:id="@+id/send_google_docs_row" >
|
<TableRow>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:contentDescription="@string/send_google_docs"
|
android:contentDescription="@string/send_google_docs"
|
||||||
android:src="@drawable/google_docs_icon"
|
android:src="@drawable/google_docs_icon"
|
||||||
|
|||||||
@@ -39,18 +39,6 @@ limitations under the License.
|
|||||||
android:orderInCategory="4"
|
android:orderInCategory="4"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/menu_share">
|
android:title="@string/menu_share">
|
||||||
<menu>
|
|
||||||
<item
|
|
||||||
android:id="@+id/track_detail_share_map_url"
|
|
||||||
android:title="@string/menu_share_map_url"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/track_detail_share_fusion_table_url"
|
|
||||||
android:title="@string/menu_share_fusion_table_url"/>
|
|
||||||
<item android:id="@+id/track_detail_share_gpx"/>
|
|
||||||
<item android:id="@+id/track_detail_share_kml"/>
|
|
||||||
<item android:id="@+id/track_detail_share_csv"/>
|
|
||||||
<item android:id="@+id/track_detail_share_tcx"/>
|
|
||||||
</menu>
|
|
||||||
</item>
|
</item>
|
||||||
<item
|
<item
|
||||||
android:icon="@drawable/menu_markers"
|
android:icon="@drawable/menu_markers"
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ limitations under the License.
|
|||||||
<string name="min_recording_interval_key">minRecordingInterval</string>
|
<string name="min_recording_interval_key">minRecordingInterval</string>
|
||||||
<string name="min_required_accuracy_key">minRequiredAccuracy</string>
|
<string name="min_required_accuracy_key">minRequiredAccuracy</string>
|
||||||
<string name="pick_existing_map_key">pickExistingMap</string>
|
<string name="pick_existing_map_key">pickExistingMap</string>
|
||||||
<string name="preferred_account_key">preferredAccount</string>
|
|
||||||
<string name="recording_track_id_key">recordingTrackId</string>
|
<string name="recording_track_id_key">recordingTrackId</string>
|
||||||
<string name="report_speed_key">reportSpeed</string>
|
<string name="report_speed_key">reportSpeed</string>
|
||||||
<string name="selected_track_id_key">selectedTrackId</string>
|
<string name="selected_track_id_key">selectedTrackId</string>
|
||||||
@@ -47,7 +46,7 @@ limitations under the License.
|
|||||||
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
|
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
|
||||||
<string name="send_to_maps_key">sendToMaps</string>
|
<string name="send_to_maps_key">sendToMaps</string>
|
||||||
<string name="sensor_type_key">sensorType</string>
|
<string name="sensor_type_key">sensorType</string>
|
||||||
<string name="share_url_only_key">shareUrlOnly</string>
|
<string name="sharing_account_key">sharingAccount</string>
|
||||||
<string name="show_check_units_dialog_key">showCheckUnitsDialog</string>
|
<string name="show_check_units_dialog_key">showCheckUnitsDialog</string>
|
||||||
<string name="show_welcome_dialog_key">showWelcomeDialog</string>
|
<string name="show_welcome_dialog_key">showWelcomeDialog</string>
|
||||||
<string name="split_frequency_key">splitFrequency</string>
|
<string name="split_frequency_key">splitFrequency</string>
|
||||||
|
|||||||
@@ -821,6 +821,12 @@ limitations under the License.
|
|||||||
</string>
|
</string>
|
||||||
|
|
||||||
<!-- Icon -->
|
<!-- Icon -->
|
||||||
|
<string name="icon_application"
|
||||||
|
translation_description="When sharing a track, we display a list of Android applications on the
|
||||||
|
phone that can be used. In the list, we display an application icon for each application. This
|
||||||
|
is the accessibility description for the icon.">
|
||||||
|
Application
|
||||||
|
</string>
|
||||||
<string name="icon_marker"
|
<string name="icon_marker"
|
||||||
translation_description="The accessibility description for the 'Marker' icon.">
|
translation_description="The accessibility description for the 'Marker' icon.">
|
||||||
Marker
|
Marker
|
||||||
@@ -1096,24 +1102,6 @@ limitations under the License.
|
|||||||
translation_description="In the menu, to share a track.">
|
translation_description="In the menu, to share a track.">
|
||||||
Share
|
Share
|
||||||
</string>
|
</string>
|
||||||
<string name="menu_share_file"
|
|
||||||
translation_description="Under the 'Share' menu option, the option to share a track as a
|
|
||||||
certain file format.
|
|
||||||
|
|
||||||
%1$s: file format. 'GPX', 'KML', 'CSV', or 'TCX'.">
|
|
||||||
%1$s file
|
|
||||||
</string>
|
|
||||||
<string name="menu_share_fusion_table_url"
|
|
||||||
translation_description="Under the 'Share' menu option, the option to save a track to Google
|
|
||||||
Fusion Tables and share the Fusion Table URL with friends. 'Fusion Table URL' in this context
|
|
||||||
means a Google Fusion Table URL.">
|
|
||||||
Fusion Table URL
|
|
||||||
</string>
|
|
||||||
<string name="menu_share_map_url"
|
|
||||||
translation_description="Under the 'Share' menu option, the option to save a track to Google
|
|
||||||
Maps and share the Map URL with friends. 'Map URL' in this context means a Google Map URL.">
|
|
||||||
Map URL
|
|
||||||
</string>
|
|
||||||
<string name="menu_show_on_map"
|
<string name="menu_show_on_map"
|
||||||
translation_description="In the menu, to show a track or a marker on the map.">
|
translation_description="In the menu, to show a track or a marker on the map.">
|
||||||
Show on map
|
Show on map
|
||||||
@@ -1342,11 +1330,6 @@ limitations under the License.
|
|||||||
%1$s: service name. 'Google Maps', 'Google Fusion Tables', or 'Google Docs'.">
|
%1$s: service name. 'Google Maps', 'Google Fusion Tables', or 'Google Docs'.">
|
||||||
Sending to %1$s...
|
Sending to %1$s...
|
||||||
</string>
|
</string>
|
||||||
<string name="send_google_result_share_url"
|
|
||||||
translation_description="When sending a track to Google, in the result dialog, the button on
|
|
||||||
the bottom to share with friends the URL of the uploaded track.">
|
|
||||||
Share track URL
|
|
||||||
</string>
|
|
||||||
<string name="send_google_send_now"
|
<string name="send_google_send_now"
|
||||||
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
|
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
|
||||||
button on the bottom to send the track to the selected Google services.">
|
button on the bottom to send the track to the selected Google services.">
|
||||||
@@ -1861,6 +1844,14 @@ limitations under the License.
|
|||||||
Character limit: ~26 (1 line)">
|
Character limit: ~26 (1 line)">
|
||||||
Sharing
|
Sharing
|
||||||
</string>
|
</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'.">
|
||||||
|
Switch account used when sending a track to Google.
|
||||||
|
</string>
|
||||||
<string name="settings_sharing_allow_access"
|
<string name="settings_sharing_allow_access"
|
||||||
translation_description="In the 'Sharing' settings, the checkbox option to allow third party
|
translation_description="In the 'Sharing' settings, the checkbox option to allow third party
|
||||||
apps access to the My Tracks data.
|
apps access to the My Tracks data.
|
||||||
@@ -1907,25 +1898,6 @@ limitations under the License.
|
|||||||
be public, as opposed to unlisted.">
|
be public, as opposed to unlisted.">
|
||||||
Make new maps created in Google Maps public.
|
Make new maps created in Google Maps public.
|
||||||
</string>
|
</string>
|
||||||
<string name="settings_sharing_url_only"
|
|
||||||
translation_description="In the 'Sharing' settings, the checkbox option to share only the URL,
|
|
||||||
without any descriptive text, when sharing a URL with friends.
|
|
||||||
|
|
||||||
Character limit: ~23 (1 line)">
|
|
||||||
Share only URL
|
|
||||||
</string>
|
|
||||||
<string name="settings_sharing_url_only_summary_off"
|
|
||||||
translation_description="In the 'Sharing' settings, the summary for the 'Share only URL'
|
|
||||||
checkbox option when it is unchecked explaining that it will include descriptive text when
|
|
||||||
sharing a URL with friends.">
|
|
||||||
Include descriptive text when sharing a URL with friends.
|
|
||||||
</string>
|
|
||||||
<string name="settings_sharing_url_only_summary_on"
|
|
||||||
translation_description="In the 'Sharing' settings, the summary for the 'Share only URL'
|
|
||||||
checkbox option when it is checked explaining that it will remove any descriptive text when
|
|
||||||
sharing a URL with friends.">
|
|
||||||
Remove any descriptive text when sharing a URL with friends.
|
|
||||||
</string>
|
|
||||||
|
|
||||||
<!-- Settings Split -->
|
<!-- Settings Split -->
|
||||||
<string name="settings_split_frequency_title"
|
<string name="settings_split_frequency_title"
|
||||||
@@ -2003,8 +1975,13 @@ limitations under the License.
|
|||||||
</string>
|
</string>
|
||||||
<string name="share_track_picker_title"
|
<string name="share_track_picker_title"
|
||||||
translation_description="When sharing a track URL with friends, the title on the picker to ask
|
translation_description="When sharing a track URL with friends, the title on the picker to ask
|
||||||
the user which application he wants to use.">
|
the user to select an application.">
|
||||||
Share track using:
|
Select an application
|
||||||
|
</string>
|
||||||
|
<string name="share_track_share_url"
|
||||||
|
translation_description="After sending a track to Google, the button on the result dialog to
|
||||||
|
share the uploaded track URL with friends.">
|
||||||
|
Share track URL
|
||||||
</string>
|
</string>
|
||||||
<string name="share_track_subject"
|
<string name="share_track_subject"
|
||||||
translation_description="When sharing a track with friends, the subject line.">
|
translation_description="When sharing a track with friends, the subject line.">
|
||||||
|
|||||||
@@ -16,18 +16,17 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:title="@string/settings_sharing" >
|
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
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="@string/default_map_public_key"
|
android:key="@string/default_map_public_key"
|
||||||
android:summaryOff="@string/settings_sharing_map_public_summary_off"
|
android:summaryOff="@string/settings_sharing_map_public_summary_off"
|
||||||
android:summaryOn="@string/settings_sharing_map_public_summary_on"
|
android:summaryOn="@string/settings_sharing_map_public_summary_on"
|
||||||
android:title="@string/settings_sharing_map_public" />
|
android:title="@string/settings_sharing_map_public" />
|
||||||
<CheckBoxPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/share_url_only_key"
|
|
||||||
android:summaryOff="@string/settings_sharing_url_only_summary_off"
|
|
||||||
android:summaryOn="@string/settings_sharing_url_only_summary_on"
|
|
||||||
android:title="@string/settings_sharing_url_only" />
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="@string/allow_access_key"
|
android:key="@string/allow_access_key"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.google.android.apps.mytracks.content.TrackDataHub;
|
|||||||
import com.google.android.apps.mytracks.content.Waypoint;
|
import com.google.android.apps.mytracks.content.Waypoint;
|
||||||
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
import com.google.android.apps.mytracks.content.WaypointCreationRequest;
|
||||||
import com.google.android.apps.mytracks.fragments.ChartFragment;
|
import com.google.android.apps.mytracks.fragments.ChartFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
|
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
|
||||||
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
|
||||||
@@ -212,15 +213,6 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
|||||||
menu.findItem(R.id.track_detail_save_tcx)
|
menu.findItem(R.id.track_detail_save_tcx)
|
||||||
.setTitle(getString(R.string.menu_save_format, fileTypes[3]));
|
.setTitle(getString(R.string.menu_save_format, fileTypes[3]));
|
||||||
|
|
||||||
menu.findItem(R.id.track_detail_share_gpx)
|
|
||||||
.setTitle(getString(R.string.menu_share_file, fileTypes[0]));
|
|
||||||
menu.findItem(R.id.track_detail_share_kml)
|
|
||||||
.setTitle(getString(R.string.menu_share_file, fileTypes[1]));
|
|
||||||
menu.findItem(R.id.track_detail_share_csv)
|
|
||||||
.setTitle(getString(R.string.menu_share_file, fileTypes[2]));
|
|
||||||
menu.findItem(R.id.track_detail_share_tcx)
|
|
||||||
.setTitle(getString(R.string.menu_share_file, fileTypes[3]));
|
|
||||||
|
|
||||||
stopRecordingMenuItem = menu.findItem(R.id.track_detail_stop_recording);
|
stopRecordingMenuItem = menu.findItem(R.id.track_detail_stop_recording);
|
||||||
insertMarkerMenuItem = menu.findItem(R.id.track_detail_insert_marker);
|
insertMarkerMenuItem = menu.findItem(R.id.track_detail_insert_marker);
|
||||||
playMenuItem = menu.findItem(R.id.track_detail_play);
|
playMenuItem = menu.findItem(R.id.track_detail_play);
|
||||||
@@ -276,27 +268,9 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
|||||||
getSupportFragmentManager(), InstallEarthDialogFragment.INSTALL_EARTH_DIALOG_TAG);
|
getSupportFragmentManager(), InstallEarthDialogFragment.INSTALL_EARTH_DIALOG_TAG);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_share_map_url:
|
case R.id.track_detail_share:
|
||||||
intent = IntentUtils.newIntent(this, UploadServiceChooserActivity.class)
|
ChooseActivityDialogFragment.newInstance(trackId, null).show(
|
||||||
.putExtra(SendRequest.SEND_REQUEST_KEY, new SendRequest(trackId, true, false, false));
|
getSupportFragmentManager(), ChooseActivityDialogFragment.CHOOSE_ACTIVITY_DIALOG_TAG);
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_share_fusion_table_url:
|
|
||||||
intent = IntentUtils.newIntent(this, UploadServiceChooserActivity.class)
|
|
||||||
.putExtra(SendRequest.SEND_REQUEST_KEY, new SendRequest(trackId, false, true, false));
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_share_gpx:
|
|
||||||
startSaveActivity(TrackFileFormat.GPX, true);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_share_kml:
|
|
||||||
startSaveActivity(TrackFileFormat.KML, true);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_share_csv:
|
|
||||||
startSaveActivity(TrackFileFormat.CSV, true);
|
|
||||||
return true;
|
|
||||||
case R.id.track_detail_share_tcx:
|
|
||||||
startSaveActivity(TrackFileFormat.TCX, true);
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_markers:
|
case R.id.track_detail_markers:
|
||||||
intent = IntentUtils.newIntent(this, MarkerListActivity.class)
|
intent = IntentUtils.newIntent(this, MarkerListActivity.class)
|
||||||
@@ -316,20 +290,20 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
|||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_send_google:
|
case R.id.track_detail_send_google:
|
||||||
intent = IntentUtils.newIntent(this, UploadServiceChooserActivity.class)
|
intent = IntentUtils.newIntent(this, UploadServiceChooserActivity.class)
|
||||||
.putExtra(SendRequest.SEND_REQUEST_KEY, new SendRequest(trackId, true, true, true));
|
.putExtra(SendRequest.SEND_REQUEST_KEY, new SendRequest(trackId));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_save_gpx:
|
case R.id.track_detail_save_gpx:
|
||||||
startSaveActivity(TrackFileFormat.GPX, false);
|
startSaveActivity(TrackFileFormat.GPX);
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_save_kml:
|
case R.id.track_detail_save_kml:
|
||||||
startSaveActivity(TrackFileFormat.KML, false);
|
startSaveActivity(TrackFileFormat.KML);
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_save_csv:
|
case R.id.track_detail_save_csv:
|
||||||
startSaveActivity(TrackFileFormat.CSV, false);
|
startSaveActivity(TrackFileFormat.CSV);
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_save_tcx:
|
case R.id.track_detail_save_tcx:
|
||||||
startSaveActivity(TrackFileFormat.TCX, false);
|
startSaveActivity(TrackFileFormat.TCX);
|
||||||
return true;
|
return true;
|
||||||
case R.id.track_detail_edit:
|
case R.id.track_detail_edit:
|
||||||
intent = IntentUtils.newIntent(this, TrackEditActivity.class)
|
intent = IntentUtils.newIntent(this, TrackEditActivity.class)
|
||||||
@@ -480,13 +454,11 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
|||||||
* Starts the {@link SaveActivity} to save a track.
|
* Starts the {@link SaveActivity} to save a track.
|
||||||
*
|
*
|
||||||
* @param trackFileFormat the track file format
|
* @param trackFileFormat the track file format
|
||||||
* @param shareTrack true to share the track after saving
|
|
||||||
*/
|
*/
|
||||||
private void startSaveActivity(TrackFileFormat trackFileFormat, boolean shareTrack) {
|
private void startSaveActivity(TrackFileFormat trackFileFormat) {
|
||||||
Intent intent = IntentUtils.newIntent(this, SaveActivity.class)
|
Intent intent = IntentUtils.newIntent(this, SaveActivity.class)
|
||||||
.putExtra(SaveActivity.EXTRA_TRACK_ID, trackId)
|
.putExtra(SaveActivity.EXTRA_TRACK_ID, trackId)
|
||||||
.putExtra(SaveActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) trackFileFormat)
|
.putExtra(SaveActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) trackFileFormat);
|
||||||
.putExtra(SaveActivity.EXTRA_SHARE_TRACK, shareTrack);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,11 +132,11 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout);
|
ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout);
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
LayoutParams layoutParams = new LayoutParams(
|
LayoutParams layoutParams = new LayoutParams(
|
||||||
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
|
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
|
||||||
layout.addView(chartView, layoutParams);
|
layout.addView(chartView, layoutParams);
|
||||||
|
|||||||
+259
@@ -0,0 +1,259 @@
|
|||||||
|
/*
|
||||||
|
* 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.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.util.IntentUtils;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v4.app.ShareCompat;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A DialogFragment to choose an activity.
|
||||||
|
*
|
||||||
|
* @author Jimmy Shih
|
||||||
|
*/
|
||||||
|
public class ChooseActivityDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
public static final String CHOOSE_ACTIVITY_DIALOG_TAG = "chooseActivityDialog";
|
||||||
|
|
||||||
|
private static final String KEY_TRACK_ID = "trackId";
|
||||||
|
private static final String KEY_TRACK_URL = "trackUrl";
|
||||||
|
|
||||||
|
private PackageManager packageManager;
|
||||||
|
|
||||||
|
public static ChooseActivityDialogFragment newInstance(long trackId, String trackUrl) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putLong(KEY_TRACK_ID, trackId);
|
||||||
|
bundle.putString(KEY_TRACK_URL, trackUrl);
|
||||||
|
|
||||||
|
ChooseActivityDialogFragment chooseActivityDialogFragment = new ChooseActivityDialogFragment();
|
||||||
|
chooseActivityDialogFragment.setArguments(bundle);
|
||||||
|
return chooseActivityDialogFragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
packageManager = getActivity().getPackageManager();
|
||||||
|
List<DisplayInfo> displayInfos = getDisplayInfos();
|
||||||
|
|
||||||
|
ArrayAdapter<DisplayInfo> arrayAdapter = new ArrayAdapter<DisplayInfo>(getActivity(),
|
||||||
|
R.layout.choose_activity_list_item, R.id.choose_activity_list_item_text1, displayInfos) {
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View view;
|
||||||
|
if (convertView == null) {
|
||||||
|
view = getActivity()
|
||||||
|
.getLayoutInflater().inflate(R.layout.choose_activity_list_item, parent, false);
|
||||||
|
} else {
|
||||||
|
view = convertView;
|
||||||
|
}
|
||||||
|
DisplayInfo displayInfo = getItem(position);
|
||||||
|
TextView text1 = (TextView) view.findViewById(R.id.choose_activity_list_item_text1);
|
||||||
|
TextView text2 = (TextView) view.findViewById(R.id.choose_activity_list_item_text2);
|
||||||
|
ImageView icon = (ImageView) view.findViewById(R.id.choose_activity_list_item_icon);
|
||||||
|
text1.setText(displayInfo.primaryLabel);
|
||||||
|
if (displayInfo.secondaryLabel != null) {
|
||||||
|
text2.setVisibility(View.VISIBLE);
|
||||||
|
text2.setText(displayInfo.secondaryLabel);
|
||||||
|
} else {
|
||||||
|
text2.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
icon.setImageDrawable(displayInfo.icon);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return new AlertDialog.Builder(getActivity())
|
||||||
|
.setSingleChoiceItems(arrayAdapter, 0, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
AlertDialog alertDialog = (AlertDialog) dialog;
|
||||||
|
DisplayInfo displayInfo = (DisplayInfo) alertDialog.getListView()
|
||||||
|
.getItemAtPosition(which);
|
||||||
|
ActivityInfo activityInfo = displayInfo.resolveInfo.activityInfo;
|
||||||
|
String packageName = activityInfo.applicationInfo.packageName;
|
||||||
|
String className = activityInfo.name;
|
||||||
|
|
||||||
|
String trackUrl = getArguments().getString(KEY_TRACK_URL);
|
||||||
|
if (trackUrl == null) {
|
||||||
|
SendRequest sendRequest = new SendRequest(getArguments().getLong(KEY_TRACK_ID));
|
||||||
|
sendRequest.setSendMaps(true);
|
||||||
|
sendRequest.setNewMap(true);
|
||||||
|
sendRequest.setSharingAppPackageName(packageName);
|
||||||
|
sendRequest.setSharingAppClassName(className);
|
||||||
|
Intent intent = IntentUtils.newIntent(getActivity(), AccountChooserActivity.class)
|
||||||
|
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
|
||||||
|
startActivity(intent);
|
||||||
|
dismiss();
|
||||||
|
} else {
|
||||||
|
Intent intent = IntentUtils.newShareUrlIntent(
|
||||||
|
getActivity(), trackUrl, packageName, className);
|
||||||
|
startActivity(intent);
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setTitle(R.string.share_track_picker_title)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the display info.
|
||||||
|
*/
|
||||||
|
private List<DisplayInfo> getDisplayInfos() {
|
||||||
|
List<DisplayInfo> displayInfos = new ArrayList<DisplayInfo>();
|
||||||
|
Intent intent = ShareCompat.IntentBuilder.from(getActivity())
|
||||||
|
.setType(IntentUtils.TEXT_PLAIN_TYPE).getIntent();
|
||||||
|
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(
|
||||||
|
intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||||
|
if (resolveInfos != null && resolveInfos.size() > 0) {
|
||||||
|
int size = resolveInfos.size();
|
||||||
|
ResolveInfo firstResolveInfo = resolveInfos.get(0);
|
||||||
|
for (int i = 1; i < size; i++) {
|
||||||
|
ResolveInfo resolveInfo = resolveInfos.get(i);
|
||||||
|
if (firstResolveInfo.priority != resolveInfo.priority
|
||||||
|
|| firstResolveInfo.isDefault != resolveInfo.isDefault) {
|
||||||
|
while (i < size) {
|
||||||
|
resolveInfos.remove(i);
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (size > 1) {
|
||||||
|
ResolveInfo.DisplayNameComparator displayNameComparator = new ResolveInfo.DisplayNameComparator(
|
||||||
|
packageManager);
|
||||||
|
Collections.sort(resolveInfos, displayNameComparator);
|
||||||
|
}
|
||||||
|
|
||||||
|
firstResolveInfo = resolveInfos.get(0);
|
||||||
|
int start = 0;
|
||||||
|
CharSequence firstLabel = firstResolveInfo.loadLabel(packageManager);
|
||||||
|
for (int i = 1; i < size; i++) {
|
||||||
|
if (firstLabel == null) {
|
||||||
|
firstLabel = firstResolveInfo.activityInfo.packageName;
|
||||||
|
}
|
||||||
|
ResolveInfo resolveInfo = resolveInfos.get(i);
|
||||||
|
CharSequence label = resolveInfo.loadLabel(packageManager);
|
||||||
|
if (label == null) {
|
||||||
|
label = resolveInfo.activityInfo.packageName;
|
||||||
|
}
|
||||||
|
if (label.equals(firstLabel)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
processGroup(resolveInfos, displayInfos, start, i - 1);
|
||||||
|
firstResolveInfo = resolveInfo;
|
||||||
|
firstLabel = label;
|
||||||
|
start = i;
|
||||||
|
}
|
||||||
|
// Process last group
|
||||||
|
processGroup(resolveInfos, displayInfos, start, size - 1);
|
||||||
|
}
|
||||||
|
return displayInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains display info.
|
||||||
|
*
|
||||||
|
* @author Jimmy Shih
|
||||||
|
*/
|
||||||
|
private final class DisplayInfo {
|
||||||
|
private ResolveInfo resolveInfo;
|
||||||
|
private CharSequence primaryLabel;
|
||||||
|
private CharSequence secondaryLabel;
|
||||||
|
private Drawable icon;
|
||||||
|
|
||||||
|
public DisplayInfo(ResolveInfo resolveInfo, CharSequence primaryLabel,
|
||||||
|
CharSequence secondaryLabel, Drawable icon) {
|
||||||
|
this.resolveInfo = resolveInfo;
|
||||||
|
this.primaryLabel = primaryLabel;
|
||||||
|
this.secondaryLabel = secondaryLabel;
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes a group of items with the same label.
|
||||||
|
*
|
||||||
|
* @param resolveInfos list of resolve infos
|
||||||
|
* @param displayInfos list of display infos
|
||||||
|
* @param start start index
|
||||||
|
* @param end end index
|
||||||
|
*/
|
||||||
|
private void processGroup(
|
||||||
|
List<ResolveInfo> resolveInfos, List<DisplayInfo> displayInfos, int start, int end) {
|
||||||
|
ResolveInfo startResolveInfo = resolveInfos.get(start);
|
||||||
|
CharSequence primaryLabel = startResolveInfo.loadLabel(packageManager);
|
||||||
|
Drawable icon = startResolveInfo.loadIcon(packageManager);
|
||||||
|
|
||||||
|
int num = end - start + 1;
|
||||||
|
if (num == 1) {
|
||||||
|
// Only one, set the secondary label to null
|
||||||
|
displayInfos.add(new DisplayInfo(startResolveInfo, primaryLabel, null, icon));
|
||||||
|
} else {
|
||||||
|
// Decide package name or application name for the secondary label
|
||||||
|
boolean usePackageName = false;
|
||||||
|
CharSequence appName = startResolveInfo.activityInfo.applicationInfo.loadLabel(
|
||||||
|
packageManager);
|
||||||
|
if (appName == null) {
|
||||||
|
usePackageName = true;
|
||||||
|
} else {
|
||||||
|
// Use HashSet to track duplicates
|
||||||
|
HashSet<CharSequence> duplicates = new HashSet<CharSequence>();
|
||||||
|
duplicates.add(appName);
|
||||||
|
for (int i = start + 1; i <= end; i++) {
|
||||||
|
ResolveInfo resolveInfo = resolveInfos.get(i);
|
||||||
|
CharSequence name = resolveInfo.activityInfo.applicationInfo.loadLabel(packageManager);
|
||||||
|
if ((name == null) || (duplicates.contains(name))) {
|
||||||
|
usePackageName = true;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
duplicates.add(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clear HashSet for later use
|
||||||
|
duplicates.clear();
|
||||||
|
}
|
||||||
|
for (int i = start; i <= end; i++) {
|
||||||
|
ResolveInfo resolveInfo = resolveInfos.get(i);
|
||||||
|
CharSequence secondaryLabel = usePackageName ? resolveInfo.activityInfo.packageName
|
||||||
|
: resolveInfo.activityInfo.applicationInfo.loadLabel(packageManager);
|
||||||
|
displayInfos.add(new DisplayInfo(resolveInfo, primaryLabel, secondaryLabel, icon));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-3
@@ -80,9 +80,6 @@ public abstract class AbstractSendAsyncTask extends AsyncTask<Void, Integer, Boo
|
|||||||
return performTask();
|
return performTask();
|
||||||
} finally {
|
} finally {
|
||||||
closeConnection();
|
closeConnection();
|
||||||
if (success) {
|
|
||||||
saveResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +94,9 @@ public abstract class AbstractSendAsyncTask extends AsyncTask<Void, Integer, Boo
|
|||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
success = result;
|
success = result;
|
||||||
completed = true;
|
completed = true;
|
||||||
|
if (success) {
|
||||||
|
saveResult();
|
||||||
|
}
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.onAsyncTaskCompleted(success);
|
activity.onAsyncTaskCompleted(success);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-18
@@ -76,7 +76,6 @@ public class AccountChooserActivity extends Activity {
|
|||||||
|
|
||||||
private SendRequest sendRequest;
|
private SendRequest sendRequest;
|
||||||
private Account[] accounts;
|
private Account[] accounts;
|
||||||
private int selectedAccountIndex;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -91,19 +90,18 @@ public class AccountChooserActivity extends Activity {
|
|||||||
|
|
||||||
if (accounts.length == 1) {
|
if (accounts.length == 1) {
|
||||||
sendRequest.setAccount(accounts[0]);
|
sendRequest.setAccount(accounts[0]);
|
||||||
PreferencesUtils.setString(this, R.string.preferred_account_key, accounts[0].name);
|
PreferencesUtils.setString(this, R.string.sharing_account_key, accounts[0].name);
|
||||||
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
|
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String preferredAccount = PreferencesUtils.getString(this, R.string.preferred_account_key,
|
String sharingAccount = PreferencesUtils.getString(this, R.string.sharing_account_key,
|
||||||
PreferencesUtils.PREFERRED_ACCOUNT_DEFAULT);
|
PreferencesUtils.SHARING_ACCOUNT_DEFAULT);
|
||||||
|
|
||||||
selectedAccountIndex = 0;
|
|
||||||
for (int i = 0; i < accounts.length; i++) {
|
for (int i = 0; i < accounts.length; i++) {
|
||||||
if (accounts[i].name.equals(preferredAccount)) {
|
if (accounts[i].name.equals(sharingAccount)) {
|
||||||
selectedAccountIndex = i;
|
sendRequest.setAccount(accounts[i]);
|
||||||
break;
|
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showDialog(DIALOG_CHOOSER_ID);
|
showDialog(DIALOG_CHOOSER_ID);
|
||||||
@@ -159,20 +157,15 @@ public class AccountChooserActivity extends Activity {
|
|||||||
})
|
})
|
||||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Account account = accounts[selectedAccountIndex];
|
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||||
|
Account account = accounts[position];
|
||||||
PreferencesUtils.setString(
|
PreferencesUtils.setString(
|
||||||
AccountChooserActivity.this, R.string.preferred_account_key, account.name);
|
AccountChooserActivity.this, R.string.sharing_account_key, account.name);
|
||||||
sendRequest.setAccount(account);
|
sendRequest.setAccount(account);
|
||||||
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
|
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setSingleChoiceItems(
|
.setSingleChoiceItems(choices, 0, null)
|
||||||
choices, selectedAccountIndex, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
selectedAccountIndex = which;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setTitle(R.string.send_google_choose_account_title)
|
.setTitle(R.string.send_google_choose_account_title)
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,8 @@ public class SendRequest implements Parcelable {
|
|||||||
public static final String SEND_REQUEST_KEY = "sendRequest";
|
public static final String SEND_REQUEST_KEY = "sendRequest";
|
||||||
|
|
||||||
private long trackId = -1L;
|
private long trackId = -1L;
|
||||||
private boolean showMaps = false;
|
private String sharingAppPackageName = null;
|
||||||
private boolean showFusionTables = false;
|
private String sharingAppClassName = null;
|
||||||
private boolean showDocs = false;
|
|
||||||
private boolean sendMaps = false;
|
private boolean sendMaps = false;
|
||||||
private boolean sendFusionTables = false;
|
private boolean sendFusionTables = false;
|
||||||
private boolean sendDocs = false;
|
private boolean sendDocs = false;
|
||||||
@@ -48,15 +47,9 @@ public class SendRequest implements Parcelable {
|
|||||||
* Creates a new send request.
|
* Creates a new send request.
|
||||||
*
|
*
|
||||||
* @param trackId the track id
|
* @param trackId the track id
|
||||||
* @param showMaps true to show the Google Maps option
|
|
||||||
* @param showFusionTables true to show the Google Fusion Tables option
|
|
||||||
* @param showDocs true to show the Google Docs option
|
|
||||||
*/
|
*/
|
||||||
public SendRequest(long trackId, boolean showMaps, boolean showFusionTables, boolean showDocs) {
|
public SendRequest(long trackId) {
|
||||||
this.trackId = trackId;
|
this.trackId = trackId;
|
||||||
this.showMaps = showMaps;
|
|
||||||
this.showFusionTables = showFusionTables;
|
|
||||||
this.showDocs = showDocs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,31 +60,35 @@ public class SendRequest implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if showing the send to Google Maps option.
|
* Gets the sharing app package name.
|
||||||
*/
|
*/
|
||||||
public boolean isShowMaps() {
|
public String getSharingAppPackageName() {
|
||||||
return showMaps;
|
return sharingAppPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if showing the send to Google Fusion Tables option.
|
* Sets the sharing app package name.
|
||||||
|
*
|
||||||
|
* @param sharingAppPackageName the sharing app package name
|
||||||
*/
|
*/
|
||||||
public boolean isShowFusionTables() {
|
public void setSharingAppPackageName(String sharingAppPackageName) {
|
||||||
return showFusionTables;
|
this.sharingAppPackageName = sharingAppPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if showing the send to Google Docs option.
|
* Gets the sharing app class name.
|
||||||
*/
|
*/
|
||||||
public boolean isShowDocs() {
|
public String getSharingAppClassName() {
|
||||||
return showDocs;
|
return sharingAppClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if showing all the send options.
|
* Sets the sharing app class name.
|
||||||
|
*
|
||||||
|
* @param sharingAppClassName the sharing app class name
|
||||||
*/
|
*/
|
||||||
public boolean isShowAll() {
|
public void setSharingAppClassName(String sharingAppClassName) {
|
||||||
return showMaps && showFusionTables && showDocs;
|
this.sharingAppClassName = sharingAppClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -245,9 +242,8 @@ public class SendRequest implements Parcelable {
|
|||||||
|
|
||||||
private SendRequest(Parcel in) {
|
private SendRequest(Parcel in) {
|
||||||
trackId = in.readLong();
|
trackId = in.readLong();
|
||||||
showMaps = in.readByte() == 1;
|
sharingAppPackageName = in.readString();
|
||||||
showFusionTables = in.readByte() == 1;
|
sharingAppClassName = in.readString();
|
||||||
showDocs = in.readByte() == 1;
|
|
||||||
sendMaps = in.readByte() == 1;
|
sendMaps = in.readByte() == 1;
|
||||||
sendFusionTables = in.readByte() == 1;
|
sendFusionTables = in.readByte() == 1;
|
||||||
sendDocs = in.readByte() == 1;
|
sendDocs = in.readByte() == 1;
|
||||||
@@ -267,9 +263,8 @@ public class SendRequest implements Parcelable {
|
|||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
out.writeLong(trackId);
|
out.writeLong(trackId);
|
||||||
out.writeByte((byte) (showMaps ? 1 : 0));
|
out.writeString(sharingAppPackageName);
|
||||||
out.writeByte((byte) (showFusionTables ? 1 : 0));
|
out.writeString(sharingAppClassName);
|
||||||
out.writeByte((byte) (showDocs ? 1 : 0));
|
|
||||||
out.writeByte((byte) (sendMaps ? 1 : 0));
|
out.writeByte((byte) (sendMaps ? 1 : 0));
|
||||||
out.writeByte((byte) (sendFusionTables ? 1 : 0));
|
out.writeByte((byte) (sendFusionTables ? 1 : 0));
|
||||||
out.writeByte((byte) (sendDocs ? 1 : 0));
|
out.writeByte((byte) (sendDocs ? 1 : 0));
|
||||||
|
|||||||
+25
-41
@@ -17,18 +17,19 @@ package com.google.android.apps.mytracks.io.sendtogoogle;
|
|||||||
|
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
|
import com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment;
|
||||||
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesUtils;
|
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesUtils;
|
||||||
import com.google.android.apps.mytracks.io.maps.SendMapsUtils;
|
import com.google.android.apps.mytracks.io.maps.SendMapsUtils;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -36,33 +37,40 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A dialog to show the result of uploading to Google services.
|
* A dialog to show the result of uploading to Google services.
|
||||||
*
|
*
|
||||||
* @author Jimmy Shih
|
* @author Jimmy Shih
|
||||||
*/
|
*/
|
||||||
public class UploadResultActivity extends Activity {
|
public class UploadResultActivity extends FragmentActivity {
|
||||||
|
|
||||||
private static final String TEXT_PLAIN_TYPE = "text/plain";
|
|
||||||
private static final int DIALOG_RESULT_ID = 0;
|
private static final int DIALOG_RESULT_ID = 0;
|
||||||
|
|
||||||
private SendRequest sendRequest;
|
private SendRequest sendRequest;
|
||||||
private Track track;
|
private Track track;
|
||||||
private String shareUrl;
|
private String shareUrl;
|
||||||
private Dialog resultDialog;
|
private Dialog resultDialog;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
sendRequest = getIntent().getParcelableExtra(SendRequest.SEND_REQUEST_KEY);
|
sendRequest = getIntent().getParcelableExtra(SendRequest.SEND_REQUEST_KEY);
|
||||||
track = null;
|
track = null;
|
||||||
shareUrl = null;
|
shareUrl = null;
|
||||||
|
|
||||||
if (sendRequest.isSendMaps() && sendRequest.isMapsSuccess()) {
|
if (sendRequest.isSendMaps() && sendRequest.isMapsSuccess()) {
|
||||||
shareUrl = SendMapsUtils.getMapUrl(getTrack());
|
shareUrl = SendMapsUtils.getMapUrl(getTrack());
|
||||||
|
if (sendRequest.getSharingAppPackageName() != null) {
|
||||||
|
Intent intent = IntentUtils.newShareUrlIntent(this, shareUrl,
|
||||||
|
sendRequest.getSharingAppPackageName(), sendRequest.getSharingAppClassName());
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (shareUrl == null && sendRequest.isSendFusionTables()
|
if (shareUrl == null && sendRequest.isSendFusionTables()
|
||||||
&& sendRequest.isFusionTablesSuccess()) {
|
&& sendRequest.isFusionTablesSuccess()) {
|
||||||
shareUrl = SendFusionTablesUtils.getMapUrl(getTrack());
|
shareUrl = SendFusionTablesUtils.getMapUrl(getTrack());
|
||||||
}
|
}
|
||||||
|
showDialog(DIALOG_RESULT_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Track getTrack() {
|
private Track getTrack() {
|
||||||
@@ -72,17 +80,11 @@ public class UploadResultActivity extends Activity {
|
|||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
showDialog(DIALOG_RESULT_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
protected Dialog onCreateDialog(int id) {
|
||||||
if (id != DIALOG_RESULT_ID) {
|
if (id != DIALOG_RESULT_ID) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
View view = getLayoutInflater().inflate(R.layout.upload_result, null);
|
View view = getLayoutInflater().inflate(R.layout.upload_result, null);
|
||||||
|
|
||||||
LinearLayout mapsResult = (LinearLayout) view.findViewById(R.id.upload_result_maps_result);
|
LinearLayout mapsResult = (LinearLayout) view.findViewById(R.id.upload_result_maps_result);
|
||||||
@@ -139,31 +141,29 @@ public class UploadResultActivity extends Activity {
|
|||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setIcon(hasError ? android.R.drawable.ic_dialog_alert : android.R.drawable.ic_dialog_info)
|
.setIcon(hasError ? android.R.drawable.ic_dialog_alert : android.R.drawable.ic_dialog_info)
|
||||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (!sendRequest.isShowAll() && shareUrl != null) {
|
|
||||||
startShareUrlActivity(shareUrl);
|
|
||||||
}
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setTitle(hasError ? R.string.generic_error_title : R.string.generic_success_title)
|
.setTitle(hasError ? R.string.generic_error_title : R.string.generic_success_title)
|
||||||
.setView(view);
|
.setView(view);
|
||||||
|
|
||||||
// Add a Share URL button if showing all the options and a shareUrl exists
|
// Add a Share URL button if shareUrl exists
|
||||||
if (sendRequest.isShowAll() && shareUrl != null) {
|
if (shareUrl != null) {
|
||||||
builder.setNegativeButton(
|
builder.setNegativeButton(
|
||||||
R.string.send_google_result_share_url, new DialogInterface.OnClickListener() {
|
R.string.share_track_share_url, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
startShareUrlActivity(shareUrl);
|
ChooseActivityDialogFragment.newInstance(sendRequest.getTrackId(), shareUrl).show(
|
||||||
finish();
|
getSupportFragmentManager(),
|
||||||
|
ChooseActivityDialogFragment.CHOOSE_ACTIVITY_DIALOG_TAG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -171,22 +171,6 @@ public class UploadResultActivity extends Activity {
|
|||||||
return resultDialog;
|
return resultDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts an activity to share the url.
|
|
||||||
*
|
|
||||||
* @param url the url
|
|
||||||
*/
|
|
||||||
private void startShareUrlActivity(String url) {
|
|
||||||
boolean shareUrlOnly = PreferencesUtils.getBoolean(
|
|
||||||
this, R.string.share_url_only_key, PreferencesUtils.SHARE_URL_ONLY_DEFAULT);
|
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND)
|
|
||||||
.setType(TEXT_PLAIN_TYPE)
|
|
||||||
.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_track_subject))
|
|
||||||
.putExtra(Intent.EXTRA_TEXT,
|
|
||||||
shareUrlOnly ? url : getString(R.string.share_track_url_body_format, url));
|
|
||||||
startActivity(Intent.createChooser(intent, getString(R.string.share_track_picker_title)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Dialog getDialog() {
|
Dialog getDialog() {
|
||||||
return resultDialog;
|
return resultDialog;
|
||||||
|
|||||||
+6
-37
@@ -49,10 +49,6 @@ public class UploadServiceChooserActivity extends Activity {
|
|||||||
private SendRequest sendRequest;
|
private SendRequest sendRequest;
|
||||||
private AlertDialog alertDialog;
|
private AlertDialog alertDialog;
|
||||||
|
|
||||||
private TableRow mapsTableRow;
|
|
||||||
private TableRow fusionTablesTableRow;
|
|
||||||
private TableRow docsTableRow;
|
|
||||||
|
|
||||||
private CheckBox mapsCheckBox;
|
private CheckBox mapsCheckBox;
|
||||||
private CheckBox fusionTablesCheckBox;
|
private CheckBox fusionTablesCheckBox;
|
||||||
private CheckBox docsCheckBox;
|
private CheckBox docsCheckBox;
|
||||||
@@ -80,10 +76,6 @@ public class UploadServiceChooserActivity extends Activity {
|
|||||||
}
|
}
|
||||||
View view = getLayoutInflater().inflate(R.layout.upload_service_chooser, null);
|
View view = getLayoutInflater().inflate(R.layout.upload_service_chooser, null);
|
||||||
|
|
||||||
mapsTableRow = (TableRow) view.findViewById(R.id.send_google_maps_row);
|
|
||||||
fusionTablesTableRow = (TableRow) view.findViewById(R.id.send_google_fusion_tables_row);
|
|
||||||
docsTableRow = (TableRow) view.findViewById(R.id.send_google_docs_row);
|
|
||||||
|
|
||||||
mapsCheckBox = (CheckBox) view.findViewById(R.id.send_google_maps);
|
mapsCheckBox = (CheckBox) view.findViewById(R.id.send_google_maps);
|
||||||
fusionTablesCheckBox = (CheckBox) view.findViewById(R.id.send_google_fusion_tables);
|
fusionTablesCheckBox = (CheckBox) view.findViewById(R.id.send_google_fusion_tables);
|
||||||
docsCheckBox = (CheckBox) view.findViewById(R.id.send_google_docs);
|
docsCheckBox = (CheckBox) view.findViewById(R.id.send_google_docs);
|
||||||
@@ -105,9 +97,6 @@ public class UploadServiceChooserActivity extends Activity {
|
|||||||
// Setup initial state
|
// Setup initial state
|
||||||
initState();
|
initState();
|
||||||
|
|
||||||
// Update state based on sendRequest
|
|
||||||
updateStateBySendRequest();
|
|
||||||
|
|
||||||
// Update state based on current selection
|
// Update state based on current selection
|
||||||
updateStateBySelection();
|
updateStateBySelection();
|
||||||
|
|
||||||
@@ -163,24 +152,6 @@ public class UploadServiceChooserActivity extends Activity {
|
|||||||
this, R.string.send_to_docs_key, PreferencesUtils.SEND_TO_DOCS_DEFAULT));
|
this, R.string.send_to_docs_key, PreferencesUtils.SEND_TO_DOCS_DEFAULT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the UI state based on sendRequest.
|
|
||||||
*/
|
|
||||||
private void updateStateBySendRequest() {
|
|
||||||
if (!sendRequest.isShowAll()) {
|
|
||||||
if (sendRequest.isShowMaps()) {
|
|
||||||
mapsCheckBox.setChecked(true);
|
|
||||||
} else if (sendRequest.isShowFusionTables()) {
|
|
||||||
fusionTablesCheckBox.setChecked(true);
|
|
||||||
} else if (sendRequest.isShowDocs()) {
|
|
||||||
docsCheckBox.setChecked(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mapsTableRow.setVisibility(sendRequest.isShowMaps() ? View.VISIBLE : View.GONE);
|
|
||||||
fusionTablesTableRow.setVisibility(sendRequest.isShowFusionTables() ? View.VISIBLE : View.GONE);
|
|
||||||
docsTableRow.setVisibility(sendRequest.isShowDocs() ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the UI state based on the current selection.
|
* Updates the UI state based on the current selection.
|
||||||
*/
|
*/
|
||||||
@@ -195,32 +166,30 @@ public class UploadServiceChooserActivity extends Activity {
|
|||||||
void saveState() {
|
void saveState() {
|
||||||
PreferencesUtils.setBoolean(
|
PreferencesUtils.setBoolean(
|
||||||
this, R.string.pick_existing_map_key, existingMapRadioButton.isChecked());
|
this, R.string.pick_existing_map_key, existingMapRadioButton.isChecked());
|
||||||
if (sendRequest.isShowAll()) {
|
PreferencesUtils.setBoolean(this, R.string.send_to_maps_key, sendMaps());
|
||||||
PreferencesUtils.setBoolean(this, R.string.send_to_maps_key, sendMaps());
|
PreferencesUtils.setBoolean(this, R.string.send_to_fusion_tables_key, sendFusionTables());
|
||||||
PreferencesUtils.setBoolean(this, R.string.send_to_fusion_tables_key, sendFusionTables());
|
PreferencesUtils.setBoolean(this, R.string.send_to_docs_key, sendDocs());
|
||||||
PreferencesUtils.setBoolean(this, R.string.send_to_docs_key, sendDocs());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true to send to Google Maps.
|
* Returns true to send to Google Maps.
|
||||||
*/
|
*/
|
||||||
private boolean sendMaps() {
|
private boolean sendMaps() {
|
||||||
return sendRequest.isShowMaps() && mapsCheckBox.isChecked();
|
return mapsCheckBox.isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true to send to Google Fusion Tables.
|
* Returns true to send to Google Fusion Tables.
|
||||||
*/
|
*/
|
||||||
private boolean sendFusionTables() {
|
private boolean sendFusionTables() {
|
||||||
return sendRequest.isShowFusionTables() && fusionTablesCheckBox.isChecked();
|
return fusionTablesCheckBox.isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true to send to Google Docs.
|
* Returns true to send to Google Docs.
|
||||||
*/
|
*/
|
||||||
private boolean sendDocs() {
|
private boolean sendDocs() {
|
||||||
return sendRequest.isShowDocs() && docsCheckBox.isChecked();
|
return docsCheckBox.isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-2
@@ -36,13 +36,13 @@ public class AbstractSettingsActivity extends PreferenceActivity {
|
|||||||
|
|
||||||
private BackupPreferencesListener backupPreferencesListener;
|
private BackupPreferencesListener backupPreferencesListener;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle bundle) {
|
protected void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
|
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
|
||||||
ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
|
ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
PreferenceManager preferenceManager = getPreferenceManager();
|
PreferenceManager preferenceManager = getPreferenceManager();
|
||||||
preferenceManager.setSharedPreferencesName(Constants.SETTINGS_NAME);
|
preferenceManager.setSharedPreferencesName(Constants.SETTINGS_NAME);
|
||||||
preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);
|
preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);
|
||||||
@@ -63,10 +63,10 @@ public class AbstractSettingsActivity extends PreferenceActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
PreferenceManager preferenceManager = getPreferenceManager();
|
PreferenceManager preferenceManager = getPreferenceManager();
|
||||||
preferenceManager.getSharedPreferences()
|
preferenceManager.getSharedPreferences()
|
||||||
.unregisterOnSharedPreferenceChangeListener(backupPreferencesListener);
|
.unregisterOnSharedPreferenceChangeListener(backupPreferencesListener);
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ public class SensorSettingsActivity extends AbstractSettingsActivity {
|
|||||||
/**
|
/**
|
||||||
* Updates the bluetooth sensor list preference.
|
* Updates the bluetooth sensor list preference.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private void updateBluetoothSensorListPreference() {
|
private void updateBluetoothSensorListPreference() {
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
ListPreference bluetoothSensorListPreference = (ListPreference) findPreference(
|
ListPreference bluetoothSensorListPreference = (ListPreference) findPreference(
|
||||||
getString(R.string.bluetooth_sensor_key));
|
getString(R.string.bluetooth_sensor_key));
|
||||||
List<String> entries = new ArrayList<String>();
|
List<String> entries = new ArrayList<String>();
|
||||||
|
|||||||
@@ -16,16 +16,23 @@
|
|||||||
|
|
||||||
package com.google.android.apps.mytracks.settings;
|
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.DialogUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.accounts.Account;
|
||||||
|
import android.accounts.AccountManager;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An activity for accessing the sharing settings.
|
* An activity for accessing the sharing settings.
|
||||||
*
|
*
|
||||||
@@ -56,6 +63,21 @@ 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
|
@Override
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.google.android.apps.mytracks.util;
|
package com.google.android.apps.mytracks.util;
|
||||||
|
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
@@ -26,6 +29,9 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class IntentUtils {
|
public class IntentUtils {
|
||||||
|
|
||||||
|
public static final String TEXT_PLAIN_TYPE = "text/plain";
|
||||||
|
private static final String TWITTER_PACKAGE_NAME = "com.twitter.android";
|
||||||
|
|
||||||
private IntentUtils() {}
|
private IntentUtils() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,4 +45,23 @@ public class IntentUtils {
|
|||||||
return new Intent(context, cls).addFlags(
|
return new Intent(context, cls).addFlags(
|
||||||
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an intent to share a url with a sharing app.
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
* @param url the url
|
||||||
|
* @param packageName the sharing app package name
|
||||||
|
* @param className the sharing app class name
|
||||||
|
*/
|
||||||
|
public static final Intent newShareUrlIntent(
|
||||||
|
Context context, String url, String packageName, String className) {
|
||||||
|
return new Intent(Intent.ACTION_SEND)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP)
|
||||||
|
.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.share_track_subject))
|
||||||
|
.putExtra(Intent.EXTRA_TEXT, TWITTER_PACKAGE_NAME.equals(packageName)
|
||||||
|
? url : context.getString(R.string.share_track_url_body_format, url))
|
||||||
|
.setComponent(new ComponentName(packageName, className))
|
||||||
|
.setType(TEXT_PLAIN_TYPE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,14 +66,13 @@ public class PreferencesUtils {
|
|||||||
public static final int MIN_REQUIRED_ACCURACY_POOR = 5000;
|
public static final int MIN_REQUIRED_ACCURACY_POOR = 5000;
|
||||||
|
|
||||||
public static final boolean PICK_EXISTING_MAP_DEFAULT = false;
|
public static final boolean PICK_EXISTING_MAP_DEFAULT = false;
|
||||||
public static final String PREFERRED_ACCOUNT_DEFAULT = "";
|
|
||||||
public static final long RECORDING_TRACK_ID_DEFAULT = -1L;
|
public static final long RECORDING_TRACK_ID_DEFAULT = -1L;
|
||||||
public static final boolean REPORT_SPEED_DEFAULT = true;
|
public static final boolean REPORT_SPEED_DEFAULT = true;
|
||||||
public static final long SELECTED_TRACK_ID_DEFAULT = -1L;
|
public static final long SELECTED_TRACK_ID_DEFAULT = -1L;
|
||||||
public static final boolean SEND_TO_DOCS_DEFAULT = true;
|
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_FUSION_TABLES_DEFAULT = true;
|
||||||
public static final boolean SEND_TO_MAPS_DEFAULT = true;
|
public static final boolean SEND_TO_MAPS_DEFAULT = true;
|
||||||
public static final boolean SHARE_URL_ONLY_DEFAULT = false;
|
public static final String SHARING_ACCOUNT_DEFAULT = "";
|
||||||
public static final boolean SHOW_CHECK_UNITS_DIALOG_DEFAULT = true;
|
public static final boolean SHOW_CHECK_UNITS_DIALOG_DEFAULT = true;
|
||||||
public static final boolean SHOW_WELCOME_DIALOG_DEFAULT = true;
|
public static final boolean SHOW_WELCOME_DIALOG_DEFAULT = true;
|
||||||
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
|
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ public class SendFusionTablesActivityTest extends AndroidTestCase {
|
|||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
sendRequest = new SendRequest(1L, true, false, true);
|
sendRequest = new SendRequest(1L);
|
||||||
sendFusionTablesActivity = new SendFusionTablesActivity();
|
sendFusionTablesActivity = new SendFusionTablesActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class SendMapsActivityTest extends AndroidTestCase {
|
|||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
sendRequest = new SendRequest(1L, true, false, true);
|
sendRequest = new SendRequest(1L);
|
||||||
sendMapsActivity = new SendMapsActivity();
|
sendMapsActivity = new SendMapsActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -86,7 +86,7 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
prepareAndUploadPointsCounter = 0;
|
prepareAndUploadPointsCounter = 0;
|
||||||
sendMapsActivityMock = AndroidMock.createMock(SendMapsActivity.class);
|
sendMapsActivityMock = AndroidMock.createMock(SendMapsActivity.class);
|
||||||
myTracksProviderUtilsMock = AndroidMock.createMock(MyTracksProviderUtils.class);
|
myTracksProviderUtilsMock = AndroidMock.createMock(MyTracksProviderUtils.class);
|
||||||
sendRequest = new SendRequest(TRACK_ID, false, true, false);
|
sendRequest = new SendRequest(TRACK_ID);
|
||||||
AndroidMock.expect(sendMapsActivityMock.getApplicationContext()).andReturn(getContext());
|
AndroidMock.expect(sendMapsActivityMock.getApplicationContext()).andReturn(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+111
-158
@@ -35,7 +35,7 @@ public class SendRequestTest extends AndroidTestCase {
|
|||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
sendRequest = new SendRequest(1, true, true, true);
|
sendRequest = new SendRequest(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,44 +46,6 @@ public class SendRequestTest extends AndroidTestCase {
|
|||||||
assertEquals(1, sendRequest.getTrackId());
|
assertEquals(1, sendRequest.getTrackId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link SendRequest#isShowMaps()}. The value should be set
|
|
||||||
* to true when it is initialed in setup method.
|
|
||||||
*/
|
|
||||||
public void testIsShowMaps() {
|
|
||||||
assertEquals(true, sendRequest.isShowMaps());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link SendRequest#isShowFusionTables()}. The value should
|
|
||||||
* be set to true when it is initialed in setup method.
|
|
||||||
*/
|
|
||||||
public void testIsShowFusionTables() {
|
|
||||||
assertEquals(true, sendRequest.isShowFusionTables());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link SendRequest#isShowDocs()}. The value should be set
|
|
||||||
* to true when it is initialed in setup method.
|
|
||||||
*/
|
|
||||||
public void testIsShowDocs() {
|
|
||||||
assertEquals(true, sendRequest.isShowDocs());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testIsShowAll() {
|
|
||||||
assertEquals(true, sendRequest.isShowAll());
|
|
||||||
sendRequest = new SendRequest(1, false, true, true);
|
|
||||||
assertEquals(false, sendRequest.isShowAll());
|
|
||||||
sendRequest = new SendRequest(1, true, false, true);
|
|
||||||
assertEquals(false, sendRequest.isShowAll());
|
|
||||||
sendRequest = new SendRequest(1, true, true, false);
|
|
||||||
assertEquals(false, sendRequest.isShowAll());
|
|
||||||
sendRequest = new SendRequest(1, false, true, false);
|
|
||||||
assertEquals(false, sendRequest.isShowAll());
|
|
||||||
sendRequest = new SendRequest(1, false, false, false);
|
|
||||||
assertEquals(false, sendRequest.isShowAll());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testIsSendMaps() {
|
public void testIsSendMaps() {
|
||||||
assertEquals(false, sendRequest.isSendMaps());
|
assertEquals(false, sendRequest.isSendMaps());
|
||||||
sendRequest.setSendMaps(true);
|
sendRequest.setSendMaps(true);
|
||||||
@@ -174,120 +136,114 @@ public class SendRequestTest extends AndroidTestCase {
|
|||||||
* Tests SendRequest.CREATOR.createFromParcel when all values are true.
|
* Tests SendRequest.CREATOR.createFromParcel when all values are true.
|
||||||
*/
|
*/
|
||||||
public void testCreateFromParcel_true() {
|
public void testCreateFromParcel_true() {
|
||||||
Parcel sourceParcel = Parcel.obtain();
|
Parcel parcel = Parcel.obtain();
|
||||||
sourceParcel.setDataPosition(0);
|
parcel.setDataPosition(0);
|
||||||
sourceParcel.writeLong(2);
|
parcel.writeLong(2);
|
||||||
sourceParcel.writeByte((byte) 1);
|
parcel.writeString("");
|
||||||
sourceParcel.writeByte((byte) 1);
|
parcel.writeString("");
|
||||||
sourceParcel.writeByte((byte) 1);
|
parcel.writeByte((byte) 1);
|
||||||
sourceParcel.writeByte((byte) 1);
|
parcel.writeByte((byte) 1);
|
||||||
sourceParcel.writeByte((byte) 1);
|
parcel.writeByte((byte) 1);
|
||||||
sourceParcel.writeByte((byte) 1);
|
parcel.writeByte((byte) 1);
|
||||||
sourceParcel.writeByte((byte) 1);
|
|
||||||
Account account = new Account(ACCOUNTNAME, ACCOUNTYPE);
|
Account account = new Account(ACCOUNTNAME, ACCOUNTYPE);
|
||||||
sourceParcel.writeParcelable(account, 0);
|
parcel.writeParcelable(account, 0);
|
||||||
sourceParcel.writeString(MAPID);
|
parcel.writeString(MAPID);
|
||||||
sourceParcel.writeByte((byte) 1);
|
parcel.writeByte((byte) 1);
|
||||||
sourceParcel.writeByte((byte) 1);
|
parcel.writeByte((byte) 1);
|
||||||
sourceParcel.writeByte((byte) 1);
|
parcel.writeByte((byte) 1);
|
||||||
sourceParcel.setDataPosition(0);
|
parcel.setDataPosition(0);
|
||||||
sendRequest = SendRequest.CREATOR.createFromParcel(sourceParcel);
|
sendRequest = SendRequest.CREATOR.createFromParcel(parcel);
|
||||||
assertEquals(2, sendRequest.getTrackId());
|
assertEquals(2, sendRequest.getTrackId());
|
||||||
assertEquals(true, sendRequest.isShowMaps());
|
assertEquals("", sendRequest.getSharingAppPackageName());
|
||||||
assertEquals(true, sendRequest.isShowFusionTables());
|
assertEquals("", sendRequest.getSharingAppClassName());
|
||||||
assertEquals(true, sendRequest.isShowDocs());
|
assertTrue(sendRequest.isSendMaps());
|
||||||
assertEquals(true, sendRequest.isSendMaps());
|
assertTrue(sendRequest.isSendFusionTables());
|
||||||
assertEquals(true, sendRequest.isSendFusionTables());
|
assertTrue(sendRequest.isSendDocs());
|
||||||
assertEquals(true, sendRequest.isSendDocs());
|
assertTrue(sendRequest.isNewMap());
|
||||||
assertEquals(true, sendRequest.isNewMap());
|
|
||||||
assertEquals(account, sendRequest.getAccount());
|
assertEquals(account, sendRequest.getAccount());
|
||||||
assertEquals(MAPID, sendRequest.getMapId());
|
assertEquals(MAPID, sendRequest.getMapId());
|
||||||
assertEquals(true, sendRequest.isMapsSuccess());
|
assertTrue(sendRequest.isMapsSuccess());
|
||||||
assertEquals(true, sendRequest.isFusionTablesSuccess());
|
assertTrue(sendRequest.isFusionTablesSuccess());
|
||||||
assertEquals(true, sendRequest.isDocsSuccess());
|
assertTrue(sendRequest.isDocsSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests SendRequest.CREATOR.createFromParcel when all values are false.
|
* Tests SendRequest.CREATOR.createFromParcel when all values are false.
|
||||||
*/
|
*/
|
||||||
public void testCreateFromParcel_false() {
|
public void testCreateFromParcel_false() {
|
||||||
Parcel sourceParcel = Parcel.obtain();
|
Parcel parcel = Parcel.obtain();
|
||||||
sourceParcel.setDataPosition(0);
|
parcel.setDataPosition(0);
|
||||||
sourceParcel.writeLong(4);
|
parcel.writeLong(4);
|
||||||
sourceParcel.writeByte((byte) 0);
|
parcel.writeString(null);
|
||||||
sourceParcel.writeByte((byte) 0);
|
parcel.writeString(null);
|
||||||
sourceParcel.writeByte((byte) 0);
|
parcel.writeByte((byte) 0);
|
||||||
sourceParcel.writeByte((byte) 0);
|
parcel.writeByte((byte) 0);
|
||||||
sourceParcel.writeByte((byte) 0);
|
parcel.writeByte((byte) 0);
|
||||||
sourceParcel.writeByte((byte) 0);
|
parcel.writeByte((byte) 0);
|
||||||
sourceParcel.writeByte((byte) 0);
|
|
||||||
Account account = new Account(ACCOUNTNAME, ACCOUNTYPE);
|
Account account = new Account(ACCOUNTNAME, ACCOUNTYPE);
|
||||||
sourceParcel.writeParcelable(account, 0);
|
parcel.writeParcelable(account, 0);
|
||||||
sourceParcel.writeString(MAPID);
|
parcel.writeString(MAPID);
|
||||||
sourceParcel.writeByte((byte) 0);
|
parcel.writeByte((byte) 0);
|
||||||
sourceParcel.writeByte((byte) 0);
|
parcel.writeByte((byte) 0);
|
||||||
sourceParcel.writeByte((byte) 0);
|
parcel.writeByte((byte) 0);
|
||||||
sourceParcel.setDataPosition(0);
|
parcel.setDataPosition(0);
|
||||||
sendRequest = SendRequest.CREATOR.createFromParcel(sourceParcel);
|
sendRequest = SendRequest.CREATOR.createFromParcel(parcel);
|
||||||
assertEquals(4, sendRequest.getTrackId());
|
assertEquals(4, sendRequest.getTrackId());
|
||||||
assertEquals(false, sendRequest.isShowMaps());
|
assertNull(sendRequest.getSharingAppPackageName());
|
||||||
assertEquals(false, sendRequest.isShowFusionTables());
|
assertNull(sendRequest.getSharingAppClassName());
|
||||||
assertEquals(false, sendRequest.isShowDocs());
|
assertFalse(sendRequest.isSendMaps());
|
||||||
assertEquals(false, sendRequest.isSendMaps());
|
assertFalse(sendRequest.isSendFusionTables());
|
||||||
assertEquals(false, sendRequest.isSendFusionTables());
|
assertFalse(sendRequest.isSendDocs());
|
||||||
assertEquals(false, sendRequest.isSendDocs());
|
assertFalse(sendRequest.isNewMap());
|
||||||
assertEquals(false, sendRequest.isNewMap());
|
|
||||||
assertEquals(account, sendRequest.getAccount());
|
assertEquals(account, sendRequest.getAccount());
|
||||||
assertEquals(MAPID, sendRequest.getMapId());
|
assertEquals(MAPID, sendRequest.getMapId());
|
||||||
assertEquals(false, sendRequest.isMapsSuccess());
|
assertFalse(sendRequest.isMapsSuccess());
|
||||||
assertEquals(false, sendRequest.isFusionTablesSuccess());
|
assertFalse(sendRequest.isFusionTablesSuccess());
|
||||||
assertEquals(false, sendRequest.isDocsSuccess());
|
assertFalse(sendRequest.isDocsSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link SendRequest#writeToParcel(Parcel, int)} when all input values
|
* Tests {@link SendRequest#writeToParcel(Parcel, int)} with default values.
|
||||||
* are true or affirmative.
|
|
||||||
*/
|
*/
|
||||||
public void testWriteToParcel_allTrue() {
|
public void testWriteToParcel_default() {
|
||||||
sendRequest = new SendRequest(1, false, false, false);
|
sendRequest = new SendRequest(1);
|
||||||
Parcel parcelWrite1st = Parcel.obtain();
|
Parcel parcel = Parcel.obtain();
|
||||||
parcelWrite1st.setDataPosition(0);
|
parcel.setDataPosition(0);
|
||||||
sendRequest.writeToParcel(parcelWrite1st, 1);
|
sendRequest.writeToParcel(parcel, 1);
|
||||||
parcelWrite1st.setDataPosition(0);
|
parcel.setDataPosition(0);
|
||||||
long trackId = parcelWrite1st.readLong();
|
long trackId = parcel.readLong();
|
||||||
boolean showMaps = parcelWrite1st.readByte() == 1;
|
String sharingAppPackageName = parcel.readString();
|
||||||
boolean showFusionTables = parcelWrite1st.readByte() == 1;
|
String sharingAppClassName = parcel.readString();
|
||||||
boolean showDocs = parcelWrite1st.readByte() == 1;
|
boolean sendMaps = parcel.readByte() == 1;
|
||||||
boolean sendMaps = parcelWrite1st.readByte() == 1;
|
boolean sendFusionTables = parcel.readByte() == 1;
|
||||||
boolean sendFusionTables = parcelWrite1st.readByte() == 1;
|
boolean sendDocs = parcel.readByte() == 1;
|
||||||
boolean sendDocs = parcelWrite1st.readByte() == 1;
|
boolean newMap = parcel.readByte() == 1;
|
||||||
boolean newMap = parcelWrite1st.readByte() == 1;
|
Parcelable account = parcel.readParcelable(null);
|
||||||
Parcelable account = parcelWrite1st.readParcelable(null);
|
String mapId = parcel.readString();
|
||||||
String mapId = parcelWrite1st.readString();
|
boolean mapsSuccess = parcel.readByte() == 1;
|
||||||
boolean mapsSuccess = parcelWrite1st.readByte() == 1;
|
boolean fusionTablesSuccess = parcel.readByte() == 1;
|
||||||
boolean fusionTablesSuccess = parcelWrite1st.readByte() == 1;
|
boolean docsSuccess = parcel.readByte() == 1;
|
||||||
boolean docsSuccess = parcelWrite1st.readByte() == 1;
|
|
||||||
assertEquals(1, trackId);
|
assertEquals(1, trackId);
|
||||||
assertEquals(false, showMaps);
|
assertNull(sharingAppPackageName);
|
||||||
assertEquals(false, showFusionTables);
|
assertNull(sharingAppClassName);
|
||||||
assertEquals(false, showDocs);
|
assertFalse(sendMaps);
|
||||||
assertEquals(false, sendMaps);
|
assertFalse(sendFusionTables);
|
||||||
assertEquals(false, sendFusionTables);
|
assertFalse(sendDocs);
|
||||||
assertEquals(false, sendDocs);
|
assertFalse(newMap);
|
||||||
assertEquals(false, newMap);
|
assertNull(account);
|
||||||
assertEquals(null, account);
|
assertNull(mapId);
|
||||||
assertEquals(null, mapId);
|
assertFalse(mapsSuccess);
|
||||||
assertEquals(false, mapsSuccess);
|
assertFalse(fusionTablesSuccess);
|
||||||
assertEquals(false, fusionTablesSuccess);
|
assertFalse(docsSuccess);
|
||||||
assertEquals(false, docsSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link SendRequest#writeToParcel(Parcel, int)} when all input values
|
* Tests {@link SendRequest#writeToParcel(Parcel, int)}.
|
||||||
* are false or negative.
|
|
||||||
*/
|
*/
|
||||||
public void testWriteToParcel_allFalse() {
|
public void testWriteToParcel() {
|
||||||
sendRequest = new SendRequest(4, true, true, true);
|
sendRequest = new SendRequest(4);
|
||||||
|
sendRequest.setSharingAppPackageName("package");
|
||||||
|
sendRequest.setSharingAppClassName("class");
|
||||||
sendRequest.setSendMaps(true);
|
sendRequest.setSendMaps(true);
|
||||||
sendRequest.setSendFusionTables(true);
|
sendRequest.setSendFusionTables(true);
|
||||||
sendRequest.setSendDocs(true);
|
sendRequest.setSendDocs(true);
|
||||||
@@ -298,36 +254,33 @@ public class SendRequestTest extends AndroidTestCase {
|
|||||||
sendRequest.setMapsSuccess(true);
|
sendRequest.setMapsSuccess(true);
|
||||||
sendRequest.setFusionTablesSuccess(true);
|
sendRequest.setFusionTablesSuccess(true);
|
||||||
sendRequest.setDocsSuccess(true);
|
sendRequest.setDocsSuccess(true);
|
||||||
Parcel parcelWrite2nd = Parcel.obtain();
|
Parcel parcel = Parcel.obtain();
|
||||||
parcelWrite2nd.setDataPosition(0);
|
parcel.setDataPosition(0);
|
||||||
sendRequest.writeToParcel(parcelWrite2nd, 1);
|
sendRequest.writeToParcel(parcel, 1);
|
||||||
parcelWrite2nd.setDataPosition(0);
|
parcel.setDataPosition(0);
|
||||||
long trackId = parcelWrite2nd.readLong();
|
long trackId = parcel.readLong();
|
||||||
boolean showMaps = parcelWrite2nd.readByte() == 1;
|
String sharingAppPackageName = parcel.readString();
|
||||||
boolean showFusionTables = parcelWrite2nd.readByte() == 1;
|
String sharingAppClassName = parcel.readString();
|
||||||
boolean showDocs = parcelWrite2nd.readByte() == 1;
|
boolean sendMaps = parcel.readByte() == 1;
|
||||||
boolean sendMaps = parcelWrite2nd.readByte() == 1;
|
boolean sendFusionTables = parcel.readByte() == 1;
|
||||||
boolean sendFusionTables = parcelWrite2nd.readByte() == 1;
|
boolean sendDocs = parcel.readByte() == 1;
|
||||||
boolean sendDocs = parcelWrite2nd.readByte() == 1;
|
boolean newMap = parcel.readByte() == 1;
|
||||||
boolean newMap = parcelWrite2nd.readByte() == 1;
|
Parcelable account = parcel.readParcelable(null);
|
||||||
Parcelable account = parcelWrite2nd.readParcelable(null);
|
String mapId = parcel.readString();
|
||||||
String mapId = parcelWrite2nd.readString();
|
boolean mapsSuccess = parcel.readByte() == 1;
|
||||||
boolean mapsSuccess = parcelWrite2nd.readByte() == 1;
|
boolean fusionTablesSuccess = parcel.readByte() == 1;
|
||||||
boolean fusionTablesSuccess = parcelWrite2nd.readByte() == 1;
|
boolean docsSuccess = parcel.readByte() == 1;
|
||||||
boolean docsSuccess = parcelWrite2nd.readByte() == 1;
|
|
||||||
assertEquals(4, trackId);
|
assertEquals(4, trackId);
|
||||||
assertEquals(true, showMaps);
|
assertEquals("package", sharingAppPackageName);
|
||||||
assertEquals(true, showFusionTables);
|
assertEquals("class", sharingAppClassName);
|
||||||
assertEquals(true, showDocs);
|
assertTrue(sendMaps);
|
||||||
assertEquals(true, sendMaps);
|
assertTrue(sendFusionTables);
|
||||||
assertEquals(true, sendFusionTables);
|
assertTrue(sendDocs);
|
||||||
assertEquals(true, sendDocs);
|
assertTrue(newMap);
|
||||||
assertEquals(true, newMap);
|
|
||||||
assertEquals(accountNew, account);
|
assertEquals(accountNew, account);
|
||||||
assertEquals(MAPID, mapId);
|
assertEquals(MAPID, mapId);
|
||||||
assertEquals(true, mapsSuccess);
|
assertTrue(mapsSuccess);
|
||||||
assertEquals(true, fusionTablesSuccess);
|
assertTrue(fusionTablesSuccess);
|
||||||
assertEquals(true, docsSuccess);
|
assertTrue(docsSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ public class UploadResultActivityTest
|
|||||||
private void initialActivity(boolean isSendMaps, boolean isSendFusionTables, boolean isSendDocs,
|
private void initialActivity(boolean isSendMaps, boolean isSendFusionTables, boolean isSendDocs,
|
||||||
boolean isMapsSuccess, boolean isFusionTablesSuccess, boolean isDocsSuccess) {
|
boolean isMapsSuccess, boolean isFusionTablesSuccess, boolean isDocsSuccess) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
SendRequest sendRequest = new SendRequest(1L, true, true, true);
|
SendRequest sendRequest = new SendRequest(1L);
|
||||||
sendRequest.setSendMaps(isSendMaps);
|
sendRequest.setSendMaps(isSendMaps);
|
||||||
sendRequest.setSendFusionTables(isSendFusionTables);
|
sendRequest.setSendFusionTables(isSendFusionTables);
|
||||||
sendRequest.setSendDocs(isSendDocs);
|
sendRequest.setSendDocs(isSendDocs);
|
||||||
|
|||||||
+7
-41
@@ -50,7 +50,7 @@ public class UploadServiceChooserActivityTest extends
|
|||||||
*/
|
*/
|
||||||
public void testOnCreateDialog_displayAll() {
|
public void testOnCreateDialog_displayAll() {
|
||||||
// Initials activity to display all send items.
|
// Initials activity to display all send items.
|
||||||
initialActivity(true, true, true);
|
initialActivity();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
assertTrue(getMapsCheckBox().isShown());
|
assertTrue(getMapsCheckBox().isShown());
|
||||||
assertTrue(getFusionTablesCheckBox().isShown());
|
assertTrue(getFusionTablesCheckBox().isShown());
|
||||||
@@ -79,46 +79,13 @@ public class UploadServiceChooserActivityTest extends
|
|||||||
assertFalse(getExistingMapRadioButton().isShown());
|
assertFalse(getExistingMapRadioButton().isShown());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the logic to display only the "Send to Google Maps" option.
|
|
||||||
*/
|
|
||||||
public void testOnCreateDialog_displayOne() {
|
|
||||||
// Initials activity to display all send items.
|
|
||||||
initialActivity(true, false, false);
|
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
assertTrue(getMapsCheckBox().isShown());
|
|
||||||
|
|
||||||
// Clicks to enable this items.
|
|
||||||
uploadServiceChooserActivity.runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (!getMapsCheckBox().isChecked()) {
|
|
||||||
getMapsCheckBox().performClick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
assertTrue(getMapsCheckBox().isShown());
|
|
||||||
assertTrue(getNewMapRadioButton().isShown());
|
|
||||||
assertTrue(getExistingMapRadioButton().isShown());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the logic to display no option.
|
|
||||||
*/
|
|
||||||
public void testOnCreateDialog_displayNone() {
|
|
||||||
initialActivity(false, false, false);
|
|
||||||
assertFalse(getMapsCheckBox().isShown());
|
|
||||||
assertFalse(getFusionTablesCheckBox().isShown());
|
|
||||||
assertFalse(getDocsCheckBox().isShown());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the logic to initial state of check box to unchecked. This test cover
|
* Tests the logic to initial state of check box to unchecked. This test cover
|
||||||
* code in method {@link UploadServiceChooserActivity#onCreateDialog(int)},
|
* code in method {@link UploadServiceChooserActivity#onCreateDialog(int)},
|
||||||
* {@link UploadServiceChooserActivity#initState()}.
|
* {@link UploadServiceChooserActivity#initState()}.
|
||||||
*/
|
*/
|
||||||
public void testOnCreateDialog_initStateUnchecked() {
|
public void testOnCreateDialog_initStateUnchecked() {
|
||||||
initialActivity(true, true, true);
|
initialActivity();
|
||||||
// Initial all values to false in SharedPreferences.
|
// Initial all values to false in SharedPreferences.
|
||||||
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_maps_key, false);
|
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_maps_key, false);
|
||||||
PreferencesUtils.setBoolean(
|
PreferencesUtils.setBoolean(
|
||||||
@@ -141,7 +108,7 @@ public class UploadServiceChooserActivityTest extends
|
|||||||
* {@link UploadServiceChooserActivity#initState()}.
|
* {@link UploadServiceChooserActivity#initState()}.
|
||||||
*/
|
*/
|
||||||
public void testOnCreateDialog_initStateChecked() {
|
public void testOnCreateDialog_initStateChecked() {
|
||||||
initialActivity(true, true, true);
|
initialActivity();
|
||||||
// Initial all values to true in SharedPreferences.
|
// Initial all values to true in SharedPreferences.
|
||||||
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.pick_existing_map_key, true);
|
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.pick_existing_map_key, true);
|
||||||
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_maps_key, true);
|
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_maps_key, true);
|
||||||
@@ -168,7 +135,7 @@ public class UploadServiceChooserActivityTest extends
|
|||||||
* {@link UploadServiceChooserActivity#saveState()},
|
* {@link UploadServiceChooserActivity#saveState()},
|
||||||
*/
|
*/
|
||||||
public void testOnCreateDialog_saveState() {
|
public void testOnCreateDialog_saveState() {
|
||||||
initialActivity(true, true, true);
|
initialActivity();
|
||||||
// Initial all values to true in SharedPreferences.
|
// Initial all values to true in SharedPreferences.
|
||||||
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_maps_key, true);
|
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_maps_key, true);
|
||||||
PreferencesUtils.setBoolean(
|
PreferencesUtils.setBoolean(
|
||||||
@@ -197,7 +164,7 @@ public class UploadServiceChooserActivityTest extends
|
|||||||
* {@link UploadServiceChooserActivity#startNextActivity()}.
|
* {@link UploadServiceChooserActivity#startNextActivity()}.
|
||||||
*/
|
*/
|
||||||
public void testOnCreateDialog_startNextActivity() {
|
public void testOnCreateDialog_startNextActivity() {
|
||||||
initialActivity(true, true, true);
|
initialActivity();
|
||||||
// Initial all values to true or false in SharedPreferences.
|
// Initial all values to true or false in SharedPreferences.
|
||||||
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_maps_key, true);
|
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_maps_key, true);
|
||||||
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_docs_key, true);
|
PreferencesUtils.setBoolean(uploadServiceChooserActivity, R.string.send_to_docs_key, true);
|
||||||
@@ -224,10 +191,9 @@ public class UploadServiceChooserActivityTest extends
|
|||||||
* @param showFusionTables
|
* @param showFusionTables
|
||||||
* @param showDocs
|
* @param showDocs
|
||||||
*/
|
*/
|
||||||
private void initialActivity(boolean showMaps, boolean showFusionTables, boolean showDocs) {
|
private void initialActivity() {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(SendRequest.SEND_REQUEST_KEY, new SendRequest(1L, showMaps, showFusionTables,
|
intent.putExtra(SendRequest.SEND_REQUEST_KEY, new SendRequest(1L));
|
||||||
showDocs));
|
|
||||||
setActivityIntent(intent);
|
setActivityIntent(intent);
|
||||||
uploadServiceChooserActivity = this.getActivity();
|
uploadServiceChooserActivity = this.getActivity();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user