Skip to content

Commit

Permalink
Set wallpaper only on window focus; remove unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devliber committed Aug 26, 2021
1 parent b6a2318 commit 2088a61
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 60 deletions.
8 changes: 0 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ android {
targetSdk 31
versionCode 6
versionName "2.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand All @@ -28,10 +26,4 @@ android {
}

dependencies {

// implementation 'androidx.appcompat:appcompat:1.3.1'
// implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,19 @@ protected void onCreate(Bundle savedInstanceState) {
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);

// Set the color wallpaper
setColorWallpaper();
if (hasFocus) {
// Set the color wallpaper
setColorWallpaper();

// Finish the activity
finish();
// Finish the activity
finish();
}
}

/**
* Sets the color wallpaper to the color value in the Clipboard, or to a random color.
*/
private void setColorWallpaper() {

// Try to get the color parameter from the clipboard
Integer colorParam = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ public static void setColorWallpaper(Context context, int color) throws IOExcept
// Get the Wallpaper Manager
final WallpaperManager wpManager = WallpaperManager.getInstance(context);

// Create the pitch black bitmap
final Bitmap pitchBlackBitmap = createColorBitmap(color, MIN_SAFE_SIZE, MIN_SAFE_SIZE);
// Create the color bitmap
final Bitmap colorBitmap = createColorBitmap(color, MIN_SAFE_SIZE, MIN_SAFE_SIZE);

// Set the wallpaper
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// On Android N and above use the new API to set both the general system wallpaper and
// the lock-screen-specific wallpaper
wpManager.setBitmap(pitchBlackBitmap, null, true, WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK);
wpManager.setBitmap(colorBitmap, null, true, WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK);
} else {
wpManager.setBitmap(pitchBlackBitmap);
wpManager.setBitmap(colorBitmap);
}
}

Expand Down
17 changes: 0 additions & 17 deletions app/src/test/java/com/appgramming/lonecolor/ExampleUnitTest.java

This file was deleted.

0 comments on commit 2088a61

Please sign in to comment.