Unverified Commit db6427c9 authored by Felix Förtsch's avatar Felix Förtsch
Browse files

add fake system scaffolding

parent 4d79d782
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal" created-in="IU-212.5457.46">
<component name="dataSourceStorageLocal" created-in="IU-213.5744.223">
<data-source name="luca-backend@localhost" uuid="b139cea7-7fec-437e-b885-9f4e9b70259b">
<database-info product="PostgreSQL" version="11.9" jdbc-version="4.2" driver-name="PostgreSQL JDBC Driver" driver-version="42.2.22" dbms="POSTGRES" exact-version="11.9" exact-driver-version="42.2">
<identifier-quote-string>&quot;</identifier-quote-string>
......
#n:public
!<md> [596, 0, null, null, -2147483648, -2147483648]
!<md> [757, 0, null, null, -2147483648, -2147483648]
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_4_API_30.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2021-12-06T19:09:20.248779Z" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationConfigOverride">
<CommitMessageValidationOverride>
<option name="enabled" value="true" />
</CommitMessageValidationOverride>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="../../../../../../layout/custom_preview.xml" value="0.34074074074074073" />
<entry key="app/src/main/res/layout/activity_fake_checkin.xml" value="0.29030797101449274" />
<entry key="app/src/main/res/layout/activity_fake_checkins.xml" value="0.29030797101449274" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.27219202898550726" />
<entry key="app/src/main/res/layout/activity_registration.xml" value="0.348731884057971" />
<entry key="app/src/main/res/layout/fragment_onboarding_info.xml" value="0.27219202898550726" />
<entry key="app/src/main/res/layout/fragment_onboarding_welcome.xml" value="0.29438405797101447" />
<entry key="app/src/main/res/layout/fragment_registration_all.xml" value="0.40208333333333335" />
<entry key="app/src/main/res/menu/bottom_navigation_menu.xml" value="0.40208333333333335" />
<entry key="app/src/main/res/menu/main_menu.xml" value="0.40208333333333335" />
</map>
</option>
</component>
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
......@@ -9,4 +25,11 @@
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.29030797101449274" />
</ProjectState>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
......@@ -64,6 +64,14 @@
</intent-filter>
</activity>
<activity
android:name=".ui.FakeCheckinActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="de.culture4life.luca.ui.registration.RegistrationActivity"
android:screenOrientation="portrait">
......
......@@ -24,6 +24,8 @@ import de.culture4life.luca.notification.LucaNotificationManager;
import de.culture4life.luca.preference.PreferencesManager;
import de.culture4life.luca.registration.RegistrationManager;
import de.culture4life.luca.service.LucaService;
import de.culture4life.luca.ui.FakeCheckinActivity;
import de.culture4life.luca.ui.MainActivity;
import de.culture4life.luca.ui.ViewError;
import de.culture4life.luca.ui.dialog.BaseDialogFragment;
......@@ -289,6 +291,12 @@ public class LucaApplication extends MultiDexApplication {
startActivity(intent);
}
public void openFakeMenu() {
Intent intent = new Intent(this, FakeCheckinActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
public Completable handleDeepLink(Uri uri) {
return Completable.fromAction(() -> deepLink = uri.toString());
}
......
package de.culture4life.luca.fake;
import android.content.Context;
import android.util.Pair;
import androidx.annotation.NonNull;
import com.google.gson.JsonObject;
import de.culture4life.luca.Manager;
import de.culture4life.luca.checkin.CheckInManager;
import de.culture4life.luca.crypto.AsymmetricCipherProvider;
import de.culture4life.luca.crypto.CryptoManager;
import de.culture4life.luca.network.NetworkManager;
import de.culture4life.luca.network.pojo.CheckInRequestData;
import de.culture4life.luca.network.pojo.ContactData;
import de.culture4life.luca.network.pojo.UserRegistrationRequestData;
import de.culture4life.luca.registration.RegistrationData;
import de.culture4life.luca.registration.RegistrationManager;
import de.culture4life.luca.ui.qrcode.QrCodeData;
import de.culture4life.luca.util.SerializationUtil;
import de.culture4life.luca.util.TimeUtil;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Single;
import org.jetbrains.annotations.NotNull;
import java.security.KeyPair;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.interfaces.ECPublicKey;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import static de.culture4life.luca.util.SerializationUtil.serializeToBase64;
public class FakeManager extends Manager {
RegistrationManager registrationManager;
CryptoManager cryptoManager;
NetworkManager networkManager;
CheckInManager checkInManager;
public FakeManager(
@NonNull RegistrationManager registrationManager,
@NonNull CryptoManager cryptoManager,
@NonNull NetworkManager networkManager,
@NonNull CheckInManager checkInManager) {
this.registrationManager = registrationManager;
this.cryptoManager = cryptoManager;
this.networkManager = networkManager;
this.checkInManager = checkInManager;
}
@Override
protected Completable doInitialize(@NonNull Context context) {
return Completable.mergeArray(
registrationManager.initialize(context),
networkManager.initialize(context),
cryptoManager.initialize(context),
checkInManager.initialize(context)
).andThen(Completable.fromAction(() -> this.context = context));
}
public UUID doFakeRegistration() {
// Create Fake RegistrationData
RegistrationData registrationData = getFakeRegistrationData();
// Make it a ContactData
ContactData contactData = new ContactData(registrationData);
Pair<Single<byte[]>, Single<Pair<byte[], byte[]>>> stuffedPair = registrationManager.encryptFakeContactData(contactData);
Single<byte[]> datasecret = stuffedPair.first;
Pair<byte[], byte[]> encryptedContactData = stuffedPair.second.blockingGet();
// Wrap it into a RequestData
UserRegistrationRequestData requestData = new UserRegistrationRequestData();
String serializedEncryptedData = serializeToBase64(encryptedContactData.first).blockingGet();
requestData.setEncryptedContactData(serializedEncryptedData);
String serializedIv = serializeToBase64(encryptedContactData.second).blockingGet();
requestData.setIv(serializedIv);
byte[] mac = datasecret
.flatMap(cryptoManager::generateDataAuthenticationSecret)
.flatMap(CryptoManager::createKeyFromSecret)
.flatMap(dataAuthenticationKey ->
cryptoManager.getMacProvider()
.sign(encryptedContactData.first, dataAuthenticationKey))
.blockingGet();
String serializedMac = serializeToBase64(mac).blockingGet();
requestData.setMac(serializedMac);
byte[] signature = registrationManager
.createContactDataSignature(encryptedContactData.first, mac, encryptedContactData.second)
.blockingGet();
String serializedSignature = serializeToBase64(signature).blockingGet();
requestData.setSignature(serializedSignature);
ECPublicKey publicKey = cryptoManager.getGuestKeyPairPublicKey().blockingGet();
String serializedPublicKey = AsymmetricCipherProvider.encode(publicKey)
.flatMap(SerializationUtil::serializeToBase64)
.blockingGet();
requestData.setGuestKeyPairPublicKey(serializedPublicKey);
// Make network request and get UserID
JsonObject jsonObject = networkManager.getLucaEndpoints().registerUser(requestData).blockingGet();
System.out.println(jsonObject.get("userId").getAsString());
return UUID.fromString(jsonObject.get("userId").getAsString());
}
// private void doFakeCheckIn() {
// QrCodeData qrCodeData = generateFakeQrCodeData();
//
// checkInManager.checkIn(UUID.fromString("09eb8d41-1914-4950-9526-36ebc6ad58fe"), qrCodeData);
// }
// private QrCodeData generateFakeQrCodeData() {
// UUID userId = UUID.fromString("80caf273-2bbd-42fa-b1d7-0e5309d40d82");
//
// Single<QrCodeData> qrCodeDataSingle = Single.just(new QrCodeData())
// .flatMap(qrCodeData -> cryptoManager.getTraceIdWrapper(userId)
// .flatMapCompletable(userTraceIdWrapper -> Completable.mergeArray(
// cryptoManager.getDailyKeyPairPublicKeyWrapper()
// .map(DailyKeyPairPublicKeyWrapper::getId)
// .doOnSuccess(qrCodeData::setKeyId)
// .ignoreElement(),
// cryptoManager.getUserEphemeralKeyPair(userTraceIdWrapper.getTraceId())
// .observeOn(Schedulers.computation())
// .flatMapCompletable(keyPair -> Completable.mergeArray(
// encryptUserIdAndSecret(userId, keyPair)
// .doOnSuccess(encryptedDataAndIv -> qrCodeData.setEncryptedData(encryptedDataAndIv.first))
// .flatMap(encryptedDataAndIv -> generateVerificationTag(encryptedDataAndIv.first, userTraceIdWrapper.getTimestamp())
// .doOnSuccess(qrCodeData::setVerificationTag))
// .ignoreElement(),
// Single.just(keyPair.getPublic())
// .cast(ECPublicKey.class)
// .flatMap(publicKey -> AsymmetricCipherProvider.encode(publicKey, true))
// .doOnSuccess(qrCodeData::setUserEphemeralPublicKey)
// .ignoreElement()
// )),
// TimeUtil.encodeUnixTimestamp(userTraceIdWrapper.getTimestamp())
// .doOnSuccess(qrCodeData::setTimestamp)
// .ignoreElement(),
// Completable.fromAction(() -> qrCodeData.setTraceId(userTraceIdWrapper.getTraceId()))))
// .andThen(Single.just(qrCodeData)));
//
// return qrCodeDataSingle.blockingGet();
// }
// private CheckInRequestData generateCheckInData(@NonNull QrCodeData qrCodeData, @NonNull PublicKey locationPublicKey) {
// CheckInRequestData checkInRequestData = new CheckInRequestData();
// SecureRandom random = new SecureRandom();
//
// checkInRequestData.setDeviceType(1);
// checkInRequestData.setUnixTimestamp(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()));
//
// byte[] traceId = new byte[16];
// random.nextBytes(traceId);
// String serialisedTraceId = serializeToBase64(traceId).blockingGet();
// checkInRequestData.setTraceId(serialisedTraceId);
//
// KeyPair scannerEphemeralKeyPair = cryptoManager.generateScannerEphemeralKeyPair().blockingGet();
// cryptoManager.persistScannerEphemeralKeyPair(scannerEphemeralKeyPair).blockingAwait();
//
// String serializedScannerPublicKey = AsymmetricCipherProvider.encode((ECPublicKey) scannerEphemeralKeyPair.getPublic())
// .flatMap(SerializationUtil::serializeToBase64).blockingGet();
// checkInRequestData.setScannerEphemeralPublicKey(serializedScannerPublicKey);
//
// byte[] iv = cryptoManager.generateSecureRandomData(16).blockingGet();
// String encodedIv = serializeToBase64(iv).blockingGet();
// checkInRequestData.setIv(encodedIv);
//
// byte[] diffieHellmanSecret = cryptoManager.getAsymmetricCipherProvider()
// .generateSecret(scannerEphemeralKeyPair.getPrivate(), locationPublicKey).blockingGet();
//
// byte[] encryptedQrCodeData = encryptQrCodeData(qrCodeData, iv, diffieHellmanSecret).blockingGet();
// String serialisedEncryptedQrCodeData = serializeToBase64(encryptedQrCodeData).blockingGet();
// checkInRequestData.setReEncryptedQrCodeData(serialisedEncryptedQrCodeData);
//
// String serialisedMac = createQrCodeDataMac(encryptedQrCodeData, diffieHellmanSecret)
// .flatMap(SerializationUtil::serializeToBase64).blockingGet();
// checkInRequestData.setMac(serialisedMac);
//
// return checkInRequestData;
// }
public static RegistrationData getFakeRegistrationData() {
RegistrationData registrationData = new RegistrationData();
registrationData.setFirstName(UUID.randomUUID().toString());
registrationData.setLastName(UUID.randomUUID().toString());
registrationData.setPhoneNumber(UUID.randomUUID().toString());
registrationData.setEmail(UUID.randomUUID().toString());
registrationData.setStreet(UUID.randomUUID().toString());
registrationData.setHouseNumber(UUID.randomUUID().toString());
registrationData.setPostalCode(UUID.randomUUID().toString());
registrationData.setCity(UUID.randomUUID().toString());
return registrationData;
}
}
\ No newline at end of file
......@@ -207,6 +207,10 @@ public abstract class BaseFragment<ViewModelType extends BaseViewModel> extends
application.openAppSettings();
break;
}
case R.id.fakeMenuItem: {
application.openFakeMenu();
break;
}
default: {
Timber.w("Unknown menu item selected: %s", item.getTitle());
return false;
......
package de.culture4life.luca.ui;
import static de.culture4life.luca.fake.FakeManager.getFakeRegistrationData;
import static de.culture4life.luca.registration.RegistrationManager.REGISTRATION_DATA_KEY;
import static de.culture4life.luca.registration.RegistrationManager.USER_ID_KEY;
import static de.culture4life.luca.util.SerializationUtil.serializeToBase64;
import android.content.Intent;
import android.os.Bundle;
import android.util.Pair;
import android.widget.SeekBar;
import android.widget.TextView;
import com.google.gson.JsonObject;
import de.culture4life.luca.R;
import de.culture4life.luca.checkin.CheckInManager;
import de.culture4life.luca.crypto.AsymmetricCipherProvider;
import de.culture4life.luca.crypto.CryptoManager;
import de.culture4life.luca.crypto.DailyKeyPairPublicKeyWrapper;
import de.culture4life.luca.fake.FakeManager;
import de.culture4life.luca.network.NetworkManager;
import de.culture4life.luca.network.pojo.ContactData;
import de.culture4life.luca.network.pojo.UserRegistrationRequestData;
import de.culture4life.luca.preference.PreferencesManager;
import de.culture4life.luca.registration.RegistrationData;
import de.culture4life.luca.registration.RegistrationManager;
import de.culture4life.luca.ui.qrcode.QrCodeData;
import de.culture4life.luca.util.SerializationUtil;
import de.culture4life.luca.util.TimeUtil;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.schedulers.Schedulers;
import timber.log.Timber;
import java.security.interfaces.ECPublicKey;
import java.util.Random;
import java.util.UUID;
public class FakeCheckinActivity extends BaseActivity {
private final CustomOnSeekBarChangeListener seekBarListener = new CustomOnSeekBarChangeListener();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fake_checkins);
SeekBar checkinCountSeekbar = findViewById(R.id.checkinCountSeekbar);
checkinCountSeekbar.setOnSeekBarChangeListener(seekBarListener);
findViewById(R.id.fakeCheckinButton).setOnClickListener(view -> {
fakeRegistrationAndCheckIn(seekBarListener.getProgress());
});
findViewById(R.id.homeButton).setOnClickListener(view -> {
fakeRegistration();
showMainApp();
});
}
private void fakeRegistration() {
activityDisposable.add(application.getPreferencesManager()
.persist(REGISTRATION_DATA_KEY, FakeManager.getFakeRegistrationData())
.onErrorComplete()
.subscribe());
activityDisposable.add(application.getRegistrationManager()
.registerUser()
.subscribe());
showMainApp();
}
private void fakeRegistrationAndCheckIn(Integer registrationCount) {
for (int i = 0; i < registrationCount; i++) {
System.out.println("FakeManager: Do fake registration");
System.out.println("FakeManager: Do fake checkin");
}
}
private void showMainApp() {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
}
private class CustomOnSeekBarChangeListener implements SeekBar.OnSeekBarChangeListener {
private Integer progress;
public CustomOnSeekBarChangeListener() {
this.progress = 1;
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser