reformat code

pull/1/head
Felix Prahl-Kamps 2019-07-24 12:16:51 +02:00
parent b52fe8ea51
commit 5ad8287b67
41 changed files with 120 additions and 33 deletions

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.activities;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
@ -34,6 +35,7 @@ import lu.circl.mispbump.models.SyncInformation;
import lu.circl.mispbump.models.UploadInformation;
import lu.circl.mispbump.security.DiffieHellman;
public class ExchangeActivity extends AppCompatActivity {
private PreferenceManager preferenceManager;

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.activities;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
@ -24,6 +25,7 @@ import lu.circl.mispbump.auxiliary.PreferenceManager;
import lu.circl.mispbump.interfaces.OnRecyclerItemClickListener;
import lu.circl.mispbump.models.UploadInformation;
public class HomeActivity extends AppCompatActivity {
private List<UploadInformation> uploadInformationList;

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.activities;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Shader;
@ -34,6 +35,7 @@ import lu.circl.mispbump.models.restModels.Role;
import lu.circl.mispbump.models.restModels.User;
import lu.circl.mispbump.security.KeyStoreWrapper;
public class ProfileActivity extends AppCompatActivity {
private CoordinatorLayout rootLayout;

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.activities;
import android.content.Intent;
import android.os.Bundle;
@ -7,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity;
import lu.circl.mispbump.auxiliary.PreferenceManager;
/**
* Starts either the login or home activity.
*/

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.activities;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
@ -24,6 +25,7 @@ import lu.circl.mispbump.models.restModels.Organisation;
import lu.circl.mispbump.models.restModels.Server;
import lu.circl.mispbump.models.restModels.User;
public class UploadActivity extends AppCompatActivity {
public static String EXTRA_UPLOAD_INFO = "uploadInformation";

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.activities;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
@ -29,6 +30,7 @@ import lu.circl.mispbump.fragments.UploadCredentialsFragment;
import lu.circl.mispbump.fragments.UploadSettingsFragment;
import lu.circl.mispbump.models.UploadInformation;
public class UploadInfoActivity extends AppCompatActivity {
public static String EXTRA_UPLOAD_INFO_UUID = "uploadInformationUuid";
@ -92,7 +94,8 @@ public class UploadInfoActivity extends AppCompatActivity {
}
@Override
public void negative() {}
public void negative() {
}
});
return true;

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.adapters;
import android.content.Context;
import android.content.res.ColorStateList;
import android.view.LayoutInflater;
@ -18,6 +19,7 @@ import lu.circl.mispbump.R;
import lu.circl.mispbump.interfaces.OnRecyclerItemClickListener;
import lu.circl.mispbump.models.UploadInformation;
public class UploadInfoAdapter extends RecyclerView.Adapter<UploadInfoAdapter.ViewHolder> {
private Context context;
@ -114,5 +116,4 @@ public class UploadInfoAdapter extends RecyclerView.Adapter<UploadInfoAdapter.Vi
syncStatus = itemView.findViewById(R.id.syncStatus);
}
}
}

View File

@ -1,9 +1,9 @@
package lu.circl.mispbump.auxiliary;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;
@ -13,6 +13,7 @@ import lu.circl.mispbump.R;
import lu.circl.mispbump.models.SyncInformation;
import lu.circl.mispbump.security.DiffieHellman;
/**
* Creates and show dialogs.
* Automatically takes care of using the UI Thread.
@ -134,8 +135,8 @@ public class DialogManager {
* Dialog to display a received public key.
*
* @param syncInformation {@link SyncInformation}
* @param context needed to build and show the dialog
* @param callback {@link IDialogFeedback}
* @param context needed to build and show the dialog
* @param callback {@link IDialogFeedback}
*/
public static void syncInformationDialog(SyncInformation syncInformation, Context context, final IDialogFeedback callback) {
@ -216,7 +217,6 @@ public class DialogManager {
*/
public static void loginHelpDialog(Context context) {
final AlertDialog.Builder adb = new AlertDialog.Builder(context);
// adb.setTitle(R.string.app_name);
adb.setMessage(R.string.login_help_text);
adb.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
@ -304,6 +304,7 @@ public class DialogManager {
*/
public interface IDialogFeedback {
void positive();
void negative();
}

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.auxiliary;
import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
@ -37,6 +38,7 @@ import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Implementation of the RetroFit2 Misp client.
* In order to conveniently use this api some wrapper interfaces are implemented to return the requested API endpoint as java object.

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.auxiliary;
import android.content.Context;
import android.content.SharedPreferences;
@ -26,6 +27,7 @@ import lu.circl.mispbump.models.restModels.Role;
import lu.circl.mispbump.models.restModels.User;
import lu.circl.mispbump.security.KeyStoreWrapper;
public class PreferenceManager {
private static final String PREFERENCES_FILE = "user_settings";
@ -229,7 +231,8 @@ public class PreferenceManager {
try {
KeyStoreWrapper keyStoreWrapper = new KeyStoreWrapper(KeyStoreWrapper.USER_CREDENTIALS_ALIAS);
Type type = new TypeToken<Pair<String, String>>() {}.getType();
Type type = new TypeToken<Pair<String, String>>() {
}.getType();
String serializedCreds = keyStoreWrapper.decrypt(preferences.getString(USER_CREDENTIALS, ""));
return new Gson().fromJson(serializedCreds, type);
} catch (InvalidKeyException | InvalidAlgorithmParameterException | NoSuchPaddingException | BadPaddingException | IllegalBlockSizeException | NoSuchAlgorithmException e) {

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.auxiliary;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Point;
@ -13,6 +14,7 @@ import com.google.zxing.common.BitMatrix;
import java.util.HashMap;
import java.util.Map;
public class QrCodeGenerator {
private Activity callingActivity;
@ -32,7 +34,7 @@ public class QrCodeGenerator {
size = displaySize.y;
}
size = (int)(size * 0.8);
size = (int) (size * 0.8);
try {
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();

View File

@ -1,9 +1,12 @@
package lu.circl.mispbump.auxiliary;
import java.security.SecureRandom;
import java.util.Locale;
import java.util.Objects;
import java.util.Random;
public class RandomString {
@SuppressWarnings("SpellCheckingInspection")
private static final String upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

View File

@ -1,12 +1,6 @@
package lu.circl.mispbump.auxiliary
import android.graphics.Bitmap
import android.graphics.BitmapShader
import android.graphics.Canvas
import android.graphics.ColorFilter
import android.graphics.Paint
import android.graphics.PixelFormat
import android.graphics.Shader
import android.graphics.*
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable

View File

@ -20,6 +20,7 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.TextureView;
/**
* A {@link TextureView} that can be adjusted to a specified aspect ratio.
*/

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.customViews;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
@ -9,7 +10,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import java.util.ConcurrentModificationException;
/**
* Can disable touch input on bottom sheet.

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.customViews;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
@ -8,6 +9,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;
public class ExtendedViewPager extends ViewPager {
private boolean swipeEnabled;

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.customViews;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
@ -7,6 +8,7 @@ import android.widget.FrameLayout;
import lu.circl.mispbump.R;
public class FixedAspectRatioFrameLayout extends FrameLayout {
private int mAspectRatioWidth;
private int mAspectRatioHeight;

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.customViews;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.method.PasswordTransformationMethod;
@ -13,6 +14,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import lu.circl.mispbump.R;
public class MaterialPasswordView extends ConstraintLayout {
private TextView titleView, passwordView;

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.customViews;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
@ -13,6 +14,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import lu.circl.mispbump.R;
public class MaterialPreferenceSwitch extends ConstraintLayout {
private View rootView;

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.customViews;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
@ -14,6 +15,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import lu.circl.mispbump.R;
public class MaterialPreferenceText extends ConstraintLayout {
private View rootView;
@ -32,7 +34,7 @@ public class MaterialPreferenceText extends ConstraintLayout {
icon = view.findViewById(R.id.material_preference_src);
int imageRes = a.getResourceId(R.styleable.MaterialPreferenceText_pref_icon, 0x0);
if (imageRes != 0x0){
if (imageRes != 0x0) {
icon.setImageResource(imageRes);
} else {
icon.setVisibility(GONE);

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.customViews;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
@ -15,6 +16,7 @@ import androidx.core.widget.ImageViewCompat;
import lu.circl.mispbump.R;
public class UploadAction extends ConstraintLayout {
private Context context;
@ -64,6 +66,7 @@ public class UploadAction extends ConstraintLayout {
/**
* Displays an error message for the upload action.
*
* @param error a string to show or null to hide
*/
public void setError(String error) {

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.fragments;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
@ -62,6 +63,7 @@ import java.util.concurrent.TimeUnit;
import lu.circl.mispbump.R;
import lu.circl.mispbump.customViews.AutoFitTextureView;
public class CameraFragment extends Fragment implements ActivityCompat.OnRequestPermissionsResultCallback {
private class ImageProcessingThread extends Thread {

View File

@ -1,11 +1,13 @@
package lu.circl.mispbump.fragments;
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
import lu.circl.mispbump.R;
public class PreferencesFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

View File

@ -1,10 +1,12 @@
package lu.circl.mispbump.fragments;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
public class SyncFragmentAdapter extends FragmentPagerAdapter {
public CameraFragment cameraFragment_1, cameraFragment_2;

View File

@ -18,12 +18,15 @@ import lu.circl.mispbump.customViews.MaterialPasswordView;
import lu.circl.mispbump.customViews.MaterialPreferenceText;
import lu.circl.mispbump.models.UploadInformation;
public class UploadCredentialsFragment extends Fragment {
private View rootLayout;
private UploadInformation uploadInformation;
public UploadCredentialsFragment() {}
public UploadCredentialsFragment() {
}
public UploadCredentialsFragment(UploadInformation uploadInformation) {
this.uploadInformation = uploadInformation;
}

View File

@ -1,7 +1,7 @@
package lu.circl.mispbump.fragments;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -13,6 +13,7 @@ import lu.circl.mispbump.R;
import lu.circl.mispbump.customViews.MaterialPreferenceSwitch;
import lu.circl.mispbump.models.UploadInformation;
public class UploadSettingsFragment extends Fragment {
private MaterialPreferenceSwitch allowSelfSigned, push, pull, cache;

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.interfaces;
import java.util.List;
import lu.circl.mispbump.models.restModels.MispOrganisation;
@ -16,6 +17,7 @@ import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
/**
* RetroFit2 interface for communication with misp instances
*/

View File

@ -1,7 +1,9 @@
package lu.circl.mispbump.interfaces;
import android.view.View;
public interface OnRecyclerItemClickListener<T> {
void onClick(View v, T item);
}

View File

@ -1,7 +1,9 @@
package lu.circl.mispbump.models;
import lu.circl.mispbump.models.restModels.Organisation;
/**
* A Class that holds the information needed synchronize two misp instances.
* This class can be serialized and passed via QR code.
@ -14,7 +16,8 @@ public class SyncInformation {
public String syncUserAuthkey;
public String baseUrl;
public SyncInformation() {}
public SyncInformation() {
}
@Override
public String toString() {

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.models;
import androidx.annotation.NonNull;
import java.text.SimpleDateFormat;
@ -8,6 +9,7 @@ import java.util.Date;
import java.util.Locale;
import java.util.UUID;
public class UploadInformation {
public enum SyncStatus {
@ -37,6 +39,7 @@ public class UploadInformation {
public void setCurrentSyncStatus(SyncStatus status) {
currentSyncStatus = status;
}
public SyncStatus getCurrentSyncStatus() {
return currentSyncStatus;
}
@ -44,6 +47,7 @@ public class UploadInformation {
public void setLocal(SyncInformation local) {
this.local = local;
}
public SyncInformation getLocal() {
return local;
}
@ -51,6 +55,7 @@ public class UploadInformation {
public void setRemote(SyncInformation remote) {
this.remote = remote;
}
public SyncInformation getRemote() {
return remote;
}
@ -58,6 +63,7 @@ public class UploadInformation {
public UUID getUuid() {
return uuid;
}
public void setUuid(UUID uuid) {
this.uuid = uuid;
}
@ -65,12 +71,15 @@ public class UploadInformation {
public void setDate() {
setDate(Calendar.getInstance().getTime());
}
public void setDate(Date date) {
this.date = date;
}
public Date getDate() {
return date;
}
public String getDateString() {
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy", Locale.getDefault());
return df.format(date);
@ -79,6 +88,7 @@ public class UploadInformation {
public boolean isAllowSelfSigned() {
return allowSelfSigned;
}
public void setAllowSelfSigned(boolean allowSelfSigned) {
this.allowSelfSigned = allowSelfSigned;
}
@ -86,6 +96,7 @@ public class UploadInformation {
public boolean isPull() {
return pull;
}
public void setPull(boolean pull) {
this.pull = pull;
}
@ -93,6 +104,7 @@ public class UploadInformation {
public boolean isPush() {
return push;
}
public void setPush(boolean push) {
this.push = push;
}
@ -100,6 +112,7 @@ public class UploadInformation {
public boolean isCached() {
return cached;
}
public void setCached(boolean cached) {
this.cached = cached;
}

View File

@ -1,8 +1,10 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class MispOrganisation {
@SerializedName("Organisation")
@Expose

View File

@ -1,8 +1,10 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class MispRole {
@SerializedName("Role")
@Expose

View File

@ -1,12 +1,16 @@
package lu.circl.mispbump.models.restModels;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class MispServer {
public MispServer() {}
public MispServer() {
}
public MispServer(Server server, Organisation organisation, Organisation remoteOrganisation) {
this.server = server;

View File

@ -1,8 +1,10 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class MispUser {
@SerializedName("User")

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.models.restModels;
/**
* Information gathered from Misp API about a organisation.
*/

View File

@ -1,7 +1,9 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.SerializedName;
public class Role {
@SerializedName("id")
private Integer id;

View File

@ -1,10 +1,13 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.SerializedName;
public class Server {
public Server() {}
public Server() {
}
public Server(String name, String url, String authkey, Integer remote_org_id) {
this.name = name;

View File

@ -1,8 +1,10 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class User {
public static final int ROLE_ADMIN = 1;

View File

@ -1,7 +1,9 @@
package lu.circl.mispbump.models.restModels;
import com.google.gson.annotations.SerializedName;
public class Version {
@SerializedName("version")

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.security;
import android.util.Base64;
import java.nio.charset.StandardCharsets;
@ -22,6 +23,7 @@ import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
/**
* This class provides the functionality generate a shared secret key.
* Furthermore it contains the encryption/decryption methods.

View File

@ -1,5 +1,6 @@
package lu.circl.mispbump.security;
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
import android.util.Base64;
@ -25,6 +26,7 @@ import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
public class KeyStoreWrapper {
public static final String USER_INFO_ALIAS = "ALIAS_USER_INFO";