add new exchange activity

pull/5/head
Felix Prahl-Kamps 2019-07-11 16:22:58 +02:00
parent 037328ff26
commit 5e3650bcd9
13 changed files with 491 additions and 16 deletions

View File

@ -38,7 +38,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -28,6 +28,12 @@
<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"

View File

@ -0,0 +1,117 @@
package lu.circl.mispbump.activities;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AnticipateOvershootInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import lu.circl.mispbump.R;
import lu.circl.mispbump.auxiliary.QrCodeGenerator;
import lu.circl.mispbump.fragments.CameraFragment;
public class ExchangeActivity2 extends AppCompatActivity {
private QrCodeGenerator qrCodeGenerator;
private TextView titleView, hintView;
private View fragmentContainer;
private ImageView qrCode;
private ImageButton prevButton, nextButton, qrInfoButton;
private CameraFragment cameraFragment;
private boolean isDone = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_exchange_2);
qrCodeGenerator = new QrCodeGenerator(ExchangeActivity2.this);
initViews();
initCamera();
}
private void initViews() {
titleView = findViewById(R.id.title);
fragmentContainer = findViewById(R.id.fragmentContainer);
qrCode = findViewById(R.id.qrCode);
qrCode.setImageBitmap(qrCodeGenerator.generateQrCode("Huhu hier steht nix aber auch nicht so wenig denn hier soll mal ein bisschen content im qr code stehen damit es auch realistisch ist...."));
prevButton = findViewById(R.id.prevButton);
prevButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isDone = !isDone;
toggleLayoutChange(isDone);
}
});
nextButton = findViewById(R.id.nextButton);
qrInfoButton = findViewById(R.id.qrInfoButton);
}
private void initCamera() {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
cameraFragment = new CameraFragment();
fragmentTransaction.add(R.id.fragmentContainer, cameraFragment, CameraFragment.class.getSimpleName());
fragmentTransaction.commit();
}
private void toggleLayoutChange(final boolean done) {
final View doneText = findViewById(R.id.doneText);
View constraintLayout = findViewById(R.id.constraintLayout);
if (done) {
fragmentContainer.animate().alpha(0f).setDuration(250).start();
doneText.setVisibility(View.VISIBLE);
doneText.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white)));
// doneText.setAlpha(0);
// doneText.setTranslationY(100);
// doneText.animate()
// .alpha(1)
// .translationY(0)
// .setInterpolator(new DecelerateInterpolator())
// .start();
//
// constraintLayout.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white)));
// constraintLayout.animate().translationY(-50).setDuration(250).start();
nextButton.setTranslationX(200);
nextButton.animate()
.translationX(0)
.setInterpolator(new AnticipateOvershootInterpolator())
.setDuration(250).start();
} else {
fragmentContainer.animate().alpha(1f).setDuration(250).start();
doneText.setVisibility(View.GONE);
doneText.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white_80)));
// doneText.animate()
// .alpha(0)
// .translationY(100)
// .start();
//
// constraintLayout.setBackgroundTintList(ColorStateList.valueOf(getColor(R.color.white_80)));
// constraintLayout.animate().translationY(0).setDuration(250).start();
nextButton.setTranslationX(0);
nextButton.animate().translationX(200).setDuration(250).start();
}
}
}

View File

@ -17,13 +17,16 @@ public class StartUpActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isUserLoggedIn()) {
Intent home = new Intent(this, HomeActivity.class);
startActivity(home);
} else {
Intent login = new Intent(this, LoginActivity.class);
startActivity(login);
}
// if (isUserLoggedIn()) {
// Intent home = new Intent(this, HomeActivity.class);
// startActivity(home);
// } else {
// Intent login = new Intent(this, LoginActivity.class);
// startActivity(login);
// }
Intent i = new Intent(this, ExchangeActivity2.class);
startActivity(i);
// closes the activity to prevent going back to this (empty) activity
finish();

View File

@ -0,0 +1,59 @@
package lu.circl.mispbump.customViews;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import lu.circl.mispbump.R;
public class FixedAspectRatioFrameLayout extends FrameLayout {
private int mAspectRatioWidth;
private int mAspectRatioHeight;
public FixedAspectRatioFrameLayout(Context context) {
super(context);
}
public FixedAspectRatioFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public FixedAspectRatioFrameLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FixedAspectRatioFrameLayout);
mAspectRatioWidth = a.getInt(R.styleable.FixedAspectRatioFrameLayout_aspectRatioWidth, 1);
mAspectRatioHeight = a.getInt(R.styleable.FixedAspectRatioFrameLayout_aspectRatioHeight, 1);
a.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int originalWidth = MeasureSpec.getSize(widthMeasureSpec);
int originalHeight = MeasureSpec.getSize(heightMeasureSpec);
int calculatedHeight = originalWidth * mAspectRatioHeight / mAspectRatioWidth;
int finalWidth, finalHeight;
if (calculatedHeight > originalHeight) {
finalWidth = originalHeight * mAspectRatioWidth / mAspectRatioHeight;
finalHeight = originalHeight;
} else {
finalWidth = originalWidth;
finalHeight = calculatedHeight;
}
super.onMeasure(
MeasureSpec.makeMeasureSpec(finalWidth, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(finalHeight, MeasureSpec.EXACTLY));
}
}

