Skip to content
This repository has been archived by the owner on Aug 5, 2019. It is now read-only.

Commit

Permalink
improve exchange activity layout and functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpk committed Jul 14, 2019
1 parent 66d586a commit ef37517
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 396 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
// android
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
<activity
android:name=".activities.HomeActivity"
android:label="@string/app_name" />
<activity
android:name=".activities.ExchangeActivity2"
android:configChanges="orientation|screenSize"
android:parentActivityName=".activities.HomeActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Translucent" />
<activity
android:name=".activities.ExchangeActivity"
android:configChanges="orientation|screenSize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

Expand Down Expand Up @@ -43,9 +43,9 @@ public class ExchangeActivity extends AppCompatActivity {

private CameraFragment cameraFragment;

private CoordinatorLayout rootLayout;
private ConstraintLayout rootLayout;
private View qrFrame, scanFeedbackView, continueHintView, fragmentContainer;
private TextView scanFeedbackText;
private TextView scanFeedbackText, qrContentInfo;
private ImageView qrCode;
private ImageButton prevButton, nextButton;

Expand All @@ -57,7 +57,7 @@ public class ExchangeActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_exchange_2);
setContentView(R.layout.activity_exchange);

preferenceManager = PreferenceManager.getInstance(ExchangeActivity.this);
qrCodeGenerator = new QrCodeGenerator(ExchangeActivity.this);
Expand All @@ -84,6 +84,7 @@ private void initViews() {
scanFeedbackView = findViewById(R.id.scanFeedbackView);
scanFeedbackText = findViewById(R.id.scanFeedbackText);
continueHintView = findViewById(R.id.continueHint);
qrContentInfo = findViewById(R.id.qrContentInfo);

prevButton = findViewById(R.id.prevButton);
prevButton.setOnClickListener(onPrevClicked());
Expand Down Expand Up @@ -130,15 +131,12 @@ private void showQrCode(final Bitmap bitmap) {
@Override
public void run() {
qrCode.setImageBitmap(bitmap);
qrFrame.setVisibility(View.VISIBLE); // TODO animate
qrFrame.setVisibility(View.VISIBLE);
}
});
}

private void setSyncState(SyncState state) {

Log.d("DEBUG", "current sync state: " + state);

currentSyncState = state;

runOnUiThread(new Runnable() {
Expand All @@ -151,8 +149,11 @@ public void run() {
nextButton.setVisibility(View.GONE);

setCameraPreviewEnabled(true);
setReadQrStatus(ReadQrStatus.PENDING);
showQrCode(publicKeyQr);

setReadQrStatus(ReadQrStatus.PENDING);
scanFeedbackText.setText(R.string.scan_qr_hint);
qrContentInfo.setText(R.string.public_key);
break;
case KEY_EXCHANGE_DONE:
prevButton.setImageDrawable(getDrawable(R.drawable.ic_close));
Expand All @@ -161,17 +162,23 @@ public void run() {
nextButton.setVisibility(View.VISIBLE);

setCameraPreviewEnabled(false);
setReadQrStatus(ReadQrStatus.SUCCESS);
showQrCode(publicKeyQr);

setReadQrStatus(ReadQrStatus.SUCCESS);
scanFeedbackText.setText(R.string.public_key_received_hint);
qrContentInfo.setText(R.string.public_key);
break;
case DATA_EXCHANGE:
prevButton.setImageDrawable(getDrawable(R.drawable.ic_arrow_back));
prevButton.setVisibility(View.VISIBLE);
nextButton.setVisibility(View.GONE);

setCameraPreviewEnabled(true);
setReadQrStatus(ReadQrStatus.PENDING);
showQrCode(dataQr);

setReadQrStatus(ReadQrStatus.PENDING);
scanFeedbackText.setText(R.string.scan_qr_hint);
qrContentInfo.setText(R.string.sync_information);
break;
case DATA_EXCHANGE_DONE:
prevButton.setImageDrawable(getDrawable(R.drawable.ic_arrow_back));
Expand All @@ -180,8 +187,11 @@ public void run() {
nextButton.setVisibility(View.VISIBLE);

setCameraPreviewEnabled(false);
setReadQrStatus(ReadQrStatus.SUCCESS);
showQrCode(dataQr);

setReadQrStatus(ReadQrStatus.SUCCESS);
scanFeedbackText.setText(R.string.sync_info_received_hint);
qrContentInfo.setText(R.string.public_key);
break;
}
}
Expand Down Expand Up @@ -213,29 +223,22 @@ private void setReadQrStatus(ReadQrStatus status) {
break;
}

runOnUiThread(new Runnable() {
@Override
public void run() {
scanFeedbackText.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
scanFeedbackText.setCompoundDrawableTintList(ColorStateList.valueOf(color));

if (currentReadQrStatus == ReadQrStatus.SUCCESS) {
continueHintView.setVisibility(View.VISIBLE);
scanFeedbackText.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
scanFeedbackText.setCompoundDrawableTintList(ColorStateList.valueOf(color));

continueHintView.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white)));
scanFeedbackView.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white)));
qrFrame.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white)));
if (currentReadQrStatus == ReadQrStatus.SUCCESS) {
continueHintView.setVisibility(View.VISIBLE);
scanFeedbackView.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white)));
qrFrame.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white)));

fragmentContainer.animate().alpha(0).setDuration(250).start();
} else {
fragmentContainer.animate().alpha(1).setDuration(250).start();
fragmentContainer.animate().alpha(0).setDuration(250).start();
} else {
continueHintView.setVisibility(View.GONE);
scanFeedbackView.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white_80)));
qrFrame.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white_80)));

continueHintView.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white_80)));
scanFeedbackView.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white_80)));
qrFrame.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white_80)));
}
}
});
fragmentContainer.animate().alpha(1).setDuration(250).start();
}
}

private void setCameraPreviewEnabled(boolean enabled) {
Expand Down
129 changes: 0 additions & 129 deletions app/src/main/java/lu/circl/mispbump/activities/ExchangeActivity2.java

This file was deleted.

Loading

0 comments on commit ef37517

Please sign in to comment.