Skip to content

Commit

Permalink
Merge pull request #23 from Spikeysanju/Dev
Browse files Browse the repository at this point in the history
Fix Bug & Refactor Code
  • Loading branch information
Spikeysanju authored Nov 6, 2020
2 parents 502b09e + 74c2747 commit 991ccb6
Show file tree
Hide file tree
Showing 20 changed files with 366 additions and 158 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/android_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Android CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]


jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Set Up JDK
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Run Tests
run: ./gradlew test

- name: Build Project
run: ./gradlew assemble

- name: Build with Gradle
run: ./gradlew build
21 changes: 10 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"

compileSdkVersion 30
defaultConfig {
applicationId "www.sanju.motiontoast"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"

multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -28,11 +26,12 @@ android {
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'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
implementation 'com.google.android.material:material:1.2.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation project(path: ':motiontoast')
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package www.sanju.motiontoast
package www.sanju.motiontoastapp

import androidx.test.platform.app.InstrumentationRegistry
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

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="www.sanju.motiontoast">
package="www.sanju.motiontoastapp">

<application
android:allowBackup="true"
Expand All @@ -9,7 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name="www.sanju.motiontoastapp.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package www.sanju.motiontoast
package www.sanju.motiontoastapp

import android.os.Bundle
import android.view.View
import android.widget.CompoundButton
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
import kotlinx.android.synthetic.main.activity_main.*
import www.sanju.motiontoast.MotionToast

class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClickListener,
CompoundButton.OnCheckedChangeListener {
Expand Down Expand Up @@ -51,16 +52,20 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
when (v!!.id) {
R.id.successBtn -> {
MotionToast.createToast(
this, "Profile Completed!",
this,
"Profile saved",
"Lorem Ipsum is simply dummy this is very simple text Lorem Ipsum is simply dummy this is very simple text Lorem Ipsum is simply dummy this is very simple text",
MotionToast.TOAST_SUCCESS,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
ResourcesCompat.getFont(this, R.font.helvetica_regular)
ResourcesCompat.getFont(this, R.font.montserrat_regular)
)
}
R.id.errorBtn -> {
MotionToast.createToast(
this, "Profile Update Failed!",
this,
"Profile failed",
"Profile Update Failed due to this reason",
MotionToast.TOAST_ERROR,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand All @@ -70,7 +75,9 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
R.id.warningBtn -> {

MotionToast.createToast(
this, "Please Fill All The Details!",
this,
"",
"Please Fill All The Details!",
MotionToast.TOAST_WARNING,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand All @@ -79,7 +86,9 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
}
R.id.infoBtn -> {
MotionToast.createColorToast(
this, "Color Toast testing here!",
this,
"",
"Color Toast testing here!",
MotionToast.TOAST_INFO,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand All @@ -89,6 +98,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
R.id.deleteBtn -> {
MotionToast.createToast(
this, "Profile Deleted!",
"",
MotionToast.TOAST_DELETE,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand All @@ -98,6 +108,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
R.id.noInternetBtn -> {
MotionToast.createToast(
this, "Please turn on internet connection!",
"",
MotionToast.TOAST_NO_INTERNET,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand All @@ -111,17 +122,21 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
override fun onLongClick(v: View?): Boolean {
when (v!!.id) {
R.id.successBtn -> {
MotionToast.darkToast(
this, "Profile Completed!",
MotionToast.createColorToast(
this,
"Post create 😍",
"Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
MotionToast.TOAST_SUCCESS,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
ResourcesCompat.getFont(this, R.font.helvetica_regular)
ResourcesCompat.getFont(this, R.font.montserrat_regular)
)
}
R.id.errorBtn -> {
MotionToast.darkToast(
this, "Profile Update Failed!",
this,
"",
"Profile Update Failed!",
MotionToast.TOAST_ERROR,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand All @@ -130,8 +145,10 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
}
R.id.warningBtn -> {

MotionToast.darkToast(
this, "Please Fill All The Details!",
MotionToast.darkColorToast(
this,
"",
"Please Fill All The Details!",
MotionToast.TOAST_WARNING,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand All @@ -141,7 +158,9 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
R.id.infoBtn -> {

MotionToast.darkToast(
this, "Dark ui testing here!",
this,
"",
"Dark ui testing here!",
MotionToast.TOAST_INFO,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand All @@ -150,7 +169,9 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
}
R.id.deleteBtn -> {
MotionToast.darkToast(
this, "Profile Deleted!",
this,
"",
"Profile Deleted!",
MotionToast.TOAST_DELETE,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand All @@ -159,7 +180,9 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, View.OnLongClick
}
R.id.noInternetBtn -> {
MotionToast.darkToast(
this, "Please turn on internet connection!",
this,
"",
"Please turn on internet connection!",
MotionToast.TOAST_NO_INTERNET,
MotionToast.GRAVITY_BOTTOM,
MotionToast.LONG_DURATION,
Expand Down
57 changes: 37 additions & 20 deletions app/src/main/res/layout/full_color_toast.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color_toast_view"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="10dp"
android:layout_margin="@dimen/dimen_24"
android:background="@drawable/toast_round_background"
android:backgroundTint="@color/warning_color">

Expand All @@ -13,42 +14,58 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginStart="15dp"
android:padding="5dp"
android:layout_marginStart="@dimen/dimen_12"
android:background="@drawable/color_view_background"
android:src="@drawable/ic_warning_yellow"
android:background="@drawable/color_view_background" />
android:contentDescription="@string/app_name"
android:padding="@dimen/dimen_8" />

<LinearLayout
android:layout_width="wrap_content"
android:id="@+id/custom_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerInParent="true"
android:layout_marginStart="55dp"
android:orientation="vertical"
android:padding="20dp">

android:layout_centerVertical="true"
android:layout_marginStart="@dimen/dimen_8"
android:layout_marginEnd="@dimen/dimen_8"
android:layout_toEndOf="@id/color_toast_image"
android:gravity="start"
android:orientation="vertical">

<TextView
android:id="@+id/color_toast_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/custom_toast_image"
android:fontFamily="@font/helveticabold"
android:text="Warning"
android:layout_marginStart="@dimen/dimen_12"
android:layout_marginTop="@dimen/dimen_12"
android:layout_marginEnd="@dimen/dimen_12"
android:fontFamily="@font/montserrat_bold"
android:letterSpacing="0.10"
android:text="@string/text_warning"
android:textAllCaps="true"
android:textAlignment="textStart"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:textColor="@android:color/white"
android:textSize="14sp"
android:textStyle="bold" />
app:layout_constraintStart_toEndOf="@id/color_toast_image"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/color_toast_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/custom_toast_image"
android:fontFamily="@font/helvetica_regular"
android:text="Hello this is demo warning!"
android:layout_marginStart="@dimen/dimen_12"
android:layout_marginTop="@dimen/dimen_4"
android:layout_marginEnd="@dimen/dimen_12"
android:layout_marginBottom="@dimen/dimen_12"
android:ellipsize="marquee"
android:fontFamily="@font/montserrat_regular"
android:maxLines="2"
android:text="@string/text_mock_description"
android:textAlignment="textStart"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
android:textColor="@android:color/white"
android:textSize="16sp" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/color_toast_image"
app:layout_constraintTop_toBottomOf="@id/color_toast_text" />

</LinearLayout>

Expand Down
Loading

0 comments on commit 991ccb6

Please sign in to comment.