Merge branch 'issue-1079--swipe-to-refresh-updates' into 'master'
Allow swipe-to-refresh on categories and updates tab. Closes #1079 See merge request fdroid/fdroidclient!586
This commit is contained in:
commit
85349fb59b
@ -7,6 +7,7 @@ import android.support.design.widget.FloatingActionButton;
|
|||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
@ -15,6 +16,7 @@ import android.widget.FrameLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
|
import org.fdroid.fdroid.UpdateService;
|
||||||
import org.fdroid.fdroid.data.CategoryProvider;
|
import org.fdroid.fdroid.data.CategoryProvider;
|
||||||
import org.fdroid.fdroid.data.Schema;
|
import org.fdroid.fdroid.data.Schema;
|
||||||
import org.fdroid.fdroid.views.apps.AppListActivity;
|
import org.fdroid.fdroid.views.apps.AppListActivity;
|
||||||
@ -54,6 +56,16 @@ class CategoriesViewBinder implements LoaderManager.LoaderCallbacks<Cursor> {
|
|||||||
categoriesList.setLayoutManager(new LinearLayoutManager(activity));
|
categoriesList.setLayoutManager(new LinearLayoutManager(activity));
|
||||||
categoriesList.setAdapter(categoryAdapter);
|
categoriesList.setAdapter(categoryAdapter);
|
||||||
|
|
||||||
|
final SwipeRefreshLayout swipeToRefresh =
|
||||||
|
(SwipeRefreshLayout) categoriesView.findViewById(R.id.swipe_to_refresh);
|
||||||
|
swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
swipeToRefresh.setRefreshing(false);
|
||||||
|
UpdateService.updateNow(activity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
FloatingActionButton searchFab = (FloatingActionButton) categoriesView.findViewById(R.id.btn_search);
|
FloatingActionButton searchFab = (FloatingActionButton) categoriesView.findViewById(R.id.btn_search);
|
||||||
searchFab.setOnClickListener(new View.OnClickListener() {
|
searchFab.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.fdroid.fdroid.views.updates;
|
package org.fdroid.fdroid.views.updates;
|
||||||
|
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
@ -9,6 +10,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
|
import org.fdroid.fdroid.UpdateService;
|
||||||
|
|
||||||
public class UpdatesViewBinder {
|
public class UpdatesViewBinder {
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ public class UpdatesViewBinder {
|
|||||||
private final TextView emptyState;
|
private final TextView emptyState;
|
||||||
private final ImageView emptyImage;
|
private final ImageView emptyImage;
|
||||||
|
|
||||||
public UpdatesViewBinder(AppCompatActivity activity, FrameLayout parent) {
|
public UpdatesViewBinder(final AppCompatActivity activity, FrameLayout parent) {
|
||||||
View view = activity.getLayoutInflater().inflate(R.layout.main_tab_updates, parent, true);
|
View view = activity.getLayoutInflater().inflate(R.layout.main_tab_updates, parent, true);
|
||||||
|
|
||||||
adapter = new UpdatesAdapter(activity);
|
adapter = new UpdatesAdapter(activity);
|
||||||
@ -30,6 +32,16 @@ public class UpdatesViewBinder {
|
|||||||
|
|
||||||
emptyState = (TextView) view.findViewById(R.id.empty_state);
|
emptyState = (TextView) view.findViewById(R.id.empty_state);
|
||||||
emptyImage = (ImageView) view.findViewById(R.id.image);
|
emptyImage = (ImageView) view.findViewById(R.id.image);
|
||||||
|
|
||||||
|
final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swipe_to_refresh);
|
||||||
|
swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
swipeToRefresh.setRefreshing(false);
|
||||||
|
UpdateService.updateNow(activity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind() {
|
public void bind() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.constraint.ConstraintLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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"
|
||||||
@ -7,46 +7,56 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<org.fdroid.fdroid.views.BannerUpdatingRepos
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/banner_updating_repos"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/swipe_to_refresh">
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
tools:layout_editor_absoluteX="8dp" />
|
|
||||||
|
|
||||||
<TextView
|
<android.support.constraint.ConstraintLayout
|
||||||
android:id="@+id/empty_state"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
android:layout_height="match_parent">
|
||||||
android:layout_height="0dp"
|
|
||||||
style="@style/AppListEmptyText"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/categories__empty_state__no_categories" />
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<org.fdroid.fdroid.views.BannerUpdatingRepos
|
||||||
android:id="@+id/category_list"
|
android:id="@+id/banner_updating_repos"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content"
|
||||||
tools:listitem="@layout/category_item"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/banner_updating_repos"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
android:scrollbars="vertical"
|
|
||||||
tools:layout_editor_absoluteX="0dp" />
|
|
||||||
|
|
||||||
<include layout="@layout/fab_search"
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/empty_state"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
style="@style/AppListEmptyText"
|
||||||
android:layout_marginBottom="@dimen/fab_margin"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:layout_marginEnd="@dimen/fab_margin"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
android:layout_marginRight="@dimen/fab_margin" />
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:text="@string/categories__empty_state__no_categories" />
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/category_list"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
tools:listitem="@layout/category_item"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/banner_updating_repos"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
tools:layout_editor_absoluteX="0dp" />
|
||||||
|
|
||||||
|
<include layout="@layout/fab_search"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:layout_marginBottom="@dimen/fab_margin"
|
||||||
|
android:layout_marginEnd="@dimen/fab_margin"
|
||||||
|
android:layout_marginRight="@dimen/fab_margin" />
|
||||||
|
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
@ -1,46 +1,66 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.constraint.ConstraintLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/mainTabSwapBackground">
|
android:id="@+id/swipe_to_refresh">
|
||||||
|
|
||||||
<TextView
|
<android.support.constraint.ConstraintLayout
|
||||||
android:id="@+id/empty_state"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:background="?attr/mainTabSwapBackground">
|
||||||
style="@style/AppListEmptyText"
|
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/empty_can_update_app_list" />
|
|
||||||
|
|
||||||
<ImageView
|
<org.fdroid.fdroid.views.BannerUpdatingRepos
|
||||||
android:id="@+id/image"
|
android:id="@+id/banner_updating_repos"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/no_updates_bg"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:importantForAccessibility="no"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/empty_state"
|
|
||||||
android:tint="?attr/mainTabSwapSplashTint"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<TextView
|
||||||
android:id="@+id/list"
|
android:id="@+id/empty_state"
|
||||||
tools:listitem="@layout/app_list_item"
|
android:layout_width="0dp"
|
||||||
android:layout_width="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="0dp"
|
style="@style/AppListEmptyText"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toBottomOf="@+id/banner_updating_repos"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:visibility="gone"
|
||||||
android:scrollbars="vertical" />
|
android:text="@string/empty_can_update_app_list" />
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
<ImageView
|
||||||
|
android:id="@+id/image"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:src="@drawable/no_updates_bg"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/empty_state"
|
||||||
|
android:tint="?attr/mainTabSwapSplashTint"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/list"
|
||||||
|
tools:listitem="@layout/app_list_item"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/banner_updating_repos"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
android:scrollbars="vertical" />
|
||||||
|
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
Loading…
x
Reference in New Issue
Block a user