mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-06 11:33:06 +02:00
Merge heads
This commit is contained in:
@@ -22,6 +22,7 @@ import com.google.android.maps.mytracks.R;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* An activity that displays the help page.
|
||||
@@ -35,6 +36,16 @@ public class HelpActivity extends AbstractMyTracksActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.help);
|
||||
|
||||
TextView mapsPublicUnlisted = (TextView) findViewById(R.id.help_maps_public_unlisted_answer);
|
||||
mapsPublicUnlisted.setText(getString(
|
||||
R.string.help_maps_public_unlisted_answer, getString(R.string.maps_public_unlisted_url)));
|
||||
|
||||
TextView googleServices = (TextView) findViewById(R.id.help_google_services_answer);
|
||||
googleServices.setText(getString(R.string.help_google_services_answer,
|
||||
getString(R.string.send_google_maps_url),
|
||||
getString(R.string.send_google_fusion_tables_url),
|
||||
getString(R.string.send_google_docs_url)));
|
||||
|
||||
findViewById(R.id.help_ok).setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.io.sendtogoogle.AccountChooserActivity;
|
||||
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
|
||||
import com.google.android.apps.mytracks.io.sendtogoogle.ConfirmSharingActivity;
|
||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ChooseActivityDialogFragment extends DialogFragment {
|
||||
sendRequest.setNewMap(true);
|
||||
sendRequest.setSharingAppPackageName(packageName);
|
||||
sendRequest.setSharingAppClassName(className);
|
||||
Intent intent = IntentUtils.newIntent(getActivity(), AccountChooserActivity.class)
|
||||
Intent intent = IntentUtils.newIntent(getActivity(), ConfirmSharingActivity.class)
|
||||
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
|
||||
startActivity(intent);
|
||||
dismiss();
|
||||
|
||||
+6
@@ -90,8 +90,14 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
});
|
||||
|
||||
mapsOptionTableRow = (TableRow) view.findViewById(R.id.choose_upload_service_maps_options);
|
||||
|
||||
RadioButton newMapRadioButton = (RadioButton) view.findViewById(
|
||||
R.id.choose_upload_service_new_map);
|
||||
boolean defaultMapPublic = PreferencesUtils.getBoolean(getActivity(),
|
||||
R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT);
|
||||
newMapRadioButton.setText(defaultMapPublic ? R.string.send_google_new_public_map
|
||||
: R.string.send_google_new_unlisted_map);
|
||||
|
||||
existingMapRadioButton = (RadioButton) view.findViewById(
|
||||
R.id.choose_upload_service_existing_map);
|
||||
|
||||
|
||||
+5
-5
@@ -90,15 +90,15 @@ public class AccountChooserActivity extends Activity {
|
||||
|
||||
if (accounts.length == 1) {
|
||||
sendRequest.setAccount(accounts[0]);
|
||||
PreferencesUtils.setString(this, R.string.sharing_account_key, accounts[0].name);
|
||||
PreferencesUtils.setString(this, R.string.google_account_key, accounts[0].name);
|
||||
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
|
||||
return;
|
||||
}
|
||||
|
||||
String sharingAccount = PreferencesUtils.getString(this, R.string.sharing_account_key,
|
||||
PreferencesUtils.SHARING_ACCOUNT_DEFAULT);
|
||||
String googleAccount = PreferencesUtils.getString(this, R.string.google_account_key,
|
||||
PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT);
|
||||
for (int i = 0; i < accounts.length; i++) {
|
||||
if (accounts[i].name.equals(sharingAccount)) {
|
||||
if (accounts[i].name.equals(googleAccount)) {
|
||||
sendRequest.setAccount(accounts[i]);
|
||||
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
|
||||
return;
|
||||
@@ -160,7 +160,7 @@ public class AccountChooserActivity extends Activity {
|
||||
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||
Account account = accounts[position];
|
||||
PreferencesUtils.setString(
|
||||
AccountChooserActivity.this, R.string.sharing_account_key, account.name);
|
||||
AccountChooserActivity.this, R.string.google_account_key, account.name);
|
||||
sendRequest.setAccount(account);
|
||||
getPermission(MapsConstants.SERVICE_NAME, sendRequest.isSendMaps(), mapsCallback);
|
||||
}
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.android.apps.mytracks.io.sendtogoogle;
|
||||
|
||||
import com.google.android.apps.mytracks.util.DialogUtils;
|
||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* An interstitial to confirm sharing with friends.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class ConfirmSharingActivity extends Activity {
|
||||
|
||||
private static final int DIALOG_ID = 0;
|
||||
|
||||
private SendRequest sendRequest;
|
||||
private CheckBox checkBox;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
sendRequest = getIntent().getParcelableExtra(SendRequest.SEND_REQUEST_KEY);
|
||||
if (PreferencesUtils.getBoolean(this, R.string.show_confirm_sharing_dialog_key,
|
||||
PreferencesUtils.SHOW_CONFIRM_SHARING_DIALOG_DEFAULT)) {
|
||||
showDialog(DIALOG_ID);
|
||||
} else {
|
||||
startNextActivity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
if (id != DIALOG_ID) {
|
||||
return null;
|
||||
}
|
||||
View view = getLayoutInflater().inflate(R.layout.confirm_sharing, null);
|
||||
|
||||
TextView textView = (TextView) view.findViewById(R.id.confirm_sharing_text_view);
|
||||
textView.setText(getString(
|
||||
R.string.share_track_confirm_message, getString(R.string.maps_public_unlisted_url)));
|
||||
|
||||
checkBox = (CheckBox) view.findViewById(R.id.confirm_sharing_check_box);
|
||||
DialogInterface.OnClickListener okListener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int button) {
|
||||
PreferencesUtils.setBoolean(ConfirmSharingActivity.this,
|
||||
R.string.show_confirm_sharing_dialog_key, !checkBox.isChecked());
|
||||
startNextActivity();
|
||||
}
|
||||
};
|
||||
DialogInterface.OnClickListener cancelListener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int button) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
Dialog dialog = DialogUtils.createConfirmationDialog(
|
||||
this, -1, view, okListener, cancelListener);
|
||||
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialogInterface) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
return dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the next activity for sharing with friends and finishes this
|
||||
* activity.
|
||||
*/
|
||||
private void startNextActivity() {
|
||||
Intent intent = IntentUtils.newIntent(this, AccountChooserActivity.class)
|
||||
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -22,17 +22,24 @@ import com.google.android.apps.mytracks.util.IntentUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An activity for accessing settings.
|
||||
*
|
||||
@@ -44,6 +51,7 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
private static final String TAG = SettingsActivity.class.getSimpleName();
|
||||
private static final int DIALOG_CONFIRM_RESET_ID = 0;
|
||||
|
||||
private ListPreference googleAccountListPreference;
|
||||
private Preference resetPreference;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -123,6 +131,29 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
}
|
||||
});
|
||||
|
||||
googleAccountListPreference = (ListPreference) findPreference(getString(R.string.google_account_key));
|
||||
List<String> entries = new ArrayList<String>();
|
||||
Account[] accounts = AccountManager.get(this).getAccountsByType(Constants.ACCOUNT_TYPE);
|
||||
for (Account account : accounts) {
|
||||
entries.add(account.name);
|
||||
}
|
||||
googleAccountListPreference.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
||||
googleAccountListPreference.setEntryValues(entries.toArray(
|
||||
new CharSequence[entries.size()]));
|
||||
if (entries.size() == 1) {
|
||||
googleAccountListPreference.setValueIndex(0);
|
||||
}
|
||||
String googleAccount = PreferencesUtils.getString(this, R.string.google_account_key,
|
||||
PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT);
|
||||
updateSwitchAccountSummary(googleAccount);
|
||||
googleAccountListPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
updateSwitchAccountSummary((String) newValue);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
resetPreference = findPreference(getString(R.string.settings_reset_key));
|
||||
resetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
@@ -143,6 +174,17 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
||||
: R.string.settings_reset_summary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the switch account summary.
|
||||
*
|
||||
* @param value the value
|
||||
*/
|
||||
private void updateSwitchAccountSummary(String value) {
|
||||
googleAccountListPreference.setSummary(
|
||||
PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT.equals(value) ? getString(R.string.value_unknown)
|
||||
: value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
if (id != DIALOG_CONFIRM_RESET_ID) {
|
||||
|
||||
+33
-23
@@ -16,23 +16,17 @@
|
||||
|
||||
package com.google.android.apps.mytracks.settings;
|
||||
|
||||
import com.google.android.apps.mytracks.Constants;
|
||||
import com.google.android.apps.mytracks.util.DialogUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An activity for accessing the sharing settings.
|
||||
*
|
||||
@@ -42,6 +36,7 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
|
||||
|
||||
private static final int DIALOG_CONFIRM_ALLOW_ACCESS_ID = 0;
|
||||
|
||||
private CheckBoxPreference defaultMapPublicCheckBoxPreference;
|
||||
private CheckBoxPreference allowAccessCheckBoxPreference;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -50,6 +45,26 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
|
||||
super.onCreate(bundle);
|
||||
addPreferencesFromResource(R.xml.sharing_settings);
|
||||
|
||||
defaultMapPublicCheckBoxPreference = (CheckBoxPreference) findPreference(
|
||||
getString(R.string.default_map_public_key));
|
||||
defaultMapPublicCheckBoxPreference.setSummaryOn(getString(
|
||||
R.string.settings_sharing_map_public_summary,
|
||||
getString(R.string.maps_public_unlisted_url)));
|
||||
defaultMapPublicCheckBoxPreference.setSummaryOff(getString(
|
||||
R.string.settings_sharing_map_unlisted_summary,
|
||||
getString(R.string.maps_public_unlisted_url)));
|
||||
boolean defaultMapPublic = PreferencesUtils.getBoolean(
|
||||
this, R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT);
|
||||
updateDefaultMapPublicTitle(defaultMapPublic);
|
||||
defaultMapPublicCheckBoxPreference.setOnPreferenceChangeListener(
|
||||
new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
updateDefaultMapPublicTitle((Boolean) newValue);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
allowAccessCheckBoxPreference = (CheckBoxPreference) findPreference(
|
||||
getString(R.string.allow_access_key));
|
||||
allowAccessCheckBoxPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@@ -63,21 +78,6 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ListPreference sharingAccountListPreference = (ListPreference) findPreference(
|
||||
getString(R.string.sharing_account_key));
|
||||
List<String> entries = new ArrayList<String>();
|
||||
Account[] accounts = AccountManager.get(this).getAccountsByType(Constants.ACCOUNT_TYPE);
|
||||
for (Account account : accounts) {
|
||||
entries.add(account.name);
|
||||
}
|
||||
|
||||
sharingAccountListPreference.setEntries(entries.toArray(new CharSequence[entries.size()]));
|
||||
sharingAccountListPreference.setEntryValues(entries.toArray(
|
||||
new CharSequence[entries.size()]));
|
||||
if (entries.size() == 1) {
|
||||
sharingAccountListPreference.setValueIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,10 +88,20 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
|
||||
return DialogUtils.createConfirmationDialog(this,
|
||||
R.string.settings_sharing_allow_access_confirm_message,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int button) {
|
||||
allowAccessCheckBoxPreference.setChecked(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the title for the default map public check box preference.
|
||||
*
|
||||
* @param value the value
|
||||
*/
|
||||
private void updateDefaultMapPublicTitle(boolean value) {
|
||||
defaultMapPublicCheckBoxPreference.setTitle(value ? R.string.settings_sharing_map_public
|
||||
: R.string.settings_sharing_map_unlisted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Utilities for creating dialogs.
|
||||
@@ -37,19 +38,40 @@ public class DialogUtils {
|
||||
* Creates a confirmation dialog.
|
||||
*
|
||||
* @param context the context
|
||||
* @param messageId the confirmation message id
|
||||
* @param onClickListener the listener to invoke when the user clicks OK
|
||||
* @param messageId the message id
|
||||
* @param okListener the listener when OK is clicked
|
||||
*/
|
||||
public static Dialog createConfirmationDialog(
|
||||
Context context, int messageId, DialogInterface.OnClickListener onClickListener) {
|
||||
return new AlertDialog.Builder(context)
|
||||
Context context, int messageId, DialogInterface.OnClickListener okListener) {
|
||||
return createConfirmationDialog(context, messageId, null, okListener, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a confirmation dialog.
|
||||
*
|
||||
* @param context the context
|
||||
* @param messageId the messageId
|
||||
* @param view the view
|
||||
* @param okListener the listener when OK is clicked
|
||||
* @param cancelListener the listener when cancel is clicked
|
||||
*/
|
||||
public static Dialog createConfirmationDialog(
|
||||
Context context, int messageId, View view, DialogInterface.OnClickListener okListener,
|
||||
DialogInterface.OnClickListener cancelListener) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context)
|
||||
.setCancelable(true)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setMessage(context.getString(messageId))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, onClickListener)
|
||||
.setTitle(R.string.generic_confirm_title)
|
||||
.create();
|
||||
.setNegativeButton(android.R.string.cancel, cancelListener)
|
||||
.setPositiveButton(android.R.string.ok, okListener)
|
||||
.setTitle(R.string.generic_confirm_title);
|
||||
if (messageId != -1) {
|
||||
builder.setMessage(messageId);
|
||||
}
|
||||
if (view != null) {
|
||||
builder.setView(view);
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,8 +51,9 @@ public class PreferencesUtils {
|
||||
public static final boolean CHART_SHOW_SPEED_DEFAULT = true;
|
||||
|
||||
public static final String DEFAULT_ACTIVITY_DEFAULT = "";
|
||||
public static final boolean DEFAULT_MAP_PUBLIC_DEFAULT = true;
|
||||
public static final boolean DEFAULT_MAP_PUBLIC_DEFAULT = false;
|
||||
public static final int FREQUENCY_OFF = 0;
|
||||
public static final String GOOGLE_ACCOUNT_DEFAULT = "";
|
||||
public static final int MAX_RECORDING_DISTANCE_DEFAULT = 200;
|
||||
public static final boolean METRIC_UNITS_DEFAULT = true;
|
||||
public static final int MIN_RECORDING_DISTANCE_DEFAULT = 5;
|
||||
@@ -72,8 +73,8 @@ public class PreferencesUtils {
|
||||
public static final boolean SEND_TO_DOCS_DEFAULT = true;
|
||||
public static final boolean SEND_TO_FUSION_TABLES_DEFAULT = true;
|
||||
public static final boolean SEND_TO_MAPS_DEFAULT = true;
|
||||
public static final String SHARING_ACCOUNT_DEFAULT = "";
|
||||
public static final boolean SHOW_CHECK_UNITS_DIALOG_DEFAULT = true;
|
||||
public static final boolean SHOW_CONFIRM_SHARING_DIALOG_DEFAULT = true;
|
||||
public static final boolean SHOW_WELCOME_DIALOG_DEFAULT = true;
|
||||
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
|
||||
|
||||
|
||||
@@ -79,8 +79,11 @@ public class TrackNameUtils {
|
||||
if (location != null) {
|
||||
return getReverseGeoCoding(context, location);
|
||||
} else {
|
||||
// assume startTime != -1L when location == null
|
||||
return StringUtils.formatDateTime(context, startTime);
|
||||
// Use the startTime if available
|
||||
if (startTime != -1L) {
|
||||
return StringUtils.formatDateTime(context, startTime);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user