diff --git a/app/src/main/java/de/overview/wg/its/mispbump/MainActivity.java b/app/src/main/java/de/overview/wg/its/mispbump/MainActivity.java index 7519e6f..b8979b0 100644 --- a/app/src/main/java/de/overview/wg/its/mispbump/MainActivity.java +++ b/app/src/main/java/de/overview/wg/its/mispbump/MainActivity.java @@ -21,13 +21,9 @@ import android.view.View; import android.widget.CheckBox; import android.widget.TextView; import de.overview.wg.its.mispbump.adapter.SyncedPartnerAdapter; -import de.overview.wg.its.mispbump.auxiliary.AESSecurity; import de.overview.wg.its.mispbump.auxiliary.PreferenceManager; import de.overview.wg.its.mispbump.model.SyncedPartner; -import de.overview.wg.its.mispbump.preferences.AppPreferenceActivity; -import de.overview.wg.its.mispbump.preferences.AppPreferenceFragment; -import java.security.PublicKey; import java.util.ArrayList; import java.util.List; @@ -72,39 +68,12 @@ public class MainActivity extends AppCompatActivity { case R.id.menu_item_delete_local_data: createSelectDeleteDialog(); return true; - - case R.id.main_menu_settings: - startActivity(new Intent(this, AppPreferenceActivity.class)); - return true; } return super.onOptionsItemSelected(item); } - private void testAESSecurity() { - - String data = "This is the secret message"; - - AESSecurity aesA = AESSecurity.getInstance(); - AESSecurity aesB = AESSecurity.getInstance(); - - PublicKey pubA = aesA.getPublicKey(); - PublicKey pubB = aesB.getPublicKey(); - - aesA.setForeignPublicKey(pubB); - aesB.setForeignPublicKey(pubA); - - emptyPartnerListView.setText("ORIGINAL: " + data + "\n"); - - String encrypted = aesA.encrypt(data); - emptyPartnerListView.append("ENCRYPTED BY A: " + encrypted + "\n"); - - String decrypted = aesB.decrypt(encrypted); - emptyPartnerListView.append("DECRYPTED BY B: " + decrypted); - - } - private void initializeViews() { Toolbar toolbar = findViewById(R.id.toolbar); diff --git a/app/src/main/java/de/overview/wg/its/mispbump/QrSyncActivity.java b/app/src/main/java/de/overview/wg/its/mispbump/QrSyncActivity.java index 446199c..7d073ba 100644 --- a/app/src/main/java/de/overview/wg/its/mispbump/QrSyncActivity.java +++ b/app/src/main/java/de/overview/wg/its/mispbump/QrSyncActivity.java @@ -265,10 +265,19 @@ public class QrSyncActivity extends AppCompatActivity implements View.OnClickLis AlertDialog.Builder adb = new AlertDialog.Builder(this); LayoutInflater inflater = getLayoutInflater(); - @SuppressLint("InflateParams") View title = inflater.inflate(R.layout.dialog_public_key, null); + @SuppressLint("InflateParams") + View title = inflater.inflate(R.layout.dialog_public_key, null); adb.setCustomTitle(title); - adb.setMessage("\nOrganisation: " + pkqr.getOrganisation() + "\nEmail: " + pkqr.getEmail()); + View pkInfoView = inflater.inflate(R.layout.view_pk_info, null); + + TextView name = pkInfoView.findViewById(R.id.pk_info_organisation_name); + name.setText(pkqr.getOrganisation()); + + TextView email = pkInfoView.findViewById(R.id.pk_info_email); + email.setText(pkqr.getEmail()); + + adb.setView(pkInfoView); adb.setPositiveButton(getString(R.string.accept), new DialogInterface.OnClickListener() { @Override @@ -299,10 +308,12 @@ public class QrSyncActivity extends AppCompatActivity implements View.OnClickLis AlertDialog.Builder adb = new AlertDialog.Builder(this); LayoutInflater inflater = getLayoutInflater(); - @SuppressLint("InflateParams") View title = inflater.inflate(R.layout.dialog_sync_info, null); + @SuppressLint("InflateParams") + View title = inflater.inflate(R.layout.dialog_sync_info, null); adb.setCustomTitle(title); - @SuppressLint("InflateParams") View orgView = inflater.inflate(R.layout.view_organisation, null); + @SuppressLint("InflateParams") + View orgView = inflater.inflate(R.layout.view_organisation, null); TextView orgTitle = orgView.findViewById(R.id.organisation_title); orgTitle.setText(siqr.getOrganisation().getName()); diff --git a/app/src/main/java/de/overview/wg/its/mispbump/SyncActivity.java b/app/src/main/java/de/overview/wg/its/mispbump/SyncActivity.java deleted file mode 100644 index 09ad1d3..0000000 --- a/app/src/main/java/de/overview/wg/its/mispbump/SyncActivity.java +++ /dev/null @@ -1,279 +0,0 @@ -package de.overview.wg.its.mispbump; - -import android.animation.Animator; -import android.content.Intent; -import android.graphics.Point; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.AppCompatActivity; -import android.view.Display; -import android.view.View; -import android.view.ViewAnimationUtils; -import android.view.WindowManager; -import android.view.animation.DecelerateInterpolator; -import android.widget.*; -import com.google.gson.Gson; -import de.overview.wg.its.mispbump.auxiliary.AESSecurity; -import de.overview.wg.its.mispbump.auxiliary.PreferenceManager; -import de.overview.wg.its.mispbump.auxiliary.RandomString; -import de.overview.wg.its.mispbump.auxiliary.TempAuth; -import de.overview.wg.its.mispbump.cam.CameraFragment; -import de.overview.wg.its.mispbump.model.*; -import net.glxn.qrgen.android.QRCode; - -@Deprecated -public class SyncActivity extends AppCompatActivity implements View.OnClickListener { - - private static final String SCAN_PUB_KEY_FRAG_TAG = "scan_public_key_fragment_tag"; - private static final String SCAN_INFO_FRAG_TAG = "scan_info_fragment_tag"; - - private AESSecurity aesSecurity; - - private Fragment currentFragment; - private String currentFragmentTag; - - private LinearLayout qrBackground; - private ImageView qrImageView; - private Button forwardButton; - private TextView forwardDescription; - - private SyncInformationQr partnerInformation; - - private FragmentManager manager; - private FragmentTransaction transaction; - private PreferenceManager preferenceManager; - - - @Override - protected void onCreate(Bundle savedInstanceState) { - - super.onCreate(savedInstanceState); - getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - setContentView(R.layout.activity_public_key_exchange); - - manager = getSupportFragmentManager(); - preferenceManager = PreferenceManager.Instance(this); - - initializeViews(); - - aesSecurity = AESSecurity.getInstance(); - - setScanTypeFragment(0); - } - - private void initializeViews() { - - ImageButton closeButton = findViewById(R.id.close); - forwardButton = findViewById(R.id.forward); - - closeButton.setOnClickListener(this); - - forwardButton.setOnClickListener(this); - forwardButton.setEnabled(false); - forwardDescription = findViewById(R.id.forward_description); - - qrImageView = findViewById(R.id.qr_imageView); - qrBackground = findViewById(R.id.qr_background); - - setContinueScreenEnabled(false); - } - - private void setScanTypeFragment(int mode) { - - transaction = manager.beginTransaction(); - - User myUser = preferenceManager.getMyUser(); - Organisation myOrg = preferenceManager.getMyOrganisation(); - - switch (mode) { - - case 0: - - setContinueScreenEnabled(false); - - PublicKeyQr pkqr = new PublicKeyQr(myOrg.getName(), - myUser.getEmail(), - AESSecurity.publicKeyToString(aesSecurity.getPublicKey())); - - setQrContent(pkqr.toJSON().toString(), 0.6f); - -// currentFragment = CameraFragment.newInstance(CameraFragment.ScanMode.PUBLIC_KEY); - currentFragmentTag = SCAN_PUB_KEY_FRAG_TAG; - - break; - - case 1: - - setContinueScreenEnabled(false); - - TempAuth.TMP_AUTH_KEY = new RandomString(40).nextString(); - - Server serverForMeOnOtherInstance = new Server(); - serverForMeOnOtherInstance.setAuthkey(TempAuth.TMP_AUTH_KEY); - serverForMeOnOtherInstance.setName("SyncServer for " + myOrg.getName()); - serverForMeOnOtherInstance.setUrl(preferenceManager.getMyServerUrl()); - - SyncInformationQr siqr = new SyncInformationQr( - preferenceManager.getMyOrganisation(), - serverForMeOnOtherInstance, - preferenceManager.getMyUser()); - - setQrContent(aesSecurity.encrypt(siqr.toJSON().toString()), 0.9f); - -// currentFragment = CameraFragment.newInstance(CameraFragment.ScanMode.INFO); - currentFragmentTag = SCAN_INFO_FRAG_TAG; - - break; - - default: - - transaction.remove(currentFragment); - transaction.commit(); - - currentFragment = null; - - finish(); - - return; - } - - transaction.replace(R.id.fragment_container, currentFragment, currentFragmentTag); - transaction.commit(); - } - - private void setQrContent(String content, float qrToScreenRatio) { - - Display display = getWindowManager().getDefaultDisplay(); - Point size = new Point(); - display.getSize(size); - - int width = (int) (size.x * qrToScreenRatio); - - //noinspection SuspiciousNameCombination - qrImageView.setImageBitmap(QRCode.from(content) - .withColor(0xFF000000, 0x00FFFFFF) - .withSize(width, width) - .bitmap()); - - circularReveal(qrBackground, true, 400); - } - - @Override - public void onClick(View v) { - - switch (v.getId()) { - - case R.id.close: - finish(); - break; - - case R.id.forward: - - if (currentFragmentTag.equals(SCAN_PUB_KEY_FRAG_TAG)) { - setScanTypeFragment(1); - } else if (currentFragmentTag.equals(SCAN_INFO_FRAG_TAG)) { - startUploadActivity(); - } - - break; - - } - } - - private void setContinueScreenEnabled(boolean enabled) { - if (enabled) { - forwardButton.setVisibility(View.VISIBLE); - forwardDescription.setVisibility(View.VISIBLE); - } else { - forwardButton.setVisibility(View.INVISIBLE); - forwardDescription.setVisibility(View.INVISIBLE); - } - - forwardButton.setEnabled(enabled); - } - - public void onPublicKeyResult(PublicKeyQr pkqr) { - aesSecurity.setForeignPublicKey(AESSecurity.publicKeyFromString(pkqr.getKey())); - - runOnUiThread(new Runnable() { - @Override - public void run() { - setContinueScreenEnabled(true); - } - }); - } - - public void onSyncInfoResult(SyncInformationQr siqr) { - partnerInformation = siqr; - - runOnUiThread(new Runnable() { - @Override - public void run() { - setContinueScreenEnabled(true); - } - }); - } - - private void startUploadActivity() { - - Intent i = new Intent(this, SyncUploadActivity.class); - i.putExtra(SyncUploadActivity.PARTNER_INFO_BUNDLE_KEY, new Gson().toJson(partnerInformation)); - startActivity(i); - finish(); - - } - - private void circularReveal(final View v, final boolean open, final long duration) { - - v.post(new Runnable() { - @Override - public void run() { - int cx = v.getWidth() / 2; - int cy = v.getHeight() / 2; - - float finalRadius = (float) Math.hypot(cx, cy); - - Animator anim; - - - if (open) { - anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius); - v.setVisibility(View.VISIBLE); - } else { - anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, finalRadius, 0); - } - - anim.setInterpolator(new DecelerateInterpolator()); - - anim.setDuration(duration); - anim.addListener(new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { - - } - - @Override - public void onAnimationEnd(Animator animation) { - if (!open) { - v.setVisibility(View.INVISIBLE); - } - } - - @Override - public void onAnimationCancel(Animator animation) { - - } - - @Override - public void onAnimationRepeat(Animator animation) { - - } - }); - anim.start(); - } - }); - - } -} diff --git a/app/src/main/java/de/overview/wg/its/mispbump/SyncUploadActivity.java b/app/src/main/java/de/overview/wg/its/mispbump/SyncUploadActivity.java index 272c19e..358801f 100644 --- a/app/src/main/java/de/overview/wg/its/mispbump/SyncUploadActivity.java +++ b/app/src/main/java/de/overview/wg/its/mispbump/SyncUploadActivity.java @@ -11,6 +11,7 @@ import android.view.View; import com.android.volley.VolleyError; import com.google.gson.Gson; import de.overview.wg.its.mispbump.adapter.UploadStateAdapter; +import de.overview.wg.its.mispbump.auxiliary.PreferenceManager; import de.overview.wg.its.mispbump.auxiliary.ReadableError; import de.overview.wg.its.mispbump.auxiliary.TempAuth; import de.overview.wg.its.mispbump.model.*; @@ -18,6 +19,8 @@ import de.overview.wg.its.mispbump.network.MispRequest; import org.json.JSONException; import org.json.JSONObject; +import java.util.List; + public class SyncUploadActivity extends AppCompatActivity implements View.OnClickListener { static final String PARTNER_INFO_BUNDLE_KEY = "partner_info"; @@ -34,6 +37,14 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic private UploadState[] uploadStates; private int currentTask = 0; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_upload); + + initializeContent(); + } + @Override public void onClick(View v) { int id = v.getId(); @@ -55,14 +66,6 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic } } - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_upload); - - initializeContent(); - } - private void initializeContent() { @@ -105,7 +108,7 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic uploadStates[0] = new UploadState("Validate upload information"); uploadStates[1] = new UploadState("Check connection to server"); uploadStates[2] = new UploadState("Create local organisation"); - uploadStates[3] = new UploadState("Create sync user & add to organisation"); + uploadStates[3] = new UploadState("Create sync user / add to organisation"); uploadStates[4] = new UploadState("Create external organisation"); uploadStates[5] = new UploadState("Create sync server"); @@ -180,7 +183,7 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic currentTask++; if (currentTask > uploadStates.length) { - return; + addToSyncedList(); } executeTask(currentTask); @@ -221,6 +224,13 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic private void checkBundle(UploadState state) { state.setInProgress(); + state.setDone(); + executeNextTask(); + + if(true) { + return; + } + Bundle b = getIntent().getExtras(); if (b != null) { @@ -249,6 +259,12 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic private void checkConnection(final UploadState state) { state.setInProgress(); + state.setDone(); + executeNextTask(); + + if(true) { + return; + } mispRequest.testConnection(new MispRequest.ConnectionCallback() { @Override @@ -267,6 +283,12 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic private void createOrganisation(final UploadState state, boolean undo) { state.setInProgress(); + state.setDone(); + executeNextTask(); + + if (true) { + return; + } if (!undo) { mispRequest.addOrganisation(partnerOrganisation, new MispRequest.OrganisationCallback() { @@ -310,6 +332,11 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic private void createSyncUser(final UploadState state, boolean undo) { state.setInProgress(); + state.setDone(); + executeNextTask(); + if (true) { + return; + } partnerSyncUser.setAuthkey(TempAuth.TMP_AUTH_KEY); partnerSyncUser.setRoleId(User.RoleId.SYNC_USER); @@ -345,10 +372,16 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic private void createExternalOrganisation(final UploadState state, boolean undo) { - final String originalOrgName = partnerOrganisation.getName(); state.setInProgress(); +// executeNextTask(); + if (true) { + return; + } + + final String originalOrgName = partnerOrganisation.getName(); + if (!undo) { partnerOrganisation.setName(partnerOrganisation.getName() + " (Remote)"); partnerOrganisation.setLocal(false); @@ -363,7 +396,7 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic partnerServer.setRemoteOrgId(extOrgId); partnerServer.setPush(true); - // Reset partner organisation name TODO why? + // Reset partner organisation name because it will show as (remote) name in syncedList partnerOrganisation.setName(originalOrgName); state.setDone(); @@ -398,6 +431,10 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic private void createSyncServer(final UploadState state, boolean undo) { state.setInProgress(); + if (true) { + return; + } + if (!undo) { mispRequest.addServer(partnerServer, new MispRequest.ServerCallback() { @Override @@ -411,12 +448,23 @@ public class SyncUploadActivity extends AppCompatActivity implements View.OnClic state.setError(ReadableError.toReadable(volleyError)); } }); - } else { - } } private void addToSyncedList() { - // todo implementation + + if(true) { + return; + } + + PreferenceManager preferenceManager = PreferenceManager.Instance(this); + + List syncedPartnerList = preferenceManager.getSyncedPartnerList(); + + SyncedPartner sp = new SyncedPartner(partnerOrganisation.getName(), partnerServer.getUrl()); + sp.generateTimeStamp(); + + syncedPartnerList.add(sp); + preferenceManager.setSyncedPartnerList(syncedPartnerList); } } diff --git a/app/src/main/java/de/overview/wg/its/mispbump/UploadActivity.java b/app/src/main/java/de/overview/wg/its/mispbump/UploadActivity.java deleted file mode 100644 index f8b6433..0000000 --- a/app/src/main/java/de/overview/wg/its/mispbump/UploadActivity.java +++ /dev/null @@ -1,243 +0,0 @@ -package de.overview.wg.its.mispbump; - -import android.os.Bundle; -import android.support.design.widget.FloatingActionButton; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.DefaultItemAnimator; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.Toolbar; -import android.view.View; -import com.android.volley.VolleyError; -import com.google.gson.Gson; -import de.overview.wg.its.mispbump.adapter.UploadStateAdapter; -import de.overview.wg.its.mispbump.auxiliary.PreferenceManager; -import de.overview.wg.its.mispbump.auxiliary.ReadableError; -import de.overview.wg.its.mispbump.auxiliary.TempAuth; -import de.overview.wg.its.mispbump.model.*; -import de.overview.wg.its.mispbump.network.MispRequest; -import org.json.JSONException; -import org.json.JSONObject; - -import java.util.ArrayList; -import java.util.List; - -@Deprecated -@SuppressWarnings("ConstantConditions") -public class UploadActivity extends AppCompatActivity implements View.OnClickListener { - - static final String PARTNER_INFO_BUNDLE_KEY = "partner_info"; - - private MispRequest mispRequest; - private SyncInformationQr partnerInformation; - - private Organisation partnerOrganisation; - private User partnerSyncUser; - private Server partnerServer; - - private UploadStateAdapter uploadStateAdapter; - private FloatingActionButton fab; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_upload); - - Bundle b = getIntent().getExtras(); - assert b != null; - String info = b.getString(PARTNER_INFO_BUNDLE_KEY); - - partnerInformation = new Gson().fromJson(info, SyncInformationQr.class); - - mispRequest = MispRequest.Instance(this, true); - - initializeViews(); - - SyncUpload(); - } - - private void initializeViews() { - - Toolbar toolbar = findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - getSupportActionBar().setDisplayShowHomeEnabled(false); - getSupportActionBar().setDisplayHomeAsUpEnabled(false); - getSupportActionBar().setDisplayShowTitleEnabled(true); - - fab = findViewById(R.id.fab_continue_sync_info); - fab.setOnClickListener(this); - fab.setVisibility(View.GONE); - - RecyclerView recyclerView = findViewById(R.id.recyclerView); - uploadStateAdapter = new UploadStateAdapter(); - RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this); - recyclerView.setLayoutManager(mLayoutManager); - recyclerView.setItemAnimator(new DefaultItemAnimator()); - recyclerView.setAdapter(uploadStateAdapter); - } - - @Override - public void onClick(View v) { - - int id = v.getId(); - - switch (id) { - case R.id.fab_continue_sync_info: - finish(); - break; - } - } - - private void setUploadSucces() { - fab.setVisibility(View.VISIBLE); - } - - private void setCurrentStateWrapper(int stateNumber, UploadState.State state) { -// syncUploadStates.get(stateNumber).setCurrentState(state); - uploadStateAdapter.notifyItemChanged(stateNumber); - } - - private List syncUploadStates = new ArrayList<>(); - private void SyncUpload() { - - partnerOrganisation = partnerInformation.getOrganisation(); - partnerSyncUser = partnerInformation.getUser(); - partnerServer = partnerInformation.getServer(); - - syncUploadStates.add(new UploadState("Create local organisation")); - syncUploadStates.add(new UploadState("Create sync user & add to organisation")); - syncUploadStates.add(new UploadState("Create external organisation")); - syncUploadStates.add(new UploadState("Create sync server")); - -// uploadStateAdapter.setStates(syncUploadStates); - - uploadSyncOrganisation(); - - fab.setVisibility(View.VISIBLE); - } - - private void uploadSyncOrganisation() { - - setCurrentStateWrapper(0, UploadState.State.IN_PROGRESS); - - mispRequest.addOrganisation(partnerOrganisation, new MispRequest.OrganisationCallback() { - @Override - public void onResult(JSONObject organisationInformation) { - try { - - Organisation retOrg = new Organisation(organisationInformation); - setCurrentStateWrapper(0, UploadState.State.DONE); - uploadSyncUser(retOrg.getId()); - - } catch (JSONException e) { - syncUploadStates.get(0).setError("Unknown error: could not read server response"); - setCurrentStateWrapper(0, UploadState.State.ERROR); - e.printStackTrace(); - } - - } - - @Override - public void onError(VolleyError volleyError) { - syncUploadStates.get(0).setError(ReadableError.toReadable(volleyError)); - setCurrentStateWrapper(0, UploadState.State.ERROR); - } - }); - } - - private void uploadSyncUser(int orgID) { - - setCurrentStateWrapper(1, UploadState.State.IN_PROGRESS); - - partnerSyncUser.setOrgId(orgID); - partnerSyncUser.setAuthkey(TempAuth.TMP_AUTH_KEY); - partnerSyncUser.setRoleId(User.RoleId.SYNC_USER); - - mispRequest.addUser(partnerSyncUser, new MispRequest.UserCallback() { - @Override - public void onResult(JSONObject myUserInformation) { - setCurrentStateWrapper(1, UploadState.State.DONE); - uploadExternalSyncOrganisation(); - } - - @Override - public void onError(VolleyError volleyError) { - syncUploadStates.get(1).setError(ReadableError.toReadable(volleyError)); - setCurrentStateWrapper(1, UploadState.State.ERROR); - } - }); - } - - private void uploadExternalSyncOrganisation() { - - setCurrentStateWrapper(2, UploadState.State.IN_PROGRESS); - - partnerOrganisation.setName(partnerOrganisation.getName() + " (Remote)"); - partnerOrganisation.setLocal(false); - - mispRequest.addOrganisation(partnerOrganisation, new MispRequest.OrganisationCallback() { - @Override - public void onResult(JSONObject organisationInformation) { - try { - - Organisation extOrg = new Organisation(organisationInformation); - setCurrentStateWrapper(2, UploadState.State.DONE); - uploadSyncServer(extOrg.getId()); - - } catch (JSONException e) { - syncUploadStates.get(2).setError("Could not read server response"); - setCurrentStateWrapper(2, UploadState.State.ERROR); - e.printStackTrace(); - } - } - - @Override - public void onError(VolleyError volleyError) { - syncUploadStates.get(2).setError(ReadableError.toReadable(volleyError)); - setCurrentStateWrapper(2, UploadState.State.ERROR); - } - }); - } - - private void uploadSyncServer(int remoteOrgId) { - - setCurrentStateWrapper(3, UploadState.State.IN_PROGRESS); - - partnerServer.setRemoteOrgId(remoteOrgId); - partnerServer.setPush(true); - - mispRequest.addServer(partnerServer, new MispRequest.ServerCallback() { - @Override - public void onResult(JSONObject servers) { - setCurrentStateWrapper(3, UploadState.State.DONE); - updateSyncedOrganisationList(); - } - - @Override - public void onError(VolleyError volleyError) { - syncUploadStates.get(3).setError(ReadableError.toReadable(volleyError)); - setCurrentStateWrapper(3, UploadState.State.ERROR); - } - }); - } - - private void updateSyncedOrganisationList() { - - PreferenceManager preferenceManager = PreferenceManager.Instance(this); - - List syncedPartnerList = preferenceManager.getSyncedPartnerList(); - - if (syncedPartnerList == null) { - syncedPartnerList = new ArrayList<>(); - } - - SyncedPartner sp = new SyncedPartner( - partnerInformation.getOrganisation().getName(), - partnerInformation.getServer().getUrl()); - - sp.generateTimeStamp(); - syncedPartnerList.add(sp); - preferenceManager.setSyncedPartnerList(syncedPartnerList); - } -} diff --git a/app/src/main/java/de/overview/wg/its/mispbump/preferences/AppPreferenceActivity.java b/app/src/main/java/de/overview/wg/its/mispbump/preferences/AppPreferenceActivity.java deleted file mode 100644 index 9c98c1e..0000000 --- a/app/src/main/java/de/overview/wg/its/mispbump/preferences/AppPreferenceActivity.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.overview.wg.its.mispbump.preferences; - -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.support.v7.preference.PreferenceManager; -import android.support.v7.widget.Toolbar; -import de.overview.wg.its.mispbump.R; - -public class AppPreferenceActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.activity_app_preference); - - getSupportFragmentManager().beginTransaction() - .replace(R.id.settings_content, new AppPreferenceFragment()) - .commit(); - - initializeContent(); - } - - private void initializeContent() { - Toolbar toolbar = findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - //noinspection ConstantConditions - getSupportActionBar().setDisplayShowTitleEnabled(true); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setDisplayShowHomeEnabled(true); - } - -} diff --git a/app/src/main/java/de/overview/wg/its/mispbump/preferences/AppPreferenceFragment.java b/app/src/main/java/de/overview/wg/its/mispbump/preferences/AppPreferenceFragment.java deleted file mode 100644 index 69cffb9..0000000 --- a/app/src/main/java/de/overview/wg/its/mispbump/preferences/AppPreferenceFragment.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.overview.wg.its.mispbump.preferences; - -import android.os.Bundle; -import android.support.v7.preference.PreferenceFragmentCompat; -import de.overview.wg.its.mispbump.R; - -public class AppPreferenceFragment extends PreferenceFragmentCompat { - - @Override - public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { - addPreferencesFromResource(R.xml.app_preferences); - } - -} diff --git a/app/src/main/res/layout/activity_app_preference.xml b/app/src/main/res/layout/activity_app_preference.xml deleted file mode 100644 index 9a0aa75..0000000 --- a/app/src/main/res/layout/activity_app_preference.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_credentials.xml b/app/src/main/res/layout/activity_credentials.xml deleted file mode 100644 index 7a8ef3b..0000000 --- a/app/src/main/res/layout/activity_credentials.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_public_key_exchange.xml b/app/src/main/res/layout/activity_public_key_exchange.xml deleted file mode 100644 index 7279957..0000000 --- a/app/src/main/res/layout/activity_public_key_exchange.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - -