Skip to content

Commit

Permalink
Added Single Player mode and Few other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ManoRanjithK committed Jul 29, 2017
1 parent 3963714 commit 83b9189
Show file tree
Hide file tree
Showing 75 changed files with 1,090 additions and 203 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:25.3.0'
testCompile 'junit:junit:4.12'
}
17 changes: 15 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,29 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity
android:name=".Splashscreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".GamePage" />
<activity android:name=".GamePage2" />
<activity android:name=".game"></activity>
<activity android:name=".game" />
<activity
android:name=".Singleplayer"
android:label="@string/title_activity_singleplayer"
android:theme="@style/AppTheme"></activity>
</application>

</manifest>
Binary file added app/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 105 additions & 9 deletions app/src/main/java/com/engima/mapps/enigma/GamePage.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,124 @@
package com.engima.mapps.enigma;

import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.KeyEvent;
import android.text.Editable;
import android.widget.EditText;

public class GamePage extends AppCompatActivity {
String num1,num2,num3,num4;
EditText c1;
EditText c2;
EditText c3;
EditText c4;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game_page);
c1 = (EditText) findViewById(R.id.n1);
c2 = (EditText) findViewById(R.id.n2);
c3 = (EditText) findViewById(R.id.n3);
c4 = (EditText) findViewById(R.id.n4);
c1.addTextChangedListener(new TextWatcher() {

public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength1 = c1.getText().length();

if (textlength1 >= 0) {
c2.requestFocus();
}
}

@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
});
c2.addTextChangedListener(new TextWatcher() {

public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength1 = c2.getText().length();

if (textlength1 >= 0) {
c3.requestFocus();
}
}

@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
});
c3.addTextChangedListener(new TextWatcher() {

public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength1 = c3.getText().length();

if (textlength1 >= 0) {
c4.requestFocus();
}
}

@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
});



}

public void gotogamepage2(View view)
{
EditText c1 = (EditText) findViewById(R.id.n1);
EditText c2 = (EditText) findViewById(R.id.n2);
EditText c3 = (EditText) findViewById(R.id.n3);
EditText c4 = (EditText) findViewById(R.id.n4);
num1 = c1.getText().toString();
num2 = c2.getText().toString();
num3 = c3.getText().toString();
num4 = c4.getText().toString();
{
StringBuilder sb=new StringBuilder();
num1 = c1.getText().toString();
num2 = c2.getText().toString();
num3 = c3.getText().toString();
num4 = c4.getText().toString();
if(((num1.equals(num2))||(num1.equals(num3))||(num1.equals(num4)))||
((num2.equals(num4))||(num2.equals(num3))||(num2.equals(num1)))||
((num3.equals(num4))||(num3.equals(num1))||(num3.equals(num2)))||
((num4.equals(num2))||(num4.equals(num1))||(num4.equals(num3))))
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Oops");
builder.setMessage("Please enter a 4 digit non-repeating number without any 0 in it");
builder.setPositiveButton("Try Again",null);
AlertDialog alertDialog = builder.create();
alertDialog.show();

}
else
{
Intent my =new Intent(this,GamePage2.class);
Bundle extras = new Bundle();
extras.putString("C1",num1);
Expand All @@ -33,6 +127,8 @@ public void gotogamepage2(View view)
extras.putString("C4",num4);
my.putExtras(extras);
startActivity(my);
}

}

}
98 changes: 92 additions & 6 deletions app/src/main/java/com/engima/mapps/enigma/GamePage2.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package com.engima.mapps.enigma;

import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.content.Intent;
import android.widget.EditText;
import android.util.Log;

public class GamePage2 extends AppCompatActivity {
String num1,num2,num3,num4,num5,num6,num7,num8;
EditText n5;
EditText n6;
EditText n7;
EditText n8;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -23,20 +30,99 @@ protected void onCreate(Bundle savedInstanceState) {
num3 =extras.getString("C3");
if(extras!=null)
num4 =extras.getString("C4");
Log.d("mytag","hh"+ num1 +"ll");
n5 = (EditText)findViewById(R.id.n5);
n6 = (EditText)findViewById(R.id.n6);
n7 =(EditText)findViewById(R.id.n7);
n8 =(EditText)findViewById(R.id.n8);

n5.addTextChangedListener(new TextWatcher() {

public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength1 = n5.getText().length();

if (textlength1 >= 1) {
n6.requestFocus();
}
}

@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
});
n6.addTextChangedListener(new TextWatcher() {

public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength1 = n6.getText().length();

if (textlength1 >= 1) {
n7.requestFocus();
}
}

@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
}); n7.addTextChangedListener(new TextWatcher() {

public void onTextChanged(CharSequence s, int start, int before,
int count) {
Integer textlength1 = n7.getText().length();

if (textlength1 >= 1) {
n8.requestFocus();
}
}

@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
});
}
public void gotogame(View view)
{
EditText n5 = (EditText)findViewById(R.id.n5);
EditText n6 = (EditText)findViewById(R.id.n6);
EditText n7 =(EditText)findViewById(R.id.n7);
EditText n8 =(EditText)findViewById(R.id.n8);
num5 = n5.getText().toString();
num6=n6.getText().toString();

num7=n7.getText().toString();
num8=n8.getText().toString();
if(((num5.equals(num6))||(num5.equals(num7))||(num5.equals(num8)))||
((num6.equals(num8))||(num6.equals(num7))||(num6.equals(num5)))||
((num7.equals(num8))||(num7.equals(num5))||(num7.equals(num6)))||
((num8.equals(num6))||(num8.equals(num5))||(num8.equals(num7))))
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Oops");
builder.setMessage("Please enter a 4 digit non-repeating number without any 0 in it");
builder.setPositiveButton("Try Again",null);
AlertDialog alertDialog = builder.create();
alertDialog.show();

}
else
{
Intent mynew=new Intent(this,game.class);
mynew.putExtra("f1",num1);
mynew.putExtra("f2",num2);
Expand All @@ -47,5 +133,5 @@ public void gotogame(View view)
mynew.putExtra("f7",num7);
mynew.putExtra("f8",num8);
startActivity(mynew);
}
}}
}
31 changes: 30 additions & 1 deletion app/src/main/java/com/engima/mapps/enigma/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
package com.engima.mapps.enigma;

import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;

public class MainActivity extends AppCompatActivity {

private DrawerLayout mDrawerlayout;
private ActionBarDrawerToggle mtoggle;
private Toolbar mtoolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mtoolbar =(Toolbar) findViewById(R.id.nav_action);
setSupportActionBar(mtoolbar);

mDrawerlayout= (DrawerLayout) findViewById(R.id.drawerlayout);
mtoggle= new ActionBarDrawerToggle(this,mDrawerlayout,R.string.open,R.string.close);
mDrawerlayout.addDrawerListener(mtoggle);
mtoggle.syncState();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);


}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(mtoggle.onOptionsItemSelected(item))
{
return true;
}
return super.onOptionsItemSelected(item);
}

public void gotogamepage(View view)
{
Intent m =new Intent (this,GamePage.class);
startActivity(m);
}
public void gotosingleplayer(View view)
{
Intent m =new Intent (this,Singleplayer.class);
startActivity(m);
}
}
Loading

0 comments on commit 83b9189

Please sign in to comment.