mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 14:52:13 -04:00
Merge branch 'master' of ssh://git.code.sf.net/p/kiwix/kiwix
This commit is contained in:
commit
016af9f16b
@ -24,13 +24,10 @@ import android.app.FragmentTransaction;
|
|||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
@ -53,13 +50,14 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class KiwixMobileActivity extends FragmentActivity implements ActionBar.TabListener,
|
public class KiwixMobileActivity extends FragmentActivity implements ActionBar.TabListener,
|
||||||
View.OnLongClickListener, View.OnDragListener, KiwixMobileFragment.FragmentCommunicator {
|
View.OnLongClickListener, View.OnDragListener, KiwixMobileFragment.FragmentCommunicator {
|
||||||
|
|
||||||
public static ArrayList<State> mPrefState;
|
public static ArrayList<State> mPrefState;
|
||||||
|
|
||||||
|
public static boolean mIsFullscreenOpened;
|
||||||
|
|
||||||
private ViewPagerAdapter mViewPagerAdapter;
|
private ViewPagerAdapter mViewPagerAdapter;
|
||||||
|
|
||||||
private ViewPager mViewPager;
|
private ViewPager mViewPager;
|
||||||
@ -99,6 +97,8 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
|
|||||||
|
|
||||||
mPrefState = new ArrayList<State>();
|
mPrefState = new ArrayList<State>();
|
||||||
|
|
||||||
|
mIsFullscreenOpened = false;
|
||||||
|
|
||||||
setUpViewPagerAndActionBar();
|
setUpViewPagerAndActionBar();
|
||||||
|
|
||||||
// Set the initial tab. It's hidden.
|
// Set the initial tab. It's hidden.
|
||||||
@ -137,6 +137,10 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
|
|||||||
mActionBar.setSelectedNavigationItem(position);
|
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
|
// 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).
|
// "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.
|
// 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;
|
break;
|
||||||
|
|
||||||
case R.id.menu_fullscreen:
|
case R.id.menu_fullscreen:
|
||||||
if (mCurrentFragment.isFullscreenOpened) {
|
if (mIsFullscreenOpened) {
|
||||||
closeFullScreen();
|
closeFullScreen();
|
||||||
} else {
|
} else {
|
||||||
openFullScreen();
|
openFullScreen();
|
||||||
@ -267,14 +271,14 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
|
|||||||
mCurrentFragment = getCurrentVisibleFragment();
|
mCurrentFragment = getCurrentVisibleFragment();
|
||||||
|
|
||||||
getActionBar().hide();
|
getActionBar().hide();
|
||||||
mCurrentFragment.exitFullscreenButton.setVisibility(0);
|
mCurrentFragment.exitFullscreenButton.setVisibility(View.VISIBLE);
|
||||||
mCurrentFragment.menu.findItem(R.id.menu_fullscreen)
|
mCurrentFragment.menu.findItem(R.id.menu_fullscreen)
|
||||||
.setTitle(getResources().getString(R.string.menu_exitfullscreen));
|
.setTitle(getResources().getString(R.string.menu_exitfullscreen));
|
||||||
int fullScreenFlag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
int fullScreenFlag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||||
int classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
int classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
||||||
getWindow().addFlags(fullScreenFlag);
|
getWindow().addFlags(fullScreenFlag);
|
||||||
getWindow().clearFlags(classicScreenFlag);
|
getWindow().clearFlags(classicScreenFlag);
|
||||||
mCurrentFragment.isFullscreenOpened = true;
|
mIsFullscreenOpened = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeFullScreen() {
|
private void closeFullScreen() {
|
||||||
@ -283,12 +287,12 @@ public class KiwixMobileActivity extends FragmentActivity implements ActionBar.T
|
|||||||
getActionBar().show();
|
getActionBar().show();
|
||||||
mCurrentFragment.menu.findItem(R.id.menu_fullscreen)
|
mCurrentFragment.menu.findItem(R.id.menu_fullscreen)
|
||||||
.setTitle(getResources().getString(R.string.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 fullScreenFlag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||||
int classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
int classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
|
||||||
getWindow().clearFlags(fullScreenFlag);
|
getWindow().clearFlags(fullScreenFlag);
|
||||||
getWindow().addFlags(classicScreenFlag);
|
getWindow().addFlags(classicScreenFlag);
|
||||||
mCurrentFragment.isFullscreenOpened = false;
|
mIsFullscreenOpened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,7 +101,7 @@ public class KiwixMobileFragment extends Fragment {
|
|||||||
|
|
||||||
private static final String PREF_KIWIX_MOBILE = "kiwix-mobile";
|
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";
|
private static final String AUTOMATIC = "automatic";
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ public class KiwixMobileFragment extends Fragment {
|
|||||||
|
|
||||||
protected int requestWebReloadOnFinished;
|
protected int requestWebReloadOnFinished;
|
||||||
|
|
||||||
private boolean isFullscreenButtonEnabled;
|
private boolean isButtonEnabled;
|
||||||
|
|
||||||
private SharedPreferences mySharedPreferences;
|
private SharedPreferences mySharedPreferences;
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ public class KiwixMobileFragment extends Fragment {
|
|||||||
requestWebReloadOnFinished = 0;
|
requestWebReloadOnFinished = 0;
|
||||||
requestInitAllMenuItems = false;
|
requestInitAllMenuItems = false;
|
||||||
nightMode = false;
|
nightMode = false;
|
||||||
isFullscreenButtonEnabled = true;
|
isButtonEnabled = true;
|
||||||
isFullscreenOpened = false;
|
isFullscreenOpened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ public class KiwixMobileFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageChanged(int page, int maxPages) {
|
public void onPageChanged(int page, int maxPages) {
|
||||||
if (isFullscreenButtonEnabled) {
|
if (isButtonEnabled) {
|
||||||
if (webView.getScrollY() > 200) {
|
if (webView.getScrollY() > 200) {
|
||||||
if (mBackToTopButton.getVisibility() == View.INVISIBLE) {
|
if (mBackToTopButton.getVisibility() == View.INVISIBLE) {
|
||||||
mBackToTopButton.setText(R.string.button_backtotop);
|
mBackToTopButton.setText(R.string.button_backtotop);
|
||||||
@ -653,7 +653,7 @@ public class KiwixMobileFragment extends Fragment {
|
|||||||
String pref_zoom = mySharedPreferences.getString(PREF_ZOOM, AUTOMATIC);
|
String pref_zoom = mySharedPreferences.getString(PREF_ZOOM, AUTOMATIC);
|
||||||
Boolean pref_zoom_enabled = mySharedPreferences.getBoolean(PREF_ZOOM_ENABLED, false);
|
Boolean pref_zoom_enabled = mySharedPreferences.getBoolean(PREF_ZOOM_ENABLED, false);
|
||||||
Boolean pref_nightmode = mySharedPreferences.getBoolean(PREF_NIGHTMODE, 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)) {
|
if (pref_zoom.equals(AUTOMATIC)) {
|
||||||
setDefaultZoom();
|
setDefaultZoom();
|
||||||
@ -674,7 +674,7 @@ public class KiwixMobileFragment extends Fragment {
|
|||||||
webView.getSettings().setBuiltInZoomControls(true);
|
webView.getSettings().setBuiltInZoomControls(true);
|
||||||
webView.getSettings().setDisplayZoomControls(pref_zoom_enabled);
|
webView.getSettings().setDisplayZoomControls(pref_zoom_enabled);
|
||||||
|
|
||||||
if (!isFullscreenButtonEnabled) {
|
if (!isButtonEnabled) {
|
||||||
mBackToTopButton.setVisibility(View.INVISIBLE);
|
mBackToTopButton.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,11 +168,6 @@ public class LanguageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLanguageSet() {
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a list of all the language names
|
// Get a list of all the language names
|
||||||
public List<String> getValues() {
|
public List<String> getValues() {
|
||||||
|
|
||||||
@ -212,7 +207,6 @@ public class LanguageUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(String name, Context context, AttributeSet attrs) {
|
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"
|
// Apply the custom font, if the xml tag equals "TextView", "EditText" or "AutoCompleteTextView"
|
||||||
if (name.equalsIgnoreCase("TextView")
|
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.
|
// 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:
|
// 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() {
|
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>();
|
HashMap<String, String> exceptions = new HashMap<String, String>();
|
||||||
exceptions.put("my", "Parabaik.ttf");
|
exceptions.put("my", "Parabaik.ttf");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user