add spinner/status dedicated to 'new identity' task

This commit is contained in:
Dan Ballard 2017-09-04 20:58:50 -07:00
parent c68a45f088
commit 3da1cc5032
2 changed files with 63 additions and 33 deletions

View File

@ -2,7 +2,6 @@ package im.ricochet.androidod;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.StrictMode;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
@ -11,11 +10,6 @@ import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import goRicochetMobile.GoRicochetMobile;
public class ConnectActivity extends AppCompatActivity {
@ -26,8 +20,10 @@ public class ConnectActivity extends AppCompatActivity {
Button regenButton;
Button connectButton;
ProgressBar spinner;
TextView progressText;
ProgressBar connectSpinner;
ProgressBar regenIdentSpinner;
TextView connectStatusText;
TextView regenIdentStatusText;
TextView idetityText;
@ -40,11 +36,13 @@ public class ConnectActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(im.ricochet.androidod.R.layout.activity_connect);
progressText = (TextView)findViewById(R.id.progressTextView);
connectStatusText = (TextView)findViewById(R.id.connectStatusTextView);
regenIdentStatusText = (TextView)findViewById(R.id.regenIdentStatusText);
idetityText = (TextView)findViewById(R.id.identityTextView);
regenButton = (Button)findViewById(R.id.regenIdentButton);
connectButton = (Button)findViewById(R.id.connectButton);
spinner = (ProgressBar)findViewById(R.id.progressBar);
connectSpinner = (ProgressBar)findViewById(R.id.connectProgressBar);
regenIdentSpinner = (ProgressBar)findViewById(R.id.regenIdentProgressBar);
regenButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@ -68,7 +66,7 @@ public class ConnectActivity extends AppCompatActivity {
}
/*Log.i(TAG, "Ready!");
progressText.setText("Ready!");
connectStatusText.setText("Ready!");
ProgressBar progressBar = (ProgressBar)findViewById(im.ricochet.androidod.R.id.progressBar);
progressBar.setVisibility(View.GONE);
@ -95,8 +93,8 @@ public class ConnectActivity extends AppCompatActivity {
Log.i(TAG, "RegenIdentTask.onPreExecute()");
regenButton.setEnabled(false);
connectButton.setEnabled(false);
progressText.setText("Generating new identity...");
spinner.setVisibility(View.VISIBLE);
regenIdentStatusText.setText("Generating new identity...");
regenIdentSpinner.setVisibility(View.VISIBLE);
}
@Override
@ -120,13 +118,13 @@ public class ConnectActivity extends AppCompatActivity {
@Override
protected void onPostExecute(String privateKey) {
Log.i(TAG, "RegenIdentTask.onPostExecute(): " + privateKey);
spinner.setVisibility(View.INVISIBLE);
regenIdentSpinner.setVisibility(View.INVISIBLE);
regenButton.setEnabled(true);
connectButton.setEnabled(true);
if (privateKey == null) {
progressText.setText("ERROR: unable to generate new identity");
regenIdentStatusText.setText("ERROR: unable to generate new identity");
} else {
progressText.setText("");
regenIdentStatusText.setText("");
setIdentity(privateKey);
}
}

View File

@ -7,15 +7,16 @@
tools:context="im.ricochet.androidod.im.ricochet.androidod.ConnectActivity">
<ProgressBar
android:id="@+id/progressBar"
android:id="@+id/connectProgressBar"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginTop="7dp"
android:visibility="invisible"
app:layout_constraintLeft_toRightOf="@+id/connectButton"
app:layout_constraintTop_toBottomOf="@+id/addressText" />
app:layout_constraintTop_toBottomOf="@+id/addressText"
android:layout_marginStart="8dp" />
<EditText
android:id="@+id/addressText"
@ -30,13 +31,14 @@
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
app:layout_constraintTop_toBottomOf="@+id/textView"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="8dp"
android:text="Connect to Onion address:"
app:layout_constraintLeft_toLeftOf="@+id/addressText"
@ -48,15 +50,17 @@
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_marginTop="7dp"
android:enabled="false"
android:text="Connect"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/addressText" />
app:layout_constraintTop_toBottomOf="@+id/addressText"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<TextView
android:id="@+id/progressTextView"
android:id="@+id/connectStatusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
@ -64,7 +68,9 @@
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent" />
app:layout_constraintRight_toRightOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<TextView
android:id="@+id/textView2"
@ -77,7 +83,9 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.511"
android:layout_marginTop="24dp"
app:layout_constraintTop_toBottomOf="@+id/progressTextView" />
app:layout_constraintTop_toBottomOf="@+id/connectStatusTextView"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<TextView
android:id="@+id/textView3"
@ -89,7 +97,9 @@
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent" />
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<TextView
android:id="@+id/textView4"
@ -98,7 +108,6 @@
android:text="CookieAuthentication 0"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/textView3"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="@+id/textView3" />
<TextView
@ -106,7 +115,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DisableNetwork 0"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="@+id/textView4"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/textView4" />
@ -118,7 +126,6 @@
android:layout_marginTop="32dp"
android:text="Identity:"
app:layout_constraintTop_toBottomOf="@+id/textView5"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="@+id/regenIdentButton" />
<TextView
@ -129,7 +136,7 @@
app:layout_constraintLeft_toRightOf="@+id/textView6"
android:layout_marginLeft="8dp"
app:layout_constraintTop_toTopOf="@+id/textView6"
android:layout_marginTop="0dp" />
android:layout_marginStart="8dp" />
<Button
android:id="@+id/regenIdentButton"
@ -137,10 +144,35 @@
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_marginTop="7dp"
android:enabled="false"
android:text="New Identity"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
app:layout_constraintTop_toBottomOf="@+id/textView6"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" />
<ProgressBar
android:id="@+id/regenIdentProgressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="0dp"
android:visibility="invisible"
app:layout_constraintLeft_toRightOf="@+id/regenIdentButton"
app:layout_constraintTop_toTopOf="@+id/regenIdentButton" />
<TextView
android:id="@+id/regenIdentStatusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/regenIdentButton"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>