Commit 5df60dca by Karthik

migrated to androidX

parent f6fc0a87
## [3.0.0]
* Migrated to AndroidX
## [2.2.12]
* Incomplete Text Fix
......
......@@ -7,13 +7,13 @@ Android and iOS Toast Library for Flutter
> * Android
> * IOS
If your project uses androidx then use `fluttertoast` version `2.2.4` or `2.2.5`
If you dont want to use androidx then use `fluttertoast` version `2.2.12`
## How to Use
```yaml
# add this line to your dependencies
fluttertoast: ^2.2.12
fluttertoast: ^3.0.0
```
```dart
......
......@@ -26,7 +26,7 @@ android {
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
......@@ -34,6 +34,6 @@ android {
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-compat:27.1.1'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.core:core:1.0.0-beta01'
}
......@@ -11,7 +11,7 @@ import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import android.support.v4.content.ContextCompat;
import androidx.core.content.ContextCompat;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
......@@ -22,6 +22,7 @@ import io.flutter.plugin.common.PluginRegistry.Registrar;
public class FluttertoastPlugin implements MethodCallHandler {
Context ctx;
Toast toast;
FluttertoastPlugin(Context context) {
ctx = context;
......@@ -44,7 +45,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
Number textSize = call.argument("fontSize");
final Toast toast = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT);
toast = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT);
toast.setText(msg);
......@@ -55,19 +56,19 @@ public class FluttertoastPlugin implements MethodCallHandler {
}
Boolean sent = false;
final Handler handler = new Handler();
final Runnable run = new Runnable() {
@Override
public void run() {
try {
result.success(false);
} catch (Exception e){
e.printStackTrace();
}
}
};
// final Handler handler = new Handler();
// final Runnable run = new Runnable() {
//
// @Override
// public void run() {
// try {
// result.success(false);
//
// } catch (Exception e){
// e.printStackTrace();
// }
// }
// };
switch (gravity) {
......@@ -82,6 +83,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
}
final TextView text = toast.getView().findViewById(android.R.id.message);
if(textSize != null)
text.setTextSize(textSize.floatValue());
text.setMaxLines(1);
......@@ -94,34 +96,39 @@ public class FluttertoastPlugin implements MethodCallHandler {
if (Build.VERSION.SDK_INT <= 27) {
toast.getView().setBackground(shapeDrawable);
} else {
toast.getView().setBackground(null);
text.setBackground(shapeDrawable);
}
}
}
text.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
handler.removeCallbacks(run);
text.setOnTouchListener(null);
toast.cancel();
try {
result.success(true);
} catch (Exception e){
e.printStackTrace();
}
return false;
}
});
// text.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(View v, MotionEvent event) {
// handler.removeCallbacks(run);
// text.setOnTouchListener(null);
// toast.cancel();
// try {
// result.success(true);
// } catch (Exception e){
// e.printStackTrace();
// }
//
// return false;
// }
// });
if(textcolor != null) {
text.setTextColor(textcolor.intValue());
}
toast.show();
handler.postDelayed(run,toast.getDuration()*1000);
result.success(true);
// handler.postDelayed(run,toast.getDuration()*1000);
} else if(call.method.equals("cancel")){
if(toast != null)
toast.cancel();
result.success(true);
} else {
result.notImplemented();
}
......
......@@ -7,8 +7,8 @@
android:color="#000000">
</solid>
<padding
android:left="10dp"
android:top="8dp"
android:right="10dp"
android:bottom="8dp" />
android:left="16dp"
android:top="12dp"
android:right="16dp"
android:bottom="12dp" />
</shape>
\ No newline at end of file
......@@ -38,7 +38,7 @@ android {
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
......@@ -56,6 +56,8 @@ flutter {
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
name: fluttertoast
description: Toast Library for FLutter
version: 2.2.12
version: 3.0.0
author: Karthik Ponnam <ponnamkarthik3@gmail.com>
homepage: https://github.com/PonnamKarthik/FlutterToast
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment