-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
124c8e4
commit 7fc5ae9
Showing
65 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,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
.idea | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
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,25 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "ir.hatamiarash.toast_sample" | ||
minSdkVersion 16 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
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:28.0.0' | ||
implementation project(':toast') | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
} |
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 |
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,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="ir.hatamiarash.toast_sample"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
Binary file not shown.
91 changes: 91 additions & 0 deletions
91
app/src/main/java/ir/hatamiarash/toast_sample/MainActivity.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,91 @@ | ||
package ir.hatamiarash.toast_sample; | ||
|
||
import android.graphics.Color; | ||
import android.graphics.Typeface; | ||
import android.graphics.drawable.Drawable; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.text.Spannable; | ||
import android.text.SpannableStringBuilder; | ||
import android.text.style.StyleSpan; | ||
import android.view.View; | ||
import android.widget.Toast; | ||
|
||
import ir.hatamiarash.toast.RTLToast; | ||
|
||
import static android.graphics.Typeface.BOLD_ITALIC; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
findViewById(R.id.button_error_toast).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
RTLToast.error(MainActivity.this, R.string.error_message, Toast.LENGTH_SHORT, true).show(); | ||
} | ||
}); | ||
findViewById(R.id.button_success_toast).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
RTLToast.success(MainActivity.this, R.string.success_message, Toast.LENGTH_SHORT, true).show(); | ||
} | ||
}); | ||
findViewById(R.id.button_info_toast).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
RTLToast.info(MainActivity.this, R.string.info_message, Toast.LENGTH_SHORT, true).show(); | ||
} | ||
}); | ||
findViewById(R.id.button_warning_toast).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
RTLToast.warning(MainActivity.this, R.string.warning_message, Toast.LENGTH_SHORT, true).show(); | ||
} | ||
}); | ||
findViewById(R.id.button_normal_toast_wo_icon).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
RTLToast.normal(MainActivity.this, R.string.normal_message_without_icon).show(); | ||
} | ||
}); | ||
findViewById(R.id.button_normal_toast_w_icon).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Drawable icon = getResources().getDrawable(R.drawable.ic_pets_white_48dp); | ||
RTLToast.normal(MainActivity.this, R.string.normal_message_with_icon, icon).show(); | ||
} | ||
}); | ||
findViewById(R.id.button_info_toast_with_formatting).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
RTLToast.info(MainActivity.this, getFormattedMessage()).show(); | ||
} | ||
}); | ||
findViewById(R.id.button_custom_config).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
RTLToast.Config.getInstance() | ||
.setTextColor(Color.GREEN) | ||
.setToastTypeface(Typeface.createFromAsset(getAssets(), "IRANSans.ttf")) | ||
.apply(); | ||
RTLToast.custom(MainActivity.this, R.string.custom_message, getResources().getDrawable(R.drawable.laptop512), | ||
Color.BLACK, Toast.LENGTH_SHORT, true, true).show(); | ||
RTLToast.Config.reset(); | ||
} | ||
}); | ||
} | ||
|
||
private CharSequence getFormattedMessage() { | ||
final String prefix = "متن "; | ||
final String highlight = "با فرمت "; | ||
final String suffix = " مخصوص"; | ||
SpannableStringBuilder ssb = new SpannableStringBuilder(prefix).append(highlight).append(suffix); | ||
int prefixLen = prefix.length(); | ||
ssb.setSpan(new StyleSpan(BOLD_ITALIC), | ||
prefixLen, prefixLen + highlight.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); | ||
return ssb; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,106 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/activity_main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="es.dmoral.toastysample.MainActivity"> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin"> | ||
|
||
<Button | ||
android:text="@string/error_toast" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentTop="true" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:id="@+id/button_error_toast" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignParentEnd="true" /> | ||
|
||
<Button | ||
android:text="@string/success_toast" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button_error_toast" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:id="@+id/button_success_toast" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignParentEnd="true" /> | ||
|
||
<Button | ||
android:text="@string/info_toast" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button_success_toast" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:id="@+id/button_info_toast" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignParentEnd="true" /> | ||
|
||
<Button | ||
android:text="@string/info_toast_with_formatting" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/button_info_toast" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:id="@+id/button_info_toast_with_formatting" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignParentEnd="true" /> | ||
|
||
<Button | ||
android:text="@string/warning_toast" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button_info_toast_with_formatting" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignParentEnd="true" | ||
android:id="@+id/button_warning_toast" /> | ||
|
||
<Button | ||
android:text="@string/normal_toast_without_icon" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button_warning_toast" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:id="@+id/button_normal_toast_wo_icon" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignParentEnd="true" /> | ||
|
||
<Button | ||
android:text="@string/normal_toast_with_icon" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button_normal_toast_wo_icon" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:id="@+id/button_normal_toast_w_icon" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignParentEnd="true" /> | ||
|
||
<Button | ||
android:text="@string/custom_configuration" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/button_normal_toast_w_icon" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:id="@+id/button_custom_config" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignParentEnd="true" /> | ||
|
||
</RelativeLayout> | ||
</ScrollView> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
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,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> |
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 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
</resources> |
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,19 @@ | ||
<resources> | ||
<string name="app_name">RTL-Toast Sample</string> | ||
<string name="normal_toast_with_icon">پیغام عادی با آیکون</string> | ||
<string name="normal_toast_without_icon">پیغام عادی بدون آیکون</string> | ||
<string name="warning_toast">پیغام هشدار</string> | ||
<string name="info_toast">پیغام اطلاع رسانی</string> | ||
<string name="info_toast_with_formatting">پیغام همراه با فرمت</string> | ||
<string name="error_toast">پیغام خطا</string> | ||
<string name="success_toast">پیغام موفقیت</string> | ||
<string name="custom_configuration">تنظیمات دلخواه</string> | ||
|
||
<string name="error_message">مشکلی به وجود آمده است</string> | ||
<string name="success_message">سلام !</string> | ||
<string name="info_message">خوش آمدید</string> | ||
<string name="warning_message">ایمیل را بررسی نمایید</string> | ||
<string name="normal_message_without_icon">پیغام بدون آیکون</string> | ||
<string name="normal_message_with_icon">پیغام با آیکون</string> | ||
<string name="custom_message">شخصی سازی شده</string> | ||
</resources> |
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,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> |
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,27 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.2.1' | ||
|
||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
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 @@ | ||
# Project-wide Gradle settings. | ||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx1536m | ||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
|
||
|
Binary file not shown.
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 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.