diff --git a/app/build.gradle b/app/build.gradle index 5072aa0..347c82a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,7 +22,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support.constraint:constraint-layout:1.1.1' + implementation 'com.android.support.constraint:constraint-layout:1.1.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' @@ -31,4 +31,5 @@ dependencies { implementation 'com.android.volley:volley:1.1.0' implementation 'com.github.kenglxn.QRGen:android:2.4.0' + implementation 'com.google.android.gms:play-services-vision:15.0.2' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b80b394..5e7973a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,7 @@ + diff --git a/app/src/main/java/de/overview/wg/its/mispauth/activity/SyncActivity.java b/app/src/main/java/de/overview/wg/its/mispauth/activity/SyncActivity.java index 72e7308..144e1a2 100644 --- a/app/src/main/java/de/overview/wg/its/mispauth/activity/SyncActivity.java +++ b/app/src/main/java/de/overview/wg/its/mispauth/activity/SyncActivity.java @@ -1,35 +1,38 @@ package de.overview.wg.its.mispauth.activity; +import android.content.DialogInterface; +import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; +import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.util.Log; import android.view.View; import android.widget.Button; -import android.widget.LinearLayout; -import com.android.volley.VolleyError; import de.overview.wg.its.mispauth.R; +import de.overview.wg.its.mispauth.auxiliary.OrganisationDialog; import de.overview.wg.its.mispauth.auxiliary.PreferenceManager; import de.overview.wg.its.mispauth.fragment.ScanQrFragment; import de.overview.wg.its.mispauth.fragment.ShowQrFragment; import de.overview.wg.its.mispauth.fragment.SyncStartFragment; import de.overview.wg.its.mispauth.fragment.UploadFragment; import de.overview.wg.its.mispauth.model.Organisation; -import de.overview.wg.its.mispauth.network.MispRequest; -import de.overview.wg.its.mispauth.custom_viewpager.ExtendedViewPager; -import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; public class SyncActivity extends AppCompatActivity { + private static final String TAG = "DEBUG"; + private PreferenceManager preferenceManager; - private static final int PAGE_COUNT = 3; - private ExtendedViewPager viewPager; - private PagerAdapter pagerAdapter; - private LinearLayout bottomLayout; + private Button prevButton, nextButton; + private int partnerChoice = -1; + private String scannedQrString = ""; + + private int currentFragmentPosition = 0; @Override @@ -37,107 +40,131 @@ public class SyncActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sync); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + preferenceManager = PreferenceManager.Instance(this); - setupViewPager(); + nextButton = findViewById(R.id.nextButton); + prevButton = findViewById(R.id.backButton); + + nextButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getFragment(currentFragmentPosition + 1, true); + } + }); + prevButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getFragment(currentFragmentPosition - 1, true); + } + }); + + getFragment(0, false); } - private void setupViewPager() { - bottomLayout = findViewById(R.id.linearLayout); + private void getFragment(int position, boolean animate) { - pagerAdapter = new SimplePagerAdapter(getSupportFragmentManager()); + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - viewPager = findViewById(R.id.viewPager); - viewPager.setPagingEnabled(false); - viewPager.setAdapter(pagerAdapter); + if (animate) { + if (position > currentFragmentPosition) { + transaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right); + } else { + transaction.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left); + } + } - viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + currentFragmentPosition = position; + + switch (position) { + + case 0: + prevButton.setEnabled(false); + nextButton.setEnabled(false); + transaction.replace(R.id.fragmentContainer, new SyncStartFragment()); + break; + + case 1: + + prevButton.setEnabled(true); + + if (partnerChoice == 1) { + + nextButton.setEnabled(false); + transaction.replace(R.id.fragmentContainer, new ScanQrFragment(), "FRAGMENT_SCAN"); - @Override - public void onPageSelected(int position) { - if (position == 0) { - bottomLayout.setVisibility(View.GONE); } else { - bottomLayout.setVisibility(View.VISIBLE); + + nextButton.setEnabled(true); + transaction.replace(R.id.fragmentContainer, new ShowQrFragment(), "FRAGMENT_SHOW"); + } - } + break; - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + case 2: + if (partnerChoice == 1) { - } + prevButton.setEnabled(true); + nextButton.setEnabled(true); + transaction.replace(R.id.fragmentContainer, new ShowQrFragment(), "FRAGMENT_SHOW"); - // SCROLL_STATE_IDLE, SCROLL_STATE_DRAGGING, SCROLL_STATE_SETTLING - @Override - public void onPageScrollStateChanged(int state) { + } else { - } - }); + prevButton.setEnabled(true); + nextButton.setEnabled(false); - Button next = findViewById(R.id.nextButton); - Button back = findViewById(R.id.backButton); + transaction.replace(R.id.fragmentContainer, new ScanQrFragment(), "FRAGMENT_SCAN"); + } + break; - next.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - viewPager.setCurrentItem(viewPager.getCurrentItem() + 1, true); - } - }); + case 3: - back.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - viewPager.setCurrentItem(viewPager.getCurrentItem() - 1, true); - } - }); + nextButton.setText("Finish"); + nextButton.setEnabled(false); + + transaction.replace(R.id.fragmentContainer, new UploadFragment()); + + break; + + default: + break; + } + transaction.commit(); } - private class SimplePagerAdapter extends FragmentStatePagerAdapter { + public void setPartnerChoice(int choice) { - public SimplePagerAdapter(FragmentManager fm) { - super(fm); - } + partnerChoice = choice; - @Override - public Fragment getItem(int position) { - - switch (position) { - case 0: - return new SyncStartFragment(); // start fragment - - case 1: - return new ScanQrFragment(); // scan fragment - - case 2: - return new ShowQrFragment(); // show QR fragment - - case 3: - return new UploadFragment(); // show upload fragment - - default: - return null; // This should not be happening - } - } - - @Override - public int getCount() { - return PAGE_COUNT; + if (choice != -1) { + nextButton.setEnabled(true); + } else { + nextButton.setEnabled(false); } } - private void uploadOrganisation(Organisation org) { - MispRequest mispRequest = MispRequest.Instance(this); + public void setScannedQr(String qr) { - mispRequest.getOrganisations(new MispRequest.OrganisationsCallback() { - @Override - public void onResult(JSONArray organisations) { + final FragmentManager manager = getSupportFragmentManager(); + final ScanQrFragment scanFragment = (ScanQrFragment) manager.findFragmentByTag("FRAGMENT_SCAN"); - } + scanFragment.setReadQr(false); + try { + OrganisationDialog d = new OrganisationDialog(this); + Organisation o = new Organisation(); + o.fromJSON(new JSONObject(qr)); + d.createDialog(o); - @Override - public void onError(VolleyError volleyError) { + } catch (JSONException e) { + e.printStackTrace(); + } - } - }); + } + + public void uploadReady() { + nextButton.setEnabled(true); } } diff --git a/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/OrganisationDialog.java b/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/OrganisationDialog.java index 04a8f2f..9f030b0 100644 --- a/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/OrganisationDialog.java +++ b/app/src/main/java/de/overview/wg/its/mispauth/auxiliary/OrganisationDialog.java @@ -27,6 +27,9 @@ public class OrganisationDialog { TextView title = dialogContent.findViewById(R.id.organisation_title); title.setText(org.getName()); + TextView uuid = dialogContent.findViewById(R.id.organisation_uuid); + uuid.setText(org.getUuid()); + TextView description = dialogContent.findViewById(R.id.organisation_description); description.setText(org.getDescription()); @@ -39,7 +42,9 @@ public class OrganisationDialog { TextView userCount = dialogContent.findViewById(R.id.organisation_user_count); userCount.setText("" + org.getUserCount()); -// dialogBuilder.setPositiveButton("OK", null); + dialogBuilder.setCancelable(false); + dialogBuilder.setNegativeButton("REJECT", null); + dialogBuilder.setPositiveButton("ACCEPT", null); dialogBuilder.show(); } } diff --git a/app/src/main/java/de/overview/wg/its/mispauth/fragment/ScanQrFragment.java b/app/src/main/java/de/overview/wg/its/mispauth/fragment/ScanQrFragment.java index a4265ff..b7ce186 100644 --- a/app/src/main/java/de/overview/wg/its/mispauth/fragment/ScanQrFragment.java +++ b/app/src/main/java/de/overview/wg/its/mispauth/fragment/ScanQrFragment.java @@ -1,17 +1,361 @@ package de.overview.wg.its.mispauth.fragment; +import android.Manifest; +import android.content.Context; +import android.content.pm.PackageManager; +import android.graphics.Bitmap; +import android.graphics.ImageFormat; +import android.graphics.SurfaceTexture; +import android.hardware.camera2.*; +import android.hardware.camera2.params.StreamConfigurationMap; +import android.media.Image; +import android.media.ImageReader; import android.os.Bundle; +import android.os.Handler; +import android.os.HandlerThread; +import android.renderscript.*; +import android.support.annotation.NonNull; +import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; +import android.support.v4.content.ContextCompat; +import android.util.Size; +import android.util.SparseArray; +import android.view.*; +import android.widget.Toast; +import com.google.android.gms.vision.Frame; +import com.google.android.gms.vision.barcode.Barcode; +import com.google.android.gms.vision.barcode.BarcodeDetector; import de.overview.wg.its.mispauth.R; +import de.overview.wg.its.mispauth.activity.SyncActivity; + +import java.util.Arrays; +import java.util.List; public class ScanQrFragment extends Fragment { + private static final int CAMERA_REQUEST_CODE = 0; + + private HandlerThread backgroundThread; + private Handler backgroundHandler; + + private CameraManager cameraManager; + private CameraDevice cameraDevice; + private String cameraID; + private CameraCaptureSession cameraCaptureSession; + + private SurfaceTexture previewSurfaceTexture; + private Surface previewSurface, yuvSurface; + private Size[] yuvSizes; + + private BarcodeDetector barcodeDetector; + private TextureView previewView; + + private boolean readQr = true; + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_sync_scan, null); + + previewView = v.findViewById(R.id.texture_scan_preview); + + if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { + + if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.CAMERA)) { + + } else { + ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.CAMERA}, CAMERA_REQUEST_CODE); + } + + } else { + setUpBarcodeDetector(); + setUpPreviewTexture(); + } + return v; } + @Override + public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { + switch (requestCode) { + case CAMERA_REQUEST_CODE: { + if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + setUpBarcodeDetector(); + setUpPreviewTexture(); + } else { + Toast.makeText(getActivity(), "Camera permission needed!", Toast.LENGTH_SHORT).show(); + } + } + } + } + + @Override + public void onResume() { + super.onResume(); + openBackgroundThread(); + } + + @Override + public void onStop() { + super.onStop(); + closeCamera(); + closeBackgroundThread(); + } + + + private void returnResult(String qrData) { + ((SyncActivity) getActivity()).setScannedQr(qrData); + } + + private void setUpPreviewTexture() { + + previewView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() { + @Override + public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { + surface.setDefaultBufferSize(width, height); + previewSurfaceTexture = surface; + setUpCamera(); + } + + @Override + public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { + + } + + @Override + public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { + return false; + } + + @Override + public void onSurfaceTextureUpdated(SurfaceTexture surface) { + + } + }); + + } + + private void setUpCamera() { + cameraManager = (CameraManager) getActivity().getSystemService(Context.CAMERA_SERVICE); + + try { + for (String cameraId : cameraManager.getCameraIdList()) { + + CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId); + Integer facing = cameraCharacteristics.get(CameraCharacteristics.LENS_FACING); + + if (facing == CameraCharacteristics.LENS_FACING_BACK) { + + cameraID = cameraId; + + StreamConfigurationMap streamConfigurationMap = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); + yuvSizes = streamConfigurationMap.getOutputSizes(ImageFormat.YUV_420_888); + + setUpImageReader(); + } + } + } catch (CameraAccessException e) { + e.printStackTrace(); + } + } + + private void setUpImageReader() { + + Size yuvSize = yuvSizes[yuvSizes.length - 6]; + + ImageReader yuvImageReader = ImageReader.newInstance(yuvSize.getWidth(), yuvSize.getHeight(), ImageFormat.YUV_420_888, 5); + ImageReader.OnImageAvailableListener yuvImageListener = new ImageReader.OnImageAvailableListener() { + + @Override + public void onImageAvailable(ImageReader reader) { + + if (!readQr) { + return; + } + + Image lastImage = reader.acquireLatestImage(); + Bitmap bitmap = YUV2Bitmap(lastImage); + + if (bitmap != null) { + + Frame frame = new Frame.Builder().setBitmap(bitmap).build(); + SparseArray barcodes = barcodeDetector.detect(frame); + + if (barcodes.size() > 0) { + returnResult(barcodes.valueAt(0).rawValue); + } + } + + if (lastImage != null) { + lastImage.close(); + } + } + }; + + yuvImageReader.setOnImageAvailableListener(yuvImageListener, backgroundHandler); + + previewSurface = new Surface(previewSurfaceTexture); + yuvSurface = yuvImageReader.getSurface(); + + openCamera(); + } + + public void openCamera() { + + CameraDevice.StateCallback stateCallback = new CameraDevice.StateCallback() { + @Override + public void onOpened(@NonNull CameraDevice camera) { + cameraDevice = camera; + createCaptureSession(); + } + + @Override + public void onDisconnected(@NonNull CameraDevice camera) { + + } + + @Override + public void onError(@NonNull CameraDevice camera, int error) { + + } + }; + + try { + if (ActivityCompat.checkSelfPermission(getActivity(), android.Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) { + cameraManager.openCamera(cameraID, stateCallback, backgroundHandler); + } + } catch (CameraAccessException e) { + e.printStackTrace(); + } + } + + private void createCaptureSession() { + List surfaces = Arrays.asList(previewSurface, yuvSurface); + + CameraCaptureSession.StateCallback captureStateCallback = new CameraCaptureSession.StateCallback() { + @Override + public void onConfigured(@NonNull CameraCaptureSession session) { + cameraCaptureSession = session; + createCaptureRequest(); + } + + @Override + public void onConfigureFailed(@NonNull CameraCaptureSession session) { + + } + }; + + try { + cameraDevice.createCaptureSession(surfaces, captureStateCallback, backgroundHandler); + } catch (CameraAccessException e) { + e.printStackTrace(); + } + + } + + private void createCaptureRequest() { + try { + + CaptureRequest.Builder requestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG); + requestBuilder.addTarget(previewSurface); + requestBuilder.addTarget(yuvSurface); + + CameraCaptureSession.CaptureCallback captureCallback = new CameraCaptureSession.CaptureCallback() { + @Override + public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) { + super.onCaptureCompleted(session, request, result); + } + }; + + cameraCaptureSession.setRepeatingRequest(requestBuilder.build(), captureCallback, backgroundHandler); + + } catch (CameraAccessException e) { + e.printStackTrace(); + } + } + + private void openBackgroundThread() { + backgroundThread = new HandlerThread("raw_image_available_listener_thread"); + backgroundThread.start(); + backgroundHandler = new Handler(backgroundThread.getLooper()); + } + + private void closeBackgroundThread() { + backgroundThread.quitSafely(); + try { + backgroundThread.join(); + backgroundThread = null; + backgroundHandler = null; + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public void closeCamera() { + if (cameraCaptureSession != null) { + cameraCaptureSession.close(); + cameraCaptureSession = null; + } + + if (cameraDevice != null) { + cameraDevice.close(); + cameraDevice = null; + } + } + + private void setUpBarcodeDetector() { + barcodeDetector = new BarcodeDetector.Builder(getActivity()) + .setBarcodeFormats(Barcode.QR_CODE) + .build(); + + if (!barcodeDetector.isOperational()) { + Toast.makeText(getActivity(), "Could not setup QR-Code scanner!", Toast.LENGTH_SHORT).show(); + } + } + + private Bitmap YUV2Bitmap(Image image) { + + if (image == null) return null; + + int W = image.getWidth(); + int H = image.getHeight(); + + Image.Plane Y = image.getPlanes()[0]; + Image.Plane U = image.getPlanes()[1]; + Image.Plane V = image.getPlanes()[2]; + + int Yb = Y.getBuffer().remaining(); + int Ub = U.getBuffer().remaining(); + int Vb = V.getBuffer().remaining(); + + byte[] data = new byte[Yb + Ub + Vb]; + + Y.getBuffer().get(data, 0, Yb); + V.getBuffer().get(data, Yb, Vb); + U.getBuffer().get(data, Yb + Vb, Ub); + + RenderScript rs = RenderScript.create(getActivity().getApplicationContext()); + + ScriptIntrinsicYuvToRGB yuvToRgbIntrinsic = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs)); + + Type.Builder yuvType = new Type.Builder(rs, Element.U8(rs)).setX(data.length); + Allocation in = Allocation.createTyped(rs, yuvType.create(), Allocation.USAGE_SCRIPT); + + Type.Builder rgbaType = new Type.Builder(rs, Element.RGBA_8888(rs)).setX(W).setY(H); + Allocation out = Allocation.createTyped(rs, rgbaType.create(), Allocation.USAGE_SCRIPT); + + + final Bitmap bmpout = Bitmap.createBitmap(W, H, Bitmap.Config.ARGB_8888); + + in.copyFromUnchecked(data); + + yuvToRgbIntrinsic.setInput(in); + yuvToRgbIntrinsic.forEach(out); + out.copyTo(bmpout); + image.close(); + return bmpout; + } + + public void setReadQr(boolean enabled) { + readQr = enabled; + } + } diff --git a/app/src/main/java/de/overview/wg/its/mispauth/fragment/ShowQrFragment.java b/app/src/main/java/de/overview/wg/its/mispauth/fragment/ShowQrFragment.java index d905921..b4aba66 100644 --- a/app/src/main/java/de/overview/wg/its/mispauth/fragment/ShowQrFragment.java +++ b/app/src/main/java/de/overview/wg/its/mispauth/fragment/ShowQrFragment.java @@ -1,27 +1,52 @@ package de.overview.wg.its.mispauth.fragment; +import android.graphics.Point; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.util.DisplayMetrics; +import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import de.overview.wg.its.mispauth.R; +import de.overview.wg.its.mispauth.auxiliary.PreferenceManager; import net.glxn.qrgen.android.QRCode; public class ShowQrFragment extends Fragment { private ImageView qrImageView; + private int screenWidth, screenHeight; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_sync_show, null); +// DisplayMetrics metrics = new DisplayMetrics(); +// getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); +// +// screenWidth = (int)(metrics.widthPixels * metrics.density); +// screenHeight = (int)(metrics.heightPixels * metrics.density); + +// Display display = getActivity().getWindowManager().getDefaultDisplay(); +// Point size = new Point(); +// display.getSize(size); +// screenWidth = size.x; +// screenHeight = size.y; + + screenHeight = getResources().getDisplayMetrics().heightPixels; + screenWidth = getResources().getDisplayMetrics().widthPixels; + qrImageView = v.findViewById(R.id.image_view_qr); - setQr("Hallo hier steht leide nur scheiße, aber ansonsten hat alles geklappt! (Y)"); + + PreferenceManager preferenceManager = PreferenceManager.Instance(getActivity()); + setQr(preferenceManager.getMyOrganisation().toJSON().toString()); + return v; } - public void setQr(String msg) { - qrImageView.setImageBitmap(QRCode.from(msg).bitmap()); + private void setQr(String msg) { + qrImageView.setImageBitmap(QRCode.from(msg) + .withSize(screenHeight, screenHeight) + .bitmap()); } } diff --git a/app/src/main/java/de/overview/wg/its/mispauth/fragment/SyncStartFragment.java b/app/src/main/java/de/overview/wg/its/mispauth/fragment/SyncStartFragment.java index 8a81c35..98409e9 100644 --- a/app/src/main/java/de/overview/wg/its/mispauth/fragment/SyncStartFragment.java +++ b/app/src/main/java/de/overview/wg/its/mispauth/fragment/SyncStartFragment.java @@ -1,17 +1,33 @@ package de.overview.wg.its.mispauth.fragment; +import android.app.Activity; +import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.RadioGroup; import de.overview.wg.its.mispauth.R; +import de.overview.wg.its.mispauth.activity.SyncActivity; + public class SyncStartFragment extends Fragment { + private static final String TAG = "DEBUG"; + private RadioGroup radioGroup; + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_sync_start, null); + radioGroup = v.findViewById(R.id.radioGroup); + + radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + ((SyncActivity)getActivity()).setPartnerChoice(checkedId % 2); + } + }); + return v; } - } diff --git a/app/src/main/java/de/overview/wg/its/mispauth/interfaces/IProcessable.java b/app/src/main/java/de/overview/wg/its/mispauth/interfaces/IProcessable.java new file mode 100644 index 0000000..76d7e55 --- /dev/null +++ b/app/src/main/java/de/overview/wg/its/mispauth/interfaces/IProcessable.java @@ -0,0 +1,5 @@ +package de.overview.wg.its.mispauth.interfaces; + +public interface IProcessable { + boolean isDone(); +} diff --git a/app/src/main/java/de/overview/wg/its/mispauth/interfaces/ISyncCommunication.java b/app/src/main/java/de/overview/wg/its/mispauth/interfaces/ISyncCommunication.java new file mode 100644 index 0000000..1b8efb9 --- /dev/null +++ b/app/src/main/java/de/overview/wg/its/mispauth/interfaces/ISyncCommunication.java @@ -0,0 +1,6 @@ +package de.overview.wg.its.mispauth.interfaces; + +public interface ISyncCommunication { + void setPartnerChoice(int choice); + void setScannedQr(String qr); +} diff --git a/app/src/main/res/anim/enter_from_left.xml b/app/src/main/res/anim/enter_from_left.xml new file mode 100644 index 0000000..eb7fb78 --- /dev/null +++ b/app/src/main/res/anim/enter_from_left.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/enter_from_right.xml b/app/src/main/res/anim/enter_from_right.xml new file mode 100644 index 0000000..0c7045c --- /dev/null +++ b/app/src/main/res/anim/enter_from_right.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/exit_to_left.xml b/app/src/main/res/anim/exit_to_left.xml new file mode 100644 index 0000000..a9c41a6 --- /dev/null +++ b/app/src/main/res/anim/exit_to_left.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/exit_to_right.xml b/app/src/main/res/anim/exit_to_right.xml new file mode 100644 index 0000000..7ef31a6 --- /dev/null +++ b/app/src/main/res/anim/exit_to_right.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/animator/fade_in.xml b/app/src/main/res/animator/fade_in.xml new file mode 100644 index 0000000..2865a0c --- /dev/null +++ b/app/src/main/res/animator/fade_in.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/tab_indicator_default.xml b/app/src/main/res/drawable/tab_indicator_default.xml new file mode 100644 index 0000000..60ae032 --- /dev/null +++ b/app/src/main/res/drawable/tab_indicator_default.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/tab_indicator_selected.xml b/app/src/main/res/drawable/tab_indicator_selected.xml new file mode 100644 index 0000000..f4ea196 --- /dev/null +++ b/app/src/main/res/drawable/tab_indicator_selected.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/tab_selector.xml b/app/src/main/res/drawable/tab_selector.xml new file mode 100644 index 0000000..95bfb40 --- /dev/null +++ b/app/src/main/res/drawable/tab_selector.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_sync.xml b/app/src/main/res/layout/activity_sync.xml index f54358c..8b74dcc 100644 --- a/app/src/main/res/layout/activity_sync.xml +++ b/app/src/main/res/layout/activity_sync.xml @@ -12,6 +12,7 @@ android:background="@color/colorPrimary"> - + app:layout_constraintTop_toTopOf="parent" + android:layout_width="0dp" + android:layout_height="0dp"> + + + android:layout_height="match_parent" + android:enabled="false"/> - + android:layout_height="match_parent" + app:tabBackground="@drawable/tab_selector" + app:tabGravity="center" + app:tabIndicatorHeight="0dp"> + +