-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# Intellij | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/libraries | ||
|
||
# Keystore files | ||
*.jks |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 24 | ||
buildToolsVersion '24.0.2' | ||
defaultConfig { | ||
applicationId "com.appgramming.lonecolor" | ||
minSdkVersion 11 | ||
targetSdkVersion 24 | ||
versionCode 4 | ||
versionName '1.2' | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
productFlavors { | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\Users\Dev\AppData\Local\Android\android-studio\sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# 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 *; | ||
#} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.appgramming.lonecolor; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.appgramming.lonecolor"> | ||
|
||
<uses-permission android:name="android.permission.SET_WALLPAPER"/> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:installLocation="auto" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".StartActivity" | ||
android:excludeFromRecents="true" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
|
||
<service | ||
android:name=".LoneColorWallpaperService" | ||
android:exported="false"/> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (C) 2014-2016 Appgramming. All rights reserved. | ||
* http://www.appgramming.com | ||
*/ | ||
package com.appgramming.lonecolor; | ||
|
||
import android.content.ClipData; | ||
import android.content.ClipDescription; | ||
import android.content.ClipboardManager; | ||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.text.TextUtils; | ||
|
||
/** | ||
* A static method to get a valid color value from the clipboard. | ||
*/ | ||
final class ColorClipParameter { | ||
|
||
/** | ||
* Gets the current clip parameter from the clipboard. | ||
* | ||
* @return The text value of the clip parameter, or null if there is no text on the clipboard. | ||
*/ | ||
private static String getClipParameter(Context context) { | ||
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); | ||
if ((clipboard != null) && clipboard.hasPrimaryClip()) { | ||
|
||
// Get the current primary clip on the clipboard | ||
final ClipData clip = clipboard.getPrimaryClip(); | ||
if ((clip != null) && (clip.getItemCount() > 0)) { | ||
|
||
final ClipDescription description = clip.getDescription(); | ||
|
||
// Return null if the clipboard does not contain plain text or html text | ||
if (!description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN) && | ||
!description.hasMimeType(ClipDescription.MIMETYPE_TEXT_HTML)) { | ||
return null; | ||
} | ||
|
||
// Ignore and return null if it's a clip previously copied by LoneColor | ||
final CharSequence label = description.getLabel(); | ||
if ((label != null) && (label.equals(context.getString(R.string.app_name)))) { | ||
return null; | ||
} | ||
|
||
// Get the text from the clipboard | ||
final CharSequence sequence = clip.getItemAt(0).getText(); | ||
if (sequence != null) { | ||
return sequence.toString(); | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Returns the value of the color clip parameter. | ||
* | ||
* @return An Integer color value, or null. | ||
*/ | ||
public static Integer getColor(Context context) { | ||
|
||
// Get the clip parameter from the clipboard | ||
final String clipText = ColorClipParameter.getClipParameter(context); | ||
|
||
// Return null if the clip is null or empty | ||
if (TextUtils.isEmpty(clipText)) { | ||
return null; | ||
} | ||
|
||
// Try to parse the clip parameter to a color value, "as it is" | ||
try { | ||
return Color.parseColor(clipText); | ||
} catch (IllegalArgumentException ignored) { | ||
// Ignore error, try next color format | ||
} | ||
|
||
// Try to parse the clip parameter with a "#" in front | ||
try { | ||
return Color.parseColor('#' + clipText); | ||
} catch (IllegalArgumentException ignored) { | ||
// Ignore error, we will return false | ||
} | ||
|
||
// No valid color, return null | ||
return null; | ||
} | ||
} |