Add buttons to open Chaturbate to register a new account or buy tokens

This commit is contained in:
0xboobface 2018-10-05 19:01:52 +02:00
parent c8eda9303b
commit 46301fc379
3 changed files with 29 additions and 4 deletions

View File

@ -40,6 +40,7 @@ public class CtbrecApplication extends Application {
static final transient Logger LOG = LoggerFactory.getLogger(CtbrecApplication.class);
public static final String BASE_URI = "https://chaturbate.com";
public static final String AFFILIATE_LINK = BASE_URI + "/in/?track=default&tour=LQps&campaign=55vTi&room=0xb00bface";
private Config config;
private Recorder recorder;

View File

@ -187,23 +187,29 @@ public class SettingsTab extends Tab implements TabSelectionListener {
GridPane.setColumnSpan(password, 2);
layout.add(password, 1, 1);
Button createAccount = new Button("Create new Account");
createAccount.setOnAction((e) -> DesktopIntergation.open(CtbrecApplication.AFFILIATE_LINK));
layout.add(createAccount, 1, 2);
GridPane.setColumnSpan(createAccount, 2);
l = new Label("Record all followed models");
layout.add(l, 0, 2);
layout.add(l, 0, 3);
autoRecordFollowed = new CheckBox();
autoRecordFollowed.setSelected(Config.getInstance().getSettings().recordFollowed);
autoRecordFollowed.setOnAction((e) -> {
Config.getInstance().getSettings().recordFollowed = autoRecordFollowed.isSelected();
showRestartRequired();
});
layout.add(autoRecordFollowed, 1, 2);
layout.add(autoRecordFollowed, 1, 3);
Label warning = new Label("Don't do this, if you follow many models. You have been warned ;) !");
warning.setTextFill(Color.RED);
layout.add(warning, 2, 2);
layout.add(warning, 2, 3);
GridPane.setMargin(l, new Insets(3, 0, 0, 0));
GridPane.setMargin(warning, new Insets(3, 0, 0, 0));
GridPane.setMargin(autoRecordFollowed, new Insets(3, 0, 0, CHECKBOX_MARGIN));
GridPane.setMargin(username, new Insets(0, 0, 0, CHECKBOX_MARGIN));
GridPane.setMargin(password, new Insets(0, 0, 0, CHECKBOX_MARGIN));
GridPane.setMargin(createAccount, new Insets(0, 0, 0, CHECKBOX_MARGIN));
ctb = new TitledPane("Chaturbate", layout);
ctb.setCollapsible(false);

View File

@ -12,6 +12,7 @@ import ctbrec.Model;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TextInputDialog;
import okhttp3.Request;
import okhttp3.Response;
@ -26,6 +27,7 @@ public class TipDialog extends TextInputDialog {
setHeaderText("Loading token balance…");
setContentText("Amount of tokens to tip:");
setResizable(true);
getEditor().setDisable(true);
}
private void loadTokenBalance() {
@ -55,7 +57,23 @@ public class TipDialog extends TextInputDialog {
protected void done() {
try {
int tokens = get();
Platform.runLater(() -> setHeaderText("Current token balance: " + tokens));
Platform.runLater(() -> {
if (tokens <= 0) {
String msg = "Do you want to buy tokens now?\n\nIf you agree, Chaturbate will open in a browser. "
+ "The used address is an affiliate link, which supports me, but doesn't cost you anything more.";
Alert buyTokens = new AutosizeAlert(Alert.AlertType.CONFIRMATION, msg, ButtonType.NO, ButtonType.YES);
buyTokens.setTitle("No tokens");
buyTokens.setHeaderText("You don't have any tokens");
buyTokens.showAndWait();
TipDialog.this.close();
if(buyTokens.getResult() == ButtonType.YES) {
DesktopIntergation.open(CtbrecApplication.AFFILIATE_LINK);
}
} else {
getEditor().setDisable(false);
setHeaderText("Current token balance: " + tokens);
}
});
} catch (InterruptedException | ExecutionException e) {
LOG.error("Couldn't retrieve account balance", e);
showErrorDialog(e);