Skip to content

Commit

Permalink
reorganize project setup, and maintenance (uberspot#67)
Browse files Browse the repository at this point in the history
* rearranged project files

* code n stuff

Signed-off-by: TacoTheDank <[email protected]>

* changelog dependency

Signed-off-by: TacoTheDank <[email protected]>
  • Loading branch information
TacoTheDank authored and uberspot committed Nov 2, 2018
1 parent 72f7890 commit ec194a0
Show file tree
Hide file tree
Showing 45 changed files with 180 additions and 185 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "assets/2048"]
path = assets/2048
[submodule "2048"]
path = 2048
url = https://github.com/uberspot/2048.git
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
language: android

jdk:
- oraclejdk8

android:
components:
- tools
- build-tools-28.0.2
- android-26
- platform-tools
- build-tools-28.0.3
- android-28

- extra-android-support
- extra-android-m2repository

jdk:
- oraclejdk8
script:
- ./gradlew build
1 change: 1 addition & 0 deletions 2048
Submodule 2048 added at 7986ea
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@

[![Build Status](https://travis-ci.org/uberspot/2048-android.svg?branch=master)](https://travis-ci.org/uberspot/2048-android)

This is the android port of the 2048 game made by Gabriele Cirulli https://github.com/gabrielecirulli/2048
It's nothing fancy, just a webview that loads the locally stored html files of the original game.
I just wanted to make it instantly playable without Internet (the app doesn't require any permissions) and with
This is the Android port of the 2048 game made by Gabriele Cirulli https://github.com/gabrielecirulli/2048
It's nothing fancy; just a WebView that loads the locally stored html files of the original game.
I just wanted to make it instantly playable without internet (the app doesn't require any permissions), and with
a quick access icon for my smartphone.

Feel free to contribute with pull requests to the original project by Gabriele or to this one if you have any android
specific improvements in mind.
Feel free to contribute with pull requests to the original project by Gabriele, or to this one
if you have any Android-specific improvements in mind.

<a href="https://f-droid.org/packages/com.uberspot.a2048/" target="_blank">
<img src="https://f-droid.org/badge/get-it-on.png" alt="Get it on F-Droid" height="100"/></a>
<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="100"/></a>
<a href="https://play.google.com/store/apps/details?id=com.uberspot.a2048" target="_blank">
<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" alt="Get it on Google Play" height="100"/></a>

![](screenshots/screen1.png)
<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" alt="Get it on Google Play" height="100"/></a>

## Building

If you want to build from source just do
If you want to build from source, just do

git clone --recursive https://github.com/uberspot/2048-android.git
cd 2048-android/
cd 2048-android
git submodule update --init --recursive
./gradlew build

Expand All @@ -38,9 +36,9 @@ If you want to build from source just do
### With Android Studio

1. Follow first three lines of Building directions.
2. In Android Studio selection "Open an Existing Android Studio Project"
2. In Android Studio selection "Open an existing Android Studio Project"
3. When prompted, add the VCS root.

## License

2048-android is licensed under the [MIT license.](https://github.com/uberspot/2048-android/blob/master/LICENSE)
2048-android is licensed under the [MIT license](https://github.com/uberspot/2048-android/blob/master/LICENSE).
33 changes: 33 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "com.uberspot.a2048"
minSdkVersion 8
targetSdkVersion 28
versionCode 23
versionName "2.08"
}

lintOptions {
disable 'MissingTranslation'
abortOnError false
}

compileOptions {
encoding = 'UTF-8'
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation 'de.cketti.library.changelog:ckchangelog:1.2.2'
// TODO: choose correct library and implement it (https://github.com/cketti/ckChangeLog/tree/version_2)
//implementation 'de.cketti.library.changelog:ckchangelog-legacy-dialog:2.0.0-SNAPSHOT'
// OR
//implementation 'de.cketti.library.changelog:ckchangelog-core:2.0.0-SNAPSHOT'
}
8 changes: 3 additions & 5 deletions AndroidManifest.xml → app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uberspot.a2048"
android:versionCode="23"
android:versionName="2.08" >
package="com.uberspot.a2048">

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme">
<activity
android:name="com.uberspot.a2048.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait" >
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

package com.uberspot.a2048;

import java.util.Locale;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.SharedPreferences;
Expand All @@ -15,8 +12,6 @@
import android.provider.Settings.SettingNotFoundException;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
Expand All @@ -25,6 +20,8 @@
import android.webkit.WebView;
import android.widget.Toast;

import java.util.Locale;

import de.cketti.library.changelog.ChangeLog;

public class MainActivity extends Activity {
Expand All @@ -40,7 +37,7 @@ public class MainActivity extends Activity {
private static final long mTouchThreshold = 2000;
private Toast pressBackToast;

@SuppressLint({ "SetJavaScriptEnabled", "NewApi", "ShowToast" })
@SuppressLint({"SetJavaScriptEnabled", "NewApi", "ShowToast"})
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -71,7 +68,7 @@ protected void onCreate(Bundle savedInstanceState) {
& Configuration.SCREENLAYOUT_SIZE_MASK;
if (((screenLayout == Configuration.SCREENLAYOUT_SIZE_LARGE)
|| (screenLayout == Configuration.SCREENLAYOUT_SIZE_XLARGE))
&& isOrientationEnabled) {
&& isOrientationEnabled) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}

Expand All @@ -95,31 +92,27 @@ protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState != null) {
mWebView.restoreState(savedInstanceState);
} else {
// Load webview with current Locale language
// Load webview with current Locale language
mWebView.loadUrl("file:///android_asset/2048/index.html?lang=" + Locale.getDefault().getLanguage());
}

Toast.makeText(getApplication(), R.string.toggle_fullscreen, Toast.LENGTH_SHORT).show();
// Set fullscreen toggle on webview LongClick
mWebView.setOnTouchListener(new OnTouchListener() {

@Override
public boolean onTouch(View v, MotionEvent event) {
// Implement a long touch action by comparing
// time between action up and action down
long currentTime = System.currentTimeMillis();
if ((event.getAction() == MotionEvent.ACTION_UP)
&& (Math.abs(currentTime - mLastTouch) > mTouchThreshold)) {
boolean toggledFullScreen = !isFullScreen();
saveFullScreen(toggledFullScreen);
applyFullScreen(toggledFullScreen);
} else if (event.getAction() == MotionEvent.ACTION_DOWN) {
mLastTouch = currentTime;
}
// return so that the event isn't consumed but used
// by the webview as well
return false;
mWebView.setOnTouchListener((v, event) -> {
// Implement a long touch action by comparing
// time between action up and action down
long currentTime = System.currentTimeMillis();
if ((event.getAction() == MotionEvent.ACTION_UP)
&& (Math.abs(currentTime - mLastTouch) > mTouchThreshold)) {
boolean toggledFullScreen = !isFullScreen();
saveFullScreen(toggledFullScreen);
applyFullScreen(toggledFullScreen);
} else if (event.getAction() == MotionEvent.ACTION_DOWN) {
mLastTouch = currentTime;
}
// return so that the event isn't consumed but used
// by the webview as well
return false;
});

pressBackToast = Toast.makeText(getApplicationContext(), R.string.press_back_again_to_exit,
Expand All @@ -136,9 +129,10 @@ protected void onResume() {
protected void onSaveInstanceState(Bundle outState) {
mWebView.saveState(outState);
}

/**
* Saves the full screen setting in the SharedPreferences
*
* @param isFullScreen
*/

Expand All @@ -155,7 +149,8 @@ private boolean isFullScreen() {
}

/**
* Toggles the activitys fullscreen mode by setting the corresponding window flag
* Toggles the activity's fullscreen mode by setting the corresponding window flag
*
* @param isFullScreen
*/
private void applyFullScreen(boolean isFullScreen) {
Expand All @@ -166,13 +161,13 @@ private void applyFullScreen(boolean isFullScreen) {
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}

/**
* Prevents app from closing on pressing back button accidentally.
* mBackPressThreshold specifies the maximum delay (ms) between two consecutive backpress to
* quit the app.
*/

@Override
public void onBackPressed() {
long currentTime = System.currentTimeMillis();
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" >
tools:context=".MainActivity">

<WebView
android:id="@+id/mainWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
android:id="@+id/mainWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

</LinearLayout>
4 changes: 2 additions & 2 deletions res/menu/main.xml → app/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<menu>

<!--<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>-->
android:title="@string/action_settings" />-->

</menu>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<string name="app_name">2048</string>
<string name="action_settings">Settings</string>
<string name="press_back_again_to_exit">Press back again to exit</string>
<string name="toggle_fullscreen">Long click to toggle fullscreen</string>
<string name="toggle_fullscreen">Long click to toggle fullscreen</string>

</resources>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="2.08" versioncode="23" >
<release
version="2.08"
versioncode="23">
<change>Added Esperanto and Dutch (thx Robin van der Vliet).</change>
<change>Fix bug with floating windows (thx diogopereira)</change>
</release>
<release version="2.06" versioncode="22" >
<release
version="2.06"
versioncode="22">
<change>Limit undo button to last 50 states to avoid using too much memory.</change>
</release>
<release version="2.05" versioncode="21" >
<release
version="2.05"
versioncode="21">
<change>Added changelog in app</change>
</release>
<release version="2.0" versioncode="20" >
<release
version="2.0"
versioncode="20">
<change>Added undo button (thx to fraggerfox on github)</change>
</release>
<release version="1.96" versioncode="19" >
<release
version="1.96"
versioncode="19">
<change>Rebuilt apk with new build tools.</change>
</release>
<release version="1.95" versioncode="18">
<change>Added German, Spanish, Polish, Serbian translations thx to contributors in github</change>
<release
version="1.95"
versioncode="18">
<change>Added German, Spanish, Polish, Serbian translations thx to contributors in github
</change>
<change>Added experimental night mode button</change>
<change>Minor optimizations to responsiveness</change>
</release>
<release version="1.91" versioncode="18" >
<release
version="1.91"
versioncode="18">
<change>Added greek and french app translation, minor build improvements.</change>
</release>
</changelog>
1 change: 0 additions & 1 deletion assets/2048
Submodule 2048 deleted from 35a371
Loading

0 comments on commit ec194a0

Please sign in to comment.