Setup wizard for new users
This commit is contained in:
@@ -36,6 +36,7 @@ import i2p.bote.I2PBote;
|
||||
import i2p.bote.android.addressbook.AddressBookActivity;
|
||||
import i2p.bote.android.config.SettingsActivity;
|
||||
import i2p.bote.android.intro.IntroActivity;
|
||||
import i2p.bote.android.intro.SetupActivity;
|
||||
import i2p.bote.android.service.BoteService;
|
||||
import i2p.bote.android.service.Init;
|
||||
import i2p.bote.android.service.Init.RouterChoice;
|
||||
@@ -66,8 +67,9 @@ public class EmailListActivity extends ActionBarActivity implements
|
||||
private static final String PREF_FIRST_START = "firstStart";
|
||||
private static final String ACTIVE_FOLDER = "activeFolder";
|
||||
|
||||
private static final int RUN_SETUP_WIZARD = 1;
|
||||
private static final int REQUEST_START_I2P = 2;
|
||||
private static final int SHOW_INTRODUCTION = 1;
|
||||
private static final int RUN_SETUP = 2;
|
||||
private static final int REQUEST_START_I2P = 3;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -217,7 +219,7 @@ public class EmailListActivity extends ActionBarActivity implements
|
||||
if (true || mSharedPrefs.getBoolean(PREF_FIRST_START, true)) {
|
||||
mSharedPrefs.edit().putBoolean(PREF_FIRST_START, false).apply();
|
||||
Intent i = new Intent(EmailListActivity.this, IntroActivity.class);
|
||||
startActivityForResult(i, RUN_SETUP_WIZARD);
|
||||
startActivityForResult(i, SHOW_INTRODUCTION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,10 +368,15 @@ public class EmailListActivity extends ActionBarActivity implements
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == RUN_SETUP_WIZARD) {
|
||||
if (requestCode == SHOW_INTRODUCTION) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
// TODO remove (and implement a UI tutorial?)
|
||||
Toast.makeText(this, "Setup wizard not yet implemented.", Toast.LENGTH_SHORT).show();
|
||||
Intent i = new Intent(EmailListActivity.this, SetupActivity.class);
|
||||
startActivityForResult(i, RUN_SETUP);
|
||||
}
|
||||
} else if (requestCode == RUN_SETUP) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
// TODO implement a UI tutorial?
|
||||
Toast.makeText(this, "Setup complete.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else if (requestCode == REQUEST_START_I2P) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
|
||||
@@ -31,6 +31,7 @@ public class EditIdentityActivity extends ActionBarActivity implements
|
||||
public void onTaskFinished() {
|
||||
Toast.makeText(this, R.string.identity_saved,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class SetPasswordActivity extends ActionBarActivity implements
|
||||
public void onTaskFinished() {
|
||||
Toast.makeText(this, R.string.password_changed,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
123
app/src/main/java/i2p/bote/android/intro/SetupActivity.java
Normal file
123
app/src/main/java/i2p/bote/android/intro/SetupActivity.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package i2p.bote.android.intro;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import i2p.bote.android.R;
|
||||
import i2p.bote.android.config.EditIdentityActivity;
|
||||
import i2p.bote.android.config.SetPasswordActivity;
|
||||
|
||||
public class SetupActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_setup);
|
||||
if (savedInstanceState == null) {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.container, new SetPasswordFragment())
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set password.
|
||||
*/
|
||||
public static class SetPasswordFragment extends Fragment {
|
||||
private static final int SET_PASSWORD = 1;
|
||||
|
||||
public SetPasswordFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_setup_set_password, container, false);
|
||||
((Button)rootView.findViewById(R.id.button_set_password)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(getActivity(), SetPasswordActivity.class);
|
||||
startActivityForResult(i, SET_PASSWORD);
|
||||
}
|
||||
});
|
||||
((Button)rootView.findViewById(R.id.button_skip)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
nextPage();
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == SET_PASSWORD) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
nextPage();
|
||||
}
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(R.id.container, new CreateIdentityFragment())
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create identity.
|
||||
*/
|
||||
public static class CreateIdentityFragment extends Fragment {
|
||||
private static final int CREATE_IDENTITY = 1;
|
||||
|
||||
public CreateIdentityFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_setup_create_identity, container, false);
|
||||
((Button)rootView.findViewById(R.id.button_set_password)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(getActivity(), EditIdentityActivity.class);
|
||||
startActivityForResult(i, CREATE_IDENTITY);
|
||||
}
|
||||
});
|
||||
((Button)rootView.findViewById(R.id.button_skip)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
nextPage();
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == CREATE_IDENTITY) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
nextPage();
|
||||
}
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
// TODO have a "finished" page?
|
||||
getActivity().setResult(RESULT_OK);
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user