mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
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/black"
|
||||
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/black"
|
||||
android:endColor="@color/gray50"
|
||||
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/gray50"
|
||||
android:endColor="@color/white"
|
||||
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/white"
|
||||
android:endColor="@color/gray50"
|
||||
android:type="linear" />
|
||||
|
||||
</shape>
|
||||
@@ -73,6 +73,59 @@
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/or_divider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="40dp"
|
||||
android:paddingBottom="30dp"
|
||||
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/email">
|
||||
|
||||
<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>
|
||||
|
||||
<Button
|
||||
style="@style/ButtonPrimary"
|
||||
android:id="@+id/qrscan_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="50dp"
|
||||
android:paddingRight="50dp"
|
||||
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/or_divider"
|
||||
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
|
||||
app:layout_constraintStart_toStartOf="@id/guideline_root_start"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<string name="app_name">Delta Chat</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="or_separator">or</string>
|
||||
<string name="clear_search">Clear Search</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
|
||||
@@ -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