Fixed fullscreen button.

This commit is contained in:
Rashiq Ahmad 2013-12-16 21:56:46 +01:00
parent 555ce47938
commit 8315ffc77a
3 changed files with 15 additions and 21 deletions

View File

@ -5,13 +5,10 @@ import android.app.FragmentTransaction;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
@ -34,13 +31,14 @@ import android.widget.LinearLayout;
import android.widget.Spinner;
import java.util.ArrayList;
import java.util.Locale;
public class KiwixMobileActivity extends FragmentActivity implements ActionBar.TabListener,
View.OnLongClickListener, View.OnDragListener, KiwixMobileFragment.FragmentCommunicator {
public static ArrayList<State> mPrefState;
public static boolean mIsFullscreenOpened;
private ViewPagerAdapter mViewPagerAdapter;
private ViewPager mViewPager;
@ -80,6 +78,8 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
mPrefState = new ArrayList<State>();
mIsFullscreenOpened = false;
setUpViewPagerAndActionBar();
// Set the initial tab. It's hidden.
@ -118,6 +118,10 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
mActionBar.setSelectedNavigationItem(position);
}
// Set the visibillity of the fullscreen button
int visibillity = mIsFullscreenOpened ? View.VISIBLE : View.INVISIBLE;
mCurrentFragment.exitFullscreenButton.setVisibility(visibillity);
// If the app is in landscape mode, Android will switch the navigationmode from
// "NAVIGATION_MODE_TABS" to "NAVIGATION_MODE_LIST" (as long as the app has more than 3 tabs open).
// There is no way to update this Spinner without creating an extra adapter for that.
@ -221,7 +225,7 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
break;
case R.id.menu_fullscreen:
if (mCurrentFragment.isFullscreenOpened) {
if (mIsFullscreenOpened) {
closeFullScreen();
} else {
openFullScreen();
@ -248,14 +252,14 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
mCurrentFragment = getCurrentVisibleFragment();
getActionBar().hide();
mCurrentFragment.exitFullscreenButton.setVisibility(0);
mCurrentFragment.exitFullscreenButton.setVisibility(View.VISIBLE);
mCurrentFragment.menu.findItem(R.id.menu_fullscreen)
.setTitle(getResources().getString(R.string.menu_exitfullscreen));
int fullScreenFlag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
int classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
getWindow().addFlags(fullScreenFlag);
getWindow().clearFlags(classicScreenFlag);
mCurrentFragment.isFullscreenOpened = true;
mIsFullscreenOpened = true;
}
private void closeFullScreen() {
@ -264,12 +268,12 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
getActionBar().show();
mCurrentFragment.menu.findItem(R.id.menu_fullscreen)
.setTitle(getResources().getString(R.string.menu_fullscreen));
mCurrentFragment.exitFullscreenButton.setVisibility(4);
mCurrentFragment.exitFullscreenButton.setVisibility(View.INVISIBLE);
int fullScreenFlag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
int classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
getWindow().clearFlags(fullScreenFlag);
getWindow().addFlags(classicScreenFlag);
mCurrentFragment.isFullscreenOpened = false;
mIsFullscreenOpened = false;
}
@Override

View File

@ -102,8 +102,6 @@ public class KiwixMobileFragment extends Fragment {
public KiwixWebView webView;
public boolean isFullscreenOpened;
public ImageButton exitFullscreenButton;
public AutoCompleteTextView articleSearchtextView;
@ -140,7 +138,6 @@ public class KiwixMobileFragment extends Fragment {
requestInitAllMenuItems = false;
nightMode = false;
isButtonEnabled = true;
isFullscreenOpened = false;
}
@Override

View File

@ -149,11 +149,6 @@ public class LanguageUtils {
}
}
private boolean isLanguageSet() {
return false;
}
// Get a list of all the language names
public List<String> getValues() {
@ -193,7 +188,6 @@ public class LanguageUtils {
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
Log.e("kiwix", name);
// Apply the custom font, if the xml tag equals "TextView", "EditText" or "AutoCompleteTextView"
if (name.equalsIgnoreCase("TextView")
@ -229,11 +223,10 @@ public class LanguageUtils {
// This method will determine which font will be applied to the not-supported-locale.
// You can define exceptions to the default DejaVu font in the 'exceptions' Hashmap:
// Key: the language code; Value: the name of the font.
// The font has to be placed in the assets folder.
private String getTypeface() {
// Define the exceptions to the rule
// Define the exceptions to the rule. The font has to be placed in the assets folder.
// Key: the language code; Value: the name of the font.
HashMap<String, String> exceptions = new HashMap<String, String>();
exceptions.put("my", "Parabaik.ttf");