commit 7023cd27e8aaffa3ac36f989ce9bd3b79e1aca50 Author: n8fr8 nathan@guardianproject.info Date: Tue Jul 13 12:28:01 2021 -0400
enable snowflake mode for orbotTV --- app-tv/build.gradle | 3 ++ .../torproject/android/tv/TeeveeMainActivity.java | 50 ++++++++++++++++++++++ app-tv/src/main/res/layout/layout_main.xml | 27 +++++++++++- app-tv/src/main/res/values/strings.xml | 1 + 4 files changed, 79 insertions(+), 2 deletions(-)
diff --git a/app-tv/build.gradle b/app-tv/build.gradle index b7121d8b..6d3250b5 100644 --- a/app-tv/build.gradle +++ b/app-tv/build.gradle @@ -137,6 +137,9 @@ dependencies { // leanback-tab is an add-on that provides customized TabLayout to be used as the top navigation bar. implementation "androidx.leanback:leanback-tab:1.1.0-beta01"
+ //add snowflake fun + implementation 'com.github.jetradarmobile:android-snowfall:1.2.1' + }
// Map for the version code that gives each ABI a value. diff --git a/app-tv/src/main/java/org/torproject/android/tv/TeeveeMainActivity.java b/app-tv/src/main/java/org/torproject/android/tv/TeeveeMainActivity.java index 0c0b2d5c..ef76c824 100644 --- a/app-tv/src/main/java/org/torproject/android/tv/TeeveeMainActivity.java +++ b/app-tv/src/main/java/org/torproject/android/tv/TeeveeMainActivity.java @@ -48,6 +48,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentResult; +import com.jetradarmobile.snowfall.SnowfallView;
import net.freehaven.tor.control.TorControlCommands; import org.json.JSONArray; @@ -98,6 +99,7 @@ public class TeeveeMainActivity extends Activity implements OrbotConstants, OnLo private TextView uploadText = null; private TextView mTxtOrbotLog = null; private Switch mBtnVPN = null; + private Switch mBtnSnowflake = null; /* Some tracking bits */ private String torStatus = null; //latest status reported from the tor service private Intent lastStatusIntent; // the last ACTION_STATUS Intent received @@ -326,6 +328,9 @@ public class TeeveeMainActivity extends Activity implements OrbotConstants, OnLo Intent intent = new Intent(TeeveeMainActivity.this, OrbotService.class); stopService(intent);
+ SnowfallView sv = findViewById(R.id.snowflake_view); + sv.setVisibility(View.GONE); + sv.stopFalling(); }
private void doLayout() { @@ -379,6 +384,33 @@ public class TeeveeMainActivity extends Activity implements OrbotConstants, OnLo } });
+ mBtnSnowflake = findViewById(R.id.btnSnowflake); + mBtnSnowflake.setFocusable(true); + mBtnSnowflake.setFocusableInTouchMode(true); + + mBtnSnowflake.setOnFocusChangeListener(new View.OnFocusChangeListener() { + @Override + public void onFocusChange(View v, boolean hasFocus) { + + if (hasFocus) + v.setBackgroundColor(getColor(R.color.dark_purple)); + else + { + v.setBackgroundColor(getColor(R.color.med_gray)); + } + } + }); + + + boolean beASnowflake = Prefs.beSnowflakeProxy(); + mBtnSnowflake.setChecked(beASnowflake); + + mBtnSnowflake.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + Prefs.setBeSnowflakeProxy(isChecked); + } + });
rv = findViewById(R.id.rv); LinearLayoutManager llm = new LinearLayoutManager(this); @@ -791,6 +823,24 @@ public class TeeveeMainActivity extends Activity implements OrbotConstants, OnLo Log.d(TAG, "autoStartFromIntent finish"); }
+ if (Prefs.beSnowflakeProxy()) + { + + + SnowfallView sv = findViewById(R.id.snowflake_view); + sv.setVisibility(View.VISIBLE); + sv.restartFalling(); + + } + else + { + SnowfallView sv = findViewById(R.id.snowflake_view); + sv.setVisibility(View.GONE); + sv.stopFalling(); + + + } +
} else if (torStatus == TorServiceConstants.STATUS_STARTING) {
diff --git a/app-tv/src/main/res/layout/layout_main.xml b/app-tv/src/main/res/layout/layout_main.xml index a6bdd5f2..e4e07441 100644 --- a/app-tv/src/main/res/layout/layout_main.xml +++ b/app-tv/src/main/res/layout/layout_main.xml @@ -5,12 +5,23 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/light_gray" + android:background="@color/light_purple" xmlns:app="http://schemas.android.com/apk/res-auto%22%3E
+ <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <com.jetradarmobile.snowfall.SnowfallView + android:id="@+id/snowflake_view" + android:visibility="gone" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + <RelativeLayout android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + >
<androidx.recyclerview.widget.RecyclerView @@ -18,6 +29,8 @@ android:layout_height="wrap_content" android:id="@+id/rv" android:layout_marginBottom="60dp" + + />
@@ -90,7 +103,16 @@ android:lines="1" />
+ <Switch + android:id="@+id/btnSnowflake" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/snowflake_mode" + android:layout_margin="9dp" + android:layout_gravity="center" + app:switchPadding="3dp"
+ /> </LinearLayout>
@@ -130,6 +152,7 @@ android:fontFamily="monospace" /> </LinearLayout> + </FrameLayout>
</LinearLayout>
diff --git a/app-tv/src/main/res/values/strings.xml b/app-tv/src/main/res/values/strings.xml index 36d5041a..f4b1ffdb 100644 --- a/app-tv/src/main/res/values/strings.xml +++ b/app-tv/src/main/res/values/strings.xml @@ -244,4 +244,5 @@ <string name="wifi_only">Wifi only</string> <string name="keep_your_apps_from_using_mobile_data">Only allow connection over wifi (coming soon!)</string> <string name="remove">Remove</string> + <string name="snowflake_mode">Snowflake</string> </resources>