Skip to content

Commit

Permalink
Componente extraído para modulo
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao Rutkoski committed May 23, 2018
1 parent 045e4b8 commit d3ad78e
Show file tree
Hide file tree
Showing 21 changed files with 203 additions and 14 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':library')
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".demo.MainActivity">
<activity android:name=".sample.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.opencraft.android.gradienttextview.demo
package com.opencraft.android.gradienttextview.sample

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
Expand Down
26 changes: 19 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f9f9f9"
tools:context=".demo.MainActivity">
android:orientation="vertical"
tools:context=".sample.MainActivity">

<com.opencraft.android.gradienttextview.control.GradientTextView
<com.opencraft.library.GradientTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="32dp"
android:text="aaaaaaaaaaaaa\naaaaaaaaaaaaa\naaaaaaaaaaaaa"
android:text="aaaaaaaaaaaaa\naaaaaaaaaaaaa\naaaaaaaaaaaaa\naaaaaaaaaaaaaa"
android:textSize="22sp"
android:textStyle="bold"
app:color_array="@array/gradient_default"
app:color_span_array="@array/gradient_color_span_default"
app:gradient_end="BOTTOM_CENTER"
app:gradient_start="TOP_CENTER" />
app:gradient_end="BOTTOM_RIGHT"
app:gradient_start="TOP_LEFT" />

</RelativeLayout>
<com.opencraft.library.GradientTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="32dp"
android:text="aaaaaaaaaaaaa\naaaaaaaaaaaaa\naaaaaaaaaaaaa\naaaaaaaaaaaaaa"
android:textSize="22sp"
android:textStyle="bold"
app:angle="-45"
app:color_array="@array/gradient_default"
app:color_span_array="@array/gradient_color_span_default" />

</LinearLayout>
1 change: 1 addition & 0 deletions library/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
39 changes: 39 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 27



defaultConfig {
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
21 changes: 21 additions & 0 deletions library/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.opencraft.library;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.opencraft.library.test", appContext.getPackageName());
}
}
2 changes: 2 additions & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.opencraft.library" />
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.opencraft.android.gradienttextview.control
package com.opencraft.library

import android.annotation.SuppressLint
import android.content.Context
Expand All @@ -9,7 +9,6 @@ import android.graphics.Point
import android.graphics.Shader
import android.util.AttributeSet
import android.widget.TextView
import com.opencraft.android.gradienttextview.R


class GradientTextView constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : TextView(context, attrs, defStyleAttr) {
Expand Down
12 changes: 12 additions & 0 deletions library/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="gradient_default">
<item>#000000</item>
<item>#FFFFFF</item>
</string-array>

<integer-array name="gradient_color_span_default">
<item>1</item>
<item>1</item>
</integer-array>
</resources>
28 changes: 28 additions & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="GradientTextView">
<attr name="color_array" format="reference" />
<attr name="color_span_array" format="reference" />
<attr name="angle" format="integer" />
<attr name="gradient_start" format="enum">
<enum name="TOP_LEFT" value="0" />
<enum name="TOP_CENTER" value="1" />
<enum name="MIDDLE_RIGHT" value="2" />
<enum name="MIDDLE_LEFT" value="3" />
<enum name="TOP_RIGHT" value="4" />
<enum name="BOTTOM_LEFT" value="5" />
<enum name="BOTTOM_CENTER" value="6" />
<enum name="BOTTOM_RIGHT" value="7" />
</attr>
<attr name="gradient_end" format="enum">
<enum name="TOP_LEFT" value="0" />
<enum name="TOP_CENTER" value="1" />
<enum name="MIDDLE_RIGHT" value="2" />
<enum name="MIDDLE_LEFT" value="3" />
<enum name="TOP_RIGHT" value="4" />
<enum name="BOTTOM_LEFT" value="5" />
<enum name="BOTTOM_CENTER" value="6" />
<enum name="BOTTOM_RIGHT" value="7" />
</attr>
</declare-styleable>
</resources>
6 changes: 6 additions & 0 deletions library/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
4 changes: 4 additions & 0 deletions library/src/main/res/values/integers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="default_angle">90</integer>
</resources>
3 changes: 3 additions & 0 deletions library/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">GradientTextView</string>
</resources>
11 changes: 11 additions & 0 deletions library/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>
17 changes: 17 additions & 0 deletions library/src/test/java/com/opencraft/library/ExampleUnitTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.opencraft.library;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app'
include ':app', ':library'

0 comments on commit d3ad78e

Please sign in to comment.