Update time !

This commit is contained in:
Florian Bouillon 2018-01-29 00:13:06 +01:00
parent 743b69261d
commit a018ad56ee
7 changed files with 131 additions and 41 deletions

15
.idea/misc.xml generated
View File

@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager"> <component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" /> <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
@ -27,17 +24,7 @@
</value> </value>
</option> </option>
</component> </component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -4,7 +4,7 @@ android {
buildToolsVersion "26.0.1" buildToolsVersion "26.0.1"
defaultConfig { defaultConfig {
applicationId "net.DeltaWings.Android.Hangman" applicationId "net.DeltaWings.Android.Hangman"
minSdkVersion 15 minSdkVersion 16
targetSdkVersion 26 targetSdkVersion 26
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"

View File

@ -6,19 +6,26 @@ import android.os.Bundle;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.widget.EditText;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.TextView;
import static net.DeltaWings.Android.Hangman.MainActivity.instance; import net.DeltaWings.Android.Hangman.Util.ConnectionUtil;
import java.util.ArrayList;
import java.util.List;
public class GameActivity extends AppCompatActivity { public class GameActivity extends AppCompatActivity {
ProgressBar progressBar; private AlertDialog.Builder builder;
AlertDialog.Builder builder; private ConnectionUtil co;
private List<String> letters = new ArrayList<>();
@Override @Override
public void onBackPressed() { public void onBackPressed() {
builder.show();
} }
@Override @Override
@ -29,47 +36,105 @@ public class GameActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
setContentView(R.layout.game_activity); setContentView(R.layout.game_activity);
ProgressBar progressBar = findViewById(R.id.progressBar);
EditText input = findViewById(R.id.input);
log("Logs");
log("Connecting...");
co = new ConnectionUtil();
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
actionBar.setHomeButtonEnabled(true); actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayShowHomeEnabled(true);
} else { } else {
Toast.makeText(instance, " There is a problem here let's see what it is", Toast.LENGTH_LONG).show(); log("A problem occurred Please restart the application");
} }
progressBar = findViewById(R.id.progressBar);
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which){ switch (which){
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
Toast.makeText(instance, "Selected Yes", Toast.LENGTH_LONG).show(); //Close Connection
break; log("Closing connection");
co.closeConnection();
case DialogInterface.BUTTON_NEGATIVE: //send to main menu
Toast.makeText(instance, "Selected No", Toast.LENGTH_LONG).show(); finish();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
break; break;
} }
} }
}; };
//Input Management
input.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
String text = ((EditText) v).getText().toString();
if(text.length() == 1) {
log("Letter : " + text);
if(letters.contains(text)) {
log("Letter : " + text + "Already in");
} else {
log("Sending letter " + text);
//Send Letter
}
} else if(text.length() > 1) {
log("Word : " + text);
}
return false;
}
});
//Input Management
//Return Builder
builder = new AlertDialog.Builder(this); builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener) builder.setMessage("Do you really want to quit your game ?")
.setPositiveButton("Yes", dialogClickListener)
.setNegativeButton("No", dialogClickListener); .setNegativeButton("No", dialogClickListener);
//Return Builder
log("Connected !");
setProgressAnimate(progressBar, 100);
} }
private void setProgressAnimate(ProgressBar pb, int progressTo)
{ private void setProgressAnimate(ProgressBar pb, int progressTo) {
ObjectAnimator animation = ObjectAnimator.ofInt(pb, "progress", pb.getProgress(), progressTo); ObjectAnimator animation = ObjectAnimator.ofInt(pb, "progress", pb.getProgress(), progressTo);
animation.setDuration(250); animation.setDuration(250);
animation.setInterpolator(new DecelerateInterpolator()); animation.setInterpolator(new DecelerateInterpolator());
animation.start(); animation.start();
} }
private void log(String message) {
TextView logs = findViewById(R.id.logs);
logs.setText(logs.getText().toString() + "\n" + message);
}
} }

View File

@ -0,0 +1,32 @@
package net.DeltaWings.Android.Hangman.Util;
import java.util.List;
public class ConnectionUtil {
static public ConnectionUtil connection;
private String ip = null;
private String userID = null;
private String jsp = "jsp";
public int percent = 0;
public ConnectionUtil ConnectionUtil() {
return this;
}
public void closeConnection() {
}
public boolean sendData(List<Object> query) {
return true;
}
public Object getData() {
return null;
}
}

View File

@ -14,6 +14,7 @@
style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Horizontal" style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Horizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="false"
android:max="100" android:max="100"
android:paddingTop="-4dp" android:paddingTop="-4dp"
android:progress="50" android:progress="50"
@ -27,14 +28,13 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintGuide_begin="4dp" app:layout_constraintGuide_begin="3dp"
tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="4dp"/> tools:layout_editor_absoluteY="4dp"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="0dp"
android:layout_marginTop="0dp"
android:orientation="vertical" android:orientation="vertical"
android:weightSum="1" android:weightSum="1"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@ -76,7 +76,7 @@
android:textStyle="bold"/> android:textStyle="bold"/>
<EditText <EditText
android:id="@+id/editText" android:id="@+id/input"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="0dp" android:layout_marginBottom="0dp"
@ -93,11 +93,17 @@
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/> app:layout_constraintRight_toRightOf="parent"/>
<TextView <ScrollView
android:id="@+id/textView3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:text="Logs"/> android:layout_weight="1">
<TextView
android:id="@+id/logs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</ScrollView>
</LinearLayout> </LinearLayout>

View File

@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

View File

@ -1,6 +1,6 @@
#Mon Sep 18 17:41:18 CEST 2017 #Mon Jan 22 23:59:18 CET 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip