import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModel;
-import net.ktnx.mobileledger.async.SendTransactionTask;
+import net.ktnx.mobileledger.App;
+import net.ktnx.mobileledger.json.API;
import net.ktnx.mobileledger.model.Currency;
import net.ktnx.mobileledger.model.HledgerVersion;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
private final MutableLiveData<Boolean> showCommodityByDefault = new MutableLiveData<>(false);
private final MutableLiveData<Boolean> showCommentsByDefault = new MutableLiveData<>(true);
private final MutableLiveData<Boolean> useAuthentication = new MutableLiveData<>(false);
- private final MutableLiveData<SendTransactionTask.API> apiVersion =
- new MutableLiveData<>(SendTransactionTask.API.auto);
+ private final MutableLiveData<API> apiVersion = new MutableLiveData<>(API.auto);
private final MutableLiveData<String> url = new MutableLiveData<>(null);
private final MutableLiveData<String> authUserName = new MutableLiveData<>(null);
private final MutableLiveData<String> authPassword = new MutableLiveData<>(null);
void observeShowCommodityByDefault(LifecycleOwner lfo, Observer<Boolean> o) {
showCommodityByDefault.observe(lfo, o);
}
- Boolean getUseAuthentication() {
+ public Boolean getUseAuthentication() {
return useAuthentication.getValue();
}
void setUseAuthentication(boolean newValue) {
void observeUseAuthentication(LifecycleOwner lfo, Observer<Boolean> o) {
useAuthentication.observe(lfo, o);
}
- SendTransactionTask.API getApiVersion() {
+ API getApiVersion() {
return apiVersion.getValue();
}
- void setApiVersion(SendTransactionTask.API newValue) {
+ void setApiVersion(API newValue) {
if (newValue != apiVersion.getValue())
apiVersion.setValue(newValue);
}
- void observeApiVersion(LifecycleOwner lfo, Observer<SendTransactionTask.API> o) {
+ void observeApiVersion(LifecycleOwner lfo, Observer<API> o) {
apiVersion.observe(lfo, o);
}
HledgerVersion getDetectedVersion() { return detectedVersion.getValue(); }
void observeDetectedVersion(LifecycleOwner lfo, Observer<HledgerVersion> o) {
detectedVersion.observe(lfo, o);
}
- String getUrl() {
+ public String getUrl() {
return url.getValue();
}
void setUrl(String newValue) {
void observeUrl(LifecycleOwner lfo, Observer<String> o) {
url.observe(lfo, o);
}
- String getAuthUserName() {
+ public String getAuthUserName() {
return authUserName.getValue();
}
void setAuthUserName(String newValue) {
void observeUserName(LifecycleOwner lfo, Observer<String> o) {
authUserName.observe(lfo, o);
}
- String getAuthPassword() {
+ public String getAuthPassword() {
return authPassword.getValue();
}
void setAuthPassword(String newValue) {
showCommentsByDefault.setValue(true);
showCommodityByDefault.setValue(false);
setFutureDates(MobileLedgerProfile.FutureDates.None);
- setApiVersion(SendTransactionTask.API.auto);
+ setApiVersion(API.auto);
useAuthentication.setValue(false);
authUserName.setValue("");
authPassword.setValue("");
this.model = model;
}
private HledgerVersion detectVersion() {
+ App.setAuthenticationDataFromProfileModel(model);
HttpURLConnection http = null;
try {
http = NetworkUtil.prepareConnection(model.getUrl(), "version",
e.printStackTrace();
return null;
}
+ finally {
+ App.resetAuthenticationData();
+ }
}
@Override
public void run() {