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

[tor-commits] [snowflake-mobile/master] Added up(back) button



commit cddbc2b4f0f5ae62a8d550fc8868a40b9cb7767d
Author: Hashik Donthineni <HashikDonthineni@xxxxxxxxx>
Date:   Fri Jul 24 13:58:19 2020 +0530

    Added up(back) button
---
 .../main/java/org/torproject/snowflake/MainActivity.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/app/src/main/java/org/torproject/snowflake/MainActivity.java b/app/src/main/java/org/torproject/snowflake/MainActivity.java
index 4664ae5..d1f6d4c 100644
--- a/app/src/main/java/org/torproject/snowflake/MainActivity.java
+++ b/app/src/main/java/org/torproject/snowflake/MainActivity.java
@@ -8,8 +8,11 @@ import android.graphics.Color;
 import android.os.Build;
 import android.os.Bundle;
 import android.util.Log;
+import android.view.MenuItem;
+import android.view.View;
 import android.widget.Button;
 
+import androidx.annotation.NonNull;
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.fragment.app.Fragment;
 
@@ -72,8 +75,10 @@ public class MainActivity extends AppCompatActivity implements MainFragmentCallb
     private void startFragment(Fragment fragment) {
         if (fragment instanceof MainFragment) {
             currentFragment = FragmentConstants.MAIN_FRAGMENT;
+            getSupportActionBar().setDisplayHomeAsUpEnabled(false);
         } else {
             currentFragment = FragmentConstants.APP_SETTINGS_FRAGMENT;
+            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
         }
 
         Log.d(TAG, "startFragment: " + currentFragment);
@@ -170,4 +175,15 @@ public class MainActivity extends AppCompatActivity implements MainFragmentCallb
         else
             return 0;
     }
+
+    @Override
+    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+
+        if (item.getItemId() == android.R.id.home) {
+            onBackPressed();
+            return true;
+        }
+
+        return super.onOptionsItemSelected(item);
+    }
 }



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