From 26bc87fb14d874a5e462bd92c312437b55d6f852 Mon Sep 17 00:00:00 2001 From: valentin Date: Sun, 16 Aug 2020 11:30:59 +0200 Subject: [PATCH] first basic features: pick file and send to kwlp --- .gitignore | 14 ++ .idea/.gitignore | 3 + .idea/.name | 1 + .idea/compiler.xml | 6 + .idea/gradle.xml | 19 ++ .idea/jarRepositories.xml | 25 +++ .idea/misc.xml | 9 + .idea/uiDesigner.xml | 124 +++++++++++++ app/.gitignore | 1 + app/build.gradle | 33 ++++ app/proguard-rules.pro | 21 +++ .../ExampleInstrumentedTest.java | 25 +++ app/src/main/AndroidManifest.xml | 21 +++ .../colorconsistency/ImageChangeService.java | 33 ++++ .../colorconsistency/MainActivity.java | 34 ++++ .../ToKWLP/CreateKLWPIntent.java | 28 +++ .../colorconsistency/image/ImageChooser.java | 37 ++++ .../drawable-v24/ic_launcher_foreground.xml | 31 ++++ .../res/drawable/ic_launcher_background.xml | 74 ++++++++ app/src/main/res/layout/activity_main.xml | 23 +++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3593 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5339 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2636 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 3388 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4926 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7472 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7909 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 11873 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10652 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 16570 bytes app/src/main/res/values/colors.xml | 6 + app/src/main/res/values/strings.xml | 3 + app/src/main/res/values/styles.xml | 10 + .../colorconsistency/ExampleUnitTest.java | 17 ++ build.gradle | 24 +++ gradle.properties | 19 ++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 172 ++++++++++++++++++ gradlew.bat | 84 +++++++++ settings.gradle | 2 + 43 files changed, 915 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/compiler.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/androidTest/java/de/valentin/colorconsistency/ExampleInstrumentedTest.java create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/de/valentin/colorconsistency/ImageChangeService.java create mode 100644 app/src/main/java/de/valentin/colorconsistency/MainActivity.java create mode 100644 app/src/main/java/de/valentin/colorconsistency/ToKWLP/CreateKLWPIntent.java create mode 100644 app/src/main/java/de/valentin/colorconsistency/image/ImageChooser.java create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/styles.xml create mode 100644 app/src/test/java/de/valentin/colorconsistency/ExampleUnitTest.java create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..0018bb9 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Color Consistency \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..fc6b9ef --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6199cc2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..8a1bf36 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.3" + + defaultConfig { + applicationId "de.valentin.colorconsistency" + minSdkVersion 24 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/de/valentin/colorconsistency/ExampleInstrumentedTest.java b/app/src/androidTest/java/de/valentin/colorconsistency/ExampleInstrumentedTest.java new file mode 100644 index 0000000..96abcdc --- /dev/null +++ b/app/src/androidTest/java/de/valentin/colorconsistency/ExampleInstrumentedTest.java @@ -0,0 +1,25 @@ +package de.valentin.colorconsistency; + +import android.content.Context; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("de.valentin.colorconsistency", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..1cbfe6d --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/de/valentin/colorconsistency/ImageChangeService.java b/app/src/main/java/de/valentin/colorconsistency/ImageChangeService.java new file mode 100644 index 0000000..735276e --- /dev/null +++ b/app/src/main/java/de/valentin/colorconsistency/ImageChangeService.java @@ -0,0 +1,33 @@ +package de.valentin.colorconsistency; + +import android.app.IntentService; +import android.content.Intent; +import androidx.annotation.Nullable; +import de.valentin.colorconsistency.ToKWLP.CreateKLWPIntent; +import de.valentin.colorconsistency.image.ImageChooser; + +import java.io.File; + +public class ImageChangeService extends IntentService { + + /** + * Creates an IntentService. Invoked by your subclass's constructor. + * + * @param name Used to name the worker thread, important only for debugging. + */ + public ImageChangeService(String name) { + super(name); + } + + @Override + protected void onHandleIntent(@Nullable Intent intent) { + ImageChooser imageChooser = new ImageChooser(new File("/storage/emulated/0/Pictures/Wallpapers")); + String imagePath=imageChooser.getPath(); + + sendBroadcast(new CreateKLWPIntent("imagepath",imagePath).getIntent()); + } + + + + +} diff --git a/app/src/main/java/de/valentin/colorconsistency/MainActivity.java b/app/src/main/java/de/valentin/colorconsistency/MainActivity.java new file mode 100644 index 0000000..319e2ac --- /dev/null +++ b/app/src/main/java/de/valentin/colorconsistency/MainActivity.java @@ -0,0 +1,34 @@ +package de.valentin.colorconsistency; + +import android.view.View; +import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; +import de.valentin.colorconsistency.ToKWLP.CreateKLWPIntent; +import de.valentin.colorconsistency.image.ImageChooser; +import android.widget.Toast; + +import java.io.File; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + } + + + public void test(View view){ + + ImageChooser imageChooser = new ImageChooser(new File("/storage/emulated/0/Pictures/Wallpapers")); + String imagePath=imageChooser.getPath(); + + sendBroadcast(new CreateKLWPIntent("imagepath",imagePath).getIntent()); + + + + Toast toast = Toast.makeText(this, imagePath, Toast.LENGTH_LONG); + toast.show(); + } +} \ No newline at end of file diff --git a/app/src/main/java/de/valentin/colorconsistency/ToKWLP/CreateKLWPIntent.java b/app/src/main/java/de/valentin/colorconsistency/ToKWLP/CreateKLWPIntent.java new file mode 100644 index 0000000..1112725 --- /dev/null +++ b/app/src/main/java/de/valentin/colorconsistency/ToKWLP/CreateKLWPIntent.java @@ -0,0 +1,28 @@ +package de.valentin.colorconsistency.ToKWLP; + +import android.content.Intent; + +public class CreateKLWPIntent { + + Intent intent; + + public static final String KUSTOM_ACTION = "org.kustom.action.SEND_VAR"; + public static final String KUSTOM_ACTION_EXT_NAME = "org.kustom.action.EXT_NAME"; + public static final String KUSTOM_ACTION_VAR_NAME = "org.kustom.action.VAR_NAME"; + public static final String KUSTOM_ACTION_VAR_VALUE = "org.kustom.action.VAR_VALUE"; + public static final String KUSTOM_ACTION_VAR_NAME_ARRAY = "org.kustom.action.VAR_NAME_ARRAY"; + public static final String KUSTOM_ACTION_VAR_VALUE_ARRAY = "org.kustom.action.VAR_VALUE_ARRAY"; + + + + public CreateKLWPIntent(String var_name,String value){ + intent = new Intent(KUSTOM_ACTION); + intent.putExtra(KUSTOM_ACTION_EXT_NAME, "colorconsistency"); + intent.putExtra(KUSTOM_ACTION_VAR_NAME , var_name); + intent.putExtra(KUSTOM_ACTION_VAR_VALUE, value); + } + + public Intent getIntent() { + return intent; + } +} diff --git a/app/src/main/java/de/valentin/colorconsistency/image/ImageChooser.java b/app/src/main/java/de/valentin/colorconsistency/image/ImageChooser.java new file mode 100644 index 0000000..d140285 --- /dev/null +++ b/app/src/main/java/de/valentin/colorconsistency/image/ImageChooser.java @@ -0,0 +1,37 @@ +package de.valentin.colorconsistency.image; + +import java.io.File; +import java.util.Random; + +public class ImageChooser { + File folder; + File selected; + String path; + + + public ImageChooser(File folder) { + this.folder=folder; + pickRandomFile(); + } + + + + public void pickRandomFile(){ + try { + File[] files = folder.listFiles(); + Random rand = new Random(); + + selected = files[rand.nextInt(files.length)]; + path = selected.getAbsolutePath(); + } + catch (Exception e ){ + path="error"; + } + + } + + + public String getPath() { + return path; + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1ee1493 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..956b344 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..f7789d6 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,23 @@ + + + +