Bug 887269 - Add "Open all previous tabs" button (r=sriram)

This commit is contained in:
Lucas Rocha 2013-07-24 00:33:40 +01:00
parent d76b618369
commit 58c12b54e1
3 changed files with 42 additions and 0 deletions

View File

@ -119,6 +119,14 @@ public class LastTabsPage extends HomeFragment {
});
registerForContextMenu(mList);
final View openAllTabsButton = view.findViewById(R.id.open_all_tabs_button);
openAllTabsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAllTabs();
}
});
}
@Override
@ -142,6 +150,21 @@ public class LastTabsPage extends HomeFragment {
getLoaderManager().initLoader(LAST_TABS_LOADER_ID, null, mCursorLoaderCallbacks);
}
private void openAllTabs() {
final Cursor c = mAdapter.getCursor();
if (c == null || !c.moveToFirst()) {
return;
}
final String[] urls = new String[c.getCount()];
do {
urls[c.getPosition()] = c.getString(c.getColumnIndexOrThrow(Combined.URL));
} while (c.moveToNext());
mNewTabsListener.onNewTabs(urls);
}
private static class LastTabsCursorLoader extends SimpleCursorLoader {
public LastTabsCursorLoader(Context context) {
super(context);

View File

@ -11,4 +11,15 @@
<include layout="@layout/home_list_with_title"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/background_light">
<Button android:id="@+id/open_all_tabs_button"
style="@style/Widget.Home.ActionButton"
android:text="@string/home_last_tabs_open"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>

View File

@ -184,6 +184,10 @@
<item name="android:paddingRight">10dip</item>
</style>
<style name="Widget.Home.ActionButton" parent="Widget.Home.PageButton">
<item name="android:textAppearance">@style/TextAppearance.Widget.Home.PageAction</item>
</style>
<style name="Widget.Home.PageTitle">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">32dp</item>
@ -303,6 +307,10 @@
<style name="TextAppearance.Widget.Home.PageTitle" parent="TextAppearance.Medium" />
<style name="TextAppearance.Widget.Home.PageAction" parent="TextAppearance.Small">
<item name="android:textColor">#00ACFF</item>
</style>
<!-- BrowserToolbar -->
<style name="BrowserToolbar">
<item name="android:layout_width">fill_parent</item>