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

View File

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