Skip to content

Commit

Permalink
make screen 'rotatable' only on tablets
Browse files Browse the repository at this point in the history
  • Loading branch information
uberspot committed Apr 10, 2014
1 parent 6f21f04 commit c3018af
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
Binary file modified 2048.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uberspot.a2048"
android:versionCode="9"
android:versionName="1.8" >
android:versionCode="10"
android:versionName="1.85" >

<uses-sdk
android:minSdkVersion="10"
Expand Down
2 changes: 1 addition & 1 deletion assets/2048
Submodule 2048 updated from f732d4 to a00c9b
36 changes: 19 additions & 17 deletions src/com/uberspot/a2048/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.uberspot.a2048;

import com.uberspot.a2048.R;

import android.os.Bundle;
import android.preference.PreferenceManager;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
Expand All @@ -29,31 +28,34 @@ public class MainActivity extends Activity {
private long mLastTouch;
private static final long mTouchThreshold = 2000;
private Toast pressBackToast;

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);
applyFullScreen(isFullScreen());

if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
== Configuration.SCREENLAYOUT_SIZE_LARGE) {
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}
setContentView(R.layout.activity_main);

mWebView = (WebView) findViewById(R.id.mainWebView);
WebSettings settings = mWebView.getSettings();
String packageName = getPackageName();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDatabasePath("/data/data/" + packageName + "/databases");

if (savedInstanceState != null) {
mWebView.restoreState(savedInstanceState);
} else {
mWebView.loadUrl("file:///android_asset/2048/index.html");
}
Toast.makeText(getApplication(),
Toast.makeText(getApplication(),
R.string.toggle_fullscreen, Toast.LENGTH_SHORT).show();
mWebView.setOnTouchListener(new OnTouchListener() {
@Override
Expand All @@ -75,23 +77,23 @@ public boolean onTouch(View v, MotionEvent event) {
// by the webview as well
return false;
}});
pressBackToast = Toast.makeText(getApplicationContext(),

pressBackToast = Toast.makeText(getApplicationContext(),
R.string.press_back_again_to_exit, Toast.LENGTH_SHORT);
}

@Override
protected void onSaveInstanceState(Bundle outState) {
mWebView.saveState(outState);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.main, menu);
return true;
}

private void saveFullScreen(boolean isFullScreen) {
// save in preferences
SharedPreferences.Editor editor = PreferenceManager
Expand All @@ -105,7 +107,7 @@ private boolean isFullScreen() {
.getDefaultSharedPreferences(this)
.getBoolean(IS_FULLSCREEN_PREF, DEF_FULLSCREEN);
}

private void applyFullScreen(boolean isFullScreen) {
if(isFullScreen) {
getWindow().clearFlags(LayoutParams.FLAG_FULLSCREEN);
Expand All @@ -114,12 +116,12 @@ private void applyFullScreen(boolean isFullScreen) {
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}

@Override
public void onBackPressed() {
long currentTime = System.currentTimeMillis();
Expand Down

0 comments on commit c3018af

Please sign in to comment.