diff --git a/.idea/encodings.xml b/.idea/encodings.xml index e206d70..f758959 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,5 +1,6 @@ - - - + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 8c3735b..a87d8d3 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,8 +3,10 @@ - - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 4ae8d54..8909776 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,31 @@ - + + + + + @@ -22,5 +46,4 @@ - - + \ No newline at end of file diff --git a/README.md b/README.md index 69a2920..343f97c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The default toasts are ugly and don't really provide much more than a short mess #### Gradle ```groovy dependencies { - compile 'net.steamcrafted:load-toast:1.0.5' + compile 'net.steamcrafted:load-toast:1.0.12' } ``` @@ -31,6 +31,8 @@ Change the displayed text: lt.setText("Sending Reply..."); ``` +If you don't have a message to display, the toast will shrink to only show the circular loader. + Then proceed to show the toast: ```java @@ -45,9 +47,12 @@ lt.success(); // Or this method if it failed lt.error(); + +// Or if no feedback is desired you can simply hide the toast +lt.hide(); ``` -If you are using translucent actionbar in a full screen activity it will appear over the actionbar, fortunately there is a method to change the y translation: +To properly position the toast use the following method to adjust the Y offset: ```java lt.setTranslationY(100); // y offset in pixels @@ -59,8 +64,27 @@ You can also change the colors of the different toast elements: lt.setTextColor(Color.RED).setBackgroundColor(Color.GREEN).setProgressColor(Color.BLUE); ``` +In some situations a border might be desired for increased visibility, by default it is transparent: + +```java +// Change the border color +lt.setBorderColor(int color); + +// Change the border width +lt.setBorderWidthPx(int widthPx); +lt.setBorderWidthDp(int widthDp); +lt.setBorderWidthRes(int resourceId); +``` + +When displaying a message in a RTL language you can force the text to marquee from left to right instead of the default right to left: + +```java +// pass in false for RTL text, true for LTR text +lt.setTextDirection(boolean isLeftToRight); +``` + These can be chained as you can see. -#License +# License Released under the [Apache 2.0 License](https://github.com/code-mc/loadtoast/blob/master/license.md) diff --git a/app/app.iml b/app/app.iml index 9f752ab..c53829f 100644 --- a/app/app.iml +++ b/app/app.iml @@ -1,5 +1,5 @@ - + @@ -9,12 +9,11 @@ - + - + + - + + - + - + + + + + + + + - + - + + + + + + + + - + - - - - - - - - + + - - + + + - - + + + + + + + + + + + + - - - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index f338fed..7daaad7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,23 +1,17 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 22 - buildToolsVersion "21.1.1" + compileSdkVersion 25 + buildToolsVersion '25.0.3' lintOptions { abortOnError false } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_6 - targetCompatibility JavaVersion.VERSION_1_6 - } - defaultConfig { applicationId "net.steamcrafted.gesturetrackerlib" - minSdkVersion 8 - targetSdkVersion 22 + minSdkVersion 9 + targetSdkVersion 25 versionCode 1 versionName "1.0" } @@ -32,4 +26,6 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':loadtoast') +// compile 'net.steamcrafted:load-toast:1.0.10' + compile 'com.android.support:appcompat-v7:25.3.1' } diff --git a/app/src/main/java/net/steamcrafted/loadtoastlib/MainActivity.java b/app/src/main/java/net/steamcrafted/loadtoastlib/MainActivity.java index 62ba024..1cb1f1c 100644 --- a/app/src/main/java/net/steamcrafted/loadtoastlib/MainActivity.java +++ b/app/src/main/java/net/steamcrafted/loadtoastlib/MainActivity.java @@ -4,12 +4,17 @@ import android.content.Intent; import android.graphics.Color; import android.os.Bundle; +import android.os.Handler; +import android.support.v7.app.AppCompatActivity; import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; import net.steamcrafted.loadtoast.LoadToast; +import net.steamcrafted.loadtoast.MaterialProgressDrawable; -public class MainActivity extends Activity { +public class MainActivity extends AppCompatActivity { // Example activity @@ -18,8 +23,19 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - final String text = "Sending reply..."; - final LoadToast lt = new LoadToast(this).setText(text).show(); + final String text = "dhfbsd kjsdfjnskdfs dfs"; + final LoadToast lt = new LoadToast(this) + .setProgressColor(Color.RED) + .setText(text) + .setTranslationY(100) + .setBorderColor(Color.LTGRAY) + .show(); + //lt.success(); + final ViewGroup root = (ViewGroup) findViewById(android.R.id.content); + + View v = new View(this); + v.setBackgroundColor(Color.RED); + //root.addView(v, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 400)); findViewById(R.id.show).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -41,10 +57,19 @@ public void onClick(View view) { findViewById(R.id.refresh).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = getIntent(); - finish(); - startActivity(intent); + View v = new View(MainActivity.this); + v.setBackgroundColor(Color.rgb((int) (Math.random() * 255), (int) (Math.random() * 255), (int) (Math.random() * 255))); + root.addView(v, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 400)); } }); + findViewById(R.id.hide).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + lt.hide(); + } + }); + + ImageView progressView = ((ImageView) findViewById(R.id.progressdrawable)); + MaterialProgressDrawable drawable = new MaterialProgressDrawable(this, progressView); } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index b8c8212..4fa3906 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,6 +6,11 @@ android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" android:id="@+id/main_root"> + +