Skip to content

Commit

Permalink
Add new design to proxy view
Browse files Browse the repository at this point in the history
  • Loading branch information
martenrebane committed Nov 20, 2023
1 parent 88d1ec0 commit bb6cb1e
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
public final class SettingsView extends CoordinatorLayout implements ContentView {

private final Toolbar toolbarView;
private final Button accessCategory;
private final Button rightsCategory;

private final Navigator navigator;

private final ViewDisposables disposables;


private final Button accessCategory;
private final Button rightsCategory;

public SettingsView(Context context) {
this(context, null);
Expand Down Expand Up @@ -71,12 +70,13 @@ public void onAttachedToWindow() {
navigator.execute(
Transaction.push(SettingsSigningScreen.create()))));
disposables.add(clicks(rightsCategory).subscribe(o ->
Transaction.push(SettingsRightsScreen.create())));
navigator.execute(
Transaction.push(SettingsRightsScreen.create()))));
}

@Override
public void onDetachedFromWindow() {
disposables.detach();
super.onDetachedFromWindow();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
package ee.ria.DigiDoc.android.main.settings.proxy;

import static com.jakewharton.rxbinding4.view.RxView.clicks;
import static com.jakewharton.rxbinding4.widget.RxRadioGroup.checkedChanges;
import static com.jakewharton.rxbinding4.widget.RxTextView.textChanges;
import static com.jakewharton.rxbinding4.widget.RxToolbar.navigationClicks;
import static ee.ria.DigiDoc.android.main.settings.util.SettingsUtil.getToolbarViewTitle;
import static ee.ria.DigiDoc.common.ProxySetting.MANUAL_PROXY;
import static ee.ria.DigiDoc.common.ProxySetting.NO_PROXY;
import static ee.ria.DigiDoc.common.ProxySetting.SYSTEM_PROXY;

import android.app.Dialog;
import android.content.Context;
import android.util.AttributeSet;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toolbar;

import androidx.coordinatorlayout.widget.CoordinatorLayout;

import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
Expand All @@ -26,17 +24,15 @@
import ee.ria.DigiDoc.R;
import ee.ria.DigiDoc.android.ApplicationApp;
import ee.ria.DigiDoc.android.main.settings.SettingsDataStore;
import ee.ria.DigiDoc.android.utils.SecureUtil;
import ee.ria.DigiDoc.android.utils.ViewDisposables;
import ee.ria.DigiDoc.android.utils.navigator.Navigator;
import ee.ria.DigiDoc.android.utils.navigator.Transaction;
import ee.ria.DigiDoc.common.ManualProxy;
import ee.ria.DigiDoc.common.ProxySetting;
import ee.ria.DigiDoc.sign.SignLib;
import timber.log.Timber;

public final class SettingsProxyView extends CoordinatorLayout {

private final Toolbar toolbarView;
public class SettingsProxyDialog extends Dialog {

private final Navigator navigator;
private final SettingsDataStore settingsDataStore;
Expand All @@ -58,19 +54,18 @@ public final class SettingsProxyView extends CoordinatorLayout {

private final ManualProxy manualProxySettings;

public SettingsProxyView(Context context) {
this(context, null);
}
private final ImageButton backButton;

public SettingsProxyView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public SettingsProxyDialog(Context context) {
super(context);

Window window = getWindow();
if (window != null) {
SecureUtil.markAsSecure(context, window);
}

setContentView(R.layout.main_settings_proxy_dialog_layout);

public SettingsProxyView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
inflate(context, R.layout.main_settings_proxy, this);
toolbarView = findViewById(R.id.toolbar);
TextView toolbarTitleView = getToolbarViewTitle(toolbarView);
navigator = ApplicationApp.component(context).navigator();
settingsDataStore = ApplicationApp.component(context).settingsDataStore();
disposables = new ViewDisposables();
Expand All @@ -90,25 +85,25 @@ public SettingsProxyView(Context context, AttributeSet attrs, int defStyleAttr)

manualProxySettings = getManualProxySettings();

toolbarView.setTitle(R.string.main_settings_proxy_button);
toolbarView.setNavigationIcon(androidx.appcompat.R.drawable.abc_ic_ab_back_material);
toolbarView.setNavigationContentDescription(R.string.back);

if (toolbarTitleView != null) {
toolbarTitleView.setContentDescription("\u202F");
}
backButton = findViewById(R.id.mainSettingsProxyBackButton);
backButton.requestFocus();

checkActiveProxySetting(settingsDataStore);
checkManualProxySettings(settingsDataStore, manualProxySettings);
checkIsSSLForProxyEnabled(settingsDataStore);

}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
disposables.attach();
disposables.add(navigationClicks(toolbarView).subscribe(o ->
navigator.execute(Transaction.pop())));
disposables.add(clicks(backButton).subscribe(o -> dismiss()));
disposables.add(textChanges(port)
.map(CharSequence::toString)
.subscribe(this::validatePortNumber));
Expand Down Expand Up @@ -145,6 +140,11 @@ public void onDetachedFromWindow() {
super.onDetachedFromWindow();
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
}

private void checkActiveProxySetting(SettingsDataStore settingsDataStore) {
if (settingsDataStore != null) {
ProxySetting currentProxySetting = settingsDataStore.getProxySetting();
Expand Down Expand Up @@ -261,4 +261,4 @@ private static boolean isValidPortNumber(String portNumber) {
return false;
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import ee.ria.DigiDoc.android.main.settings.create.CertificateAddViewModel;
import ee.ria.DigiDoc.android.main.settings.create.ChooseFileScreen;
import ee.ria.DigiDoc.android.main.settings.create.ViewState;
import ee.ria.DigiDoc.android.main.settings.proxy.SettingsProxyDialog;
import ee.ria.DigiDoc.android.main.settings.signing.siva.SettingsSivaDialog;
import ee.ria.DigiDoc.android.signature.detail.CertificateDetailScreen;
import ee.ria.DigiDoc.android.utils.ViewDisposables;
Expand Down Expand Up @@ -64,10 +65,11 @@ public final class SettingsSigningView extends CoordinatorLayout {

private final Button sivaCategory;
private final SettingsSivaDialog sivaDialog;
private final Button proxyCategory;
private final SettingsProxyDialog proxyDialog;

private final Navigator navigator;
private final SettingsDataStore settingsDataStore;
private final ConfigurationProvider configurationProvider;

private final ViewDisposables disposables;
private final CertificateAddViewModel viewModel;
Expand All @@ -94,7 +96,6 @@ public SettingsSigningView(Context context, AttributeSet attrs, int defStyleAttr
TextView toolbarTitleView = getToolbarViewTitle(toolbarView);
navigator = ApplicationApp.component(context).navigator();
settingsDataStore = ApplicationApp.component(context).settingsDataStore();
configurationProvider = ((ApplicationApp) context.getApplicationContext()).getConfigurationProvider();
disposables = new ViewDisposables();

toolbarView.setTitle(R.string.signature_update_title_created);
Expand All @@ -117,7 +118,9 @@ public SettingsSigningView(Context context, AttributeSet attrs, int defStyleAttr
}

sivaCategory = findViewById(R.id.signingSettingsSivaCategory);
proxyCategory = findViewById(R.id.signingSettingsProxyCategory);
sivaDialog = new SettingsSivaDialog(navigator.activity());
proxyDialog = new SettingsProxyDialog(navigator.activity());

askRoleAndAddressSwitch = findViewById(R.id.mainSettingsAskRoleAndAddress);
}
Expand Down Expand Up @@ -207,6 +210,7 @@ public void onAttachedToWindow() {
settingsDataStore.setIsRoleAskingEnabled(isChecked);
}));
disposables.add(clicks(sivaCategory).subscribe(o -> sivaDialog.show()));
disposables.add(clicks(proxyCategory).subscribe(o -> proxyDialog.show()));
disposables.add(viewModel.viewStates().subscribe(this::render));
}

Expand Down
28 changes: 0 additions & 28 deletions app/src/main/res/layout/main_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,34 +69,6 @@

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/material_baseline_grid_2.5x"
android:layout_marginBottom="@dimen/material_baseline_grid_2.5x">

<Button
android:id="@id/mainSettingsProxyCategory"
style="@style/MaterialTypography.Regular.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_icon_access_padded"
android:drawableEnd="@drawable/ic_baseline_keyboard_arrow_right_24"
android:textColor="@color/material_color_black"
android:textSize="@dimen/material_baseline_grid_2x"
android:textAllCaps="false"
android:drawableTint="@color/material_color_black"
android:background="@null"
android:padding="0dp"
android:layout_margin="0dp"
android:minHeight="0dp"
android:minWidth="0dp"
android:gravity="center_vertical"
android:contentDescription="@string/main_settings_proxy_button"
android:text="@string/main_settings_proxy_button" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
Loading

0 comments on commit bb6cb1e

Please sign in to comment.