Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.hatamiarash7:rtl-toast:1.3'
}
dependencies {
implementation("com.github.hatamiarash7:rtl-toast:1.3")
}
<dependency>
<groupId>com.github.hatamiarash7</groupId>
<artifactId>rtl-toast</artifactId>
<version>1.3</version>
</dependency>
libraryDependencies += "com.github.hatamiarash7" % "rtl-toast" % "1.3"
:dependencies [[com.github.hatamiarash7/rtl-toast "1.3"]]
Android library to show Toasts in a pretty RTL way
Add it in your root build.gradle
allprojects {
repositories {
...
maven {
url 'https://jitpack.io'
}
}
}
Add the dependency
dependencies {
implementation 'com.github.hatamiarash7:RTL-Toast:1.3'
}
RTLToast.error(context, message, length, withIcon);
RTLToast.success(context, message, length, withIcon);
RTLToast.info(context, message, length, withIcon);
RTLToast.warning(context, message, length, withIcon);
RTLToast.normal(context, message, length, withIcon);
You can use formatted strings
RTLToast.info(context, getFormattedMessage())
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;
}
Or you can customize your toast with RTLToast.Config
RTLToast.Config.getInstance()
.setTextColor(Color.GREEN)
.setToastTypeface(Typeface.createFromAsset(getAssets(), "IRANSans.ttf"))
.apply();
RTLToast.custom(context, message, getResources().getDrawable(R.drawable.laptop512), Color.BLACK, length, withIcon, shouldTint).show();
RTLToast.Config.reset();
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
Each project may have many problems. Contributing to the better development of this project by reporting them