Wizard styling

This commit is contained in:
serso 2015-01-30 22:15:37 +01:00
parent 983d6eb2f9
commit 5a758e7acd
11 changed files with 59 additions and 37 deletions

View File

@ -80,14 +80,6 @@ public class ChooseModeWizardStep extends WizardFragment implements AdapterView.
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState);
setupNextButton(R.string.acl_wizard_next);
setupPrevButton(R.string.acl_wizard_back);
return view;
}
@Override
protected int getViewResId() {
return R.layout.cpp_wizard_step_choose_mode;

View File

@ -75,14 +75,6 @@ public class DragButtonWizardStep extends WizardFragment {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState);
setupNextButton(R.string.acl_wizard_next);
setupPrevButton(R.string.acl_wizard_back);
return view;
}
@Override
protected int getViewResId() {
return R.layout.cpp_wizard_step_drag_button;

View File

@ -3,17 +3,14 @@ package org.solovyev.android.calculator.wizard;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.preferences.PurchaseDialogActivity;
import static android.content.Intent.ACTION_VIEW;
public class FinalWizardStep extends Fragment {
public class FinalWizardStep extends WizardFragment {
private static final String GITHUB_URL = "https://github.com/serso/android-calculatorpp";
private static final String CROWDIN_URL = "http://crowdin.net/project/calculatorpp";
@ -23,8 +20,8 @@ public class FinalWizardStep extends Fragment {
private Button contributeButton;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.cpp_wizard_step_final, null);
protected int getViewResId() {
return R.layout.cpp_wizard_step_final;
}
@Override

View File

@ -23,9 +23,7 @@
package org.solovyev.android.calculator.wizard;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
@ -70,14 +68,6 @@ public class OnScreenCalculatorWizardStep extends WizardFragment {
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState);
setupNextButton(R.string.acl_wizard_next);
setupPrevButton(R.string.acl_wizard_back);
return view;
}
@Override
protected int getViewResId() {
return R.layout.cpp_wizard_step_onscreen;

View File

@ -38,8 +38,6 @@ public final class WelcomeWizardStep extends WizardFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState);
setupNextButton(R.string.wizard_start);
setupPrevButton(R.string.wizard_skip);
prevButton.setTextColor(getResources().getColor(R.color.cpp_wizard_disabled_text));
return view;
}

View File

@ -158,6 +158,14 @@ public class WizardActivity extends BaseActivity implements WizardsAware {
}
}
public WizardFlow getFlow() {
return wizardUi.getFlow();
}
public Wizard getWizard() {
return wizardUi.getWizard();
}
@Override
protected void onDestroy() {
dismissDialog();

View File

@ -8,7 +8,10 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.solovyev.android.calculator.R;
import org.solovyev.android.wizard.WizardFlow;
import org.solovyev.android.wizard.WizardStep;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class WizardFragment extends Fragment implements View.OnClickListener {
@ -19,6 +22,26 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
@Nullable
protected TextView prevButton;
private WizardStep step;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
step = findStepByClassName();
}
@Nonnull
private CalculatorWizardStep findStepByClassName() {
for (CalculatorWizardStep step : CalculatorWizardStep.values()) {
if(step.getFragmentClass().equals(getClass())) {
return step;
}
}
throw new AssertionError("Wizard step for class " + getClass() + " was not found");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_wizard, container, false);
@ -35,6 +58,25 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
prevButton.setOnClickListener(this);
}
final WizardFlow flow = getWizardActivity().getFlow();
final boolean canGoNext = flow.getNextStep(step) != null;
final boolean canGoPrev = flow.getPrevStep(step) != null;
if (canGoNext) {
if (canGoPrev) {
setupNextButton(R.string.acl_wizard_next);
} else {
setupNextButton(R.string.acl_wizard_start);
}
} else {
setupNextButton(R.string.acl_wizard_finish);
}
if (canGoPrev) {
setupPrevButton(R.string.acl_wizard_back);
} else {
setupPrevButton(R.string.wizard_skip);
}
return view;
}

View File

@ -45,6 +45,6 @@
a:id="@+id/wizard_mode_description"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
style="@style/WizardLabel"/>
style="@style/WizardLabel.Last"/>
</LinearLayout>

View File

@ -40,6 +40,6 @@
a:layout_height="wrap_content"
a:layout_width="wrap_content"
a:text="@string/cpp_wizard_onscreen_checkbox"
style="@style/WizardLabel" />
style="@style/WizardLabel.Last" />
</LinearLayout>

View File

@ -27,7 +27,7 @@
a:layout_height="match_parent">
<TextView
style="@style/WizardLabel"
style="@style/WizardLabel.Last"
a:drawableTop="@drawable/logo_wizard"
a:text="@string/c_first_start_text" />
</FrameLayout>

View File

@ -145,6 +145,9 @@
<item name="android:padding">1dp</item>
</style>
<style name="WizardLabel.Last" parent="WizardLabel">
<item name="android:layout_marginBottom">0dp</item>
</style>
<style name="WizardLabel">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>