Merge branch 'master' of ssh://git.code.sf.net/p/kiwix/kiwix

This commit is contained in:
kelson42 2013-12-16 22:04:27 +01:00
commit 016af9f16b
3 changed files with 21 additions and 24 deletions

View File

@ -24,13 +24,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;
@ -53,13 +50,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;
@ -99,6 +97,8 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
mPrefState = new ArrayList<State>();
mIsFullscreenOpened = false;
setUpViewPagerAndActionBar();
// Set the initial tab. It's hidden.
@ -137,6 +137,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.
@ -240,7 +244,7 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
break;
case R.id.menu_fullscreen:
if (mCurrentFragment.isFullscreenOpened) {
if (mIsFullscreenOpened) {
closeFullScreen();
} else {
openFullScreen();
@ -267,14 +271,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() {
@ -283,12 +287,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

@ -101,7 +101,7 @@ public class KiwixMobileFragment extends Fragment {
private static final String PREF_KIWIX_MOBILE = "kiwix-mobile";
private static final String PREF_BACK_TO_TOP = "pref_backtotop";
private static final String PREF_BACK_TO_TOP = "pref_back_to_top";
private static final String AUTOMATIC = "automatic";
@ -135,7 +135,7 @@ public class KiwixMobileFragment extends Fragment {
protected int requestWebReloadOnFinished;
private boolean isFullscreenButtonEnabled;
private boolean isButtonEnabled;
private SharedPreferences mySharedPreferences;
@ -158,7 +158,7 @@ public class KiwixMobileFragment extends Fragment {
requestWebReloadOnFinished = 0;
requestInitAllMenuItems = false;
nightMode = false;
isFullscreenButtonEnabled = true;
isButtonEnabled = true;
isFullscreenOpened = false;
}
@ -385,7 +385,7 @@ public class KiwixMobileFragment extends Fragment {
@Override
public void onPageChanged(int page, int maxPages) {
if (isFullscreenButtonEnabled) {
if (isButtonEnabled) {
if (webView.getScrollY() > 200) {
if (mBackToTopButton.getVisibility() == View.INVISIBLE) {
mBackToTopButton.setText(R.string.button_backtotop);
@ -653,7 +653,7 @@ public class KiwixMobileFragment extends Fragment {
String pref_zoom = mySharedPreferences.getString(PREF_ZOOM, AUTOMATIC);
Boolean pref_zoom_enabled = mySharedPreferences.getBoolean(PREF_ZOOM_ENABLED, false);
Boolean pref_nightmode = mySharedPreferences.getBoolean(PREF_NIGHTMODE, false);
isFullscreenButtonEnabled = mySharedPreferences.getBoolean(PREF_BACK_TO_TOP, isFullscreenButtonEnabled);
isButtonEnabled = mySharedPreferences.getBoolean(PREF_BACK_TO_TOP, isButtonEnabled);
if (pref_zoom.equals(AUTOMATIC)) {
setDefaultZoom();
@ -674,7 +674,7 @@ public class KiwixMobileFragment extends Fragment {
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(pref_zoom_enabled);
if (!isFullscreenButtonEnabled) {
if (!isButtonEnabled) {
mBackToTopButton.setVisibility(View.INVISIBLE);
}

View File

@ -168,11 +168,6 @@ public class LanguageUtils {
}
}
private boolean isLanguageSet() {
return false;
}
// Get a list of all the language names
public List<String> getValues() {
@ -212,7 +207,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")
@ -248,11 +242,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");