Skip to content

Commit 17cabb3

Browse files
committed
Version 0.3.0
1 parent 0addb7e commit 17cabb3

File tree

4 files changed

+91
-74
lines changed

4 files changed

+91
-74
lines changed

README.md

Lines changed: 61 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ package, tasks and sdk on Android 9+ (Gingerbread or above) devices.
2222
6. [DynamicTaskUtils](https://github.com/pranavpandey/dynamic-utils#dynamictaskutils)
2323
7. [DynamicVersionUtils](https://github.com/pranavpandey/dynamic-utils#dynamicversionutils)
2424
8. [DynamicWindowUtils](https://github.com/pranavpandey/dynamic-utils#dynamicwindowutils)
25-
9. [Dependency](https://github.com/pranavpandey/dynamic-utils#dependency)
25+
9. [DynamicUnitUtils](https://github.com/pranavpandey/dynamic-utils#dynamicwindowutils)
26+
10. [Dependency](https://github.com/pranavpandey/dynamic-utils#dynamicunitutils)
2627
3. [License](https://github.com/pranavpandey/dynamic-utils#license)
2728

2829
---
@@ -33,7 +34,7 @@ It can be installed by adding the following dependency to your `build.gradle` fi
3334

3435
```groovy
3536
dependencies {
36-
compile 'com.pranavpandey.android:dynamic-utils:0.2.0'
37+
compile 'com.pranavpandey.android:dynamic-utils:0.3.0'
3738
}
3839
```
3940

@@ -49,109 +50,127 @@ for more hidden features.
4950

5051
Helper class to change colors dynamically.
5152

52-
1. `adjustAlpha(color, factor)` - Adjust alpha of a color according to the given parameter.
53+
1. `@ColorInt int adjustAlpha(color, factor)` - Adjust alpha of a color according to the given
54+
parameter.
5355

54-
2. `calculateContrast(color1, color2) ` - Calculate color contrast difference between two
55-
colors based on luma value according to XYZ color space.
56+
2. `@ColorInt int calculateContrast(color1, color2) ` - Calculate color contrast difference
57+
between two colors based on luma value according to XYZ color space.
5658

57-
3. `getAccentColor(color)` - Calculate accent color based on the given color for dynamic theme
58-
generation.
59+
3. `@ColorInt int getAccentColor(color)` - Calculate accent color based on the given color for
60+
dynamic theme generation.
5961

60-
4. `getColorDarkness(color) ` - Calculate darkness of a color.
62+
4. `@ColorInt int getColorDarkness(color) ` - Calculate darkness of a color.
6163

62-
5. `getContrastColor(color, contrastWithColor)` - Calculate contrast of a color based on the given
63-
base color so that it will be visible always on top of the base color.
64+
5. `@ColorInt int getContrastColor(color, contrastWithColor)` - Calculate contrast of a color
65+
based on the given base color so that it will be visible always on top of the base color.
6466

65-
6. `getLessVisibleColor(color)` - Calculate less visible color of a given color.
67+
6. `@ColorInt int getLessVisibleColor(color)` - Calculate less visible color of a given color.
6668

67-
7. `getTintColor(color)` - Calculate tint based on a given color for better readability.
69+
7. `@ColorInt int getTintColor(color)` - Calculate tint based on a given color for better
70+
readability.
6871

69-
8. `isColorDark(color)` - Detect light or dark color.
72+
8. `boolean isColorDark(color)` - Detect light or dark color.
7073

71-
9. `shiftColor(color, by)` - Shift a color according to the given parameter.
74+
9. `@ColorInt int shiftColor(color, by)` - Shift a color according to the given parameter.
7275

7376
### DynamicDeviceUtils
7477

7578
Helper class to detect device specific features like Telephony, etc.
7679

77-
1. `hasTelephony(context)` - To detect if device has telephony feature or not by using PackageManager.
80+
1. `boolean hasTelephony(context)` - To detect if device has telephony feature or not by using
81+
PackageManager.
7882

7983
### DynamicDrawableUtils
8084

8185
Helper class to perform Drawable operations.
8286

83-
1. `colorizeDrawable(drawable, wrap, color, mode)` - Colorize and return the mutated drawable so that,
84-
all other references do not change.
87+
1. `void colorizeDrawable(drawable, wrap, color, mode)` - Colorize and return the mutated drawable
88+
so that, all other references do not change.
8589

86-
2. `setBackground(view, drawable)` - Set background of a given view in an efficient way by detecting
87-
the Android SDK at runtime.
90+
2. `Drawable setBackground(view, drawable)` - Set background of a given view in an efficient way
91+
by detecting the Android SDK at runtime.
8892

8993
### DynamicLinkUtils
9094

9195
A collection of functions to perform various operations on the URL or to generate intents.
9296

93-
1. `moreApps(context, publisher)` - View other apps of a Publisher in the Google Play or Android
94-
Market.
97+
1. `void shareApp(context, title, message)` - Share application via system default share intent
98+
so that user can select from the available apps if more than one apps are available.
9599

96-
2. `rateApp(context)` - View app in the Google Play or Android Market.
100+
2. `void viewInGooglePlay(context, packageName)` - View app in the Google Play or Android Market.
97101

98-
3. `report(context, appName, email)` - Ask questions or submit bug report to the developer via email.
102+
3. `void rateApp(context)` - View app in the Google Play or Android Market.
99103

100-
4. `shareApp(context, title, message)` - Share application via system default share intent so that
101-
user can select from the available apps if more than one apps are available.
104+
4. `void moreApps(context, publisher)` - View other apps of a Publisher in the Google Play
105+
or Android Market.
102106

103-
5. `viewInGooglePlay(context, packageName)` - View app in the Google Play or Android Market.
107+
5. `void viewUrl(context, url)` - View any URL in the available app or browser.
104108

105-
6. `viewUrl(context, url)` - View any URL in the available app or browser.
109+
6. `void report(context, appName, email)` - Ask questions or submit bug report to the developer
110+
via email.
106111

107112
### DynamicPackageUtils
108113

109114
Helper class to get package or app related information.
110115

111-
1. `getAppIcon(context)` - Load application icon from the given context.
116+
1. `ComponentName getComponentName(context)` - Get component name from the given context.
112117

113-
2. `getAppLabel(context)` - Get application label from the given context.
118+
2. `CharSequence getAppLabel(context)` - Get application label from the given context.
114119

115-
3. `getAppVersion(context)` - Get application version name from the given context.
120+
3. `String getAppVersion(context)` - Get application version name from the given context.
116121

117-
4. `getComponentName(context)` - Get component name from the given context.
122+
4. `Drawable getAppIcon(context)` - Load application icon from the given context.
118123

119-
5. `isSystemApp(applicationInfo)` - To detect the given ApplicationInfo is a system app or not.
124+
5. `booelan isSystemApp(applicationInfo)` - To detect the given ApplicationInfo is a system app
125+
or not.
120126

121127
### DynamicTaskUtils
122128

123129
Helper class to easily execute or cancel an AsyncTask by handling all the exceptions.
124130

125-
1. `cancelTask(asyncTask)` - Try to cancel the supplied AsyncTask.
131+
1. `void cancelTask(asyncTask)` - Try to cancel the supplied AsyncTask.
126132

127-
2. `executeTask(asyncTask)` - Try to execute the supplied AsyncTask.
133+
2. `void executeTask(asyncTask)` - Try to execute the supplied AsyncTask.
128134

129135
### DynamicVersionUtils
130136

131137
Helper class to detect the Android SDK version at runtime so that we can provide the user
132138
experience accordingly.
133139

134-
1. `isGingerbread()` - To detect if the current Android version is Gingerbread or above.
140+
1. `boolean isGingerbread()` - To detect if the current Android version is Gingerbread or above.
135141

136-
2. `isIceCreamSandwich()` - To detect if the current Android version is Ice Cream Sandwich or above.
142+
2. `boolean isIceCreamSandwich()` - To detect if the current Android version is Ice Cream Sandwich
143+
or above.
137144

138145
...
139146

140-
10. `isNougat()` - To detect if the current Android version is N or above.
147+
10. `boolean isNougat()` - To detect if the current Android version is N or above.
141148

142-
11. `isNougatMR1()` - To detect if the current Android version is N_MR1 or above.
149+
11. `boolean isNougatMR1()` - To detect if the current Android version is N_MR1 or above.
143150

144151
### DynamicWindowUtils
145152

146153
Helper class to perform Window operations and to detect system configurations at runtime.
147154

148-
1. `getAppUsableScreenSize(context)` - Get the app usable screen size.
155+
1. `Point getAppUsableScreenSize(context)` - Get the app usable screen size.
149156

150-
2. `getNavigationBarSize(context)` - Get the on-screen navigation bar size.
157+
2. `Point getRealScreenSize(context)` - Get the real screen size.
151158

152-
3. `getRealScreenSize(context)` - Get the real screen size.
159+
3. `Point getNavigationBarSize(context)` - Get the on-screen navigation bar size.
153160

154-
4. `isNavigationBarThemeSupported(context)` - Detect support for navigation bar theme.
161+
4. `boolean isNavigationBarThemeSupported(context)` - Detect support for navigation bar theme.
162+
163+
### DynamicUnitUtils
164+
165+
Helper class to perform unit conversions.
166+
167+
1. `int convertDpToPixels(dp)` - To convert DP into pixels.
168+
169+
2. `int convertPixelsToDp(pixels)` - To convert pixels into DP.
170+
171+
3. `int convertSpToPixels(sp)` - To convert SP into pixels.
172+
173+
4. `int convertPixelsToSp(pixels)` - To convert pixels into SP.
155174

156175
### Dependency
157176

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ext {
3333
issueUrl = 'https://github.com/pranavpandey/dynamic-utils/issues'
3434

3535
mavenGroup = 'com.pranavpandey.android'
36-
mavenVersion = '0.2.0'
36+
mavenVersion = '0.3.0'
3737
mavenInceptionYear = 2017
3838
mavenArtifactId = 'dynamic-utils'
3939
bintrayRepo = 'android'
@@ -47,7 +47,7 @@ ext {
4747
licenseDistribution = 'repo'
4848
allLicenses = ["Apache-2.0"]
4949

50-
versionCode = 2
50+
versionCode = 3
5151

5252
buildTools = '25.0.3'
5353
minSdk = 9

dynamic-utils/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ android {
2424
}
2525

2626
dependencies {
27-
compile fileTree(include: ['*.jar'], dir: 'libs')
2827
compile "com.android.support:support-compat:$androidSupport"
2928
}
3029

dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/utils/DynamicWindowUtils.java

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import android.content.Context;
2020
import android.graphics.Point;
21-
import android.os.Build;
2221
import android.support.annotation.NonNull;
2322
import android.view.Display;
2423
import android.view.WindowManager;
@@ -31,34 +30,6 @@
3130
*/
3231
public class DynamicWindowUtils {
3332

34-
/**
35-
* Get the on-screen navigation bar size.
36-
*
37-
* @param context Context to get the resources and window service.
38-
*
39-
* @return On-screen navigation bar in point.
40-
*
41-
* @see android.content.Context#WINDOW_SERVICE
42-
* @see android.graphics.Point
43-
*/
44-
public static Point getNavigationBarSize(@NonNull Context context) {
45-
Point appUsableSize = getAppUsableScreenSize(context);
46-
Point realScreenSize = getRealScreenSize(context);
47-
48-
// navigation bar on the right
49-
if (appUsableSize.x < realScreenSize.x) {
50-
return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y);
51-
}
52-
53-
// navigation bar at the bottom
54-
if (appUsableSize.y < realScreenSize.y) {
55-
return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y);
56-
}
57-
58-
// navigation bar is not present
59-
return new Point();
60-
}
61-
6233
/**
6334
* Get the app usable screen size.
6435
*
@@ -119,6 +90,34 @@ public static Point getRealScreenSize(@NonNull Context context) {
11990
return size;
12091
}
12192

93+
/**
94+
* Get the on-screen navigation bar size.
95+
*
96+
* @param context Context to get the resources and window service.
97+
*
98+
* @return On-screen navigation bar in point.
99+
*
100+
* @see android.content.Context#WINDOW_SERVICE
101+
* @see android.graphics.Point
102+
*/
103+
public static Point getNavigationBarSize(@NonNull Context context) {
104+
Point appUsableSize = getAppUsableScreenSize(context);
105+
Point realScreenSize = getRealScreenSize(context);
106+
107+
// navigation bar on the right
108+
if (appUsableSize.x < realScreenSize.x) {
109+
return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y);
110+
}
111+
112+
// navigation bar at the bottom
113+
if (appUsableSize.y < realScreenSize.y) {
114+
return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y);
115+
}
116+
117+
// navigation bar is not present
118+
return new Point();
119+
}
120+
122121
/**
123122
* Detect support for navigation bar theme.
124123
*

0 commit comments

Comments
 (0)