Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mori-hub committed Mar 24, 2022
0 parents commit 4a2b30e
Show file tree
Hide file tree
Showing 49 changed files with 1,115 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions .idea/.gitignore

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

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

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

20 changes: 20 additions & 0 deletions .idea/gradle.xml

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

18 changes: 18 additions & 0 deletions .idea/misc.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.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
39 changes: 39 additions & 0 deletions app/build.gradle
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'
}
1 change: 1 addition & 0 deletions app/coloredtoast/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
35 changes: 35 additions & 0 deletions app/coloredtoast/build.gradle
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.
21 changes: 21 additions & 0 deletions app/coloredtoast/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.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());
}
}
5 changes: 5 additions & 0 deletions app/coloredtoast/src/main/AndroidManifest.xml
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 app/coloredtoast/src/main/java/com/src/coloredtoast/ColoredToast.java
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;
}
}
7 changes: 7 additions & 0 deletions app/coloredtoast/src/main/res/drawable/option.xml
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 app/coloredtoast/src/main/res/layout/toast_hint_layout.xml
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>
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);
}
}
Loading

1 comment on commit 4a2b30e

@Mori-hub
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a Sample

Please sign in to comment.