commit 26bc87fb14d874a5e462bd92c312437b55d6f852 Author: valentin Date: Sun Aug 16 11:30:59 2020 +0200 first basic features: pick file and send to kwlp 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 @@ + + + +