Skip to content

Commit

Permalink
Let Translation activity uses the orientation and title states
Browse files Browse the repository at this point in the history
  • Loading branch information
Hussein Maher committed Dec 11, 2010
1 parent 0f5041c commit 517f8b3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/com/quran/labs/androidquran/QuranViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.text.NumberFormat;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
Expand All @@ -13,7 +12,6 @@
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
Expand Down Expand Up @@ -50,10 +48,6 @@ public class QuranViewActivity extends GestureQuranActivity implements Animation
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
QuranSettings.load(prefs);
BookmarksManager.load(prefs);

adjustDisplaySettings();
initializeViewElements();
initializeQsi();
loadPageState(savedInstanceState);
Expand All @@ -64,30 +58,6 @@ protected void onCreate(Bundle savedInstanceState){
showPage();
}

private void adjustActivityOrientation() {
if (QuranSettings.getInstance().isLockOrientation()) {
if (QuranSettings.getInstance().isLandscapeOrientation())
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
else
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}

private void adjustDisplaySettings() {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
if (QuranSettings.getInstance().isFullScreen()) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
if (!QuranSettings.getInstance().isShowClock()) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}

adjustActivityOrientation();
}

private void initializeViewElements() {
setContentView(R.layout.quran_view);
imageView = (QuranImageView)findViewById(R.id.pageview);
Expand Down
39 changes: 39 additions & 0 deletions src/com/quran/labs/androidquran/common/GestureQuranActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package com.quran.labs.androidquran.common;

import com.quran.labs.androidquran.util.BookmarksManager;
import com.quran.labs.androidquran.util.QuranSettings;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.Window;
import android.view.WindowManager;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;

Expand All @@ -11,6 +18,14 @@ public abstract class GestureQuranActivity extends BaseQuranActivity {
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;

@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
QuranSettings.load(prefs);
BookmarksManager.load(prefs);
adjustDisplaySettings();
}

// thanks to codeshogun's blog post for this
// http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/
public class QuranGestureDetector extends SimpleOnGestureListener {
Expand Down Expand Up @@ -46,4 +61,28 @@ public boolean dispatchTouchEvent(MotionEvent event){
super.dispatchTouchEvent(event);
return gestureDetector.onTouchEvent(event);
}

protected void adjustActivityOrientation() {
if (QuranSettings.getInstance().isLockOrientation()) {
if (QuranSettings.getInstance().isLandscapeOrientation())
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
else
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}

protected void adjustDisplaySettings() {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
if (QuranSettings.getInstance().isFullScreen()) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
if (!QuranSettings.getInstance().isShowClock()) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}

adjustActivityOrientation();
}
}

0 comments on commit 517f8b3

Please sign in to comment.