Code cleanup: remove TAG in Constants.java

This commit is contained in:
Jimmy Shih
2013-10-04 11:01:23 -07:00
parent 9c938b1260
commit 39d26febc1
16 changed files with 50 additions and 49 deletions
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks; package com.google.android.apps.mytracks;
import static android.content.Intent.ACTION_BOOT_COMPLETED; import static android.content.Intent.ACTION_BOOT_COMPLETED;
import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.services.TrackRecordingService; import com.google.android.apps.mytracks.services.TrackRecordingService;
@@ -42,6 +41,8 @@ import android.util.Log;
*/ */
public class BootReceiver extends BroadcastReceiver { public class BootReceiver extends BroadcastReceiver {
private static final String TAG = BootReceiver.class.getSimpleName();
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Log.d(TAG, "BootReceiver.onReceive: " + intent.getAction()); Log.d(TAG, "BootReceiver.onReceive: " + intent.getAction());
@@ -57,11 +57,6 @@ public class Constants {
*/ */
public static final String SETTINGS_NAME = "SettingsActivity"; public static final String SETTINGS_NAME = "SettingsActivity";
/**
* The log tag.
*/
public static final String TAG = "MyTracks";
/** /**
* Target number of track points displayed by the map overlay. We may display * Target number of track points displayed by the map overlay. We may display
* more than this number of points. * more than this number of points.
@@ -16,8 +16,6 @@
package com.google.android.apps.mytracks; package com.google.android.apps.mytracks;
import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.Waypoint.WaypointType; import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
import com.google.android.apps.mytracks.maps.TrackPath; import com.google.android.apps.mytracks.maps.TrackPath;
@@ -53,6 +51,8 @@ public class MapOverlay {
public static final float WAYPOINT_X_ANCHOR = 13f / 48f; public static final float WAYPOINT_X_ANCHOR = 13f / 48f;
private static final String TAG = MapOverlay.class.getSimpleName();
private static final float WAYPOINT_Y_ANCHOR = 43f / 48f; private static final float WAYPOINT_Y_ANCHOR = 43f / 48f;
private static final float MARKER_X_ANCHOR = 50f / 96f; private static final float MARKER_X_ANCHOR = 50f / 96f;
private static final float MARKER_Y_ANCHOR = 90f / 96f; private static final float MARKER_Y_ANCHOR = 90f / 96f;
@@ -16,8 +16,6 @@
package com.google.android.apps.mytracks.content; package com.google.android.apps.mytracks.content;
import static com.google.android.apps.mytracks.Constants.TAG;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.database.ContentObserver; import android.database.ContentObserver;
@@ -36,6 +34,8 @@ import java.util.Set;
*/ */
public class DataSourceManager { public class DataSourceManager {
private static final String TAG = DataSourceManager.class.getSimpleName();
/** /**
* Observer when the tracks table is updated. * Observer when the tracks table is updated.
* *
@@ -16,8 +16,6 @@
package com.google.android.apps.mytracks.content; package com.google.android.apps.mytracks.content;
import static com.google.android.apps.mytracks.Constants.TAG;
import android.util.Log; import android.util.Log;
import java.util.EnumMap; import java.util.EnumMap;
@@ -35,6 +33,8 @@ import java.util.Set;
*/ */
public class TrackDataManager { public class TrackDataManager {
private static final String TAG = TrackDataManager.class.getSimpleName();
// Map of listener to its track data types // Map of listener to its track data types
private final Map<TrackDataListener, EnumSet<TrackDataType>> private final Map<TrackDataListener, EnumSet<TrackDataType>>
listenerToTypesMap = new HashMap<TrackDataListener, EnumSet<TrackDataType>>(); listenerToTypesMap = new HashMap<TrackDataListener, EnumSet<TrackDataType>>();
@@ -15,8 +15,6 @@
*/ */
package com.google.android.apps.mytracks.io.backup; package com.google.android.apps.mytracks.io.backup;
import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.TrackPointsColumns; import com.google.android.apps.mytracks.content.TrackPointsColumns;
import com.google.android.apps.mytracks.content.TracksColumns; import com.google.android.apps.mytracks.content.TracksColumns;
@@ -52,6 +50,9 @@ import java.util.zip.ZipOutputStream;
* @author Rodrigo Damazio * @author Rodrigo Damazio
*/ */
class ExternalFileBackup { class ExternalFileBackup {
private static final String TAG = ExternalFileBackup.class.getSimpleName();
// Filename format - in UTC // Filename format - in UTC
private static final SimpleDateFormat BACKUP_FILENAME_FORMAT = new SimpleDateFormat( private static final SimpleDateFormat BACKUP_FILENAME_FORMAT = new SimpleDateFormat(
"'backup-'yyyy-MM-dd_HH-mm-ss'.zip'", Locale.US); "'backup-'yyyy-MM-dd_HH-mm-ss'.zip'", Locale.US);
@@ -87,7 +88,7 @@ class ExternalFileBackup {
private File getBackupsDirectory(boolean create) { private File getBackupsDirectory(boolean create) {
String directoryPath = FileUtils.getDirectoryPath(FileUtils.BACKUPS_DIR); String directoryPath = FileUtils.getDirectoryPath(FileUtils.BACKUPS_DIR);
final File dir = new File(directoryPath); final File dir = new File(directoryPath);
Log.d(Constants.TAG, "Dir: " + dir.getAbsolutePath()); Log.d(TAG, "Dir: " + dir.getAbsolutePath());
if (create) { if (create) {
// Try to create - if that fails, return null // Try to create - if that fails, return null
return FileUtils.ensureDirectoryExists(dir) ? dir : null; return FileUtils.ensureDirectoryExists(dir) ? dir : null;
@@ -146,8 +147,7 @@ class ExternalFileBackup {
* Synchronously writes a backup to the given file. * Synchronously writes a backup to the given file.
*/ */
private void writeToFile(File outputFile) throws IOException { private void writeToFile(File outputFile) throws IOException {
Log.d(Constants.TAG, Log.d(TAG, "Writing backup to file " + outputFile.getAbsolutePath());
"Writing backup to file " + outputFile.getAbsolutePath());
// Create all the auxiliary classes that will do the writing // Create all the auxiliary classes that will do the writing
PreferenceBackupHelper preferencesHelper = new PreferenceBackupHelper(context); PreferenceBackupHelper preferencesHelper = new PreferenceBackupHelper(context);
@@ -234,8 +234,7 @@ class ExternalFileBackup {
* Synchronously restores the backup from the given file. * Synchronously restores the backup from the given file.
*/ */
private void restoreFromFile(File inputFile) throws IOException { private void restoreFromFile(File inputFile) throws IOException {
Log.d(Constants.TAG, Log.d(TAG, "Restoring from file " + inputFile.getAbsolutePath());
"Restoring from file " + inputFile.getAbsolutePath());
PreferenceBackupHelper preferencesHelper = new PreferenceBackupHelper(context); PreferenceBackupHelper preferencesHelper = new PreferenceBackupHelper(context);
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
@@ -35,17 +35,20 @@ import java.io.IOException;
* @author Rodrigo Damazio * @author Rodrigo Damazio
*/ */
public class MyTracksBackupAgent extends BackupAgent { public class MyTracksBackupAgent extends BackupAgent {
private static final String TAG = MyTracksBackupAgent.class.getSimpleName();
private static final String PREFERENCES_ENTITY = "prefs"; private static final String PREFERENCES_ENTITY = "prefs";
@Override @Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) throws IOException { ParcelFileDescriptor newState) throws IOException {
Log.i(Constants.TAG, "Performing backup"); Log.i(TAG, "Performing backup");
SharedPreferences preferences = this.getSharedPreferences( SharedPreferences preferences = this.getSharedPreferences(
Constants.SETTINGS_NAME, Context.MODE_PRIVATE); Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
backupPreferences(data, preferences); backupPreferences(data, preferences);
Log.i(Constants.TAG, "Backup complete"); Log.i(TAG, "Backup complete");
} }
private void backupPreferences(BackupDataOutput data, private void backupPreferences(BackupDataOutput data,
@@ -63,18 +66,18 @@ public class MyTracksBackupAgent extends BackupAgent {
@Override @Override
public void onRestore(BackupDataInput data, int appVersionCode, public void onRestore(BackupDataInput data, int appVersionCode,
ParcelFileDescriptor newState) throws IOException { ParcelFileDescriptor newState) throws IOException {
Log.i(Constants.TAG, "Restoring from backup"); Log.i(TAG, "Restoring from backup");
while (data.readNextHeader()) { while (data.readNextHeader()) {
String key = data.getKey(); String key = data.getKey();
Log.d(Constants.TAG, "Restoring entity " + key); Log.d(TAG, "Restoring entity " + key);
if (key.equals(PREFERENCES_ENTITY)) { if (key.equals(PREFERENCES_ENTITY)) {
restorePreferences(data); restorePreferences(data);
} else { } else {
Log.e(Constants.TAG, "Found unknown backup entity: " + key); Log.e(TAG, "Found unknown backup entity: " + key);
data.skipEntityData(); data.skipEntityData();
} }
} }
Log.i(Constants.TAG, "Done restoring from backup"); Log.i(TAG, "Done restoring from backup");
} }
/** /**
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.io.file.importer; package com.google.android.apps.mytracks.io.file.importer;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl; import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Track;
@@ -173,7 +172,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
saxParser.parse(inputStream, this); saxParser.parse(inputStream, this);
Log.d(Constants.TAG, "Total import time: " + (System.currentTimeMillis() - start) + "ms"); Log.d(TAG, "Total import time: " + (System.currentTimeMillis() - start) + "ms");
if (trackIds.size() != 1) { if (trackIds.size() != 1) {
Log.d(TAG, trackIds.size() + " tracks imported"); Log.d(TAG, trackIds.size() + " tracks imported");
cleanImport(); cleanImport();
@@ -406,7 +405,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
// Check for negative time change // Check for negative time change
if (timeDifference <= 0) { if (timeDifference <= 0) {
Log.w(Constants.TAG, "Time difference not postive."); Log.w(TAG, "Time difference not postive.");
} else { } else {
/* /*
@@ -15,7 +15,6 @@
*/ */
package com.google.android.apps.mytracks.io.gdata; package com.google.android.apps.mytracks.io.gdata;
import com.google.android.apps.mytracks.Constants;
import com.google.wireless.gdata.client.GDataClient; import com.google.wireless.gdata.client.GDataClient;
import android.content.Context; import android.content.Context;
@@ -28,6 +27,8 @@ import android.util.Log;
*/ */
public class GDataClientFactory { public class GDataClientFactory {
private static final String TAG = GDataClientFactory.class.getSimpleName();
private GDataClientFactory() { } private GDataClientFactory() { }
/** /**
@@ -44,7 +45,7 @@ public class GDataClientFactory {
} catch (LinkageError e) { } catch (LinkageError e) {
// On all other platforms use the client implementation packaged in the // On all other platforms use the client implementation packaged in the
// apk. // apk.
Log.i(Constants.TAG, "Using mytracks AndroidGDataClient.", e); Log.i(TAG, "Using mytracks AndroidGDataClient.", e);
return new com.google.android.apps.mytracks.io.gdata.AndroidGDataClient(); return new com.google.android.apps.mytracks.io.gdata.AndroidGDataClient();
} }
} }
@@ -16,8 +16,6 @@
package com.google.android.apps.mytracks.services; package com.google.android.apps.mytracks.services;
import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.widgets.TrackWidgetProvider; import com.google.android.apps.mytracks.widgets.TrackWidgetProvider;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@@ -42,6 +40,8 @@ import android.util.Log;
*/ */
public class ControlRecordingService extends IntentService implements ServiceConnection { public class ControlRecordingService extends IntentService implements ServiceConnection {
private static final String TAG = ControlRecordingService.class.getSimpleName();
private ITrackRecordingService trackRecordingService; private ITrackRecordingService trackRecordingService;
private boolean connected = false; private boolean connected = false;
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.stats; package com.google.android.apps.mytracks.stats;
import static com.google.android.apps.mytracks.Constants.TAG;
import static com.google.android.apps.mytracks.services.TrackRecordingService.MAX_NO_MOVEMENT_SPEED; import static com.google.android.apps.mytracks.services.TrackRecordingService.MAX_NO_MOVEMENT_SPEED;
import static com.google.android.apps.mytracks.services.TrackRecordingService.PAUSE_LATITUDE; import static com.google.android.apps.mytracks.services.TrackRecordingService.PAUSE_LATITUDE;
@@ -38,6 +37,8 @@ import android.util.Log;
*/ */
public class TripStatisticsUpdater { public class TripStatisticsUpdater {
private static final String TAG = TripStatisticsUpdater.class.getSimpleName();
/** /**
* The number of elevation readings to smooth to get a somewhat accurate * The number of elevation readings to smooth to get a somewhat accurate
* signal. * signal.
@@ -15,7 +15,6 @@
*/ */
package com.google.android.apps.mytracks.util; package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.services.sensors.BluetoothConnectionManager; import com.google.android.apps.mytracks.services.sensors.BluetoothConnectionManager;
import android.annotation.TargetApi; import android.annotation.TargetApi;
@@ -33,13 +32,15 @@ import java.io.IOException;
@TargetApi(10) @TargetApi(10)
public class Api10Adapter extends Api9Adapter { public class Api10Adapter extends Api9Adapter {
private static final String TAG = Api10Adapter.class.getSimpleName();
@Override @Override
public BluetoothSocket getBluetoothSocket(BluetoothDevice bluetoothDevice) throws IOException { public BluetoothSocket getBluetoothSocket(BluetoothDevice bluetoothDevice) throws IOException {
try { try {
return bluetoothDevice.createInsecureRfcommSocketToServiceRecord( return bluetoothDevice.createInsecureRfcommSocketToServiceRecord(
BluetoothConnectionManager.MY_TRACKS_UUID); BluetoothConnectionManager.MY_TRACKS_UUID);
} catch (IOException e) { } catch (IOException e) {
Log.d(Constants.TAG, "Unable to create insecure connection", e); Log.d(TAG, "Unable to create insecure connection", e);
} }
return bluetoothDevice.createRfcommSocketToServiceRecord(BluetoothConnectionManager.MY_TRACKS_UUID); return bluetoothDevice.createRfcommSocketToServiceRecord(BluetoothConnectionManager.MY_TRACKS_UUID);
}; };
@@ -15,7 +15,6 @@
*/ */
package com.google.android.apps.mytracks.util; package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.ContextualActionModeCallback; import com.google.android.apps.mytracks.ContextualActionModeCallback;
import com.google.android.apps.mytracks.TrackController; import com.google.android.apps.mytracks.TrackController;
import com.google.android.apps.mytracks.services.sensors.BluetoothConnectionManager; import com.google.android.apps.mytracks.services.sensors.BluetoothConnectionManager;
@@ -49,6 +48,8 @@ import java.util.List;
*/ */
public class Api8Adapter implements ApiAdapter { public class Api8Adapter implements ApiAdapter {
private static final String TAG = Api8Adapter.class.getSimpleName();
@Override @Override
public void applyPreferenceChanges(Editor editor) { public void applyPreferenceChanges(Editor editor) {
editor.commit(); editor.commit();
@@ -85,15 +86,15 @@ public class Api8Adapter implements ApiAdapter {
insecure.setAccessible(true); insecure.setAccessible(true);
return (BluetoothSocket) insecure.invoke(bluetoothDevice, 1); return (BluetoothSocket) insecure.invoke(bluetoothDevice, 1);
} catch (SecurityException e) { } catch (SecurityException e) {
Log.d(Constants.TAG, "Unable to create insecure connection", e); Log.d(TAG, "Unable to create insecure connection", e);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
Log.d(Constants.TAG, "Unable to create insecure connection", e); Log.d(TAG, "Unable to create insecure connection", e);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Log.d(Constants.TAG, "Unable to create insecure connection", e); Log.d(TAG, "Unable to create insecure connection", e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
Log.d(Constants.TAG, "Unable to create insecure connection", e); Log.d(TAG, "Unable to create insecure connection", e);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
Log.d(Constants.TAG, "Unable to create insecure connection", e); Log.d(TAG, "Unable to create insecure connection", e);
} }
return bluetoothDevice.createRfcommSocketToServiceRecord(BluetoothConnectionManager.MY_TRACKS_UUID); return bluetoothDevice.createRfcommSocketToServiceRecord(BluetoothConnectionManager.MY_TRACKS_UUID);
} }
@@ -15,7 +15,6 @@
*/ */
package com.google.android.apps.mytracks.util; package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.Constants;
import com.google.api.client.http.HttpTransport; import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.http.javanet.NetHttpTransport;
@@ -35,6 +34,8 @@ import java.util.Arrays;
@TargetApi(9) @TargetApi(9)
public class Api9Adapter extends Api8Adapter { public class Api9Adapter extends Api8Adapter {
private static final String TAG = Api9Adapter.class.getSimpleName();
@Override @Override
public void applyPreferenceChanges(Editor editor) { public void applyPreferenceChanges(Editor editor) {
// Apply asynchronously // Apply asynchronously
@@ -43,7 +44,7 @@ public class Api9Adapter extends Api8Adapter {
@Override @Override
public void enableStrictMode() { public void enableStrictMode() {
Log.d(Constants.TAG, "Enabling strict mode"); Log.d(TAG, "Enabling strict mode");
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll() .detectAll()
.penaltyLog() .penaltyLog()
@@ -15,7 +15,6 @@
*/ */
package com.google.android.apps.mytracks.util; package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Track;
import android.location.Location; import android.location.Location;
@@ -31,6 +30,8 @@ import java.util.Stack;
*/ */
public class LocationUtils { public class LocationUtils {
private static final String TAG = LocationUtils.class.getSimpleName();
private static final long MAX_LOCATION_AGE_MS = 60 * 1000; // 1 minute private static final long MAX_LOCATION_AGE_MS = 60 * 1000; // 1 minute
private LocationUtils() {} private LocationUtils() {}
@@ -133,7 +134,7 @@ public class LocationUtils {
} }
idx++; idx++;
} }
Log.d(Constants.TAG, "Decimating " + n + " points to " + i + " w/ tolerance = " + tolerance); Log.d(TAG, "Decimating " + n + " points to " + i + " w/ tolerance = " + tolerance);
} }
/** /**
@@ -16,8 +16,6 @@
package com.google.android.apps.mytracks.util; package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.Constants;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
@@ -49,7 +47,7 @@ public class SystemUtils {
.getPackageInfo("com.google.android.maps.mytracks", PackageManager.GET_META_DATA); .getPackageInfo("com.google.android.maps.mytracks", PackageManager.GET_META_DATA);
return pi.versionName; return pi.versionName;
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
Log.w(Constants.TAG, "Failed to get version info.", e); Log.w(TAG, "Failed to get version info.", e);
return ""; return "";
} }
} }
@@ -75,7 +73,7 @@ public class SystemUtils {
return wakeLock; return wakeLock;
} }
if (wakeLock == null) { if (wakeLock == null) {
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.TAG); wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
if (wakeLock == null) { if (wakeLock == null) {
Log.e(TAG, "Cannot create a new wake lock."); Log.e(TAG, "Cannot create a new wake lock.");
} }