View File

@ -0,0 +1,7 @@
<vector android:height="100dp" android:viewportHeight="100.00009"
android:viewportWidth="100.00009" android:width="100dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha="1" android:fillColor="#ffffff"
android:fillType="nonZero"
android:pathData="m0,0v4.233c0,-2.345 1.888,-4.233 4.233,-4.233zM95.767,0c2.345,0 4.233,1.888 4.233,4.233L100,0ZM0,95.767v4.233h4.233c-2.345,0 -4.233,-1.888 -4.233,-4.233zM100,95.767c0,2.345 -1.888,4.233 -4.233,4.233h4.233z"
android:strokeAlpha="1" android:strokeColor="#00000000" android:strokeWidth="1"/>
</vector>

View File

@ -4,6 +4,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:fillColor="#FFF"
android:pathData="M11.19,1.36l-7,3.11C3.47,4.79 3,5.51 3,6.3L3,11c0,5.55 3.84,10.74 9,12 5.16,-1.26 9,-6.45 9,-12L21,6.3c0,-0.79 -0.47,-1.51 -1.19,-1.83l-7,-3.11c-0.51,-0.23 -1.11,-0.23 -1.62,0zM9.29,16.29L6.7,13.7c-0.39,-0.39 -0.39,-1.02 0,-1.41 0.39,-0.39 1.02,-0.39 1.41,0L10,14.17l5.88,-5.88c0.39,-0.39 1.02,-0.39 1.41,0 0.39,0.39 0.39,1.02 0,1.41l-6.59,6.59c-0.38,0.39 -1.02,0.39 -1.41,0z"/>
</vector>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<size android:width="256dp" android:height="256dp"/>
<corners android:radius="12dp"/>
<solid android:color="@color/white"/>
<!--<corners android:radius="12dp"/>-->
</shape>
</item>
</layer-list>

View File

@ -21,14 +21,14 @@
android:backgroundTint="#99FFFFFF"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="8dp"
tools:layout_height="256dp"
tools:layout_width="256dp">
android:padding="8dp">
<ImageView
android:id="@+id/qrCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/rect_rounded"
android:tint="@color/colorIconDark"
android:layout_width="match_parent"
android:layout_height="256dp"
android:contentDescription="@string/qr_code" />
<TextView
@ -58,7 +58,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/bottom"
android:id="@+id/navbar_bottom"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"

View File

