diff --git a/res/layout-v17/download_item.xml b/res/layout-v17/download_item.xml
new file mode 100644
index 000000000..f54f54eac
--- /dev/null
+++ b/res/layout-v17/download_item.xml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/activity_library.xml b/res/layout/activity_library.xml
index 2cd43212f..95e1092dc 100644
--- a/res/layout/activity_library.xml
+++ b/res/layout/activity_library.xml
@@ -15,26 +15,37 @@
android:layout_height="match_parent"
android:id="@+id/library_list" />
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/download_item.xml b/res/layout/download_item.xml
index 9fdc2b2ad..bbd2cbbdf 100644
--- a/res/layout/download_item.xml
+++ b/res/layout/download_item.xml
@@ -6,69 +6,81 @@
android:weightSum="1">
+ android:layout_width="match_parent"
+ android:descendantFocusability="blocksDescendants"
+ android:layout_height="wrap_content">
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:baselineAligned="false"
+ android:gravity="center">
+ android:orientation="vertical"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:gravity="center" >
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:text="Large Text"
+ android:id="@+id/downloadTitle"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:padding="8dp"/>
+ style="?android:attr/progressBarStyleHorizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/downloadProgress"
+ android:indeterminate="false"
+ android:paddingBottom="10dp"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentLeft="true"
+ android:padding="4dp"/>
-
-
+ android:layout_alignParentRight="true">
-
+
+
+
diff --git a/res/layout/download_management.xml b/res/layout/download_management.xml
index 2ed917e8b..aa4dc489f 100644
--- a/res/layout/download_management.xml
+++ b/res/layout/download_management.xml
@@ -1,11 +1,21 @@
-
+
+
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/res/layout/zim_list.xml b/res/layout/zim_list.xml
index 49c62e492..9fdffa297 100644
--- a/res/layout/zim_list.xml
+++ b/res/layout/zim_list.xml
@@ -28,26 +28,37 @@
android:text="@string/error_nozimfilesfound"
android:visibility="gone"/>
-
-
+ android:layout_height="match_parent"
+ android:id="@+id/progressbar_layout"
+ android:visibility="gone"
+ android:layout_centerInParent="true"
+
+ android:layout_marginTop="300dp">
+
+
+
+
+
+
+
+
-
diff --git a/res/layout/zim_manager.xml b/res/layout/zim_manager.xml
index 1016ac2e8..6bd37a061 100644
--- a/res/layout/zim_manager.xml
+++ b/res/layout/zim_manager.xml
@@ -2,7 +2,7 @@
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"
+ />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e332effcd..d963f1b7a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -102,4 +102,6 @@
play
stop
close
+ No Downloads Here!
+ Download complete
\ No newline at end of file
diff --git a/src/org/kiwix/kiwixmobile/LibraryFragment.java b/src/org/kiwix/kiwixmobile/LibraryFragment.java
index b83c6e67e..f342a1e9b 100644
--- a/src/org/kiwix/kiwixmobile/LibraryFragment.java
+++ b/src/org/kiwix/kiwixmobile/LibraryFragment.java
@@ -11,6 +11,7 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
+import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
@@ -22,6 +23,7 @@ import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -49,8 +51,7 @@ 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;
+ @BindView(R.id.progressbar_layout) RelativeLayout progressBar;
private KiwixService kiwixService;
@@ -79,7 +80,6 @@ public class LibraryFragment extends Fragment {
// 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()
@@ -102,8 +102,7 @@ public class LibraryFragment extends Fragment {
books = booksCopy;
libraryAdapter = new LibraryAdapter(super.getActivity(), books);
libraryList.setAdapter(libraryAdapter);
- progressBar.setVisibility(View.INVISIBLE);
- progressText.setVisibility(View.INVISIBLE);
+ progressBar.setVisibility(View.GONE);
}
});
@@ -127,6 +126,14 @@ public class LibraryFragment extends Fragment {
// findViewById(R.id.someGuiElement);
return llLayout; // We must return the loaded Layout
}
+
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ progressBar.setVisibility(View.VISIBLE);
+
+ }
+
@Override
public void onDestroyView() {
super.onDestroyView();
diff --git a/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java b/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java
index 4f89ae02d..b116ddced 100644
--- a/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java
+++ b/src/org/kiwix/kiwixmobile/ZimFileSelectFragment.java
@@ -56,6 +56,7 @@ import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
@@ -84,7 +85,7 @@ public class ZimFileSelectFragment extends Fragment
private ListView mZimFileList;
- private ProgressBar mProgressBar;
+ private RelativeLayout mProgressBar;
private TextView mProgressBarMessage;
public LinearLayout llLayout;
@@ -96,7 +97,7 @@ public class ZimFileSelectFragment extends Fragment
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);
+ 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
@@ -104,8 +105,8 @@ public class ZimFileSelectFragment extends Fragment
mFiles = new ArrayList();
- mProgressBar = (ProgressBar) llLayout.findViewById(R.id.progressBar);
- mProgressBarMessage = (TextView) llLayout.findViewById(R.id.progressbar_message);
+ mProgressBar = (RelativeLayout) llLayout.findViewById(R.id.progressbar_layout);
+// mProgressBarMessage = (TextView) llLayout.findViewById(R.id.progressbar_message);
mZimFileList = (ListView) llLayout.findViewById(R.id.zimfilelist);
mZimFileList.setOnItemClickListener(this);
@@ -420,7 +421,6 @@ public class ZimFileSelectFragment extends Fragment
@Override
protected void onPreExecute() {
- mProgressBarMessage.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.VISIBLE);
setAlpha(true);
@@ -439,7 +439,6 @@ public class ZimFileSelectFragment extends Fragment
mZimFileList.setAdapter(mRescanAdapter);
- mProgressBarMessage.setVisibility(View.GONE);
mProgressBar.setVisibility(View.GONE);
setAlpha(false);
diff --git a/src/org/kiwix/kiwixmobile/ZimManageActivity.java b/src/org/kiwix/kiwixmobile/ZimManageActivity.java
index bb1352540..06bcbe8bd 100644
--- a/src/org/kiwix/kiwixmobile/ZimManageActivity.java
+++ b/src/org/kiwix/kiwixmobile/ZimManageActivity.java
@@ -104,6 +104,10 @@ public class ZimManageActivity extends AppCompatActivity {
mViewPager.setCurrentItem(2);
}
+ public void displayLocalTab() {
+ mViewPager.setCurrentItem(0);
+ }
+
@Override
public void onBackPressed()
{
diff --git a/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java b/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java
index 1ff293542..512653c5e 100644
--- a/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java
+++ b/src/org/kiwix/kiwixmobile/downloader/DownloadFragment.java
@@ -5,6 +5,9 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.design.widget.CoordinatorLayout;
+import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
@@ -20,7 +23,9 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
import android.widget.TextView;
+import android.widget.Toast;
import org.kiwix.kiwixmobile.LibraryFragment;
import org.kiwix.kiwixmobile.R;
@@ -37,23 +42,41 @@ import java.util.Map;
public class DownloadFragment extends Fragment {
public static LinkedHashMap mDownloads= new LinkedHashMap();
- public LinearLayout llLayout;
- public ListView listView;
+ public RelativeLayout relLayout;
+ public static ListView listView;
public static DownloadAdapter downloadAdapter;
+ private ZimManageActivity zimManageActivity;
+ CoordinatorLayout mainLayout;
+ private static FragmentActivity faActivity;
@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.download_management, 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
+ faActivity = (FragmentActivity) super.getActivity();
+ relLayout = (RelativeLayout) inflater.inflate(R.layout.download_management, container, false);
- listView = (ListView) llLayout.findViewById(R.id.downloadingZims);
+ zimManageActivity = (ZimManageActivity) super.getActivity();
+ listView = (ListView) relLayout.findViewById(R.id.downloadingZims);
downloadAdapter = new DownloadAdapter(mDownloads);
listView.setAdapter(downloadAdapter);
+ mainLayout = (CoordinatorLayout) faActivity.findViewById(R.id.zim_manager_main_activity);
+ return relLayout;
+ }
+
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ updateNoDownloads();
+
+ }
+
+ private static void updateNoDownloads() {
+ TextView noDownloadsText = (TextView) faActivity.findViewById(R.id.download_management_no_downloads);
+ if (listView.getCount() == 0) {
+ noDownloadsText.setVisibility(View.VISIBLE);
+ } else if (listView.getCount() > 0){
+ noDownloadsText.setVisibility(View.GONE);
+ }
- return llLayout;
- // Don't use this method, it's handled by inflater.inflate() above :
}
public class DownloadAdapter extends BaseAdapter {
@@ -86,10 +109,22 @@ public class DownloadFragment extends Fragment {
ProgressBar downloadProgress = (ProgressBar) viewGroup.findViewById(R.id.downloadProgress);
downloadProgress.setProgress(progress);
if (progress == 100){
- Button pause = (Button) viewGroup.findViewById(R.id.pause);
+ ImageView pause = (ImageView) viewGroup.findViewById(R.id.pause);
pause.setEnabled(false);
- Button stop = (Button) viewGroup.findViewById(R.id.stop);
- stop.setText("CLOSE");
+ mDownloads.remove(mKeys[position]);
+ downloadAdapter.notifyDataSetChanged();
+ updateNoDownloads();
+
+
+ Snackbar completeSnack = Snackbar.make(mainLayout, getResources().getString(R.string.download_complete_snackbar), Snackbar.LENGTH_LONG);
+ completeSnack.setAction(getResources().getString(R.string.open), new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ zimManageActivity.displayLocalTab();
+ }
+ })
+ .setActionTextColor(getResources().getColor(R.color.white))
+ .show();
}
}
@@ -109,28 +144,28 @@ public class DownloadFragment extends Fragment {
ProgressBar downloadProgress = (ProgressBar) convertView.findViewById(R.id.downloadProgress);
if (LibraryFragment.mService.downloadStatus.get(mKeys[position]) != null && LibraryFragment.mService.downloadStatus.get(mKeys[position]) == 4) {
downloadProgress.setProgress(100);
- Button pause = (Button) convertView.findViewById(R.id.pause);
+ ImageView pause = (ImageView) convertView.findViewById(R.id.pause);
pause.setEnabled(false);
- Button stop = (Button) convertView.findViewById(R.id.stop);
- stop.setText(getResources().getString(R.string.download_close));
+ ImageView stop = (ImageView) convertView.findViewById(R.id.stop);
+// stop.setText(getResources().getString(R.string.download_close));
}
- Button pause = (Button) convertView.findViewById(R.id.pause);
+ ImageView pause = (ImageView) convertView.findViewById(R.id.pause);
pause.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (LibraryFragment.mService.downloadStatus.get(mKeys[position]) == 0) {
LibraryFragment.mService.pauseDownload(mKeys[position]);
- pause.setText(getResources().getString(R.string.download_play));
+ pause.setImageDrawable(getResources().getDrawable(R.drawable.ic_play_arrow_black_24dp));
} else {
LibraryFragment.mService.playDownload(mKeys[position]);
- pause.setText(getResources().getString(R.string.download_pause));
+ pause.setImageDrawable(getResources().getDrawable(R.drawable.ic_pause_black_24dp));
}
}
});
- Button stop = (Button) convertView.findViewById(R.id.stop);
+ ImageView stop = (ImageView) convertView.findViewById(R.id.stop);
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -157,6 +192,7 @@ public class DownloadFragment extends Fragment {
public static void addDownload(int position, String title){
mDownloads.put(position, title);
downloadAdapter.notifyDataSetChanged();
+ updateNoDownloads();
}
}