mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #2841 from deltachat/adb/improve-new-contact-form
improve NewContactActivity, add "scan QR button"
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:startColor="@color/gray50"
|
||||
android:endColor="@color/transparent"
|
||||
android:type="linear" />
|
||||
|
||||
</shape>
|
||||
@@ -0,0 +1,10 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:startColor="@color/transparent"
|
||||
android:endColor="@color/gray50"
|
||||
android:type="linear" />
|
||||
|
||||
</shape>
|
||||
@@ -35,8 +35,62 @@
|
||||
|
||||
<androidx.legacy.widget.Space
|
||||
android:id="@+id/fab_spacer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<Button
|
||||
style="@style/ButtonSecondary"
|
||||
android:id="@+id/qrscan_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="28dp" />
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:text="@string/qrscan_title"
|
||||
android:drawableStart="@drawable/baseline_qr_code_24"
|
||||
android:drawableLeft="@drawable/baseline_qr_code_24"
|
||||
android:drawablePadding="5dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/fab_spacer"
|
||||
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/or_divider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="35dp"
|
||||
android:paddingBottom="35dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="@id/qrscan_btn"
|
||||
app:layout_constraintEnd_toEndOf="@id/qrscan_btn"
|
||||
app:layout_constraintTop_toBottomOf="@id/qrscan_btn">
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/divider_start"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center"
|
||||
android:text="@string/or_separator"
|
||||
android:textSize="14sp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textColor="@color/gray50"/>
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/divider_end"/>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/name"
|
||||
@@ -44,7 +98,7 @@
|
||||
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/fab_spacer">
|
||||
app:layout_constraintTop_toBottomOf="@id/or_divider">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/name_text"
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<string name="app_name">Delta Chat</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<!-- the word "or" to separate blocks in the user interface that are mutually exclusive -->
|
||||
<string name="or_separator">or</string>
|
||||
<string name="clear_search">Clear Search</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<resources>
|
||||
<style name="AppCompatAlertDialogStyleLight" parent="Theme.AppCompat.Light.Dialog.Alert">
|
||||
</style>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
<style name="TextSecure.DarkActionBar"
|
||||
parent="@style/Widget.AppCompat.ActionBar">
|
||||
<item name="background">@color/gray95</item>
|
||||
<item name="android:popupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="elevation">4dp</item>
|
||||
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="titleTextStyle">@style/TextSecure.TitleTextStyle</item>
|
||||
@@ -84,6 +83,7 @@
|
||||
</style>
|
||||
|
||||
<style name="ButtonPrimary">
|
||||
<item name="drawableTint">@color/white</item>
|
||||
<item name="android:textColor">@color/white</item>
|
||||
<item name="android:paddingLeft">8dp</item>
|
||||
<item name="android:paddingRight">8dp</item>
|
||||
@@ -91,6 +91,7 @@
|
||||
</style>
|
||||
|
||||
<style name="ButtonSecondary">
|
||||
<item name="drawableTint">?attr/secondary_button_fg</item>
|
||||
<item name="android:textColor">?attr/secondary_button_fg</item>
|
||||
<item name="android:paddingLeft">8dp</item>
|
||||
<item name="android:paddingRight">8dp</item>
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -12,11 +13,15 @@ import androidx.appcompat.app.ActionBar;
|
||||
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.zxing.integration.android.IntentIntegrator;
|
||||
import com.google.zxing.integration.android.IntentResult;
|
||||
|
||||
import org.thoughtcrime.securesms.ConversationActivity;
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.qr.QrActivity;
|
||||
import org.thoughtcrime.securesms.qr.QrCodeHandler;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
public class NewContactActivity extends PassphraseRequiredActionBarActivity
|
||||
@@ -42,7 +47,9 @@ public class NewContactActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
nameInput = ViewUtil.findById(this, R.id.name_text);
|
||||
addrInput = ViewUtil.findById(this, R.id.email_text);
|
||||
Button qrscanBtn = ViewUtil.findById(this, R.id.qrscan_btn);
|
||||
|
||||
qrscanBtn.setOnClickListener((view) -> new IntentIntegrator(this).setCaptureActivity(QrActivity.class).initiateScan());
|
||||
addrInput.setText(getIntent().getStringExtra(ADDR_EXTRA));
|
||||
addrInput.setOnFocusChangeListener((view, focused) -> {
|
||||
String addr = addrInput.getText() == null? "" : addrInput.getText().toString();
|
||||
@@ -92,4 +99,14 @@ public class NewContactActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == IntentIntegrator.REQUEST_CODE) {
|
||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
|
||||
QrCodeHandler qrCodeHandler = new QrCodeHandler(this);
|
||||
qrCodeHandler.onScanPerformed(scanResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user