mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -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,26 +15,37 @@
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/library_list" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="visible">
|
||||
</ProgressBar>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progressbar_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/rescan_fs_warning"
|
||||
android:paddingTop="10px"
|
||||
android:textStyle="bold"
|
||||
android:layout_below="@id/progressBar"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="visible"/>
|
||||
<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
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true">
|
||||
</ProgressBar>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progressbar_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/rescan_fs_warning"
|
||||
android:paddingTop="10px"
|
||||
android:textStyle="bold"
|
||||
android:layout_below="@id/progressBar"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
@ -6,69 +6,81 @@
|
||||
android:weightSum="1">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:layout_height="wrap_content">
|
||||
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: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:orientation="vertical"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
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: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"/>
|
||||
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"
|
||||
>
|
||||
|
||||
<Button
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/pause"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:minHeight="50dp"
|
||||
android:minWidth="75dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/download_pause"/>
|
||||
android:layout_alignParentRight="true">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/stop"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:minHeight="50dp"
|
||||
android:minWidth="75dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/download_stop"/>
|
||||
<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>
|
||||
|
||||
|
@ -1,11 +1,21 @@
|
||||
<?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:layout_width="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
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/downloadingZims"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
@ -28,26 +28,37 @@
|
||||
android:text="@string/error_nozimfilesfound"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone">
|
||||
</ProgressBar>
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/progressbar_layout"
|
||||
android:visibility="gone"
|
||||
android:layout_centerInParent="true"
|
||||
|
||||
android:layout_marginTop="300dp">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true">
|
||||
</ProgressBar>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progressbar_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/rescan_fs_warning"
|
||||
android:paddingTop="10px"
|
||||
android:textStyle="bold"
|
||||
android:layout_below="@id/progressBar"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progressbar_message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/rescan_fs_warning"
|
||||
android:paddingTop="10px"
|
||||
android:textStyle="bold"
|
||||
android:layout_below="@id/progressBar"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
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_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
@ -36,7 +36,8 @@
|
||||
android:id="@+id/container"
|
||||
android:layout_width="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>
|
||||
|
@ -102,4 +102,6 @@
|
||||
<string name="download_play">play</string>
|
||||
<string name="download_stop">stop</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>
|
@ -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();
|
||||
|
@ -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<DataModel>();
|
||||
|
||||
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);
|
||||
|
||||
|
@ -104,6 +104,10 @@ public class ZimManageActivity extends AppCompatActivity {
|
||||
mViewPager.setCurrentItem(2);
|
||||
}
|
||||
|
||||
public void displayLocalTab() {
|
||||
mViewPager.setCurrentItem(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
|
@ -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<Integer, String> mDownloads= new LinkedHashMap<Integer, String>();
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user