import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
+import android.widget.PopupMenu;
import android.widget.Switch;
import android.widget.TextView;
private TextInputLayout preferredAccountsFilterLayout;
private View huePickerView;
private View insecureWarningText;
+ private TextView futureDatesText;
+ private MobileLedgerProfile.FutureDates futureDates;
+ private View futureDatesLayout;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
mProfile.setAuthUserName(userName.getText());
mProfile.setAuthPassword(password.getText());
mProfile.setThemeId(huePickerView.getTag());
+ mProfile.setFutureDates(futureDates);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
url = rootView.findViewById(R.id.url);
urlLayout = rootView.findViewById(R.id.url_layout);
postingPermitted = rootView.findViewById(R.id.profile_permit_posting);
+ futureDatesLayout = rootView.findViewById(R.id.future_dates_layout);
+ futureDatesText = rootView.findViewById(R.id.future_dates_text);
+ rootView.findViewById(R.id.future_dates_layout)
+ .setOnClickListener(v -> {
+ MenuInflater mi = new MenuInflater(getContext());
+ PopupMenu menu = new PopupMenu(getContext(), v);
+ menu.inflate(R.menu.future_dates);
+ menu.setOnMenuItemClickListener(item -> {
+ switch (item.getItemId()) {
+ case R.id.menu_future_dates_30:
+ futureDates = MobileLedgerProfile.FutureDates.OneMonth;
+ break;
+ case R.id.menu_future_dates_60:
+ futureDates = MobileLedgerProfile.FutureDates.TwoMonths;
+ break;
+ case R.id.menu_future_dates_90:
+ futureDates = MobileLedgerProfile.FutureDates.ThreeMonths;
+ break;
+ case R.id.menu_future_dates_180:
+ futureDates = MobileLedgerProfile.FutureDates.SixMonths;
+ break;
+ case R.id.menu_future_dates_365:
+ futureDates = MobileLedgerProfile.FutureDates.OneYear;
+ break;
+ case R.id.menu_future_dates_all:
+ futureDates = MobileLedgerProfile.FutureDates.All;
+ break;
+ default:
+ futureDates = MobileLedgerProfile.FutureDates.None;
+ }
+ futureDatesText.setText(futureDates.getText(getResources()));
+ return true;
+ });
+ menu.show();
+ });
authParams = rootView.findViewById(R.id.auth_params);
useAuthentication = rootView.findViewById(R.id.enable_http_auth);
userName = rootView.findViewById(R.id.auth_user_name);
checkInsecureSchemeWithAuth();
});
- postingPermitted.setOnCheckedChangeListener(
- ((buttonView, isChecked) -> preferredAccountsFilterLayout
- .setVisibility(isChecked ? View.VISIBLE : View.GONE)));
+ postingPermitted.setOnCheckedChangeListener(((buttonView, isChecked) -> {
+ preferredAccountsFilterLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
+ futureDatesLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
+ }));
hookClearErrorOnFocusListener(profileName, profileNameLayout);
hookClearErrorOnFocusListener(url, urlLayout);
if (mProfile != null) {
profileName.setText(mProfile.getName());
postingPermitted.setChecked(mProfile.isPostingPermitted());
+ futureDates = mProfile.getFutureDates();
+ futureDatesText.setText(futureDates.getText(getResources()));
url.setText(mProfile.getUrl());
useAuthentication.setChecked(mProfile.isAuthEnabled());
authParams.setVisibility(mProfile.isAuthEnabled() ? View.VISIBLE : View.GONE);
profileName.setText("");
url.setText(HTTPS_URL_START);
postingPermitted.setChecked(true);
+ futureDates = MobileLedgerProfile.FutureDates.None;
+ futureDatesText.setText(futureDates.getText(getResources()));
useAuthentication.setChecked(false);
authParams.setVisibility(View.GONE);
userName.setText("");
android:layout_marginBottom="16dp"
android:text="@string/posting_permitted" />
+ <LinearLayout
+ android:id="@+id/future_dates_layout"
+ android:layout_width="match_parent"
+ android:layout_marginBottom="16dp"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/future_dates_title"
+ android:textAppearance="?android:textAppearanceListItem"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/profile_future_dates_label" />
+
+ <TextView
+ android:id="@+id/future_dates_text"
+ android:textAppearance="?android:textAppearanceListItemSecondary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textColor="?attr/textColor"/>
+ </LinearLayout>
+
<Switch
android:id="@+id/enable_http_auth"
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:title="@string/future_dates_none" android:id="@+id/menu_future_dates_none"/>
+ <item android:title="@string/future_dates_30" android:id="@+id/menu_future_dates_30"/>
+ <item android:title="@string/future_dates_60" android:id="@+id/menu_future_dates_60"/>
+ <item android:title="@string/future_dates_90" android:id="@+id/menu_future_dates_90"/>
+ <item android:title="@string/future_dates_180" android:id="@+id/menu_future_dates_180"/>
+ <item android:title="@string/future_dates_365" android:id="@+id/menu_future_dates_365"/>
+ <item android:title="@string/future_dates_all" android:id="@+id/menu_future_dates_all"/>
+</menu>
\ No newline at end of file