Skip to content

Commit

Permalink
first commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
kishangohel committed Mar 30, 2020
1 parent 30bec42 commit ac37e69
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build
# Built application files
*.apk
*.aar
Expand Down
36 changes: 36 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}

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

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Empty file added consumer-rules.pro
Empty file.
176 changes: 176 additions & 0 deletions ktoaster.iml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions 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,22 @@
package kishan.library.ktoaster

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("kishan.library.ktoaster.test", appContext.packageName)
}
}
1 change: 1 addition & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="kishan.library.ktoaster" />
31 changes: 31 additions & 0 deletions src/main/java/kishan/library/ktoaster/ToastMessage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package kishan.library.ktoaster

import android.content.Context
import android.widget.Toast
import androidx.annotation.StringRes

object ToastMessage : Throwable("ToastMessage is not initialized") {

lateinit var context: Context


fun initialize(context: Context) {
this.context = context
}

fun s(@StringRes message: Int) {
s(context.resources.getString(message))
}

fun s(message: String, isShort: Boolean = true) {
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}

fun l(@StringRes message: Int) {
l(context.resources.getString(message))
}

fun l(message: String, isShort: Boolean = true) {
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
}
}
16 changes: 16 additions & 0 deletions src/test/java/kishan/library/ktoaster/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package kishan.library.ktoaster

import org.junit.Assert.assertEquals
import org.junit.Test

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

0 comments on commit ac37e69

Please sign in to comment.