Improve share track dialog

This commit is contained in:
Jimmy Shih
2013-06-07 10:10:55 -07:00
parent 4efd2a3f5e
commit 9571afa286
7 changed files with 91 additions and 29 deletions
+18 -11
View File
@@ -20,24 +20,31 @@ limitations under the License.
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:text="@string/share_track_emails_label"
style="@style/EditLabel" />
android:paddingBottom="16dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp" >
<CheckBox
android:id="@+id/share_track_public"
android:layout_gravity="center_vertical"
android:text="@string/share_track_public"
style="@style/TextMedium" />
<CheckBox
android:id="@+id/share_track_invite"
android:layout_gravity="center_vertical"
android:layout_marginTop="16dp"
android:text="@string/share_track_invite"
style="@style/TextMedium" />
<MultiAutoCompleteTextView
android:completionThreshold="1"
android:hint="@string/share_track_emails_hint"
android:id="@+id/share_track_emails"
android:imeOptions="actionDone"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_width="match_parent"
android:singleLine="false" >
android:singleLine="false"
android:visibility="gone" >
</MultiAutoCompleteTextView>
<CheckBox
android:id="@+id/share_track_public"
android:layout_gravity="center_vertical"
android:layout_marginTop="16dp"
android:text="@string/share_track_public"
style="@style/TextMedium" />
</LinearLayout>
</ScrollView>
+2
View File
@@ -37,6 +37,8 @@ limitations under the License.
<string name="min_required_accuracy_key">minRequiredAccuracy</string>
<string name="report_speed_key">reportSpeed</string>
<string name="sensor_type_key">sensorType</string>
<string name="share_track_invite_key">shareTrackInvite</string>
<string name="share_track_public_key">shareTrackPublic</string>
<string name="split_frequency_key">splitFrequency</string>
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
<string name="stats_show_grade_elevation_key">statsShowGradeElevation</string>
+13 -4
View File
@@ -2007,10 +2007,19 @@ limitations under the License.
translation_description="The hint for the auto complete text box for entering email addresses.">
Email addresses
</string>
<string name="share_track_emails_label"
translation_description="The label for the auto complete text box for entering email
addresses.">
Invite to view:
<string name="share_track_invite"
translation_description="The checkbox to invite people to view a track.">
Invite people to view
</string>
<string name="share_track_no_emails"
translation_description="When sharing a track, error message indicating that no email addresses
is entered.">
No email addresses entered.
</string>
<string name="share_track_no_selection"
translation_description="When sharing a track, error message indicating that no option is
selected.">
No option selected.
</string>
<string name="share_track_picker_title"
translation_description="When sharing a track with friends, the title on the picker to ask the
@@ -16,6 +16,7 @@
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
@@ -31,8 +32,11 @@ import android.support.v4.app.FragmentActivity;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FilterQueryProvider;
import android.widget.MultiAutoCompleteTextView;
import android.widget.Toast;
/**
* A DialogFragment to share a track.
@@ -73,8 +77,9 @@ public class ShareTrackDialogFragment extends DialogFragment {
private ShareTrackCaller caller;
private FragmentActivity fragmentActivity;
private MultiAutoCompleteTextView multiAutoCompleteTextView;
private CheckBox checkBox;
private CheckBox publicCheckBox;
private CheckBox inviteCheckBox;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
@@ -90,7 +95,7 @@ public class ShareTrackDialogFragment extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
fragmentActivity = getActivity();
View view = fragmentActivity.getLayoutInflater().inflate(R.layout.share_track, null);
multiAutoCompleteTextView = (MultiAutoCompleteTextView) view.findViewById(
R.id.share_track_emails);
multiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
@@ -114,15 +119,43 @@ public class ShareTrackDialogFragment extends DialogFragment {
});
multiAutoCompleteTextView.setAdapter(adapter);
checkBox = (CheckBox) view.findViewById(R.id.share_track_public);
publicCheckBox = (CheckBox) view.findViewById(R.id.share_track_public);
publicCheckBox.setChecked(PreferencesUtils.getBoolean(
fragmentActivity, R.string.share_track_public_key,
PreferencesUtils.SHARE_TRACK_PUBLIC_DEFAULT));
inviteCheckBox = (CheckBox) view.findViewById(R.id.share_track_invite);
inviteCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
multiAutoCompleteTextView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
}
});
inviteCheckBox.setChecked(PreferencesUtils.getBoolean(
fragmentActivity, R.string.share_track_invite_key,
PreferencesUtils.SHARE_TRACK_INVITE_DEFAULT));
return new AlertDialog.Builder(fragmentActivity).setNegativeButton(
R.string.generic_cancel, null)
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String acl = multiAutoCompleteTextView.getText().toString();
caller.onShareTrackDone(acl, checkBox.isChecked());
if (!publicCheckBox.isChecked() && !inviteCheckBox.isChecked()) {
Toast.makeText(fragmentActivity, R.string.share_track_no_selection, Toast.LENGTH_LONG)
.show();
return;
}
String acl = multiAutoCompleteTextView.getText().toString().trim();
if (!publicCheckBox.isChecked() && acl.equals("")) {
Toast.makeText(fragmentActivity, R.string.share_track_no_emails, Toast.LENGTH_LONG)
.show();
return;
}
PreferencesUtils.setBoolean(
fragmentActivity, R.string.share_track_public_key, publicCheckBox.isChecked());
PreferencesUtils.setBoolean(
fragmentActivity, R.string.share_track_invite_key, inviteCheckBox.isChecked());
caller.onShareTrackDone(acl, publicCheckBox.isChecked());
}
}).setTitle(R.string.share_track_title).setView(view).create();
}
@@ -127,7 +127,7 @@ public class SendDriveAsyncTask extends AbstractSendAsyncTask {
* Adds permission.
*
* @param drive the drive
* @param driveId the drive id
* @param file the drive file
*/
private void addPermission(Drive drive, File file) throws IOException {
if (isPublic) {
@@ -48,6 +48,7 @@ public class PreferencesUtils {
public static final int AUTO_RESUME_TRACK_TIMEOUT_NEVER = 0;
public static final String BLUETOOTH_SENSOR_DEFAULT = "";
public static final boolean CHART_BY_DISTANCE_DEFAULT = true;
public static final boolean CHART_SHOW_CADENCE_DEFAULT = true;
public static final boolean CHART_SHOW_ELEVATION_DEFAULT = true;
@@ -59,6 +60,7 @@ public class PreferencesUtils {
public static final boolean CONFIRM_SHARE_DRIVE_DEFAULT = true;
public static final String DEFAULT_ACTIVITY_DEFAULT = "";
public static final String DRIVE_DELETED_LIST_DEFAULT = "";
public static final long DRIVE_LARGEST_CHANGE_ID_DEFAULT = -1L;
public static final boolean DRIVE_SYNC_DEFAULT = false;
@@ -72,9 +74,7 @@ public class PreferencesUtils {
public static final int FREQUENCY_OFF = 0;
public static final String GOOGLE_ACCOUNT_DEFAULT = "";
public static final int MAP_TYPE_DEFAUlT = 1;
public static final int MAX_RECORDING_DISTANCE_DEFAULT = 200;
public static final boolean METRIC_UNITS_DEFAULT = true;
public static final int MIN_RECORDING_DISTANCE_DEFAULT = 5;
@@ -93,16 +93,27 @@ public class PreferencesUtils {
public static final boolean RECORDING_TRACK_PAUSED_DEFAULT = true;
public static final boolean REPORT_SPEED_DEFAULT = true;
public static final long SELECTED_TRACK_ID_DEFAULT = -1L;
public static final String SENSOR_TYPE_DEFAULT = "NONE";
// Share track
public static final boolean SHARE_TRACK_INVITE_DEFAULT = false;
public static final boolean SHARE_TRACK_PUBLIC_DEFAULT = false;
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
// Stats
public static final boolean STATS_SHOW_COORDINATE_DEFAULT = false;
public static final boolean STATS_SHOW_GRADE_ELEVATION_DEFAULT = false;
// Track color
public static final String TRACK_COLOR_MODE_DEFAULT = "SINGLE";
public static final int TRACK_COLOR_MODE_MEDIUM_DEFAULT = 15;
public static final int TRACK_COLOR_MODE_PERCENTAGE_DEFAULT = 25;
public static final int TRACK_COLOR_MODE_SLOW_DEFAULT = 9;
public static final String TRACK_NAME_DEFAULT = "LOCATION";
// Track widget
public static final int TRACK_WIDGET_ITEM1_DEFAULT = 3; // moving time
public static final int TRACK_WIDGET_ITEM2_DEFAULT = 0; // distance
public static final int TRACK_WIDGET_ITEM3_DEFAULT = 1; // total time
@@ -32,14 +32,14 @@ import junit.framework.TestCase;
public class SendFusionTablesUtilsTest extends TestCase {
/**
* Tests {@link SendFusionTablesUtils#getMapUrl(Track)} with null track.
* Tests {@link SendFusionTablesUtils#getMapUrl(Track, String)} with null track.
*/
public void testGetMapUrl_null_track() {
assertEquals(null, SendFusionTablesUtils.getMapUrl(null, "123"));
}
/**
* Tests {@link SendFusionTablesUtils#getMapUrl(Track)} with null stats.
* Tests {@link SendFusionTablesUtils#getMapUrl(Track, String)} with null stats.
*/
public void testGetMapUrl_null_stats() {
Track track = new Track();
@@ -48,7 +48,7 @@ public class SendFusionTablesUtilsTest extends TestCase {
}
/**
* Tests {@link SendFusionTablesUtils#getMapUrl(Track)} with a valid track.
* Tests {@link SendFusionTablesUtils#getMapUrl(Track, String)} with a valid track.
*/
public void testGetMapUrl_valid_track() {
Track track = new Track();