[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake-mobile/master] Handled failure case and changed messages



commit 21941c076437c77ffadb2524a21163b296f9fdd0
Author: Hashik Donthineni <HashikDonthineni@xxxxxxxxx>
Date:   Wed Nov 11 14:59:50 2020 +0530

    Handled failure case and changed messages
---
 app/src/main/java/org/torproject/snowflake/MainActivity.java      | 2 ++
 .../java/org/torproject/snowflake/fragments/MainFragment.java     | 8 ++++++++
 .../java/org/torproject/snowflake/models/MainActivityModel.java   | 4 ++--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/app/src/main/java/org/torproject/snowflake/MainActivity.java b/app/src/main/java/org/torproject/snowflake/MainActivity.java
index 43f3697..5fb3fb4 100644
--- a/app/src/main/java/org/torproject/snowflake/MainActivity.java
+++ b/app/src/main/java/org/torproject/snowflake/MainActivity.java
@@ -204,6 +204,8 @@ public class MainActivity extends AppCompatActivity implements MainFragmentCallb
         runOnUiThread(() -> {
             settingsButton.setEnabled(true);
             settingsButton.setClickable(true);
+            Fragment mainFragment = getSupportFragmentManager().findFragmentByTag(Integer.toString(FragmentConstants.MAIN_FRAGMENT));
+            ((MainFragment) mainFragment).relayFailed(message);
         });
     }
 
diff --git a/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java b/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java
index 64e0ef4..1fddeaa 100644
--- a/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java
+++ b/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java
@@ -148,4 +148,12 @@ public class MainFragment extends Fragment {
         colorAnimation.addUpdateListener(animator -> snowflakeLogo.setColorFilter((int) animator.getAnimatedValue(), PorterDuff.Mode.SRC_ATOP));
         colorAnimation.start();
     }
+
+    public void relayFailed(String message) {
+        startButton.setEnabled(true);
+        startButton.setClickable(true);
+        startButton.setChecked(false);
+        setSnowflakeStatus(false);
+        noteTV.setText(message);
+    }
 }
\ No newline at end of file
diff --git a/app/src/main/java/org/torproject/snowflake/models/MainActivityModel.java b/app/src/main/java/org/torproject/snowflake/models/MainActivityModel.java
index 15572a0..cc42599 100644
--- a/app/src/main/java/org/torproject/snowflake/models/MainActivityModel.java
+++ b/app/src/main/java/org/torproject/snowflake/models/MainActivityModel.java
@@ -164,7 +164,7 @@ public class MainActivityModel implements MainActivityMVPContract.Model {
         try {
             req = new Request.Builder().url(GlobalApplication.getWebSocketUrl()).build();
         } catch (IllegalArgumentException e) {
-            presenter.relayFailure("Malformed URL");
+            presenter.relayFailure("Error: Malformed/Invalid Relay URL");
             return;
         }
 
@@ -175,7 +175,7 @@ public class MainActivityModel implements MainActivityMVPContract.Model {
                     public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t, @org.jetbrains.annotations.Nullable Response response) {
                         Log.d(TAG, "WebSocketListener: onFailure: ");
                         webSocket.close(1000, "Normal Closure"); //TODO: Change Failure code.
-                        presenter.relayFailure("Web socket connection failed");
+                        presenter.relayFailure("Error: WebSocket Connection Failed. Try again later.");
                     }
 
                     @Override



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits