Skip to content

Commit

Permalink
resolve #68
Browse files Browse the repository at this point in the history
  • Loading branch information
valkriaine committed May 11, 2022
1 parent 24a3664 commit dbbe199
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions app/src/main/java/com/factor/launcher/activities/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import com.factor.launcher.databinding.ActivityHomeBinding;
import com.factor.launcher.fragments.HomeScreenFragment;
import com.factor.launcher.util.OnSystemActionsCallBack;
import com.factor.launcher.view_models.AppSettingsManager;
import com.factor.launcher.util.Util;
import com.factor.launcher.view_models.AppSettingsManager;

import static com.factor.launcher.util.Constants.PACKAGE_NAME;

Expand All @@ -32,6 +32,8 @@ public class HomeActivity extends AppCompatActivity implements LifecycleOwner

private Drawable wallpaper = null;

private int wallpaperId = 0;

private WallpaperManager wm;

private boolean isWallpaperChanged = false;
Expand All @@ -57,7 +59,13 @@ protected void onCreate(Bundle savedInstanceState)
wm = WallpaperManager.getInstance(this);
if (PermissionChecker.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PermissionChecker.PERMISSION_GRANTED)
{
if (wm.getWallpaperInfo() == null) wallpaper = wm.getFastDrawable();
if (wm.getWallpaperInfo() == null)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
wallpaperId = wm.getWallpaperId(WallpaperManager.FLAG_SYSTEM);
else
if (wm.getWallpaperInfo() == null) wallpaper = wm.getFastDrawable();
}
}


Expand Down Expand Up @@ -111,6 +119,8 @@ protected void onResume()
}
}


//home button press
@Override
protected void onNewIntent(Intent intent)
{
Expand Down Expand Up @@ -139,13 +149,30 @@ private void detectWallpaperChanges()
//live wallpaper
if (wm.getWallpaperInfo() != null)
{
isWallpaperChanged = wallpaper != null;
wallpaper = null;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
{
isWallpaperChanged = wallpaperId != 0;
wallpaperId = 0;
}
else
{
isWallpaperChanged = wallpaper != null;
wallpaper = null;
}
}
else //static wallpaper
{
isWallpaperChanged = wallpaper == null || !Util.bytesEqualTo(wallpaper, wm.getFastDrawable());
wallpaper = wm.getFastDrawable();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
{
isWallpaperChanged = wallpaperId == 0 || wallpaperId != wm.getWallpaperId(WallpaperManager.FLAG_SYSTEM);
wallpaperId = wm.getWallpaperId(WallpaperManager.FLAG_SYSTEM);
}
else
{
isWallpaperChanged = wallpaper == null || !Util.bytesEqualTo(wallpaper, wm.getFastDrawable());
wallpaper = wm.getFastDrawable();
}
}
}
}
Expand Down

0 comments on commit dbbe199

Please sign in to comment.