Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanndroid committed Jun 9, 2022
1 parent 967cb38 commit 66fb541
Show file tree
Hide file tree
Showing 26 changed files with 576 additions and 82 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: New Release
on:
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Init values
id: values
run: |
version=$(grep -Po -m 1 '(?<=versionName ).*' ./app/build.gradle | tr -d \")
echo ::set-output name=name::DualWallpaper v$version
echo ::set-output name=tag::v$version
echo ::set-output name=apk::DualWallpaper_v$version
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: ${{ steps.values.outputs.name }}
tag_name: ${{ steps.values.outputs.tag }}
body: No changelog
- name: Add apk
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./app/release/app-release.apk
asset_name: ${{ steps.values.outputs.apk }}.apk
asset_content_type: application/vnd.android.package-archive
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# <img align="left" loading="lazy" src="readme-res/icon.png" height="50"/> DualWallpaper
Customize your device even more by having two separate sets of wallpapers for light and dark mode. When your device's theme changes, this app will change your wallpaper to the one you've selected accordingly. To handle the change this app offers two possibilities: ``Wallpaper Service`` and ``Live Wallpaper``. In my opinion the first option is more reliable and works better but in some cases the app might get killed by the system and in this case I'd suggest using the second one. You have to see for yourself which option works best on your device. You can download and install the latest apk [here](https://github.com/Yanndroid/DualWallpaper/raw/master/app/release/app-release.apk), future updates are available directly via the app.

<img loading="lazy" src="readme-res/1.png" height="350"/> <img loading="lazy" src="readme-res/2.png" height="350"/> <img loading="lazy" src="readme-res/3.png" height="350"/> <img loading="lazy" src="readme-res/4.png" height="350"/>
3 changes: 2 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/build
google-services.json
19 changes: 13 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}