@ -0,0 +1,264 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark">
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:animateLayoutChanges="true"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center"
app:layout_constraintBottom_toTopOf="@id/navbar_bottom">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="32dp"
android:layout_marginTop="8dp"
android:background="@drawable/rect_rounded"
android:backgroundTint="@color/white_80"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/navbar_bottom">
<TextView
android:id="@+id/qrInfoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Public Key"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/qrCode" />
<ImageButton
android:id="@+id/qrInfoButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_info_outline"
android:tint="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="@+id/qrCode"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:src="@color/white"
app:layout_constraintBottom_toTopOf="@+id/qrInfoButton"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:visibility="gone"
android:id="@+id/qrCodeInfo"
android:background="@color/white"
android:text="This is what the qr code looks like in text, mayber there is much more but I dont know about this shit."
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
app:layout_constraintBottom_toTopOf="@+id/qrInfoButton"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/doneText"
android:alpha="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:background="@drawable/rect_rounded"
android:backgroundTint="@color/white_80">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:drawableStart="@drawable/ic_check_outline"
android:drawableTint="@color/status_green"
android:drawablePadding="8dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
android:gravity="center_vertical"
android:text="Public key received"/>
</LinearLayout>
</LinearLayout>
<!--<androidx.constraintlayout.widget.ConstraintLayout-->
<!--android:id="@+id/constraintLayout"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_margin="32dp"-->
<!--android:layout_marginTop="8dp"-->
<!--android:background="@drawable/rect_rounded"-->
<!--android:backgroundTint="@color/white_80"-->
<!--app:layout_constraintEnd_toEndOf="parent"-->
<!--app:layout_constraintStart_toStartOf="parent"-->
<!--app:layout_constraintTop_toTopOf="parent"-->
<!--app:layout_constraintBottom_toTopOf="@id/navbar_bottom">-->
<!--<TextView-->
<!--android:id="@+id/qrInfoText"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="Public Key"-->
<!--android:textAlignment="center"-->
<!--android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"-->
<!--android:textColor="@color/black"-->
<!--app:layout_constraintBottom_toBottomOf="parent"-->
<!--app:layout_constraintEnd_toEndOf="parent"-->
<!--app:layout_constraintStart_toStartOf="parent"-->
<!--app:layout_constraintTop_toBottomOf="@id/qrCode" />-->
<!--<ImageButton-->
<!--android:id="@+id/qrInfoButton"-->
<!--android:layout_width="48dp"-->
<!--android:layout_height="48dp"-->
<!--android:background="?attr/selectableItemBackgroundBorderless"-->
<!--android:src="@drawable/ic_info_outline"-->
<!--android:tint="@color/black"-->
<!--app:layout_constraintBottom_toBottomOf="parent"-->
<!--app:layout_constraintEnd_toEndOf="parent" />-->
<!--<ImageView-->
<!--android:id="@+id/qrCode"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="0dp"-->
<!--android:layout_marginStart="12dp"-->
<!--android:layout_marginTop="12dp"-->
<!--android:layout_marginEnd="12dp"-->
<!--android:src="@color/white"-->
<!--app:layout_constraintBottom_toTopOf="@+id/qrInfoButton"-->
<!--app:layout_constraintDimensionRatio="1:1"-->
<!--app:layout_constraintEnd_toEndOf="parent"-->
<!--app:layout_constraintStart_toStartOf="parent"-->
<!--app:layout_constraintTop_toTopOf="parent" />-->
<!--<TextView-->
<!--android:visibility="gone"-->
<!--android:id="@+id/qrCodeInfo"-->
<!--android:background="@color/white"-->
<!--android:text="This is what the qr code looks like in text, mayber there is much more but I dont know about this shit."-->
<!--android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="0dp"-->
<!--android:layout_marginStart="12dp"-->
<!--android:layout_marginTop="12dp"-->
<!--android:layout_marginEnd="12dp"-->
<!--app:layout_constraintBottom_toTopOf="@+id/qrInfoButton"-->
<!--app:layout_constraintDimensionRatio="1:1"-->
<!--app:layout_constraintEnd_toEndOf="parent"-->
<!--app:layout_constraintStart_toStartOf="parent"-->
<!--app:layout_constraintTop_toTopOf="parent" />-->
<!--</androidx.constraintlayout.widget.ConstraintLayout>-->
<!--<LinearLayout-->
<!--android:alpha="0"-->
<!--android:id="@+id/doneText"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginTop="0dp"-->
<!--app:layout_constraintBottom_toTopOf="@id/navbar_bottom"-->
<!--app:layout_constraintEnd_toEndOf="parent"-->
<!--app:layout_constraintStart_toStartOf="parent"-->
<!--android:background="@drawable/rect_rounded"-->
<!--android:backgroundTint="@color/white_80">-->
<!--<TextView-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:padding="16dp"-->
<!--android:drawableStart="@drawable/ic_check_outline"-->
<!--android:drawableTint="@color/status_green"-->
<!--android:drawablePadding="8dp"-->
<!--android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"-->
<!--android:gravity="center_vertical"-->
<!--android:text="Public key received"/>-->
<!--</LinearLayout>-->
<LinearLayout
android:id="@+id/navbar_bottom"
android:layout_width="0dp"
android:layout_height="56dp"
android:background="@drawable/rect_rounded_top"
android:backgroundTint="@color/colorPrimary"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<ImageButton
android:id="@+id/prevButton"
android:layout_width="56dp"
android:layout_height="56dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/button_prev"
android:padding="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_arrow_back" />
<TextView
android:id="@+id/hint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:text="Scan each others QR codes"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
android:textColor="@color/white" />
<ImageButton
android:id="@+id/nextButton"
android:layout_width="56dp"
android:layout_height="56dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/button_continue"
android:padding="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_arrow_forward" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -24,4 +24,9 @@
<declare-styleable name="UploadAction">
<attr name="description" format="string"/>
</declare-styleable>
<declare-styleable name="FixedAspectRatioFrameLayout">
<attr name="aspectRatioWidth" format="integer"/>
<attr name="aspectRatioHeight" format="integer"/>
</declare-styleable>
</resources>

View File

@ -10,6 +10,7 @@
<color name="dividerColor">#33000000</color>
<color name="white">#FFFFFF</color>
<color name="white_80">#CCFFFFFF</color>
<color name="white_50">#80FFFFFF</color>
<color name="grey">#BDBDBD</color>

View File

@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong