diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f31027003..66455c1cd 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,16 +1,16 @@
+ package="org.kiwix.kiwixmobile"
+ android:installLocation="auto"
+ android:versionCode="30"
+ android:versionName="2.0">
+ android:anyDensity="true"
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:resizeable="true"
+ android:smallScreens="true" />
@@ -26,9 +26,9 @@
android:theme="@style/AppTheme"
android:supportsRtl="true">
+ android:name=".KiwixMobileActivity"
+ android:configChanges="orientation|keyboardHidden|screenSize|locale"
+ android:label="@string/app_name">
@@ -86,8 +86,8 @@
+ android:name=".ZimFileSelectFragment"
+ android:label="@string/choose_file">
@@ -104,25 +104,31 @@
+ android:name=".ZimContentProvider"
+ android:authorities="org.kiwix.zim.base"
+ android:exported="true" />
-
+
-
-
-
-
-
+
+
+
+
-
+
+
-
+
+
+
+
\ No newline at end of file
diff --git a/CHANGELOG b/CHANGELOG
index 06563b202..33c267494 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ NEW: Clean history button
NEW: Open new tab in background - settings option
NEW: Kiwix search home screen widget
NEW: Download manager
+NEW: Improved ZIM management
FIXED: Opening problem with ZIM filenames with special characters
FIXED: Useless "w820dp" language
FIXED: Failing he, id, yi locales
diff --git a/res/layout/activity_library.xml b/res/layout/activity_library.xml
index 90dc2f0c7..2cd43212f 100644
--- a/res/layout/activity_library.xml
+++ b/res/layout/activity_library.xml
@@ -5,13 +5,36 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- tools:context="org.kiwix.kiwixmobile.LibraryActivity">
-
-
+ tools:context=".LibraryFragment">
+
+
+
+
+
+
diff --git a/res/layout/fragment_zim_manager.xml b/res/layout/fragment_zim_manager.xml
new file mode 100644
index 000000000..af9f87855
--- /dev/null
+++ b/res/layout/fragment_zim_manager.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/res/layout/zim_list.xml b/res/layout/zim_list.xml
index 8eaa45977..49c62e492 100644
--- a/res/layout/zim_list.xml
+++ b/res/layout/zim_list.xml
@@ -5,8 +5,6 @@
android:layout_height="fill_parent"
android:orientation="vertical">
-
-
diff --git a/res/layout/zim_manager.xml b/res/layout/zim_manager.xml
new file mode 100644
index 000000000..62caa4137
--- /dev/null
+++ b/res/layout/zim_manager.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/menu/menu_main.xml b/res/menu/menu_main.xml
index e163d44c9..dbf3824ab 100644
--- a/res/menu/menu_main.xml
+++ b/res/menu/menu_main.xml
@@ -36,14 +36,10 @@
-
-
+
+
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index e44402d7f..fb3331a23 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -7,5 +7,7 @@
8dp
260dp
0dp
+ 16dp
+ 8dp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4966e4284..f8b31a629 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,6 +1,6 @@
- Open File
+ Get Content
Help
Home
Forward
@@ -91,4 +91,7 @@
Sorry! Your device does not support speech input
Download started...
Download ZIM files
+ Local
+ Remote
+ Content Management
\ No newline at end of file
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 5d4dfb9a6..84dd572c8 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -1,7 +1,7 @@
-
+
-
+
+
+
+
+
diff --git a/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java
index 5e1162446..2c36b2e99 100644
--- a/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java
+++ b/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java
@@ -49,7 +49,6 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.ActionMode;
-import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -271,7 +270,6 @@ public class KiwixMobileActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
handleLocaleCheck();
-
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
@@ -772,7 +770,7 @@ public class KiwixMobileActivity extends AppCompatActivity {
break;
case R.id.menu_openfile:
- selectZimFile();
+ manageZimFiles();
break;
case R.id.menu_settings:
@@ -791,8 +789,6 @@ public class KiwixMobileActivity extends AppCompatActivity {
}
break;
- case R.id.menu_library:
- openDownloadManager();
default:
break;
}
@@ -801,7 +797,7 @@ public class KiwixMobileActivity extends AppCompatActivity {
}
private void openDownloadManager() {
- Intent downloadIntent = new Intent(this, LibraryActivity.class);
+ Intent downloadIntent = new Intent(this, LibraryFragment.class);
startActivity(downloadIntent);
}
@@ -1498,9 +1494,9 @@ public class KiwixMobileActivity extends AppCompatActivity {
}
}
- public void selectZimFile() {
+ public void manageZimFiles() {
refreshBookmarks();
- final Intent target = new Intent(this, ZimFileSelectActivity.class);
+ final Intent target = new Intent(this, ZimManageActivity.class);
target.setAction(Intent.ACTION_GET_CONTENT);
// The MIME data type filter
target.setType("//");
@@ -1733,7 +1729,7 @@ public class KiwixMobileActivity extends AppCompatActivity {
} else if (url.startsWith(ZimContentProvider.UI_URI.toString())) {
// To handle links which access user interface (i.p. used in help page)
if (url.equals(ZimContentProvider.UI_URI.toString() + "selectzimfile")) {
- selectZimFile();
+ manageZimFiles();
} else if (url.equals(ZimContentProvider.UI_URI.toString() + "gotohelp")) {
showHelp();
} else {
diff --git a/src/org/kiwix/kiwixmobile/LibraryActivity.java b/src/org/kiwix/kiwixmobile/LibraryActivity.java
deleted file mode 100644
index 1871b9edf..000000000
--- a/src/org/kiwix/kiwixmobile/LibraryActivity.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.kiwix.kiwixmobile;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.widget.ListView;
-import android.widget.Toast;
-
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import java.util.List;
-import org.kiwix.kiwixmobile.downloader.DownloadIntent;
-import org.kiwix.kiwixmobile.downloader.DownloadService;
-import org.kiwix.kiwixmobile.library.LibraryAdapter;
-import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity;
-import org.kiwix.kiwixmobile.network.KiwixService;
-import org.kiwix.kiwixmobile.utils.ShortcutUtils;
-
-import rx.android.schedulers.AndroidSchedulers;
-
-import static org.kiwix.kiwixmobile.utils.ShortcutUtils.stringsGetter;
-
-public class LibraryActivity extends AppCompatActivity {
-
- @BindView(R.id.toolbar) Toolbar toolbar;
- @BindView(R.id.library_list) ListView libraryList;
-
- private KiwixService kiwixService;
- private List books;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_library);
- ButterKnife.bind(this);
- setSupportActionBar(toolbar);
- kiwixService = ((KiwixApplication) getApplication()).getKiwixService();
- kiwixService.getLibrary()
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(library -> {
- books = library.getBooks();
- libraryList.setAdapter(new LibraryAdapter(LibraryActivity.this, books));
- });
-
- libraryList.setOnItemClickListener(
- (parent, view, position, id) -> {
- Toast.makeText(LibraryActivity.this, stringsGetter(R.string.download_started_library, this), Toast.LENGTH_LONG).show();
- Intent service = new Intent(this, DownloadService.class);
- service.putExtra(DownloadIntent.DOWNLOAD_URL_PARAMETER, books.get(position).getUrl());
- startService(service);
- });
- }
-}
\ No newline at end of file
diff --git a/src/org/kiwix/kiwixmobile/LibraryFragment.java b/src/org/kiwix/kiwixmobile/LibraryFragment.java
new file mode 100644
index 000000000..be00fced5
--- /dev/null
+++ b/src/org/kiwix/kiwixmobile/LibraryFragment.java
@@ -0,0 +1,89 @@
+package org.kiwix.kiwixmobile;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import java.util.List;
+import org.kiwix.kiwixmobile.downloader.DownloadIntent;
+import org.kiwix.kiwixmobile.downloader.DownloadService;
+import org.kiwix.kiwixmobile.library.LibraryAdapter;
+import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity;
+import org.kiwix.kiwixmobile.network.KiwixService;
+import org.kiwix.kiwixmobile.utils.ShortcutUtils;
+
+import rx.android.schedulers.AndroidSchedulers;
+
+import static org.kiwix.kiwixmobile.utils.ShortcutUtils.stringsGetter;
+
+public class LibraryFragment extends Fragment {
+
+ @BindView(R.id.library_list) ListView libraryList;
+ @BindView(R.id.progressBar) ProgressBar progressBar;
+ @BindView(R.id.progressbar_message) TextView progressText;
+
+ private KiwixService kiwixService;
+
+ private LinearLayout llLayout;
+
+ private List books;
+
+ private boolean active;
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ FragmentActivity faActivity = (FragmentActivity) super.getActivity();
+ // Replace LinearLayout by the type of the root element of the layout you're trying to load
+ llLayout = (LinearLayout) inflater.inflate(R.layout.activity_library, container, false);
+ // Of course you will want to faActivity and llLayout in the class and not this method to access them in the rest of
+ // the class, just initialize them here
+
+ // Don't use this method, it's handled by inflater.inflate() above :
+ // setContentView(R.layout.activity_layout);
+
+ ButterKnife.bind(this, llLayout);
+ kiwixService = ((KiwixApplication) super.getActivity().getApplication()).getKiwixService();
+ kiwixService.getLibrary()
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(library -> {
+ books = library.getBooks();
+ if (active) {
+ libraryList.setAdapter(new LibraryAdapter(super.getActivity(), books));
+ progressBar.setVisibility(View.INVISIBLE);
+ progressText.setVisibility(View.INVISIBLE);
+ }
+ });
+
+ libraryList.setOnItemClickListener(
+ (parent, view, position, id) -> {
+ Toast.makeText(super.getActivity(), stringsGetter(R.string.download_started_library, super.getActivity()), Toast.LENGTH_LONG).show();
+ Intent service = new Intent(super.getActivity(), DownloadService.class);
+ service.putExtra(DownloadIntent.DOWNLOAD_URL_PARAMETER, books.get(position).getUrl());
+ super.getActivity().startService(service);
+ });
+ active = true;
+ // The FragmentActivity doesn't contain the layout directly so we must use our instance of LinearLayout :
+ //llLayout.findViewById(R.id.someGuiElement);
+ // Instead of :
+ // findViewById(R.id.someGuiElement);
+ return llLayout; // We must return the loaded Layout
+ }
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ active = false;
+ }
+
+}
\ No newline at end of file
diff --git a/src/org/kiwix/kiwixmobile/ZimFileSelectActivity.java b/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java
similarity index 77%
rename from src/org/kiwix/kiwixmobile/ZimFileSelectActivity.java
rename to src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java
index b54e6c60a..b343104e2 100644
--- a/src/org/kiwix/kiwixmobile/ZimFileSelectActivity.java
+++ b/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java
@@ -30,6 +30,8 @@ import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.CursorLoader;
@@ -38,6 +40,7 @@ import android.support.v4.widget.SimpleCursorAdapter;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -48,6 +51,7 @@ import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
+import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -59,7 +63,7 @@ import org.kiwix.kiwixmobile.utils.LanguageUtils;
import org.kiwix.kiwixmobile.utils.files.FileSearch;
import org.kiwix.kiwixmobile.utils.files.FileWriter;
-public class ZimFileSelectActivity extends AppCompatActivity
+public class ZimFileSelectFragment extends Fragment
implements LoaderManager.LoaderCallbacks, OnItemClickListener {
public static final String TAG_KIWIX = "kiwix";
@@ -79,44 +83,53 @@ public class ZimFileSelectActivity extends AppCompatActivity
private ProgressBar mProgressBar;
private TextView mProgressBarMessage;
+ public LinearLayout llLayout;
+
+ public static Context context;
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ FragmentActivity faActivity = (FragmentActivity) super.getActivity();
+ context = super.getActivity();
+ // Replace LinearLayout by the type of the root element of the layout you're trying to load
+ llLayout = (LinearLayout) inflater.inflate(R.layout.zim_list, container, false);
+ // Of course you will want to faActivity and llLayout in the class and not this method to access them in the rest of
+ // the class, just initialize them here
- new LanguageUtils(this).changeFont(getLayoutInflater());
+ new LanguageUtils(super.getActivity()).changeFont(super.getActivity().getLayoutInflater());
- setContentView(R.layout.zim_list);
- setUpToolbar();
mFiles = new ArrayList();
+ mProgressBar = (ProgressBar) llLayout.findViewById(R.id.progressBar);
+ mProgressBarMessage = (TextView) llLayout.findViewById(R.id.progressbar_message);
+ mZimFileList = (ListView) llLayout.findViewById(R.id.zimfilelist);
+
+ mZimFileList.setOnItemClickListener(this);
+
+ mProgressBar.setVisibility(View.VISIBLE);
+ setAlpha(true);
+
checkPermissions();
+ // Don't use this method, it's handled by inflater.inflate() above :
+ // setContentView(R.layout.activity_layout);
+
+ // The FragmentActivity doesn't contain the layout directly so we must use our instance of LinearLayout :
+ //llLayout.findViewById(R.id.someGuiElement);
+ // Instead of :
+ // findViewById(R.id.someGuiElement);
+ return llLayout; // We must return the loaded Layout
}
- private void setUpToolbar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- getSupportActionBar().setHomeButtonEnabled(true);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
-
- toolbar.setNavigationOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- });
- }
public void checkPermissions(){
- if (ContextCompat.checkSelfPermission(this,
+ if (ContextCompat.checkSelfPermission(super.getActivity(),
Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED && Build.VERSION.SDK_INT > 18) {
- Toast.makeText(this, getResources().getString(R.string.request_storage), Toast.LENGTH_LONG)
+ Toast.makeText(super.getActivity(), getResources().getString(R.string.request_storage), Toast.LENGTH_LONG)
.show();
- ActivityCompat.requestPermissions(this,
+ ActivityCompat.requestPermissions(super.getActivity(),
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
KiwixMobileActivity.REQUEST_STORAGE_PERMISSION);
@@ -126,21 +139,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
}
public void getFiles(){
-
- mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
- mProgressBarMessage = (TextView) findViewById(R.id.progressbar_message);
- mZimFileList = (ListView) findViewById(R.id.zimfilelist);
-
- mZimFileList.setOnItemClickListener(this);
-
- mProgressBar.setVisibility(View.VISIBLE);
- setAlpha(true);
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
- startQuery();
- } else {
new RescanFileSystem().execute();
- }
}
@Override
@@ -152,7 +151,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
getFiles();
} else {
- finish();
+ super.getActivity().finish();
}
return;
}
@@ -189,7 +188,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
String sortOrder = MediaStore.Files.FileColumns.TITLE; // Sorted alphabetical
Log.d(TAG_KIWIX, " Performing query for zim files...");
- return new CursorLoader(this, uri, projection, query, selectionArgs, sortOrder);
+ return new CursorLoader(super.getActivity(), uri, projection, query, selectionArgs, sortOrder);
}
@Override
@@ -201,7 +200,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
mZimFileList.setAdapter(mRescanAdapter);
// Done here to avoid that shown while loading.
- mZimFileList.setEmptyView(findViewById(R.id.zimfilelist_nozimfilesfound_view));
+ mZimFileList.setEmptyView( llLayout.findViewById(R.id.zimfilelist_nozimfilesfound_view));
if (mProgressBarMessage.getVisibility() == View.GONE) {
mProgressBar.setVisibility(View.GONE);
@@ -216,37 +215,8 @@ public class ZimFileSelectActivity extends AppCompatActivity
mCursorAdapter.swapCursor(null);
}
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- // Check, if the user has rescanned the file system, if he has, then we want to save this list,
- // so this can be shown again, if the activity is recreated (on a device rotation for example)
- if (!mFiles.isEmpty()) {
- Log.i(TAG_KIWIX, "Saved state of the ListView");
- outState.putParcelableArrayList("rescanData", mFiles);
- }
- super.onSaveInstanceState(outState);
- }
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
-
- // Get the rescanned data, if available. Create an Adapter for the ListView and display the list
- if (savedInstanceState.getParcelableArrayList("rescanData") != null) {
- ArrayList data = savedInstanceState.getParcelableArrayList("rescanData");
- mRescanAdapter = new RescanDataAdapter(ZimFileSelectActivity.this, 0, data);
-
- mZimFileList.setAdapter(mRescanAdapter);
- }
- super.onRestoreInstanceState(savedInstanceState);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- final MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu_files, menu);
- return super.onCreateOptionsMenu(menu);
- }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
@@ -264,7 +234,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
}
@Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
+public void onItemClick(AdapterView> parent, View view, int position, long id) {
Log.d(TAG_KIWIX, " mZimFileList.onItemClick");
@@ -299,7 +269,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
mCursorAdapter = new SimpleCursorAdapter(
// The Context object
- ZimFileSelectActivity.this,
+ super.getActivity(),
// A layout in XML for one row in the ListView
android.R.layout.simple_list_item_2,
// The cursor, swapped later by cursorloader
@@ -311,7 +281,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
// Flags for the Adapter
Adapter.NO_SELECTION);
- getSupportLoaderManager().initLoader(LOADER_ID, null, this);
+ super.getActivity().getSupportLoaderManager().initLoader(LOADER_ID, null, this);
}
// Get the data of our cursor and wrap it all in our ArrayAdapter.
@@ -327,7 +297,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
}
}
- files = new FileWriter(ZimFileSelectActivity.this, files).getDataModelList();
+ files = new FileWriter(super.getActivity(), files).getDataModelList();
for (int i = 0; i < files.size(); i++) {
@@ -340,21 +310,20 @@ public class ZimFileSelectActivity extends AppCompatActivity
files = new FileSearch().sortDataModel(files);
mFiles = files;
- return new RescanDataAdapter(ZimFileSelectActivity.this, 0, mFiles);
+ return new RescanDataAdapter(super.getActivity(), 0, mFiles);
}
- // Get the selected file and return the result to the Activity, that called this Activity
private void finishResult(String path) {
if (path != null) {
File file = new File(path);
Uri uri = Uri.fromFile(file);
Log.i(TAG_KIWIX, "Opening " + uri);
- setResult(RESULT_OK, new Intent().setData(uri));
- finish();
+ super.getActivity().setResult(super.getActivity().RESULT_OK, new Intent().setData(uri));
+ super.getActivity().finish();
} else {
- setResult(RESULT_CANCELED);
- finish();
+ super.getActivity().setResult(super.getActivity().RESULT_CANCELED);
+ super.getActivity().finish();
}
}
@@ -430,10 +399,9 @@ public class ZimFileSelectActivity extends AppCompatActivity
mFiles = new FileSearch().findFiles();
return null;
}
-
@Override
protected void onPostExecute(Void result) {
- mRescanAdapter = new RescanDataAdapter(ZimFileSelectActivity.this, 0, mFiles);
+ mRescanAdapter = new RescanDataAdapter(ZimFileSelectFragment.context, 0, mFiles);
mZimFileList.setAdapter(mRescanAdapter);
@@ -441,7 +409,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
mProgressBar.setVisibility(View.GONE);
setAlpha(false);
- new FileWriter(ZimFileSelectActivity.this).saveArray(mFiles);
+ new FileWriter(ZimFileSelectFragment.context).saveArray(mFiles);
super.onPostExecute(result);
}
diff --git a/src/org/kiwix/kiwixmobile/ZimManageActivity.java b/src/org/kiwix/kiwixmobile/ZimManageActivity.java
new file mode 100644
index 000000000..96c04b05b
--- /dev/null
+++ b/src/org/kiwix/kiwixmobile/ZimManageActivity.java
@@ -0,0 +1,135 @@
+package org.kiwix.kiwixmobile;
+
+import android.support.design.widget.TabLayout;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+
+public class ZimManageActivity extends AppCompatActivity {
+
+ /**
+ * The {@link android.support.v4.view.PagerAdapter} that will provide
+ * fragments for each of the sections. We use a
+ * {@link FragmentPagerAdapter} derivative, which will keep every
+ * loaded fragment in memory. If this becomes too memory intensive, it
+ * may be best to switch to a
+ * {@link android.support.v4.app.FragmentStatePagerAdapter}.
+ */
+ private SectionsPagerAdapter mSectionsPagerAdapter;
+
+ /**
+ * The {@link ViewPager} that will host the section contents.
+ */
+ private ViewPager mViewPager;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.zim_manager);
+
+ setUpToolbar();
+ // Create the adapter that will return a fragment for each of the three
+ // primary sections of the activity.
+ mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
+
+ // Set up the ViewPager with the sections adapter.
+ mViewPager = (ViewPager) findViewById(R.id.container);
+ mViewPager.setAdapter(mSectionsPagerAdapter);
+
+ TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
+ tabLayout.setupWithViewPager(mViewPager);
+
+ }
+
+ private void setUpToolbar() {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ // Don't use this method, it's handled by inflater.inflate() above :
+ // setContentView(R.layout.activity_layout);
+
+ getSupportActionBar().setHomeButtonEnabled(true);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setTitle(R.string.zim_manager);
+
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ });
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_zim_manager, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ if (id == R.id.menu_rescan_fs){
+ mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
+ int position = mViewPager.getCurrentItem();
+ mViewPager.setAdapter(mSectionsPagerAdapter);
+ mViewPager.setCurrentItem(position);
+ // mViewPager.notify();
+ }
+ //noinspection SimplifiableIfStatement
+
+ return super.onOptionsItemSelected(item);
+ }
+
+
+ /**
+ * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
+ * one of the sections/tabs/pages.
+ */
+ public class SectionsPagerAdapter extends FragmentPagerAdapter {
+
+ public SectionsPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ // getItem is called to instantiate the fragment for the given page.
+ if (position == 0) {
+ return new ZimFileSelectFragment();
+ } else {
+ return new LibraryFragment();
+ }
+ }
+
+ @Override
+ public int getCount() {
+ // Show 3 total pages.
+ return 2;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ switch (position) {
+ case 0:
+ return getResources().getString(R.string.local_zims);
+ case 1:
+ return getResources().getString(R.string.remote_zims);
+ }
+ return null;
+ }
+ }
+}