Skip to content

Commit

Permalink
Fixes to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
km2442 committed Jun 17, 2019
1 parent bfa6348 commit 40e5887
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
Expand All @@ -11,6 +12,8 @@ public class ConnectWait extends AppCompatActivity {
String IP, Port = "1234", addr;
SocketCommunicator sc;

private static final String TAG = "ConnectWait";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -26,13 +29,14 @@ protected void onCreate(Bundle savedInstanceState) {
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ConnectWait.this.finish();
finish();
}
});
}

private void connectToPC(String IP, String Port)
{
Log.d(TAG, "connectToPC: create");
Hub.sc = new SocketCommunicator(IP, this);
}

Expand All @@ -42,8 +46,4 @@ public void connected()
i.putExtra("Addr", addr);
startActivity(i);
}

public void finish() {
finish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ public void onClick(View v) {
};
btn.setOnClickListener(cl);

Button clear = (Button) findViewById(R.id.main_IP_Clear);
clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText IP1 = (EditText) findViewById(R.id.main_IP_1);
EditText IP2 = (EditText) findViewById(R.id.main_IP_2);
EditText IP3 = (EditText) findViewById(R.id.main_IP_3);
EditText IP4 = (EditText) findViewById(R.id.main_IP_4);

IP1.setText("");
IP2.setText("");
IP3.setText("");
IP4.setText("");

IP1.requestFocus();
}
});

final Button buttonSetup = (Button) findViewById(R.id.btn_setup);

buttonSetup.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void run() {
}

public void startReceiver() {
Thread thread = new Thread(new Runnable() {
final Thread thread = new Thread(new Runnable() {
@Override
public void run() {
boolean exception = false;
Expand All @@ -91,6 +91,8 @@ public void run() {
e.printStackTrace();
}
while (!exception) {
if(socket.isClosed()) break;

try {
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
final String st = input.readLine();
Expand Down
104 changes: 61 additions & 43 deletions Android/app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,58 @@
tools:context=".MainActivity"
tools:showIn="@layout/app_bar_main">

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="IP"
app:layout_constraintBaseline_toBaselineOf="@id/main_IP_1"
app:layout_constraintEnd_toStartOf="@+id/main_IP_1"
app:layout_constraintStart_toStartOf="parent" />

<EditText
android:id="@+id/main_IP_4"
android:layout_width="75dp"
android:id="@+id/main_IP_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:inputType="number"
android:maxLength="3"
android:phoneNumber="false"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/main_IP_3" />
app:layout_constraintEnd_toStartOf="@+id/textView4"
app:layout_constraintStart_toEndOf="@id/textView2"
app:layout_constraintTop_toBottomOf="@+id/textView" />

<TextView
android:id="@+id/textView6"
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="."
android:textAlignment="center"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/main_IP_3"
app:layout_constraintEnd_toStartOf="@+id/main_IP_4" />
app:layout_constraintBottom_toBottomOf="@+id/main_IP_1"
app:layout_constraintEnd_toStartOf="@+id/main_IP_2"
app:layout_constraintStart_toEndOf="@id/main_IP_1" />

<EditText
android:id="@+id/main_IP_3"
android:layout_width="75dp"
android:id="@+id/main_IP_2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:ems="10"
android:inputType="number"
android:maxLength="3"
android:phoneNumber="false"
android:textAlignment="center"
app:layout_constraintEnd_toStartOf="@+id/textView6"
app:layout_constraintTop_toTopOf="@+id/main_IP_2" />
app:layout_constraintEnd_toStartOf="@+id/textView5"
app:layout_constraintStart_toEndOf="@id/textView4"
app:layout_constraintTop_toTopOf="@+id/main_IP_1" />

<TextView
android:id="@+id/textView5"
Expand All @@ -56,34 +71,59 @@
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/main_IP_2"
app:layout_constraintEnd_toStartOf="@+id/main_IP_3" />
app:layout_constraintEnd_toStartOf="@+id/main_IP_3"
app:layout_constraintStart_toEndOf="@id/main_IP_2" />

<EditText
android:id="@+id/main_IP_2"
android:layout_width="75dp"
android:id="@+id/main_IP_3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:ems="10"
android:inputType="number"
android:maxLength="3"
android:phoneNumber="false"
android:textAlignment="center"
app:layout_constraintEnd_toStartOf="@+id/textView5"
app:layout_constraintTop_toTopOf="@+id/main_IP_1" />
app:layout_constraintEnd_toStartOf="@+id/textView6"
app:layout_constraintStart_toEndOf="@id/textView5"
app:layout_constraintTop_toTopOf="@+id/main_IP_2" />

<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="."
android:textAlignment="center"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/main_IP_3"
app:layout_constraintEnd_toStartOf="@+id/main_IP_4"
app:layout_constraintStart_toEndOf="@id/main_IP_3" />

<EditText
android:id="@+id/main_IP_1"
android:layout_width="75dp"
android:id="@+id/main_IP_4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:inputType="number"
android:maxLength="3"
android:phoneNumber="false"
android:textAlignment="center"
app:layout_constraintEnd_toStartOf="@+id/textView4"
app:layout_constraintTop_toBottomOf="@+id/textView" />
app:layout_constraintEnd_toStartOf="@+id/main_IP_Clear"
app:layout_constraintStart_toEndOf="@id/textView6"
app:layout_constraintTop_toTopOf="@+id/main_IP_3" />

<Button
android:id="@+id/main_IP_Clear"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="X"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/main_IP_4"
app:layout_constraintTop_toTopOf="@+id/main_IP_4" />

<ImageView
android:id="@+id/imageView3"
Expand Down Expand Up @@ -137,26 +177,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="IP"
app:layout_constraintBaseline_toBaselineOf="@id/main_IP_1"
app:layout_constraintEnd_toStartOf="@+id/main_IP_1"
app:layout_constraintStart_toStartOf="parent" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="."
android:textAlignment="center"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/main_IP_1"
app:layout_constraintEnd_toStartOf="@+id/main_IP_2" />
</android.support.constraint.ConstraintLayout>

0 comments on commit 40e5887

Please sign in to comment.