forked from upstream-mirrors/OpenTracks
Improve share track dialog
This commit is contained in:
+40
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user