diff --git a/app/build.gradle b/app/build.gradle
index 772d671..9e4d154 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -61,7 +61,4 @@ dependencies {
}
repositories {
mavenCentral()
-}
-configurations {
- all*.exclude group: 'com.google.guava', module:'listenablefuture'
}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/CoreContracts.kt b/app/src/main/java/io/github/chronosx88/influence/contracts/CoreContracts.kt
index 3a2c099..4764bad 100644
--- a/app/src/main/java/io/github/chronosx88/influence/contracts/CoreContracts.kt
+++ b/app/src/main/java/io/github/chronosx88/influence/contracts/CoreContracts.kt
@@ -54,7 +54,10 @@ interface CoreContracts {
fun onDestroy()
}
- interface IMainViewContract//
+ interface IMainViewContract {
+ fun showSnackbar(message: String)
+ fun showProgressBar(state: Boolean)
+ }
// -----ChatActivity-----
diff --git a/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.java b/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.java
deleted file mode 100644
index 82797d4..0000000
--- a/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package io.github.chronosx88.influence.presenters;
-
-import io.github.chronosx88.influence.contracts.CoreContracts;
-import io.github.chronosx88.influence.logic.MainLogic;
-
-public class MainPresenter implements CoreContracts.IMainPresenterContract {
- private CoreContracts.IMainLogicContract logic;
- private CoreContracts.IMainViewContract view;
-
- public MainPresenter(CoreContracts.IMainViewContract view) {
- this.view = view;
- logic = new MainLogic();
- }
-
- @Override
- public void initPeer() {
- logic.initPeer();
- }
-
- @Override
- public void onDestroy() {
- logic.shutdownPeer();
- }
-}
diff --git a/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.kt b/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.kt
new file mode 100644
index 0000000..73ab727
--- /dev/null
+++ b/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.kt
@@ -0,0 +1,23 @@
+package io.github.chronosx88.influence.presenters
+
+import io.github.chronosx88.influence.R
+import io.github.chronosx88.influence.contracts.CoreContracts
+import io.github.chronosx88.influence.helpers.AppHelper
+import io.github.chronosx88.influence.logic.MainLogic
+
+class MainPresenter(private val view: CoreContracts.IMainViewContract) : CoreContracts.IMainPresenterContract {
+ private val logic: CoreContracts.IMainLogicContract = MainLogic()
+
+ override fun initPeer() {
+ if (AppHelper.getPeerDHT() == null) {
+ logic.initPeer()
+ } else {
+ view.showSnackbar(AppHelper.getContext().getString(R.string.node_already_running))
+ view.showProgressBar(false)
+ }
+ }
+
+ override fun onDestroy() {
+ logic.shutdownPeer()
+ }
+}
diff --git a/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java b/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java
index 006dfa9..90db9f3 100644
--- a/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java
+++ b/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java
@@ -2,16 +2,23 @@ package io.github.chronosx88.influence.views;
import android.app.ProgressDialog;
import android.os.Bundle;
+import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.Toast;
import com.google.android.material.bottomnavigation.BottomNavigationView;
+import com.google.android.material.snackbar.Snackbar;
import com.google.gson.JsonObject;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
+
+import org.jetbrains.annotations.NotNull;
+
import io.github.chronosx88.influence.R;
import io.github.chronosx88.influence.contracts.CoreContracts;
import io.github.chronosx88.influence.contracts.observer.IObserver;
@@ -130,4 +137,47 @@ public class MainActivity extends AppCompatActivity implements IObserver, CoreCo
}
}
}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main_actionbar_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if(item.getItemId() == R.id.action_reconnect_network) {
+ progressDialog.show();
+ presenter.initPeer();
+ }
+ return true;
+ }
+
+ @Override
+ public void showSnackbar(@NotNull String message) {
+ Snackbar.make(getRootView(), message, Snackbar.LENGTH_LONG)
+ .show();
+ }
+
+ @Override
+ public void showProgressBar(boolean state) {
+ if(state) {
+ progressDialog.show();
+ } else {
+ progressDialog.dismiss();
+ }
+ }
+
+ private View getRootView() {
+ final ViewGroup contentViewGroup = findViewById(android.R.id.content);
+ View rootView = null;
+
+ if(contentViewGroup != null)
+ rootView = contentViewGroup.getChildAt(0);
+
+ if(rootView == null)
+ rootView = getWindow().getDecorView().getRootView();
+
+ return rootView;
+ }
}
diff --git a/app/src/main/res/drawable/ic_autorenew_white_24dp.xml b/app/src/main/res/drawable/ic_autorenew_white_24dp.xml
new file mode 100644
index 0000000..a23db6d
--- /dev/null
+++ b/app/src/main/res/drawable/ic_autorenew_white_24dp.xml
@@ -0,0 +1,22 @@
+
+
+