android {
Expand All @@ -10,7 +11,7 @@ android {
minSdk 26
targetSdk 32
versionCode 1
versionName "1.0"
versionName "1.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -30,12 +31,18 @@ android {
configurations.all {
exclude group: 'androidx.appcompat', module: 'appcompat'
exclude group: 'androidx.core', module: 'core'
//exclude group: 'androidx.drawerlayout', module: 'drawerlayout'
//exclude group: 'androidx.viewpager', module: 'viewpager'
exclude group: 'androidx.drawerlayout', module: 'drawerlayout'
exclude group: 'androidx.viewpager', module: 'viewpager'
exclude group: 'androidx.fragment', module: 'fragment'
exclude group: 'androidx.customview', module: 'customview'
exclude group: 'androidx.coordinatorlayout', module: 'coordinatorlayout'
}

dependencies {
implementation 'io.github.oneuiproject:lib:1.0.0'
implementation 'io.github.oneuiproject.sesl:appcompat:1.0.0'
implementation 'io.github.oneuiproject.sesl:material:1.0.0'
implementation 'io.github.oneuiproject:design:1.0.0'
implementation 'io.github.oneuiproject.sesl:appcompat:1.2.1'
implementation 'io.github.oneuiproject.sesl:material:1.2.0'
implementation 'io.github.oneuiproject.sesl:preference:1.1.0'
implementation 'io.github.oneuiproject.sesl:recyclerview:1.1.0'
implementation 'com.google.firebase:firebase-database:20.0.5'
}
Binary file added app/release/app-release.apk
Binary file not shown.
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "de.dlyt.yanndroid.dualwallpaper",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
24 changes: 24 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

<uses-feature
android:name="android.software.live_wallpaper"
Expand Down Expand Up @@ -58,7 +61,28 @@

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.ATTACH_DATA" />
<data android:mimeType="image/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".ui.AboutActivity"
android:exported="true" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider_paths" />
</provider>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import android.content.Intent;
import android.util.Log;

import androidx.preference.PreferenceManager;

public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("BootReceiver", intent.getAction());
if (context.getSharedPreferences("sp", Context.MODE_PRIVATE).getBoolean("use_service_switch", false))
if (PreferenceManager.getDefaultSharedPreferences(context).getString("main_pref", "off").equals("wps"))
context.startForegroundService(new Intent(context, WallpaperService.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.service.wallpaper.WallpaperService;
import android.view.SurfaceHolder;

import java.io.File;

public class LiveWallpaper extends WallpaperService {

private WallpaperUtil wallpaperUtil;
Expand All @@ -26,21 +28,16 @@ public Engine onCreateEngine() {
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (uiMode != newConfig.uiMode) {
//dynamicThemeEngine.update(newConfig);
wallpaperUtil.loadWallpaper(false, newConfig.uiMode != 33);
uiMode = newConfig.uiMode;
}
dynamicThemeEngine.update(newConfig);
//wallpaperUtil.loadWallpaper(false, newConfig.uiMode != 33);
}

private class DynamicThemeEngine extends Engine {
private final Handler handler = new Handler();
private final Runnable runnable = this::draw;
private boolean lightMode, portrait;

private boolean visible = true;

private boolean visible = true; private final Runnable runnable = this::draw;
public DynamicThemeEngine(Context context) {
update(context.getResources().getConfiguration());
}
Expand All @@ -54,9 +51,11 @@ public void update(Configuration config) {
private void draw() {
SurfaceHolder holder = getSurfaceHolder();
Canvas canvas = null;
String wallpaperPath = wallpaperUtil.getWallpaperPath(true, lightMode);
if (!new File(wallpaperPath).exists()) return;
try {
canvas = holder.lockCanvas();
Bitmap bMap = BitmapFactory.decodeFile(wallpaperUtil.getWallpaperPath(true, lightMode));
Bitmap bMap = BitmapFactory.decodeFile(wallpaperPath);
Rect surfaceFrame = holder.getSurfaceFrame();

int cropH = !portrait ? 0 : (bMap.getWidth() - ((bMap.getHeight() / surfaceFrame.height()) * surfaceFrame.width())) / 2;
Expand Down Expand Up @@ -90,6 +89,10 @@ public void onSurfaceDestroyed(SurfaceHolder holder) {
this.visible = false;
handler.removeCallbacks(runnable);
}




}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import android.app.WallpaperManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.widget.Toast;

import androidx.core.app.ActivityCompat;
import androidx.preference.PreferenceManager;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -26,9 +29,21 @@ public WallpaperUtil(Context context) {
this.wallpaperManager = WallpaperManager.getInstance(context);
}

public void saveWallpaper(boolean homeScreen, boolean lightMode) {
public void saveCurrentWallpaper(boolean homeScreen, boolean lightMode) {
if (!hasPermission()) return;
saveInputStream(new ParcelFileDescriptor.AutoCloseInputStream(wallpaperManager.getWallpaperFile(homeScreen ? WallpaperManager.FLAG_SYSTEM : WallpaperManager.FLAG_LOCK)), new File(getWallpaperPath(homeScreen, lightMode)));
ParcelFileDescriptor fileDescriptor = wallpaperManager.getWallpaperFile(homeScreen ? WallpaperManager.FLAG_SYSTEM : WallpaperManager.FLAG_LOCK);
if (fileDescriptor == null) {
Toast.makeText(context, R.string.wallpaper_not_supported, Toast.LENGTH_SHORT).show();
return;
}
saveInputStream(new ParcelFileDescriptor.AutoCloseInputStream(fileDescriptor), new File(getWallpaperPath(homeScreen, lightMode)));
}

public void saveUriWallpaper(Uri wallpaperUri, boolean homeScreen, boolean lightMode) throws FileNotFoundException {
saveInputStream(context.getContentResolver().openInputStream(wallpaperUri), new File(getWallpaperPath(homeScreen, lightMode)));
if (PreferenceManager.getDefaultSharedPreferences(context).getString("main_pref", "off").equals("wps") && (context.getResources().getConfiguration().uiMode != 33) == lightMode) {
loadWallpaper(homeScreen, lightMode);
}
}

public void loadWallpaper(boolean homeScreen, boolean lightMode) {
Expand Down Expand Up @@ -58,7 +73,7 @@ private InputStream loadInputStream(File file) {
}
}

private void saveInputStream(InputStream in, File file) {
public void saveInputStream(InputStream in, File file) {
OutputStream out = null;
try {
out = new FileOutputStream(file);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package de.dlyt.yanndroid.dualwallpaper.ui;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;

import de.dlyt.yanndroid.dualwallpaper.R;
import de.dlyt.yanndroid.dualwallpaper.utils.Updater;
import dev.oneuiproject.oneui.layout.AppInfoLayout;

public class AboutActivity extends AppCompatActivity implements AppInfoLayout.OnClickListener, Updater.UpdateChecker {

private AppInfoLayout appInfoLayout;
private String update_url, update_version;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);

appInfoLayout = findViewById(R.id.appInfoLayout);
appInfoLayout.setMainButtonClickListener(this);
Updater.checkForUpdate(this, this);
}

@Override
public void updateAvailable(boolean available, String url, String versionName) {
appInfoLayout.setStatus(available ? AppInfoLayout.UPDATE_AVAILABLE : AppInfoLayout.NO_UPDATE);
update_url = url;
update_version = versionName;
}

@Override
public void githubAvailable(String url) {
AppCompatButton about_github = findViewById(R.id.about_github);
about_github.setVisibility(View.VISIBLE);
about_github.setOnClickListener(v -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))));
}

@Override
public void noConnection() {
appInfoLayout.setStatus(AppInfoLayout.NO_CONNECTION);
}

@Override
public void onUpdateClicked(View v) {
if (update_url != null) Updater.downloadAndInstall(this, update_url, update_version);
}

@Override
public void onRetryClicked(View v) {
Updater.checkForUpdate(this, this);
}

@Override
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
getMenuInflater().inflate(dev.oneuiproject.oneui.R.menu.app_info_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == dev.oneuiproject.oneui.R.id.menu_app_info) {
appInfoLayout.openSettingsAppInfo();
return true;
}
return false;
}
}
Loading

0 comments on commit 66fb541

Please sign in to comment.