mirror of https://github.com/MISP/misp-bump
fixed focus and clickable problems
parent
e860219dc4
commit
7123bea567
|
@ -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">
|
||||
|
|
|
@ -10,14 +10,10 @@ import androidx.appcompat.app.ActionBar;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
|
@ -26,9 +22,9 @@ import java.util.Objects;
|
|||
import lu.circl.mispbump.R;
|
||||
import lu.circl.mispbump.auxiliary.DialogManager;
|
||||
import lu.circl.mispbump.auxiliary.PreferenceManager;
|
||||
import lu.circl.mispbump.restful_client.MispRestClient;
|
||||
import lu.circl.mispbump.restful_client.Organisation;
|
||||
import lu.circl.mispbump.restful_client.User;
|
||||
import lu.circl.mispbump.auxiliary.MispRestClient;
|
||||
import lu.circl.mispbump.models.restModels.Organisation;
|
||||
import lu.circl.mispbump.models.restModels.User;
|
||||
|
||||
/**
|
||||
* This activity is shown when the current device has no misp user and organisation associated with it.
|
||||
|
|
|
@ -13,6 +13,8 @@ import androidx.appcompat.app.ActionBar;
|
|||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -24,10 +26,10 @@ import java.util.Random;
|
|||
import lu.circl.mispbump.R;
|
||||
import lu.circl.mispbump.auxiliary.PreferenceManager;
|
||||
import lu.circl.mispbump.auxiliary.TileDrawable;
|
||||
import lu.circl.mispbump.custom_views.MaterialPreferenceText;
|
||||
import lu.circl.mispbump.restful_client.MispRestClient;
|
||||
import lu.circl.mispbump.restful_client.Organisation;
|
||||
import lu.circl.mispbump.restful_client.User;
|
||||
import lu.circl.mispbump.customViews.MaterialPreferenceText;
|
||||
import lu.circl.mispbump.auxiliary.MispRestClient;
|
||||
import lu.circl.mispbump.models.restModels.Organisation;
|
||||
import lu.circl.mispbump.models.restModels.User;
|
||||
import lu.circl.mispbump.security.KeyStoreWrapper;
|
||||
|
||||
public class ProfileActivity extends AppCompatActivity {
|
||||
|
@ -47,11 +49,11 @@ public class ProfileActivity extends AppCompatActivity {
|
|||
mispRestClient = MispRestClient.getInstance(this);
|
||||
preferenceManager = PreferenceManager.getInstance(this);
|
||||
|
||||
initializeViews();
|
||||
init();
|
||||
populateInformationViews();
|
||||
}
|
||||
|
||||
private void initializeViews() {
|
||||
private void init() {
|
||||
rootLayout = findViewById(R.id.rootLayout);
|
||||
|
||||
ImageView headerBg = findViewById(R.id.headerBg);
|
||||
|
@ -79,21 +81,27 @@ public class ProfileActivity extends AppCompatActivity {
|
|||
TextView name = findViewById(R.id.orgName);
|
||||
name.setText(organisation.name);
|
||||
|
||||
MaterialPreferenceText uuid = findViewById(R.id.uuid);
|
||||
uuid.setSubText(organisation.uuid);
|
||||
final MaterialPreferenceText uuid = findViewById(R.id.uuid);
|
||||
uuid.setSubtitle(organisation.uuid);
|
||||
// uuid.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// Snackbar.make(rootLayout, "Copied to clipboard", Snackbar.LENGTH_LONG).show();
|
||||
// }
|
||||
// });
|
||||
|
||||
MaterialPreferenceText nationality = findViewById(R.id.nationality);
|
||||
nationality.setSubText(organisation.nationality);
|
||||
nationality.setSubtitle(organisation.nationality);
|
||||
|
||||
MaterialPreferenceText sector = findViewById(R.id.sector);
|
||||
if (organisation.sector == null) {
|
||||
sector.setVisibility(View.GONE);
|
||||
} else {
|
||||
sector.setSubText(organisation.sector);
|
||||
sector.setSubtitle(organisation.sector);
|
||||
}
|
||||
|
||||
MaterialPreferenceText description = findViewById(R.id.description);
|
||||
description.setSubText(organisation.description);
|
||||
description.setSubtitle(organisation.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.os.Bundle;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import lu.circl.mispbump.auxiliary.PreferenceManager;
|
||||
import lu.circl.mispbump.restful_client.User;
|
||||
import lu.circl.mispbump.models.restModels.User;
|
||||
|
||||
public class StartUpActivity extends AppCompatActivity {
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ import lu.circl.mispbump.R;
|
|||
import lu.circl.mispbump.auxiliary.PreferenceManager;
|
||||
import lu.circl.mispbump.auxiliary.QrCodeGenerator;
|
||||
import lu.circl.mispbump.auxiliary.RandomString;
|
||||
import lu.circl.mispbump.cam.CameraFragment;
|
||||
import lu.circl.mispbump.custom_views.ExtendedBottomSheetBehavior;
|
||||
import lu.circl.mispbump.fragments.CameraFragment;
|
||||
import lu.circl.mispbump.customViews.ExtendedBottomSheetBehavior;
|
||||
import lu.circl.mispbump.fragments.SyncOptionsFragment;
|
||||
import lu.circl.mispbump.models.SyncInformation;
|
||||
import lu.circl.mispbump.models.UploadInformation;
|
||||
|
|
|
@ -18,15 +18,14 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import lu.circl.mispbump.R;
|
||||
import lu.circl.mispbump.auxiliary.DialogManager;
|
||||
import lu.circl.mispbump.auxiliary.PreferenceManager;
|
||||
import lu.circl.mispbump.custom_views.UploadAction;
|
||||
import lu.circl.mispbump.customViews.UploadAction;
|
||||
import lu.circl.mispbump.models.UploadInformation;
|
||||
import lu.circl.mispbump.restful_client.MispRestClient;
|
||||
import lu.circl.mispbump.restful_client.MispServer;
|
||||
import lu.circl.mispbump.restful_client.Organisation;
|
||||
import lu.circl.mispbump.restful_client.Server;
|
||||
import lu.circl.mispbump.restful_client.User;
|
||||
import lu.circl.mispbump.auxiliary.MispRestClient;
|
||||
import lu.circl.mispbump.models.restModels.MispServer;
|
||||
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 {
|
||||
|
||||
|
@ -207,11 +206,6 @@ public class UploadActivity extends AppCompatActivity {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void success(MispServer server) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void success(Server server) {
|
||||
serverAction.setCurrentUploadState(UploadAction.UploadState.DONE);
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package lu.circl.mispbump.auxiliary;
|
||||
|
||||
public class KeyValue<K, V> {
|
||||
public K key;
|
||||
public V value;
|
||||
|
||||
/**
|
||||
* Generates a generic key value pair.
|
||||
* @param key key
|
||||
* @param value value
|
||||
*/
|
||||
public KeyValue(K key, V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
package lu.circl.mispbump.restful_client;
|
||||
package lu.circl.mispbump.auxiliary;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.NoRouteToHostException;
|
||||
import java.security.cert.CertPathValidatorException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -22,7 +20,14 @@ import javax.net.ssl.SSLSocketFactory;
|
|||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import lu.circl.mispbump.auxiliary.PreferenceManager;
|
||||
import lu.circl.mispbump.interfaces.MispRestInterface;
|
||||
import lu.circl.mispbump.models.restModels.MispOrganisation;
|
||||
import lu.circl.mispbump.models.restModels.MispServer;
|
||||
import lu.circl.mispbump.models.restModels.MispUser;
|
||||
import lu.circl.mispbump.models.restModels.Organisation;
|
||||
import lu.circl.mispbump.models.restModels.Server;
|
||||
import lu.circl.mispbump.models.restModels.User;
|
||||
import lu.circl.mispbump.models.restModels.Version;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
@ -39,6 +44,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
*/
|
||||
public class MispRestClient {
|
||||
|
||||
|
||||
public interface AvailableCallback {
|
||||
void available();
|
||||
|
||||
|
@ -60,8 +66,6 @@ public class MispRestClient {
|
|||
public interface ServerCallback {
|
||||
void success(List<MispServer> servers);
|
||||
|
||||
void success(MispServer server);
|
||||
|
||||
void success(Server server);
|
||||
|
||||
void failure(String error);
|
||||
|
@ -69,8 +73,9 @@ public class MispRestClient {
|
|||
|
||||
|
||||
private static MispRestClient instance;
|
||||
|
||||
private PreferenceManager preferenceManager;
|
||||
private MispRestService mispRestService;
|
||||
private MispRestInterface mispRestInterface;
|
||||
|
||||
|
||||
public static MispRestClient getInstance(Context context) {
|
||||
|
@ -95,64 +100,68 @@ public class MispRestClient {
|
|||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(url)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(getUnsafeOkHttpClient())
|
||||
.client(getCustomClient(true, false))
|
||||
.build();
|
||||
|
||||
mispRestService = retrofit.create(MispRestService.class);
|
||||
mispRestInterface = retrofit.create(MispRestInterface.class);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: for development only!
|
||||
* <p>
|
||||
* Accepts all certificates including self signed.
|
||||
*
|
||||
* @return {@link OkHttpClient} which accepts all certificates
|
||||
* @param unsafe whether to accept all certificates or only trusted ones
|
||||
* @param logging whether to log Retrofit calls (for debugging)
|
||||
* @return {@link OkHttpClient}
|
||||
*/
|
||||
private OkHttpClient getUnsafeOkHttpClient() {
|
||||
private OkHttpClient getCustomClient(boolean unsafe, boolean logging) {
|
||||
try {
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
final TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@SuppressLint("TrustAllX509TrustManager")
|
||||
@Override
|
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@SuppressLint("TrustAllX509TrustManager")
|
||||
@Override
|
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return new java.security.cert.X509Certificate[]{};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Install the all-trusting trust manager
|
||||
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
|
||||
// Create an ssl socket factory with our all-trusting manager
|
||||
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager)trustAllCerts[0]);
|
||||
builder.hostnameVerifier(new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// create logging interceptor
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
builder.addInterceptor(interceptor);
|
||||
if (unsafe) {
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
final TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@SuppressLint("TrustAllX509TrustManager")
|
||||
@Override
|
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@SuppressLint("TrustAllX509TrustManager")
|
||||
@Override
|
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return new java.security.cert.X509Certificate[]{};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Install the all-trusting trust manager
|
||||
final SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
|
||||
// Create an ssl socket factory with our all-trusting manager
|
||||
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
|
||||
|
||||
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager)trustAllCerts[0]);
|
||||
builder.hostnameVerifier(new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (logging) {
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
builder.addInterceptor(interceptor);
|
||||
}
|
||||
|
||||
// create authorization interceptor
|
||||
builder.addInterceptor(new Interceptor() {
|
||||
|
@ -167,12 +176,12 @@ public class MispRestClient {
|
|||
});
|
||||
|
||||
return builder.build();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// status routes
|
||||
|
||||
/**
|
||||
* Check via pyMispRoute if server is available
|
||||
|
@ -180,7 +189,7 @@ public class MispRestClient {
|
|||
* @param callback {@link AvailableCallback}
|
||||
*/
|
||||
public void isAvailable(final AvailableCallback callback) {
|
||||
Call<Version> call = mispRestService.pyMispVersion();
|
||||
Call<Version> call = mispRestInterface.pyMispVersion();
|
||||
call.enqueue(new Callback<Version>() {
|
||||
@Override
|
||||
public void onResponse(Call<Version> call, Response<Version> response) {
|
||||
|
@ -203,7 +212,7 @@ public class MispRestClient {
|
|||
});
|
||||
}
|
||||
|
||||
// user routes
|
||||
|
||||
|
||||
/**
|
||||
* Fetches information about the user that is associated with saved auth key.
|
||||
|
@ -211,7 +220,7 @@ public class MispRestClient {
|
|||
* @param callback {@link UserCallback} wrapper to return user directly
|
||||
*/
|
||||
public void getMyUser(final UserCallback callback) {
|
||||
Call<MispUser> call = mispRestService.getMyUserInformation();
|
||||
Call<MispUser> call = mispRestInterface.getMyUserInformation();
|
||||
|
||||
call.enqueue(new Callback<MispUser>() {
|
||||
@Override
|
||||
|
@ -242,7 +251,7 @@ public class MispRestClient {
|
|||
* @param callback {@link UserCallback} wrapper to return user directly
|
||||
*/
|
||||
public void getUser(int userId, final UserCallback callback) {
|
||||
Call<MispUser> call = mispRestService.getUser(userId);
|
||||
Call<MispUser> call = mispRestInterface.getUser(userId);
|
||||
|
||||
call.enqueue(new Callback<MispUser>() {
|
||||
@Override
|
||||
|
@ -273,7 +282,7 @@ public class MispRestClient {
|
|||
* @param callback {@link UserCallback} wrapper to return the created user directly
|
||||
*/
|
||||
public void addUser(User user, final UserCallback callback) {
|
||||
Call<MispUser> call = mispRestService.addUser(user);
|
||||
Call<MispUser> call = mispRestInterface.addUser(user);
|
||||
|
||||
call.enqueue(new Callback<MispUser>() {
|
||||
@Override
|
||||
|
@ -294,7 +303,7 @@ public class MispRestClient {
|
|||
}
|
||||
|
||||
|
||||
// organisation routes
|
||||
// --- organisation routes ---
|
||||
|
||||
/**
|
||||
* Get an organisation by a given organisation id.
|
||||
|
@ -303,7 +312,7 @@ public class MispRestClient {
|
|||
* @param callback {@link OrganisationCallback} wrapper to return a organisation directly
|
||||
*/
|
||||
public void getOrganisation(int orgId, final OrganisationCallback callback) {
|
||||
Call<MispOrganisation> call = mispRestService.getOrganisation(orgId);
|
||||
Call<MispOrganisation> call = mispRestInterface.getOrganisation(orgId);
|
||||
|
||||
call.enqueue(new Callback<MispOrganisation>() {
|
||||
@Override
|
||||
|
@ -327,7 +336,7 @@ public class MispRestClient {
|
|||
}
|
||||
|
||||
public Organisation[] getAllOrganisations() throws IOException {
|
||||
Call<List<MispOrganisation>> call = mispRestService.getAllOrganisations();
|
||||
Call<List<MispOrganisation>> call = mispRestInterface.getAllOrganisations();
|
||||
Response<List<MispOrganisation>> response = call.execute();
|
||||
|
||||
List<MispOrganisation> mispOrganisations = response.body();
|
||||
|
@ -374,7 +383,7 @@ public class MispRestClient {
|
|||
* @param callback {@link OrganisationCallback} wrapper to return the created organisation directly
|
||||
*/
|
||||
public void addOrganisation(Organisation organisation, final OrganisationCallback callback) {
|
||||
Call<MispOrganisation> call = mispRestService.addOrganisation(organisation);
|
||||
Call<MispOrganisation> call = mispRestInterface.addOrganisation(organisation);
|
||||
|
||||
call.enqueue(new Callback<MispOrganisation>() {
|
||||
@Override
|
||||
|
@ -394,7 +403,7 @@ public class MispRestClient {
|
|||
});
|
||||
}
|
||||
|
||||
// server routes
|
||||
// --- server routes ---
|
||||
|
||||
/**
|
||||
* Get all servers on MISP instance.
|
||||
|
@ -402,7 +411,7 @@ public class MispRestClient {
|
|||
* @param callback {@link OrganisationCallback} wrapper to return a list of servers directly
|
||||
*/
|
||||
public void getServers(final ServerCallback callback) {
|
||||
Call<List<MispServer>> call = mispRestService.getServers();
|
||||
Call<List<MispServer>> call = mispRestInterface.getServers();
|
||||
|
||||
call.enqueue(new Callback<List<MispServer>>() {
|
||||
@Override
|
||||
|
@ -428,7 +437,7 @@ public class MispRestClient {
|
|||
* @param callback {@link ServerCallback} wrapper to return the created server directly
|
||||
*/
|
||||
public void addServer(Server server, final ServerCallback callback) {
|
||||
Call<Server> call = mispRestService.addServer(server);
|
||||
Call<Server> call = mispRestInterface.addServer(server);
|
||||
|
||||
call.enqueue(new Callback<Server>() {
|
||||
@Override
|
||||
|
@ -447,7 +456,7 @@ public class MispRestClient {
|
|||
});
|
||||
}
|
||||
|
||||
// error parsing
|
||||
// --- error parsing ---
|
||||
|
||||
/**
|
||||
* Converts error {@link Response}s to human readable info.
|
|
@ -20,8 +20,8 @@ import javax.crypto.IllegalBlockSizeException;
|
|||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import lu.circl.mispbump.models.UploadInformation;
|
||||
import lu.circl.mispbump.restful_client.Organisation;
|
||||
import lu.circl.mispbump.restful_client.User;
|
||||
import lu.circl.mispbump.models.restModels.Organisation;
|
||||
import lu.circl.mispbump.models.restModels.User;
|
||||
import lu.circl.mispbump.security.KeyStoreWrapper;
|
||||
|
||||
public class PreferenceManager {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.cam;
|
||||
package lu.circl.mispbump.customViews;
|
||||
|
||||
/*
|
||||
* Copyright 2014 The Android Open Source Project
|
|
@ -1,5 +1,7 @@
|
|||
package lu.circl.mispbump.custom_views;
|
||||
package lu.circl.mispbump.customViews;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
|
@ -7,14 +9,24 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
/**
|
||||
* Can disable touch input on bottom sheet.
|
||||
*
|
||||
* @param <V>
|
||||
*/
|
||||
public class ExtendedBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
|
||||
|
||||
private boolean swipeable = false;
|
||||
|
||||
public ExtendedBottomSheetBehavior() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ExtendedBottomSheetBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
|
|
@ -0,0 +1,79 @@
|
|||
package lu.circl.mispbump.customViews;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import lu.circl.mispbump.R;
|
||||
|
||||
public class MaterialPreferenceText extends ConstraintLayout {
|
||||
|
||||
private View rootView;
|
||||
private ImageView icon;
|
||||
private TextView title, subtitle;
|
||||
|
||||
|
||||
public MaterialPreferenceText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.material_preference_text, this);
|
||||
|
||||
rootView = view.findViewById(R.id.rootLayout);
|
||||
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MaterialPreferenceText);
|
||||
|
||||
icon = view.findViewById(R.id.material_preference_src);
|
||||
icon.setImageResource(a.getResourceId(R.styleable.MaterialPreferenceText_pref_icon, 0x0));
|
||||
|
||||
title = view.findViewById(R.id.material_preference_title);
|
||||
title.setText(a.getString(R.styleable.MaterialPreferenceText_title));
|
||||
|
||||
subtitle = view.findViewById(R.id.material_preference_subtitle);
|
||||
subtitle.setText(a.getString(R.styleable.MaterialPreferenceText_subtitle));
|
||||
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title.setText(title);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title.getText().toString();
|
||||
}
|
||||
|
||||
|
||||
public void setSubtitle(String subtitle) {
|
||||
this.subtitle.setText(subtitle);
|
||||
}
|
||||
|
||||
public String getSubtitle() {
|
||||
return this.subtitle.getText().toString();
|
||||
}
|
||||
|
||||
|
||||
public void setDrawable(int resourceId) {
|
||||
this.icon.setImageResource(resourceId);
|
||||
}
|
||||
|
||||
public void setDrawable(Drawable drawable) {
|
||||
this.icon.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setOnClickListener(@Nullable OnClickListener l) {
|
||||
rootView.setOnClickListener(l);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.custom_views;
|
||||
package lu.circl.mispbump.customViews;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
|
@ -39,11 +39,10 @@ public class UploadAction extends LinearLayoutCompat {
|
|||
|
||||
public UploadAction(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
this.context = context;
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UploadAction);
|
||||
String title = a.getString(R.styleable.UploadAction_title);
|
||||
String title = a.getString(R.styleable.UploadAction_description);
|
||||
a.recycle();
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
|
@ -72,7 +71,6 @@ public class UploadAction extends LinearLayoutCompat {
|
|||
}
|
||||
|
||||
public void setCurrentUploadState(UploadState state) {
|
||||
|
||||
currentUploadState = state;
|
||||
progressBar.setVisibility(GONE);
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
package lu.circl.mispbump.custom_views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import lu.circl.mispbump.R;
|
||||
|
||||
public class MaterialPreferenceText extends ConstraintLayout {
|
||||
|
||||
private View baseView;
|
||||
private TextView title, subtitle;
|
||||
|
||||
public MaterialPreferenceText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
baseView = inflater.inflate(R.layout.material_preference_text, this);
|
||||
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MaterialPreferenceText);
|
||||
|
||||
ImageView icon = baseView.findViewById(R.id.material_preference_src);
|
||||
icon.setImageResource(a.getResourceId(R.styleable.MaterialPreferenceText_pref_icon, 0x0));
|
||||
|
||||
title = baseView.findViewById(R.id.material_preference_title);
|
||||
title.setText(a.getString(R.styleable.MaterialPreferenceText_text));
|
||||
|
||||
subtitle = baseView.findViewById(R.id.material_preference_subtitle);
|
||||
subtitle.setText(a.getString(R.styleable.MaterialPreferenceText_subText));
|
||||
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
public void setSubText(String subText) {
|
||||
subtitle.setText(subText);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.cam;
|
||||
package lu.circl.mispbump.fragments;
|
||||
|
||||
import android.Manifest;
|
||||
import android.animation.Animator;
|
||||
|
@ -63,6 +63,7 @@ import java.util.concurrent.Semaphore;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lu.circl.mispbump.R;
|
||||
import lu.circl.mispbump.customViews.AutoFitTextureView;
|
||||
|
||||
public class CameraFragment extends Fragment implements ActivityCompat.OnRequestPermissionsResultCallback {
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
package lu.circl.mispbump.fragments;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
}
|
|
@ -1,7 +1,14 @@
|
|||
package lu.circl.mispbump.restful_client;
|
||||
package lu.circl.mispbump.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lu.circl.mispbump.models.restModels.MispOrganisation;
|
||||
import lu.circl.mispbump.models.restModels.MispServer;
|
||||
import lu.circl.mispbump.models.restModels.MispUser;
|
||||
import lu.circl.mispbump.models.restModels.Organisation;
|
||||
import lu.circl.mispbump.models.restModels.Server;
|
||||
import lu.circl.mispbump.models.restModels.User;
|
||||
import lu.circl.mispbump.models.restModels.Version;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
|
@ -11,7 +18,7 @@ import retrofit2.http.Path;
|
|||
/**
|
||||
* RetroFit2 interface for communication with misp instances
|
||||
*/
|
||||
public interface MispRestService {
|
||||
public interface MispRestInterface {
|
||||
|
||||
// settings routes
|
||||
|
||||
|
@ -45,9 +52,6 @@ public interface MispRestService {
|
|||
@GET("servers/index")
|
||||
Call<List<MispServer>> getServers();
|
||||
|
||||
// @POST("servers/add")
|
||||
// Call<MispServer> addServer(@Body MispServer server);
|
||||
|
||||
@POST("servers/add")
|
||||
Call<Server> addServer(@Body Server server);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package lu.circl.mispbump.models;
|
||||
|
||||
import lu.circl.mispbump.restful_client.Organisation;
|
||||
import lu.circl.mispbump.models.restModels.Organisation;
|
||||
|
||||
/**
|
||||
* A Class that holds the information needed synchronize two misp instances.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.restful_client;
|
||||
package lu.circl.mispbump.models.restModels;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.restful_client;
|
||||
package lu.circl.mispbump.models.restModels;
|
||||
|
||||
import java.util.List;
|
||||
import com.google.gson.annotations.Expose;
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.restful_client;
|
||||
package lu.circl.mispbump.models.restModels;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.restful_client;
|
||||
package lu.circl.mispbump.models.restModels;
|
||||
|
||||
/**
|
||||
* Information gathered from Misp API about a organisation.
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.restful_client;
|
||||
package lu.circl.mispbump.models.restModels;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.restful_client;
|
||||
package lu.circl.mispbump.models.restModels;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
|
@ -1,4 +1,4 @@
|
|||
package lu.circl.mispbump.restful_client;
|
||||
package lu.circl.mispbump.models.restModels;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
android:id="@+id/rootLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
tools:context=".activities.ProfileActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
|
@ -76,33 +78,20 @@
|
|||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<lu.circl.mispbump.custom_views.MaterialPreferenceText
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sector"
|
||||
app:pref_icon="@drawable/ic_description"
|
||||
app:subText=""
|
||||
app:text="Description">
|
||||
|
||||
</lu.circl.mispbump.custom_views.MaterialPreferenceText>
|
||||
|
||||
<lu.circl.mispbump.custom_views.MaterialPreferenceText
|
||||
<lu.circl.mispbump.customViews.MaterialPreferenceText
|
||||
android:id="@+id/uuid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:pref_icon="@drawable/ic_code_black_24dp"
|
||||
app:subText=""
|
||||
app:text="UUID" />
|
||||
app:title="UUID"/>
|
||||
|
||||
<lu.circl.mispbump.custom_views.MaterialPreferenceText
|
||||
<lu.circl.mispbump.customViews.MaterialPreferenceText
|
||||
android:id="@+id/nationality"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -111,12 +100,9 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/uuid"
|
||||
app:pref_icon="@drawable/ic_language"
|
||||
app:subText="German"
|
||||
app:text="Nationality">
|
||||
app:title="Nationality"/>
|
||||
|
||||
</lu.circl.mispbump.custom_views.MaterialPreferenceText>
|
||||
|
||||
<lu.circl.mispbump.custom_views.MaterialPreferenceText
|
||||
<lu.circl.mispbump.customViews.MaterialPreferenceText
|
||||
android:id="@+id/sector"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -125,10 +111,18 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nationality"
|
||||
app:pref_icon="@drawable/ic_sector"
|
||||
app:subText="Industrial"
|
||||
app:text="Sector">
|
||||
app:title="Sector"/>
|
||||
|
||||
</lu.circl.mispbump.custom_views.MaterialPreferenceText>
|
||||
<lu.circl.mispbump.customViews.MaterialPreferenceText
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sector"
|
||||
app:pref_icon="@drawable/ic_description"
|
||||
app:title="Description"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
@ -35,7 +36,7 @@
|
|||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
app:layout_behavior=".custom_views.ExtendedBottomSheetBehavior"
|
||||
app:layout_behavior=".customViews.ExtendedBottomSheetBehavior"
|
||||
android:id="@+id/bottomSheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<lu.circl.mispbump.custom_views.UploadAction
|
||||
<lu.circl.mispbump.customViews.UploadAction
|
||||
android:id="@+id/availableAction"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -39,7 +39,7 @@
|
|||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="Check if instance is available" />
|
||||
|
||||
<lu.circl.mispbump.custom_views.UploadAction
|
||||
<lu.circl.mispbump.customViews.UploadAction
|
||||
android:id="@+id/orgAction"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -51,7 +51,7 @@
|
|||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="Add organisation" />
|
||||
|
||||
<lu.circl.mispbump.custom_views.UploadAction
|
||||
<lu.circl.mispbump.customViews.UploadAction
|
||||
android:id="@+id/userAction"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -63,7 +63,7 @@
|
|||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="Add sync user" />
|
||||
|
||||
<lu.circl.mispbump.custom_views.UploadAction
|
||||
<lu.circl.mispbump.customViews.UploadAction
|
||||
android:id="@+id/serverAction"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<lu.circl.mispbump.cam.AutoFitTextureView
|
||||
<lu.circl.mispbump.customViews.AutoFitTextureView
|
||||
android:id="@+id/texture"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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:clickable="true"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
android:foreground="?attr/selectableItemBackground">
|
||||
|
||||
<ImageView
|
||||
tools:src="@drawable/ic_language"
|
||||
android:id="@+id/material_preference_src"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
|
@ -13,33 +20,42 @@
|
|||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:tint="@color/colorPrimaryDark"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/material_preference_subtitle"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/material_preference_title"
|
||||
app:srcCompat="@drawable/ic_language" />
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/material_preference_title"
|
||||
tools:text="Title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="Language"
|
||||
android:textAppearance="@style/Text.Title"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/material_preference_src"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/material_preference_subtitle"
|
||||
tools:text="Subtitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="German"
|
||||
android:textAppearance="@style/Text.SubTitle"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/material_preference_src"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="MaterialPreferenceText">
|
||||
<attr name="pref_icon" format="reference"/>
|
||||
<attr name="text"/>
|
||||
<attr name="subText"/>
|
||||
<attr name="pref_icon" format="integer"/>
|
||||
<attr name="title" format="string"/>
|
||||
<attr name="subtitle" format="string"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="UploadAction">
|
||||
<attr name="title" format="string"/>
|
||||
<attr name="description" format="string"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
Loading…
Reference in New Issue