Skip to content

Commit

Permalink
Merge pull request #45 from d3kod/master
Browse files Browse the repository at this point in the history
Fix issues #24 #41 #43
  • Loading branch information
re-sounding committed Nov 23, 2013
2 parents 5e0b3dd + abdde38 commit 03381cd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 93 deletions.
17 changes: 16 additions & 1 deletion src/com/twobigears/circlesynth/SynthCircle.java
Expand Up @@ -1110,7 +1110,7 @@ public void updateCircles(float mX, float mY) {

double dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY);

if (dist < outerCircSize / 2) {
if (dist < outerCircSize) {
xDown = mX;
yDown = mY;
if (hasLine) {
Expand Down Expand Up @@ -1143,6 +1143,8 @@ public void updateCircles(float mX, float mY) {
int checkdelete;
int fxcheckdelete;

private static float mSavedPlayState = 0;

/**
* This is where the magic happens. All touch events are sent here, and then
* worked on accordingly.
Expand Down Expand Up @@ -1335,8 +1337,21 @@ public void bpmChanged(int t) {
PdBase.sendFloat("pd_bpm", bpm);
}

@Override
protected void onPause() {
PdBase.sendFloat("pd_playToggle", 0);
if (toolbar.playToggleB.isEnabled) {
mSavedPlayState = 1;
}
else {
mSavedPlayState = 0;
}
super.onPause();
}

@Override
protected void onResume() {
PdBase.sendFloat("pd_playToggle", mSavedPlayState);
super.onResume();
}

Expand Down
17 changes: 13 additions & 4 deletions src/com/twobigears/circlesynth/SynthSettingsTwo.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

}

Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}
Expand Down
94 changes: 6 additions & 88 deletions src/com/twobigears/circlesynth/TutorialDialog.java
Expand Up @@ -17,6 +17,7 @@

package com.twobigears.circlesynth;

import android.app.Activity;
import android.app.Dialog;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -27,25 +28,19 @@
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,
* along with next/previous buttons to advance in the tutorial.
*/

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();
Expand Down Expand Up @@ -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;

}

Expand Down

0 comments on commit 03381cd

Please sign in to comment.