Permalink
Browse files

Fix issues reported by lint

  • Loading branch information...
ianhanniballake committed Oct 27, 2017
1 parent 6e844d1 commit 43516415d3ac0127f3e9d0e28fe197808f8bb385
Showing with 81 additions and 54 deletions.
  1. +5 −4 android-client-common/src/main/java/com/google/android/apps/muzei/room/MuzeiDatabase.java
  2. +8 −0 api/src/main/java/com/google/android/apps/muzei/api/RemoteMuzeiArtSource.java
  3. +5 −6 main/src/main/java/com/google/android/apps/muzei/ArtDetailFragment.java
  4. +1 −1 main/src/main/java/com/google/android/apps/muzei/MuzeiActivity.java
  5. +3 −0 main/src/main/java/com/google/android/apps/muzei/MuzeiWallpaperService.java
  6. +2 −0 main/src/main/java/com/google/android/apps/muzei/NetworkChangeReceiver.java
  7. +2 −0 main/src/main/java/com/google/android/apps/muzei/SourcePackageChangeReceiver.java
  8. +3 −5 main/src/main/java/com/google/android/apps/muzei/TutorialFragment.java
  9. +2 −0 main/src/main/java/com/google/android/apps/muzei/quicksettings/NextArtworkTileService.java
  10. +2 −0 main/src/main/java/com/google/android/apps/muzei/render/MuzeiBlurRenderer.java
  11. +2 −2 main/src/main/java/com/google/android/apps/muzei/settings/AboutActivity.java
  12. +3 −4 main/src/main/java/com/google/android/apps/muzei/settings/SettingsActivity.java
  13. +5 −5 main/src/main/java/com/google/android/apps/muzei/settings/SettingsAdvancedFragment.java
  14. +3 −0 main/src/main/java/com/google/android/apps/muzei/sync/DownloadArtworkJobService.java
  15. +2 −2 main/src/main/java/com/google/android/apps/muzei/sync/TaskQueueService.java
  16. +1 −1 main/src/main/java/com/google/android/apps/muzei/util/AnimatedMuzeiLogoFragment.java
  17. +7 −5 main/src/main/java/com/google/android/apps/muzei/util/PanScaleProxyView.java
  18. +0 −1 main/src/main/java/com/google/android/apps/muzei/wearable/WearableController.java
  19. +1 −0 source-gallery/src/main/java/com/google/android/apps/muzei/gallery/GalleryArtSource.java
  20. +6 −5 source-gallery/src/main/java/com/google/android/apps/muzei/gallery/GalleryDatabase.java
  21. +4 −4 wearable/src/main/java/com/google/android/apps/muzei/FullScreenActivity.java
  22. +1 −1 ...src/main/java/com/google/android/apps/muzei/complications/ArtworkComplicationProviderService.java
  23. +1 −1 wearable/src/main/java/com/google/android/apps/muzei/datalayer/ActivateMuzeiIntentService.java
  24. +9 −4 wearable/src/main/java/com/google/android/apps/muzei/util/PanView.java
  25. +2 −2 wearable/src/main/res/layout/full_screen_activity.xml
  26. +1 −1 wearable/src/main/res/xml/watch_face.xml
