forked from j62/ctbrec
Add Flirt4Free config UI
This commit is contained in:
parent
3cd341d88e
commit
80071a1eb4
|
@ -0,0 +1,86 @@
|
|||
package ctbrec.ui.sites.flirt4free;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Settings;
|
||||
import ctbrec.sites.flirt4free.Flirt4Free;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.settings.SettingsTab;
|
||||
import ctbrec.ui.sites.AbstractConfigUI;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
public class Flirt4FreeConfigUI extends AbstractConfigUI {
|
||||
private Flirt4Free flirt4free;
|
||||
|
||||
public Flirt4FreeConfigUI(Flirt4Free flirt4free) {
|
||||
this.flirt4free = flirt4free;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parent createConfigPanel() {
|
||||
GridPane layout = SettingsTab.createGridLayout();
|
||||
Settings settings = Config.getInstance().getSettings();
|
||||
|
||||
int row = 0;
|
||||
Label l = new Label("Active");
|
||||
layout.add(l, 0, row);
|
||||
CheckBox enabled = new CheckBox();
|
||||
enabled.setSelected(!settings.disabledSites.contains(flirt4free.getName()));
|
||||
enabled.setOnAction((e) -> {
|
||||
if(enabled.isSelected()) {
|
||||
settings.disabledSites.remove(flirt4free.getName());
|
||||
} else {
|
||||
settings.disabledSites.add(flirt4free.getName());
|
||||
}
|
||||
save();
|
||||
});
|
||||
GridPane.setMargin(enabled, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||
layout.add(enabled, 1, row++);
|
||||
|
||||
layout.add(new Label("Flirt4Free User"), 0, row);
|
||||
TextField username = new TextField(settings.flirt4freeUsername);
|
||||
username.textProperty().addListener((ob, o, n) -> {
|
||||
if(!n.equals(Config.getInstance().getSettings().flirt4freeUsername)) {
|
||||
Config.getInstance().getSettings().flirt4freeUsername = username.getText();
|
||||
flirt4free.getHttpClient().logout();
|
||||
save();
|
||||
}
|
||||
});
|
||||
GridPane.setFillWidth(username, true);
|
||||
GridPane.setHgrow(username, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(username, 2);
|
||||
layout.add(username, 1, row++);
|
||||
|
||||
layout.add(new Label("Flirt4Free Password"), 0, row);
|
||||
PasswordField password = new PasswordField();
|
||||
password.setText(settings.flirt4freePassword);
|
||||
password.textProperty().addListener((ob, o, n) -> {
|
||||
if(!n.equals(Config.getInstance().getSettings().flirt4freePassword)) {
|
||||
Config.getInstance().getSettings().flirt4freePassword = password.getText();
|
||||
flirt4free.getHttpClient().logout();
|
||||
save();
|
||||
}
|
||||
});
|
||||
GridPane.setFillWidth(password, true);
|
||||
GridPane.setHgrow(password, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(password, 2);
|
||||
layout.add(password, 1, row++);
|
||||
|
||||
Button createAccount = new Button("Create new Account");
|
||||
createAccount.setOnAction((e) -> DesktopIntegration.open(flirt4free.getAffiliateLink()));
|
||||
layout.add(createAccount, 1, row++);
|
||||
GridPane.setColumnSpan(createAccount, 2);
|
||||
GridPane.setMargin(username, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||
GridPane.setMargin(password, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||
GridPane.setMargin(createAccount, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||
return layout;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,9 +2,6 @@ package ctbrec.ui.sites.flirt4free;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.flirt4free.Flirt4Free;
|
||||
import ctbrec.ui.TabProvider;
|
||||
|
@ -12,14 +9,14 @@ import ctbrec.ui.sites.AbstractSiteUi;
|
|||
|
||||
public class Flirt4FreeSiteUi extends AbstractSiteUi {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(Flirt4FreeSiteUi.class);
|
||||
private Flirt4Free flirt4Free;
|
||||
private Flirt4FreeTabProvider tabProvider;
|
||||
private Flirt4FreeConfigUI configUi;
|
||||
|
||||
public Flirt4FreeSiteUi(Flirt4Free flirt4Free) {
|
||||
this.flirt4Free = flirt4Free;
|
||||
tabProvider = new Flirt4FreeTabProvider(flirt4Free);
|
||||
//configUi = new LiveJasminConfigUi(liveJasmin);
|
||||
configUi = new Flirt4FreeConfigUI(flirt4Free);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,11 +26,11 @@ public class Flirt4FreeSiteUi extends AbstractSiteUi {
|
|||
|
||||
@Override
|
||||
public ConfigUI getConfigUI() {
|
||||
return null;
|
||||
return configUi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean login() throws IOException {
|
||||
return false;
|
||||
return flirt4Free.login();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue