Added search floating action button to Overview and Categories screen.
Both times it launches the AppListActivity with an empty search box focussed.
This commit is contained in:
parent
7209ab87f5
commit
908d5f3a05
@ -1,7 +1,9 @@
|
|||||||
package org.fdroid.fdroid.views.main;
|
package org.fdroid.fdroid.views.main;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
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;
|
||||||
@ -14,6 +16,7 @@ import android.widget.FrameLayout;
|
|||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
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.categories.CategoryAdapter;
|
import org.fdroid.fdroid.views.categories.CategoryAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +31,7 @@ class CategoriesViewBinder implements LoaderManager.LoaderCallbacks<Cursor> {
|
|||||||
private final CategoryAdapter categoryAdapter;
|
private final CategoryAdapter categoryAdapter;
|
||||||
private final AppCompatActivity activity;
|
private final AppCompatActivity activity;
|
||||||
|
|
||||||
CategoriesViewBinder(AppCompatActivity activity, FrameLayout parent) {
|
CategoriesViewBinder(final AppCompatActivity activity, FrameLayout parent) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
|
|
||||||
View categoriesView = activity.getLayoutInflater().inflate(R.layout.main_tab_categories, parent, true);
|
View categoriesView = activity.getLayoutInflater().inflate(R.layout.main_tab_categories, parent, true);
|
||||||
@ -40,6 +43,14 @@ class CategoriesViewBinder implements LoaderManager.LoaderCallbacks<Cursor> {
|
|||||||
categoriesList.setLayoutManager(new LinearLayoutManager(activity));
|
categoriesList.setLayoutManager(new LinearLayoutManager(activity));
|
||||||
categoriesList.setAdapter(categoryAdapter);
|
categoriesList.setAdapter(categoryAdapter);
|
||||||
|
|
||||||
|
FloatingActionButton searchFab = (FloatingActionButton) categoriesView.findViewById(R.id.btn_search);
|
||||||
|
searchFab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
activity.startActivity(new Intent(activity, AppListActivity.class));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
activity.getSupportLoaderManager().initLoader(LOADER_ID, null, this);
|
activity.getSupportLoaderManager().initLoader(LOADER_ID, null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package org.fdroid.fdroid.views.main;
|
package org.fdroid.fdroid.views.main;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
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;
|
||||||
@ -16,6 +18,7 @@ import org.fdroid.fdroid.R;
|
|||||||
import org.fdroid.fdroid.UpdateService;
|
import org.fdroid.fdroid.UpdateService;
|
||||||
import org.fdroid.fdroid.data.AppProvider;
|
import org.fdroid.fdroid.data.AppProvider;
|
||||||
import org.fdroid.fdroid.data.Schema;
|
import org.fdroid.fdroid.data.Schema;
|
||||||
|
import org.fdroid.fdroid.views.apps.AppListActivity;
|
||||||
import org.fdroid.fdroid.views.whatsnew.WhatsNewAdapter;
|
import org.fdroid.fdroid.views.whatsnew.WhatsNewAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,6 +55,14 @@ class WhatsNewViewBinder implements LoaderManager.LoaderCallbacks<Cursor> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
FloatingActionButton searchFab = (FloatingActionButton) whatsNewView.findViewById(R.id.btn_search);
|
||||||
|
searchFab.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
activity.startActivity(new Intent(activity, AppListActivity.class));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
activity.getSupportLoaderManager().initLoader(LOADER_ID, null, this);
|
activity.getSupportLoaderManager().initLoader(LOADER_ID, null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
app/src/main/res/layout/fab_search.xml
Normal file
11
app/src/main/res/layout/fab_search.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/btn_search"
|
||||||
|
android:src="@drawable/ic_search_white"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginBottom="@dimen/fab_margin"
|
||||||
|
android:layout_marginEnd="@dimen/fab_margin"
|
||||||
|
android:layout_marginRight="@dimen/fab_margin" />
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout 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:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@ -16,4 +17,6 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:scrollbars="vertical" />
|
android:scrollbars="vertical" />
|
||||||
|
|
||||||
</LinearLayout>
|
<include layout="@layout/fab_search" />
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout 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:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@ -23,4 +24,6 @@
|
|||||||
|
|
||||||
</android.support.v4.widget.SwipeRefreshLayout>
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
<include layout="@layout/fab_search" />
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
7
app/src/main/res/values-sw720dp-v21/dimens.xml
Normal file
7
app/src/main/res/values-sw720dp-v21/dimens.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- The material design specs indicate a 24dp margin on tablets should be used (hence this
|
||||||
|
file differing from values-v21/dimens.xml):
|
||||||
|
https://material.google.com/components/buttons-floating-action-button.html -->
|
||||||
|
<dimen name="fab_margin">24dp</dimen>
|
||||||
|
</resources>
|
@ -18,6 +18,8 @@
|
|||||||
<!-- The selected item stands out from the background by this elevation -->
|
<!-- The selected item stands out from the background by this elevation -->
|
||||||
<dimen name="details_screenshot_selected_elevation">3dp</dimen>
|
<dimen name="details_screenshot_selected_elevation">3dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
|
|
||||||
<dimen name="whats_new__padding__app_card__horizontal">12dp</dimen>
|
<dimen name="whats_new__padding__app_card__horizontal">12dp</dimen>
|
||||||
<dimen name="whats_new__padding__app_card__vertical">10dp</dimen>
|
<dimen name="whats_new__padding__app_card__vertical">10dp</dimen>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user