@@ -24,6 +24,7 @@
import android.arch.persistence.room.migration.Migration;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.apps.muzei.api.MuzeiContract;
@@ -67,14 +68,14 @@ public void onChanged(@Nullable final Source source) {
private static Migration MIGRATION_1_2 = new Migration(1, 2) {
@Override
public void migrate(final SupportSQLiteDatabase database) {
public void migrate(@NonNull final SupportSQLiteDatabase database) {
// NO-OP
}
};
private static Migration MIGRATION_2_3 = new Migration(2, 3) {
@Override
public void migrate(final SupportSQLiteDatabase database) {
public void migrate(@NonNull final SupportSQLiteDatabase database) {
// We can't ALTER TABLE to add a foreign key and we wouldn't know what the FK should be
// at this point anyways so we'll wipe and recreate the artwork table
database.execSQL("DROP TABLE " + MuzeiContract.Artwork.TABLE_NAME);
@@ -105,7 +106,7 @@ public void migrate(final SupportSQLiteDatabase database) {
private static Migration MIGRATION_3_4 = new Migration(3, 4) {
@Override
public void migrate(final SupportSQLiteDatabase database) {
public void migrate(@NonNull final SupportSQLiteDatabase database) {
// Handle Sources
database.execSQL("CREATE TABLE sources2 ("
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
@@ -144,7 +145,7 @@ public void migrate(final SupportSQLiteDatabase database) {
private static Migration MIGRATION_4_5 = new Migration(4, 5) {
@Override
public void migrate(final SupportSQLiteDatabase database) {
public void migrate(@NonNull final SupportSQLiteDatabase database) {
// NO-OP
}
};
@@ -16,13 +16,15 @@
package com.google.android.apps.muzei.api;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.PowerManager;
import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresPermission;
import android.util.Log;
/**
@@ -68,6 +70,8 @@
* not user-visible and is only used for {@linkplain #getSharedPreferences()
* storing preferences} and in system log output.
*/
@RequiresPermission(allOf =
{Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.WAKE_LOCK})
public RemoteMuzeiArtSource(@NonNull String name) {
super(name);
}
@@ -90,6 +94,8 @@ public RemoteMuzeiArtSource(@NonNull String name) {
* Subclasses of {@link RemoteMuzeiArtSource} should implement {@link #onTryUpdate(int)}
* instead of this method.
*/
@RequiresPermission(allOf =
{Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.WAKE_LOCK})
@CallSuper
@Override
protected void onUpdate(@UpdateReason int reason) {
@@ -139,6 +145,8 @@ protected void onDisabled() {
setWantsNetworkAvailable(false);
}
@RequiresPermission(allOf =
{Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.WAKE_LOCK})
@CallSuper
@Override
protected void onNetworkAvailable() {
@@ -260,9 +260,9 @@ public void run() {
}
});
mTitleView = (TextView) view.findViewById(R.id.title);
mBylineView = (TextView) view.findViewById(R.id.byline);
mAttributionView = (TextView) view.findViewById(R.id.attribution);
mTitleView = view.findViewById(R.id.title);
mBylineView = view.findViewById(R.id.byline);
mAttributionView = view.findViewById(R.id.attribution);
final View overflowButton = view.findViewById(R.id.overflow_button);
mOverflowMenu = new PopupMenu(getContext(), overflowButton);
@@ -304,7 +304,7 @@ public void onClick(View view) {
});
CheatSheet.setup(mNextButton);
mPanScaleProxyView = (PanScaleProxyView) view.findViewById(R.id.pan_scale_proxy);
mPanScaleProxyView = view.findViewById(R.id.pan_scale_proxy);
mPanScaleProxyView.setMaxZoom(5);
mPanScaleProxyView.setOnViewportChangedListener(
new PanScaleProxyView.OnViewportChangedListener() {
@@ -333,8 +333,7 @@ public void onLongPress() {
});
mLoadingContainerView = view.findViewById(R.id.image_loading_container);
mLoadingIndicatorView = (AnimatedMuzeiLoadingSpinnerView)
view.findViewById(R.id.image_loading_indicator);
mLoadingIndicatorView = view.findViewById(R.id.image_loading_indicator);
mLoadErrorContainerView = view.findViewById(R.id.image_error_container);
mLoadErrorEasterEggView = view.findViewById(R.id.error_easter_egg);
@@ -44,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.muzei_activity);
FirebaseAnalytics.getInstance(this).setUserProperty("device_type", BuildConfig.DEVICE_TYPE);
final DrawInsetsFrameLayout mContainerView = (DrawInsetsFrameLayout) findViewById(R.id.container);
final DrawInsetsFrameLayout mContainerView = findViewById(R.id.container);
mContainerView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
@@ -29,6 +29,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v4.os.UserManagerCompat;
import android.view.GestureDetector;
import android.view.MotionEvent;
@@ -91,6 +92,7 @@ public void onReceive(Context context, Intent intent) {
}
}
@NonNull
@Override
public Lifecycle getLifecycle() {
return mLifecycle;
@@ -154,6 +156,7 @@ public void onCreate(SurfaceHolder surfaceHolder) {
EventBus.getDefault().register(this);
}
@NonNull
@Override
public Lifecycle getLifecycle() {
return mEngineLifecycle;
@@ -24,6 +24,7 @@
import android.content.Intent;
import android.net.ConnectivityManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.WakefulBroadcastReceiver;
@@ -38,6 +39,7 @@
public class NetworkChangeReceiver extends WakefulBroadcastReceiver implements LifecycleOwner {
private LifecycleRegistry mLifecycle;
@NonNull
@Override
public Lifecycle getLifecycle() {
return mLifecycle;
@@ -24,6 +24,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.text.TextUtils;
@@ -43,6 +44,7 @@
private LifecycleRegistry mLifecycle;
@NonNull
@Override
public Lifecycle getLifecycle() {
return mLifecycle;
@@ -118,9 +118,8 @@ public void onClick(View view) {
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (isAdded()) {
ImageView emanateView = (ImageView)
view.findViewById(R.id.tutorial_icon_emanate);
if (isAdded() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ImageView emanateView = view.findViewById(R.id.tutorial_icon_emanate);
AnimatedVectorDrawable avd = (AnimatedVectorDrawable)
getResources().getDrawable(
R.drawable.avd_tutorial_icon_emanate,
@@ -133,8 +132,7 @@ public void onAnimationEnd(Animator animation) {
}
mAnimator.start();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ImageView emanateView = (ImageView)
view.findViewById(R.id.tutorial_icon_emanate);
ImageView emanateView = view.findViewById(R.id.tutorial_icon_emanate);
AnimatedVectorDrawable avd = (AnimatedVectorDrawable)
getResources().getDrawable(
R.drawable.avd_tutorial_icon_emanate,
@@ -29,6 +29,7 @@
import android.os.Build;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.widget.Toast;
@@ -64,6 +65,7 @@ public void onCreate() {
mLifecycle.handleLifecycleEvent(Lifecycle.Event.ON_CREATE);
}
@NonNull
@Override
public Lifecycle getLifecycle() {
return mLifecycle;
@@ -26,6 +26,7 @@
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.Matrix;
import android.support.annotation.Keep;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.animation.AccelerateDecelerateInterpolator;
@@ -218,6 +219,7 @@ public void onDrawFrame(GL10 unused) {
}
}
@Keep
public void setNormalOffsetX(float x) {
mNormalOffsetX = MathUtil.constrain(0, 1, x);
onViewportChanged();
@@ -63,11 +63,11 @@ public void onClick(View view) {
}
// Build the about body view and append the link to see OSS licenses
TextView versionView = (TextView) findViewById(R.id.app_version);
TextView versionView = findViewById(R.id.app_version);
versionView.setText(Html.fromHtml(
getString(R.string.about_version_template, BuildConfig.VERSION_NAME)));
TextView aboutBodyView = (TextView) findViewById(R.id.about_body);
TextView aboutBodyView = findViewById(R.id.about_body);
aboutBodyView.setText(Html.fromHtml(getString(R.string.about_body)));
aboutBodyView.setMovementMethod(new LinkMovementMethod());
@@ -138,7 +138,7 @@ protected void onStop() {
}
private void setupAppBar() {
mAppBar = (Toolbar) findViewById(R.id.app_bar);
mAppBar = findViewById(R.id.app_bar);
mAppBar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -147,7 +147,7 @@ public void onClick(View view) {
});
final LayoutInflater inflater = LayoutInflater.from(this);
Spinner sectionSpinner = (Spinner) findViewById(R.id.section_spinner);
Spinner sectionSpinner = findViewById(R.id.section_spinner);
sectionSpinner.setAdapter(new BaseAdapter() {
@Override
public int getCount() {
@@ -307,8 +307,7 @@ private void updateRenderLocally(boolean renderLocally) {
mRenderLocally = renderLocally;
final View uiContainer = findViewById(R.id.container);
final ViewGroup localRenderContainer = (ViewGroup)
findViewById(R.id.local_render_container);
final ViewGroup localRenderContainer = findViewById(R.id.local_render_container);
FragmentManager fm = getSupportFragmentManager();
Fragment localRenderFragment = fm.findFragmentById(R.id.local_render_container);
@@ -53,7 +53,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.settings_advanced_fragment, container, false);
mBlurSeekBar = (SeekBar) rootView.findViewById(R.id.blur_amount);
mBlurSeekBar = rootView.findViewById(R.id.blur_amount);
mBlurSeekBar.setProgress(Prefs.getSharedPreferences(getContext())
.getInt(Prefs.PREF_BLUR_AMOUNT, MuzeiBlurRenderer.DEFAULT_BLUR));
mBlurSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@@ -74,7 +74,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mDimSeekBar = (SeekBar) rootView.findViewById(R.id.dim_amount);
mDimSeekBar = rootView.findViewById(R.id.dim_amount);
mDimSeekBar.setProgress(Prefs.getSharedPreferences(getContext())
.getInt(Prefs.PREF_DIM_AMOUNT, MuzeiBlurRenderer.DEFAULT_MAX_DIM));
mDimSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@@ -95,7 +95,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mGreySeekBar = (SeekBar) rootView.findViewById(R.id.grey_amount);
mGreySeekBar = rootView.findViewById(R.id.grey_amount);
mGreySeekBar.setProgress(Prefs.getSharedPreferences(getContext())
.getInt(Prefs.PREF_GREY_AMOUNT, MuzeiBlurRenderer.DEFAULT_GREY));
mGreySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@@ -115,7 +115,7 @@ public void onStartTrackingTouch(SeekBar seekBar) {
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
CheckBox mNotifyNewWallpaperCheckBox = (CheckBox) rootView.findViewById(
CheckBox mNotifyNewWallpaperCheckBox = rootView.findViewById(
R.id.notify_new_wallpaper_checkbox);
mNotifyNewWallpaperCheckBox.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@@ -128,7 +128,7 @@ public void onCheckedChanged(CompoundButton button, boolean checked) {
});
mNotifyNewWallpaperCheckBox.setChecked(PreferenceManager.getDefaultSharedPreferences(getContext())
.getBoolean(NewWallpaperNotificationReceiver.PREF_ENABLED, true));
CheckBox mBlurOnLockScreenCheckBox = (CheckBox) rootView.findViewById(
CheckBox mBlurOnLockScreenCheckBox = rootView.findViewById(
R.id.blur_on_lockscreen_checkbox);
mBlurOnLockScreenCheckBox.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@@ -18,10 +18,13 @@
import android.app.job.JobParameters;
import android.app.job.JobService;
import android.os.Build;
import android.support.annotation.RequiresApi;
/**
* JobService that handles reloading artwork after any initial failure
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class DownloadArtworkJobService extends JobService {
private DownloadArtworkTask mDownloadArtworkTask = null;
@@ -115,7 +115,7 @@ private void cancelArtworkDownloadRetries() {
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
am.cancel(TaskQueueService.getArtworkDownloadRetryPendingIntent(this));
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
sp.edit().putInt(PREF_ARTWORK_DOWNLOAD_ATTEMPT, 0).commit();
sp.edit().putInt(PREF_ARTWORK_DOWNLOAD_ATTEMPT, 0).apply();
}
}
@@ -131,7 +131,7 @@ private void scheduleRetryArtworkDownload() {
} else {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
int reloadAttempt = sp.getInt(PREF_ARTWORK_DOWNLOAD_ATTEMPT, 0);
sp.edit().putInt(PREF_ARTWORK_DOWNLOAD_ATTEMPT, reloadAttempt + 1).commit();
sp.edit().putInt(PREF_ARTWORK_DOWNLOAD_ATTEMPT, reloadAttempt + 1).apply();
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
long retryTimeMillis = SystemClock.elapsedRealtime() + (1 << reloadAttempt) * 2000;
am.set(AlarmManager.ELAPSED_REALTIME, retryTimeMillis,
@@ -53,7 +53,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) {
mSubtitleView = view.findViewById(R.id.logo_subtitle);
mLogoView = (AnimatedMuzeiLogoView) view.findViewById(R.id.animated_logo);
mLogoView = view.findViewById(R.id.animated_logo);
mLogoView.setOnStateChangeListener(new AnimatedMuzeiLogoView.OnStateChangeListener() {
@Override
public void onStateChange(int state) {
Oops, something went wrong.

0 comments on commit 4351641

Please sign in to comment.