Skip to content

Commit

Permalink
Second version is ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
Todor Balabanov committed Jun 27, 2016
1 parent 07c5e09 commit 37607c7
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 16 deletions.
54 changes: 42 additions & 12 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.veldsoft.kechi" android:versionCode="1"
android:versionName="1.0">
package="eu.veldsoft.kechi"
android:versionCode="2"
android:versionName="1.1" >

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />

<application android:allowBackup="true" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:theme="@style/AppTheme">
<activity android:name=".GameActivity" android:label="@string/title_activity_main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".GameActivity"
android:label="@string/title_activity_main" >
</activity>
<activity
android:name=".SplashActivity"
android:label="@string/title_activity_splash"
android:noHistory="true" >
<meta-data
android:name="timeout"
android:value="5000" />
<meta-data
android:name="redirect"
android:value="eu.veldsoft.kechi.GameActivity" />

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HelpActivity"
android:label="@string/title_activity_help" >
</activity>
<activity
android:name=".AboutActivity"
android:label="@string/title_activity_about" >
</activity>
</application>

</manifest>
23 changes: 23 additions & 0 deletions assets/banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<html>
<body bgcolor="black">
<div style="text-align:center">

<script type='text/javascript'><!--//<![CDATA[
var m3_u = (location.protocol=='https:'?'https://adserver.veldsoft.eu/www/delivery/ajs.php':'http://adserver.veldsoft.eu/www/delivery/ajs.php');
var m3_r = Math.floor(Math.random()*99999999999);
if (!document.MAX_used) document.MAX_used = ',';
document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
document.write ("?zoneid=21&amp;target=_blank");
document.write ('&amp;cb=' + m3_r);
if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
document.write ("&amp;loc=" + escape(window.location));
if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
if (document.context) document.write ("&context=" + escape(document.context));
if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
document.write ("'><\/scr"+"ipt>");
//]]>--></script><noscript><a href='http://adserver.veldsoft.eu/www/delivery/ck.php?n=ad4e0c5a&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://adserver.veldsoft.eu/www/delivery/avw.php?zoneid=21&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=ad4e0c5a' border='0' alt='' /></a></noscript>

</div>
</body>
</html>
18 changes: 18 additions & 0 deletions res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:freezesText="true"
android:inputType="textMultiLine"
android:longClickable="false"
android:text="@string/about_text" />

</RelativeLayout>
18 changes: 18 additions & 0 deletions res/layout/activity_help.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:freezesText="true"
android:inputType="textMultiLine"
android:longClickable="false"
android:text="@string/help_text" />

</RelativeLayout>
12 changes: 12 additions & 0 deletions res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >

<WebView
android:id="@+id/ads"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</RelativeLayout>
8 changes: 7 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
<resources>

<string name="hello_world"></string>
<string name="redirect_activity_is_missing_message">Redirect activity is missing!</string>
<string name="app_name">Kechi</string>
<string name="title_activity_main">Kechi</string>
<string name="no_moves_left">No moves left!</string>
<string name="new_game_menu">New Game</string>
<string name="help_menu">Help</string>
<string name="about_menu">About</string>

<string name="title_activity_splash">Kechi</string>
<string name="title_activity_help">Help</string>
<string name="title_activity_about">About</string>
<string name="help_text">This game is played on the following board with the following setup:\n\nMOVE - On each turn, each player moves his stones a total of exactly six cells.\n\nThis means that if he has exactly one stone left, it must move exactly six cells (the stones are able to jump the intermediate cells).\n\nThe stone must finish its move on an available empty cell or a cell occupied by an enemy stone (which is captured and removed from the board).\n\nWhen a stone moves and leaves a cell, that cell cannot be used to finish any subsequent moves for either players (it should be marked somehow).\n\nGOAL - A player who is unable to make a valid move, looses.</string>
<string name="about_text">KECHI\n\nCopyright (c) 1999 Michael Marcus\n\nAndroid version was implemented as user interface tutorial at Soft Intellect academy in Java classes. \nSofia, Bulgaria, 2016\n\nCopyright (c) 2016 Velbazhd Software LLC</string>

</resources>
Expand Down
15 changes: 15 additions & 0 deletions src/eu/veldsoft/kechi/AboutActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package eu.veldsoft.kechi;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class AboutActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
}
}
18 changes: 15 additions & 3 deletions src/eu/veldsoft/kechi/GameActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package eu.veldsoft.kechi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
Expand Down Expand Up @@ -286,6 +289,16 @@ protected void onCreate(Bundle savedInstanceState) {
updateViews();
}

/**
* {@inheritDoc}
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.game_option_menu, menu);
return super.onCreateOptionsMenu(menu);
}

/**
* {@inheritDoc}
*/
Expand All @@ -298,11 +311,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
updateViews();
break;
case R.id.help:
// startActivity(new Intent(GameActivity.this, HelpActivity.class));
startActivity(new Intent(GameActivity.this, HelpActivity.class));
break;
case R.id.about:
// startActivity(new Intent(GameActivity.this,
// AboutActivity.class));
startActivity(new Intent(GameActivity.this, AboutActivity.class));
break;
}
return true;
Expand Down
15 changes: 15 additions & 0 deletions src/eu/veldsoft/kechi/HelpActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package eu.veldsoft.kechi;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class HelpActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
}
}
70 changes: 70 additions & 0 deletions src/eu/veldsoft/kechi/SplashActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package eu.veldsoft.kechi;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.Toast;

public class SplashActivity extends Activity {

private long timeout = 0L;

private String redirect = "";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);

/*
* Activate JavaScript.
*/
((WebView) findViewById(R.id.ads)).getSettings().setJavaScriptEnabled(true);

/*
* Load local web page as banner holder.
*/
((WebView) findViewById(R.id.ads)).loadUrl("file:///android_asset/banner.html");

/*
* Get splash screen timeout.
*/
try {
timeout = getPackageManager().getActivityInfo(this.getComponentName(),
PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA).metaData.getInt("timeout", 0);
} catch (Exception e) {
timeout = 0;
}

/*
* Get redirect activity class name.
*/
try {
redirect = getPackageManager().getActivityInfo(this.getComponentName(),
PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA).metaData.getString("redirect");
} catch (Exception e) {
redirect = this.getClass().toString();
Toast.makeText(this, getResources().getString(R.string.redirect_activity_is_missing_message),
Toast.LENGTH_LONG).show();
}
}

@Override
protected void onResume() {
super.onResume();

new Timer().schedule(new TimerTask() {
public void run() {
try {
startActivity(new Intent(SplashActivity.this, Class.forName(redirect)));
} catch (Exception e) {
}
}
}, timeout);
}
}

0 comments on commit 37607c7

Please sign in to comment.