зеркало из https://github.com/mozilla/gecko-dev.git
Bug 887268 - Open items from "tabs from last time" on a new tabs (r=bnicholson)
This commit is contained in:
Родитель
7017218cc1
Коммит
08669a8382
|
@ -84,6 +84,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
GeckoLayerClient.OnMetricsChangedListener,
|
||||
BrowserSearch.OnSearchListener,
|
||||
BrowserSearch.OnEditSuggestionListener,
|
||||
HomePager.OnNewTabsListener,
|
||||
HomePager.OnUrlOpenListener {
|
||||
private static final String LOGTAG = "GeckoBrowserApp";
|
||||
|
||||
|
@ -1963,12 +1964,20 @@ abstract public class BrowserApp extends GeckoApp
|
|||
}).execute();
|
||||
}
|
||||
|
||||
// HomePager.OnNewTabsListener
|
||||
@Override
|
||||
public void onNewTabs(String[] urls) {
|
||||
for (String url : urls) {
|
||||
openUrl(url, EditingTarget.NEW_TAB);
|
||||
}
|
||||
}
|
||||
|
||||
// HomePager.OnUrlOpenListener
|
||||
@Override
|
||||
public void onUrlOpen(String url) {
|
||||
openUrl(url);
|
||||
}
|
||||
|
||||
|
||||
// BrowserSearch.OnSearchListener
|
||||
@Override
|
||||
public void onSearch(String engineId, String text) {
|
||||
|
|
|
@ -41,6 +41,10 @@ public class HomePager extends ViewPager {
|
|||
public void onUrlOpen(String url);
|
||||
}
|
||||
|
||||
public interface OnNewTabsListener {
|
||||
public void onNewTabs(String[] urls);
|
||||
}
|
||||
|
||||
public HomePager(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.mozilla.gecko.R;
|
|||
import org.mozilla.gecko.SessionParser;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.db.BrowserContract.Combined;
|
||||
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
|
||||
import org.mozilla.gecko.home.HomePager.OnNewTabsListener;
|
||||
import org.mozilla.gecko.home.TwoLinePageRow;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -60,15 +60,15 @@ public class LastTabsPage extends HomeFragment {
|
|||
// Inflater used by the adapter
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
// On URL open listener
|
||||
private OnUrlOpenListener mUrlOpenListener;
|
||||
// On new tabs listener
|
||||
private OnNewTabsListener mNewTabsListener;
|
||||
|
||||
public static LastTabsPage newInstance() {
|
||||
return new LastTabsPage();
|
||||
}
|
||||
|
||||
public LastTabsPage() {
|
||||
mUrlOpenListener = null;
|
||||
mNewTabsListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,10 +76,10 @@ public class LastTabsPage extends HomeFragment {
|
|||
super.onAttach(activity);
|
||||
|
||||
try {
|
||||
mUrlOpenListener = (OnUrlOpenListener) activity;
|
||||
mNewTabsListener = (OnNewTabsListener) activity;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(activity.toString()
|
||||
+ " must implement HomePager.OnUrlOpenListener");
|
||||
+ " must implement HomePager.OnNewTabsListener");
|
||||
}
|
||||
|
||||
mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
@ -90,7 +90,7 @@ public class LastTabsPage extends HomeFragment {
|
|||
super.onDetach();
|
||||
|
||||
mInflater = null;
|
||||
mUrlOpenListener = null;
|
||||
mNewTabsListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,7 +114,7 @@ public class LastTabsPage extends HomeFragment {
|
|||
}
|
||||
|
||||
final String url = c.getString(c.getColumnIndexOrThrow(Combined.URL));
|
||||
mUrlOpenListener.onUrlOpen(url);
|
||||
mNewTabsListener.onNewTabs(new String[] { url });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче