summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2023-08-04 03:17:32 +0200
committercyBerta <cyberta@riseup.net>2023-08-04 03:17:32 +0200
commitfe7db7a1e9b72adf137e8221e8d9cda114b2b8e7 (patch)
tree2f49d2385490ad6aced47558f0261b12d1957905 /app
parentdf84c3064002bb90b8e7d840afe25b6b58a64efd (diff)
set back button in setup action bar title if configured provider is already available
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SetupActivity.java24
-rw-r--r--app/src/main/res/drawable-anydpi-v24/ic_back.xml1
-rw-r--r--app/src/main/res/drawable/ic_back.pngbin0 -> 205 bytes
3 files changed, 25 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SetupActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SetupActivity.java
index e7a1d4e2..57b648f4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SetupActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SetupActivity.java
@@ -12,11 +12,13 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
import android.net.VpnService;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
@@ -26,6 +28,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
+import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager2.widget.ViewPager2;
@@ -40,6 +43,8 @@ import se.leap.bitmaskclient.BuildConfig;
import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.base.FragmentManagerEnhanced;
import se.leap.bitmaskclient.base.models.Provider;
+import se.leap.bitmaskclient.base.models.ProviderObservable;
+import se.leap.bitmaskclient.base.utils.ViewHelper;
import se.leap.bitmaskclient.base.views.ActionBarTitle;
import se.leap.bitmaskclient.databinding.ActivitySetupBinding;
import se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog;
@@ -97,6 +102,11 @@ public class SetupActivity extends AppCompatActivity implements SetupActivityCal
getChildAt(0).
setBackgroundColor(ContextCompat.getColor(SetupActivity.this, (i == position) ? R.color.colorPrimaryDark : R.color.colorDisabled));
}
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(position == 0 && ProviderObservable.getInstance().getCurrentProvider().isConfigured());
+ }
+
}
});
binding.viewPager.setAdapter(adapter);
@@ -153,6 +163,10 @@ public class SetupActivity extends AppCompatActivity implements SetupActivityCal
actionBarTitle.setTitle(getString(R.string.app_name));
actionBarTitle.showSubtitle(false);
+ final Drawable upArrow = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_back, getTheme());
+ actionBar.setHomeAsUpIndicator(upArrow);
+
+ actionBar.setDisplayHomeAsUpEnabled(ProviderObservable.getInstance().getCurrentProvider().isConfigured());
@ColorInt int titleColor = ContextCompat.getColor(context, R.color.colorActionBarTitleFont);
actionBarTitle.setTitleTextColor(titleColor);
@@ -169,6 +183,16 @@ public class SetupActivity extends AppCompatActivity implements SetupActivityCal
}
@Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
public void onSetupStepValidationChanged(boolean isValid) {
binding.setupNextButton.setEnabled(isValid);
}
diff --git a/app/src/main/res/drawable-anydpi-v24/ic_back.xml b/app/src/main/res/drawable-anydpi-v24/ic_back.xml
new file mode 100644
index 00000000..404c8177
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi-v24/ic_back.xml
@@ -0,0 +1 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#FFFFFF" android:pathData="M21,11H6.83L10.41,7.41L9,6L3,12L9,18L10.41,16.58L6.83,13H21V11Z" /></vector> \ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_back.png b/app/src/main/res/drawable/ic_back.png
new file mode 100644
index 00000000..dcc52bfa
--- /dev/null
+++ b/app/src/main/res/drawable/ic_back.png
Binary files differ