forked from upstream-mirrors/OpenTracks
Add Send to Drive in ChooseUploadServiceDialogFragment
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -21,6 +21,16 @@ limitations under the License.
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:stretchColumns="1" >
|
android:stretchColumns="1" >
|
||||||
|
<TableRow>
|
||||||
|
<ImageView
|
||||||
|
android:contentDescription="@string/send_google_drive"
|
||||||
|
android:src="@drawable/google_drive_icon"
|
||||||
|
style="@style/ChooseUploadServiceImageView" />
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/choose_upload_service_drive"
|
||||||
|
android:text="@string/send_google_drive"
|
||||||
|
style="@style/ChooseUploadServiceCheckBox" />
|
||||||
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:contentDescription="@string/send_google_maps"
|
android:contentDescription="@string/send_google_maps"
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ limitations under the License.
|
|||||||
<string name="pick_existing_map_key">pickExistingMap</string>
|
<string name="pick_existing_map_key">pickExistingMap</string>
|
||||||
<string name="report_speed_key">reportSpeed</string>
|
<string name="report_speed_key">reportSpeed</string>
|
||||||
<string name="send_to_docs_key">sendToDocs</string>
|
<string name="send_to_docs_key">sendToDocs</string>
|
||||||
|
<string name="send_to_drive_key">sendToDrive</string>
|
||||||
<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>
|
||||||
|
|||||||
@@ -1436,6 +1436,11 @@ limitations under the License.
|
|||||||
checkbox option to send to Google Docs.">
|
checkbox option to send to Google Docs.">
|
||||||
Google Docs
|
Google Docs
|
||||||
</string>
|
</string>
|
||||||
|
<string name="send_google_drive"
|
||||||
|
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
|
||||||
|
checkbox option to send to Google Drive.">
|
||||||
|
Google Drive
|
||||||
|
</string>
|
||||||
<string name="send_google_error"
|
<string name="send_google_error"
|
||||||
translation_description="When sending a track to Google, a message indicating that an error has
|
translation_description="When sending a track to Google, a message indicating that an error has
|
||||||
occurred and ask the user to try again.">
|
occurred and ask the user to try again.">
|
||||||
|
|||||||
+22
-16
@@ -13,6 +13,7 @@
|
|||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks.fragments;
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.io.sendtogoogle.AccountChooserActivity;
|
import com.google.android.apps.mytracks.io.sendtogoogle.AccountChooserActivity;
|
||||||
@@ -52,8 +53,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putParcelable(KEY_SEND_REQUEST, sendRequest);
|
bundle.putParcelable(KEY_SEND_REQUEST, sendRequest);
|
||||||
|
|
||||||
ChooseUploadServiceDialogFragment chooseUploadServiceDialogFragment =
|
ChooseUploadServiceDialogFragment chooseUploadServiceDialogFragment = new ChooseUploadServiceDialogFragment();
|
||||||
new ChooseUploadServiceDialogFragment();
|
|
||||||
chooseUploadServiceDialogFragment.setArguments(bundle);
|
chooseUploadServiceDialogFragment.setArguments(bundle);
|
||||||
return chooseUploadServiceDialogFragment;
|
return chooseUploadServiceDialogFragment;
|
||||||
}
|
}
|
||||||
@@ -61,6 +61,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
private FragmentActivity activity;
|
private FragmentActivity activity;
|
||||||
private SendRequest sendRequest;
|
private SendRequest sendRequest;
|
||||||
|
|
||||||
|
private CheckBox driveCheckBox;
|
||||||
private CheckBox mapsCheckBox;
|
private CheckBox mapsCheckBox;
|
||||||
private CheckBox fusionTablesCheckBox;
|
private CheckBox fusionTablesCheckBox;
|
||||||
private CheckBox docsCheckBox;
|
private CheckBox docsCheckBox;
|
||||||
@@ -75,10 +76,13 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
View view = activity.getLayoutInflater().inflate(R.layout.choose_upload_service, null);
|
View view = activity.getLayoutInflater().inflate(R.layout.choose_upload_service, null);
|
||||||
|
|
||||||
|
driveCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_drive);
|
||||||
mapsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_maps);
|
mapsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_maps);
|
||||||
fusionTablesCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_fusion_tables);
|
fusionTablesCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_fusion_tables);
|
||||||
docsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_docs);
|
docsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_docs);
|
||||||
|
|
||||||
|
driveCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||||
|
activity, R.string.send_to_drive_key, PreferencesUtils.SEND_TO_DRIVE_DEFAULT));
|
||||||
mapsCheckBox.setChecked(PreferencesUtils.getBoolean(
|
mapsCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||||
activity, R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT));
|
activity, R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT));
|
||||||
fusionTablesCheckBox.setChecked(PreferencesUtils.getBoolean(
|
fusionTablesCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||||
@@ -97,8 +101,8 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
RadioButton newMapRadioButton = (RadioButton) view.findViewById(
|
RadioButton newMapRadioButton = (RadioButton) view.findViewById(
|
||||||
R.id.choose_upload_service_new_map);
|
R.id.choose_upload_service_new_map);
|
||||||
boolean defaultMapPublic = PreferencesUtils.getBoolean(activity,
|
boolean defaultMapPublic = PreferencesUtils.getBoolean(
|
||||||
R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT);
|
activity, R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT);
|
||||||
newMapRadioButton.setText(defaultMapPublic ? R.string.send_google_new_public_map
|
newMapRadioButton.setText(defaultMapPublic ? R.string.send_google_new_public_map
|
||||||
: R.string.send_google_new_unlisted_map);
|
: R.string.send_google_new_unlisted_map);
|
||||||
|
|
||||||
@@ -106,8 +110,8 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
R.id.choose_upload_service_existing_map);
|
R.id.choose_upload_service_existing_map);
|
||||||
|
|
||||||
updateMapsOption();
|
updateMapsOption();
|
||||||
if (PreferencesUtils.getBoolean(activity, R.string.pick_existing_map_key,
|
if (PreferencesUtils.getBoolean(
|
||||||
PreferencesUtils.PICK_EXISTING_MAP_DEFAULT)) {
|
activity, R.string.pick_existing_map_key, PreferencesUtils.PICK_EXISTING_MAP_DEFAULT)) {
|
||||||
existingMapRadioButton.setChecked(true);
|
existingMapRadioButton.setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
newMapRadioButton.setChecked(true);
|
newMapRadioButton.setChecked(true);
|
||||||
@@ -117,27 +121,25 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
.setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
PreferencesUtils.setBoolean(
|
||||||
|
activity, R.string.send_to_drive_key, driveCheckBox.isChecked());
|
||||||
PreferencesUtils.setBoolean(
|
PreferencesUtils.setBoolean(
|
||||||
activity, R.string.pick_existing_map_key, existingMapRadioButton.isChecked());
|
activity, R.string.pick_existing_map_key, existingMapRadioButton.isChecked());
|
||||||
PreferencesUtils.setBoolean(
|
PreferencesUtils.setBoolean(
|
||||||
activity, R.string.send_to_maps_key, mapsCheckBox.isChecked());
|
activity, R.string.send_to_maps_key, mapsCheckBox.isChecked());
|
||||||
PreferencesUtils.setBoolean(activity, R.string.send_to_fusion_tables_key,
|
PreferencesUtils.setBoolean(
|
||||||
fusionTablesCheckBox.isChecked());
|
activity, R.string.send_to_fusion_tables_key, fusionTablesCheckBox.isChecked());
|
||||||
PreferencesUtils.setBoolean(
|
PreferencesUtils.setBoolean(
|
||||||
activity, R.string.send_to_docs_key, docsCheckBox.isChecked());
|
activity, R.string.send_to_docs_key, docsCheckBox.isChecked());
|
||||||
if (mapsCheckBox.isChecked() || fusionTablesCheckBox.isChecked()
|
if (driveCheckBox.isChecked() || mapsCheckBox.isChecked()
|
||||||
|| docsCheckBox.isChecked()) {
|
|| fusionTablesCheckBox.isChecked() || docsCheckBox.isChecked()) {
|
||||||
startNextActivity();
|
startNextActivity();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(activity, R.string.send_google_no_service_selected, Toast.LENGTH_LONG)
|
||||||
activity, R.string.send_google_no_service_selected, Toast.LENGTH_LONG)
|
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}).setTitle(R.string.send_google_title).setView(view).create();
|
||||||
.setTitle(R.string.send_google_title)
|
|
||||||
.setView(view)
|
|
||||||
.create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,6 +153,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
* Starts the next activity, {@link AccountChooserActivity}.
|
* Starts the next activity, {@link AccountChooserActivity}.
|
||||||
*/
|
*/
|
||||||
private void startNextActivity() {
|
private void startNextActivity() {
|
||||||
|
sendRequest.setSendDrive(driveCheckBox.isChecked());
|
||||||
sendRequest.setSendMaps(mapsCheckBox.isChecked());
|
sendRequest.setSendMaps(mapsCheckBox.isChecked());
|
||||||
sendRequest.setSendFusionTables(fusionTablesCheckBox.isChecked());
|
sendRequest.setSendFusionTables(fusionTablesCheckBox.isChecked());
|
||||||
sendRequest.setSendDocs(docsCheckBox.isChecked());
|
sendRequest.setSendDocs(docsCheckBox.isChecked());
|
||||||
@@ -165,6 +168,9 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
* Sends stats to Google Analytics.
|
* Sends stats to Google Analytics.
|
||||||
*/
|
*/
|
||||||
private void sendStats() {
|
private void sendStats() {
|
||||||
|
if (sendRequest.isSendDrive()) {
|
||||||
|
AnalyticsUtils.sendPageViews(activity, "/send/drive");
|
||||||
|
}
|
||||||
if (sendRequest.isSendMaps()) {
|
if (sendRequest.isSendMaps()) {
|
||||||
AnalyticsUtils.sendPageViews(activity, "/send/maps");
|
AnalyticsUtils.sendPageViews(activity, "/send/maps");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,14 @@ public class SendRequest implements Parcelable {
|
|||||||
private long trackId = -1L;
|
private long trackId = -1L;
|
||||||
private String sharingAppPackageName = null;
|
private String sharingAppPackageName = null;
|
||||||
private String sharingAppClassName = null;
|
private String sharingAppClassName = null;
|
||||||
|
private boolean sendDrive = 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;
|
||||||
private boolean newMap = false;
|
private boolean newMap = false;
|
||||||
private Account account = null;
|
private Account account = null;
|
||||||
private String mapId = null;
|
private String mapId = null;
|
||||||
|
private boolean driveSuccess = false;
|
||||||
private boolean mapsSuccess = false;
|
private boolean mapsSuccess = false;
|
||||||
private boolean docsSuccess = false;
|
private boolean docsSuccess = false;
|
||||||
private boolean fusionTablesSuccess = false;
|
private boolean fusionTablesSuccess = false;
|
||||||
@@ -91,6 +93,23 @@ public class SendRequest implements Parcelable {
|
|||||||
this.sharingAppClassName = sharingAppClassName;
|
this.sharingAppClassName = sharingAppClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the user has selected the send to Google Drive option.
|
||||||
|
*/
|
||||||
|
public boolean isSendDrive() {
|
||||||
|
return sendDrive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the send to Google Drive option.
|
||||||
|
*
|
||||||
|
* @param sendDrive true if the user has selected the send to Google Drive
|
||||||
|
* option
|
||||||
|
*/
|
||||||
|
public void setSendDrive(boolean sendDrive) {
|
||||||
|
this.sendDrive = sendDrive;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the user has selected the send to Google Maps option.
|
* True if the user has selected the send to Google Maps option.
|
||||||
*/
|
*/
|
||||||
@@ -191,6 +210,22 @@ public class SendRequest implements Parcelable {
|
|||||||
this.mapId = mapId;
|
this.mapId = mapId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if sending to Google Drive is success.
|
||||||
|
*/
|
||||||
|
public boolean isDriveSuccess() {
|
||||||
|
return driveSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Google Drive result.
|
||||||
|
*
|
||||||
|
* @param driveSuccess true if sending to Google Drive is success
|
||||||
|
*/
|
||||||
|
public void setDriveSuccess(boolean driveSuccess) {
|
||||||
|
this.driveSuccess = driveSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if sending to Google Maps is success.
|
* True if sending to Google Maps is success.
|
||||||
*/
|
*/
|
||||||
@@ -244,12 +279,14 @@ public class SendRequest implements Parcelable {
|
|||||||
trackId = in.readLong();
|
trackId = in.readLong();
|
||||||
sharingAppPackageName = in.readString();
|
sharingAppPackageName = in.readString();
|
||||||
sharingAppClassName = in.readString();
|
sharingAppClassName = in.readString();
|
||||||
|
sendDrive = 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;
|
||||||
newMap = in.readByte() == 1;
|
newMap = in.readByte() == 1;
|
||||||
account = in.readParcelable(null);
|
account = in.readParcelable(null);
|
||||||
mapId = in.readString();
|
mapId = in.readString();
|
||||||
|
driveSuccess = in.readByte() == 1;
|
||||||
mapsSuccess = in.readByte() == 1;
|
mapsSuccess = in.readByte() == 1;
|
||||||
fusionTablesSuccess = in.readByte() == 1;
|
fusionTablesSuccess = in.readByte() == 1;
|
||||||
docsSuccess = in.readByte() == 1;
|
docsSuccess = in.readByte() == 1;
|
||||||
@@ -265,12 +302,14 @@ public class SendRequest implements Parcelable {
|
|||||||
out.writeLong(trackId);
|
out.writeLong(trackId);
|
||||||
out.writeString(sharingAppPackageName);
|
out.writeString(sharingAppPackageName);
|
||||||
out.writeString(sharingAppClassName);
|
out.writeString(sharingAppClassName);
|
||||||
|
out.writeByte((byte) (sendDrive ? 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));
|
||||||
out.writeByte((byte) (newMap ? 1 : 0));
|
out.writeByte((byte) (newMap ? 1 : 0));
|
||||||
out.writeParcelable(account, 0);
|
out.writeParcelable(account, 0);
|
||||||
out.writeString(mapId);
|
out.writeString(mapId);
|
||||||
|
out.writeByte((byte) (driveSuccess ? 1 : 0));
|
||||||
out.writeByte((byte) (mapsSuccess ? 1 : 0));
|
out.writeByte((byte) (mapsSuccess ? 1 : 0));
|
||||||
out.writeByte((byte) (fusionTablesSuccess ? 1 : 0));
|
out.writeByte((byte) (fusionTablesSuccess ? 1 : 0));
|
||||||
out.writeByte((byte) (docsSuccess ? 1 : 0));
|
out.writeByte((byte) (docsSuccess ? 1 : 0));
|
||||||
|
|||||||
@@ -78,9 +78,12 @@ public class PreferencesUtils {
|
|||||||
public static final boolean RECORDING_TRACK_PAUSED_DEFAULT = true;
|
public static final boolean RECORDING_TRACK_PAUSED_DEFAULT = true;
|
||||||
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_FUSION_TABLES_DEFAULT = true;
|
public static final boolean SEND_TO_DRIVE_DEFAULT = false;
|
||||||
public static final boolean SEND_TO_MAPS_DEFAULT = true;
|
public static final boolean SEND_TO_DOCS_DEFAULT = false;
|
||||||
|
public static final boolean SEND_TO_FUSION_TABLES_DEFAULT = false;
|
||||||
|
public static final boolean SEND_TO_MAPS_DEFAULT = false;
|
||||||
|
|
||||||
public static final String SENSOR_TYPE_DEFAULT = "NONE";
|
public static final String SENSOR_TYPE_DEFAULT = "NONE";
|
||||||
public static final boolean SHOW_CONFIRM_PLAY_DIALOG_DEFAULT = true;
|
public static final boolean SHOW_CONFIRM_PLAY_DIALOG_DEFAULT = true;
|
||||||
public static final boolean SHOW_CONFIRM_SHARING_DIALOG_DEFAULT = true;
|
public static final boolean SHOW_CONFIRM_SHARING_DIALOG_DEFAULT = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user