Skip to content

Commit

Permalink
Merge pull request #9 from m1ga/feat
Browse files Browse the repository at this point in the history
android: Parity with iOS
  • Loading branch information
hansemannn authored Oct 24, 2020
2 parents 7079088 + a9d6314 commit e91c8e4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import NotificationBanner from 'ti.notificationbanner';
NotificationBanner.show({
title: 'Titanium rocks!',
duration: 2,

// iOS only for now
subtitle: 'It seriously does',
backgroundColor: 'green',
});
Expand All @@ -32,7 +30,7 @@ NotificationBanner.show({
- `backgroundColor` (Optional)
- `duration` (Optional)

## License
## License

MIT

Expand Down
Binary file removed android/dist/ti.notificationbanner-android-2.0.0.zip
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 2.0.0
version: 3.0.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: titanium-notification-banner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import org.appcelerator.titanium.util.TiConvert;

import android.app.Activity;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.CoordinatorLayout;
import android.view.ViewGroup;

import com.tapadoo.alerter.Alerter;

Expand All @@ -39,9 +36,9 @@ public void show(KrollDict args)
{
Activity currentActivity = TiApplication.getAppCurrentActivity();
int duration = args.getInt("duration");
String title = args.getString("title");
String subtitle = args.getString("subtitle");
int color = TiConvert.toColor(args.getString("color"));
String title = args.optString("title", "");
String subtitle = args.optString("subtitle", "");
String bgColor = args.optString("backgroundColor", "");

final KrollFunction callback = (KrollFunction) args.get("onClick");

Expand All @@ -50,7 +47,7 @@ public void show(KrollDict args)
return;
}

Alerter.create(currentActivity)
Alerter alerter = Alerter.create(currentActivity)
.setTitle(title)
.setText(subtitle)
.setOnClickListener(new View.OnClickListener() {
Expand All @@ -59,13 +56,22 @@ public void onClick(View view) {
KrollDict dict = new KrollDict();
callback.call(getKrollObject(), dict);
}
})
.show();
});

if (duration > 0) {
alerter.setDuration(duration * 1000);
}

if (bgColor != "") {
int backgroundColor = TiConvert.toColor(bgColor);
alerter.setBackgroundColorInt(backgroundColor);
}

alerter.show();
}

@Kroll.method
public void hide() {
Alerter.hide();
}
}
}

0 comments on commit e91c8e4

Please sign in to comment.