diff options
Diffstat (limited to 'app')
17 files changed, 86 insertions, 36 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 11cab7e5..f8053f5e 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 @@ -417,62 +417,56 @@ public class EipFragment extends Fragment implements Observer { if (eipStatus.isConnecting() ) { setMainButtonEnabled(true); showConnectionTransitionLayout(true); - if (eipStatus.isReconnecting()) { - subDescription.setText(getString(R.string.reconnecting)); - } else { - subDescription.setText(R.string.connection_not_connected); - } locationButton.setText(getString(R.string.finding_best_connection)); - mainDescription.setText(R.string.eip_state_insecure); - locationButton.setVisibility(VISIBLE); locationButton.setLocationLoad(UNKNOWN); locationButton.showBridgeIndicator(false); + locationButton.showRecommendedIndicator(false); + mainDescription.setText(R.string.eip_state_insecure); + subDescription.setText(null); } else if (eipStatus.isConnected()) { setMainButtonEnabled(true); mainButton.updateState(true, false, false); locationButton.setLocationLoad(gatewaysManager.getLoadForLocation(VpnStatus.getLastConnectedVpnName())); locationButton.setText(VpnStatus.getLastConnectedVpnName()); locationButton.showBridgeIndicator(VpnStatus.isUsingBridges()); - locationButton.setVisibility(VISIBLE); - colorBackground(); + locationButton.showRecommendedIndicator(getPreferredCity(getContext())== null); mainDescription.setText(R.string.eip_state_connected); - subDescription.setText(getPreferredCity(getContext()) == null ? - R.string.eip_state_connected_recommended : - R.string.eip_state_connected_manual); + subDescription.setText(null); + colorBackground(); } else if(isOpenVpnRunningWithoutNetwork()){ Log.d(TAG, "eip fragment eipStatus - isOpenVpnRunningWithoutNetwork"); setMainButtonEnabled(true); mainButton.updateState(true, false, true); - locationButton.setVisibility(VISIBLE); locationButton.setText(VpnStatus.getCurrentlyConnectingVpnName()); locationButton.showBridgeIndicator(VpnStatus.isUsingBridges()); + locationButton.showBridgeIndicator(VpnStatus.isUsingBridges()); + locationButton.showRecommendedIndicator(getPreferredCity(getContext())== null); colorBackgroundALittle(); - mainDescription.setText(R.string.eip_state_insecure); + mainDescription.setText(R.string.eip_state_connected); subDescription.setText(R.string.eip_state_no_network); } else if (eipStatus.isDisconnected() && reconnectingWithDifferentGateway()) { showConnectionTransitionLayout(true); // showRetryToast(activity); locationButton.setText(getString(R.string.finding_best_connection)); - locationButton.setVisibility(VISIBLE); locationButton.setLocationLoad(UNKNOWN); locationButton.showBridgeIndicator(false); + locationButton.showRecommendedIndicator(false); mainDescription.setText(R.string.eip_state_insecure); subDescription.setText(R.string.reconnecting); } else if (eipStatus.isDisconnecting()) { setMainButtonEnabled(false); showConnectionTransitionLayout(false); mainDescription.setText(R.string.eip_state_insecure); - subDescription.setText(R.string.connection_not_connected); } else if (eipStatus.isBlocking()) { setMainButtonEnabled(true); mainButton.updateState(true, false, true); colorBackgroundALittle(); locationButton.setText(getString(R.string.finding_best_connection)); - locationButton.setVisibility(VISIBLE); locationButton.setLocationLoad(UNKNOWN); locationButton.showBridgeIndicator(false); + locationButton.showRecommendedIndicator(false); mainDescription.setText(R.string.eip_state_connected); - subDescription.setText(R.string.eip_state_blocking); + subDescription.setText(getString(R.string.eip_state_blocking, getString(R.string.app_name))); } else { locationButton.setText(activity.getString(R.string.vpn_button_turn_on)); setMainButtonEnabled(true); @@ -480,7 +474,8 @@ public class EipFragment extends Fragment implements Observer { greyscaleBackground(); locationButton.setLocationLoad(UNKNOWN); locationButton.showBridgeIndicator(false); - locationButton.setVisibility(INVISIBLE); + locationButton.setText(getString(R.string.gateway_selection_title)); + 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/GatewaySelectionFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java index 4a431dff..c98abd74 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/GatewaySelectionFragment.java @@ -29,6 +29,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatButton; import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatTextView; +import androidx.core.view.LayoutInflaterCompat; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -50,6 +51,7 @@ import se.leap.bitmaskclient.eip.EipCommand; import se.leap.bitmaskclient.eip.EipStatus; import se.leap.bitmaskclient.eip.GatewaysManager; +import static android.view.View.GONE; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4; @@ -199,6 +201,7 @@ public class GatewaySelectionFragment extends Fragment implements Observer, Loca public AppCompatTextView locationLabel; public LocationIndicator locationIndicator; public AppCompatImageView bridgeView; + public AppCompatImageView selectedView; public View layout; public ViewHolder(View v) { @@ -207,6 +210,7 @@ public class GatewaySelectionFragment extends Fragment implements Observer, Loca locationLabel = v.findViewById(R.id.location); locationIndicator = v.findViewById(R.id.quality); bridgeView = v.findViewById(R.id.bridge_image); + selectedView = v.findViewById(R.id.selected); } } @@ -249,11 +253,17 @@ public class GatewaySelectionFragment extends Fragment implements Observer, Loca Log.d(TAG, "view at position clicked: " + position); LocationListSelectionListener listener = callback.get(); if (listener != null) { + for (Location l : values) { + l.selected = false; + } + location.selected = !location.selected; + notifyDataSetChanged(); listener.onLocationSelected(location); } }); holder.locationIndicator.setLoad(GatewaysManager.Load.getLoadByValue(location.averageLoad)); - holder.bridgeView.setVisibility(location.supportedTransports.contains(OBFS4) ? VISIBLE : View.GONE); + holder.bridgeView.setVisibility(location.supportedTransports.contains(OBFS4) ? VISIBLE : GONE); + holder.selectedView.setVisibility(location.selected ? VISIBLE : INVISIBLE); } diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/Location.java b/app/src/main/java/se/leap/bitmaskclient/base/models/Location.java index 3ec7d38c..3eb82f22 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/models/Location.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/models/Location.java @@ -26,12 +26,14 @@ public class Location { @NonNull public HashSet<Connection.TransportType> supportedTransports; public double averageLoad; public int numberOfGateways; + public boolean selected; - public Location(@NonNull String name, double averageLoad, int numberOfGateways, @NonNull HashSet<Connection.TransportType> supportedTransports) { + public Location(@NonNull String name, double averageLoad, int numberOfGateways, @NonNull HashSet<Connection.TransportType> supportedTransports, boolean selected) { this.name = name; this.averageLoad = averageLoad; this.numberOfGateways = numberOfGateways; this.supportedTransports = supportedTransports; + this.selected = selected; } @Override diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/LocationButton.java b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationButton.java index 11ea198c..b2182d61 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/views/LocationButton.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationButton.java @@ -10,7 +10,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatTextView; -import androidx.appcompat.widget.LinearLayoutCompat; import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.eip.GatewaysManager; @@ -19,6 +18,7 @@ public class LocationButton extends RelativeLayout { private LocationIndicator locationIndicator; private AppCompatTextView textView; private AppCompatImageView bridgeView; + private AppCompatImageView recommendedView; public LocationButton(@NonNull Context context) { super(context); @@ -37,6 +37,7 @@ public class LocationButton extends RelativeLayout { locationIndicator = rootview.findViewById(R.id.load_indicator); textView = rootview.findViewById(R.id.text_location); bridgeView = rootview.findViewById(R.id.bridge_icn); + recommendedView = rootview.findViewById(R.id.recommended_icn); } public void setLocationLoad(GatewaysManager.Load load) { @@ -50,4 +51,8 @@ public class LocationButton extends RelativeLayout { public void showBridgeIndicator(boolean show) { bridgeView.setVisibility(show ? VISIBLE : GONE); } + + public void showRecommendedIndicator(boolean show) { + recommendedView.setVisibility(show? VISIBLE : GONE ); + } } diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java index dbb2a914..8e3e20df 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java @@ -43,6 +43,7 @@ import de.blinkt.openvpn.core.connection.Connection; import se.leap.bitmaskclient.base.models.Location; import se.leap.bitmaskclient.base.models.Provider; import se.leap.bitmaskclient.base.models.ProviderObservable; +import se.leap.bitmaskclient.base.utils.PreferenceHelper; import static de.blinkt.openvpn.core.connection.Connection.TransportType.OBFS4; import static de.blinkt.openvpn.core.connection.Connection.TransportType.OPENVPN; @@ -138,6 +139,7 @@ public class GatewaysManager { HashMap<String, Integer> locationNames = new HashMap<>(); ArrayList<Location> locations = new ArrayList<>(); ArrayList<Gateway> gateways = getSortedGateways(); + String preferredCity = PreferenceHelper.getPreferredCity(context); for (Gateway gateway : gateways) { String name = gateway.getName(); if (name == null) { @@ -145,19 +147,20 @@ public class GatewaysManager { continue; } - if (!locationNames.containsKey(gateway.getName())) { - locationNames.put(gateway.getName(), locations.size()); + if (!locationNames.containsKey(name)) { + locationNames.put(name, locations.size()); // fake values for now Random rand = new Random(); double averageLoad = rand.nextDouble(); //location.averageLoad; - Log.d(TAG, "getGatewayLocations - new averageLoad (" + gateway.getName() + " - " + gateway.getHost()+ "): " + averageLoad); + Log.d(TAG, "getGatewayLocations - new averageLoad (" + name + " - " + gateway.getHost()+ "): " + averageLoad); Location location = new Location( gateway.getName(), averageLoad /*gateway.getFullness()*/, 1, - gateway.getSupportedTransports() + gateway.getSupportedTransports(), + name.equals(preferredCity) ); locations.add(location); } else { diff --git a/app/src/main/res/color/button_color.xml b/app/src/main/res/color/button_state_font_color.xml index f7fed335..f7fed335 100644 --- a/app/src/main/res/color/button_color.xml +++ b/app/src/main/res/color/button_state_font_color.xml diff --git a/app/src/main/res/drawable-hdpi/ic_lightning_bolt.png b/app/src/main/res/drawable-hdpi/ic_lightning_bolt.png Binary files differnew file mode 100644 index 00000000..ade9565c --- /dev/null +++ b/app/src/main/res/drawable-hdpi/ic_lightning_bolt.png diff --git a/app/src/main/res/drawable-ldpi/ic_lightning_bolt.png b/app/src/main/res/drawable-ldpi/ic_lightning_bolt.png Binary files differnew file mode 100644 index 00000000..8209e93f --- /dev/null +++ b/app/src/main/res/drawable-ldpi/ic_lightning_bolt.png diff --git a/app/src/main/res/drawable-mdpi/ic_lightning_bolt.png b/app/src/main/res/drawable-mdpi/ic_lightning_bolt.png Binary files differnew file mode 100644 index 00000000..021cd490 --- /dev/null +++ b/app/src/main/res/drawable-mdpi/ic_lightning_bolt.png diff --git a/app/src/main/res/drawable-xhdpi/ic_lightning_bolt.png b/app/src/main/res/drawable-xhdpi/ic_lightning_bolt.png Binary files differnew file mode 100644 index 00000000..f1852f68 --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/ic_lightning_bolt.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_lightning_bolt.png b/app/src/main/res/drawable-xxhdpi/ic_lightning_bolt.png Binary files differnew file mode 100644 index 00000000..23914343 --- /dev/null +++ b/app/src/main/res/drawable-xxhdpi/ic_lightning_bolt.png diff --git a/app/src/main/res/drawable-xxxhdpi/ic_lightning_bolt.png b/app/src/main/res/drawable-xxxhdpi/ic_lightning_bolt.png Binary files differnew file mode 100644 index 00000000..53ed1873 --- /dev/null +++ b/app/src/main/res/drawable-xxxhdpi/ic_lightning_bolt.png diff --git a/app/src/main/res/drawable/cust_button_primary_rect.xml b/app/src/main/res/drawable/cust_button_primary_rect.xml index cb77b578..1587caf4 100644 --- a/app/src/main/res/drawable/cust_button_primary_rect.xml +++ b/app/src/main/res/drawable/cust_button_primary_rect.xml @@ -47,7 +47,7 @@ android:left="1dp" > <shape android:shape="rectangle" > - <corners android:radius="10dp" /> + <corners android:radius="@dimen/stdpadding" /> <solid android:color="@color/colorPrimary_transparent"/> </shape> </item> diff --git a/app/src/main/res/layout/f_gateway_selection.xml b/app/src/main/res/layout/f_gateway_selection.xml index 70a2bb1d..a5034182 100644 --- a/app/src/main/res/layout/f_gateway_selection.xml +++ b/app/src/main/res/layout/f_gateway_selection.xml @@ -74,9 +74,10 @@ <androidx.appcompat.widget.AppCompatButton android:id="@+id/automatic_gateway_selection_btn" - android:layout_width="match_parent" + android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/gateway_selection_recommended_location" + android:textColor="@color/button_state_font_color" /> </LinearLayout> diff --git a/app/src/main/res/layout/v_location_button.xml b/app/src/main/res/layout/v_location_button.xml index 6a7214c8..8cba9d70 100644 --- a/app/src/main/res/layout/v_location_button.xml +++ b/app/src/main/res/layout/v_location_button.xml @@ -18,6 +18,21 @@ android:src="@drawable/ic_web" android:layout_gravity="center" /> + <androidx.appcompat.widget.AppCompatImageView + android:id="@+id/recommended_icn" + android:scaleType="fitXY" + android:layout_marginRight="-13dp" + android:layout_marginEnd="-13dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignTop="@id/text_location" + android:layout_alignBottom="@+id/text_location" + android:layout_toEndOf="@id/world_icn" + android:layout_toRightOf="@id/world_icn" + android:src="@drawable/ic_lightning_bolt" + android:visibility="gone" + tools:visibility="visible" + /> <androidx.appcompat.widget.AppCompatTextView android:id="@+id/text_location" android:paddingStart="@dimen/stdpadding" @@ -28,8 +43,8 @@ android:ellipsize="end" android:layout_height="wrap_content" android:layout_width="wrap_content" - android:layout_toEndOf="@id/world_icn" - android:layout_toRightOf="@+id/world_icn" + android:layout_toEndOf="@id/recommended_icn" + android:layout_toRightOf="@+id/recommended_icn" android:layout_toLeftOf="@+id/bridge_icn" android:layout_toStartOf="@+id/bridge_icn" android:layout_gravity="center_vertical" diff --git a/app/src/main/res/layout/v_select_text_list_item.xml b/app/src/main/res/layout/v_select_text_list_item.xml index 663b5b4d..b0cfac34 100644 --- a/app/src/main/res/layout/v_select_text_list_item.xml +++ b/app/src/main/res/layout/v_select_text_list_item.xml @@ -1,26 +1,45 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" android:id="@+id/item_container" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:layout_width="match_parent" android:orientation="horizontal" - xmlns:tools="http://schemas.android.com/tools"> + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> <!-- views are composed right to left --> + <androidx.appcompat.widget.AppCompatImageView + android:id="@+id/selected" + android:layout_width="40dp" + android:layout_height="match_parent" + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" + android:src="@drawable/ic_check_bold" + android:tint="@color/green200" + android:visibility="invisible" + android:paddingTop="10dp" + android:paddingBottom="10dp" + android:paddingRight="10dp" + android:paddingEnd="10dp" + tools:visibility="visible" + /> <se.leap.bitmaskclient.base.views.LocationIndicator android:id="@+id/quality" - android:layout_width="56dp" + android:layout_width="30dp" android:layout_height="match_parent" - android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" + android:layout_toLeftOf="@id/selected" + android:layout_toStartOf="@id/selected" android:layout_margin="10dp" tools:visibility="visible" /> <androidx.appcompat.widget.AppCompatImageView android:id="@+id/bridge_image" - android:layout_width="56dp" + android:layout_width="wrap_content" android:layout_height="match_parent" + android:scaleType="fitXY" android:layout_toStartOf="@id/quality" android:layout_toLeftOf="@id/quality" android:src="@drawable/ic_bridge_36" diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index df08916b..9b05d3fe 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -65,7 +65,7 @@ <item name="android:background">@drawable/cust_button_primary</item> <item name="android:height">36dp</item> <item name="android:minWidth">75dp</item> - <item name="android:textColor">@color/button_color</item> + <item name="android:textColor">@color/colorFontBtn</item> </style> <style name="BitmaskActivity"> |