mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
use new proxy screen in RegistrationActivity
This commit is contained in:
@@ -90,6 +90,12 @@ public class ProxySettingsActivity extends BaseActionBarActivity {
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
private void focusListener(View view, boolean focused, VerificationType type) {
|
||||
|
||||
if (!focused) {
|
||||
|
||||
@@ -96,7 +96,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
Spinner certCheck;
|
||||
|
||||
private SwitchCompat proxySwitch;
|
||||
private Group proxyGroup;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
@@ -127,15 +126,11 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
authMethod = findViewById(R.id.auth_method);
|
||||
certCheck = findViewById(R.id.cert_check);
|
||||
|
||||
proxyGroup = findViewById(R.id.socks5_group);
|
||||
proxySwitch = findViewById(R.id.socks5_switch);
|
||||
proxySwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
proxyGroup.setVisibility(isChecked? advancedGroup.getVisibility() : View.GONE);
|
||||
proxySwitch = findViewById(R.id.proxy_settings);
|
||||
proxySwitch.setOnClickListener(l -> {
|
||||
proxySwitch.setChecked(!proxySwitch.isChecked()); // revert toggle
|
||||
startActivity(new Intent(this, ProxySettingsActivity.class));
|
||||
});
|
||||
TextInputEditText proxyHostInput = findViewById(R.id.socks5_host_text);
|
||||
TextInputEditText proxyPortInput = findViewById(R.id.socks5_port_text);
|
||||
proxyHostInput.setOnFocusChangeListener((view, focused) -> focusListener(view, focused, VerificationType.SERVER));
|
||||
proxyPortInput.setOnFocusChangeListener((view, focused) -> focusListener(view, focused, VerificationType.PORT));
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
@@ -161,7 +156,16 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
advancedIcon.setOnClickListener(l -> onAdvancedSettings());
|
||||
advancedIcon.setRotation(45);
|
||||
viewLogText.setOnClickListener((view) -> showLog());
|
||||
|
||||
boolean isConfigured = DcHelper.isConfigured(getApplicationContext());
|
||||
boolean expandAdvanced = false;
|
||||
String strVal;
|
||||
int intVal;
|
||||
|
||||
intVal = DcHelper.getInt(this, CONFIG_SOCKS5_ENABLED);
|
||||
proxySwitch.setChecked(intVal == 1);
|
||||
expandAdvanced = expandAdvanced || intVal == 1;
|
||||
|
||||
if (isConfigured) {
|
||||
String email = DcHelper.get(this, CONFIG_ADDRESS);
|
||||
emailInput.setText(email);
|
||||
@@ -170,10 +174,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
}
|
||||
passwordInput.setText(DcHelper.get(this, CONFIG_MAIL_PASSWORD));
|
||||
|
||||
boolean expandAdvanced = false;
|
||||
String strVal;
|
||||
int intVal;
|
||||
|
||||
TextInputEditText imapLoginInput = findViewById(R.id.imap_login_text);
|
||||
strVal = DcHelper.get(this, CONFIG_MAIL_USER);
|
||||
imapLoginInput.setText(strVal);
|
||||
@@ -213,17 +213,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
smtpSecurity.setSelection(intVal);
|
||||
expandAdvanced = expandAdvanced || intVal != 0;
|
||||
|
||||
intVal = DcHelper.getInt(this, CONFIG_SOCKS5_ENABLED);
|
||||
proxySwitch.setChecked(intVal == 1);
|
||||
expandAdvanced = expandAdvanced || intVal == 1;
|
||||
|
||||
proxyHostInput.setText(DcHelper.get(this, CONFIG_SOCKS5_HOST));
|
||||
proxyPortInput.setText(DcHelper.get(this, CONFIG_SOCKS5_PORT));
|
||||
TextInputEditText proxyUserInput = findViewById(R.id.socks5_user_text);
|
||||
TextInputEditText proxyPasswordInput = findViewById(R.id.socks5_password_text);
|
||||
proxyUserInput.setText(DcHelper.get(this, CONFIG_SOCKS5_USER));
|
||||
proxyPasswordInput.setText(DcHelper.get(this, CONFIG_SOCKS5_PASSWORD));
|
||||
|
||||
int serverFlags = DcHelper.getInt(this, CONFIG_SERVER_FLAGS);
|
||||
int sel = 0;
|
||||
if((serverFlags&DcContext.DC_LP_AUTH_OAUTH2)!=0) {
|
||||
@@ -242,8 +231,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
int certCheckFlags = DcHelper.getInt(this, "imap_certificate_checks");
|
||||
certCheck.setSelection(certCheckFlags);
|
||||
expandAdvanced = expandAdvanced || certCheckFlags != 0;
|
||||
|
||||
if (expandAdvanced) { onAdvancedSettings(); }
|
||||
} else if (getIntent() != null && getIntent().getBundleExtra(ACCOUNT_DATA) != null) {
|
||||
// Companion app might have sent account data
|
||||
Bundle b = getIntent().getBundleExtra(ACCOUNT_DATA);
|
||||
@@ -261,6 +248,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
}
|
||||
}
|
||||
|
||||
if (expandAdvanced) { onAdvancedSettings(); }
|
||||
registerForEvents();
|
||||
}
|
||||
|
||||
@@ -272,6 +260,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
dynamicTheme.onResume(this);
|
||||
proxySwitch.setChecked(DcHelper.getInt(this, CONFIG_SOCKS5_ENABLED) == 1);
|
||||
}
|
||||
|
||||
private void showLog() {
|
||||
@@ -574,12 +563,10 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
private void onAdvancedSettings() {
|
||||
boolean advancedViewVisible = advancedGroup.getVisibility() == View.VISIBLE;
|
||||
if (advancedViewVisible) {
|
||||
proxyGroup.setVisibility(View.GONE);
|
||||
advancedGroup.setVisibility(View.GONE);
|
||||
advancedIcon.setRotation(45);
|
||||
} else {
|
||||
advancedGroup.setVisibility(View.VISIBLE);
|
||||
if (proxySwitch.isChecked()) proxyGroup.setVisibility(View.VISIBLE);
|
||||
advancedIcon.setRotation(0);
|
||||
}
|
||||
}
|
||||
@@ -621,15 +608,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
|
||||
setConfig(R.id.smtp_port_text, CONFIG_SEND_PORT, true);
|
||||
setConfig(R.id.smtp_login_text, CONFIG_SEND_USER, false);
|
||||
setConfig(R.id.smtp_password_text, CONFIG_SEND_PASSWORD, false);
|
||||
if (proxySwitch.isChecked()) {
|
||||
DcHelper.getContext(this).setConfigInt(CONFIG_SOCKS5_ENABLED, 1);
|
||||
setConfig(R.id.socks5_host_text, CONFIG_SOCKS5_HOST, true);
|
||||
setConfig(R.id.socks5_port_text, CONFIG_SOCKS5_PORT, true);
|
||||
setConfig(R.id.socks5_user_text, CONFIG_SOCKS5_USER, true);
|
||||
setConfig(R.id.socks5_password_text, CONFIG_SOCKS5_PASSWORD, false);
|
||||
} else {
|
||||
DcHelper.getContext(this).setConfigInt(CONFIG_SOCKS5_ENABLED, 0);
|
||||
}
|
||||
|
||||
DcHelper.getContext(this).setConfigInt(CONFIG_MAIL_SECURITY, imapSecurity.getSelectedItemPosition());
|
||||
DcHelper.getContext(this).setConfigInt(CONFIG_SEND_SECURITY, smtpSecurity.getSelectedItemPosition());
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
app:constraint_referenced_ids="inbox, imap_login, imap_server, imap_port, imap_security_label, imap_security, outbox_view_spacer_top,
|
||||
outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, auth_method_label, auth_method, cert_check_label, cert_check, view_log_button, socks5_switch" />
|
||||
outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, auth_method_label, auth_method, cert_check_label, cert_check, view_log_button, proxy_settings" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/advanced_icon"
|
||||
@@ -151,6 +151,17 @@
|
||||
app:layout_constraintStart_toEndOf="@id/advanced_icon"
|
||||
app:layout_constraintTop_toBottomOf="@id/no_servers_hint" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/proxy_settings"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="@string/proxy_use_proxy"
|
||||
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
|
||||
app:layout_constraintTop_toBottomOf="@id/advanced_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/inbox"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -159,7 +170,7 @@
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/login_inbox"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
|
||||
app:layout_constraintTop_toBottomOf="@id/advanced_text" />
|
||||
app:layout_constraintTop_toBottomOf="@id/proxy_settings" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/imap_login"
|
||||
@@ -378,110 +389,6 @@
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
|
||||
app:layout_constraintTop_toBottomOf="@id/cert_check_label" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/socks5_switch"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="@string/login_socks5_use_socks5"
|
||||
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
|
||||
app:layout_constraintTop_toBottomOf="@id/cert_check" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/socks5_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
tools:visibility="gone"
|
||||
app:constraint_referenced_ids="socks5_experimental_warning, socks5_host, socks5_port, socks5_user, socks5_password" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/socks5_experimental_warning"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="1dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="@string/login_socks5_experimental_warning"
|
||||
android:textColor="@color/gray50"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/socks5_switch" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/socks5_host"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="58dp"
|
||||
app:errorEnabled="true"
|
||||
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
|
||||
app:layout_constraintTop_toBottomOf="@id/socks5_experimental_warning">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/socks5_host_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/login_socks5_host"
|
||||
android:inputType="textUri|textNoSuggestions" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/socks5_port"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="58dp"
|
||||
app:errorEnabled="true"
|
||||
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
|
||||
app:layout_constraintTop_toBottomOf="@id/socks5_host">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/socks5_port_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/login_socks5_port"
|
||||
android:inputType="number" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/socks5_user"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
|
||||
app:layout_constraintTop_toBottomOf="@id/socks5_port">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/socks5_user_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:hint="@string/login_socks5_user" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/socks5_password"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
|
||||
app:layout_constraintTop_toBottomOf="@id/socks5_user"
|
||||
app:passwordToggleEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/socks5_password_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/login_socks5_password"
|
||||
android:inputType="textPassword" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_log_button"
|
||||
android:layout_width="0dp"
|
||||
@@ -495,7 +402,7 @@
|
||||
android:paddingBottom="32dp"
|
||||
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
|
||||
app:layout_constraintTop_toBottomOf="@id/socks5_password" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cert_check" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sub_header"
|
||||
|
||||
Reference in New Issue
Block a user