-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4a2b30e
Showing
49 changed files
with
1,115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
android { | ||
compileSdk 31 | ||
|
||
defaultConfig { | ||
applicationId "com.src.tools" | ||
minSdk 21 | ||
targetSdk 31 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.4.1' | ||
implementation 'com.google.android.material:material:1.5.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' | ||
implementation project(path: ':app:coloredtoast') | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
plugins { | ||
id 'com.android.library' | ||
} | ||
|
||
android { | ||
compileSdk 31 | ||
|
||
defaultConfig { | ||
minSdk 21 | ||
targetSdk 31 | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.4.1' | ||
implementation 'com.google.android.material:material:1.5.0' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
26 changes: 26 additions & 0 deletions
26
app/coloredtoast/src/androidTest/java/com/src/coloredtoast/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.src.coloredtoast; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.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.getInstrumentation().getTargetContext(); | ||
assertEquals("com.src.coloredtoast.test", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.src.coloredtoast"> | ||
|
||
</manifest> |
109 changes: 109 additions & 0 deletions
109
app/coloredtoast/src/main/java/com/src/coloredtoast/ColoredToast.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.src.coloredtoast; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.content.res.ColorStateList; | ||
import android.graphics.Color; | ||
import android.view.Gravity; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
public class ColoredToast { | ||
|
||
Context context; | ||
LayoutInflater li; | ||
View toastView; | ||
TextView text; | ||
ImageView icon; | ||
|
||
@SuppressLint("InflateParams") | ||
public ColoredToast(Context context) { | ||
this.context = context; | ||
// Define Elements of Toast | ||
this.li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
this.toastView = li.inflate(R.layout.toast_hint_layout, null); | ||
this.text = toastView.findViewById(R.id.tv_toast); | ||
this.icon = toastView.findViewById(R.id.icon_toast); | ||
} | ||
|
||
public Toast customs(String textMessage, int length, int colorText, int colorBack, int colorTintArgb, int iconDrawable, int gravity) { | ||
Toast toast = Toast.makeText(context, textMessage, length); | ||
|
||
// Give Value to them | ||
if (iconDrawable != 0) | ||
icon.setImageResource(iconDrawable); | ||
if (colorText != 0) | ||
text.setTextColor(context.getResources().getColor(colorText)); | ||
if (colorBack != 0) | ||
toastView.setBackgroundResource(colorBack); | ||
if (colorTintArgb != 0) | ||
toastView.setBackgroundTintList(ColorStateList.valueOf(colorTintArgb)); | ||
text.setText(textMessage); | ||
toast.setView(toastView); | ||
if (gravity != 0) | ||
toast.setGravity(gravity, 0, 0); | ||
return toast; | ||
} | ||
|
||
public Toast success(String textMessage, int length) { | ||
Toast toast = Toast.makeText(context, textMessage, length); | ||
// Values | ||
icon.setImageResource(android.R.drawable.ic_menu_myplaces); | ||
text.setTextColor(context.getResources().getColor(android.R.color.background_light)); | ||
text.setText(textMessage); | ||
toastView.setBackgroundTintList(ColorStateList.valueOf(Color.argb(255, 132, 204, 0))); | ||
toastView.setBackgroundResource(R.drawable.option); | ||
toast.setView(toastView); | ||
toast.setGravity(Gravity.CENTER, 0, 0); | ||
return toast; | ||
} | ||
|
||
public Toast fail(String textMessage, int length) { | ||
Toast toast = Toast.makeText(context, textMessage, length); | ||
|
||
// Values | ||
icon.setImageResource(android.R.drawable.ic_menu_info_details); | ||
text.setTextColor(context.getResources().getColor(android.R.color.background_light)); | ||
text.setText(textMessage); | ||
// toastView.setBackgroundColor(context.getResources().getColor(R.color.colorPrimary)); | ||
toastView.setBackgroundTintList(ColorStateList.valueOf(Color.argb(255, 255, 0, 0))); | ||
toastView.setBackgroundResource(R.drawable.option); | ||
toast.setView(toastView); | ||
toast.setGravity(Gravity.CENTER, 0, 0); | ||
return toast; | ||
} | ||
|
||
public Toast warning(String textMessage, int length) { | ||
Toast toast = Toast.makeText(context, textMessage, length); | ||
|
||
|
||
// Values | ||
icon.setImageResource(android.R.drawable.stat_sys_warning); | ||
text.setTextColor(context.getResources().getColor(android.R.color.background_light)); | ||
text.setText(textMessage); | ||
// toastView.setBackgroundColor(context.getResources().getColor(R.color.colorPrimary)); | ||
toastView.setBackgroundTintList(ColorStateList.valueOf(Color.argb(255, 255, 178, 0))); | ||
toastView.setBackgroundResource(R.drawable.option); | ||
toast.setView(toastView); | ||
toast.setGravity(Gravity.CENTER, 0, 0); | ||
return toast; | ||
} | ||
|
||
public Toast info(String textMessage, int length) { | ||
Toast toast = Toast.makeText(context, textMessage, length); | ||
|
||
// Values | ||
icon.setImageResource(android.R.drawable.ic_dialog_info); | ||
text.setTextColor(context.getResources().getColor(android.R.color.background_light)); | ||
text.setText(textMessage); | ||
// toastView.setBackgroundColor(context.getResources().getColor(R.color.colorPrimary)); | ||
toastView.setBackgroundTintList(ColorStateList.valueOf(Color.argb(255, 0, 99, 251))); | ||
toastView.setBackgroundResource(R.drawable.option); | ||
toast.setView(toastView); | ||
toast.setGravity(Gravity.CENTER, 0, 0); | ||
return toast; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@android:color/darker_gray"/> | ||
<corners android:radius="5dp"/> | ||
<stroke android:color="@android:color/holo_green_dark" | ||
android:width="2dp"/> | ||
</shape> |
28 changes: 28 additions & 0 deletions
28
app/coloredtoast/src/main/res/layout/toast_hint_layout.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<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:id="@+id/layout_toast" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:background="@android:color/holo_green_light" | ||
android:orientation="horizontal" | ||
android:padding="8dp"> | ||
|
||
<ImageView | ||
android:id="@+id/icon_toast" | ||
android:layout_width="32dp" | ||
android:layout_height="43dp" | ||
app:srcCompat="@android:drawable/checkbox_on_background" | ||
tools:ignore="ContentDescription" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_toast" | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:padding="8dp" | ||
android:textColor="@android:color/black" | ||
android:textSize="14sp" /> | ||
|
||
</LinearLayout> |
17 changes: 17 additions & 0 deletions
17
app/coloredtoast/src/test/java/com/src/coloredtoast/ExampleUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.src.coloredtoast; | ||
|
||
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); | ||
} | ||
} |
Oops, something went wrong.
4a2b30e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a Sample