wizard finished
This commit is contained in:
@@ -28,6 +28,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.solovyev.android.calculator.wizard.WizardStep.last;
|
||||
import static org.solovyev.android.calculator.wizard.Wizards.DEFAULT_WIZARD_FLOW;
|
||||
import static org.solovyev.android.calculator.wizard.Wizards.FIRST_TIME_WIZARD;
|
||||
import static org.solovyev.android.calculator.wizard.WizardStep.welcome;
|
||||
@@ -50,7 +51,7 @@ final class AppWizardFlow implements WizardFlow {
|
||||
static AppWizardFlow newDefaultWizardFlow() {
|
||||
final List<WizardStep> wizardSteps = new ArrayList<WizardStep>();
|
||||
for (WizardStep wizardStep : WizardStep.values()) {
|
||||
if (wizardStep != welcome && wizardStep.isVisible()) {
|
||||
if (wizardStep != welcome && wizardStep != last && wizardStep.isVisible()) {
|
||||
wizardSteps.add(wizardStep);
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import org.solovyev.android.calculator.R;
|
||||
|
||||
@@ -67,8 +68,7 @@ public final class CalculatorWizardActivity extends FragmentActivity {
|
||||
*/
|
||||
|
||||
private View prevButton;
|
||||
private View nextButton;
|
||||
private View finishButton;
|
||||
private Button nextButton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -77,8 +77,7 @@ public final class CalculatorWizardActivity extends FragmentActivity {
|
||||
setContentView(R.layout.cpp_wizard);
|
||||
|
||||
prevButton = findViewById(R.id.wizard_prev_button);
|
||||
nextButton = findViewById(R.id.wizard_next_button);
|
||||
finishButton = findViewById(R.id.wizard_finish_button);
|
||||
nextButton = (Button) findViewById(R.id.wizard_next_button);
|
||||
|
||||
String wizardName = getIntent().getStringExtra(FLOW);
|
||||
String stepName = getIntent().getStringExtra(STEP);
|
||||
@@ -109,29 +108,10 @@ public final class CalculatorWizardActivity extends FragmentActivity {
|
||||
|
||||
initTitle();
|
||||
initNextButton();
|
||||
initFinishButton();
|
||||
initPrevButton();
|
||||
}
|
||||
}
|
||||
|
||||
private void initFinishButton() {
|
||||
final WizardStep nextStep = flow.getNextStep(step);
|
||||
if (nextStep == null) {
|
||||
finishButton.setVisibility(VISIBLE);
|
||||
finishButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (tryGoNext()) {
|
||||
finishFlow();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
finishButton.setVisibility(GONE);
|
||||
finishButton.setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void initTitle() {
|
||||
setTitle(step.getTitleResId());
|
||||
}
|
||||
@@ -157,10 +137,17 @@ public final class CalculatorWizardActivity extends FragmentActivity {
|
||||
private void initNextButton() {
|
||||
final WizardStep nextStep = flow.getNextStep(step);
|
||||
if (nextStep == null) {
|
||||
nextButton.setVisibility(GONE);
|
||||
nextButton.setOnClickListener(null);
|
||||
nextButton.setText(R.string.cpp_wizard_finish);
|
||||
nextButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (tryGoNext()) {
|
||||
finishFlow();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
nextButton.setVisibility(VISIBLE);
|
||||
nextButton.setText(step.getNextButtonTitleResId());
|
||||
nextButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -284,10 +271,6 @@ public final class CalculatorWizardActivity extends FragmentActivity {
|
||||
return nextButton;
|
||||
}
|
||||
|
||||
View getFinishButton() {
|
||||
return finishButton;
|
||||
}
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
|
@@ -0,0 +1,69 @@
|
||||
package org.solovyev.android.calculator.wizard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import net.robotmedia.billing.BillingController;
|
||||
|
||||
import org.solovyev.android.ads.AdsController;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.preferences.CalculatorPurchaseDialogActivity;
|
||||
|
||||
import static android.content.Intent.ACTION_VIEW;
|
||||
|
||||
public class FinalWizardStep extends Fragment {
|
||||
|
||||
private static final String GITHUB_URL = "https://github.com/serso/android-calculatorpp";
|
||||
private static final String CROWDIN_URL = "http://crowdin.net/project/calculatorpp";
|
||||
|
||||
private Button donateButton;
|
||||
private Button translateButton;
|
||||
private Button contributeButton;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.cpp_wizard_step_final, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
donateButton = (Button) root.findViewById(R.id.cpp_wizard_final_donate_button);
|
||||
donateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getActivity(), CalculatorPurchaseDialogActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
translateButton = (Button) root.findViewById(R.id.cpp_wizard_final_translate_button);
|
||||
translateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showUrl(CROWDIN_URL);
|
||||
}
|
||||
});
|
||||
|
||||
contributeButton = (Button) root.findViewById(R.id.cpp_wizard_final_contribute_button);
|
||||
contributeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showUrl(GITHUB_URL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showUrl(String url) {
|
||||
startActivity(new Intent(ACTION_VIEW, Uri.parse(url)));
|
||||
}
|
||||
}
|
@@ -48,23 +48,7 @@ import static org.solovyev.android.calculator.wizard.OnScreenCalculatorWizardSte
|
||||
*/
|
||||
enum WizardStep {
|
||||
|
||||
welcome(WelcomeWizardStep.class, R.string.cpp_wizard_welcome_title) {
|
||||
@Override
|
||||
boolean onNext(@Nonnull Fragment fragment) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean onPrev(@Nonnull Fragment fragment) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
Bundle getFragmentArgs() {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
welcome(WelcomeWizardStep.class, R.string.cpp_wizard_welcome_title, R.string.cpp_wizard_start),
|
||||
|
||||
choose_layout(ChooseLayoutWizardStep.class, R.string.cpp_wizard_layout_title) {
|
||||
@Override
|
||||
@@ -79,11 +63,6 @@ enum WizardStep {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean onPrev(@Nonnull Fragment fragment) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
Bundle getFragmentArgs() {
|
||||
@@ -113,11 +92,6 @@ enum WizardStep {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean onPrev(@Nonnull Fragment fragment) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
Bundle getFragmentArgs() {
|
||||
@@ -141,11 +115,6 @@ enum WizardStep {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean onPrev(@Nonnull Fragment fragment) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
Bundle getFragmentArgs() {
|
||||
@@ -157,32 +126,25 @@ enum WizardStep {
|
||||
}
|
||||
},
|
||||
|
||||
drag_button_step(DragButtonWizardStep.class, R.string.cpp_wizard_dragbutton_title) {
|
||||
@Override
|
||||
boolean onNext(@Nonnull Fragment fragment) {
|
||||
return true;
|
||||
}
|
||||
drag_button(DragButtonWizardStep.class, R.string.cpp_wizard_dragbutton_title),
|
||||
|
||||
@Override
|
||||
boolean onPrev(@Nonnull Fragment fragment) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
Bundle getFragmentArgs() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
last(FinalWizardStep.class, R.string.cpp_wizard_final_title);
|
||||
|
||||
@Nonnull
|
||||
private final Class<? extends Fragment> fragmentClass;
|
||||
|
||||
private final int titleResId;
|
||||
private final int nextButtonTitleResId;
|
||||
|
||||
|
||||
|
||||
WizardStep(@Nonnull Class<? extends Fragment> fragmentClass, int titleResId) {
|
||||
this(fragmentClass, titleResId, R.string.cpp_wizard_next);
|
||||
}
|
||||
WizardStep(@Nonnull Class<? extends Fragment> fragmentClass, int titleResId, int nextButtonTitleResId) {
|
||||
this.fragmentClass = fragmentClass;
|
||||
this.titleResId = titleResId;
|
||||
this.nextButtonTitleResId = nextButtonTitleResId;
|
||||
}
|
||||
|
||||
public String getFragmentTag() {
|
||||
@@ -198,12 +160,22 @@ enum WizardStep {
|
||||
return titleResId;
|
||||
}
|
||||
|
||||
abstract boolean onNext(@Nonnull Fragment fragment);
|
||||
int getNextButtonTitleResId() {
|
||||
return nextButtonTitleResId;
|
||||
}
|
||||
|
||||
abstract boolean onPrev(@Nonnull Fragment fragment);
|
||||
boolean onNext(@Nonnull Fragment fragment) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean onPrev(@Nonnull Fragment fragment) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
abstract Bundle getFragmentArgs();
|
||||
Bundle getFragmentArgs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user