2014-05-22 18:38:03 -07:00
|
|
|
/* 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/. */
|
|
|
|
|
2014-08-06 07:59:41 -07:00
|
|
|
package org.mozilla.gecko.tabs;
|
2014-05-22 18:38:03 -07:00
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
import org.mozilla.gecko.R;
|
|
|
|
import org.mozilla.gecko.Tabs;
|
|
|
|
import org.mozilla.gecko.fxa.FirefoxAccounts;
|
|
|
|
import org.mozilla.gecko.fxa.activities.FxAccountCreateAccountActivity;
|
2014-08-06 07:59:41 -07:00
|
|
|
import org.mozilla.gecko.tabs.TabsPanel.PanelView;
|
2014-05-22 18:38:03 -07:00
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2014-07-03 13:13:02 -07:00
|
|
|
import android.view.LayoutInflater;
|
2014-05-22 18:38:03 -07:00
|
|
|
import android.view.View;
|
|
|
|
import android.widget.LinearLayout;
|
2014-06-11 14:31:10 -07:00
|
|
|
import android.widget.ScrollView;
|
2014-05-22 18:38:03 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A tabs panel which allows a user to get started setting up a Firefox
|
|
|
|
* Accounts account. Currently used as one sub-panel in a sequence
|
|
|
|
* contained by the {@link RemoteTabsPanel}.
|
|
|
|
*/
|
2014-06-11 14:31:10 -07:00
|
|
|
class RemoteTabsSetupPanel extends ScrollView implements PanelView {
|
2014-07-03 13:13:02 -07:00
|
|
|
private final LinearLayout containingLayout;
|
2014-06-11 14:31:10 -07:00
|
|
|
|
2014-05-22 18:38:03 -07:00
|
|
|
private TabsPanel tabsPanel;
|
|
|
|
|
2014-07-03 13:13:02 -07:00
|
|
|
public RemoteTabsSetupPanel(Context context) {
|
|
|
|
super(context);
|
2014-05-22 18:38:03 -07:00
|
|
|
|
2014-07-03 13:13:02 -07:00
|
|
|
LayoutInflater.from(context).inflate(R.layout.remote_tabs_setup_panel, this);
|
2014-06-11 14:31:10 -07:00
|
|
|
containingLayout = (LinearLayout) findViewById(R.id.remote_tabs_setup_containing_layout);
|
|
|
|
|
|
|
|
final View setupGetStartedButton =
|
|
|
|
containingLayout.findViewById(R.id.remote_tabs_setup_get_started);
|
2014-05-22 18:38:03 -07:00
|
|
|
setupGetStartedButton.setOnClickListener(new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(final View v) {
|
|
|
|
final Context context = getContext();
|
|
|
|
// This Activity will redirect to the correct Activity if the
|
|
|
|
// account is no longer in the setup state.
|
|
|
|
final Intent intent = new Intent(context, FxAccountCreateAccountActivity.class);
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
context.startActivity(intent);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-11 14:31:10 -07:00
|
|
|
final View setupOlderVersionLink =
|
|
|
|
containingLayout.findViewById(R.id.remote_tabs_setup_old_sync_link);
|
2014-05-22 18:38:03 -07:00
|
|
|
setupOlderVersionLink.setOnClickListener(new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(final View v) {
|
|
|
|
final String url = FirefoxAccounts.getOldSyncUpgradeURL(
|
|
|
|
getResources(), Locale.getDefault());
|
|
|
|
Tabs.getInstance().loadUrlInTab(url);
|
|
|
|
if (tabsPanel != null) {
|
|
|
|
tabsPanel.autoHidePanel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setTabsPanel(TabsPanel panel) {
|
|
|
|
tabsPanel = panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void show() {
|
|
|
|
setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void hide() {
|
|
|
|
setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldExpand() {
|
2014-06-11 14:31:10 -07:00
|
|
|
return containingLayout.getOrientation() == LinearLayout.VERTICAL;
|
2014-05-22 18:38:03 -07:00
|
|
|
}
|
|
|
|
}
|