├── .gitignore
├── README.md
├── annotations
├── .gitignore
├── build.gradle
└── src
│ └── main
│ └── java
│ └── com
│ └── thefinestartist
│ └── annotations
│ └── Extra.java
├── art
├── 144.png
├── 192.png
├── 2056.png
├── 256_1.png
├── 256_2.png
├── 48.png
├── 512.png
├── 72.png
├── 96.png
├── APILevel Lint Option.png
├── LogHelper.png
└── LogUtil.png
├── build.gradle
├── compilers
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── thefinestartist
│ │ └── compilers
│ │ ├── Constants.java
│ │ ├── ExtraCompiler.java
│ │ └── TypeElementUtil.java
│ └── resources
│ └── META-INF
│ └── services
│ └── javax.annotation.processing.Processor
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── sample
├── .gitignore
├── build.gradle
├── keystore
│ └── keystore.jks
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── thefinestartist
│ │ └── utils
│ │ └── sample
│ │ ├── App.java
│ │ ├── Fragment1.java
│ │ ├── MainActivity.java
│ │ └── fragments
│ │ ├── Fragment2.java
│ │ ├── Fragment3.java
│ │ └── SubActivity.java
│ └── res
│ ├── color
│ └── black.xml
│ ├── layout
│ ├── fragment1_layout.xml
│ └── main_layout.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── settings.gradle
└── utils
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── com
│ └── thefinestartist
│ └── utils
│ ├── ApplicationTest.java
│ └── etc
│ └── PreferencesUtilTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── thefinestartist
│ │ ├── Base.java
│ │ ├── binders
│ │ └── ExtrasBinder.java
│ │ ├── builders
│ │ ├── ActivityBuilder.java
│ │ └── BundleBuilder.java
│ │ ├── converters
│ │ ├── Unit.java
│ │ └── UnitConverter.java
│ │ ├── enums
│ │ ├── LogLevel.java
│ │ └── Rotation.java
│ │ ├── listeners
│ │ └── KeyboardStateListener.java
│ │ ├── utils
│ │ ├── content
│ │ │ ├── ContextUtil.java
│ │ │ ├── Ctx.java
│ │ │ ├── Res.java
│ │ │ ├── ResourcesUtil.java
│ │ │ ├── ThemeUtil.java
│ │ │ └── TypedValueUtil.java
│ │ ├── etc
│ │ │ ├── APILevel.java
│ │ │ ├── IntArrayUtil.java
│ │ │ ├── PackageUtil.java
│ │ │ ├── SparseArrayUtil.java
│ │ │ ├── ThreadUtil.java
│ │ │ └── TypefaceUtil.java
│ │ ├── log
│ │ │ ├── AndroidLogPrinter.java
│ │ │ ├── FileLogPrinter.java
│ │ │ ├── L.java
│ │ │ ├── LogHelper.java
│ │ │ ├── LogPrinter.java
│ │ │ ├── LogUtil.java
│ │ │ └── Settings.java
│ │ ├── preferences
│ │ │ ├── Pref.java
│ │ │ └── PreferencesUtil.java
│ │ ├── service
│ │ │ ├── ClipboardManagerUtil.java
│ │ │ ├── ServiceUtil.java
│ │ │ ├── VibratorUtil.java
│ │ │ └── WindowManagerUtil.java
│ │ └── ui
│ │ │ ├── DisplayUtil.java
│ │ │ ├── Keyboard.java
│ │ │ ├── KeyboardUtil.java
│ │ │ └── ViewUtil.java
│ │ └── wip
│ │ ├── AgeUtil.java
│ │ ├── AudioManagerUtil.java
│ │ ├── AwakeUtil.java
│ │ ├── BitmapUtil.java
│ │ ├── DateUtil.java
│ │ ├── EmailUtil.java
│ │ ├── FileUtil.java
│ │ ├── LanguageDetector.java
│ │ ├── NetworkUtil.java
│ │ ├── PhotoUtil.java
│ │ ├── RippleUtil.java
│ │ └── Validator.java
└── res
│ ├── anim
│ ├── accelerate_cubic.xml
│ ├── accelerate_quart.xml
│ ├── accelerate_quint.xml
│ ├── activity_close_enter.xml
│ ├── activity_close_exit.xml
│ ├── activity_open_enter.xml
│ ├── activity_open_exit.xml
│ ├── decelerate_cubic.xml
│ ├── decelerate_quart.xml
│ ├── decelerate_quint.xml
│ ├── fade_in.xml
│ ├── fade_in_fast.xml
│ ├── fade_out.xml
│ ├── fade_out_fast.xml
│ ├── fade_out_slow.xml
│ ├── fragment_close_exit.xml
│ ├── fragment_close_exit_reverse.xml
│ ├── fragment_open_enter.xml
│ ├── fragment_open_enter_reverse.xml
│ ├── modal_activity_close_enter.xml
│ ├── modal_activity_close_exit.xml
│ ├── modal_activity_open_enter.xml
│ ├── modal_activity_open_exit.xml
│ ├── no_anim.xml
│ ├── splash_out.xml
│ ├── view_blink.xml
│ ├── view_bounce.xml
│ ├── view_fade_in.xml
│ ├── view_fade_out.xml
│ ├── view_move.xml
│ ├── view_rotate.xml
│ ├── view_slide_down.xml
│ ├── view_slide_up.xml
│ ├── view_zoom_in.xml
│ └── view_zoom_out.xml
│ ├── animator
│ ├── card_flip_left_in.xml
│ ├── card_flip_left_out.xml
│ ├── card_flip_right_in.xml
│ └── card_flip_right_out.xml
│ └── values
│ ├── colors_basic.xml
│ ├── colors_grey.xml
│ └── colors_transparent.xml
└── test
└── java
└── com
└── thefinestartist
└── helpers
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/osx,windows,linux,android,intellij
3 |
4 | ### OSX ###
5 | .DS_Store
6 | .AppleDouble
7 | .LSOverride
8 |
9 | # Icon must end with two \r
10 | Icon
11 |
12 |
13 | # Thumbnails
14 | ._*
15 |
16 | # Files that might appear in the root of a volume
17 | .DocumentRevisions-V100
18 | .fseventsd
19 | .Spotlight-V100
20 | .TemporaryItems
21 | .Trashes
22 | .VolumeIcon.icns
23 |
24 | # Directories potentially created on remote AFP share
25 | .AppleDB
26 | .AppleDesktop
27 | Network Trash Folder
28 | Temporary Items
29 | .apdisk
30 |
31 |
32 | ### Windows ###
33 | # Windows image file caches
34 | Thumbs.db
35 | ehthumbs.db
36 |
37 | # Folder config file
38 | Desktop.ini
39 |
40 | # Recycle Bin used on file shares
41 | $RECYCLE.BIN/
42 |
43 | # Windows Installer files
44 | *.cab
45 | *.msi
46 | *.msm
47 | *.msp
48 |
49 | # Windows shortcuts
50 | *.lnk
51 |
52 |
53 | ### Linux ###
54 | *~
55 |
56 | # temporary files which can be created if a process still has a handle open of a deleted file
57 | .fuse_hidden*
58 |
59 | # KDE directory preferences
60 | .directory
61 |
62 | # Linux trash folder which might appear on any partition or disk
63 | .Trash-*
64 |
65 |
66 | ### Android ###
67 | # Built application files
68 | *.apk
69 | *.ap_
70 |
71 | # Files for the Dalvik VM
72 | *.dex
73 |
74 | # Java class files
75 | *.class
76 |
77 | # Generated files
78 | bin/
79 | gen/
80 |
81 | # Gradle files
82 | .gradle/
83 | build/
84 |
85 | # Local configuration file (sdk path, etc)
86 | local.properties
87 |
88 | # Proguard folder generated by Eclipse
89 | proguard/
90 |
91 | # Log Files
92 | *.log
93 |
94 | # Android Studio Navigation editor temp files
95 | .navigation/
96 |
97 | # Android Studio captures folder
98 | captures/
99 |
100 | ### Android Patch ###
101 | gen-external-apklibs
102 |
103 |
104 | ### Intellij ###
105 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
106 |
107 | *.iml
108 |
109 | ## Directory-based project format:
110 | .idea/
111 | # if you remove the above rule, at least ignore the following:
112 |
113 | # User-specific stuff:
114 | # .idea/workspace.xml
115 | # .idea/tasks.xml
116 | # .idea/dictionaries
117 | # .idea/shelf
118 |
119 | # Sensitive or high-churn files:
120 | # .idea/dataSources.ids
121 | # .idea/dataSources.xml
122 | # .idea/sqlDataSources.xml
123 | # .idea/dynamic.xml
124 | # .idea/uiDesigner.xml
125 |
126 | # Gradle:
127 | # .idea/gradle.xml
128 | # .idea/libraries
129 |
130 | # Mongo Explorer plugin:
131 | # .idea/mongoSettings.xml
132 |
133 | ## File-based project format:
134 | *.ipr
135 | *.iws
136 |
137 | ## Plugin-specific files:
138 |
139 | # IntelliJ
140 | /out/
141 |
142 | # mpeltonen/sbt-idea plugin
143 | .idea_modules/
144 |
145 | # JIRA plugin
146 | atlassian-ide-plugin.xml
147 |
148 | # Crashlytics plugin (for Android Studio and IntelliJ)
149 | com_crashlytics_export_strings.xml
150 | crashlytics.properties
151 | crashlytics-build.properties
152 | fabric.properties
--------------------------------------------------------------------------------
/annotations/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/annotations/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 | //apply plugin: 'com.novoda.bintray-release'
3 |
4 | //publish {
5 | // userOrg = 'thefinestartist'
6 | // groupId = 'com.thefinestartist'
7 | // artifactId = 'annotations'
8 | // publishVersion = rootProject.ext.versionName
9 | // desc = 'Context free and basic utils to build Android project conveniently.'
10 | // website = 'https://github.com/TheFinestArtist/AndroidBaseUtils'
11 | //}
--------------------------------------------------------------------------------
/annotations/src/main/java/com/thefinestartist/annotations/Extra.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.annotations;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.Target;
5 |
6 | import static java.lang.annotation.ElementType.FIELD;
7 | import static java.lang.annotation.RetentionPolicy.CLASS;
8 |
9 | /**
10 | * Bind a field to the bundle data for the specific key.
11 | *
12 | * {@literal @}Extra(EXTRA_TITLE) String title;
13 | *
14 | */
15 | @Retention(CLASS)
16 | @Target(FIELD)
17 | public @interface Extra {
18 | String value() default "";
19 | }
--------------------------------------------------------------------------------
/art/144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/144.png
--------------------------------------------------------------------------------
/art/192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/192.png
--------------------------------------------------------------------------------
/art/2056.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/2056.png
--------------------------------------------------------------------------------
/art/256_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/256_1.png
--------------------------------------------------------------------------------
/art/256_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/256_2.png
--------------------------------------------------------------------------------
/art/48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/48.png
--------------------------------------------------------------------------------
/art/512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/512.png
--------------------------------------------------------------------------------
/art/72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/72.png
--------------------------------------------------------------------------------
/art/96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/96.png
--------------------------------------------------------------------------------
/art/APILevel Lint Option.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/APILevel Lint Option.png
--------------------------------------------------------------------------------
/art/LogHelper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/LogHelper.png
--------------------------------------------------------------------------------
/art/LogUtil.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/art/LogUtil.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
9 | classpath 'com.android.tools.build:gradle:2.1.0'
10 | classpath 'com.novoda:bintray-release:0.3.4'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | }
21 |
22 | /**
23 | * Prevents sporadic compilation error: 'Bad service configuration file, or exception thrown while constructing
24 | * Processor object: javax.annotation.processing.Processor: Error reading configuration file'
25 | *
26 | * See https://discuss.gradle.org/t/gradle-not-compiles-with-solder-tooling-jar/7583/20
27 | */
28 | tasks.withType(JavaCompile) { options.fork = true }
29 | }
30 |
31 | task clean(type: Delete) {
32 | delete rootProject.buildDir
33 | }
34 |
35 | ext {
36 | minSdkVersion = 7
37 | targetSdkVersion = 23
38 | compileSdkVersion = 23
39 | buildToolsVersion = '23.0.2'
40 |
41 | sourceCompatibility = JavaVersion.VERSION_1_7
42 | targetCompatibility = JavaVersion.VERSION_1_7
43 |
44 | versionCode = 1
45 | versionName = '0.9.5'
46 |
47 | supportLibVersion = '23.3.0'
48 | playLibVersion = '8.4.0'
49 | }
50 |
51 | //$ ./gradlew clean build bintrayUpload -PbintrayUser=thefinestartist -PbintrayKey=BINTRAY_KEY -PdryRun=false
--------------------------------------------------------------------------------
/compilers/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/compilers/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 | //apply plugin: 'com.novoda.bintray-release'
3 |
4 | dependencies {
5 | compile project(':annotations')
6 | // compile "com.thefinestartist:annotations:${rootProject.ext.versionName}"
7 | compile 'com.google.auto.service:auto-service:1.0-rc2'
8 | compile 'com.google.android:android:2.1.2'
9 | compile 'com.squareup:javapoet:1.5.1'
10 | }
11 |
12 | //publish {
13 | // userOrg = 'thefinestartist'
14 | // groupId = 'com.thefinestartist'
15 | // artifactId = 'compilers'
16 | // publishVersion = rootProject.ext.versionName
17 | // desc = 'Context free and basic utils to build Android project conveniently.'
18 | // website = 'https://github.com/TheFinestArtist/AndroidBaseUtils'
19 | //}
--------------------------------------------------------------------------------
/compilers/src/main/java/com/thefinestartist/compilers/Constants.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.compilers;
2 |
3 | /**
4 | * Created by TheFinestArtist on 2/9/16.
5 | */
6 | public class Constants {
7 |
8 | public static final String SUFFIX = "$$ExtraBinder";
9 |
10 | public static final String BINDING_ACTIVITY = " activity.%s = (%s) bundle.get(\"%s\");";
11 | public static final String BINDER_ACTIVITY = ""
12 | + "package %s;\n\n"
13 | + "import android.os.Bundle;\n\n"
14 | + "public class %s {\n"
15 | + " public static void bind(%s activity) {\n"
16 | + " Bundle bundle = activity.getIntent().getExtras();\n"
17 | + "%s"
18 | + " }\n"
19 | + "}\n";
20 |
21 | public static final String BINDING_FRAGMENT = " fragment.%s = (%s) bundle.get(\"%s\");";
22 | public static final String BINDER_FRAGMENT = ""
23 | + "package %s;\n\n"
24 | + "import android.os.Bundle;\n\n"
25 | + "public class %s {\n"
26 | + " public static void bind(%s fragment) {\n"
27 | + " Bundle bundle = fragment.getArguments();\n"
28 | + "%s"
29 | + " }\n"
30 | + "}\n";
31 | }
32 |
--------------------------------------------------------------------------------
/compilers/src/main/java/com/thefinestartist/compilers/ExtraCompiler.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.compilers;
2 |
3 | import android.app.Activity;
4 |
5 | import com.thefinestartist.annotations.Extra;
6 |
7 | import java.io.IOException;
8 | import java.io.Writer;
9 | import java.util.HashSet;
10 | import java.util.LinkedHashMap;
11 | import java.util.Map;
12 | import java.util.Set;
13 |
14 | import javax.annotation.processing.AbstractProcessor;
15 | import javax.annotation.processing.Filer;
16 | import javax.annotation.processing.Messager;
17 | import javax.annotation.processing.ProcessingEnvironment;
18 | import javax.annotation.processing.RoundEnvironment;
19 | import javax.annotation.processing.SupportedAnnotationTypes;
20 | import javax.lang.model.SourceVersion;
21 | import javax.lang.model.element.Element;
22 | import javax.lang.model.element.ElementKind;
23 | import javax.lang.model.element.Modifier;
24 | import javax.lang.model.element.TypeElement;
25 | import javax.lang.model.type.DeclaredType;
26 | import javax.lang.model.type.TypeKind;
27 | import javax.lang.model.type.TypeMirror;
28 | import javax.lang.model.util.Types;
29 | import javax.tools.Diagnostic;
30 | import javax.tools.JavaFileObject;
31 |
32 | /**
33 | * Created by TheFinestArtist on 2/7/16.
34 | */
35 | @SupportedAnnotationTypes("com.thefinestartist.annotations.Extra")
36 | public class ExtraCompiler extends AbstractProcessor {
37 |
38 |
39 | Filer filer;
40 | Messager messager;
41 | Types types;
42 |
43 | @Override
44 | public SourceVersion getSupportedSourceVersion() {
45 | return SourceVersion.latestSupported();
46 | }
47 |
48 | @Override
49 | public synchronized void init(ProcessingEnvironment processingEnv) {
50 | super.init(processingEnv);
51 | filer = processingEnv.getFiler();
52 | messager = processingEnv.getMessager();
53 | types = processingEnv.getTypeUtils();
54 | }
55 |
56 | private void note(String message, Object... args) {
57 | messager.printMessage(Diagnostic.Kind.NOTE, String.format(message, args));
58 | }
59 |
60 | private void error(String message, Object... args) {
61 | messager.printMessage(Diagnostic.Kind.ERROR, String.format(message, args));
62 | }
63 |
64 | @Override
65 | public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {
66 | Map> bindingsByClass = new LinkedHashMap<>();
67 | Set bindingTargets = new HashSet<>();
68 |
69 | for (Element element : roundEnv.getElementsAnnotatedWith(Extra.class)) {
70 |
71 | // Verify containing type.
72 | TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();
73 | if (enclosingElement.getKind() != ElementKind.CLASS) {
74 | error("Unexpected @Extra on field in " + element);
75 | continue;
76 | }
77 |
78 | // Verify field properties.
79 | Set modifiers = element.getModifiers();
80 | if (modifiers.contains(Modifier.PRIVATE)) {
81 | error("@Extra fields must not be private: "
82 | + enclosingElement.getQualifiedName()
83 | + "."
84 | + element);
85 | continue;
86 | }
87 |
88 | // Get and optionally create a set of all binding points for a type.
89 | Set bindings = bindingsByClass.get(enclosingElement);
90 | if (bindings == null) {
91 | bindings = new HashSet<>();
92 | bindingsByClass.put(enclosingElement, bindings);
93 | }
94 |
95 | // Assemble information on the binding point.
96 | String variableName = element.getSimpleName().toString();
97 | String type = element.asType().toString();
98 | String value = element.getAnnotation(Extra.class).value();
99 |
100 | if (TypeElementUtil.instanceOf(enclosingElement, Activity.class)) {
101 | bindings.add(new BindingPoint(ClassType.ACTIVITY, variableName, type, value));
102 | } else {
103 | bindings.add(new BindingPoint(ClassType.FRAGMENT, variableName, type, value));
104 | }
105 |
106 | // Add to the valid binding targets set.
107 | bindingTargets.add(enclosingElement.asType());
108 | }
109 |
110 | for (Map.Entry> binding : bindingsByClass.entrySet()) {
111 | TypeElement type = binding.getKey();
112 | String targetClass = type.getQualifiedName().toString();
113 | int lastDot = targetClass.lastIndexOf(".");
114 | String classType = targetClass.substring(lastDot + 1);
115 | String className = classType + Constants.SUFFIX;
116 | String packageName = targetClass.substring(0, lastDot);
117 | StringBuilder bindings = new StringBuilder();
118 | for (BindingPoint bindingPoint : binding.getValue()) {
119 | bindings.append(bindingPoint).append("\n");
120 | }
121 |
122 | // Write the view binder class.
123 | try {
124 | JavaFileObject jfo = filer.createSourceFile(packageName + "." + className, type);
125 | Writer writer = jfo.openWriter();
126 | if (TypeElementUtil.instanceOf(type, Activity.class)) {
127 | writer.write(String.format(Constants.BINDER_ACTIVITY, packageName, className, classType, bindings.toString()));
128 | } else {
129 | writer.write(String.format(Constants.BINDER_FRAGMENT, packageName, className, classType, bindings.toString()));
130 | }
131 | writer.flush();
132 | writer.close();
133 | } catch (IOException e) {
134 | error(e.getMessage());
135 | }
136 | }
137 |
138 | return true;
139 | }
140 |
141 |
142 | private String resolveParentType(TypeElement typeElement, Set parents) {
143 | TypeMirror type;
144 | while (true) {
145 | type = typeElement.getSuperclass();
146 | if (type.getKind() == TypeKind.NONE) {
147 | return null;
148 | }
149 | if (parents.contains(type)) {
150 | return type.toString();
151 | }
152 | typeElement = (TypeElement) ((DeclaredType) type).asElement();
153 | }
154 | }
155 |
156 | private enum ClassType {
157 | ACTIVITY, FRAGMENT
158 | }
159 |
160 | private static class BindingPoint {
161 | private final ClassType classType;
162 | private final String variableName;
163 | private final String type;
164 | private final String value;
165 |
166 | BindingPoint(ClassType classType, String variableName, String type, String value) {
167 | this.classType = classType;
168 | this.variableName = variableName;
169 | this.type = type;
170 | this.value = value.length() == 0 ? variableName : value;
171 | }
172 |
173 | @Override
174 | public String toString() {
175 | switch (classType) {
176 | case ACTIVITY:
177 | return String.format(Constants.BINDING_ACTIVITY, variableName, type, value);
178 | case FRAGMENT:
179 | default:
180 | return String.format(Constants.BINDING_FRAGMENT, variableName, type, value);
181 | }
182 | }
183 | }
184 |
185 |
186 | }
187 |
--------------------------------------------------------------------------------
/compilers/src/main/java/com/thefinestartist/compilers/TypeElementUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.compilers;
2 |
3 | import javax.lang.model.element.TypeElement;
4 | import javax.lang.model.type.DeclaredType;
5 | import javax.lang.model.type.NoType;
6 |
7 | /**
8 | * Created by TheFinestArtist on 2/9/16.
9 | */
10 | public class TypeElementUtil {
11 |
12 | public static boolean instanceOf(TypeElement typeElement, Class clazz) {
13 | if (typeElement == null || typeElement instanceof NoType) {
14 | return false;
15 | } else if (typeElement.getQualifiedName().toString().equals(clazz.getCanonicalName())) {
16 | return true;
17 | } else if (typeElement.getSuperclass() instanceof DeclaredType) {
18 | return instanceOf((TypeElement) ((DeclaredType) typeElement.getSuperclass()).asElement(), clazz);
19 | } else {
20 | return false;
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/compilers/src/main/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | com.thefinestartist.compilers.ExtraCompiler
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'com.neenbedankt.android-apt'
3 |
4 | android {
5 | compileSdkVersion rootProject.ext.compileSdkVersion
6 | buildToolsVersion rootProject.ext.buildToolsVersion
7 |
8 | lintOptions {
9 | abortOnError false
10 | }
11 |
12 | defaultConfig {
13 | applicationId "com.thefinestartist.helpers.sample"
14 | minSdkVersion 8
15 | targetSdkVersion rootProject.ext.targetSdkVersion
16 | versionCode rootProject.ext.versionCode
17 | versionName rootProject.ext.versionName
18 | }
19 |
20 | signingConfigs {
21 | release {
22 | storeFile file("../sample/keystore/keystore.jks")
23 | storePassword "baseutils"
24 | keyAlias "thefinestartist"
25 | keyPassword "baseutils"
26 | }
27 | }
28 |
29 | buildTypes {
30 | release {
31 | minifyEnabled true
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | signingConfig signingConfigs.release
34 | }
35 | debug {
36 | minifyEnabled false
37 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
38 | }
39 | }
40 | }
41 |
42 | repositories {
43 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
44 | maven { url "https://jitpack.io" }
45 | }
46 |
47 | dependencies {
48 | // compile project(':annotations')
49 | compile project(':utils')
50 | apt project(':compilers')
51 | // compile 'com.thefinestartist:annotations:0.8.6'
52 | // compile 'com.thefinestartist:utils:0.8.4'
53 | // apt 'com.thefinestartist:compilers:0.8.4'
54 | compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
55 | compile 'com.jakewharton:butterknife:7.0.1'
56 | // compile 'com.github.orhanobut:logger:1.12'
57 | // compile 'com.jakewharton:butterknife:8.0.0-SNAPSHOT'
58 | // apt 'com.jakewharton:butterknife-compiler:8.0.0-SNAPSHOT'
59 | }
60 |
--------------------------------------------------------------------------------
/sample/keystore/keystore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/sample/keystore/keystore.jks
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/TheFinestArtist/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | -keep class com.thefinestartist.annotations.** { *; }
20 | -keep class **$$ExtraBinder { *; }
21 | -keepclasseswithmembernames class * {
22 | @com.thefinestartist.annotations.Extra ;
23 | }
24 |
25 | -keep class butterknife.** { *; }
26 | -dontwarn butterknife.internal.**
27 | -keep class **$$ViewBinder { *; }
28 |
29 | -keepclasseswithmembernames class * {
30 | @butterknife.* ;
31 | }
32 |
33 | -keepclasseswithmembernames class * {
34 | @butterknife.* ;
35 | }
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/thefinestartist/utils/sample/App.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.sample;
2 |
3 | import android.app.Application;
4 |
5 | import com.thefinestartist.Base;
6 |
7 | /**
8 | * Created by TheFinestArtist on 2/10/16.
9 | */
10 | public class App extends Application {
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | Base.initialize(this);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/thefinestartist/utils/sample/Fragment1.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import com.thefinestartist.annotations.Extra;
11 | import com.thefinestartist.binders.ExtrasBinder;
12 |
13 | import butterknife.Bind;
14 | import butterknife.ButterKnife;
15 |
16 | /**
17 | * Created by TheFinestArtist on 2/8/16.
18 | */
19 | public class Fragment1 extends Fragment {
20 |
21 | public static final String NAME = "NAME";
22 |
23 | @Extra(NAME) String name;
24 | @Bind(R.id.view) View view;
25 |
26 | @Nullable
27 | @Override
28 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
29 | View rootView = inflater.inflate(R.layout.fragment1_layout, container, false);
30 | ButterKnife.bind(this, rootView);
31 | ExtrasBinder.bind(this);
32 | return rootView;
33 | }
34 |
35 | public static String getCallerClassName() {
36 | StackTraceElement[] stElements = Thread.currentThread().getStackTrace();
37 | for (int i = 1; i < stElements.length; i++) {
38 | StackTraceElement ste = stElements[i];
39 | if (!ste.getClassName().equals(Fragment1.class.getName()) && ste.getClassName().indexOf("java.lang.Thread") != 0) {
40 | return ste.getClassName();
41 | }
42 | }
43 | return null;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/thefinestartist/utils/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentTransaction;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 |
11 | import com.thefinestartist.utils.log.L;
12 | import com.thefinestartist.utils.log.LogHelper;
13 |
14 | import org.json.JSONException;
15 | import org.json.JSONObject;
16 |
17 | /**
18 | * Created by TheFinestArtist on 1/30/16.
19 | */
20 | public class MainActivity extends AppCompatActivity {
21 |
22 | LogHelper logHelper = new LogHelper(MainActivity.class).showThreadInfo(true);
23 |
24 | EditText editText;
25 | Button button;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.main_layout);
31 | editText = (EditText) findViewById(R.id.edit_text);
32 | button = (Button) findViewById(R.id.button);
33 | button.setOnClickListener(new View.OnClickListener() {
34 | @Override
35 | public void onClick(View v) {
36 | // KeyboardUtil.showImmediately(editText);
37 | // new ActivityBuilder(SubActivity.class)
38 | // .set(SubActivity.TITLE, "Hey")
39 | // .start();
40 |
41 | // ArrayList list = new ArrayList<>();
42 | // list.add(1);
43 | // new ActivityBuilder(SubActivity.class)
44 | // .set(SubActivity.TITLE, "Hey")
45 | // .set(SubActivity.CONTENT, 1)
46 | // .set("values", new int[]{1, 2, 3})
47 | // .set(SubActivity.ARRAY_LIST, list)
48 | // .start();
49 |
50 | Fragment1 fragment1 = new Fragment1();
51 | Bundle bundle = new Bundle();
52 | bundle.putString(Fragment1.NAME, "Name");
53 | fragment1.setArguments(bundle);
54 | //
55 | // fragment1.setArguments(new BundleBuilder()
56 | // .set(Fragment1.NAME, "Hoy")
57 | // .build());
58 | //
59 | FragmentManager fragmentManager = getSupportFragmentManager();
60 | FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
61 | fragmentTransaction.add(android.R.id.content, fragment1);
62 | fragmentTransaction.commitAllowingStateLoss();
63 |
64 | // Log.e("DisplayUtil","DisplayUtil: " + DisplayUtil.getWidth());
65 | }
66 | });
67 |
68 | // VibratorUtil.eee();
69 | // KeyboardUtil.showImmediately(editText);
70 |
71 | // logHelper.v("Hey");
72 | // logHelper.v("Hello");
73 | // try {
74 | // JSONObject jsonObject = new JSONObject("caller\":\"getPoiById\",\"results\":{\"indexForPhone\":0,\"indexForEmail\":\"NULL\",\"indexForHomePage\":\"NULL\",\"indexForComment\":\"NULL\",\"phone\":\"05137-930 68\",\"cleanPhone\":\"0513793068\",\"internetAccess\":\"2\",\"overnightStay\":\"2\",\"wasteDisposal\":\"2\",\"toilet\":\"2\",\"electricity\":\"2\",\"cran\":\"2\",\"slipway\":\"2\",\"camping\":\"2\",\"freshWater\":\"2\",\"fieldNamesWithValue\":[\"phone\"],\"fieldNameTranslations\":[\"Telefon\"],\"id\":\"1470\",\"name\":\"Marina Rasche Werft GmbH & Co. KG\",\"latitude\":\"52.3956107286487\",\"longitude\":\"9.56583023071289\"}}");
75 | // logHelper.e(jsonObject);
76 | // } catch (JSONException e) {
77 | // L.e(e);
78 | // logHelper.e(e);
79 | // }
80 | //
81 | // logHelper.json("{\"caller\":\"getPoiById\",\"results\":{\"indexForPhone\":0,\"indexForEmail\":\"NULL\",\"indexForHomePage\":\"NULL\",\"indexForComment\":\"NULL\",\"phone\":\"05137-930 68\",\"cleanPhone\":\"0513793068\",\"internetAccess\":\"2\",\"overnightStay\":\"2\",\"wasteDisposal\":\"2\",\"toilet\":\"2\",\"electricity\":\"2\",\"cran\":\"2\",\"slipway\":\"2\",\"camping\":\"2\",\"freshWater\":\"2\",\"fieldNamesWithValue\":[\"phone\"],\"fieldNameTranslations\":[\"Telefon\"],\"id\":\"1470\",\"name\":\"Marina Rasche Werft GmbH & Co. KG\",\"latitude\":\"52.3956107286487\",\"longitude\":\"9.56583023071289\"}}");
82 | //
83 | // logHelper.xml("\n" +
84 | // " \n" +
85 | // " \n" +
90 | // "\n" +
91 | // " \n" +
92 | // " \n" +
98 | // "\n" +
99 | // " \n" +
100 | // " \n" +
106 | // "");
107 | // Thread thread = new Thread(new Runnable() {
108 | // @Override
109 | // public void run() {
110 | // logHelper.e("Hey");
111 | // }
112 | // });
113 | // thread.start();
114 | //
115 | // L.stackTraceCount(3).json("{\"name\":\"Leonardo Taehwan Kim\",\"email\":\"leonardo@thefinestartist.com\"}");
116 | // L.e("Hello World");
117 | //
118 | // L.showThreadInfo(true).v("Hello World");
119 | // L.tag("MainActivity").e(12.0f);
120 | // L.stackTraceCount(3).showDivider(true).json("{\"name\":\"Leonardo Taehwan Kim\",\"email\":\"leonardo@thefinestartist.com\"}");
121 |
122 | L.v("Hello World");
123 | L.tag("Tag").e(12.0f);
124 | L.showThreadInfo(true).i(new int[]{1, 2, 3});
125 | L.stackTraceCount(3).showDivider(true).json("{\"name\":\"Leonardo Taehwan Kim\",\"email\":\"leonardo@thefinestartist.com\"}");
126 |
127 | logHelper.v("Hello World");
128 | logHelper.e(12.0f);
129 | logHelper.json("{\"name\":\"Leonardo Taehwan Kim\",\"email\":\"leonardo@thefinestartist.com\"}");
130 | }
131 |
132 | @Override
133 | protected void onStart() {
134 | super.onStart();
135 | // KeyboardUtil.showImmediately(editText);
136 | }
137 |
138 | @Override
139 | protected void onResume() {
140 | super.onResume();
141 | // KeyboardUtil.showImmediately(editText);
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/thefinestartist/utils/sample/fragments/Fragment2.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.sample.fragments;
2 |
3 |
4 | import android.app.Fragment;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.thefinestartist.annotations.Extra;
12 | import com.thefinestartist.binders.ExtrasBinder;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * Created by TheFinestArtist on 2/15/16.
18 | */
19 | public class Fragment2 extends Fragment {
20 |
21 | @Extra String[] titles;
22 | @Extra List contents;
23 |
24 | @Nullable
25 | @Override
26 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
27 | ExtrasBinder.bind(this);
28 | return super.onCreateView(inflater, container, savedInstanceState);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/thefinestartist/utils/sample/fragments/Fragment3.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.sample.fragments;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.thefinestartist.annotations.Extra;
12 | import com.thefinestartist.binders.ExtrasBinder;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * Created by TheFinestArtist on 2/15/16.
18 | */
19 | public class Fragment3 extends Fragment {
20 |
21 | @Extra String[] titles;
22 | @Extra List contents;
23 |
24 | @Nullable
25 | @Override
26 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
27 | ExtrasBinder.bind(this);
28 | return super.onCreateView(inflater, container, savedInstanceState);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/thefinestartist/utils/sample/fragments/SubActivity.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.sample.fragments;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.util.Log;
6 |
7 | import com.thefinestartist.annotations.Extra;
8 | import com.thefinestartist.binders.ExtrasBinder;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by TheFinestArtist on 2/7/16.
14 | */
15 | public class SubActivity extends AppCompatActivity {
16 |
17 | public static final String TITLE = "TITLE";
18 | public static final String CONTENT = "CONTENT";
19 | public static final String ARRAY_LIST = "ARRAY_LIST";
20 |
21 | protected @Extra(TITLE) String title;
22 | static @Extra(CONTENT) int content;
23 | @Extra int[] values;
24 | @Extra(ARRAY_LIST) ArrayList list;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | ExtrasBinder.bind(this);
30 | Log.e("SubActivity", "title: " + title);
31 | Log.e("SubActivity", "content: " + content);
32 | Log.e("SubActivity", "values: " + values);
33 | Log.e("SubActivity", "list: " + list);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/sample/src/main/res/color/black.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment1_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/main_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
17 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheFinestArtist/AndroidBaseUtils/c69de3234afbce1ea0f042f6b2300d9c1ac236f9/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BaseUtils
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':annotations', ':compilers', ':utils', ':sample'
--------------------------------------------------------------------------------
/utils/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/utils/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | //apply plugin: 'com.novoda.bintray-release'
3 |
4 | android {
5 | compileSdkVersion rootProject.ext.compileSdkVersion
6 | buildToolsVersion rootProject.ext.buildToolsVersion
7 |
8 | compileOptions {
9 | sourceCompatibility rootProject.ext.sourceCompatibility
10 | targetCompatibility rootProject.ext.targetCompatibility
11 | }
12 |
13 | lintOptions {
14 | abortOnError false
15 | }
16 |
17 | defaultConfig {
18 | minSdkVersion rootProject.ext.minSdkVersion
19 | targetSdkVersion rootProject.ext.targetSdkVersion
20 | versionCode rootProject.ext.versionCode
21 | versionName rootProject.ext.versionName
22 | vectorDrawables.useSupportLibrary = true
23 | }
24 | }
25 |
26 | dependencies {
27 | compile project(':annotations')
28 | // compile "com.thefinestartist:annotations:${rootProject.ext.versionName}"
29 | compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
30 | compile "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"
31 | testCompile 'junit:junit:4.12'
32 | }
33 |
34 | //publish {
35 | // userOrg = 'thefinestartist'
36 | // groupId = 'com.thefinestartist'
37 | // artifactId = 'utils'
38 | // publishVersion = rootProject.ext.versionName
39 | // desc = 'Context free and basic utils to build Android project conveniently.'
40 | // website = 'https://github.com/TheFinestArtist/AndroidBaseUtils'
41 | //}
--------------------------------------------------------------------------------
/utils/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/TheFinestArtist/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/utils/src/androidTest/java/com/thefinestartist/utils/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/utils/src/androidTest/java/com/thefinestartist/utils/etc/PreferencesUtilTest.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.etc;
2 |
3 | import android.test.AndroidTestCase;
4 | import android.test.suitebuilder.annotation.MediumTest;
5 | import android.test.suitebuilder.annotation.SmallTest;
6 |
7 | import com.thefinestartist.Base;
8 | import com.thefinestartist.utils.preferences.PreferencesUtil;
9 |
10 | import java.util.ArrayList;
11 | import java.util.HashSet;
12 | import java.util.Set;
13 |
14 | /**
15 | * Tests of the {@link PreferencesUtil} class.
16 | *
17 | * @author Robin Gustafsson
18 | */
19 | public class PreferencesUtilTest extends AndroidTestCase {
20 |
21 | @Override
22 | public void setUp() throws Exception {
23 | super.setUp();
24 | Base.initialize(getContext());
25 | }
26 |
27 | @SmallTest
28 | public void testSetGetDefaultName() {
29 | final String expected = "TEST_DEFAULT_NAME";
30 |
31 | PreferencesUtil.setDefaultName(expected);
32 | String actual = PreferencesUtil.getDefaultName();
33 | assertEquals(expected, actual);
34 | }
35 |
36 | @SmallTest
37 | public void testDifferentNames() {
38 | final String name1 = "TEST_DIFFERENTNAMES_NAME1";
39 | final String name2 = "TEST_DIFFERENTNAMES_NAME2";
40 | final String key = "TEST_DIFFERENTNAMES_KEY";
41 | final boolean value = true;
42 | final boolean expected = false;
43 |
44 | PreferencesUtil.put(name1, key, value);
45 | boolean actual = PreferencesUtil.get(name2, key, expected);
46 | assertEquals(expected, actual);
47 | }
48 |
49 | @SmallTest
50 | public void testStoreBoolean() {
51 | final String key = "TEST_BOOLEAN";
52 | final boolean expected = true;
53 | final boolean defValue = false;
54 |
55 | PreferencesUtil.put(key, expected);
56 | boolean actual = PreferencesUtil.get(key, defValue);
57 | assertEquals(expected, actual);
58 | }
59 |
60 | @SmallTest
61 | public void testStoreBooleanNamed() {
62 | final String name = "TEST_NAMED";
63 | final String key = "TEST_BOOLEAN";
64 | final boolean expected = true;
65 | final boolean defValue = false;
66 |
67 | PreferencesUtil.put(name, key, expected);
68 | boolean actual = PreferencesUtil.get(name, key, defValue);
69 | assertEquals(expected, actual);
70 | }
71 |
72 | @SmallTest
73 | public void testStoreInt() {
74 | final String key = "TEST_INT";
75 | final int expected = 321;
76 | final int defValue = 0;
77 |
78 | PreferencesUtil.put(key, expected);
79 | int actual = PreferencesUtil.get(key, defValue);
80 | assertEquals(expected, actual);
81 | }
82 |
83 | @SmallTest
84 | public void testStoreIntNamed() {
85 | final String name = "TEST_NAMED";
86 | final String key = "TEST_INT";
87 | final int expected = 321;
88 | final int defValue = 0;
89 |
90 | PreferencesUtil.put(name, key, expected);
91 | int actual = PreferencesUtil.get(name, key, defValue);
92 | assertEquals(expected, actual);
93 | }
94 |
95 | @SmallTest
96 | public void testStoreFloat() {
97 | final String key = "TEST_FLOAT";
98 | final float expected = 12.3f;
99 | final float defValue = 0.0f;
100 |
101 | PreferencesUtil.put(key, expected);
102 | float actual = PreferencesUtil.get(key, defValue);
103 | assertEquals(expected, actual);
104 | }
105 |
106 | @SmallTest
107 | public void testStoreFloatNamed() {
108 | final String name = "TEST_NAMED";
109 | final String key = "TEST_FLOAT";
110 | final float expected = 12.3f;
111 | final float defValue = 0.0f;
112 |
113 | PreferencesUtil.put(name, key, expected);
114 | float actual = PreferencesUtil.get(name, key, defValue);
115 | assertEquals(expected, actual);
116 | }
117 |
118 | @SmallTest
119 | public void testStoreLong() {
120 | final String key = "TEST_LONG";
121 | final long expected = 321L;
122 | final long defValue = 0L;
123 |
124 | PreferencesUtil.put(key, expected);
125 | long actual = PreferencesUtil.get(key, defValue);
126 | assertEquals(expected, actual);
127 | }
128 |
129 | @SmallTest
130 | public void testStoreLongNamed() {
131 | final String name = "TEST_NAMED";
132 | final String key = "TEST_LONG";
133 | final long expected = 321L;
134 | final long defValue = 0L;
135 |
136 | PreferencesUtil.put(name, key, expected);
137 | long actual = PreferencesUtil.get(name, key, defValue);
138 | assertEquals(expected, actual);
139 | }
140 |
141 | @SmallTest
142 | public void testStoreString() {
143 | final String key = "TEST_STRING";
144 | final String expected = "Lorem ipsum";
145 | final String defValue = null;
146 |
147 | PreferencesUtil.put(key, expected);
148 | String actual = PreferencesUtil.get(key, defValue);
149 | assertEquals(expected, actual);
150 | }
151 |
152 | @SmallTest
153 | public void testStoreStringNamed() {
154 | final String name = "TEST_NAMED";
155 | final String key = "TEST_STRING";
156 | final String expected = "Lorem ipsum";
157 | final String defValue = null;
158 |
159 | PreferencesUtil.put(name, key, expected);
160 | String actual = PreferencesUtil.get(name, key, defValue);
161 | assertEquals(expected, actual);
162 | }
163 |
164 | @SmallTest
165 | public void testStoreStringSet() {
166 | final String key = "TEST_STRINGSET";
167 | final Set expected = new HashSet<>();
168 | expected.add("Lorem ipsum");
169 | expected.add("dolor sit amet");
170 | expected.add("consectetur adipiscing elit");
171 | final Set defValue = null;
172 |
173 | PreferencesUtil.put(key, expected);
174 | Set actual = PreferencesUtil.get(key, defValue);
175 | assertEquals(expected, actual);
176 | }
177 |
178 | @SmallTest
179 | public void testStoreStringSetNamed() {
180 | final String name = "TEST_NAMED";
181 | final String key = "TEST_STRINGSET";
182 | final Set expected = new HashSet<>();
183 | expected.add("Lorem ipsum");
184 | expected.add("dolor sit amet");
185 | expected.add("consectetur adipiscing elit");
186 | final Set defValue = null;
187 |
188 | PreferencesUtil.put(name, key, expected);
189 | Set actual = PreferencesUtil.get(name, key, defValue);
190 | assertEquals(expected, actual);
191 | }
192 |
193 | @MediumTest
194 | public void testStoreSerializable() {
195 | final String key = "TEST_SERIALIZABLE";
196 | final ArrayList expected = new ArrayList<>();
197 | expected.add("Lorem ipsum");
198 | expected.add("dolor sit amet");
199 | expected.add("consectetur adipiscing elit");
200 | final ArrayList defValue = new ArrayList<>();
201 | defValue.add("Proin mollis dictum");
202 |
203 | PreferencesUtil.put(key, expected);
204 | ArrayList actual = PreferencesUtil.get(key, defValue);
205 | assertEquals(expected, actual);
206 | }
207 |
208 | @MediumTest
209 | public void testStoreSerializableNamed() {
210 | final String name = "TEST_NAMED";
211 | final String key = "TEST_SERIALIZABLE";
212 | final ArrayList expected = new ArrayList<>();
213 | expected.add("Lorem ipsum");
214 | expected.add("dolor sit amet");
215 | expected.add("consectetur adipiscing elit");
216 | final ArrayList defValue = new ArrayList<>();
217 | defValue.add("Proin mollis dictum");
218 |
219 | PreferencesUtil.put(name, key, expected);
220 | ArrayList actual = PreferencesUtil.get(name, key, defValue);
221 | assertEquals(expected, actual);
222 | }
223 |
224 | @SmallTest
225 | public void testRemove() {
226 | final String key = "TEST_REMOVE";
227 | final String expected = null;
228 |
229 | PreferencesUtil.put(key, "Lorem ipsum");
230 | PreferencesUtil.remove(key);
231 | String actual = PreferencesUtil.get(key, expected);
232 | assertEquals(expected, actual);
233 | }
234 |
235 | @SmallTest
236 | public void testRemoveNamed() {
237 | final String name = "TEST_NAMED";
238 | final String key = "TEST_REMOVE";
239 | final String expected = null;
240 |
241 | PreferencesUtil.put(name, key, "Lorem ipsum");
242 | PreferencesUtil.remove(name, key);
243 | String actual = PreferencesUtil.get(name, key, expected);
244 | assertEquals(expected, actual);
245 | }
246 |
247 | @SmallTest
248 | public void testClear() {
249 | final String[] keys = {"TEST_REMOVE_1", "TEST_REMOVE_2", "TEST_REMOVE_2"};
250 | final String expected = null;
251 |
252 | for (String key : keys) {
253 | PreferencesUtil.put(key, "Lorem ipsum");
254 | }
255 | PreferencesUtil.clear();
256 | for (String key : keys) {
257 | String actual = PreferencesUtil.get(key, expected);
258 | assertEquals(expected, actual);
259 | }
260 | }
261 |
262 | @SmallTest
263 | public void testClearNamed() {
264 | final String name = "TEST_NAMED";
265 | final String[] keys = {"TEST_REMOVE_1", "TEST_REMOVE_2", "TEST_REMOVE_2"};
266 | final String expected = null;
267 |
268 | for (String key : keys) {
269 | PreferencesUtil.put(name, key, "Lorem ipsum");
270 | }
271 | PreferencesUtil.clear(name);
272 | for (String key : keys) {
273 | String actual = PreferencesUtil.get(name, key, expected);
274 | assertEquals(expected, actual);
275 | }
276 | }
277 |
278 | }
279 |
--------------------------------------------------------------------------------
/utils/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/Base.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist;
2 |
3 | import android.content.Context;
4 | import android.content.res.AssetManager;
5 | import android.content.res.Configuration;
6 | import android.content.res.Resources;
7 | import android.support.annotation.NonNull;
8 | import android.util.DisplayMetrics;
9 |
10 | /**
11 | * Base helps to get {@link Context}, {@link Resources}, {@link AssetManager}, {@link Configuration} and {@link DisplayMetrics} in any class.
12 | *
13 | * @author Leonardo Taehwan Kim
14 | */
15 | public class Base {
16 |
17 | private static Context context;
18 |
19 | public static void initialize(@NonNull Context context) {
20 | Base.context = context;
21 | }
22 |
23 | public static Context getContext() {
24 | synchronized (Base.class) {
25 | if (Base.context == null)
26 | throw new NullPointerException("Call Base.initialize(context) within your Application onCreate() method.");
27 |
28 | return Base.context.getApplicationContext();
29 | }
30 | }
31 |
32 | public static Resources getResources() {
33 | return Base.getContext().getResources();
34 | }
35 |
36 | public static Resources.Theme getTheme() {
37 | return Base.getContext().getTheme();
38 | }
39 |
40 | public static AssetManager getAssets() {
41 | return Base.getContext().getAssets();
42 | }
43 |
44 | public static Configuration getConfiguration() {
45 | return Base.getResources().getConfiguration();
46 | }
47 |
48 | public static DisplayMetrics getDisplayMetrics() {
49 | return Base.getResources().getDisplayMetrics();
50 | }
51 | }
52 | // TODO: Thread safety
53 | // TODO: ripple, bitmap, time, contact list, picture list, video list, connectivity, wake lock, screen lock/off/on, get attributes, cookie, audio
54 | // TODO: keystore
55 | // TODO: http://jo.centis1504.net/?p=1189
56 | // TODO: Test codes
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/binders/ExtrasBinder.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.binders;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.annotation.NonNull;
7 | import android.support.v4.app.Fragment;
8 |
9 | import java.lang.reflect.Method;
10 |
11 | /**
12 | * ExtrasBinder binds data from {@link Intent} or {@link Bundle} to matching variable.
13 | *
14 | * @author Leonardo Taehwan Kim
15 | */
16 | public class ExtrasBinder {
17 |
18 | static final String SUFFIX = "$$ExtraBinder";
19 |
20 | public static void bind(Activity activity) {
21 | if (activity == null)
22 | return;
23 |
24 | bindObject(activity);
25 | }
26 |
27 | public static void bind(Fragment fragment) {
28 | if (fragment == null)
29 | return;
30 |
31 | bindObject(fragment);
32 | }
33 |
34 | public static void bind(android.app.Fragment fragment) {
35 | if (fragment == null)
36 | return;
37 |
38 | bindObject(fragment);
39 | }
40 |
41 | private static void bindObject(@NonNull Object object) {
42 | try {
43 | Class> binder = Class.forName(object.getClass().getName() + SUFFIX);
44 | Method bind = binder.getMethod("bind", object.getClass());
45 | bind.invoke(null, object);
46 | } catch (ClassNotFoundException e) {
47 | e.printStackTrace();
48 | } catch (RuntimeException e) {
49 | throw e;
50 | } catch (Exception e) {
51 | throw new RuntimeException("Unable to bind extras for " + object, e);
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/builders/ActivityBuilder.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.builders;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.os.Parcelable;
8 | import android.support.annotation.NonNull;
9 | import android.support.annotation.Nullable;
10 |
11 | import com.thefinestartist.Base;
12 | import com.thefinestartist.utils.content.ContextUtil;
13 |
14 | import java.io.Serializable;
15 | import java.util.ArrayList;
16 |
17 | /**
18 | * ActivityBuilder helps to build {@link Activity} {@link Intent} and start {@link Activity}.
19 | *
20 | * @author Leonardo Taehwan Kim
21 | */
22 | public class ActivityBuilder {
23 |
24 | final Intent intent;
25 |
26 | public ActivityBuilder(@NonNull Class clazz) {
27 | intent = new Intent(Base.getContext(), clazz);
28 | }
29 |
30 | public ActivityBuilder set(@NonNull String key, T value) {
31 | intent.putExtra(key, value);
32 | return this;
33 | }
34 |
35 | public ActivityBuilder set(@NonNull String key, Parcelable value) {
36 | intent.putExtra(key, value);
37 | return this;
38 | }
39 |
40 | public ActivityBuilder set(@NonNull String key, Parcelable[] value) {
41 | intent.putExtra(key, value);
42 | return this;
43 | }
44 |
45 | public ActivityBuilder set(@NonNull String key, ArrayList value) {
46 | intent.putExtra(key, value);
47 | return this;
48 | }
49 |
50 | public ActivityBuilder remove(@NonNull String key) {
51 | intent.removeExtra(key);
52 | return this;
53 | }
54 |
55 | public ActivityBuilder setFlags(int flags) {
56 | intent.setFlags(flags);
57 | return this;
58 | }
59 |
60 | public ActivityBuilder addFlags(int flags) {
61 | intent.addFlags(flags);
62 | return this;
63 | }
64 |
65 | public Intent buildIntent() {
66 | return intent;
67 | }
68 |
69 | public void start() {
70 | ContextUtil.startActivity(intent);
71 | }
72 |
73 | public void startForResult(@NonNull Activity activity, int requestCode) {
74 | activity.startActivityForResult(intent, requestCode);
75 | }
76 |
77 | @TargetApi(16)
78 | public void startForResult(@NonNull Activity activity, int requestCode, @Nullable Bundle options) {
79 | activity.startActivityForResult(intent, requestCode, options);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/builders/BundleBuilder.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.builders;
2 |
3 | import android.os.Bundle;
4 | import android.os.Parcelable;
5 |
6 | import java.io.Serializable;
7 |
8 | /**
9 | * BundleBuilder helps to build {@link Bundle} conveniently.
10 | *
11 | * @author Leonardo Taehwan Kim
12 | */
13 | public class BundleBuilder {
14 |
15 | final Bundle bundle = new Bundle();
16 |
17 | public BundleBuilder set(String key, T value) {
18 | bundle.putSerializable(key, value);
19 | return this;
20 | }
21 |
22 | public BundleBuilder set(String key, Parcelable value) {
23 | bundle.putParcelable(key, value);
24 | return this;
25 | }
26 |
27 | public T get(String key) {
28 | return (T) bundle.getSerializable(key);
29 | }
30 |
31 | public Bundle build() {
32 | return bundle;
33 | }
34 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/converters/Unit.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.converters;
2 |
3 | /**
4 | * Unit is abbreviation class of {@link UnitConverter}.
5 | *
6 | * @author Leonardo Taehwan Kim
7 | */
8 | public class Unit extends UnitConverter {
9 | }
10 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/converters/UnitConverter.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.converters;
2 |
3 | import com.thefinestartist.Base;
4 |
5 | /**
6 | * UnitConverter helps to convert dp or sp size into pixel.
7 | *
8 | * @author Leonardo Taehwan Kim
9 | */
10 | public class UnitConverter {
11 |
12 | public static float dpToPx(float dp) {
13 | return dp * Base.getDisplayMetrics().density;
14 | }
15 |
16 | public static int dpToPx(int dp) {
17 | return (int) (dp * Base.getDisplayMetrics().density + 0.5f);
18 | }
19 |
20 | public static float pxToDp(float px) {
21 | return px / Base.getDisplayMetrics().density;
22 | }
23 |
24 | public static int pxToDp(int px) {
25 | return (int) (px / Base.getDisplayMetrics().density + 0.5f);
26 | }
27 |
28 | public static float spToPx(float sp) {
29 | return sp * Base.getDisplayMetrics().scaledDensity;
30 | }
31 |
32 | public static int spToPx(int sp) {
33 | return (int) (sp * Base.getDisplayMetrics().scaledDensity + 0.5f);
34 | }
35 |
36 | public static float pxToSp(float px) {
37 | return px / Base.getDisplayMetrics().scaledDensity;
38 | }
39 |
40 | public static int pxToSp(int px) {
41 | return (int) (px / Base.getDisplayMetrics().scaledDensity + 0.5f);
42 | }
43 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/enums/LogLevel.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.enums;
2 |
3 | import com.thefinestartist.utils.log.LogUtil;
4 |
5 | /**
6 | * Enum class associated with {@link LogUtil}.
7 | *
8 | * @author Leonardo Taehwan Kim
9 | */
10 | public enum LogLevel {
11 | FULL,
12 | VERBOSE,
13 | DEBUG,
14 | INFO,
15 | WARN,
16 | ERROR,
17 | ASSERT,
18 | NONE
19 | }
20 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/enums/Rotation.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.enums;
2 |
3 | import com.thefinestartist.utils.ui.DisplayUtil;
4 |
5 | /**
6 | * Enum class associated with {@link DisplayUtil}.
7 | *
8 | * @author Leonardo Taehwan Kim
9 | */
10 | public enum Rotation {
11 | DEGREES_0(0),
12 | DEGREES_90(1),
13 | DEGREES_180(2),
14 | DEGREES_270(3);
15 |
16 | int value;
17 |
18 | Rotation(int value) {
19 | this.value = value;
20 | }
21 |
22 | public static Rotation fromValue(int value) {
23 | for (Rotation rotation : values())
24 | if (rotation.value == value)
25 | return rotation;
26 |
27 | return DEGREES_0;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/listeners/KeyboardStateListener.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.listeners;
2 |
3 | import com.thefinestartist.utils.ui.KeyboardUtil;
4 |
5 | /**
6 | * Listener class associated with {@link KeyboardUtil}.
7 | *
8 | * @author Leonardo Taehwan Kim
9 | */
10 | public abstract class KeyboardStateListener {
11 |
12 | public void onStateChanged(int keyboardHeight, boolean opened) {
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/content/Ctx.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.content;
2 |
3 | /**
4 | * Ctx is abbreviation class of {@link ContextUtil}.
5 | *
6 | * @author Leonardo Taehwan Kim
7 | */
8 | public class Ctx extends ContextUtil {
9 | }
10 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/content/Res.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.content;
2 |
3 | /**
4 | * Res is abbreviation class of {@link ResourcesUtil}.
5 | *
6 | * @author Leonardo Taehwan Kim
7 | */
8 | public class Res extends ResourcesUtil {
9 | }
10 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/content/ThemeUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.content;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.res.Resources;
5 | import android.content.res.TypedArray;
6 | import android.graphics.drawable.Drawable;
7 | import android.support.annotation.AttrRes;
8 | import android.support.annotation.DrawableRes;
9 | import android.support.annotation.StyleRes;
10 | import android.support.annotation.StyleableRes;
11 | import android.util.AttributeSet;
12 | import android.util.TypedValue;
13 |
14 | import com.thefinestartist.Base;
15 |
16 | /**
17 | * ThemeUtil helps to manage {@link Resources.Theme} conveniently.
18 | *
19 | * @author Leonardo Taehwan Kim
20 | */
21 | public class ThemeUtil {
22 |
23 | public static void applyStyle(int resId, boolean force) {
24 | Base.getTheme().applyStyle(resId, force);
25 | }
26 |
27 | public static void dump(int priority, String tag, String prefix) {
28 | Base.getTheme().dump(priority, tag, prefix);
29 | }
30 |
31 | @TargetApi(23)
32 | public static int getChangingConfigurations() {
33 | return Base.getTheme().getChangingConfigurations();
34 | }
35 |
36 | public static Drawable getDrawable(@DrawableRes int drawableRes) {
37 | return ResourcesUtil.getDrawable(drawableRes);
38 | }
39 |
40 | public static Resources getResources() {
41 | return Base.getResources();
42 | }
43 |
44 | public static TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) {
45 | return Base.getTheme().obtainStyledAttributes(attrs);
46 | }
47 |
48 | public static TypedArray obtainStyledAttributes(@StyleRes int resid, @StyleableRes int[] attrs) {
49 | return Base.getTheme().obtainStyledAttributes(resid, attrs);
50 | }
51 |
52 | public static TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
53 | return Base.getTheme().obtainStyledAttributes(set, attrs, defStyleAttr, defStyleRes);
54 | }
55 |
56 | public static boolean resolveAttribute(int resid, TypedValue outValue, boolean resolveRefs) {
57 | return Base.getTheme().resolveAttribute(resid, outValue, resolveRefs);
58 | }
59 |
60 | public static void setTo(Resources.Theme other) {
61 | Base.getTheme().setTo(other);
62 | }
63 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/content/TypedValueUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.content;
2 |
3 | import android.util.TypedValue;
4 |
5 | import com.thefinestartist.Base;
6 |
7 | /**
8 | * TypedValueUtil helps to manage {@link TypedValue} class conveniently.
9 | *
10 | * @author Leonardo Taehwan Kim
11 | */
12 | public class TypedValueUtil {
13 |
14 | public static float applyDimension(int unit, float value) {
15 | return TypedValue.applyDimension(unit, value, Base.getDisplayMetrics());
16 | }
17 |
18 | public static float complexToDimension(int data) {
19 | return TypedValue.complexToDimension(data, Base.getDisplayMetrics());
20 | }
21 |
22 | public static int complexToDimensionPixelOffset(int data) {
23 | return TypedValue.complexToDimensionPixelOffset(data, Base.getDisplayMetrics());
24 | }
25 |
26 | public static int complexToDimensionPixelSize(int data) {
27 | return TypedValue.complexToDimensionPixelSize(data, Base.getDisplayMetrics());
28 | }
29 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/etc/APILevel.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.etc;
2 |
3 | import android.os.Build;
4 |
5 | /**
6 | * APILevel helps to check device API {@link android.os.Build.VERSION} conveniently.
7 | *
8 | * @author Marcos Trujillo, Leonardo Taehwan Kim
9 | */
10 | public class APILevel {
11 |
12 | /**
13 | * @param level minimum API level version that has to support the device
14 | * @return true when the caller API version is at least level
15 | */
16 | public static boolean require(int level) {
17 | return Build.VERSION.SDK_INT >= level;
18 | }
19 |
20 | /**
21 | * @return true when the caller API version is at least Cupcake 3
22 | */
23 | public static boolean requireCupcake() {
24 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE;
25 | }
26 |
27 | /**
28 | * @return true when the caller API version is at least Donut 4
29 | */
30 | public static boolean requireDonut() {
31 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT;
32 | }
33 |
34 | /**
35 | * @return true when the caller API version is at least Eclair 5
36 | */
37 | public static boolean requireEclair() {
38 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR;
39 | }
40 |
41 | /**
42 | * @return true when the caller API version is at least Froyo 8
43 | */
44 | public static boolean requireFroyo() {
45 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO;
46 | }
47 |
48 | /**
49 | * @return true when the caller API version is at least GingerBread 9
50 | */
51 | public static boolean requireGingerbread() {
52 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
53 | }
54 |
55 | /**
56 | * @return true when the caller API version is at least Honeycomb 11
57 | */
58 | public static boolean requireHoneycomb() {
59 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
60 | }
61 |
62 | /**
63 | * @return true when the caller API version is at least Honeycomb 3.2, 13
64 | */
65 | public static boolean requireHoneycombMR2() {
66 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2;
67 | }
68 |
69 | /**
70 | * @return true when the caller API version is at least ICS 14
71 | */
72 | public static boolean requireIceCreamSandwich() {
73 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
74 | }
75 |
76 | /**
77 | * @return true when the caller API version is at least JellyBean 16
78 | */
79 | public static boolean requireJellyBean() {
80 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
81 | }
82 |
83 | /**
84 | * @return true when the caller API version is at least JellyBean MR1 17
85 | */
86 | public static boolean requireJellyBeanMR1() {
87 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;
88 | }
89 |
90 | /**
91 | * @return true when the caller API version is at least JellyBean MR2 18
92 | */
93 | public static boolean requireJellyBeanMR2() {
94 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
95 | }
96 |
97 | /**
98 | * @return true when the caller API version is at least Kitkat 19
99 | */
100 | public static boolean requireKitkat() {
101 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
102 | }
103 |
104 | /**
105 | * @return true when the caller API version is at least Lollipop 21
106 | */
107 | public static boolean requireLollipop() {
108 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
109 | }
110 |
111 | /**
112 | * @return true when the caller API version is at least Lollipop MR1 22
113 | */
114 | public static boolean requireLollipopMR1() {
115 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1;
116 | }
117 |
118 | /**
119 | * @return true when the caller API version is at least Marshmallow 23
120 | */
121 | public static boolean requireMarshmallow() {
122 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
123 | }
124 |
125 | /**
126 | * @param level API level version that specific method or variable has been deprecated
127 | * @return true when the caller API version is less than level
128 | */
129 | public static boolean deprecatedAt(int level) {
130 | return Build.VERSION.SDK_INT < level;
131 | }
132 |
133 | /**
134 | * @return true when the caller API version is less than Cupcake 3
135 | */
136 | public static boolean deprecatedAtCupcake() {
137 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.CUPCAKE;
138 | }
139 |
140 | /**
141 | * @return true when the caller API version is less than Donut 4
142 | */
143 | public static boolean deprecatedAtDonut() {
144 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.DONUT;
145 | }
146 |
147 | /**
148 | * @return true when the caller API version is less than Eclair 5
149 | */
150 | public static boolean deprecatedAtEclair() {
151 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.ECLAIR;
152 | }
153 |
154 | /**
155 | * @return true when the caller API version is less than Froyo 8
156 | */
157 | public static boolean deprecatedAtFroyo() {
158 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO;
159 | }
160 |
161 | /**
162 | * @return true when the caller API version is less than GingerBread 9
163 | */
164 | public static boolean deprecatedAtGingerbread() {
165 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD;
166 | }
167 |
168 | /**
169 | * @return true when the caller API version is less than Honeycomb 11
170 | */
171 | public static boolean deprecatedAtHoneycomb() {
172 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB;
173 | }
174 |
175 | /**
176 | * @return true when the caller API version is less than Honeycomb 3.2, 13
177 | */
178 | public static boolean deprecatedAtHoneycombMR2() {
179 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2;
180 | }
181 |
182 | /**
183 | * @return true when the caller API version is less than ICS 14
184 | */
185 | public static boolean deprecatedAtIceCreamSandwich() {
186 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH;
187 | }
188 |
189 | /**
190 | * @return true when the caller API version is less than JellyBean 16
191 | */
192 | public static boolean deprecatedAtJellyBean() {
193 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN;
194 | }
195 |
196 | /**
197 | * @return true when the caller API version is less than JellyBean MR1 17
198 | */
199 | public static boolean deprecatedAtJellyBeanMR1() {
200 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1;
201 | }
202 |
203 | /**
204 | * @return true when the caller API version is less than JellyBean MR2 18
205 | */
206 | public static boolean deprecatedAtJellyBeanMR2() {
207 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2;
208 | }
209 |
210 | /**
211 | * @return true when the caller API version is less than Kitkat 19
212 | */
213 | public static boolean deprecatedAtKitkat() {
214 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT;
215 | }
216 |
217 | /**
218 | * @return true when the caller API version is less than Lollipop 21
219 | */
220 | public static boolean deprecatedAtLollipop() {
221 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP;
222 | }
223 |
224 | /**
225 | * @return true when the caller API version is less than Lollipop MR1 22
226 | */
227 | public static boolean deprecatedAtLollipopMR1() {
228 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1;
229 | }
230 |
231 | /**
232 | * @return true when the caller API version is less than Marshmallow 23
233 | */
234 | public static boolean deprecatedAtMarshmallow() {
235 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.M;
236 | }
237 | }
238 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/etc/IntArrayUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.etc;
2 |
3 | /**
4 | * IntArrayUtil helps to manage IntArray conveniently.
5 | *
6 | * @author Leonardo Taehwan Kim
7 | */
8 | public class IntArrayUtil {
9 |
10 | public static boolean contains(int[] array, int value) {
11 | if (array == null)
12 | return false;
13 |
14 | for (int i : array)
15 | if (i == value)
16 | return true;
17 | return false;
18 | }
19 |
20 | public static int[] add(int[] array, int value) {
21 | if (array == null)
22 | return new int[]{value};
23 |
24 | int[] newArray = new int[array.length + 1];
25 | System.arraycopy(array, 0, newArray, 0, array.length);
26 | newArray[array.length] = value;
27 | return newArray;
28 | }
29 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/etc/PackageUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.etc;
2 |
3 | import android.content.ActivityNotFoundException;
4 | import android.content.Intent;
5 | import android.content.pm.PackageManager;
6 | import android.net.Uri;
7 |
8 | import com.thefinestartist.Base;
9 |
10 | /**
11 | * PackageUtil helps to handle methods related to package.
12 | *
13 | * @author Leonardo Taehwan Kim
14 | */
15 | public class PackageUtil {
16 |
17 | public static final String FACEBOOK = "com.facebook.katana";
18 | public static final String TWITTER = "com.twitter.android";
19 | public static final String GOOGLE_PLUS = "com.google.android.apps.plus";
20 | public static final String GMAIL = "com.google.android.gm";
21 | public static final String PINTEREST = "com.pinterest";
22 | public static final String TUMBLR = "com.tumblr";
23 | public static final String FANCY = "com.thefancy.app";
24 | public static final String FLIPBOARD = "flipboard.app";
25 | public static final String KAKAOTALK = "com.kakao.talk";
26 | public static final String KAKAOSTORY = "com.kakao.story";
27 |
28 | public static boolean isInstalled(String packageName) {
29 | PackageManager packageManager = Base.getContext().getPackageManager();
30 | try {
31 | packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
32 | return true;
33 | } catch (PackageManager.NameNotFoundException e) {
34 | return false;
35 | }
36 | }
37 |
38 | public static String getPackageName() {
39 | return Base.getContext().getPackageName();
40 | }
41 |
42 | public static void openPlayStore() {
43 | String packageName = Base.getContext().getPackageName();
44 | openPlayStore(packageName);
45 | }
46 |
47 | public static void openPlayStore(String packageName) {
48 | try {
49 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName));
50 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
51 | Base.getContext().startActivity(intent);
52 | } catch (ActivityNotFoundException exception) {
53 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + packageName));
54 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
55 | Base.getContext().startActivity(intent);
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/etc/SparseArrayUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.etc;
2 |
3 | import android.util.SparseArray;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * SparseArrayUtil helps to manage SparseArray conveniently.
10 | *
11 | * @author Leonardo Taehwan Kim
12 | */
13 | public class SparseArrayUtil {
14 |
15 | public static List asArrayList(SparseArray sparseArray) {
16 | if (sparseArray == null)
17 | return new ArrayList();
18 |
19 | ArrayList arrayList = new ArrayList(sparseArray.size());
20 | for (int i = 0; i < sparseArray.size(); i++)
21 | arrayList.add(sparseArray.valueAt(i));
22 | return arrayList;
23 | }
24 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/etc/ThreadUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.etc;
2 |
3 | import android.os.Looper;
4 |
5 | /**
6 | * ThreadUtil helps to manage thread conveniently.
7 | *
8 | * @author Leonardo Taehwan Kim
9 | */
10 | public class ThreadUtil {
11 |
12 | public static boolean isMain() {
13 | return Looper.myLooper() == Looper.getMainLooper();
14 | }
15 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/etc/TypefaceUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.etc;
2 |
3 | import android.graphics.Typeface;
4 | import android.support.annotation.NonNull;
5 | import android.support.v4.util.SimpleArrayMap;
6 | import android.widget.TextView;
7 |
8 | import com.thefinestartist.Base;
9 |
10 | /**
11 | * TypefaceUtil helps to retrieve typeface from assets folder.
12 | *
13 | * @author Leonardo Taehwan Kim
14 | */
15 | public class TypefaceUtil {
16 |
17 | private static final SimpleArrayMap cache = new SimpleArrayMap<>();
18 |
19 | public static Typeface get(@NonNull String path) {
20 | synchronized (cache) {
21 | if (cache.containsKey(path))
22 | return cache.get(path);
23 |
24 | try {
25 | Typeface typeface = Typeface.createFromAsset(Base.getContext().getAssets(), path);
26 | cache.put(path, typeface);
27 | return typeface;
28 | } catch (RuntimeException e) {
29 | return null;
30 | }
31 | }
32 | }
33 |
34 | public static void setTypeface(@NonNull String path, TextView... textViews) {
35 | if (textViews == null)
36 | return;
37 |
38 | for (TextView textView : textViews)
39 | if (textView != null)
40 | textView.setTypeface(get(path));
41 | }
42 |
43 | public static void setTypeface(@NonNull String path, boolean includeFontPadding, TextView... textViews) {
44 | if (textViews == null)
45 | return;
46 |
47 | for (TextView textView : textViews) {
48 | if (textView != null) {
49 | textView.setTypeface(get(path));
50 | textView.setIncludeFontPadding(includeFontPadding);
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/log/AndroidLogPrinter.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.log;
2 |
3 | /**
4 | * AndroidLogPrinter log message via Android system.
5 | *
6 | * @author Leonardo Taehwan Kim
7 | */
8 | public class AndroidLogPrinter extends LogPrinter {
9 | }
10 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/log/FileLogPrinter.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.log;
2 |
3 | /**
4 | * FileLogPrinter log message via file system.
5 | *
6 | * @author Leonardo Taehwan Kim
7 | */
8 | public class FileLogPrinter extends LogPrinter {
9 |
10 | @Override
11 | public void v(String tag, String message) {
12 | super.v(tag, message);
13 | }
14 |
15 | @Override
16 | public void d(String tag, String message) {
17 | super.d(tag, message);
18 | }
19 |
20 | @Override
21 | public void i(String tag, String message) {
22 | super.i(tag, message);
23 | }
24 |
25 | @Override
26 | public void w(String tag, String message) {
27 | super.w(tag, message);
28 | }
29 |
30 | @Override
31 | public void e(String tag, String message) {
32 | super.e(tag, message);
33 | }
34 |
35 | @Override
36 | public void wtf(String tag, String message) {
37 | super.wtf(tag, message);
38 | }
39 | }
40 | // TODO: Finish this file after FileUtil
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/log/L.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.log;
2 |
3 | /**
4 | * L is abbreviation class of {@link LogUtil}.
5 | *
6 | * @author Leonardo Taehwan Kim
7 | */
8 | public class L extends LogUtil {
9 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/log/LogPrinter.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.log;
2 |
3 | import android.util.Log;
4 |
5 | import com.thefinestartist.utils.etc.APILevel;
6 |
7 | /**
8 | * LogPrinter helps to print message for {@link LogHelper}.
9 | *
10 | * @author Leonardo Taehwan Kim
11 | */
12 | public abstract class LogPrinter {
13 |
14 | public void v(String tag, String message) {
15 | Log.v(tag, message);
16 | }
17 |
18 | public void d(String tag, String message) {
19 | Log.d(tag, message);
20 | }
21 |
22 | public void i(String tag, String message) {
23 | Log.i(tag, message);
24 | }
25 |
26 | public void w(String tag, String message) {
27 | Log.w(tag, message);
28 | }
29 |
30 | public void e(String tag, String message) {
31 | Log.e(tag, message);
32 | }
33 |
34 | public void wtf(String tag, String message) {
35 | if (APILevel.require(8))
36 | Log.wtf(tag, message);
37 | else
38 | Log.e(tag, message);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/log/LogUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.log;
2 |
3 | import android.support.annotation.StringRes;
4 | import android.util.Log;
5 |
6 | import com.thefinestartist.enums.LogLevel;
7 |
8 | import org.json.JSONArray;
9 | import org.json.JSONObject;
10 |
11 | /**
12 | * LogUtil helps to manage application-wide {@link Log} conveniently.
13 | *
14 | * @author Leonardo Taehwan Kim
15 | */
16 | public class LogUtil {
17 |
18 | // Defaults
19 | private static Settings defaultSettings = new Settings(LogUtil.class.getSimpleName());
20 |
21 | // Singleton
22 | private static volatile LogHelper logHelper = new LogHelper()
23 | .tag(defaultSettings.getTag())
24 | .showThreadInfo(defaultSettings.getShowThreadInfo())
25 | .stackTraceCount(defaultSettings.getStackTraceCount())
26 | .logLevel(defaultSettings.getLogLevel())
27 | .showDivider(defaultSettings.getShowDivider());
28 |
29 | public static Settings getDefaultSettings() {
30 | return defaultSettings;
31 | }
32 |
33 | public static LogHelper getInstance() {
34 | return logHelper;
35 | }
36 |
37 | // Builder
38 | public static LogHelper tag(String tag) {
39 | return logHelper.tag(tag);
40 | }
41 |
42 | public static LogHelper tag(@StringRes int tagRes) {
43 | return logHelper.tag(tagRes);
44 | }
45 |
46 | public static LogHelper tag(Class clazz) {
47 | return logHelper.tag(clazz);
48 | }
49 |
50 | public static LogHelper showThreadInfo(boolean showThreadInfo) {
51 | return logHelper.showThreadInfo(showThreadInfo);
52 | }
53 |
54 | public static LogHelper stackTraceCount(int stackTraceCount) {
55 | return logHelper.stackTraceCount(stackTraceCount);
56 | }
57 |
58 | public static LogHelper logLevel(LogLevel logLevel) {
59 | return logHelper.logLevel(logLevel);
60 | }
61 |
62 | public static LogHelper showDivider(boolean showDivider) {
63 | return logHelper.showDivider(showDivider);
64 | }
65 |
66 | public LogHelper logPrinter(LogPrinter logPrinter) {
67 | return logHelper.logPrinter(logPrinter);
68 | }
69 |
70 | // Logging Verbose
71 | public static void v(byte message) {
72 | logHelper.v(message);
73 | }
74 |
75 | public static void v(char message) {
76 | logHelper.v(message);
77 | }
78 |
79 | public static void v(short message) {
80 | logHelper.v(message);
81 | }
82 |
83 | public static void v(int message) {
84 | logHelper.v(message);
85 | }
86 |
87 | public static void v(long message) {
88 | logHelper.v(message);
89 | }
90 |
91 | public static void v(float message) {
92 | logHelper.v(message);
93 | }
94 |
95 | public static void v(double message) {
96 | logHelper.v(message);
97 | }
98 |
99 | public static void v(boolean message) {
100 | logHelper.v(message);
101 | }
102 |
103 | public static void v(String message) {
104 | logHelper.v(message);
105 | }
106 |
107 | public static void v(JSONObject message) {
108 | logHelper.v(message);
109 | }
110 |
111 | public static void v(JSONArray message) {
112 | logHelper.v(message);
113 | }
114 |
115 | public static void v(Exception message) {
116 | logHelper.v(message);
117 | }
118 |
119 | public static void v(Object message) {
120 | logHelper.v(message);
121 | }
122 |
123 | // Logging Debug
124 | public static void d(byte message) {
125 | logHelper.d(message);
126 | }
127 |
128 | public static void d(char message) {
129 | logHelper.d(message);
130 | }
131 |
132 | public static void d(short message) {
133 | logHelper.d(message);
134 | }
135 |
136 | public static void d(int message) {
137 | logHelper.d(message);
138 | }
139 |
140 | public static void d(long message) {
141 | logHelper.d(message);
142 | }
143 |
144 | public static void d(float message) {
145 | logHelper.d(message);
146 | }
147 |
148 | public static void d(double message) {
149 | logHelper.d(message);
150 | }
151 |
152 | public static void d(boolean message) {
153 | logHelper.d(message);
154 | }
155 |
156 | public static void d(String message) {
157 | logHelper.d(message);
158 | }
159 |
160 | public static void d(JSONObject message) {
161 | logHelper.d(message);
162 | }
163 |
164 | public static void d(JSONArray message) {
165 | logHelper.d(message);
166 | }
167 |
168 | public static void d(Exception message) {
169 | logHelper.d(message);
170 | }
171 |
172 | public static void d(Object message) {
173 | logHelper.d(message);
174 | }
175 |
176 | // Logging Information
177 | public static void i(byte message) {
178 | logHelper.i(message);
179 | }
180 |
181 | public static void i(char message) {
182 | logHelper.i(message);
183 | }
184 |
185 | public static void i(short message) {
186 | logHelper.i(message);
187 | }
188 |
189 | public static void i(int message) {
190 | logHelper.i(message);
191 | }
192 |
193 | public static void i(long message) {
194 | logHelper.i(message);
195 | }
196 |
197 | public static void i(float message) {
198 | logHelper.i(message);
199 | }
200 |
201 | public static void i(double message) {
202 | logHelper.i(message);
203 | }
204 |
205 | public static void i(boolean message) {
206 | logHelper.i(message);
207 | }
208 |
209 | public static void i(String message) {
210 | logHelper.i(message);
211 | }
212 |
213 | public static void i(JSONObject message) {
214 | logHelper.i(message);
215 | }
216 |
217 | public static void i(JSONArray message) {
218 | logHelper.i(message);
219 | }
220 |
221 | public static void i(Exception message) {
222 | logHelper.i(message);
223 | }
224 |
225 | public static void i(Object message) {
226 | logHelper.i(message);
227 | }
228 |
229 | // Logging Warning
230 | public static void w(byte message) {
231 | logHelper.w(message);
232 | }
233 |
234 | public static void w(char message) {
235 | logHelper.w(message);
236 | }
237 |
238 | public static void w(short message) {
239 | logHelper.w(message);
240 | }
241 |
242 | public static void w(int message) {
243 | logHelper.w(message);
244 | }
245 |
246 | public static void w(long message) {
247 | logHelper.w(message);
248 | }
249 |
250 | public static void w(float message) {
251 | logHelper.w(message);
252 | }
253 |
254 | public static void w(double message) {
255 | logHelper.w(message);
256 | }
257 |
258 | public static void w(boolean message) {
259 | logHelper.w(message);
260 | }
261 |
262 | public static void w(String message) {
263 | logHelper.w(message);
264 | }
265 |
266 | public static void w(JSONObject message) {
267 | logHelper.w(message);
268 | }
269 |
270 | public static void w(JSONArray message) {
271 | logHelper.w(message);
272 | }
273 |
274 | public static void w(Exception message) {
275 | logHelper.w(message);
276 | }
277 |
278 | public static void w(Object message) {
279 | logHelper.w(message);
280 | }
281 |
282 | // Logging Error
283 | public static void e(byte message) {
284 | logHelper.e(message);
285 | }
286 |
287 | public static void e(char message) {
288 | logHelper.e(message);
289 | }
290 |
291 | public static void e(short message) {
292 | logHelper.e(message);
293 | }
294 |
295 | public static void e(int message) {
296 | logHelper.e(message);
297 | }
298 |
299 | public static void e(long message) {
300 | logHelper.e(message);
301 | }
302 |
303 | public static void e(float message) {
304 | logHelper.e(message);
305 | }
306 |
307 | public static void e(double message) {
308 | logHelper.e(message);
309 | }
310 |
311 | public static void e(boolean message) {
312 | logHelper.e(message);
313 | }
314 |
315 | public static void e(String message) {
316 | logHelper.e(message);
317 | }
318 |
319 | public static void e(JSONObject message) {
320 | logHelper.e(message);
321 | }
322 |
323 | public static void e(JSONArray message) {
324 | logHelper.e(message);
325 | }
326 |
327 | public static void e(Exception message) {
328 | logHelper.e(message);
329 | }
330 |
331 | public static void e(Object message) {
332 | logHelper.e(message);
333 | }
334 |
335 | // Logging Assert
336 | public static void wtf(byte message) {
337 | logHelper.wtf(message);
338 | }
339 |
340 | public static void wtf(char message) {
341 | logHelper.wtf(message);
342 | }
343 |
344 | public static void wtf(short message) {
345 | logHelper.wtf(message);
346 | }
347 |
348 | public static void wtf(int message) {
349 | logHelper.wtf(message);
350 | }
351 |
352 | public static void wtf(long message) {
353 | logHelper.wtf(message);
354 | }
355 |
356 | public static void wtf(float message) {
357 | logHelper.wtf(message);
358 | }
359 |
360 | public static void wtf(double message) {
361 | logHelper.wtf(message);
362 | }
363 |
364 | public static void wtf(boolean message) {
365 | logHelper.wtf(message);
366 | }
367 |
368 | public static void wtf(String message) {
369 | logHelper.wtf(message);
370 | }
371 |
372 | public static void wtf(JSONObject message) {
373 | logHelper.wtf(message);
374 | }
375 |
376 | public static void wtf(JSONArray message) {
377 | logHelper.wtf(message);
378 | }
379 |
380 | public static void wtf(Exception message) {
381 | logHelper.wtf(message);
382 | }
383 |
384 | public static void wtf(Object message) {
385 | logHelper.wtf(message);
386 | }
387 |
388 | // Logging JsonString
389 | public static void json(String jsonString) {
390 | json(LogLevel.DEBUG, jsonString);
391 | }
392 |
393 | public static void json(LogLevel logLevel, String jsonString) {
394 | logHelper.json(logLevel, jsonString);
395 | }
396 |
397 | // Logging XmlString
398 | public static void xml(String xmlString) {
399 | xml(LogLevel.DEBUG, xmlString);
400 | }
401 |
402 | public static void xml(LogLevel logLevel, String jsonString) {
403 | logHelper.xml(logLevel, jsonString);
404 | }
405 | }
406 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/log/Settings.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.log;
2 |
3 | import android.support.annotation.StringRes;
4 |
5 | import com.thefinestartist.enums.LogLevel;
6 | import com.thefinestartist.utils.content.ResourcesUtil;
7 |
8 | /**
9 | * Settings for {@link LogHelper}.
10 | *
11 | * @author Leonardo Taehwan Kim
12 | */
13 | public class Settings {
14 |
15 | private String tag = Settings.class.getSimpleName();
16 | private boolean showThreadInfo = false;
17 | private int stackTraceCount = 0;
18 | private LogLevel logLevel = LogLevel.FULL;
19 | private boolean showDivider = false;
20 | private LogPrinter logPrinter = new AndroidLogPrinter();
21 |
22 | public Settings() {
23 | }
24 |
25 | public Settings(String tag) {
26 | this.tag = tag;
27 | }
28 |
29 | public Settings(@StringRes int tagRes) {
30 | this.tag = ResourcesUtil.getString(tagRes);
31 | }
32 |
33 | public Settings(Class clazz) {
34 | this.tag = clazz.getSimpleName();
35 | }
36 |
37 | public String getTag() {
38 | return tag;
39 | }
40 |
41 | public Settings setTag(String tag) {
42 | this.tag = tag;
43 | if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault();
44 | return this;
45 | }
46 |
47 | public Settings setTag(@StringRes int tagRes) {
48 | this.tag = ResourcesUtil.getString(tagRes);
49 | if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault();
50 | return this;
51 | }
52 |
53 | public Settings setTag(Class clazz) {
54 | this.tag = clazz.getSimpleName();
55 | if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault();
56 | return this;
57 | }
58 |
59 | public boolean getShowThreadInfo() {
60 | return showThreadInfo;
61 | }
62 |
63 | public Settings setShowThreadInfo(boolean showThreadInfo) {
64 | this.showThreadInfo = showThreadInfo;
65 | if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault();
66 | return this;
67 | }
68 |
69 | public int getStackTraceCount() {
70 | return stackTraceCount;
71 | }
72 |
73 | public Settings setStackTraceCount(int stackTraceCount) {
74 | this.stackTraceCount = stackTraceCount;
75 | if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault();
76 | return this;
77 | }
78 |
79 | public LogLevel getLogLevel() {
80 | return logLevel;
81 | }
82 |
83 | public Settings setLogLevel(LogLevel logLevel) {
84 | this.logLevel = logLevel;
85 | if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault();
86 | return this;
87 | }
88 |
89 | public boolean getShowDivider() {
90 | return showDivider;
91 | }
92 |
93 | public Settings setShowDivider(boolean showDivider) {
94 | this.showDivider = showDivider;
95 | if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault();
96 | return this;
97 | }
98 |
99 | public LogPrinter getLogPrinter() {
100 | return logPrinter;
101 | }
102 |
103 | public Settings setLogPrinter(LogPrinter logPrinter) {
104 | this.logPrinter = logPrinter;
105 | if (this == LogUtil.getDefaultSettings()) LogUtil.getInstance().setToDefault();
106 | return this;
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/preferences/Pref.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.preferences;
2 |
3 | /**
4 | * Pref is abbreviation class of {@link PreferencesUtil}.
5 | *
6 | * @author Robin Gustafsson
7 | */
8 | public class Pref extends PreferencesUtil {
9 | }
10 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/preferences/PreferencesUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.preferences;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.os.Build;
7 | import android.util.Base64;
8 |
9 | import com.thefinestartist.Base;
10 | import com.thefinestartist.utils.etc.APILevel;
11 | import com.thefinestartist.utils.log.LogHelper;
12 |
13 | import java.io.ByteArrayInputStream;
14 | import java.io.ByteArrayOutputStream;
15 | import java.io.IOException;
16 | import java.io.ObjectInputStream;
17 | import java.io.ObjectOutputStream;
18 | import java.io.Serializable;
19 | import java.util.Set;
20 |
21 | /**
22 | * PreferencesUtil helps to manage application-wide {@link SharedPreferences} conveniently.
23 | *
24 | * @author Robin Gustafsson
25 | */
26 | public class PreferencesUtil {
27 |
28 | private static final LogHelper LogHelper = new LogHelper(PreferencesUtil.class);
29 | private static String defaultName = PreferencesUtil.class.getCanonicalName();
30 |
31 | private static SharedPreferences getPreferences(String name) {
32 | return Base.getContext().getSharedPreferences(name, Context.MODE_PRIVATE);
33 | }
34 |
35 |
36 | public static String getDefaultName() {
37 | return defaultName;
38 | }
39 |
40 | public static void setDefaultName(String name) {
41 | defaultName = name;
42 | }
43 |
44 |
45 | public static boolean get(String key, boolean defValue) {
46 | return get(defaultName, key, defValue);
47 | }
48 |
49 | public static int get(String key, int defValue) {
50 | return get(defaultName, key, defValue);
51 | }
52 |
53 | public static float get(String key, float defValue) {
54 | return get(defaultName, key, defValue);
55 | }
56 |
57 | public static long get(String key, long defValue) {
58 | return get(defaultName, key, defValue);
59 | }
60 |
61 | public static String get(String key, String defValue) {
62 | return get(defaultName, key, defValue);
63 | }
64 |
65 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
66 | public static Set get(String key, Set defValue) {
67 | return get(defaultName, key, defValue);
68 | }
69 |
70 | @TargetApi(Build.VERSION_CODES.FROYO)
71 | public static C get(String key, C defValue) {
72 | return get(defaultName, key, defValue);
73 | }
74 |
75 | public static boolean get(String name, String key, boolean defValue) {
76 | return getPreferences(name).getBoolean(key, defValue);
77 | }
78 |
79 | public static int get(String name, String key, int defValue) {
80 | return getPreferences(name).getInt(key, defValue);
81 | }
82 |
83 | public static float get(String name, String key, float defValue) {
84 | return getPreferences(name).getFloat(key, defValue);
85 | }
86 |
87 | public static long get(String name, String key, long defValue) {
88 | return getPreferences(name).getLong(key, defValue);
89 | }
90 |
91 | public static String get(String name, String key, String defValue) {
92 | return getPreferences(name).getString(key, defValue);
93 | }
94 |
95 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
96 | public static Set get(String name, String key, Set defValue) {
97 | return getPreferences(name).getStringSet(key, defValue);
98 | }
99 |
100 | @TargetApi(Build.VERSION_CODES.FROYO)
101 | public static C get(String name, String key, C defValue) {
102 | ByteArrayInputStream bais = null;
103 | ObjectInputStream ois = null;
104 | C result = defValue;
105 |
106 | String value = getPreferences(name).getString(key, null);
107 | if (value != null) {
108 | try {
109 | byte[] decoded = Base64.decode(value.getBytes(), Base64.DEFAULT);
110 | bais = new ByteArrayInputStream(decoded);
111 | ois = new ObjectInputStream(bais);
112 | result = (C) ois.readObject();
113 |
114 | } catch (Exception e) {
115 | LogHelper.e(e);
116 | } finally {
117 | if (ois != null) {
118 | try {
119 | ois.close();
120 | } catch (IOException e) {
121 | LogHelper.e(e);
122 | }
123 | }
124 | if (bais != null) {
125 | try {
126 | bais.close();
127 | } catch (IOException e) {
128 | LogHelper.e(e);
129 | }
130 | }
131 | }
132 | }
133 |
134 | return result;
135 | }
136 |
137 |
138 | public static void put(String key, boolean value) {
139 | put(defaultName, key, value);
140 | }
141 |
142 | public static void put(String key, int value) {
143 | put(defaultName, key, value);
144 | }
145 |
146 | public static void put(String key, float value) {
147 | put(defaultName, key, value);
148 | }
149 |
150 | public static void put(String key, long value) {
151 | put(defaultName, key, value);
152 | }
153 |
154 | public static void put(String key, String value) {
155 | put(defaultName, key, value);
156 | }
157 |
158 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
159 | public static void put(String key, Set value) {
160 | put(defaultName, key, value);
161 | }
162 |
163 | @TargetApi(Build.VERSION_CODES.FROYO)
164 | public static void put(String key, C value) {
165 | put(defaultName, key, value);
166 | }
167 |
168 | public static void put(String name, String key, boolean value) {
169 | if (APILevel.require(9))
170 | getPreferences(name).edit().putBoolean(key, value).apply();
171 | else
172 | getPreferences(name).edit().putBoolean(key, value).commit();
173 | }
174 |
175 | public static void put(String name, String key, int value) {
176 | if (APILevel.require(9))
177 | getPreferences(name).edit().putInt(key, value).apply();
178 | else
179 | getPreferences(name).edit().putInt(key, value).commit();
180 | }
181 |
182 | public static void put(String name, String key, float value) {
183 | if (APILevel.require(9))
184 | getPreferences(name).edit().putFloat(key, value).apply();
185 | else
186 | getPreferences(name).edit().putFloat(key, value).commit();
187 | }
188 |
189 | public static void put(String name, String key, long value) {
190 | if (APILevel.require(9))
191 | getPreferences(name).edit().putLong(key, value).apply();
192 | else
193 | getPreferences(name).edit().putLong(key, value).commit();
194 | }
195 |
196 | public static void put(String name, String key, String value) {
197 | if (APILevel.require(9))
198 | getPreferences(name).edit().putString(key, value).apply();
199 | else
200 | getPreferences(name).edit().putString(key, value).commit();
201 | }
202 |
203 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
204 | public static void put(String name, String key, Set value) {
205 | if (APILevel.require(9))
206 | getPreferences(name).edit().putStringSet(key, value).apply();
207 | else
208 | getPreferences(name).edit().putStringSet(key, value).commit();
209 | }
210 |
211 | @TargetApi(Build.VERSION_CODES.FROYO)
212 | public static void put(String name, String key, C value) {
213 | ByteArrayOutputStream baos = null;
214 | ObjectOutputStream oos = null;
215 |
216 | try {
217 | baos = new ByteArrayOutputStream();
218 | oos = new ObjectOutputStream(baos);
219 | oos.writeObject(value);
220 | byte[] encoded = Base64.encode(baos.toByteArray(), Base64.DEFAULT);
221 | if (APILevel.require(9))
222 | getPreferences(name).edit().putString(key, new String(encoded)).apply();
223 | else
224 | getPreferences(name).edit().putString(key, new String(encoded)).commit();
225 |
226 | } catch (IOException e) {
227 | LogHelper.e(e);
228 | throw new RuntimeException(e);
229 |
230 | } finally {
231 | if (oos != null) {
232 | try {
233 | oos.close();
234 | } catch (IOException e) {
235 | LogHelper.e(e);
236 | }
237 | }
238 | if (baos != null) {
239 | try {
240 | baos.close();
241 | } catch (IOException e) {
242 | LogHelper.e(e);
243 | }
244 | }
245 | }
246 | }
247 |
248 |
249 | public static void remove(String key) {
250 | remove(defaultName, key);
251 | }
252 |
253 | public static void remove(String name, String key) {
254 | if (APILevel.require(9))
255 | getPreferences(name).edit().remove(key).apply();
256 | else
257 | getPreferences(name).edit().remove(key).commit();
258 | }
259 |
260 |
261 | public static void clear() {
262 | clear(defaultName);
263 | }
264 |
265 | public static void clear(String name) {
266 | if (APILevel.require(9))
267 | getPreferences(name).edit().clear().apply();
268 | else
269 | getPreferences(name).edit().clear().commit();
270 | }
271 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/service/ClipboardManagerUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.service;
2 |
3 | import android.content.ClipData;
4 | import android.content.ClipDescription;
5 | import android.content.ClipboardManager;
6 |
7 | import com.thefinestartist.utils.etc.APILevel;
8 |
9 | /**
10 | * ClipboardManagerUtil helps to manage {@link ClipboardManager} conveniently.
11 | *
12 | * @author Leonardo Taehwan Kim
13 | */
14 | public class ClipboardManagerUtil {
15 |
16 | public static void setText(CharSequence text) {
17 | android.text.ClipboardManager clipboardManager = ServiceUtil.getClipboardManager();
18 | if (APILevel.require(11)) {
19 | ClipboardManager cm = (ClipboardManager) clipboardManager;
20 | ClipData clip = ClipData.newPlainText("ClipboardManagerUtil", text);
21 | cm.setPrimaryClip(clip);
22 | } else {
23 | clipboardManager.setText(text);
24 | }
25 | }
26 |
27 | public static boolean hasText() {
28 | android.text.ClipboardManager clipboardManager = ServiceUtil.getClipboardManager();
29 | if (APILevel.require(11)) {
30 | ClipboardManager cm = (ClipboardManager) clipboardManager;
31 | ClipDescription description = cm.getPrimaryClipDescription();
32 | ClipData clipData = cm.getPrimaryClip();
33 | return clipData != null
34 | && description != null
35 | && (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN));
36 | } else {
37 | return clipboardManager.hasText();
38 | }
39 | }
40 |
41 | public static CharSequence getText() {
42 | android.text.ClipboardManager clipboardManager = ServiceUtil.getClipboardManager();
43 | if (APILevel.require(11)) {
44 | ClipboardManager cm = (ClipboardManager) clipboardManager;
45 | ClipDescription description = cm.getPrimaryClipDescription();
46 | ClipData clipData = cm.getPrimaryClip();
47 | if (clipData != null
48 | && description != null
49 | && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN))
50 | return clipData.getItemAt(0).getText();
51 | else
52 | return null;
53 | } else {
54 | return clipboardManager.getText();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/service/VibratorUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.service;
2 |
3 | import android.annotation.TargetApi;
4 | import android.media.AudioAttributes;
5 | import android.os.Vibrator;
6 |
7 | /**
8 | * VibratorUtil helps to manage {@link Vibrator} conveniently.
9 | *
10 | * @author Leonardo Taehwan Kim
11 | */
12 | public class VibratorUtil {
13 |
14 | @TargetApi(11)
15 | public static boolean hasVibrator() {
16 | return ServiceUtil.getVibrator().hasVibrator();
17 | }
18 |
19 | public static void vibrate() {
20 | vibrate(200);
21 | }
22 |
23 | public static void vibrate(long milliseconds) {
24 | vibrate(new long[]{milliseconds});
25 | }
26 |
27 | public static void vibrate(long[] pattern) {
28 | vibrate(pattern, -1);
29 | }
30 |
31 | public static void vibrate(long[] pattern, int repeat) {
32 | ServiceUtil.getVibrator().vibrate(pattern, repeat);
33 | }
34 |
35 | @TargetApi(21)
36 | public static void vibrate(long milliseconds, AudioAttributes attributes) {
37 | vibrate(new long[]{milliseconds}, -1, attributes);
38 | }
39 |
40 | @TargetApi(21)
41 | public static void vibrate(long[] pattern, int repeat, AudioAttributes attributes) {
42 | ServiceUtil.getVibrator().vibrate(pattern, repeat, attributes);
43 | }
44 |
45 | public static void cancel() {
46 | ServiceUtil.getVibrator().cancel();
47 | }
48 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/service/WindowManagerUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.service;
2 |
3 | import android.view.Display;
4 | import android.view.View;
5 | import android.view.WindowManager;
6 |
7 | /**
8 | * WindowManagerUtil helps to manage {@link WindowManager} conveniently.
9 | *
10 | * @author Leonardo Taehwan Kim
11 | */
12 | public class WindowManagerUtil {
13 |
14 | public static Display getDefaultDisplay() {
15 | return ServiceUtil.getWindowManager().getDefaultDisplay();
16 | }
17 |
18 | public static void removeViewImmediate(View view) {
19 | ServiceUtil.getWindowManager().removeViewImmediate(view);
20 | }
21 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/ui/DisplayUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.ui;
2 |
3 | import android.graphics.Point;
4 | import android.util.TypedValue;
5 | import android.view.Display;
6 |
7 | import com.thefinestartist.enums.Rotation;
8 | import com.thefinestartist.utils.content.ResourcesUtil;
9 | import com.thefinestartist.utils.content.ThemeUtil;
10 | import com.thefinestartist.utils.content.TypedValueUtil;
11 | import com.thefinestartist.utils.etc.APILevel;
12 | import com.thefinestartist.utils.service.WindowManagerUtil;
13 |
14 | /**
15 | * DisplayUtil helps to calculate screen size conveniently.
16 | *
17 | * @author Leonardo Taehwan Kim
18 | */
19 | public class DisplayUtil {
20 |
21 | public static int getWidth() {
22 | Display display = WindowManagerUtil.getDefaultDisplay();
23 | if (APILevel.require(13)) {
24 | Point size = new Point();
25 | display.getSize(size);
26 | return size.x;
27 | } else {
28 | return display.getWidth();
29 | }
30 | }
31 |
32 | public static int getHeight() {
33 | Display display = WindowManagerUtil.getDefaultDisplay();
34 | if (APILevel.require(13)) {
35 | Point size = new Point();
36 | display.getSize(size);
37 | return size.y;
38 | } else {
39 | return display.getHeight();
40 | }
41 | }
42 |
43 | public static Rotation getRotation() {
44 | if (APILevel.require(8))
45 | return Rotation.fromValue(WindowManagerUtil.getDefaultDisplay().getRotation());
46 | else
47 | return Rotation.fromValue(WindowManagerUtil.getDefaultDisplay().getOrientation());
48 | }
49 |
50 | public static boolean isPortrait() {
51 | return getHeight() >= getWidth();
52 | }
53 |
54 | public static boolean isLandscape() {
55 | return getHeight() < getWidth();
56 | }
57 |
58 | public static int getStatusBarHeight() {
59 | int resourceId = ResourcesUtil.getIdentifier("status_bar_height", "dimen", "android");
60 | return resourceId > 0 ?
61 | ResourcesUtil.getDimensionPixelSize(resourceId) :
62 | 0;
63 | }
64 |
65 | public static int getToolbarHeight() {
66 | return getActionBarHeight();
67 | }
68 |
69 | public static int getActionBarHeight() {
70 | TypedValue tv = new TypedValue();
71 | return ThemeUtil.resolveAttribute(android.R.attr.actionBarSize, tv, true) ?
72 | TypedValueUtil.complexToDimensionPixelSize(tv.data) :
73 | 0;
74 | }
75 |
76 | public static int getNavigationBarHeight() {
77 | int resourceId = ResourcesUtil.getIdentifier("navigation_bar_height", "dimen", "android");
78 | return resourceId > 0 ?
79 | ResourcesUtil.getDimensionPixelSize(resourceId) :
80 | 0;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/ui/Keyboard.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.ui;
2 |
3 | /**
4 | * Keyboard is abbreviation class of {@link KeyboardUtil}.
5 | *
6 | * @author Leonardo Taehwan Kim
7 | */
8 | public class Keyboard extends KeyboardUtil {
9 | }
10 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/ui/KeyboardUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.ui;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.app.Dialog;
6 | import android.content.Context;
7 | import android.os.Build;
8 | import android.os.Bundle;
9 | import android.os.Looper;
10 | import android.support.v4.app.Fragment;
11 | import android.view.LayoutInflater;
12 | import android.view.MenuItem;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.view.inputmethod.InputMethodManager;
16 |
17 | import com.thefinestartist.Base;
18 | import com.thefinestartist.converters.UnitConverter;
19 | import com.thefinestartist.utils.etc.ThreadUtil;
20 | import com.thefinestartist.utils.service.ServiceUtil;
21 |
22 | /**
23 | * KeyboardUtil helps to show and hide keyboard conveniently.
24 | *
25 | * @author Leonardo Taehwan Kim
26 | */
27 | public class KeyboardUtil {
28 |
29 | public static int height = 0;
30 | public static final String KEYBOARD_UTIL_PREF = "KEYBOARD_UTIL_PREF";
31 | public static final String KEYBOARD_HEIGHT = "KEYBOARD_HEIGHT";
32 | public static final int DEFAULT_KEYBOARD_HEIGHT = 200;
33 |
34 | /**
35 | * Helps to show keyboard in {@link Activity#onCreate(Bundle)}, {@link Activity#onStart()},
36 | * {@link Activity#onResume()},
37 | * {@link MenuItem.OnActionExpandListener#onMenuItemActionExpand(MenuItem)},
38 | * {@link Fragment#onCreateView(LayoutInflater, ViewGroup, Bundle)} and etc
39 | * This method guarantee to show keyboard every time.
40 | */
41 | public static void show(final View view) {
42 | if (view == null)
43 | return;
44 |
45 | view.postDelayed(new Runnable() {
46 | @Override
47 | public void run() {
48 | showInMainThread(view);
49 | }
50 | }, 200);
51 | }
52 |
53 | /**
54 | * Please note that this method does not guarantee to show keyboard every time. To guarantee
55 | * to show keyboard, please use {@link #show(View)} instead. It doesn't have any delay, use
56 | * this method when it is able to show keyboard immediately. EX) when user click a button to
57 | * show keyboard
58 | */
59 | public static void showImmediately(final View view) {
60 | if (view == null)
61 | return;
62 |
63 | if (ThreadUtil.isMain()) {
64 | showInMainThread(view);
65 | } else {
66 | view.post(new Runnable() {
67 | @Override
68 | public void run() {
69 | showInMainThread(view);
70 | }
71 | });
72 | }
73 | }
74 |
75 | private static void showInMainThread(final View view) {
76 | if (view == null)
77 | return;
78 |
79 | view.requestFocus();
80 | ServiceUtil.getInputMethodManager().showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
81 | }
82 |
83 | public static void hide(Fragment fragment) {
84 | if (fragment == null || fragment.getActivity() == null)
85 | return;
86 |
87 | hide(fragment.getActivity());
88 | }
89 |
90 | public static void hide(Fragment fragment, boolean clearFocus) {
91 | if (fragment == null || fragment.getActivity() == null)
92 | return;
93 |
94 | hide(fragment.getActivity());
95 | }
96 |
97 | public static void hide(Activity activity) {
98 | hide(activity, true);
99 | }
100 |
101 | public static void hide(Activity activity, boolean clearFocus) {
102 | if (activity == null)
103 | return;
104 |
105 | hide(activity.getCurrentFocus(), clearFocus);
106 | }
107 |
108 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
109 | public static void hide(android.app.Fragment fragment) {
110 | hide(fragment, true);
111 | }
112 |
113 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
114 | public static void hide(android.app.Fragment fragment, boolean clearFocus) {
115 | if (fragment == null || fragment.getActivity() == null)
116 | return;
117 |
118 | hide(fragment.getActivity(), clearFocus);
119 | }
120 |
121 | public static void hide(Dialog dialog) {
122 | hide(dialog, true);
123 | }
124 |
125 | public static void hide(Dialog dialog, boolean clearFocus) {
126 | if (dialog == null)
127 | return;
128 |
129 | hide(dialog.getCurrentFocus(), clearFocus);
130 | }
131 |
132 | public static void hide(View view) {
133 | hide(view, true);
134 | }
135 |
136 | public static void hide(View view, boolean clearFocus) {
137 | if (view == null)
138 | return;
139 |
140 | if (clearFocus) {
141 | view.clearFocus();
142 | }
143 |
144 | ServiceUtil.getInputMethodManager().hideSoftInputFromWindow(view.getWindowToken(), 0);
145 | }
146 |
147 | public static int getHeight() {
148 | if (height <= 0)
149 | height = Base.getContext().getSharedPreferences(KEYBOARD_UTIL_PREF, Context.MODE_PRIVATE).getInt(KEYBOARD_HEIGHT, UnitConverter.dpToPx(DEFAULT_KEYBOARD_HEIGHT));
150 |
151 | return height;
152 | }
153 |
154 | public static void setHeight(int height) {
155 | KeyboardUtil.height = height;
156 | Base.getContext().getSharedPreferences(KEYBOARD_UTIL_PREF, Context.MODE_PRIVATE).edit().putInt(KEYBOARD_HEIGHT, height).apply();
157 | }
158 |
159 | // coordinatorLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
160 | // @Override
161 | // public void onGlobalLayout() {
162 | // Rect r = new Rect();
163 | // coordinatorLayout.getWindowVisibleDisplayFrame(r);
164 | // if (ResourcesUtil.navigationBarHeight == -1) {
165 | // ResourcesUtil.navigationBarHeight = coordinatorLayout.getRootView().getHeight() - r.height() - ResourcesUtil.statusBarHeight;
166 | // }
167 | // int usableHeight = coordinatorLayout.getRootView().getHeight() - ResourcesUtil.statusBarHeight - ResourcesUtil.navigationBarHeight;
168 | // int keyboardHeight = usableHeight - r.height();
169 | // if (isKeyboardOpened) {
170 | // if (keyboardHeight < 100) {
171 | // onKeyboardChanged(usableHeight, keyboardHeight, false);
172 | // isKeyboardOpened = false;
173 | // }
174 | // } else {
175 | // if (keyboardHeight > 100) {
176 | // onKeyboardChanged(usableHeight, keyboardHeight, true);
177 | // isKeyboardOpened = true;
178 | // }
179 | // }
180 | // }
181 | // });
182 | }
183 | //TODO: Support keyboard show and hide listener
184 | //TODO: Keyboard height
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/utils/ui/ViewUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils.ui;
2 |
3 | import android.graphics.drawable.Drawable;
4 | import android.os.Build;
5 | import android.support.annotation.DrawableRes;
6 | import android.view.View;
7 |
8 | import com.thefinestartist.Base;
9 | import com.thefinestartist.utils.etc.APILevel;
10 |
11 | /**
12 | * ViewUtil helps to set background drawable conveniently.
13 | *
14 | * @author Leonardo Taehwan Kim
15 | */
16 | public class ViewUtil {
17 |
18 | public static void setBackground(View view, Drawable drawable) {
19 | if (view == null)
20 | return;
21 |
22 | if (APILevel.require(16)) {
23 | view.setBackground(drawable);
24 | } else {
25 | view.setBackgroundDrawable(drawable);
26 | }
27 | }
28 |
29 | public static void setBackground(View view, @DrawableRes int drawableRes) {
30 | if (view == null)
31 | return;
32 |
33 | if (APILevel.require(16)) {
34 | view.setBackground(Base.getResources().getDrawable(drawableRes));
35 | } else {
36 | view.setBackgroundDrawable(Base.getResources().getDrawable(drawableRes));
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/AgeUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import android.text.format.DateFormat;
4 |
5 | import java.util.Calendar;
6 | import java.util.Date;
7 |
8 | /**
9 | * Created by TheFinestArtist
10 | */
11 | public class AgeUtil {
12 |
13 | // public static String getFromBirthDay(Date date) {
14 | // if (date == null)
15 | // return "?";
16 | //
17 | // int year = Integer.parseInt((String) DateFormat.format("yyyy", date));
18 | // int month = Integer.parseInt((String) DateFormat.format("MM", date));
19 | // int day = Integer.parseInt((String) DateFormat.format("dd", date));
20 | //
21 | // Calendar birthday = Calendar.getInstance();
22 | // birthday.set(year, month - 1, day);
23 | // Calendar today = Calendar.getInstance();
24 | //
25 | //
26 | // int age = today.get(Calendar.YEAR) - birthday.get(Calendar.YEAR);
27 | //
28 | // if (today.get(Calendar.DAY_OF_YEAR) < birthday.get(Calendar.DAY_OF_YEAR)) {
29 | // age--;
30 | // }
31 | //
32 | // return String.format("%d", age);
33 | // }
34 | }
35 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/AudioManagerUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import android.media.AudioManager;
4 |
5 | /**
6 | * Created by TheFinestArtist on 2/18/16.
7 | */
8 | public class AudioManagerUtil {
9 |
10 | // public static void getMode() {
11 | // AudioManager am = ServiceUtil.getAudioManager();
12 | // switch (am.getRingerMode()) {
13 | // case AudioManager.RINGER_MODE_NORMAL:
14 | // case AudioManager.RINGER_MODE_VIBRATE:
15 | // case AudioManager.RINGER_MODE_SILENT:
16 | // }
17 | // }
18 | //
19 | // public static void getVolume() {
20 | // AudioManager am = ServiceUtil.getAudioManager();
21 | // int voiceCall = am.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
22 | // int system = am.getStreamVolume(AudioManager.STREAM_SYSTEM);
23 | // int ring = am.getStreamVolume(AudioManager.STREAM_RING);
24 | // int music = am.getStreamVolume(AudioManager.STREAM_MUSIC);
25 | // int alarm = am.getStreamVolume(AudioManager.STREAM_ALARM);
26 | // int notification = am.getStreamVolume(AudioManager.STREAM_NOTIFICATION);
27 | // }
28 | //
29 | // public static void setVolume() {
30 | // AudioManager am = ServiceUtil.getAudioManager();
31 | // int currentVolumn = am.getStreamVolume(AudioManager.STREAM_SYSTEM);
32 | // switch (am.getRingerMode()) {
33 | // case AudioManager.RINGER_MODE_SILENT:
34 | // am.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
35 | // break;
36 | // case AudioManager.RINGER_MODE_VIBRATE:
37 | // am.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
38 | // break;
39 | // case AudioManager.RINGER_MODE_NORMAL:
40 | // am.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolumn, 0);
41 | // break;
42 | // }
43 | // }
44 | }
45 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/AwakeUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import android.app.Activity;
4 | import android.os.PowerManager;
5 | import android.support.annotation.NonNull;
6 | import android.view.WindowManager;
7 |
8 | import com.thefinestartist.utils.service.ServiceUtil;
9 |
10 | import java.util.HashMap;
11 | import java.util.Map;
12 |
13 | /**
14 | * Created by TheFinestArtist on 2/10/16.
15 | */
16 | public class AwakeUtil {
17 |
18 | // private static Map wakeLocks = new HashMap<>();
19 | // private static final String TAG = "AwakeUtil";
20 | //
21 | // public static void awakeCPU() {
22 | // awakeCPU(TAG);
23 | // }
24 | //
25 | // public static void awakeCPU(@NonNull String tag) {
26 | // PowerManager.WakeLock wakeLock = ServiceUtil.getPowerManager().newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, tag);
27 | // wakeLock.acquire();
28 | //
29 | // if (wakeLocks.get(tag) != null)
30 | // releaseCPU(tag);
31 | // wakeLocks.put(tag, wakeLock);
32 | // }
33 | //
34 | // public static void releaseCPU() {
35 | // releaseCPU(TAG);
36 | // }
37 | //
38 | // public static void releaseCPU(@NonNull String tag) {
39 | // if (wakeLocks.get(tag) == null)
40 | // return;
41 | //
42 | // wakeLocks.get(tag).release();
43 | // wakeLocks.remove(tag);
44 | // }
45 | //
46 | // public static void awakeScreen(@NonNull Activity activity) {
47 | // activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
48 | // }
49 | //
50 | // public static void releaseScreen(@NonNull Activity activity) {
51 | // activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
52 | // }
53 | //
54 | // public void turnOnScreen() {
55 | // ServiceUtil.getPowerManager().newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag").acquire();
56 | // }
57 | //
58 | // public void turnOffScreen() {
59 | // if (APILevel.require(21))
60 | // ServiceUtil.getPowerManager().newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "tag").acquire();
61 | // }
62 | }
63 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/BitmapUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | /**
4 | * Created by TheFinestArtist on 2/9/16.
5 | */
6 | public class BitmapUtil {
7 |
8 | // private final static String TAG = ImageUtils.class.getSimpleName();
9 | //
10 | // private static final String ERROR_URI_NULL = "Uri cannot be null";
11 | //
12 | // /***
13 | // * Scales the image depending upon the display density of the device. Maintains image aspect
14 | // * ratio.
15 | // *
16 | // * When dealing with the bitmaps of bigger size, this method must be called from a non-UI
17 | // * thread.
18 | // * ***/
19 | // public static Bitmap scaleDownBitmap(Context ctx, Bitmap source, int newHeight) {
20 | // final float densityMultiplier = Utils.getDensityMultiplier(ctx);
21 | //
22 | // // Log.v( TAG, "#scaleDownBitmap Original w: " + source.getWidth() + " h: " +
23 | // // source.getHeight() );
24 | //
25 | // int h = (int) (newHeight * densityMultiplier);
26 | // int w = (int) (h * source.getWidth() / ((double) source.getHeight()));
27 | //
28 | // // Log.v( TAG, "#scaleDownBitmap Computed w: " + w + " h: " + h );
29 | //
30 | // Bitmap photo = Bitmap.createScaledBitmap(source, w, h, true);
31 | //
32 | // // Log.v( TAG, "#scaleDownBitmap Final w: " + w + " h: " + h );
33 | //
34 | // return photo;
35 | // }
36 | //
37 | // /***
38 | // * Scales the image independently of the screen density of the device. Maintains image aspect
39 | // * ratio.
40 | // *
41 | // * When dealing with the bitmaps of bigger size, this method must be called from a non-UI
42 | // * thread.
43 | // * ***/
44 | // public static Bitmap scaleBitmap(Context ctx, Bitmap source, int newHeight) {
45 | //
46 | // // Log.v( TAG, "#scaleDownBitmap Original w: " + source.getWidth() + " h: " +
47 | // // source.getHeight() );
48 | //
49 | // int w = (int) (newHeight * source.getWidth() / ((double) source.getHeight()));
50 | //
51 | // // Log.v( TAG, "#scaleDownBitmap Computed w: " + w + " h: " + newHeight );
52 | //
53 | // Bitmap photo = Bitmap.createScaledBitmap(source, w, newHeight, true);
54 | //
55 | // // Log.v( TAG, "#scaleDownBitmap Final w: " + w + " h: " + newHeight );
56 | //
57 | // return photo;
58 | // }
59 | //
60 | // /***
61 | // * Scales the image independently of the screen density of the device. Maintains image aspect
62 | // * ratio.
63 | // *
64 | // * @param uri
65 | // * Uri of the source bitmap
66 | // ****/
67 | // public static Bitmap scaleDownBitmap(Context ctx, Uri uri, int newHeight) throws FileNotFoundException, IOException {
68 | // Bitmap original = Media.getBitmap(ctx.getContentResolver(), uri);
69 | // return scaleBitmap(ctx, original, newHeight);
70 | // }
71 | //
72 | // /***
73 | // * Scales the image independently of the screen density of the device. Maintains image aspect
74 | // * ratio.
75 | // *
76 | // * @param uri
77 | // * Uri of the source bitmap
78 | // ****/
79 | // public static Uri scaleDownBitmapForUri(Context ctx, Uri uri, int newHeight) throws FileNotFoundException, IOException {
80 | //
81 | // if (uri == null)
82 | // throw new NullPointerException(ERROR_URI_NULL);
83 | //
84 | // if (!isMediaContentUri(uri))
85 | // return null;
86 | //
87 | // Bitmap original = Media.getBitmap(ctx.getContentResolver(), uri);
88 | // Bitmap bmp = scaleBitmap(ctx, original, newHeight);
89 | //
90 | // Uri destUri = null;
91 | // String uriStr = Utils.writeImageToMedia(ctx, bmp, "", "");
92 | //
93 | // if (uriStr != null) {
94 | // destUri = Uri.parse(uriStr);
95 | // }
96 | //
97 | // return destUri;
98 | // }
99 | //
100 | // /***
101 | // * Gets the orientation of the image pointed to by the parameter uri
102 | // *
103 | // * @return Image orientation value corresponding to ExifInterface.ORIENTATION_*
104 | // * Returns -1 if the row for the {@link android.net.Uri} is not found.
105 | // ****/
106 | // public static int getOrientation(Context context, Uri uri) {
107 | //
108 | // int invalidOrientation = -1;
109 | // if (uri == null) {
110 | // throw new NullPointerException(ERROR_URI_NULL);
111 | // }
112 | //
113 | // if (!isMediaContentUri(uri)) {
114 | // return invalidOrientation;
115 | // }
116 | //
117 | // String filePath = Utils.getImagePathForUri(context, uri);
118 | // ExifInterface exif = null;
119 | //
120 | // try {
121 | // exif = new ExifInterface(filePath);
122 | // } catch (IOException e) {
123 | // e.printStackTrace();
124 | // }
125 | //
126 | // int orientation = invalidOrientation;
127 | // if (exif != null) {
128 | // orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, invalidOrientation);
129 | // }
130 | //
131 | // return orientation;
132 | // }
133 | //
134 | // /***
135 | // * @deprecated Use {@link MediaUtils#isMediaContentUri(android.net.Uri)} instead.
136 | // * Checks if the parameter {@link android.net.Uri} is a
137 | // * {@link android.provider.MediaStore.Audio.Media} content uri.
138 | // ****/
139 | // public static boolean isMediaContentUri(Uri uri) {
140 | // if (!uri.toString().contains("content://media/")) {
141 | // Log.w(TAG, "#isContentUri The uri is not a media content uri");
142 | // return false;
143 | // } else {
144 | // return true;
145 | // }
146 | // }
147 | //
148 | // /***
149 | // * Rotate the image at the specified uri. For the rotation of the image the
150 | // * {@link android.media.ExifInterface} data in the image will be used.
151 | // *
152 | // * @param uri
153 | // * Uri of the image to be rotated.
154 | // ****/
155 | // public static Uri rotateImage(Context context, Uri uri) throws FileNotFoundException, IOException {
156 | // // rotate the image
157 | // if (uri == null) {
158 | // throw new NullPointerException(ERROR_URI_NULL);
159 | // }
160 | //
161 | // if (!isMediaContentUri(uri)) {
162 | // return null;
163 | // }
164 | //
165 | // int invalidOrientation = -1;
166 | // byte[] data = Utils.getMediaData(context, uri);
167 | //
168 | // int orientation = getOrientation(context, uri);
169 | //
170 | // Uri newUri = null;
171 | //
172 | // try {
173 | //
174 | // Log.d(TAG, "#rotateImage Exif orientation: " + orientation);
175 | //
176 | // if (orientation != invalidOrientation) {
177 | // Matrix matrix = new Matrix();
178 | //
179 | // switch (orientation) {
180 | // case ExifInterface.ORIENTATION_ROTATE_90:
181 | // matrix.postRotate(90);
182 | // break;
183 | // case ExifInterface.ORIENTATION_ROTATE_180:
184 | // matrix.postRotate(180);
185 | // break;
186 | // case ExifInterface.ORIENTATION_ROTATE_270:
187 | // matrix.postRotate(270);
188 | // break;
189 | // }
190 | //
191 | // // set some options so the memory is manager properly
192 | // BitmapFactory.Options options = new BitmapFactory.Options();
193 | // // options.inPreferredConfig = Bitmap.Config.RGB_565; // try to enable this if
194 | // // OutOfMem issue still persists
195 | // options.inPurgeable = true;
196 | // options.inInputShareable = true;
197 | //
198 | // Bitmap original = BitmapFactory.decodeByteArray(data, 0, data.length, options);
199 | // Bitmap rotatedBitmap = Bitmap.createBitmap(original, 0, 0, original.getWidth(), original.getHeight(), matrix, true); // rotating
200 | // // bitmap
201 | // String newUrl = Media.insertImage(((Activity) context).getContentResolver(), rotatedBitmap, "", "");
202 | //
203 | // if (newUrl != null) {
204 | // newUri = Uri.parse(newUrl);
205 | // }
206 | // }
207 | // } catch (Exception e) {
208 | // e.printStackTrace();
209 | // }
210 | //
211 | // return newUri;
212 | // }
213 | }
214 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/DateUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import android.text.format.DateFormat;
4 |
5 | import java.text.ParseException;
6 | import java.text.SimpleDateFormat;
7 | import java.util.Date;
8 | import java.util.TimeZone;
9 |
10 | /**
11 | * Created by TheFinestArtist on 1/26/16.
12 | */
13 | public class DateUtil {
14 |
15 | // public static String SERVER_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.'000Z'";
16 | // public static String POST_FORMAT = "yy/MM/dd HH:mm";
17 | // public static String CLICKER_FORMAT = "yyyy/MM/dd kk:mm";
18 | // public static String DATE_FORMAT = "yyyy/MM/dd";
19 | // public static String TIME_FORMAT = "HH:mm";
20 | // private static SimpleDateFormat server_format = new SimpleDateFormat(SERVER_FORMAT);
21 | // private static SimpleDateFormat post_format = new SimpleDateFormat(POST_FORMAT);
22 | // private static SimpleDateFormat date_format = new SimpleDateFormat(DATE_FORMAT);
23 | // private static SimpleDateFormat time_format = new SimpleDateFormat(TIME_FORMAT);
24 | //
25 | // public static synchronized long getCurrentGMTTimeMillis() {
26 | // final Date currentTime = new Date();
27 | // final SimpleDateFormat sdf = new SimpleDateFormat(SERVER_FORMAT);
28 | // sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
29 | // String time = sdf.format(currentTime);
30 | // return getTime(time);
31 | // }
32 | //
33 | // public static String getCurrentTimeString() {
34 | // return (String) DateFormat.format(CLICKER_FORMAT, System.currentTimeMillis());
35 | // }
36 | //
37 | // public static long getTime(String timeStr) {
38 | // Date date;
39 | // try {
40 | // server_format.setTimeZone(TimeZone.getTimeZone("GMT"));
41 | // date = server_format.parse(timeStr);
42 | // return date.getTime();
43 | // } catch (ParseException e) {
44 | // return 0;
45 | // }
46 | // }
47 | //
48 | // public static Date getDate(String timeStr) {
49 | // Date date;
50 | // try {
51 | // server_format.setTimeZone(TimeZone.getTimeZone("GMT"));
52 | // date = server_format.parse(timeStr);
53 | // return date;
54 | // } catch (ParseException e) {
55 | // return null;
56 | // }
57 | // }
58 | //
59 | // public static String getPostFormatString(String timeStr) {
60 | // Date date;
61 | // try {
62 | // server_format.setTimeZone(TimeZone.getTimeZone("GMT"));
63 | // post_format.setTimeZone(TimeZone.getDefault());
64 | // date = server_format.parse(timeStr);
65 | // return post_format.format(date);
66 | // } catch (ParseException e) {
67 | // return null;
68 | // }
69 | // }
70 | //
71 | // public static String getDateFormatString(String timeStr) {
72 | // Date date;
73 | // try {
74 | // server_format.setTimeZone(TimeZone.getTimeZone("GMT"));
75 | // date_format.setTimeZone(TimeZone.getDefault());
76 | // date = server_format.parse(timeStr);
77 | // return date_format.format(date);
78 | // } catch (ParseException e) {
79 | // return null;
80 | // }
81 | // }
82 | //
83 | // public static String getTimeFormatString(String timeStr) {
84 | // Date date;
85 | // try {
86 | // server_format.setTimeZone(TimeZone.getTimeZone("GMT"));
87 | // time_format.setTimeZone(TimeZone.getDefault());
88 | // date = server_format.parse(timeStr);
89 | // return time_format.format(date);
90 | // } catch (ParseException e) {
91 | // return null;
92 | // }
93 | // }
94 | }
95 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/EmailUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import android.content.Intent;
4 | import android.os.Build;
5 |
6 | import com.thefinestartist.Base;
7 |
8 | /**
9 | * Created by TheFinestArtist
10 | */
11 | public class EmailUtil {
12 |
13 | // public static void sendSupportMail(String url) {
14 | // Intent i = new Intent(Intent.ACTION_SEND);
15 | // i.setType("message/rfc822");
16 | // i.putExtra(Intent.EXTRA_EMAIL, new String[]{url});
17 | // i.putExtra(Intent.EXTRA_SUBJECT, "[FEEDBACK] Android App (" + Build.VERSION.CODENAME + ")");
18 | // i.putExtra(Intent.EXTRA_TEXT, "");
19 | // try {
20 | // Base.getContext().startActivity(Intent.createChooser(i, "Send Feedback"));
21 | // } catch (android.content.ActivityNotFoundException e) {
22 | // e.printStackTrace();
23 | // }
24 | // }
25 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/FileUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import com.thefinestartist.Base;
4 |
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 |
8 | /**
9 | * Created by TheFinestArtist on 2/10/16.
10 | */
11 | public class FileUtil {
12 |
13 | // public static String readJsonFile(String filePath) {
14 | // try {
15 | // String json = null;
16 | // InputStream is = Base.getContext().getAssets().open(filePath);
17 | // int size = is.available();
18 | // byte[] buffer = new byte[size];
19 | // is.read(buffer);
20 | // is.close();
21 | // return new String(buffer, "UTF-8");
22 | // } catch (IOException e) {
23 | // e.printStackTrace();
24 | // return null;
25 | // }
26 | // }
27 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/LanguageDetector.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | /**
4 | * Created by TheFinestArtist on 2014. 9. 2..
5 | */
6 | public class LanguageDetector {
7 |
8 | // public static boolean isEnglish(CharSequence charSequence) {
9 | // boolean isEnglish = true;
10 | // for (char c : charSequence.toString().toCharArray()) {
11 | // if (Character.UnicodeBlock.of(c) != Character.UnicodeBlock.BASIC_LATIN) {
12 | // isEnglish = false;
13 | // break;
14 | // }
15 | // }
16 | //
17 | // return isEnglish;
18 | // }
19 | //
20 | // public static boolean hasKorean(CharSequence charSequence) {
21 | // boolean hasKorean = false;
22 | // for (char c : charSequence.toString().toCharArray()) {
23 | // if (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.HANGUL_JAMO
24 | // || Character.UnicodeBlock.of(c) == Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO
25 | // || Character.UnicodeBlock.of(c) == Character.UnicodeBlock.HANGUL_SYLLABLES) {
26 | // hasKorean = true;
27 | // break;
28 | // }
29 | // }
30 | //
31 | // return hasKorean;
32 | // }
33 | //
34 | // public static boolean hasJapanese(CharSequence charSequence) {
35 | // boolean hasJapanese = false;
36 | // for (char c : charSequence.toString().toCharArray()) {
37 | // if (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
38 | // || Character.UnicodeBlock.of(c) == Character.UnicodeBlock.HIRAGANA
39 | // || Character.UnicodeBlock.of(c) == Character.UnicodeBlock.KATAKANA
40 | // || Character.UnicodeBlock.of(c) == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
41 | // || Character.UnicodeBlock.of(c) == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
42 | // || Character.UnicodeBlock.of(c) == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION) {
43 | // hasJapanese = true;
44 | // break;
45 | // }
46 | // }
47 | //
48 | // return hasJapanese;
49 | // }
50 | //
51 | // public enum Language {Korean, Japanese, English}
52 |
53 | }
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/NetworkUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import android.net.ConnectivityManager;
4 | import android.net.NetworkInfo;
5 | import android.telephony.TelephonyManager;
6 |
7 | import com.thefinestartist.utils.service.ServiceUtil;
8 |
9 | /**
10 | * Created by TheFinestArtist on 2/21/16.
11 | */
12 | public class NetworkUtil {
13 |
14 | // public static NetworkInfo getNetworkInfo() {
15 | // return ServiceUtil.getConnectivityManager().getActiveNetworkInfo();
16 | // }
17 | //
18 | // public static boolean isConnected() {
19 | // NetworkInfo info = getNetworkInfo();
20 | // return (info != null && info.isConnected());
21 | // }
22 | //
23 | // public static boolean isConnectedWifi() {
24 | // NetworkInfo info = getNetworkInfo();
25 | // return (info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_WIFI);
26 | // }
27 | //
28 | // public static boolean isConnectedMobile() {
29 | // NetworkInfo info = getNetworkInfo();
30 | // return (info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_MOBILE);
31 | // }
32 | //
33 | // public static boolean isConnectedFast() {
34 | // NetworkInfo info = getNetworkInfo();
35 | // return (info != null && info.isConnected() && isConnectionFast(info.getType(), info.getSubtype()));
36 | // }
37 | //
38 | // public static boolean isConnectionFast(int type, int subType) {
39 | // if (type == ConnectivityManager.TYPE_WIFI) {
40 | // return true;
41 | // } else if (type == ConnectivityManager.TYPE_MOBILE) {
42 | // switch (subType) {
43 | // case TelephonyManager.NETWORK_TYPE_1xRTT:
44 | // return false; // ~ 50-100 kbps
45 | // case TelephonyManager.NETWORK_TYPE_CDMA:
46 | // return false; // ~ 14-64 kbps
47 | // case TelephonyManager.NETWORK_TYPE_EDGE:
48 | // return false; // ~ 50-100 kbps
49 | // case TelephonyManager.NETWORK_TYPE_EVDO_0:
50 | // return true; // ~ 400-1000 kbps
51 | // case TelephonyManager.NETWORK_TYPE_EVDO_A:
52 | // return true; // ~ 600-1400 kbps
53 | // case TelephonyManager.NETWORK_TYPE_GPRS:
54 | // return false; // ~ 100 kbps
55 | // case TelephonyManager.NETWORK_TYPE_HSDPA:
56 | // return true; // ~ 2-14 Mbps
57 | // case TelephonyManager.NETWORK_TYPE_HSPA:
58 | // return true; // ~ 700-1700 kbps
59 | // case TelephonyManager.NETWORK_TYPE_HSUPA:
60 | // return true; // ~ 1-23 Mbps
61 | // case TelephonyManager.NETWORK_TYPE_UMTS:
62 | // return true; // ~ 400-7000 kbps
63 | // /*
64 | // * Above API level 7, make sure to set android:targetSdkVersion
65 | // * to appropriate level to use these
66 | // */
67 | // case TelephonyManager.NETWORK_TYPE_EHRPD: // API level 11
68 | // return true; // ~ 1-2 Mbps
69 | // case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9
70 | // return true; // ~ 5 Mbps
71 | // case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13
72 | // return true; // ~ 10-20 Mbps
73 | // case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8
74 | // return false; // ~25 kbps
75 | // case TelephonyManager.NETWORK_TYPE_LTE: // API level 11
76 | // return true; // ~ 10+ Mbps
77 | // // Unknown
78 | // case TelephonyManager.NETWORK_TYPE_UNKNOWN:
79 | // default:
80 | // return false;
81 | // }
82 | // } else {
83 | // return false;
84 | // }
85 | // }
86 | }
87 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/PhotoUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.graphics.Matrix;
6 | import android.media.ExifInterface;
7 |
8 | import java.io.ByteArrayOutputStream;
9 | import java.io.File;
10 | import java.io.FileInputStream;
11 | import java.io.FileNotFoundException;
12 | import java.lang.ref.SoftReference;
13 |
14 | /**
15 | * Created by TheFinestArtist
16 | */
17 | public class PhotoUtil {
18 |
19 | // public static final int IMAGE_MAX_WIDTH = 800;
20 | //
21 | // public static SoftReference convertToByte(String path) {
22 | // if (path == null)
23 | // return new SoftReference<>(new byte[0]);
24 | //
25 | // BitmapFactory.Options options = new BitmapFactory.Options();
26 | // int inSampleSize = getInSampleSize(path, IMAGE_MAX_WIDTH * 2);
27 | // options.inSampleSize = inSampleSize;
28 | // Bitmap bitmap = BitmapFactory.decodeFile(path, options);
29 | //
30 | // if (bitmap == null) {
31 | // inSampleSize = getInSampleSize(path, IMAGE_MAX_WIDTH * 2);
32 | // options.inSampleSize = inSampleSize;
33 | // bitmap = BitmapFactory.decodeFile(path, options);
34 | // }
35 | //
36 | // if (bitmap == null)
37 | // return new SoftReference<>(new byte[0]);
38 | //
39 | // // Scale the bitmap
40 | // if (inSampleSize > 1) {
41 | // float height;
42 | // switch (getRotation(path)) {
43 | // case ExifInterface.ORIENTATION_ROTATE_90:
44 | // case ExifInterface.ORIENTATION_ROTATE_270:
45 | // height = ((float) bitmap.getWidth()) * ((float) IMAGE_MAX_WIDTH) / ((float) bitmap.getHeight());
46 | // bitmap = Bitmap.createScaledBitmap(bitmap, (int) height, IMAGE_MAX_WIDTH, true);
47 | // break;
48 | // case ExifInterface.ORIENTATION_NORMAL:
49 | // case ExifInterface.ORIENTATION_ROTATE_180:
50 | // default:
51 | // height = ((float) bitmap.getHeight()) * ((float) IMAGE_MAX_WIDTH) / ((float) bitmap.getWidth());
52 | // bitmap = Bitmap.createScaledBitmap(bitmap, IMAGE_MAX_WIDTH, (int) height, true);
53 | // break;
54 | // }
55 | // }
56 | //
57 | // // Rotate the bitmap
58 | // switch (getRotation(path)) {
59 | // case ExifInterface.ORIENTATION_ROTATE_90:
60 | // bitmap = rotateBitmap(bitmap, 90);
61 | // break;
62 | // case ExifInterface.ORIENTATION_ROTATE_270:
63 | // bitmap = rotateBitmap(bitmap, 270);
64 | // break;
65 | // }
66 | //
67 | // byte[] bytes = null;
68 | // try {
69 | // ByteArrayOutputStream stream = new ByteArrayOutputStream();
70 | // bitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream);
71 | // bytes = stream.toByteArray();
72 | // stream.close();
73 | // } catch (Exception e) {
74 | // e.printStackTrace();
75 | // }
76 | //
77 | // return new SoftReference<>(bytes);
78 | // }
79 | //
80 | // public static Bitmap rotateBitmap(Bitmap bitmap, float angle) {
81 | // Matrix matrix = new Matrix();
82 | // matrix.postRotate(angle);
83 | // return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
84 | // }
85 | //
86 | //
87 | // public static int getInSampleSize(String path, int maxWidth) {
88 | // SoftReference bitmap = getBitmap(path);
89 | // int inSampleSize = 1;
90 | // float currentWidth = 0;
91 | // switch (getRotation(path)) {
92 | // case ExifInterface.ORIENTATION_ROTATE_90:
93 | // case ExifInterface.ORIENTATION_ROTATE_270:
94 | // if (bitmap != null && bitmap.get() != null)
95 | // currentWidth = bitmap.get().getHeight();
96 | // break;
97 | // case ExifInterface.ORIENTATION_NORMAL:
98 | // case ExifInterface.ORIENTATION_ROTATE_180:
99 | // default:
100 | // if (bitmap != null && bitmap.get() != null)
101 | // currentWidth = bitmap.get().getWidth();
102 | // break;
103 | // }
104 | //
105 | // currentWidth /= (float) maxWidth;
106 | // while (currentWidth > 1) {
107 | // inSampleSize *= 2;
108 | // currentWidth /= 2;
109 | // }
110 | //
111 | // return inSampleSize;
112 | // }
113 | //
114 | // public static SoftReference getBitmap(String path) {
115 | // SoftReference bitmap = null;
116 | //
117 | // try {
118 | // bitmap = new SoftReference<>(BitmapFactory.decodeStream(new FileInputStream(new File(path))));
119 | // } catch (FileNotFoundException e) {
120 | // e.printStackTrace();
121 | // }
122 | //
123 | // return bitmap;
124 | // }
125 | //
126 | // public static int getRotation(String path) {
127 | // int rotate = ExifInterface.ORIENTATION_NORMAL;
128 | // try {
129 | // File imageFile = new File(path);
130 | // ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
131 | // rotate = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
132 | // } catch (Exception e) {
133 | // e.printStackTrace();
134 | // }
135 | // return rotate;
136 | // }
137 | }
138 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/RippleUtil.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import android.graphics.drawable.Drawable;
4 | import android.graphics.drawable.RippleDrawable;
5 | import android.view.View;
6 |
7 | import com.thefinestartist.utils.etc.APILevel;
8 |
9 | /**
10 | * Created by TheFinestArtist on 2/21/16.
11 | */
12 | public class RippleUtil {
13 |
14 | // public static void forceEvent(View view, float x, float y) {
15 | // Drawable background = view.getBackground();
16 | // if (APILevel.require(21)) {
17 | // if (background instanceof RippleDrawable) {
18 | // RippleDrawable ripple = (RippleDrawable) background;
19 | // ripple.setHotspot(x, y);
20 | // ripple.setVisible(true, true);
21 | // }
22 | // }
23 | // }
24 | }
25 |
--------------------------------------------------------------------------------
/utils/src/main/java/com/thefinestartist/wip/Validator.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.wip;
2 |
3 | import java.util.regex.Matcher;
4 | import java.util.regex.Pattern;
5 |
6 | /**
7 | * Created by TheFinestArtist on 2/18/16.
8 | */
9 | public class Validator {
10 |
11 | // public static final String SPECIAL_CHARS = "\\p{Cntrl}\\(\\)<>@,;:'\\\\\\\"\\.\\[\\]";
12 | // public static final String VALID_CHARS = "[^\\s" + SPECIAL_CHARS + "]";
13 | // public static final String QUOTED_USER = "(\"[^\"]*\")";
14 | // public static final String WORD = "((" + VALID_CHARS + "|')+|" + QUOTED_USER + ")";
15 | //
16 | // public static final String EMAIL_REGEX = "^\\s*?(.+)@(.+?)\\s*$";
17 | // public static final String IP_DOMAIN_REGEX = "^\\[(.*)\\]$";
18 | // public static final String USER_REGEX = "^\\s*" + WORD + "(\\." + WORD + ")*$";
19 | //
20 | // public static final Pattern EMAIL_PATTERN = Pattern.compile(EMAIL_REGEX);
21 | // public static final Pattern IP_DOMAIN_PATTERN = Pattern.compile(IP_DOMAIN_REGEX);
22 | // public static final Pattern USER_PATTERN = Pattern.compile(USER_REGEX);
23 | //
24 | //
25 | // // Regular expression strings for hostnames (derived from RFC2396 and RFC 1123)
26 | //
27 | // // RFC2396: domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
28 | // // Max 63 characters
29 | // public static final String DOMAIN_LABEL_REGEX = "\\p{Alnum}(?>[\\p{Alnum}-]{0,61}\\p{Alnum})?";
30 | //
31 | // // RFC2396 toplabel = alpha | alpha *( alphanum | "-" ) alphanum
32 | // // Max 63 characters
33 | // public static final String TOP_LABEL_REGEX = "\\p{Alpha}(?>[\\p{Alnum}-]{0,61}\\p{Alnum})?";
34 | //
35 | // // RFC2396 hostname = *( domainlabel "." ) toplabel [ "." ]
36 | // // Note that the regex currently requires both a domain label and a top level label, whereas
37 | // // the RFC does not. This is because the regex is used to detect if a TLD is present.
38 | // // If the match fails, input is checked against DOMAIN_LABEL_REGEX (hostnameRegex)
39 | // // RFC1123 sec 2.1 allows hostnames to start with a digit
40 | // public static final String DOMAIN_NAME_REGEX = "^(?:" + DOMAIN_LABEL_REGEX + "\\.)+" + "(" + TOP_LABEL_REGEX + ")\\.?$";
41 | //
42 | //
43 | // public static boolean isEmail(String email) {
44 | // String emailPattern = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
45 | // Pattern pattern = Pattern.compile(emailPattern);
46 | // Matcher matcher = pattern.matcher(email);
47 | // return matcher.matches();
48 | // }
49 | }
50 | // https://github.com/throrin19/Android-Validator/tree/master/library/src/com/throrinstudio/android/common/libs/validator/validator
51 | // https://github.com/ragunathjawahar/android-saripaar/tree/master/saripaar/src/main/java/commons/validator/routines
--------------------------------------------------------------------------------
/utils/src/main/res/anim/accelerate_cubic.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/accelerate_quart.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/accelerate_quint.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/activity_close_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
23 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/activity_close_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/activity_open_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/activity_open_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
23 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/decelerate_cubic.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/decelerate_quart.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/decelerate_quint.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/fade_in_fast.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/fade_out_fast.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/fade_out_slow.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/fragment_close_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
15 |
23 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/fragment_close_exit_reverse.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
15 |
23 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/fragment_open_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
14 |
22 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/fragment_open_enter_reverse.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
14 |
22 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/modal_activity_close_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
23 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/modal_activity_close_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/modal_activity_open_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/modal_activity_open_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
23 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/no_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/splash_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_blink.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_bounce.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_move.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_rotate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_slide_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_slide_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_zoom_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
--------------------------------------------------------------------------------
/utils/src/main/res/anim/view_zoom_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
--------------------------------------------------------------------------------
/utils/src/main/res/animator/card_flip_left_in.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
36 |
37 |
38 |
39 |
44 |
45 |
46 |
52 |
53 |
54 |
60 |
61 |
--------------------------------------------------------------------------------
/utils/src/main/res/animator/card_flip_left_out.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
35 |
36 |
37 |
38 |
44 |
45 |
46 |
52 |
53 |
--------------------------------------------------------------------------------
/utils/src/main/res/animator/card_flip_right_in.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
36 |
37 |
38 |
39 |
44 |
45 |
46 |
52 |
53 |
54 |
60 |
61 |
--------------------------------------------------------------------------------
/utils/src/main/res/animator/card_flip_right_out.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
35 |
36 |
37 |
38 |
44 |
45 |
46 |
52 |
53 |
--------------------------------------------------------------------------------
/utils/src/main/res/values/colors_basic.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #FFFFFF
5 | #FFFFF0
6 | #FFFFE0
7 | #FFFF00
8 | #FFFAFA
9 | #FFFAF0
10 | #FFFACD
11 | #FFF8DC
12 | #FFF5EE
13 | #FFF0F5
14 | #FFEFD5
15 | #FFEBCD
16 | #FFE4E1
17 | #FFE4C4
18 | #FFE4B5
19 | #FFDEAD
20 | #FFDAB9
21 | #FFD700
22 | #FFC0CB
23 | #FFB6C1
24 | #FFA500
25 | #FFA07A
26 | #FF8C00
27 | #FF7F50
28 | #FF69B4
29 | #FF6347
30 | #FF4500
31 | #FF1493
32 | #FF00FF
33 | #FF00FF
34 | #FF0000
35 | #FDF5E6
36 | #FAFAD2
37 | #FAF0E6
38 | #FAEBD7
39 | #FA8072
40 | #F8F8FF
41 | #F5FFFA
42 | #F5F5F5
43 | #F5F5DC
44 | #F5DEB3
45 | #F4A460
46 | #F0FFFF
47 | #F0FFF0
48 | #F0F8FF
49 | #F0E68C
50 | #F08080
51 | #EEE8AA
52 | #EE82EE
53 | #E9967A
54 | #E6E6FA
55 | #E0FFFF
56 | #DEB887
57 | #DDA0DD
58 | #DCDCDC
59 | #DC143C
60 | #DB7093
61 | #DAA520
62 | #DA70D6
63 | #D8BFD8
64 | #D3D3D3
65 | #D2B48C
66 | #D2691E
67 | #CD853F
68 | #CD5C5C
69 | #C71585
70 | #C0C0C0
71 | #BDB76B
72 | #BC8F8F
73 | #BA55D3
74 | #B8860B
75 | #B22222
76 | #B0E0E6
77 | #B0C4DE
78 | #AFEEEE
79 | #ADFF2F
80 | #ADD8E6
81 | #A9A9A9
82 | #A52A2A
83 | #A0522D
84 | #9ACD32
85 | #9932CC
86 | #98FB98
87 | #9400D3
88 | #9370DB
89 | #90EE90
90 | #8FBC8F
91 | #8B4513
92 | #8B008B
93 | #8B0000
94 | #8A2BE2
95 | #87CEFA
96 | #87CEEB
97 | #808080
98 | #808000
99 | #800080
100 | #800000
101 | #7FFFD4
102 | #7FFF00
103 | #7CFC00
104 | #7B68EE
105 | #778899
106 | #708090
107 | #6B8E23
108 | #6A5ACD
109 | #696969
110 | #66CDAA
111 | #6495ED
112 | #5F9EA0
113 | #556B2F
114 | #4B0082
115 | #48D1CC
116 | #483D8B
117 | #4682B4
118 | #4169E1
119 | #40E0D0
120 | #3CB371
121 | #32CD32
122 | #2F4F4F
123 | #2E8B57
124 | #228B22
125 | #20B2AA
126 | #1E90FF
127 | #191970
128 | #00FFFF
129 | #00FFFF
130 | #00FF7F
131 | #00FF00
132 | #00FA9A
133 | #00CED1
134 | #00BFFF
135 | #008B8B
136 | #008080
137 | #008000
138 | #006400
139 | #0000FF
140 | #0000CD
141 | #00008B
142 | #000080
143 | #000000
144 |
145 |
--------------------------------------------------------------------------------
/utils/src/main/res/values/colors_transparent.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 | #11000000
23 | #22000000
24 | #33000000
25 | #44000000
26 | #55000000
27 | #66000000
28 | #77000000
29 | #88000000
30 | #99000000
31 | #aa000000
32 | #bb000000
33 | #cc000000
34 | #dd000000
35 | #ee000000
36 | #0D000000
37 | #1A000000
38 | #26000000
39 | #33000000
40 | #40000000
41 | #4D000000
42 | #59000000
43 | #66000000
44 | #73000000
45 | #80000000
46 | #8C000000
47 | #99000000
48 | #A6000000
49 | #B3000000
50 | #BF000000
51 | #CC000000
52 | #D9000000
53 | #E6000000
54 | #F2000000
55 |
56 |
57 | #11ffffff
58 | #22ffffff
59 | #33ffffff
60 | #44ffffff
61 | #55ffffff
62 | #66ffffff
63 | #77ffffff
64 | #88ffffff
65 | #99ffffff
66 | #aaffffff
67 | #bbffffff
68 | #ccffffff
69 | #ddffffff
70 | #eeffffff
71 | #0Dffffff
72 | #1Affffff
73 | #26ffffff
74 | #33ffffff
75 | #40ffffff
76 | #4Dffffff
77 | #59ffffff
78 | #66ffffff
79 | #73ffffff
80 | #80ffffff
81 | #8Cffffff
82 | #99ffffff
83 | #A6ffffff
84 | #B3ffffff
85 | #BFffffff
86 | #CCffffff
87 | #D9ffffff
88 | #E6ffffff
89 | #F2ffffff
90 |
91 |
--------------------------------------------------------------------------------
/utils/src/test/java/com/thefinestartist/helpers/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.thefinestartist.utils;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------