Use ApiAdapter to disable Google Feedback for pre-ICS

This commit is contained in:
Jimmy Shih
2013-06-14 13:33:48 -07:00
parent 86a3f407ce
commit 5262dd0bc2
6 changed files with 19 additions and 32 deletions
@@ -311,7 +311,7 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
voiceFrequencyMenuItem = menu.findItem(R.id.track_detail_voice_frequency);
splitFrequencyMenuItem = menu.findItem(R.id.track_detail_split_frequency);
feedbackMenuItem = menu.findItem(R.id.track_detail_split_frequency);
feedbackMenuItem.setVisible(GoogleFeedbackUtils.isAvailable(this));
feedbackMenuItem.setVisible(ApiAdapterFactory.getApiAdapter().isGoogleFeedbackAvailable());
updateMenuItems(trackId == recordingTrackId, recordingTrackPaused);
return true;
@@ -462,7 +462,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
deleteAllMenuItem = menu.findItem(R.id.track_list_delete_all);
syncNowMenuItem = menu.findItem(R.id.track_list_sync_now);
feedbackMenuItem = menu.findItem(R.id.track_list_feedback);
feedbackMenuItem.setVisible(GoogleFeedbackUtils.isAvailable(this));
feedbackMenuItem.setVisible(ApiAdapterFactory.getApiAdapter().isGoogleFeedbackAvailable());
ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, searchMenuItem, trackController);
boolean isGpsStarted = TrackRecordingServiceConnectionUtils.isRecordingServiceRunning(this);
@@ -75,4 +75,9 @@ public class Api14Adapter extends Api11Adapter {
menuItem.expandActionView();
return true;
}
@Override
public boolean isGoogleFeedbackAvailable() {
return true;
}
}
@@ -153,6 +153,11 @@ public class Api8Adapter implements ApiAdapter {
// Return false and allow the framework to handle the search key.
return false;
}
@Override
public boolean isGoogleFeedbackAvailable() {
return false;
}
@Override
public int getAppWidgetSize(AppWidgetManager appWidgetManager, int appWidgetId) {
@@ -192,6 +192,13 @@ public interface ApiAdapter {
*/
public boolean handleSearchKey(MenuItem menu);
/**
* Returns true if Google Feedback is available.
* <p>
* Due to changes in ApI level 14.
*/
public boolean isGoogleFeedbackAvailable();
/**
* Gets the app widget size.
* <p>
@@ -20,16 +20,12 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
import java.util.List;
/**
* Utilities for Google Feedback.
*
@@ -37,36 +33,10 @@ import java.util.List;
*/
public class GoogleFeedbackUtils {
private static final String GOOGLE_FEEDBACK_PACKAGE_NAME = "com.google.android.feedback";
private static final String TAG = GoogleFeedbackUtils.class.getSimpleName();
private static Boolean available = null;
private GoogleFeedbackUtils() {}
/**
* Returns true if the Google Feedback is available.
*
* @param context the context
*/
public static boolean isAvailable(Context context) {
if (available == null) {
List<ResolveInfo> infos = context.getPackageManager().queryIntentServices(
new Intent(Intent.ACTION_BUG_REPORT), PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo info : infos) {
if (info.serviceInfo != null && info.serviceInfo.packageName != null
&& info.serviceInfo.packageName.equals(GOOGLE_FEEDBACK_PACKAGE_NAME)) {
available = true;
break;
}
}
if (available == null) {
available = false;
}
}
return available;
}
/**
* Binds the Google Feedback service.
*