diff --git a/MyTracks/AndroidManifest.xml b/MyTracks/AndroidManifest.xml index e539e40d9..cc100a0d8 100755 --- a/MyTracks/AndroidManifest.xml +++ b/MyTracks/AndroidManifest.xml @@ -134,7 +134,7 @@ limitations under the License. android:theme="@android:style/Theme.Translucent.NoTitleBar" android:noHistory="true"> - + diff --git a/MyTracks/res/values/do_not_translate.xml b/MyTracks/res/values/do_not_translate.xml index 3d752908a..c8ce04282 100644 --- a/MyTracks/res/values/do_not_translate.xml +++ b/MyTracks/res/values/do_not_translate.xml @@ -39,4 +39,7 @@ limitations under the License. google.com/fusiontables maps.google.com docs.google.com + + + android.intent.action.SAVE diff --git a/MyTracks/src/com/google/android/apps/mytracks/Constants.java b/MyTracks/src/com/google/android/apps/mytracks/Constants.java index bc0802e84..063bb6679 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/Constants.java +++ b/MyTracks/src/com/google/android/apps/mytracks/Constants.java @@ -33,9 +33,6 @@ public abstract class Constants { */ public static final String SDCARD_TOP_DIR = "MyTracks"; - // Intent actions - public static final String ACTION_SAVE = "android.intent.action.SAVE"; - /* * onActivityResult request codes: */ diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/file/SaveActivity.java b/MyTracks/src/com/google/android/apps/mytracks/io/file/SaveActivity.java index 8fc5feb02..3ef2ad7ca 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/file/SaveActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/file/SaveActivity.java @@ -15,7 +15,6 @@ */ package com.google.android.apps.mytracks.io.file; -import static com.google.android.apps.mytracks.Constants.ACTION_SAVE; import static com.google.android.apps.mytracks.Constants.TAG; import com.google.android.apps.mytracks.Constants; @@ -23,8 +22,8 @@ import com.google.android.apps.mytracks.DialogManager; import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.TracksColumns; import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat; -import com.google.android.apps.mytracks.util.UriUtils; import com.google.android.apps.mytracks.util.FileUtils; +import com.google.android.apps.mytracks.util.UriUtils; import com.google.android.maps.mytracks.R; import android.app.Activity; @@ -69,7 +68,7 @@ public class SaveActivity extends Activity { String action = intent.getAction(); String type = intent.getType(); Uri data = intent.getData(); - if (!ACTION_SAVE.equals(action) || + if (!getString(R.string.save_intent_action).equals(action) || !TracksColumns.CONTENT_ITEMTYPE.equals(type) || !UriUtils.matchesContentUri(data, TracksColumns.CONTENT_URI)) { Log.e(TAG, "Got bad save intent: " + intent); @@ -183,7 +182,7 @@ public class SaveActivity extends Activity { Uri uri = ContentUris.withAppendedId(TracksColumns.CONTENT_URI, trackId); Intent intent = new Intent(ctx, SaveActivity.class); - intent.setAction(ACTION_SAVE); + intent.setAction(ctx.getString(R.string.save_intent_action)); intent.setDataAndType(uri, TracksColumns.CONTENT_ITEMTYPE); intent.putExtra(EXTRA_FILE_FORMAT, exportFormat.ordinal()); intent.putExtra(EXTRA_SHARE_FILE, shareFile); diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/UriUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/UriUtils.java index c0eb6bd49..bc49f323a 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/UriUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/UriUtils.java @@ -27,18 +27,26 @@ import java.util.List; public class UriUtils { public static boolean matchesContentUri(Uri uri, Uri baseContentUri) { - if (uri == null) return false; + if (uri == null) { + return false; + } // Check that scheme and authority are the same. - if (!uri.getScheme().equals(baseContentUri.getScheme())) return false; - if (!uri.getAuthority().equals(baseContentUri.getAuthority())) return false; + if (!uri.getScheme().equals(baseContentUri.getScheme()) || + !uri.getAuthority().equals(baseContentUri.getAuthority())) { + return false; + } // Checks that all the base path components are in the URI. List uriPathSegments = uri.getPathSegments(); List basePathSegments = baseContentUri.getPathSegments(); - if (basePathSegments.size() > uriPathSegments.size()) return false; + if (basePathSegments.size() > uriPathSegments.size()) { + return false; + } for (int i = 0; i < basePathSegments.size(); i++) { - if (!uriPathSegments.get(i).equals(basePathSegments.get(i))) return false; + if (!uriPathSegments.get(i).equals(basePathSegments.get(i))) { + return false; + } } return true;