import net.ktnx.mobileledger.BuildConfig;
import net.ktnx.mobileledger.R;
+import net.ktnx.mobileledger.async.SendTransactionTask;
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
import net.ktnx.mobileledger.ui.HueRingDialog;
private TextView futureDatesText;
private MobileLedgerProfile.FutureDates futureDates;
private View futureDatesLayout;
+ private TextView apiVersionText;
+ private View apiVersionLayout;
+ private SendTransactionTask.API apiVersion;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
});
menu.show();
});
+ apiVersionLayout = context.findViewById(R.id.api_version_layout);
+ apiVersionText = context.findViewById(R.id.api_version_text);
+ apiVersionLayout.setOnClickListener(v -> {
+ MenuInflater mi = new MenuInflater(context);
+ PopupMenu menu = new PopupMenu(context, v);
+ menu.inflate(R.menu.api_version);
+ menu.setOnMenuItemClickListener(item -> {
+ switch (item.getItemId()) {
+ case R.id.api_version_menu_auto:
+ apiVersion = SendTransactionTask.API.auto;
+ break;
+ case R.id.api_version_menu_html:
+ apiVersion = SendTransactionTask.API.html;
+ break;
+ case R.id.api_version_menu_post_1_14:
+ apiVersion = SendTransactionTask.API.post_1_14;
+ break;
+ case R.id.api_version_menu_pre_1_15:
+ apiVersion = SendTransactionTask.API.pre_1_15;
+ break;
+ default:
+ apiVersion = SendTransactionTask.API.auto;
+ }
+ apiVersionText.setText(apiVersion.getDescription(getResources()));
+ return true;
+ });
+ menu.show();
+ });
authParams = context.findViewById(R.id.auth_params);
useAuthentication = context.findViewById(R.id.enable_http_auth);
userName = context.findViewById(R.id.auth_user_name);
postingPermitted.setChecked(mProfile.isPostingPermitted());
futureDates = mProfile.getFutureDates();
futureDatesText.setText(futureDates.getText(getResources()));
+ apiVersion = mProfile.getApiVersion();
+ apiVersionText.setText(apiVersion.getDescription(getResources()));
url.setText(mProfile.getUrl());
useAuthentication.setChecked(mProfile.isAuthEnabled());
authParams.setVisibility(mProfile.isAuthEnabled() ? View.VISIBLE : View.GONE);
postingPermitted.setChecked(true);
futureDates = MobileLedgerProfile.FutureDates.None;
futureDatesText.setText(futureDates.getText(getResources()));
+ apiVersion = SendTransactionTask.API.auto;
+ apiVersionText.setText(apiVersion.getDescription(getResources()));
useAuthentication.setChecked(false);
authParams.setVisibility(View.GONE);
userName.setText("");
mProfile.setAuthPassword(password.getText());
mProfile.setThemeId(huePickerView.getTag());
mProfile.setFutureDates(futureDates);
+ mProfile.setApiVersion(apiVersion);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
</LinearLayout>
+ <LinearLayout
+ android:id="@+id/api_version_layout"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/profile_api_version_title"
+ android:textAppearance="?android:textAppearanceListItem" />
+
+ <TextView
+ android:id="@+id/api_version_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:textAppearanceListItemSecondary"
+ android:textColor="?attr/textColor" />
+ </LinearLayout>
+
<Switch
android:id="@+id/profile_permit_posting"
android:layout_width="match_parent"
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright © 2019 Damyan Ivanov.
+ ~ This file is part of MoLe.
+ ~ MoLe is free software: you can distribute it and/or modify it
+ ~ under the term of the GNU General Public License as published by
+ ~ the Free Software Foundation, either version 3 of the License, or
+ ~ (at your opinion), any later version.
+ ~
+ ~ MoLe is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ~ GNU General Public License terms for details.
+ ~
+ ~ You should have received a copy of the GNU General Public License
+ ~ along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/api_version_menu_auto"
+ android:title="@string/api_auto" />
+ <item
+ android:id="@+id/api_version_menu_post_1_14"
+ android:title="@string/api_post_1_14" />
+ <item
+ android:id="@+id/api_version_menu_pre_1_15"
+ android:title="@string/api_pre_1_15" />
+ <item
+ android:id="@+id/api_version_menu_html"
+ android:title="@string/api_html" />
+</menu>
\ No newline at end of file
<string name="future_dates_none">Без въвеждане на бъдещи дати</string>
<string name="profile_future_dates_label">Въвеждане на дати в бъдещето</string>
<string name="api_auto">Автоматично откриване</string>
- <string name="api_html">Симулиране на заявка от браузър</string>
- <string name="api_post_1_14">версия 1.15 и по-нови</string>
- <string name="api_pre_1_15">версии преди 1.15</string>
+ <string name="api_html">Версия преди 1.14</string>
+ <string name="api_post_1_14">Версия 1.15 или по-нова</string>
+ <string name="api_pre_1_15">Версия 1.14.x</string>
+ <string name="profile_api_version_title">Версия на сървъра</string>
</resources>
<string name="future_dates_180">Up to six months</string>
<string name="future_dates_365">Up to a year</string>
<string name="future_dates_all">Without restrictions</string>
- <string name="api_html">Simulate HTML form</string>
- <string name="api_pre_1_15">version before 1.15</string>
- <string name="api_post_1_14">version 1.15 and above</string>
+ <string name="api_html">Version before 1.14</string>
+ <string name="api_pre_1_15">Version 1.14.x</string>
+ <string name="api_post_1_14">Version 1.15 and above</string>
<string name="api_auto">Detect automaticaly</string>
+ <string name="profile_api_version_title">Backend server version</string>
</resources>