mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-14 09:57:31 -04:00
New ZIM downloader UI improvements
This commit is contained in:
parent
f20306ac4d
commit
ec9b75f78d
88
res/layout-v17/download_item.xml
Normal file
88
res/layout-v17/download_item.xml
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:weightSum="1">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:descendantFocusability="blocksDescendants"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:baselineAligned="false"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layoutDirection="locale"
|
||||||
|
android:gravity="center" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
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"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
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"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/pause"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:minHeight="35dp"
|
||||||
|
android:minWidth="35dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/download_pause"
|
||||||
|
android:src="@drawable/ic_pause_black_24dp"
|
||||||
|
android:layout_weight="0.5"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/stop"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:minHeight="35dp"
|
||||||
|
android:minWidth="35dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/download_stop"
|
||||||
|
android:src="@drawable/ic_stop_black_24dp"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="8dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -15,14 +15,22 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/library_list" />
|
android:id="@+id/library_list" />
|
||||||
|
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/progressbar_layout"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
|
||||||
|
android:layout_marginTop="300dp">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="?android:attr/progressBarStyleLarge"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true">
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:visibility="visible">
|
|
||||||
</ProgressBar>
|
</ProgressBar>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -35,6 +43,9 @@
|
|||||||
android:layout_below="@id/progressBar"
|
android:layout_below="@id/progressBar"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:visibility="visible"/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -15,13 +15,16 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:baselineAligned="false"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -30,7 +33,8 @@
|
|||||||
android:text="Large Text"
|
android:text="Large Text"
|
||||||
android:id="@+id/downloadTitle"
|
android:id="@+id/downloadTitle"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentStart="true"/>
|
android:layout_alignParentStart="true"
|
||||||
|
android:padding="8dp"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
@ -39,7 +43,9 @@
|
|||||||
android:id="@+id/downloadProgress"
|
android:id="@+id/downloadProgress"
|
||||||
android:indeterminate="false"
|
android:indeterminate="false"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
android:layout_alignParentStart="true"/>
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:padding="4dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -47,28 +53,34 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
>
|
android:layout_alignParentRight="true">
|
||||||
|
|
||||||
<Button
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/pause"
|
android:id="@+id/pause"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:minHeight="50dp"
|
android:layout_alignParentRight="true"
|
||||||
android:minWidth="75dp"
|
android:minHeight="35dp"
|
||||||
|
android:minWidth="35dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:text="@string/download_pause"/>
|
android:text="@string/download_pause"
|
||||||
|
android:src="@drawable/ic_pause_black_24dp"
|
||||||
|
android:layout_weight="0.5"/>
|
||||||
|
|
||||||
<Button
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/stop"
|
android:id="@+id/stop"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:adjustViewBounds="true"
|
android:minHeight="35dp"
|
||||||
android:minHeight="50dp"
|
android:minWidth="35dp"
|
||||||
android:minWidth="75dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:text="@string/download_stop"/>
|
android:text="@string/download_stop"
|
||||||
|
android:src="@drawable/ic_stop_black_24dp"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="8dp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/download_management_no_downloads"
|
||||||
|
android:text="@string/no_downloads_here"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/downloadingZims"/>
|
android:id="@+id/downloadingZims"/>
|
||||||
</LinearLayout>
|
|
||||||
|
</RelativeLayout>
|
@ -28,14 +28,21 @@
|
|||||||
android:text="@string/error_nozimfilesfound"
|
android:text="@string/error_nozimfilesfound"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/progressbar_layout"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
|
||||||
|
android:layout_marginTop="300dp">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="?android:attr/progressBarStyleLarge"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true">
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:visibility="gone">
|
|
||||||
</ProgressBar>
|
</ProgressBar>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -48,6 +55,10 @@
|
|||||||
android:layout_below="@id/progressBar"
|
android:layout_below="@id/progressBar"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:visibility="gone"/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/main_content"
|
android:id="@+id/zim_manager_main_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
@ -36,7 +36,8 @@
|
|||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
@ -102,4 +102,6 @@
|
|||||||
<string name="download_play">play</string>
|
<string name="download_play">play</string>
|
||||||
<string name="download_stop">stop</string>
|
<string name="download_stop">stop</string>
|
||||||
<string name="download_close">close</string>
|
<string name="download_close">close</string>
|
||||||
|
<string name="no_downloads_here">No Downloads Here!</string>
|
||||||
|
<string name="download_complete_snackbar">Download complete</string>
|
||||||
</resources>
|
</resources>
|
@ -11,6 +11,7 @@ import android.os.Handler;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
@ -22,6 +23,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -49,8 +51,7 @@ import static org.kiwix.kiwixmobile.utils.ShortcutUtils.stringsGetter;
|
|||||||
public class LibraryFragment extends Fragment {
|
public class LibraryFragment extends Fragment {
|
||||||
|
|
||||||
@BindView(R.id.library_list) ListView libraryList;
|
@BindView(R.id.library_list) ListView libraryList;
|
||||||
@BindView(R.id.progressBar) ProgressBar progressBar;
|
@BindView(R.id.progressbar_layout) RelativeLayout progressBar;
|
||||||
@BindView(R.id.progressbar_message) TextView progressText;
|
|
||||||
|
|
||||||
|
|
||||||
private KiwixService kiwixService;
|
private KiwixService kiwixService;
|
||||||
@ -79,7 +80,6 @@ public class LibraryFragment extends Fragment {
|
|||||||
|
|
||||||
// Don't use this method, it's handled by inflater.inflate() above :
|
// Don't use this method, it's handled by inflater.inflate() above :
|
||||||
// setContentView(R.layout.activity_layout);
|
// setContentView(R.layout.activity_layout);
|
||||||
|
|
||||||
ButterKnife.bind(this, llLayout);
|
ButterKnife.bind(this, llLayout);
|
||||||
kiwixService = ((KiwixApplication) super.getActivity().getApplication()).getKiwixService();
|
kiwixService = ((KiwixApplication) super.getActivity().getApplication()).getKiwixService();
|
||||||
kiwixService.getLibrary()
|
kiwixService.getLibrary()
|
||||||
@ -102,8 +102,7 @@ public class LibraryFragment extends Fragment {
|
|||||||
books = booksCopy;
|
books = booksCopy;
|
||||||
libraryAdapter = new LibraryAdapter(super.getActivity(), books);
|
libraryAdapter = new LibraryAdapter(super.getActivity(), books);
|
||||||
libraryList.setAdapter(libraryAdapter);
|
libraryList.setAdapter(libraryAdapter);
|
||||||
progressBar.setVisibility(View.INVISIBLE);
|
progressBar.setVisibility(View.GONE);
|
||||||
progressText.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -127,6 +126,14 @@ public class LibraryFragment extends Fragment {
|
|||||||
// findViewById(R.id.someGuiElement);
|
// findViewById(R.id.someGuiElement);
|
||||||
return llLayout; // We must return the loaded Layout
|
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
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
@ -56,6 +56,7 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -84,7 +85,7 @@ public class ZimFileSelectFragment extends Fragment
|
|||||||
|
|
||||||
private ListView mZimFileList;
|
private ListView mZimFileList;
|
||||||
|
|
||||||
private ProgressBar mProgressBar;
|
private RelativeLayout mProgressBar;
|
||||||
|
|
||||||
private TextView mProgressBarMessage;
|
private TextView mProgressBarMessage;
|
||||||
public LinearLayout llLayout;
|
public LinearLayout llLayout;
|
||||||
@ -104,8 +105,8 @@ public class ZimFileSelectFragment extends Fragment
|
|||||||
|
|
||||||
mFiles = new ArrayList<DataModel>();
|
mFiles = new ArrayList<DataModel>();
|
||||||
|
|
||||||
mProgressBar = (ProgressBar) llLayout.findViewById(R.id.progressBar);
|
mProgressBar = (RelativeLayout) llLayout.findViewById(R.id.progressbar_layout);
|
||||||
mProgressBarMessage = (TextView) llLayout.findViewById(R.id.progressbar_message);
|
// mProgressBarMessage = (TextView) llLayout.findViewById(R.id.progressbar_message);
|
||||||
mZimFileList = (ListView) llLayout.findViewById(R.id.zimfilelist);
|
mZimFileList = (ListView) llLayout.findViewById(R.id.zimfilelist);
|
||||||
|
|
||||||
mZimFileList.setOnItemClickListener(this);
|
mZimFileList.setOnItemClickListener(this);
|
||||||
@ -420,7 +421,6 @@ public class ZimFileSelectFragment extends Fragment
|
|||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
|
|
||||||
mProgressBarMessage.setVisibility(View.VISIBLE);
|
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
setAlpha(true);
|
setAlpha(true);
|
||||||
|
|
||||||
@ -439,7 +439,6 @@ public class ZimFileSelectFragment extends Fragment
|
|||||||
|
|
||||||
mZimFileList.setAdapter(mRescanAdapter);
|
mZimFileList.setAdapter(mRescanAdapter);
|
||||||
|
|
||||||
mProgressBarMessage.setVisibility(View.GONE);
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
mProgressBar.setVisibility(View.GONE);
|
||||||
setAlpha(false);
|
setAlpha(false);
|
||||||
|
|
||||||
|
@ -104,6 +104,10 @@ public class ZimManageActivity extends AppCompatActivity {
|
|||||||
mViewPager.setCurrentItem(2);
|
mViewPager.setCurrentItem(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void displayLocalTab() {
|
||||||
|
mViewPager.setCurrentItem(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed()
|
public void onBackPressed()
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,9 @@ import android.content.Context;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.os.Bundle;
|
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.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
|
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
|
||||||
@ -20,7 +23,9 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.kiwix.kiwixmobile.LibraryFragment;
|
import org.kiwix.kiwixmobile.LibraryFragment;
|
||||||
import org.kiwix.kiwixmobile.R;
|
import org.kiwix.kiwixmobile.R;
|
||||||
@ -37,23 +42,41 @@ import java.util.Map;
|
|||||||
public class DownloadFragment extends Fragment {
|
public class DownloadFragment extends Fragment {
|
||||||
|
|
||||||
public static LinkedHashMap<Integer, String> mDownloads= new LinkedHashMap<Integer, String>();
|
public static LinkedHashMap<Integer, String> mDownloads= new LinkedHashMap<Integer, String>();
|
||||||
public LinearLayout llLayout;
|
public RelativeLayout relLayout;
|
||||||
public ListView listView;
|
public static ListView listView;
|
||||||
public static DownloadAdapter downloadAdapter;
|
public static DownloadAdapter downloadAdapter;
|
||||||
|
private ZimManageActivity zimManageActivity;
|
||||||
|
CoordinatorLayout mainLayout;
|
||||||
|
private static FragmentActivity faActivity;
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
FragmentActivity faActivity = (FragmentActivity) super.getActivity();
|
faActivity = (FragmentActivity) super.getActivity();
|
||||||
// Replace LinearLayout by the type of the root element of the layout you're trying to load
|
relLayout = (RelativeLayout) inflater.inflate(R.layout.download_management, container, false);
|
||||||
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
|
|
||||||
|
|
||||||
listView = (ListView) llLayout.findViewById(R.id.downloadingZims);
|
zimManageActivity = (ZimManageActivity) super.getActivity();
|
||||||
|
listView = (ListView) relLayout.findViewById(R.id.downloadingZims);
|
||||||
downloadAdapter = new DownloadAdapter(mDownloads);
|
downloadAdapter = new DownloadAdapter(mDownloads);
|
||||||
listView.setAdapter(downloadAdapter);
|
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 {
|
public class DownloadAdapter extends BaseAdapter {
|
||||||
@ -86,10 +109,22 @@ public class DownloadFragment extends Fragment {
|
|||||||
ProgressBar downloadProgress = (ProgressBar) viewGroup.findViewById(R.id.downloadProgress);
|
ProgressBar downloadProgress = (ProgressBar) viewGroup.findViewById(R.id.downloadProgress);
|
||||||
downloadProgress.setProgress(progress);
|
downloadProgress.setProgress(progress);
|
||||||
if (progress == 100){
|
if (progress == 100){
|
||||||
Button pause = (Button) viewGroup.findViewById(R.id.pause);
|
ImageView pause = (ImageView) viewGroup.findViewById(R.id.pause);
|
||||||
pause.setEnabled(false);
|
pause.setEnabled(false);
|
||||||
Button stop = (Button) viewGroup.findViewById(R.id.stop);
|
mDownloads.remove(mKeys[position]);
|
||||||
stop.setText("CLOSE");
|
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);
|
ProgressBar downloadProgress = (ProgressBar) convertView.findViewById(R.id.downloadProgress);
|
||||||
if (LibraryFragment.mService.downloadStatus.get(mKeys[position]) != null && LibraryFragment.mService.downloadStatus.get(mKeys[position]) == 4) {
|
if (LibraryFragment.mService.downloadStatus.get(mKeys[position]) != null && LibraryFragment.mService.downloadStatus.get(mKeys[position]) == 4) {
|
||||||
downloadProgress.setProgress(100);
|
downloadProgress.setProgress(100);
|
||||||
Button pause = (Button) convertView.findViewById(R.id.pause);
|
ImageView pause = (ImageView) convertView.findViewById(R.id.pause);
|
||||||
pause.setEnabled(false);
|
pause.setEnabled(false);
|
||||||
Button stop = (Button) convertView.findViewById(R.id.stop);
|
ImageView stop = (ImageView) convertView.findViewById(R.id.stop);
|
||||||
stop.setText(getResources().getString(R.string.download_close));
|
// 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() {
|
pause.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (LibraryFragment.mService.downloadStatus.get(mKeys[position]) == 0) {
|
if (LibraryFragment.mService.downloadStatus.get(mKeys[position]) == 0) {
|
||||||
LibraryFragment.mService.pauseDownload(mKeys[position]);
|
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 {
|
} else {
|
||||||
LibraryFragment.mService.playDownload(mKeys[position]);
|
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() {
|
stop.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -157,6 +192,7 @@ public class DownloadFragment extends Fragment {
|
|||||||
public static void addDownload(int position, String title){
|
public static void addDownload(int position, String title){
|
||||||
mDownloads.put(position, title);
|
mDownloads.put(position, title);
|
||||||
downloadAdapter.notifyDataSetChanged();
|
downloadAdapter.notifyDataSetChanged();
|
||||||
|
updateNoDownloads();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user