summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2021-06-24 23:15:41 +0200
committercyBerta <cyberta@riseup.net>2021-07-21 22:02:24 +0200
commit236c17ec3f4348a9f0d4ec4a2454b9fbfaf8707f (patch)
treeaa6259310a625e6e58aa16a661ca25fc4bb34d7f /app
parentfca60f51acf8eea48fc4086db00cba1097d097b7 (diff)
show tor status info in provider setup activies
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ConfigWizardBaseActivity.java35
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/activities/LoginActivity.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SignupActivity.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/tor/TorNotificationManager.java7
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/tor/TorStatusObservable.java2
-rw-r--r--app/src/main/res/layout-xlarge/v_loading_screen.xml22
-rw-r--r--app/src/main/res/layout/v_add_provider.xml20
-rw-r--r--app/src/main/res/layout/v_loading_screen.xml22
8 files changed, 94 insertions, 18 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ConfigWizardBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ConfigWizardBaseActivity.java
index b2f13e07..7d452200 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ConfigWizardBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ConfigWizardBaseActivity.java
@@ -19,11 +19,14 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Guideline;
import androidx.core.content.ContextCompat;
+import java.util.Observable;
+import java.util.Observer;
+
import butterknife.BindView;
-import butterknife.Optional;
import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.base.models.Provider;
import se.leap.bitmaskclient.base.views.ProviderHeaderView;
+import se.leap.bitmaskclient.tor.TorStatusObservable;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.view.View.GONE;
@@ -37,7 +40,7 @@ import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
* Created by fupduck on 09.01.18.
*/
-public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity {
+public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity implements Observer {
private static final String TAG = ConfigWizardBaseActivity.class.getName();
public static final float GUIDE_LINE_COMPACT_DELTA = 0.1f;
@@ -56,8 +59,12 @@ public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity {
protected ProgressBar progressBar;
@Nullable
+ @BindView(R.id.progressbar_title)
+ protected AppCompatTextView progressbarTitle;
+
+ @Nullable
@BindView(R.id.progressbar_description)
- protected AppCompatTextView progressbarText;
+ protected AppCompatTextView progressbarDescription;
//Only tablet layouts have guidelines as they are based on a ConstraintLayout
@Nullable
@@ -142,12 +149,15 @@ public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity {
protected void onPause() {
super.onPause();
isActivityShowing = false;
+ TorStatusObservable.getInstance().deleteObserver(this);
}
@Override
protected void onResume() {
super.onResume();
isActivityShowing = true;
+ TorStatusObservable.getInstance().addObserver(this);
+ setProgressbarDescription(TorStatusObservable.getStringForCurrentStatus(this));
}
protected void restoreState(Bundle savedInstanceState) {
@@ -184,11 +194,18 @@ public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity {
loadingScreen.setVisibility(VISIBLE);
}
- protected void setProgressbarText(@StringRes int progressbarText) {
- if (this.progressbarText == null) {
+ protected void setProgressbarTitle(@StringRes int progressbarTitle) {
+ if (this.progressbarTitle == null) {
+ return;
+ }
+ this.progressbarTitle.setText(progressbarTitle);
+ }
+
+ protected void setProgressbarDescription(String progressbarDescription) {
+ if (this.progressbarDescription == null) {
return;
}
- this.progressbarText.setText(progressbarText);
+ this.progressbarDescription.setText(progressbarDescription);
}
@@ -287,4 +304,10 @@ public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity {
});
}
+ @Override
+ public void update(Observable o, Object arg) {
+ if (o instanceof TorStatusObservable) {
+ runOnUiThread(() -> setProgressbarDescription(TorStatusObservable.getStringForCurrentStatus(ConfigWizardBaseActivity.this)));
+ }
+ }
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/LoginActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/LoginActivity.java
index a8bac6d8..9a5f31f2 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/LoginActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/LoginActivity.java
@@ -17,7 +17,7 @@ public class LoginActivity extends ProviderCredentialsBaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setProgressbarText(R.string.logging_in);
+ setProgressbarTitle(R.string.logging_in);
setProviderHeaderLogo(R.drawable.logo);
setProviderHeaderText(R.string.login_to_profile);
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SignupActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SignupActivity.java
index c0245845..16007a70 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SignupActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SignupActivity.java
@@ -37,7 +37,7 @@ public class SignupActivity extends ProviderCredentialsBaseActivity {
setProviderHeaderLogo(R.drawable.logo);
setProviderHeaderText(R.string.create_profile);
- setProgressbarText(R.string.signing_up);
+ setProgressbarTitle(R.string.signing_up);
setButtonText(R.string.signup_button);
passwordVerificationField.setVisibility(VISIBLE);
diff --git a/app/src/main/java/se/leap/bitmaskclient/tor/TorNotificationManager.java b/app/src/main/java/se/leap/bitmaskclient/tor/TorNotificationManager.java
index 4acc2b7e..71b5c378 100644
--- a/app/src/main/java/se/leap/bitmaskclient/tor/TorNotificationManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/tor/TorNotificationManager.java
@@ -27,6 +27,8 @@ import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import se.leap.bitmaskclient.R;
+import se.leap.bitmaskclient.base.models.Provider;
+import se.leap.bitmaskclient.base.models.ProviderObservable;
public class TorNotificationManager {
public final static int TOR_SERVICE_NOTIFICATION_ID = 10;
@@ -45,7 +47,7 @@ public class TorNotificationManager {
return notificationBuilder
.setSmallIcon(R.drawable.ic_bridge_36)
.setWhen(System.currentTimeMillis())
- .setContentTitle(context.getString(R.string.tor_provider_setup)).build();
+ .setContentTitle(context.getString(R.string.tor_started)).build();
}
public void buildTorNotification(Context context, String state) {
@@ -58,8 +60,7 @@ public class TorNotificationManager {
.setSmallIcon(R.drawable.ic_bridge_36)
.setWhen(System.currentTimeMillis())
.setTicker(state)
- .setContentTitle(context.getString(R.string.tor_provider_setup))
- .setContentText(state);
+ .setContentTitle(state);
notificationManager.notify(TOR_SERVICE_NOTIFICATION_ID, notificationBuilder.build());
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/tor/TorStatusObservable.java b/app/src/main/java/se/leap/bitmaskclient/tor/TorStatusObservable.java
index ed4ae24b..e806e441 100644
--- a/app/src/main/java/se/leap/bitmaskclient/tor/TorStatusObservable.java
+++ b/app/src/main/java/se/leap/bitmaskclient/tor/TorStatusObservable.java
@@ -85,7 +85,7 @@ public class TorStatusObservable extends Observable {
return lastError;
}
- private static String getStringForCurrentStatus(Context context) {
+ public static String getStringForCurrentStatus(Context context) {
switch (getInstance().status) {
case ON:
return context.getString(R.string.tor_started);
diff --git a/app/src/main/res/layout-xlarge/v_loading_screen.xml b/app/src/main/res/layout-xlarge/v_loading_screen.xml
index a002665f..adcbfabc 100644
--- a/app/src/main/res/layout-xlarge/v_loading_screen.xml
+++ b/app/src/main/res/layout-xlarge/v_loading_screen.xml
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loading_screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:visibility="gone">
+ android:visibility="gone"
+ tools:visibility="visible"
+ >
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="32dp"
@@ -18,7 +21,7 @@
/>
<androidx.appcompat.widget.AppCompatTextView
- android:id="@+id/progressbar_description"
+ android:id="@+id/progressbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fadingEdge="horizontal"
@@ -29,6 +32,21 @@
android:layout_marginBottom="@dimen/standard_margin"
/>
+ <androidx.appcompat.widget.AppCompatTextView
+ android:id="@+id/progressbar_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fadingEdge="horizontal"
+ android:singleLine="true"
+ android:text="@string/configuring_provider"
+ android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
+ android:layout_marginTop="@dimen/standard_margin"
+ android:layout_marginBottom="@dimen/standard_margin"
+ tools:text="test"
+ tools:visibility="visible"
+
+ />
+
<ProgressBar
android:id="@+id/progressbar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
diff --git a/app/src/main/res/layout/v_add_provider.xml b/app/src/main/res/layout/v_add_provider.xml
index afcae4af..1448e7e7 100644
--- a/app/src/main/res/layout/v_add_provider.xml
+++ b/app/src/main/res/layout/v_add_provider.xml
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loading_screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:visibility="gone">
+ android:visibility="gone"
+ tools:visibility="visible">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
@@ -18,7 +20,7 @@
/>
<androidx.appcompat.widget.AppCompatTextView
- android:id="@+id/progressbar_description"
+ android:id="@+id/progressbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fadingEdge="horizontal"
@@ -29,6 +31,20 @@
android:layout_marginBottom="@dimen/standard_margin"
/>
+ <androidx.appcompat.widget.AppCompatTextView
+ android:id="@+id/progressbar_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fadingEdge="horizontal"
+ android:singleLine="true"
+ android:text="@string/configuring_provider"
+ android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
+ android:layout_marginTop="@dimen/standard_margin"
+ android:layout_marginBottom="@dimen/standard_margin"
+ tools:text="test"
+ tools:visibility="visible"
+ />
+
<ProgressBar
android:id="@+id/progressbar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
diff --git a/app/src/main/res/layout/v_loading_screen.xml b/app/src/main/res/layout/v_loading_screen.xml
index a3498e97..9bda063d 100644
--- a/app/src/main/res/layout/v_loading_screen.xml
+++ b/app/src/main/res/layout/v_loading_screen.xml
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loading_screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:visibility="gone">
+ android:visibility="gone"
+ tools:visibility="visible"
+ >
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
@@ -18,7 +21,7 @@
/>
<androidx.appcompat.widget.AppCompatTextView
- android:id="@+id/progressbar_description"
+ android:id="@+id/progressbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fadingEdge="horizontal"
@@ -27,6 +30,21 @@
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:layout_marginTop="@dimen/standard_margin"
android:layout_marginBottom="@dimen/standard_margin"
+ tools:text="title"
+ />
+
+ <androidx.appcompat.widget.AppCompatTextView
+ android:id="@+id/progressbar_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fadingEdge="horizontal"
+ android:singleLine="true"
+ android:text="@string/configuring_provider"
+ android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
+ android:layout_marginTop="@dimen/standard_margin"
+ android:layout_marginBottom="@dimen/standard_margin"
+ tools:text="test"
+ tools:visibility="visible"
/>
<ProgressBar