[tor-commits] [snowflake-mobile/master] Added text view to show the user how many clients he has served

cohosh at torproject.org cohosh at torproject.org
Mon Jul 20 15:34:01 UTC 2020


commit c24291af2642ae56022bab5136dfc5f92361ca69
Author: Hashik Donthineni <HashikDonthineni at gmail.com>
Date:   Sat Jul 11 02:59:38 2020 +0530

    Added text view to show the user how many clients he has served
---
 .../org/torproject/snowflake/fragments/MainFragment.java    | 13 ++++++++++++-
 app/src/main/res/layout/fragment_main_fragment.xml          | 12 ++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

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 705cd0c..6841be3 100644
--- a/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java
+++ b/app/src/main/java/org/torproject/snowflake/fragments/MainFragment.java
@@ -2,11 +2,13 @@ package org.torproject.snowflake.fragments;
 
 import android.content.Context;
 import android.os.Bundle;
+import android.text.Layout;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.Button;
+import android.widget.TextView;
 
 import androidx.annotation.NonNull;
 import androidx.fragment.app.Fragment;
@@ -23,6 +25,7 @@ import org.torproject.snowflake.interfaces.MainFragmentCallback;
 public class MainFragment extends Fragment {
     private static final String TAG = "MainFragment";
     MainFragmentCallback callback;
+    TextView usersServedTV;
 
     public MainFragment() {
         // Required empty public constructor
@@ -49,7 +52,9 @@ public class MainFragment extends Fragment {
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         View rootView = inflater.inflate(R.layout.fragment_main_fragment, container, false);
+        usersServedTV = rootView.findViewById(R.id.users_served);
         Button startButton = rootView.findViewById(R.id.start_button);
+
         startButton.setOnClickListener(v -> {
             if (callback.isServiceRunning()) //Toggling the service.
                 callback.serviceToggle(ForegroundServiceConstants.ACTION_STOP);
@@ -71,6 +76,12 @@ public class MainFragment extends Fragment {
     }
 
     public void showServed() {
-        Log.d(TAG, "showServed: " + callback.getServed());
+        int served = callback.getServed();
+        Log.d(TAG, "showServed: " + served);
+
+        if(served > 0){
+            usersServedTV.setVisibility(View.VISIBLE);
+            usersServedTV.setText("Users you have helped circumvent censorship in the past day \n" + served);
+        }
     }
 }
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_main_fragment.xml b/app/src/main/res/layout/fragment_main_fragment.xml
index bd6a855..d7f2bd9 100644
--- a/app/src/main/res/layout/fragment_main_fragment.xml
+++ b/app/src/main/res/layout/fragment_main_fragment.xml
@@ -14,4 +14,16 @@
         android:foreground="?android:attr/selectableItemBackground"
         android:text="Service Toggle" />
 
+    <TextView
+        android:id="@+id/users_served"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/start_button"
+        android:layout_centerHorizontal="true"
+        android:paddingTop="10dp"
+        android:paddingLeft="50dp"
+        android:paddingRight="50dp"
+        android:gravity="center"
+        android:visibility="gone" />
+
 </RelativeLayout>
\ No newline at end of file





More information about the tor-commits mailing list