Skip to content

Commit 72829ed

Browse files
author
antonxy
committed
New Layout
1 parent 770bdc1 commit 72829ed

10 files changed

Lines changed: 196 additions & 109 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
audiosync_androidapp
22
====================
3+
This app generates sync patterns for [audiosync](https://github.com/antonxy/audiosync)

libs/android-support-v4.jar

-377 KB
Binary file not shown.

res/layout/activity_main.xml

Lines changed: 25 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,37 @@
1-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools"
1+
<!-- </android.support.v7.widget.GridLayout> -->
2+
3+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
34
android:layout_width="match_parent"
45
android:layout_height="match_parent"
5-
android:paddingBottom="@dimen/activity_vertical_margin"
6-
android:paddingLeft="@dimen/activity_horizontal_margin"
7-
android:paddingRight="@dimen/activity_horizontal_margin"
8-
android:paddingTop="@dimen/activity_vertical_margin"
9-
tools:context=".MainActivity" >
10-
11-
<EditText
12-
android:id="@+id/sceneInp"
13-
android:layout_width="wrap_content"
14-
android:layout_height="wrap_content"
15-
android:layout_alignParentLeft="true"
16-
android:layout_centerVertical="true"
17-
android:ems="@integer/scene_text_lenght"
18-
android:inputType="number"
19-
android:text="@string/scene_default_value"
20-
android:textSize="@dimen/scene_text_size" >
21-
22-
<requestFocus />
23-
</EditText>
24-
25-
<TextView
26-
android:id="@+id/textView1"
27-
android:layout_width="wrap_content"
28-
android:layout_height="wrap_content"
29-
android:layout_centerVertical="true"
30-
android:layout_toRightOf="@+id/sceneInp"
31-
android:text="@string/scene_delim"
32-
android:textSize="@dimen/scene_text_size" />
33-
34-
<EditText
35-
android:id="@+id/shotInp"
36-
android:layout_width="wrap_content"
37-
android:layout_height="wrap_content"
38-
android:layout_centerVertical="true"
39-
android:layout_toRightOf="@+id/textView1"
40-
android:ems="@integer/scene_text_lenght"
41-
android:inputType="number"
42-
android:text="@string/scene_default_value"
43-
android:textSize="@dimen/scene_text_size" />
6+
android:orientation="horizontal" >
447

45-
<TextView
46-
android:id="@+id/TextView01"
8+
<org.audiosync.NumberChooser
9+
android:id="@+id/sceneChooser"
4710
android:layout_width="wrap_content"
48-
android:layout_height="wrap_content"
49-
android:layout_centerVertical="true"
50-
android:layout_toRightOf="@+id/shotInp"
51-
android:text="@string/scene_delim"
52-
android:textSize="@dimen/scene_text_size" />
11+
android:layout_height="fill_parent"
12+
android:layout_weight="1" >
13+
</org.audiosync.NumberChooser>
5314

54-
<EditText
55-
android:id="@+id/takeInp"
15+
<org.audiosync.NumberChooser
16+
android:id="@+id/shotChooser"
5617
android:layout_width="wrap_content"
57-
android:layout_height="wrap_content"
58-
android:layout_centerVertical="true"
59-
android:layout_toRightOf="@+id/TextView01"
60-
android:ems="@integer/scene_text_lenght"
61-
android:inputType="number"
62-
android:text="@string/scene_default_value"
63-
android:textSize="@dimen/scene_text_size" />
18+
android:layout_height="fill_parent"
19+
android:layout_weight="1" >
20+
</org.audiosync.NumberChooser>
6421

65-
<Button
66-
android:id="@+id/nextButton"
22+
<org.audiosync.NumberChooser
23+
android:id="@+id/takeChooser"
6724
android:layout_width="wrap_content"
68-
android:layout_height="wrap_content"
69-
android:layout_alignLeft="@+id/sceneInp"
70-
android:layout_alignParentTop="true"
71-
android:layout_alignRight="@+id/takeInp"
72-
android:text="@string/next_take" />
25+
android:layout_height="fill_parent"
26+
android:layout_weight="1" >
27+
</org.audiosync.NumberChooser>
7328

7429
<Button
7530
android:id="@+id/goButton"
7631
android:layout_width="wrap_content"
77-
android:layout_height="wrap_content"
78-
android:layout_alignParentBottom="true"
79-
android:layout_alignParentRight="true"
80-
android:layout_alignTop="@+id/nextButton"
81-
android:layout_toRightOf="@+id/nextButton"
82-
android:text="@string/go" />
83-
84-
<Button
85-
android:id="@+id/clearTakeBtn"
86-
android:layout_width="wrap_content"
87-
android:layout_height="wrap_content"
88-
android:layout_alignLeft="@+id/sceneInp"
89-
android:layout_alignParentBottom="true"
90-
android:layout_alignRight="@+id/takeInp"
91-
android:text="@string/clear_take" />
92-
93-
</RelativeLayout>
32+
android:layout_height="fill_parent"
33+
android:layout_weight="0.44"
34+
android:text="@string/go"
35+
android:textSize="@dimen/scene_text_size" />
36+
37+
</LinearLayout>

res/layout/number_chooser.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="fill_parent"
4+
android:layout_height="fill_parent"
5+
android:orientation="vertical" >
6+
7+
<Button
8+
android:id="@+id/plusButton"
9+
android:layout_width="match_parent"
10+
android:layout_height="fill_parent"
11+
android:layout_weight="1"
12+
android:text="@string/plus"
13+
android:textSize="@dimen/scene_text_size" />
14+
15+
<EditText
16+
android:id="@+id/numberField"
17+
android:layout_width="match_parent"
18+
android:layout_height="fill_parent"
19+
android:layout_weight="1"
20+
android:gravity="center"
21+
android:inputType="number"
22+
android:text="@string/scene_default_value"
23+
android:textSize="@dimen/scene_text_size" >
24+
25+
<requestFocus />
26+
</EditText>
27+
28+
<Button
29+
android:id="@+id/minusButton"
30+
android:layout_width="match_parent"
31+
android:layout_height="fill_parent"
32+
android:layout_weight="1"
33+
android:text="@string/minus"
34+
android:textSize="@dimen/scene_text_size" />
35+
36+
<Button
37+
android:id="@+id/oneButton"
38+
android:layout_width="match_parent"
39+
android:layout_height="fill_parent"
40+
android:layout_weight="1"
41+
android:text="@string/set_one"
42+
android:textSize="@dimen/scene_text_size" />
43+
44+
</LinearLayout>

res/values/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
<string name="hello_world">Hello world!</string>
77
<string name="scene_delim">-</string>
88
<string name="next_take">Next Take</string>
9-
<string name="go">GO!</string>
9+
<string name="go">S\nY\nN\nC</string>
1010
<string name="scene_default_value">1</string>
1111
<string name="clear_take">Clear Take</string>
12+
<string name="set_one">1</string>
13+
<string name="plus">+</string>
14+
<string name="minus">-</string>
1215

1316
</resources>

src/org/audiosync/MainActivity.java

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,34 @@
88
import android.view.Menu;
99
import android.view.View;
1010
import android.widget.Button;
11-
import android.widget.EditText;
1211
import android.widget.Toast;
1312

1413
public class MainActivity extends Activity {
1514

15+
private NumberChooser sceneInp;
16+
private NumberChooser shotInp;
17+
private NumberChooser takeInp;
18+
1619
@Override
1720
protected void onCreate(Bundle savedInstanceState) {
1821
super.onCreate(savedInstanceState);
1922
setContentView(R.layout.activity_main);
23+
2024
final Button goBtn = (Button) findViewById(R.id.goButton);
21-
final Button nextTakeBtn = (Button) findViewById(R.id.nextButton);
22-
final Button clearTakeBtn = (Button) findViewById(R.id.clearTakeBtn);
23-
final EditText sceneInp = (EditText) findViewById(R.id.sceneInp);
24-
final EditText shotInp = (EditText) findViewById(R.id.shotInp);
25-
final EditText takeInp = (EditText) findViewById(R.id.takeInp);
25+
26+
sceneInp = (NumberChooser) findViewById(R.id.sceneChooser);
27+
shotInp = (NumberChooser) findViewById(R.id.shotChooser);
28+
takeInp = (NumberChooser) findViewById(R.id.takeChooser);
29+
2630
goBtn.setOnClickListener(new View.OnClickListener() {
2731

2832
@Override
2933
public void onClick(View arg0) {
3034
int[] bytes_to_send = new int[4];
3135
try {
32-
bytes_to_send[0] = Integer.parseInt(sceneInp.getText().toString());
33-
bytes_to_send[1] = Integer.parseInt(shotInp.getText().toString());
34-
bytes_to_send[2] = Integer.parseInt(takeInp.getText().toString());
36+
bytes_to_send[0] = sceneInp.getNumber();
37+
bytes_to_send[1] = shotInp.getNumber();
38+
bytes_to_send[2] = takeInp.getNumber();
3539
for (int i : bytes_to_send) {
3640
if(i < 0 || i > 255){
3741
Toast.makeText(MainActivity.this, "Numbers have to be between 0 and 255", Toast.LENGTH_SHORT).show();
@@ -54,24 +58,7 @@ public void onClick(View arg0) {
5458
audio.play();
5559
}
5660
});
57-
nextTakeBtn.setOnClickListener(new View.OnClickListener() {
58-
59-
@Override
60-
public void onClick(View v) {
61-
try {
62-
takeInp.setText(String.valueOf(Integer.parseInt(takeInp.getText().toString()) + 1));
63-
} catch (NumberFormatException e) {
64-
takeInp.setText(R.string.scene_default_value);
65-
}
66-
}
67-
});
68-
clearTakeBtn.setOnClickListener(new View.OnClickListener() {
69-
70-
@Override
71-
public void onClick(View v) {
72-
takeInp.setText(R.string.scene_default_value);
73-
}
74-
});
61+
7562

7663
}
7764

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.audiosync;
2+
3+
import android.view.View;
4+
import android.view.View.OnClickListener;
5+
import android.widget.EditText;
6+
7+
public class MinusListener implements OnClickListener {
8+
9+
private EditText inputField;
10+
11+
public MinusListener(EditText inputField) {
12+
this.inputField = inputField;
13+
}
14+
15+
@Override
16+
public void onClick(View v) {
17+
try {
18+
inputField.setText(String.valueOf(Math.max(Integer.parseInt(inputField.getText().toString()) - 1, 1)));
19+
} catch (NumberFormatException e) {
20+
inputField.setText(R.string.scene_default_value);
21+
}
22+
}
23+
24+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.audiosync;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.view.LayoutInflater;
6+
import android.widget.Button;
7+
import android.widget.EditText;
8+
import android.widget.LinearLayout;
9+
10+
public class NumberChooser extends LinearLayout {
11+
12+
private EditText numberField;
13+
14+
public NumberChooser(Context context, AttributeSet attrs) {
15+
super(context, attrs);
16+
String infService = Context.LAYOUT_INFLATER_SERVICE;
17+
LayoutInflater li;
18+
li = (LayoutInflater)getContext().getSystemService(infService);
19+
li.inflate(R.layout.number_chooser, this, true);
20+
21+
numberField = (EditText)findViewById(R.id.numberField);
22+
((Button) findViewById(R.id.plusButton)).setOnClickListener(new PlusListener(numberField));
23+
((Button) findViewById(R.id.minusButton)).setOnClickListener(new MinusListener(numberField));
24+
((Button) findViewById(R.id.oneButton)).setOnClickListener(new OneListener(numberField));
25+
26+
}
27+
28+
public NumberChooser(Context context){
29+
this(context, null);
30+
}
31+
32+
public int getNumber() throws NumberFormatException{
33+
return Integer.parseInt(numberField.getText().toString());
34+
}
35+
36+
}

src/org/audiosync/OneListener.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.audiosync;
2+
3+
import android.view.View;
4+
import android.view.View.OnClickListener;
5+
import android.widget.EditText;
6+
7+
public class OneListener implements OnClickListener {
8+
9+
private EditText inputField;
10+
11+
public OneListener(EditText inputField) {
12+
this.inputField = inputField;
13+
}
14+
15+
@Override
16+
public void onClick(View v) {
17+
try {
18+
inputField.setText(String.valueOf(1));
19+
} catch (NumberFormatException e) {
20+
inputField.setText(R.string.scene_default_value);
21+
}
22+
}
23+
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.audiosync;
2+
3+
import android.view.View;
4+
import android.view.View.OnClickListener;
5+
import android.widget.EditText;
6+
7+
public class PlusListener implements OnClickListener {
8+
9+
private EditText inputField;
10+
11+
public PlusListener(EditText inputField) {
12+
this.inputField = inputField;
13+
}
14+
15+
@Override
16+
public void onClick(View v) {
17+
try {
18+
inputField.setText(String.valueOf(Math.min(Integer.parseInt(inputField.getText().toString()) + 1, 255)));
19+
} catch (NumberFormatException e) {
20+
inputField.setText(R.string.scene_default_value);
21+
}
22+
}
23+
24+
}

0 commit comments

Comments
 (0)