diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b0c9e79..6950428 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,9 +15,11 @@ android:supportsRtl="true" android:theme="@style/AppTheme" tools:ignore="GoogleAppIndexingWarning"> - + + android:label="Upload" /> diff --git a/app/src/main/java/lu/circl/mispbump/activities/HomeActivity.java b/app/src/main/java/lu/circl/mispbump/activities/HomeActivity.java index b35b766..2e44639 100644 --- a/app/src/main/java/lu/circl/mispbump/activities/HomeActivity.java +++ b/app/src/main/java/lu/circl/mispbump/activities/HomeActivity.java @@ -2,7 +2,7 @@ package lu.circl.mispbump.activities; import android.content.Intent; import android.os.Bundle; -import androidx.coordinatorlayout.widget.CoordinatorLayout; + import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.snackbar.Snackbar; import com.google.gson.Gson; @@ -21,28 +21,18 @@ import android.widget.TextView; import java.util.List; import lu.circl.mispbump.R; -import lu.circl.mispbump.adapters.SyncAdapter; -import lu.circl.mispbump.auxiliary.DialogManager; +import lu.circl.mispbump.adapters.UploadInfoAdapter; import lu.circl.mispbump.auxiliary.PreferenceManager; -import lu.circl.mispbump.interfaces.IOnItemClickListener; +import lu.circl.mispbump.interfaces.OnRecyclerItemClickListener; import lu.circl.mispbump.models.UploadInformation; public class HomeActivity extends AppCompatActivity { - public static final String TAG = "Home"; - - private CoordinatorLayout layout; - private RecyclerView recyclerView; - + private View rootView; private PreferenceManager preferenceManager; - private View.OnClickListener onFabClicked = new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent sync = new Intent(HomeActivity.this, SyncActivity.class); - startActivity(sync); - } - }; + private RecyclerView recyclerView; + private UploadInfoAdapter uploadInfoAdapter; @Override protected void onCreate(Bundle savedInstanceState) { @@ -51,14 +41,72 @@ public class HomeActivity extends AppCompatActivity { preferenceManager = PreferenceManager.getInstance(this); - initializeViews(); + init(); + initRecyclerView(); } + + private void init() { + rootView = findViewById(R.id.rootLayout); + + // populate Toolbar (Actionbar) + Toolbar myToolbar = findViewById(R.id.toolbar); + setSupportActionBar(myToolbar); + + ActionBar ab = getSupportActionBar(); + if (ab != null) { + ab.setDisplayHomeAsUpEnabled(false); + } + + FloatingActionButton sync_fab = findViewById(R.id.home_fab); + sync_fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(HomeActivity.this, SyncActivity.class)); + } + }); + } + + private void initRecyclerView() { + recyclerView = findViewById(R.id.recyclerView); + recyclerView.setLayoutManager(new LinearLayoutManager(HomeActivity.this)); + + uploadInfoAdapter = new UploadInfoAdapter(HomeActivity.this); + + uploadInfoAdapter.setOnRecyclerItemClickListener(new OnRecyclerItemClickListener() { + @Override + public void onClick(UploadInformation item) { + Intent i = new Intent(HomeActivity.this, UploadInformationActivity.class); + i.putExtra(UploadInformationActivity.EXTRA_UPLOAD_INFO_KEY, new Gson().toJson(item)); + startActivity(i); + } + }); + + recyclerView.setAdapter(uploadInfoAdapter); + } + + private void refreshRecyclerView() { + List uploadInformationList = preferenceManager.getUploadInformation(); + TextView empty = findViewById(R.id.empty); + + // no sync information available + if (uploadInformationList == null) { + empty.setVisibility(View.VISIBLE); + recyclerView.setVisibility(View.GONE); + return; + } + + // sync information available + empty.setVisibility(View.GONE); + recyclerView.setVisibility(View.VISIBLE); + uploadInfoAdapter.setItems(uploadInformationList); + } + + @Override protected void onResume() { super.onResume(); - initializeRecyclerView(); - refreshSyncInformation(); + refreshRecyclerView(); } @Override @@ -82,79 +130,4 @@ public class HomeActivity extends AppCompatActivity { // invoke superclass to handle unrecognized item (eg. homeAsUp) return super.onOptionsItemSelected(item); } - - private void initializeViews() { - layout = findViewById(R.id.rootLayout); - - // populate Toolbar (Actionbar) - Toolbar myToolbar = findViewById(R.id.toolbar); - setSupportActionBar(myToolbar); - - ActionBar ab = getSupportActionBar(); - if (ab != null) { - ab.setDisplayHomeAsUpEnabled(false); - } - - recyclerView = findViewById(R.id.recyclerView); - recyclerView.setLayoutManager(new LinearLayoutManager(this)); - - FloatingActionButton sync_fab = findViewById(R.id.home_fab); - sync_fab.setOnClickListener(onFabClicked); - } - - private void refreshSyncInformation () { - List uploadInformationList = preferenceManager.getUploadInformation(); - TextView empty = findViewById(R.id.emtpy); - - // no sync information available - if (uploadInformationList == null) { - empty.setVisibility(View.VISIBLE); - recyclerView.setVisibility(View.GONE); - return; - } - - // sync information available - empty.setVisibility(View.GONE); - recyclerView.setVisibility(View.VISIBLE); - - SyncAdapter adapter = (SyncAdapter) recyclerView.getAdapter(); - assert adapter != null; - adapter.setUploadInformationList(uploadInformationList); - } - - private void initializeRecyclerView() { - SyncAdapter syncAdapter = new SyncAdapter(HomeActivity.this); - syncAdapter.setOnDeleteClickListener(new IOnItemClickListener() { - @Override - public void onItemClick(final UploadInformation clickedObject) { - DialogManager.deleteSyncInformationDialog(HomeActivity.this, new DialogManager.IDialogFeedback() { - @Override - public void positive() { - boolean status = preferenceManager.removeUploadInformation(clickedObject.getId()); - - if (status) { - Snackbar.make(layout, "Successfully deleted sync information", Snackbar.LENGTH_LONG).show(); - refreshSyncInformation(); - } else { - Snackbar.make(layout, "Failed to delete sync information", Snackbar.LENGTH_LONG).show(); - } - } - - @Override - public void negative() { } - }); - } - }); - - syncAdapter.setOnRetryClickListener(new IOnItemClickListener() { - @Override - public void onItemClick(UploadInformation clickedObject) { - Intent upload = new Intent(HomeActivity.this, UploadActivity.class); - upload.putExtra(UploadActivity.EXTRA_UPLOAD_INFO, new Gson().toJson(clickedObject)); - startActivity(upload); - } - }); - - recyclerView.setAdapter(syncAdapter); - } } diff --git a/app/src/main/java/lu/circl/mispbump/activities/LoginActivity.java b/app/src/main/java/lu/circl/mispbump/activities/LoginActivity.java index f2ddce9..4a50402 100644 --- a/app/src/main/java/lu/circl/mispbump/activities/LoginActivity.java +++ b/app/src/main/java/lu/circl/mispbump/activities/LoginActivity.java @@ -31,8 +31,8 @@ import lu.circl.mispbump.restful_client.Organisation; import lu.circl.mispbump.restful_client.User; /** - * This activity is shown when the current device has no misp user associated with it. - * Takes care of downloading all information necessary for a sync with other misp instances. + * This activity is shown when the current device has no misp user and organisation associated with it. + * It takes care of downloading all information necessary for a sync with other misp instances. */ public class LoginActivity extends AppCompatActivity { @@ -78,11 +78,11 @@ public class LoginActivity extends AppCompatActivity { constraintLayout = findViewById(R.id.rootLayout); - serverUrl = findViewById(R.id.login_server_url); - serverAutomationKey = findViewById(R.id.login_automation_key); Button downloadInfoButton = findViewById(R.id.login_download_button); downloadInfoButton.setOnClickListener(onClickDownload); + serverUrl = findViewById(R.id.login_server_url); + serverAutomationKey = findViewById(R.id.login_automation_key); progressBar = findViewById(R.id.login_progressbar); preferenceManager = PreferenceManager.getInstance(this); @@ -124,7 +124,7 @@ public class LoginActivity extends AppCompatActivity { preferenceManager.setServerUrl(url); // instance of MispRestClient with given URL - final MispRestClient mispRestClient = new MispRestClient(getApplicationContext()); + final MispRestClient mispRestClient = MispRestClient.getInstance(getApplicationContext()); // display progress bar progressBar.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/lu/circl/mispbump/activities/ProfileActivity.java b/app/src/main/java/lu/circl/mispbump/activities/ProfileActivity.java index 8279469..f959baf 100644 --- a/app/src/main/java/lu/circl/mispbump/activities/ProfileActivity.java +++ b/app/src/main/java/lu/circl/mispbump/activities/ProfileActivity.java @@ -44,7 +44,7 @@ public class ProfileActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); - mispRestClient = new MispRestClient(this); + mispRestClient = MispRestClient.getInstance(this); preferenceManager = PreferenceManager.getInstance(this); initializeViews(); diff --git a/app/src/main/java/lu/circl/mispbump/activities/UploadActivity.java b/app/src/main/java/lu/circl/mispbump/activities/UploadActivity.java index 6c02aac..7110f38 100644 --- a/app/src/main/java/lu/circl/mispbump/activities/UploadActivity.java +++ b/app/src/main/java/lu/circl/mispbump/activities/UploadActivity.java @@ -55,8 +55,9 @@ public class UploadActivity extends AppCompatActivity { } private void init() { + restClient = MispRestClient.getInstance(this); preferenceManager = PreferenceManager.getInstance(this); - restClient = new MispRestClient(this); + rootLayout = findViewById(R.id.rootLayout); // toolbar diff --git a/app/src/main/java/lu/circl/mispbump/activities/UploadInformationActivity.java b/app/src/main/java/lu/circl/mispbump/activities/UploadInformationActivity.java new file mode 100644 index 0000000..a211e58 --- /dev/null +++ b/app/src/main/java/lu/circl/mispbump/activities/UploadInformationActivity.java @@ -0,0 +1,39 @@ +package lu.circl.mispbump.activities; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.widget.TextView; + +import com.google.gson.Gson; + +import lu.circl.mispbump.R; +import lu.circl.mispbump.models.UploadInformation; + +public class UploadInformationActivity extends AppCompatActivity { + + public static String EXTRA_UPLOAD_INFO_KEY = "uploadInformation"; + + private UploadInformation uploadInformation; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_upload_information); + + parseExtra(); + init(); + } + + private void parseExtra() { + String uploadInfo = getIntent().getStringExtra(EXTRA_UPLOAD_INFO_KEY); + this.uploadInformation = new Gson().fromJson(uploadInfo, UploadInformation.class); + } + + private void init() { + TextView name = findViewById(R.id.orgName); + name.setText(uploadInformation.getRemote().organisation.name); + } + +} diff --git a/app/src/main/java/lu/circl/mispbump/adapters/SyncAdapter.java b/app/src/main/java/lu/circl/mispbump/adapters/SyncAdapter.java deleted file mode 100644 index 1a305de..0000000 --- a/app/src/main/java/lu/circl/mispbump/adapters/SyncAdapter.java +++ /dev/null @@ -1,157 +0,0 @@ -package lu.circl.mispbump.adapters; - -import android.content.Context; - -import androidx.annotation.NonNull; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.core.widget.ImageViewCompat; -import androidx.recyclerview.widget.RecyclerView; - -import android.content.res.ColorStateList; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.TextView; - -import java.util.List; - -import lu.circl.mispbump.R; -import lu.circl.mispbump.custom_views.MaterialPreferenceText; -import lu.circl.mispbump.interfaces.IOnItemClickListener; -import lu.circl.mispbump.models.UploadInformation; - -public class SyncAdapter extends RecyclerView.Adapter { - - private Context context; - private List uploadInformationList; - private IOnItemClickListener deleteListener, retryListener; - - static class SyncViewHolder extends RecyclerView.ViewHolder { - MaterialPreferenceText baseUrl, email, password, authkey; - TextView orgName, date; - ImageView syncStatus; - ImageButton retry, delete; - - ConstraintLayout collapsedContent, expandedContent; - - SyncViewHolder(View v) { - super(v); - - expandedContent = v.findViewById(R.id.expandedContent); - expandedContent.setVisibility(View.GONE); - - collapsedContent = v.findViewById(R.id.collapsedContent); - collapsedContent.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (expandedContent.getVisibility() == View.GONE) { - expandedContent.setVisibility(View.VISIBLE); - } else { - expandedContent.setVisibility(View.GONE); - } - } - }); - - orgName = v.findViewById(R.id.orgName); - date = v.findViewById(R.id.date); - - baseUrl = v.findViewById(R.id.baseUrl); - email = v.findViewById(R.id.email); - password = v.findViewById(R.id.password); - authkey = v.findViewById(R.id.authkey); - - syncStatus = v.findViewById(R.id.syncStatus); - - retry = v.findViewById(R.id.retryButton); - delete = v.findViewById(R.id.deleteButton); - } - - void bindDeleteListener(final UploadInformation item, final IOnItemClickListener listener) { - delete.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - listener.onItemClick(item); - } - }); - } - - void bindRetryListener(final UploadInformation item, final IOnItemClickListener listener) { - retry.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - listener.onItemClick(item); - } - }); - } - } - - public SyncAdapter(Context context) { - this.context = context; - } - - public void setUploadInformationList(List uploadInformationList) { - this.uploadInformationList = uploadInformationList; - notifyDataSetChanged(); - } - - public void setOnDeleteClickListener(IOnItemClickListener listener) { - deleteListener = listener; - } - - public void setOnRetryClickListener(IOnItemClickListener listener) { - retryListener = listener; - } - - @NonNull - @Override - public SyncViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { - View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.viewholder_sync, viewGroup, false); - return new SyncViewHolder(v); - } - - @Override - public void onBindViewHolder(@NonNull SyncViewHolder syncViewHolder, int i) { - - syncViewHolder.date.setText(uploadInformationList.get(i).getDateString()); - syncViewHolder.orgName.setText(uploadInformationList.get(i).getRemote().organisation.name); - - syncViewHolder.baseUrl.setSubText(uploadInformationList.get(i).getRemote().baseUrl); - syncViewHolder.email.setSubText(uploadInformationList.get(i).getLocal().syncUserEmail); - syncViewHolder.password.setSubText(uploadInformationList.get(i).getLocal().syncUserPassword); - syncViewHolder.authkey.setSubText(uploadInformationList.get(i).getLocal().syncUserAuthkey); - - - switch (uploadInformationList.get(i).getCurrentSyncStatus()) { - case COMPLETE: - ImageViewCompat.setImageTintList(syncViewHolder.syncStatus, ColorStateList.valueOf(context.getColor(R.color.status_green))); - syncViewHolder.syncStatus.setImageResource(R.drawable.ic_check); - syncViewHolder.retry.setVisibility(View.GONE); - break; - case FAILURE: - ImageViewCompat.setImageTintList(syncViewHolder.syncStatus, ColorStateList.valueOf(context.getColor(R.color.status_red))); - syncViewHolder.syncStatus.setImageResource(R.drawable.ic_error_outline); - syncViewHolder.retry.setVisibility(View.VISIBLE); - break; - case PENDING: - ImageViewCompat.setImageTintList(syncViewHolder.syncStatus, ColorStateList.valueOf(context.getColor(R.color.status_amber))); - syncViewHolder.syncStatus.setImageResource(R.drawable.ic_info_outline); - syncViewHolder.retry.setVisibility(View.VISIBLE); - break; - } - - syncViewHolder.bindDeleteListener(uploadInformationList.get(i), deleteListener); - syncViewHolder.bindRetryListener(uploadInformationList.get(i), retryListener); - } - - @Override - public int getItemCount() { - if (uploadInformationList == null) { - return 0; - } - - return uploadInformationList.size(); - } - -} diff --git a/app/src/main/java/lu/circl/mispbump/adapters/UploadInfoAdapter.java b/app/src/main/java/lu/circl/mispbump/adapters/UploadInfoAdapter.java new file mode 100644 index 0000000..980dafa --- /dev/null +++ b/app/src/main/java/lu/circl/mispbump/adapters/UploadInfoAdapter.java @@ -0,0 +1,88 @@ +package lu.circl.mispbump.adapters; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.core.widget.ImageViewCompat; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.List; + +import lu.circl.mispbump.R; +import lu.circl.mispbump.interfaces.OnRecyclerItemClickListener; +import lu.circl.mispbump.models.UploadInformation; +import lu.circl.mispbump.viewholders.UploadInfoListViewHolder; + +public class UploadInfoAdapter extends RecyclerView.Adapter { + + private Context context; + private List items; + + private OnRecyclerItemClickListener onRecyclerItemClickListener; + + + public UploadInfoAdapter(Context context) { + this.context = context; + } + + public UploadInfoAdapter(Context context, List items) { + this.context = context; + this.items = items; + } + + @NonNull + @Override + public UploadInfoListViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { + View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.row_upload_information, viewGroup, false); + return new UploadInfoListViewHolder(v); + } + + @Override + public void onBindViewHolder(@NonNull final UploadInfoListViewHolder holder, int position) { + + final UploadInformation item = items.get(position); + + holder.date.setText(item.getDateString()); + holder.orgName.setText(item.getRemote().organisation.name); + + switch (item.getCurrentSyncStatus()) { + case COMPLETE: + ImageViewCompat.setImageTintList(holder.syncStatus, ColorStateList.valueOf(context.getColor(R.color.status_green))); + holder.syncStatus.setImageResource(R.drawable.ic_check); + break; + case FAILURE: + ImageViewCompat.setImageTintList(holder.syncStatus, ColorStateList.valueOf(context.getColor(R.color.status_red))); + holder.syncStatus.setImageResource(R.drawable.ic_error_outline); + break; + case PENDING: + ImageViewCompat.setImageTintList(holder.syncStatus, ColorStateList.valueOf(context.getColor(R.color.status_amber))); + holder.syncStatus.setImageResource(R.drawable.ic_info_outline); + break; + } + + holder.rootView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + onRecyclerItemClickListener.onClick(item); + } + }); + } + + @Override + public int getItemCount() { + return items.size(); + } + + public void setItems(List items) { + this.items = items; + } + + public void setOnRecyclerItemClickListener(OnRecyclerItemClickListener onRecyclerItemClickListener) { + this.onRecyclerItemClickListener = onRecyclerItemClickListener; + } + +} diff --git a/app/src/main/java/lu/circl/mispbump/adapters/UserAdapter.java b/app/src/main/java/lu/circl/mispbump/adapters/UserAdapter.java deleted file mode 100644 index e3f7c00..0000000 --- a/app/src/main/java/lu/circl/mispbump/adapters/UserAdapter.java +++ /dev/null @@ -1,60 +0,0 @@ -package lu.circl.mispbump.adapters; - -import androidx.recyclerview.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import java.util.ArrayList; -import java.util.List; - -import lu.circl.mispbump.R; -import lu.circl.mispbump.auxiliary.KeyValue; -import lu.circl.mispbump.restful_client.Organisation; -import lu.circl.mispbump.restful_client.User; - -public class UserAdapter extends RecyclerView.Adapter { - - private List> data = new ArrayList<>(); - - static class UserViewHolder extends RecyclerView.ViewHolder { - TextView title; - TextView description; - - UserViewHolder(View v) { - super(v); - title = v.findViewById(R.id.viewholder_user_title); - description = v.findViewById(R.id.viewholder_user_description); - } - } - - public UserAdapter(User user, Organisation organisation) { - data.add(new KeyValue<>("UUID", organisation.uuid)); - data.add(new KeyValue<>("Name", organisation.name)); - data.add(new KeyValue<>("Description", organisation.description)); - data.add(new KeyValue<>("Nationality", organisation.nationality)); - data.add(new KeyValue<>("Email", user.email)); -// data.add(new KeyValue<>("ID", "" + user.value)); -// data.add(new KeyValue<>("Organisation ID", "" + user.org_id)); -// data.add(new KeyValue<>("Role ID", "" + user.role_id)); - } - - @Override - public UserAdapter.UserViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.viewholder_user, parent, false); - return new UserViewHolder(v); - } - - @Override - public void onBindViewHolder(UserViewHolder holder, int position) { - holder.title.setText(data.get(position).key); - holder.description.setText(data.get(position).value); - } - - @Override - public int getItemCount() { - return data.size(); - } - -} diff --git a/app/src/main/java/lu/circl/mispbump/custom_views/ExtendedBottomSheetBehavior.java b/app/src/main/java/lu/circl/mispbump/custom_views/ExtendedBottomSheetBehavior.java index 700489a..3f4f05a 100644 --- a/app/src/main/java/lu/circl/mispbump/custom_views/ExtendedBottomSheetBehavior.java +++ b/app/src/main/java/lu/circl/mispbump/custom_views/ExtendedBottomSheetBehavior.java @@ -1,8 +1,5 @@ package lu.circl.mispbump.custom_views; -import android.content.Context; -import android.util.AttributeSet; -import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -10,19 +7,14 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout; import com.google.android.material.bottomsheet.BottomSheetBehavior; +/** + * Can disable touch input on bottom sheet. + * @param + */ public class ExtendedBottomSheetBehavior extends BottomSheetBehavior { private boolean swipeable = false; - private Context context; - public ExtendedBottomSheetBehavior() { - super(); - } - - public ExtendedBottomSheetBehavior(Context context, AttributeSet attrs) { - super(context, attrs); - this.context = context; - } @Override public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) { @@ -48,6 +40,7 @@ public class ExtendedBottomSheetBehavior extends BottomSheetBeha return false; } + public void setSwipeable(boolean swipeable) { this.swipeable = swipeable; } diff --git a/app/src/main/java/lu/circl/mispbump/interfaces/IOnItemClickListener.java b/app/src/main/java/lu/circl/mispbump/interfaces/IOnItemClickListener.java deleted file mode 100644 index 2a76fdf..0000000 --- a/app/src/main/java/lu/circl/mispbump/interfaces/IOnItemClickListener.java +++ /dev/null @@ -1,5 +0,0 @@ -package lu.circl.mispbump.interfaces; - -public interface IOnItemClickListener { - void onItemClick(T clickedObject); -} diff --git a/app/src/main/java/lu/circl/mispbump/interfaces/OnRecyclerItemClickListener.java b/app/src/main/java/lu/circl/mispbump/interfaces/OnRecyclerItemClickListener.java new file mode 100644 index 0000000..1c1e198 --- /dev/null +++ b/app/src/main/java/lu/circl/mispbump/interfaces/OnRecyclerItemClickListener.java @@ -0,0 +1,5 @@ +package lu.circl.mispbump.interfaces; + +public interface OnRecyclerItemClickListener { + void onClick(T item); +} diff --git a/app/src/main/java/lu/circl/mispbump/restful_client/MispRestClient.java b/app/src/main/java/lu/circl/mispbump/restful_client/MispRestClient.java index 2dc850b..f399fa3 100644 --- a/app/src/main/java/lu/circl/mispbump/restful_client/MispRestClient.java +++ b/app/src/main/java/lu/circl/mispbump/restful_client/MispRestClient.java @@ -39,8 +39,6 @@ import retrofit2.converter.gson.GsonConverterFactory; */ public class MispRestClient { - private static final String TAG = "restClient"; - public interface AvailableCallback { void available(); @@ -59,11 +57,6 @@ public class MispRestClient { void failure(String error); } - public interface OrganisationsCallback { - void success(Organisation[] organisations); - void failure(String error); - } - public interface ServerCallback { void success(List servers); @@ -75,21 +68,29 @@ public class MispRestClient { } + private static MispRestClient instance; private PreferenceManager preferenceManager; private MispRestService mispRestService; + + public static MispRestClient getInstance(Context context) { + if (instance == null) { + instance = new MispRestClient(context); + } + + return instance; + } + /** * Initializes the rest client to communicate with a MISP instance. * * @param context needed to access the preferences for loading credentials */ - public MispRestClient(Context context) { + private MispRestClient(Context context) { preferenceManager = PreferenceManager.getInstance(context); String url = preferenceManager.getServerUrl(); - Log.i(TAG, "URL: " + url); - try { Retrofit retrofit = new Retrofit.Builder() .baseUrl(url) diff --git a/app/src/main/java/lu/circl/mispbump/viewholders/UploadInfoListViewHolder.java b/app/src/main/java/lu/circl/mispbump/viewholders/UploadInfoListViewHolder.java new file mode 100644 index 0000000..ce2b890 --- /dev/null +++ b/app/src/main/java/lu/circl/mispbump/viewholders/UploadInfoListViewHolder.java @@ -0,0 +1,27 @@ +package lu.circl.mispbump.viewholders; + +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import lu.circl.mispbump.R; + +public class UploadInfoListViewHolder extends RecyclerView.ViewHolder { + + public View rootView; + public ImageView syncStatus; + public TextView orgName, date; + + public UploadInfoListViewHolder(@NonNull View itemView) { + super(itemView); + + rootView = itemView; + + orgName = itemView.findViewById(R.id.orgName); + date = itemView.findViewById(R.id.date); + syncStatus = itemView.findViewById(R.id.syncStatus); + } +} diff --git a/app/src/main/res/drawable/ic_more_vert.xml b/app/src/main/res/drawable/ic_more_vert.xml new file mode 100644 index 0000000..c097d3e --- /dev/null +++ b/app/src/main/res/drawable/ic_more_vert.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index cb08ed5..5efa0f8 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -4,7 +4,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/rootLayout" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:animateLayoutChanges="true"> + android:layout_height="match_parent" + android:animateLayoutChanges="true"/> + app:layout_constraintTop_toTopOf="parent" /> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/bottom_sheet_public_key.xml b/app/src/main/res/layout/bottom_sheet_public_key.xml deleted file mode 100644 index 66e4777..0000000 --- a/app/src/main/res/layout/bottom_sheet_public_key.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/bottom_sheet_sync_information.xml b/app/src/main/res/layout/bottom_sheet_sync_information.xml deleted file mode 100644 index 5d2c2d0..0000000 --- a/app/src/main/res/layout/bottom_sheet_sync_information.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/row_upload_information.xml b/app/src/main/res/layout/row_upload_information.xml new file mode 100644 index 0000000..f7a5b45 --- /dev/null +++ b/app/src/main/res/layout/row_upload_information.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/viewholder_sync.xml b/app/src/main/res/layout/viewholder_sync.xml deleted file mode 100644 index 693c233..0000000 --- a/app/src/main/res/layout/viewholder_sync.xml +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/viewholder_user.xml b/app/src/main/res/layout/viewholder_user.xml deleted file mode 100644 index f3950c3..0000000 --- a/app/src/main/res/layout/viewholder_user.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/raw/misp.crt b/app/src/main/res/raw/misp.crt deleted file mode 100644 index 00f458a..0000000 --- a/app/src/main/res/raw/misp.crt +++ /dev/null @@ -1,23 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDwzCCAqugAwIBAgIUEHRo5YZyVzJRWcqG4zHzG68DoTgwDQYJKoZIhvcNAQEL -BQAwcTELMAkGA1UEBhMCREUxDDAKBgNVBAgMA05SVzENMAsGA1UEBwwEQm9ubjEO -MAwGA1UECgwFRmVsaXgxEjAQBgNVBAMMCWxvY2FsaG9zdDEhMB8GCSqGSIb3DQEJ -ARYSZmVsaXhwa0BvdXRsb29rLmRlMB4XDTE5MDUxMzA4NTEwOVoXDTIwMDUxMjA4 -NTEwOVowcTELMAkGA1UEBhMCREUxDDAKBgNVBAgMA05SVzENMAsGA1UEBwwEQm9u -bjEOMAwGA1UECgwFRmVsaXgxEjAQBgNVBAMMCWxvY2FsaG9zdDEhMB8GCSqGSIb3 -DQEJARYSZmVsaXhwa0BvdXRsb29rLmRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A -MIIBCgKCAQEA0ut7qAzPuNPoZmQNCyOkDL8szBT6+pspGNQHQpL7GG5UotlniXcp -q+FtF4X4PEow5P0aRMBG72QIxUzAtFiqK2/RCbK3ECrKezedM26BT0xkEB/eUU7E -RQIO+XYa4JUi+g+YwnDCnPWexGIsztq+vvHXdny+uMeRCBFQxiPuPwdB4uPQyy8d -kv9XNScRCOu4Hp4IaFBIw5V7uP71WdyoHjD7NBbzubrVjcr+I0DC+MbpJOKpM/YB -lbp+I9NeA/rWZ4r6rrMAVOv6tV2dgnQ+6cWOFBiM3ZkxuocPWg/iI4UzdSsy2K/W -qONJfAjAqkmgkBBr2cyW5wwWEN8J994DIwIDAQABo1MwUTAdBgNVHQ4EFgQUWsMY -gtEo2b2WtuROWMfRDKzwTT0wHwYDVR0jBBgwFoAUWsMYgtEo2b2WtuROWMfRDKzw -TT0wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAmGU2K9isN1Wm -2PksR92pKrs7SJom2L3o7V3ui8oZ2FZrLx/IUeUA4aSmSeyqbxuziPqYUkO0ku1t -9ASaf9yaNS7CULDftgoebLzlIEwktvEI3XixpRIfJJywHSG5eLsG51D65hyuOZ2z -s0Y94HzvKX4fIaXv7NxGCW+xHhc6anxYKrXFldFwv3z/NHq0pzvd/aebbfuEeggH -xpmA3dgi0y0meTLKzYzDypEhkUPiq6u8R+cEuFgSun89/fW80VktEo+32tkaczEm -qjcZGfUFGNGG08p6MfRSl9PSakpdymV+aKK+TxB5nACe/RmISkqLz9REDlzUyNDm -yArY8SEbhg== ------END CERTIFICATE----- diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 11144ba..9c82ee7 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -10,5 +10,5 @@ MISP Server URL\nDie URL unter der Ihre MISP Instanz erreichbar ist.\n\nMISP Automatisierungs Schlüssel\nZu finden unter ... QR code Synchronisation - Sie haben noch keine MISP Instanzen verknüpft. + Sie haben noch keine MISP Instanzen verknüpft \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d881361..7738241 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,5 +12,5 @@ Okay QR code Synchronization - You have not synced any MISP instances yet. + You have not synced any MISP instances yet diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 3116eeb..6aba1c4 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -12,6 +12,15 @@ true + + + +