mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1014994 - Part 1: Register RemoteTabsPanel. r=margaret
This is the boilerplate to add a new RemoteTabsPanel HomeFragment. At the moment, it merely displays a static view with a static string. The panel title is "Synced Tabs", per yuan's design PDF; and the panel appears at the front (far left) of the list on phones, and at the back (far right) of the list on tablets.
This commit is contained in:
parent
2b1fc35e55
commit
88ae98593f
@ -8,8 +8,8 @@ package org.mozilla.gecko.home;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.home.RemoteTabsPanel;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -39,6 +39,7 @@ public final class HomeConfig {
|
||||
TOP_SITES("top_sites", TopSitesPanel.class),
|
||||
BOOKMARKS("bookmarks", BookmarksPanel.class),
|
||||
HISTORY("history", HistoryPanel.class),
|
||||
REMOTE_TABS("remote_tabs", RemoteTabsPanel.class),
|
||||
READING_LIST("reading_list", ReadingListPanel.class),
|
||||
RECENT_TABS("recent_tabs", RecentTabsPanel.class),
|
||||
DYNAMIC("dynamic", DynamicPanel.class);
|
||||
@ -1495,6 +1496,7 @@ public final class HomeConfig {
|
||||
private static final String READING_LIST_PANEL_ID = "20f4549a-64ad-4c32-93e4-1dcef792733b";
|
||||
private static final String HISTORY_PANEL_ID = "f134bf20-11f7-4867-ab8b-e8e705d7fbe8";
|
||||
private static final String RECENT_TABS_PANEL_ID = "5c2601a5-eedc-4477-b297-ce4cef52adf8";
|
||||
private static final String REMOTE_TABS_PANEL_ID = "72429afd-8d8b-43d8-9189-14b779c563d0";
|
||||
|
||||
private final HomeConfigBackend mBackend;
|
||||
|
||||
@ -1545,6 +1547,11 @@ public final class HomeConfig {
|
||||
id = HISTORY_PANEL_ID;
|
||||
break;
|
||||
|
||||
case REMOTE_TABS:
|
||||
titleId = R.string.home_remote_tabs_title;
|
||||
id = REMOTE_TABS_PANEL_ID;
|
||||
break;
|
||||
|
||||
case READING_LIST:
|
||||
titleId = R.string.reading_list_title;
|
||||
id = READING_LIST_PANEL_ID;
|
||||
|
@ -9,7 +9,6 @@ import static org.mozilla.gecko.home.HomeConfig.createBuiltinPanelConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@ -28,7 +27,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@ -83,15 +81,18 @@ class HomeConfigPrefsBackend implements HomeConfigBackend {
|
||||
|
||||
final PanelConfig historyEntry = createBuiltinPanelConfig(mContext, PanelType.HISTORY);
|
||||
final PanelConfig recentTabsEntry = createBuiltinPanelConfig(mContext, PanelType.RECENT_TABS);
|
||||
final PanelConfig remoteTabsEntry = createBuiltinPanelConfig(mContext, PanelType.REMOTE_TABS);
|
||||
|
||||
// On tablets, the history panel is the last.
|
||||
// On phones, the history panel is the first one.
|
||||
// On tablets, we go [...|History|Recent Tabs|Synced Tabs].
|
||||
// On phones, we go [Synced Tabs|Recent Tabs|History|...].
|
||||
if (HardwareUtils.isTablet()) {
|
||||
panelConfigs.add(historyEntry);
|
||||
panelConfigs.add(recentTabsEntry);
|
||||
panelConfigs.add(remoteTabsEntry);
|
||||
} else {
|
||||
panelConfigs.add(0, historyEntry);
|
||||
panelConfigs.add(0, recentTabsEntry);
|
||||
panelConfigs.add(0, remoteTabsEntry);
|
||||
}
|
||||
|
||||
return new State(panelConfigs, true);
|
||||
|
@ -50,7 +50,7 @@ import android.widget.Toast;
|
||||
* <p>
|
||||
* The containing activity <b>must</b> implement {@link OnUrlOpenListener}.
|
||||
*/
|
||||
abstract class HomeFragment extends Fragment {
|
||||
public abstract class HomeFragment extends Fragment {
|
||||
// Log Tag.
|
||||
private static final String LOGTAG="GeckoHomeFragment";
|
||||
|
||||
|
@ -70,6 +70,7 @@ public class HomePager extends ViewPager {
|
||||
public static final String LIST_TAG_TOP_SITES = "top_sites";
|
||||
public static final String LIST_TAG_RECENT_TABS = "recent_tabs";
|
||||
public static final String LIST_TAG_BROWSER_SEARCH = "browser_search";
|
||||
public static final String LIST_TAG_REMOTE_TABS = "remote_tabs";
|
||||
|
||||
public interface OnUrlOpenListener {
|
||||
public enum Flags {
|
||||
@ -120,8 +121,8 @@ public class HomePager extends ViewPager {
|
||||
LOADED
|
||||
}
|
||||
|
||||
static final String CAN_LOAD_ARG = "canLoad";
|
||||
static final String PANEL_CONFIG_ARG = "panelConfig";
|
||||
public static final String CAN_LOAD_ARG = "canLoad";
|
||||
public static final String PANEL_CONFIG_ARG = "panelConfig";
|
||||
|
||||
public HomePager(Context context) {
|
||||
this(context, null);
|
||||
|
43
mobile/android/base/home/RemoteTabsPanel.java
Normal file
43
mobile/android/base/home/RemoteTabsPanel.java
Normal file
@ -0,0 +1,43 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import org.mozilla.gecko.R;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* A <code>HomeFragment</code> that, depending on the state of accounts on the
|
||||
* device:
|
||||
* <ul>
|
||||
* <li>displays remote tabs from other devices;</li>
|
||||
* <li>offers to re-connect a Firefox Account;</li>
|
||||
* <li>offers to create a new Firefox Account.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class RemoteTabsPanel extends HomeFragment {
|
||||
@SuppressWarnings("unused")
|
||||
private static final String LOGTAG = "GeckoRemoteTabsPanel";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.home_remote_tabs_panel, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
loadIfVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
}
|
||||
}
|
@ -403,6 +403,9 @@ size. -->
|
||||
previous location in the navigation, such as the previous folder -->
|
||||
<!ENTITY home_move_up_to_filter "Up to &formatS;">
|
||||
|
||||
<!ENTITY home_remote_tabs_title "Synced Tabs">
|
||||
<!ENTITY home_remote_tabs_empty "Your tabs from other devices show up here.">
|
||||
|
||||
<!ENTITY private_browsing_title "Private Browsing">
|
||||
<!ENTITY private_tabs_panel_empty_desc "Your private tabs will show up here. While we don\'t keep any of your browsing history or cookies, bookmarks and files that you download will still be saved on your device.">
|
||||
<!ENTITY private_tabs_panel_learn_more "Want to learn more?">
|
||||
|
@ -297,6 +297,7 @@ gbjar.sources += [
|
||||
'home/ReadingListPanel.java',
|
||||
'home/ReadingListRow.java',
|
||||
'home/RecentTabsPanel.java',
|
||||
'home/RemoteTabsPanel.java',
|
||||
'home/SearchEngine.java',
|
||||
'home/SearchEngineRow.java',
|
||||
'home/SearchLoader.java',
|
||||
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/home_remote_tabs_empty" />
|
||||
|
||||
</LinearLayout>
|
@ -351,6 +351,8 @@
|
||||
<string name="home_reading_list_hint_accessible">&home_reading_list_hint_accessible;</string>
|
||||
<string name="home_default_empty">&home_default_empty;</string>
|
||||
<string name="home_move_up_to_filter">&home_move_up_to_filter;</string>
|
||||
<string name="home_remote_tabs_title">&home_remote_tabs_title;</string>
|
||||
<string name="home_remote_tabs_empty">&home_remote_tabs_empty;</string>
|
||||
<string name="private_browsing_title">&private_browsing_title;</string>
|
||||
<string name="private_tabs_panel_empty_desc">&private_tabs_panel_empty_desc;</string>
|
||||
<string name="private_tabs_panel_learn_more">&private_tabs_panel_learn_more;</string>
|
||||
|
Loading…
Reference in New Issue
Block a user