From ff9c21ab084afbe147b0f7fff71cfb90f250e966 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Mon, 27 Apr 2009 14:58:09 -0700 Subject: Fix the opt-in window for usage stat so that it works when running from ADT. --- .../plugins/com.android.ide.eclipse.adt/.classpath | 2 +- .../src/com/android/ide/eclipse/adt/AdtPlugin.java | 28 +++++++++++----- .../android/ide/eclipse/common/SdkStatsHelper.java | 39 ---------------------- 3 files changed, 21 insertions(+), 48 deletions(-) delete mode 100644 eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/SdkStatsHelper.java (limited to 'eclipse') diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/.classpath b/eclipse/plugins/com.android.ide.eclipse.adt/.classpath index a24fc87..9898b97 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/.classpath +++ b/eclipse/plugins/com.android.ide.eclipse.adt/.classpath @@ -5,7 +5,7 @@ - + diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java index b5cee81..8ef0f2c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java @@ -31,7 +31,6 @@ import com.android.ide.eclipse.adt.sdk.Sdk; import com.android.ide.eclipse.adt.sdk.Sdk.ITargetChangeListener; import com.android.ide.eclipse.adt.ui.EclipseUiHelper; import com.android.ide.eclipse.common.AndroidConstants; -import com.android.ide.eclipse.common.SdkStatsHelper; import com.android.ide.eclipse.common.StreamHelper; import com.android.ide.eclipse.common.project.BaseProjectHelper; import com.android.ide.eclipse.common.project.ExportHelper; @@ -51,6 +50,7 @@ import com.android.ide.eclipse.editors.resources.manager.ResourceMonitor.IFileLi import com.android.ide.eclipse.editors.xml.XmlEditor; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkConstants; +import com.android.sdkstats.SdkStatsService; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -983,13 +983,7 @@ public class AdtPlugin extends AbstractUIPlugin { @Override protected IStatus run(IProgressMonitor monitor) { try { - - // get the version of the plugin - String versionString = (String) getBundle().getHeaders().get( - Constants.BUNDLE_VERSION); - Version version = new Version(versionString); - - SdkStatsHelper.pingUsageServer("adt", version); //$NON-NLS-1$ + pingUsageServer(); //$NON-NLS-1$ return Status.OK_STATUS; } catch (Throwable t) { @@ -1389,4 +1383,22 @@ public class AdtPlugin extends AbstractUIPlugin { public static synchronized OutputStream getErrorStream() { return sPlugin.mAndroidConsoleErrorStream; } + + /** + * Pings the usage start server. + * @param pluginName the name of the plugin to appear in the stats + * @param pluginVersion the {@link Version} of the plugin. + */ + private void pingUsageServer() { + // get the version of the plugin + String versionString = (String) getBundle().getHeaders().get( + Constants.BUNDLE_VERSION); + Version version = new Version(versionString); + + versionString = String.format("%1$d.%2$d.%3$d", version.getMajor(), //$NON-NLS-1$ + version.getMinor(), version.getMicro()); + + SdkStatsService.ping("adt", versionString, getDisplay()); //$NON-NLS-1$ + } + } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/SdkStatsHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/SdkStatsHelper.java deleted file mode 100644 index 345c663..0000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/SdkStatsHelper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.android.ide.eclipse.common; - -import com.android.sdkstats.SdkStatsService; - -import org.osgi.framework.Version; - -/** - * Helper class to access the ping usage stat server. - */ -public class SdkStatsHelper { - - /** - * Pings the usage start server. - * @param pluginName the name of the plugin to appear in the stats - * @param pluginVersion the {@link Version} of the plugin. - */ - public static void pingUsageServer(String pluginName, Version pluginVersion) { - String versionString = String.format("%1$d.%2$d.%3$d", pluginVersion.getMajor(), - pluginVersion.getMinor(), pluginVersion.getMicro()); - - SdkStatsService.ping(pluginName, versionString); - } -} -- cgit v1.1