diff --git a/src/com/twobigears/circlesynth/SynthSettingsTwo.java b/src/com/twobigears/circlesynth/SynthSettingsTwo.java index 5796fb0..cbc73aa 100644 --- a/src/com/twobigears/circlesynth/SynthSettingsTwo.java +++ b/src/com/twobigears/circlesynth/SynthSettingsTwo.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; +import android.app.Dialog; import android.content.Intent; import android.os.Bundle; import android.os.Environment; @@ -48,6 +49,10 @@ public class SynthSettingsTwo extends PreferenceActivity { public static final String PREF_DONATE = "donate"; public static final String PREF_DELREC = "deleterecordings"; + private AboutDialog about; + + private Dialog tutorial; + @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { @@ -154,7 +159,7 @@ public void deleteFiles(String path, String msg) { public void showTutorial() { //pass the context as a parameter, as the tutorial could be called either from //the main activity or from this - TutorialDialog.showTutorialDialog(SynthSettingsTwo.this); + tutorial = TutorialDialog.showTutorialDialog(SynthSettingsTwo.this); } @@ -184,9 +189,8 @@ public void setupDonate() { public void setupAbout() { - AboutDialog about = new AboutDialog(this); + about = new AboutDialog(this); about.setTitle("Circle Synth"); - about.show(); } @@ -196,7 +200,12 @@ public void setupAbout() { //as processing and libPd as a service doesn't play too well with the activity stack. @Override protected void onUserLeaveHint() { - + if (about != null) { + about.dismiss(); + } + if (tutorial != null) { + tutorial.dismiss(); + } super.onUserLeaveHint(); finish(); } diff --git a/src/com/twobigears/circlesynth/TutorialDialog.java b/src/com/twobigears/circlesynth/TutorialDialog.java index f813ec0..50706fe 100644 --- a/src/com/twobigears/circlesynth/TutorialDialog.java +++ b/src/com/twobigears/circlesynth/TutorialDialog.java @@ -17,6 +17,7 @@ package com.twobigears.circlesynth; +import android.app.Activity; import android.app.Dialog; import android.view.LayoutInflater; import android.view.View; @@ -27,7 +28,6 @@ import android.widget.Button; import android.widget.ImageButton; import android.widget.LinearLayout; -import com.twobigears.circlesynth.R; /* * Class creating the tutorial dialog. References images and text and puts it in the layout, @@ -35,17 +35,12 @@ */ public class TutorialDialog { + public static class Counter { public int count = 0; } - - //Two instances are mentioned here for two different contexts. Pretty sure this can be cleaned up - //later. - - - public static void showTutorialDialog(final SynthSettingsTwo context) { - + public static Dialog showTutorialDialog(final Activity context) { final Dialog alert = new Dialog(context); alert.requestWindowFeature(Window.FEATURE_NO_TITLE); final LayoutInflater inflater = context.getLayoutInflater(); @@ -120,87 +115,10 @@ public void onClick(View v) { } } }); - - alert.show(); - - } - - public static void showTutorialDialog(final SynthCircle context) { - - final Dialog alert = new Dialog(context); - alert.requestWindowFeature(Window.FEATURE_NO_TITLE); - final LayoutInflater inflater = context.getLayoutInflater(); - final LinearLayout tutorialFrame = (LinearLayout) inflater.inflate( - R.layout.demoframe, new LinearLayout(context), false); - final ViewGroup blanklayout = (ViewGroup) tutorialFrame - .findViewById(R.id.dynocontent); - final int[] slides = { R.layout.demoscreen0, R.layout.demoscreen1, - R.layout.demoscreen2, R.layout.demoscreen3, - R.layout.demoscreen4 }; - - final Counter c = new Counter(); - c.count = 0; - - inflater.inflate(slides[c.count], blanklayout); - - alert.setContentView(tutorialFrame); - - final ImageButton next = (ImageButton) tutorialFrame - .findViewById(R.id.next); - final ImageButton back = (ImageButton) tutorialFrame - .findViewById(R.id.back); - back.setOnClickListener(new Button.OnClickListener() { - public void onClick(View v) { - c.count -= 1; - blanklayout.removeAllViews(); - inflater.inflate(slides[c.count], blanklayout); - if (c.count == 0) { - back.setBackgroundResource(R.drawable.prevoff); - back.setEnabled(false); - } else { - back.setBackgroundResource(R.drawable.prevon); - back.setEnabled(true); - next.setBackgroundResource(R.drawable.nexton); - } - - } - }); - back.setEnabled(false); - - next.setOnClickListener(new Button.OnClickListener() { - public void onClick(View v) { - c.count += 1; - if (c.count == slides.length) { - alert.dismiss(); - } else { - WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); - lp.copyFrom(alert.getWindow().getAttributes()); - lp.width = alert.getWindow().getDecorView().getWidth(); - lp.height = LayoutParams.WRAP_CONTENT; - alert.getWindow().setAttributes(lp); - - blanklayout.setVisibility(View.INVISIBLE); - blanklayout.removeAllViews(); - inflater.inflate(slides[c.count], blanklayout); - blanklayout.setVisibility(View.VISIBLE); - if (c.count == slides.length - 1) { - next.setBackgroundResource(R.drawable.closeon); - back.setBackgroundResource(R.drawable.prevon); - back.setEnabled(true); - } else if (c.count == 0) { - back.setEnabled(false); - back.setBackgroundResource(R.drawable.prevoff); - next.setBackgroundResource(R.drawable.nexton); - } else { - next.setBackgroundResource(R.drawable.nexton); - back.setBackgroundResource(R.drawable.prevon); - back.setEnabled(true); - } - } - } - }); - + alert.show(); + + return alert; }