mock out rest of connect activity, start writing regen ident code
This commit is contained in:
parent
03e0ea6bb4
commit
767fccef40
|
@ -7,6 +7,7 @@ import android.support.v7.app.AppCompatActivity;
|
|||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -25,30 +26,26 @@ public class ConnectActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// Load identity and connect to addr. Enable appropriate buttons
|
||||
// If no identity, generate.
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(im.ricochet.androidod.R.layout.activity_connect);
|
||||
|
||||
TextView progressText = (TextView)findViewById(im.ricochet.androidod.R.id.progressTextView);
|
||||
progressText.setText("Loading private key...");
|
||||
//progressText.setText("Loading private key...");
|
||||
|
||||
Log.i(TAG, "Loading private key...");
|
||||
SharedPreferences prefs = getSharedPreferences(PREFERNCE_FILE, MODE_PRIVATE);
|
||||
String privateKey = prefs.getString(PRIVATE_KEY_KEY, "");
|
||||
Log.i(TAG, "Loaded! '" + privateKey + "'");
|
||||
if (privateKey.equals("")) {
|
||||
Log.i(TAG, "Failed to load private key from preferences, generating new");
|
||||
progressText.setText("Generating private key...");
|
||||
try {
|
||||
privateKey = GoRicochetMobile.generatePrivateKey();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.toString());
|
||||
// Kick of identity generateion
|
||||
regenIdentity();
|
||||
} else {
|
||||
Button regenButton = (Button)findViewById(R.id.regenIdentButton);
|
||||
regenButton.setEnabled(true);
|
||||
}
|
||||
Log.i(TAG, "Generated!: '" + privateKey + "'");
|
||||
SharedPreferences.Editor prefsEditor = prefs.edit();
|
||||
prefsEditor.putString(PRIVATE_KEY_KEY, privateKey);
|
||||
prefsEditor.commit();
|
||||
}
|
||||
Log.i(TAG, "Ready!");
|
||||
|
||||
/*Log.i(TAG, "Ready!");
|
||||
progressText.setText("Ready!");
|
||||
ProgressBar progressBar = (ProgressBar)findViewById(im.ricochet.androidod.R.id.progressBar);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
@ -60,7 +57,33 @@ public class ConnectActivity extends AppCompatActivity {
|
|||
Log.i(TAG, "Starting Echo Bot");
|
||||
//GoRicochetMobile.echoBot(privateKey);
|
||||
new EchoBot(privateKey).execute();
|
||||
*/
|
||||
}
|
||||
|
||||
private void regenIdentity() {
|
||||
Button regenButton = (Button)findViewById(R.id.regenIdentButton);
|
||||
regenButton.setEnabled(false);
|
||||
TextView progressText = (TextView)findViewById(im.ricochet.androidod.R.id.progressTextView);
|
||||
progressText.setText("Generating new identity...");
|
||||
ProgressBar spinner = (ProgressBar)findViewById(R.id.progressBar);
|
||||
spinner.setVisibility(View.VISIBLE);
|
||||
|
||||
String privateKey;
|
||||
try {
|
||||
privateKey = GoRicochetMobile.generatePrivateKey();
|
||||
|
||||
SharedPreferences prefs = getSharedPreferences(PREFERNCE_FILE, MODE_PRIVATE);
|
||||
SharedPreferences.Editor prefsEditor = prefs.edit();
|
||||
prefsEditor.putString(PRIVATE_KEY_KEY, privateKey);
|
||||
prefsEditor.commit();
|
||||
progressText.setText("");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.toString());
|
||||
progressText.setText("ERROR: unable to generate new identity: " + e.toString());
|
||||
}
|
||||
|
||||
spinner.setVisibility(View.INVISIBLE);
|
||||
regenButton.setEnabled(true);
|
||||
}
|
||||
|
||||
private class EchoBot extends AsyncTask<Void, Void, Void> {
|
||||
|
|
|
@ -11,12 +11,10 @@
|
|||
style="@style/Widget.AppCompat.ProgressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toRightOf="@+id/connect"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="32dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/connect" />
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/addressText" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/addressText"
|
||||
|
@ -37,11 +35,11 @@
|
|||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Onion Address:"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="0dp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/addressText" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Connect to Onion address:"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/addressText"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/connect"
|
||||
|
@ -50,6 +48,7 @@
|
|||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:enabled="false"
|
||||
android:text="Connect"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
|
@ -59,12 +58,9 @@
|
|||
android:id="@+id/progressTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
tools:layout_editor_absoluteX="195dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/progressBar" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/connect" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
|
@ -72,10 +68,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="Required step: Orbot/Settings/Torrc Custom Config:"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.511"
|
||||
android:layout_marginTop="24dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/progressTextView" />
|
||||
|
||||
<TextView
|
||||
|
@ -99,4 +96,47 @@
|
|||
app:layout_constraintTop_toBottomOf="@+id/textView3"
|
||||
android:layout_marginLeft="0dp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/textView3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="Identity:"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView5"
|
||||
android:layout_marginLeft="0dp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/regenIdentButton" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/identityTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ricochet:"
|
||||
app:layout_constraintLeft_toRightOf="@+id/textView6"
|
||||
android:layout_marginLeft="8dp"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView6"
|
||||
android:layout_marginTop="0dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/regenIdentButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:enabled="false"
|
||||
android:text="Regenerate Identity"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView6" />
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
|
Loading…
Reference in New Issue