diff options
Diffstat (limited to 'app/src/main/java')
5 files changed, 38 insertions, 46 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java index 45c6307a..14673874 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java @@ -477,7 +477,8 @@ public class EipFragment extends Fragment implements Observer { greyscaleBackground(); locationButton.setLocationLoad(UNKNOWN); locationButton.showBridgeIndicator(false); - locationButton.setText(getString(R.string.gateway_selection_title)); + String city = getPreferredCity(getContext()); + locationButton.setText(city == null ? getString(R.string.gateway_selection_recommended_location) : city); locationButton.showRecommendedIndicator(false); mainDescription.setText(R.string.eip_state_insecure); subDescription.setText(R.string.connection_not_connected); diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java index 9f210bd5..ae961366 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/NavigationDrawerFragment.java @@ -83,7 +83,6 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen * Per the design guidelines, you should show the drawer on launch until the user manually * expands it. This shared preference tracks this. */ - private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned"; private static final String TAG = NavigationDrawerFragment.class.getName(); public static final int TWO_SECONDS = 2000; @@ -100,7 +99,6 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen private IconSwitchEntry saveBattery; private IconTextEntry manualGatewaySelection; - private boolean userLearnedDrawer; private volatile boolean wasPaused; private volatile boolean shouldCloseOnResume; @@ -116,7 +114,6 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen // Reads in the flag indicating whether or not the user has demonstrated awareness of the // drawer. See PREF_USER_LEARNED_DRAWER for details. preferences = getContext().getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); - userLearnedDrawer = preferences.getBoolean(PREF_USER_LEARNED_DRAWER, false); preferences.registerOnSharedPreferenceChangeListener(this); } @@ -181,10 +178,6 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen setupEntries(); setupActionBarDrawerToggle(activity); - if (!userLearnedDrawer) { - openNavigationDrawerForFirstTimeUsers(); - } - // Defer code dependent on restoration of previous instance state. this.drawerLayout.post(() -> drawerToggle.syncState()); this.drawerLayout.addDrawerListener(drawerToggle); @@ -216,12 +209,6 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen return; } - if (!userLearnedDrawer) { - // The user manually opened the drawer; store this flag to prevent auto-showing - // the navigation drawer automatically in the future. - userLearnedDrawer = true; - preferences.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); - } activity.invalidateOptionsMenu(); } }; @@ -369,15 +356,6 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen return actionBar; } - private void openNavigationDrawerForFirstTimeUsers() { - if (userLearnedDrawer) { - return; - } - - drawerLayout.openDrawer(fragmentContainerView, false); - closeDrawerWithDelay(); - } - @NonNull private void closeDrawerWithDelay() { final Handler navigationDrawerHandler = new Handler(); diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java index 5ea70085..a20d0b73 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java @@ -32,7 +32,7 @@ import static android.content.Context.MODE_PRIVATE; import static android.view.View.GONE; import static android.view.View.VISIBLE; import static se.leap.bitmaskclient.R.string.advanced_settings; -import static se.leap.bitmaskclient.base.MainActivity.ACTION_SHOW_VPN_FRAGMENT; +import static se.leap.bitmaskclient.base.models.Constants.PREFER_UDP; import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES; import static se.leap.bitmaskclient.base.models.Constants.USE_BRIDGES; import static se.leap.bitmaskclient.base.models.Constants.USE_IPv6_FIREWALL; @@ -53,6 +53,7 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh private IconTextEntry tethering; private IconSwitchEntry firewall; + IconSwitchEntry useUdpEntry; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -98,8 +99,12 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh Toast.makeText(getContext(), R.string.reconnecting, Toast.LENGTH_LONG).show(); } }); - - + //We check the UI state of the useUdpEntry here as well, in order to avoid a situation + //where both entries are disabled, because both preferences are enabled. + //bridges can be enabled not only from here but also from error handling + boolean useUDP = getPreferUDP(getContext()) && useUdpEntry.isEnabled(); + useBridges.setEnabled(!useUDP); + useBridges.setSubtitle(getString(useUDP ? R.string.disabled_while_udp_on : R.string.nav_drawer_subtitle_obfuscated_connection)); } else { useBridges.setVisibility(GONE); } @@ -134,7 +139,7 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh } private void initPreferUDPEntry(View rootView) { - IconSwitchEntry useUdpEntry = rootView.findViewById(R.id.prefer_udp); + useUdpEntry = rootView.findViewById(R.id.prefer_udp); useUdpEntry.setVisibility(VISIBLE); useUdpEntry.setChecked(getPreferUDP(getContext())); useUdpEntry.setOnCheckedChangeListener((buttonView, isChecked) -> { @@ -235,7 +240,7 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh if (rootView == null) { return; } - if (key.equals(USE_BRIDGES)) { + if (key.equals(USE_BRIDGES) || key.equals(PREFER_UDP)) { initUseBridgesEntry(rootView); initPreferUDPEntry(rootView); } else if (key.equals(USE_IPv6_FIREWALL)) { diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java index 72ad03f9..08a852ec 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java @@ -1,13 +1,13 @@ package se.leap.bitmaskclient.base.views; import android.content.Context; +import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.eip.GatewaysManager; @@ -22,25 +22,26 @@ public class LocationIndicator extends LinearLayout { private View level2_2; private View level3; private View level3_2; + private int tintColor; public LocationIndicator(Context context) { super(context); - initLayout(context); + initLayout(context, null); } public LocationIndicator(Context context, @Nullable AttributeSet attrs) { super(context, attrs); - initLayout(context); + initLayout(context, attrs); } public LocationIndicator(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - initLayout(context); + initLayout(context, attrs); } - void initLayout(Context context) { + void initLayout(Context context, AttributeSet attrs) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rootview = inflater.inflate(R.layout.v_location_status_indicator, this, true); @@ -50,6 +51,13 @@ public class LocationIndicator extends LinearLayout { level2_2 = rootview.findViewById(R.id.level2_2); level3 = rootview.findViewById(R.id.level3); level3_2 = rootview.findViewById(R.id.level3_2); + if (attrs != null) { + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LocationIndicator); + this.tintColor = typedArray.getColor(R.styleable.LocationIndicator_tint, getColor(context, R.color.black800_high_transparent)); + typedArray.recycle(); + } else { + this.tintColor = getColor(context, R.color.black800_high_transparent); + } } public void setLoad(GatewaysManager.Load load) { @@ -67,24 +75,24 @@ public class LocationIndicator extends LinearLayout { level1_2.setBackgroundColor(getColor(getContext(), R.color.amber200)); level2.setBackgroundColor(getColor(getContext(), R.color.amber200)); level2_2.setBackgroundColor(getColor(getContext(), R.color.amber200)); - level3.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); - level3_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level3.setBackgroundColor(tintColor); + level3_2.setBackgroundColor(tintColor); break; case CRITICAL: level1.setBackgroundColor(getColor(getContext(), R.color.red200)); level1_2.setBackgroundColor(getColor(getContext(), R.color.red200)); - level2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); - level2_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); - level3.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); - level3_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level2.setBackgroundColor(tintColor); + level2_2.setBackgroundColor(tintColor); + level3.setBackgroundColor(tintColor); + level3_2.setBackgroundColor(tintColor); break; default: - level1.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); - level1_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); - level2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); - level2_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); - level3.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); - level3_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent));; + level1.setBackgroundColor(tintColor); + level1_2.setBackgroundColor(tintColor); + level2.setBackgroundColor(tintColor); + level2_2.setBackgroundColor(tintColor); + level3.setBackgroundColor(tintColor); + level3_2.setBackgroundColor(tintColor); break; } } diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupFailedDialog.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupFailedDialog.java index a9247807..0d5f903f 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupFailedDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupFailedDialog.java @@ -143,7 +143,7 @@ public class ProviderSetupFailedDialog extends DialogFragment { handleTorTimeoutError(); }); builder.setNeutralButton(R.string.retry_unobfuscated, ((dialog, id) -> { - PreferenceHelper.useBridges(getContext(), false); + PreferenceHelper.useSnowflake(getContext(), false); handleTorTimeoutError(); })); default: |