Skip to content

Commit

Permalink
release 1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
hantrungkien committed Feb 12, 2021
1 parent d425fa2 commit c0faccf
Show file tree
Hide file tree
Showing 35 changed files with 58,140 additions and 8,812 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ allprojects {
````
module/build.gradle
````gradle
compile 'com.github.hantrungkien:AutoDimension:1.0.5'
compile 'com.github.hantrungkien:AutoDimension:1.0.6'
````

#### How to use:
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "30.0.2"
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "htkien.autodimension"
minSdkVersion 14
Expand Down
39 changes: 19 additions & 20 deletions autodimens.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/**
* Created by kienht - 1.7.2017
*/
//./gradlew createDimen
//./gradlew createDimension
class AutoFactory extends DefaultTask {
@TaskAction
def create() {}
}

class DimenFactory extends DefaultTask {
class DimensionFactory extends DefaultTask {

@Input
int[] dimens = [320, 360, 384, 390, 400, 411, 420, 433, 450, 480, 533, 540, 561, 600, 640, 681, 720, 768, 800, 886, 960, 1024, 1080, 1280, 1366, 1440, 1920, 2560, 3840];
@Input
int fromDimen = 360;
int fromDimension = 360;
@Input
double positiveMaxDP = 300
double positiveMaxDP = 600
@Input
double negativeMaxDP = 100
double negativeMaxDP = 600
@Input
double positiveMaxSP = 60

Expand All @@ -40,26 +40,25 @@ class DimenFactory extends DefaultTask {
String dimenFileName = "\t<string name=\"dimenFileName\">" + folderName + "</string>\r"
printWriter.println(dimenFileName);

double ratio = dimen / fromDimension;
double haftDp = ratio * 0.5;

printWriter.printf("\t<dimen name=\"_0_5dp\">%.2fdp</dimen>\r\n", haftDp);
for (int i = 1; i <= positiveMaxDP; i++) {
double ratio = i / fromDimen;
double dp = ratio * dimen;
double haftDp = dp * 0.5d;
if (i == 1) {
printWriter.printf("\t<dimen name=\"_0_5dp\">%.2fdp</dimen>\r\n", haftDp);
}
double dp = ratio * i;
printWriter.printf("\t<dimen name=\"_%ddp\">%.2fdp</dimen>\r\n", i, dp);
printWriter.printf("\t<dimen name=\"_%d_5dp\">%.2fdp</dimen>\r\n", i, dp + haftDp);
}

printWriter.printf("\t<dimen name=\"minus_0_5dp\">%.2fdp</dimen>\r\n", -haftDp);
for (int i = 1; i <= negativeMaxDP; i++) {
double ratio = i / fromDimen;
double dp = ratio * dimen;
double dp = ratio * i;
printWriter.printf("\t<dimen name=\"minus_%ddp\">%.2fdp</dimen>\r\n", i, -dp);
printWriter.printf("\t<dimen name=\"minus_%d_5dp\">%.2fdp</dimen>\r\n", i, -dp - haftDp);
}

for (int i = 1; i <= positiveMaxSP; i++) {
double ratio = i / fromDimen;
double sp = ratio * dimen;
double sp = ratio * i;
printWriter.printf("\t<dimen name=\"_%dsp\">%.2fsp</dimen>\r\n", i, sp);
}

Expand All @@ -69,12 +68,12 @@ class DimenFactory extends DefaultTask {
}
}

task createDimen(type: DimenFactory) {}
task createDimension(type: DimensionFactory) {}

createDimen {
createDimension {
dimens = [320, 360, 384, 390, 400, 411, 420, 433, 450, 480, 533, 540, 561, 600, 640, 681, 720, 768, 800, 886, 960, 1024, 1080, 1280, 1366, 1440, 1920, 2560, 3840];
fromDimen = 360
positiveMaxDP = 300
negativeMaxDP = 100
fromDimension = 360
positiveMaxDP = 600
negativeMaxDP = 600
positiveMaxSP = 60
}
2 changes: 1 addition & 1 deletion autodimens/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply from: "../autodimens.gradle"

android {
compileSdkVersion 29
buildToolsVersion "30.0.2"
buildToolsVersion "30.0.3"

defaultConfig {
minSdkVersion 14
Expand Down
Loading

0 comments on commit c0faccf

Please sign in to comment.