From 517f8b3a8684b02fed1a344db44a15c7dafea871 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sat, 11 Dec 2010 15:34:46 +0200 Subject: [PATCH] Let Translation activity uses the orientation and title states --- .../labs/androidquran/QuranViewActivity.java | 30 -------------- .../common/GestureQuranActivity.java | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 8fc1a43168..6e33c586a5 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -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; @@ -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; @@ -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); @@ -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); diff --git a/src/com/quran/labs/androidquran/common/GestureQuranActivity.java b/src/com/quran/labs/androidquran/common/GestureQuranActivity.java index 645c123079..afd75892bd 100644 --- a/src/com/quran/labs/androidquran/common/GestureQuranActivity.java +++ b/src/com/quran/labs/androidquran/common/GestureQuranActivity.java @@ -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; @@ -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 { @@ -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(); + } }