mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-07 03:53:05 +02:00
Add an interstitial when sharing a track with friends.
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();
|
||||
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
checkBox = (CheckBox) view.findViewById(R.id.confirm_sharing);
|
||||
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();
|
||||
}
|
||||
};
|
||||
String message = getString(
|
||||
R.string.share_track_confirm_message, getString(R.string.maps_public_unlisted_url));
|
||||
Dialog dialog = DialogUtils.createConfirmationDialog(
|
||||
this, message, 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();
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import android.preference.Preference.OnPreferenceChangeListener;
|
||||
public class SharingSettingsActivity extends AbstractSettingsActivity {
|
||||
|
||||
private static final int DIALOG_CONFIRM_ALLOW_ACCESS_ID = 0;
|
||||
|
||||
|
||||
private CheckBoxPreference defaultMapPublicCheckBoxPreference;
|
||||
private CheckBoxPreference allowAccessCheckBoxPreference;
|
||||
|
||||
@@ -47,6 +47,12 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
|
||||
|
||||
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);
|
||||
@@ -82,7 +88,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -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,37 @@ 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, context.getString(messageId), null, okListener, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a confirmation dialog.
|
||||
*
|
||||
* @param context the context
|
||||
* @param message the message
|
||||
* @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, String message, 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();
|
||||
.setMessage(message)
|
||||
.setNegativeButton(android.R.string.cancel, cancelListener)
|
||||
.setPositiveButton(android.R.string.ok, okListener)
|
||||
.setTitle(R.string.generic_confirm_title);
|
||||
if (view != null) {
|
||||
builder.setView(view);
|
||||
}
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,6 +74,7 @@ public class PreferencesUtils {
|
||||
public static final boolean SEND_TO_FUSION_TABLES_DEFAULT = true;
|
||||
public static final boolean SEND_TO_MAPS_DEFAULT = true;
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user