Bug 1148028 - Remove MOZ_ANDROID_SHARE_OVERLAY. r=vivek,nalexander

Fennec ships the Share Overlay everywhere.
This commit is contained in:
Kalpesh Krishna 2015-11-27 12:51:02 -08:00
parent 8735758c91
commit d40608a4b8
11 changed files with 15 additions and 626 deletions

View File

@ -3761,7 +3761,6 @@ MOZ_ANDROID_SEARCH_ACTIVITY=
MOZ_ANDROID_DOWNLOADS_INTEGRATION= MOZ_ANDROID_DOWNLOADS_INTEGRATION=
MOZ_ANDROID_GCM= MOZ_ANDROID_GCM=
MOZ_ANDROID_MLS_STUMBLER= MOZ_ANDROID_MLS_STUMBLER=
MOZ_ANDROID_SHARE_OVERLAY=
MOZ_EXCLUDE_HYPHENATION_DICTIONARIES= MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
MOZ_INSTALL_TRACKING= MOZ_INSTALL_TRACKING=
MOZ_SWITCHBOARD= MOZ_SWITCHBOARD=
@ -4863,13 +4862,6 @@ if test -n "$MOZ_ANDROID_MLS_STUMBLER"; then
AC_DEFINE(MOZ_ANDROID_MLS_STUMBLER) AC_DEFINE(MOZ_ANDROID_MLS_STUMBLER)
fi fi
dnl ========================================================
dnl = Include share overlay on Android
dnl ========================================================
if test -n "$MOZ_ANDROID_SHARE_OVERLAY"; then
AC_DEFINE(MOZ_ANDROID_SHARE_OVERLAY)
fi
dnl = Include Tab Queue on Android dnl = Include Tab Queue on Android
dnl = Temporary build flag to allow development in Nightly dnl = Temporary build flag to allow development in Nightly
dnl ======================================================== dnl ========================================================
@ -8593,7 +8585,6 @@ AC_SUBST(MOZ_ANDROID_GCM)
AC_SUBST(MOZ_ANDROID_GECKOLIBS_AAR) AC_SUBST(MOZ_ANDROID_GECKOLIBS_AAR)
AC_SUBST(MOZ_ANDROID_READING_LIST_SERVICE) AC_SUBST(MOZ_ANDROID_READING_LIST_SERVICE)
AC_SUBST(MOZ_ANDROID_SEARCH_ACTIVITY) AC_SUBST(MOZ_ANDROID_SEARCH_ACTIVITY)
AC_SUBST(MOZ_ANDROID_SHARE_OVERLAY)
AC_SUBST(MOZ_ANDROID_TAB_QUEUE) AC_SUBST(MOZ_ANDROID_TAB_QUEUE)
AC_SUBST(MOZ_ANDROID_MLS_STUMBLER) AC_SUBST(MOZ_ANDROID_MLS_STUMBLER)
AC_SUBST(MOZ_ANDROID_DOWNLOADS_INTEGRATION) AC_SUBST(MOZ_ANDROID_DOWNLOADS_INTEGRATION)

View File

@ -91,9 +91,6 @@ fi
# Mark as WebGL conformant # Mark as WebGL conformant
MOZ_WEBGL_CONFORMANT=1 MOZ_WEBGL_CONFORMANT=1
# Enable the share handler.
MOZ_ANDROID_SHARE_OVERLAY=1
# Enable Tab Queue # Enable Tab Queue
if test "$NIGHTLY_BUILD"; then if test "$NIGHTLY_BUILD"; then
MOZ_ANDROID_TAB_QUEUE=1 MOZ_ANDROID_TAB_QUEUE=1

View File

@ -423,7 +423,6 @@
android:authorities="@ANDROID_PACKAGE_NAME@.db.browser" android:authorities="@ANDROID_PACKAGE_NAME@.db.browser"
android:permission="@ANDROID_PACKAGE_NAME@.permissions.BROWSER_PROVIDER"/> android:permission="@ANDROID_PACKAGE_NAME@.permissions.BROWSER_PROVIDER"/>
#ifdef MOZ_ANDROID_SHARE_OVERLAY
<!-- Share overlay activity <!-- Share overlay activity
Setting launchMode="singleTop" ensures onNewIntent is called when the Activity is Setting launchMode="singleTop" ensures onNewIntent is called when the Activity is
@ -445,7 +444,7 @@
<!-- Service to handle requests from overlays. --> <!-- Service to handle requests from overlays. -->
<service android:name="org.mozilla.gecko.overlays.service.OverlayActionService" /> <service android:name="org.mozilla.gecko.overlays.service.OverlayActionService" />
#endif
<!-- <!--
Ensure that passwords provider runs in its own process. (Bug 718760.) Ensure that passwords provider runs in its own process. (Bug 718760.)
Process name is per-application to avoid loading CPs from multiple Process name is per-application to avoid loading CPs from multiple

View File

@ -1097,9 +1097,7 @@ sync_java_files = [
'sync/Server11RecordPostFailedException.java', 'sync/Server11RecordPostFailedException.java',
'sync/setup/activities/AccountActivity.java', 'sync/setup/activities/AccountActivity.java',
'sync/setup/activities/ActivityUtils.java', 'sync/setup/activities/ActivityUtils.java',
'sync/setup/activities/ClientRecordArrayAdapter.java',
'sync/setup/activities/RedirectToSetupActivity.java', 'sync/setup/activities/RedirectToSetupActivity.java',
'sync/setup/activities/SendTabActivity.java',
'sync/setup/activities/SendTabData.java', 'sync/setup/activities/SendTabData.java',
'sync/setup/activities/SetupFailureActivity.java', 'sync/setup/activities/SetupFailureActivity.java',
'sync/setup/activities/SetupSuccessActivity.java', 'sync/setup/activities/SetupSuccessActivity.java',

View File

@ -6,6 +6,3 @@
if CONFIG['MOZ_ANDROID_SEARCH_ACTIVITY']: if CONFIG['MOZ_ANDROID_SEARCH_ACTIVITY']:
DEFINES['MOZ_ANDROID_SEARCH_ACTIVITY'] = 1 DEFINES['MOZ_ANDROID_SEARCH_ACTIVITY'] = 1
if CONFIG['MOZ_ANDROID_SHARE_OVERLAY']:
DEFINES['MOZ_ANDROID_SHARE_OVERLAY'] = 1

View File

@ -436,6 +436,18 @@ gbjar.sources += [
'NotificationService.java', 'NotificationService.java',
'NSSBridge.java', 'NSSBridge.java',
'OrderedBroadcastHelper.java', 'OrderedBroadcastHelper.java',
'overlays/OverlayConstants.java',
'overlays/service/OverlayActionService.java',
'overlays/service/ShareData.java',
'overlays/service/sharemethods/AddBookmark.java',
'overlays/service/sharemethods/AddToReadingList.java',
'overlays/service/sharemethods/SendTab.java',
'overlays/service/sharemethods/ShareMethod.java',
'overlays/ui/OverlayDialogButton.java',
'overlays/ui/SendTabDeviceListArrayAdapter.java',
'overlays/ui/SendTabList.java',
'overlays/ui/SendTabTargetSelectedListener.java',
'overlays/ui/ShareDialog.java',
'preferences/AlignRightLinkPreference.java', 'preferences/AlignRightLinkPreference.java',
'preferences/AndroidImport.java', 'preferences/AndroidImport.java',
'preferences/AndroidImportPreference.java', 'preferences/AndroidImportPreference.java',
@ -632,22 +644,6 @@ if CONFIG['MOZ_CRASHREPORTER']:
gbjar.sources += [ 'CrashReporter.java' ] gbjar.sources += [ 'CrashReporter.java' ]
ANDROID_RES_DIRS += [ 'crashreporter/res' ] ANDROID_RES_DIRS += [ 'crashreporter/res' ]
if CONFIG['MOZ_ANDROID_SHARE_OVERLAY']:
gbjar.sources += [
'overlays/OverlayConstants.java',
'overlays/service/OverlayActionService.java',
'overlays/service/ShareData.java',
'overlays/service/sharemethods/AddBookmark.java',
'overlays/service/sharemethods/AddToReadingList.java',
'overlays/service/sharemethods/SendTab.java',
'overlays/service/sharemethods/ShareMethod.java',
'overlays/ui/OverlayDialogButton.java',
'overlays/ui/SendTabDeviceListArrayAdapter.java',
'overlays/ui/SendTabList.java',
'overlays/ui/SendTabTargetSelectedListener.java',
'overlays/ui/ShareDialog.java',
]
if (CONFIG['MOZ_ANDROID_MAX_SDK_VERSION']): if (CONFIG['MOZ_ANDROID_MAX_SDK_VERSION']):
max_sdk_version = int(CONFIG['MOZ_ANDROID_MAX_SDK_VERSION']) max_sdk_version = int(CONFIG['MOZ_ANDROID_MAX_SDK_VERSION'])
else: else:
@ -880,7 +876,7 @@ ANDROID_ASSETS_DIRS += [
# appropriate in Makefile.in. # appropriate in Makefile.in.
for var in ('MOZ_ANDROID_ANR_REPORTER', 'MOZ_LINKER_EXTRACT', 'MOZ_DEBUG', for var in ('MOZ_ANDROID_ANR_REPORTER', 'MOZ_LINKER_EXTRACT', 'MOZ_DEBUG',
'MOZ_ANDROID_SEARCH_ACTIVITY', 'MOZ_NATIVE_DEVICES', 'MOZ_ANDROID_MLS_STUMBLER', 'MOZ_ANDROID_SEARCH_ACTIVITY', 'MOZ_NATIVE_DEVICES', 'MOZ_ANDROID_MLS_STUMBLER',
'MOZ_ANDROID_SHARE_OVERLAY', 'MOZ_ANDROID_DOWNLOADS_INTEGRATION', 'MOZ_INSTALL_TRACKING', 'MOZ_ANDROID_DOWNLOADS_INTEGRATION', 'MOZ_INSTALL_TRACKING',
'MOZ_ANDROID_GCM', 'MOZ_ANDROID_TAB_QUEUE'): 'MOZ_ANDROID_GCM', 'MOZ_ANDROID_TAB_QUEUE'):
if CONFIG[var]: if CONFIG[var]:
DEFINES[var] = 1 DEFINES[var] = 1

View File

@ -30,8 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* <li>We execute commands during the "clients" engine stage of a Sync. Each * <li>We execute commands during the "clients" engine stage of a Sync. Each
* command takes a <code>GlobalSession</code> instance as a parameter.</li> * command takes a <code>GlobalSession</code> instance as a parameter.</li>
* <li>We queue commands to be executed or propagated to other Sync clients * <li>We queue commands to be executed or propagated to other Sync clients
* during an activity completely unrelated to a sync (such as * during an activity completely unrelated to a sync</li>
* <code>SendTabActivity</code>.)</li>
* </ol> * </ol>
* To provide a processor for both these time frames, we maintain a static * To provide a processor for both these time frames, we maintain a static
* long-lived singleton. * long-lived singleton.

View File

@ -1,158 +0,0 @@
/* 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.sync.setup.activities;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.mozilla.gecko.R;
import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
public class ClientRecordArrayAdapter extends ArrayAdapter<ClientRecord> {
public static final String LOG_TAG = "ClientRecArrayAdapter";
private boolean[] checkedItems;
private final SendTabActivity sendTabActivity;
public ClientRecordArrayAdapter(Context context,
int textViewResourceId) {
super(context, textViewResourceId, new ArrayList<ClientRecord>());
this.checkedItems = new boolean[0];
this.sendTabActivity = (SendTabActivity) context;
}
public synchronized void setClientRecordList(final Collection<ClientRecord> clientRecordList) {
this.clear();
this.checkedItems = new boolean[clientRecordList.size()];
for (ClientRecord clientRecord : clientRecordList) {
this.add(clientRecord);
}
this.notifyDataSetChanged();
}
/**
* If we have only a single client record in the list, mark it as checked.
*/
public synchronized void checkItem(final int position, boolean checked) throws ArrayIndexOutOfBoundsException {
if (position < 0 ||
position >= checkedItems.length) {
throw new ArrayIndexOutOfBoundsException(position);
}
if (setRowChecked(position, true)) {
this.notifyDataSetChanged();
}
}
/**
* Set the specified row to the specified checked state.
* @param position an index.
* @param checked whether the checkbox should be checked.
* @return <code>true</code> if the state changed, <code>false</code> if the
* box was already in the requested state.
*/
protected synchronized boolean setRowChecked(int position, boolean checked) {
boolean current = checkedItems[position];
if (current == checked) {
return false;
}
checkedItems[position] = checked;
sendTabActivity.enableSend(getNumCheckedGUIDs() > 0);
return true;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final Context context = this.getContext();
// Reuse View objects if they exist.
View row = convertView;
if (row == null) {
row = View.inflate(context, R.layout.sync_list_item, null);
setSelectable(row, true);
row.setBackgroundResource(android.R.drawable.menuitem_background);
}
final ClientRecord clientRecord = this.getItem(position);
ImageView clientType = (ImageView) row.findViewById(R.id.img);
TextView clientName = (TextView) row.findViewById(R.id.client_name);
// Set up checkbox and restore stored state.
CheckBox checkbox = (CheckBox) row.findViewById(R.id.check);
checkbox.setChecked(checkedItems[position]);
setSelectable(checkbox, false);
clientName.setText(clientRecord.name);
clientType.setImageResource(getImage(clientRecord));
row.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
final CheckBox item = (CheckBox) view.findViewById(R.id.check);
// Update the checked item, both in the UI and in our internal state.
final boolean checked = !item.isChecked(); // Because it hasn't happened yet.
item.setChecked(checked);
setRowChecked(position, checked);
}
});
return row;
}
/**
* Get list of checked GUIDs.
*
* @return non-null list.
*/
public synchronized List<String> getCheckedGUIDs() {
final List<String> guids = new ArrayList<String>();
for (int i = 0; i < checkedItems.length; i++) {
if (checkedItems[i]) {
guids.add(this.getItem(i).guid);
}
}
return guids;
}
/**
* Get number of checked GUIDs.
*
* @return non-negative integer.
*/
public synchronized int getNumCheckedGUIDs() {
int numCheckedGUIDs = 0;
for (int i = 0; i < checkedItems.length; i++) {
if (checkedItems[i]) {
numCheckedGUIDs += 1;
}
}
return numCheckedGUIDs;
}
private int getImage(ClientRecord record) {
if ("mobile".equals(record.type)) {
return R.drawable.sync_mobile;
}
return R.drawable.sync_desktop;
}
private void setSelectable(View view, boolean selectable) {
view.setClickable(selectable);
view.setFocusable(selectable);
}
}

View File

@ -1,408 +0,0 @@
/* 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.sync.setup.activities;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.mozilla.gecko.R;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.activities.FxAccountGetStartedActivity;
import org.mozilla.gecko.fxa.activities.FxAccountStatusActivity;
import org.mozilla.gecko.fxa.activities.FxAccountWebFlowActivity;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
import org.mozilla.gecko.fxa.login.State.Action;
import org.mozilla.gecko.sync.CommandProcessor;
import org.mozilla.gecko.sync.CommandRunner;
import org.mozilla.gecko.sync.GlobalSession;
import org.mozilla.gecko.sync.SyncConfiguration;
import org.mozilla.gecko.sync.SyncConstants;
import org.mozilla.gecko.sync.repositories.NullCursorException;
import org.mozilla.gecko.sync.repositories.android.ClientsDatabaseAccessor;
import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
import org.mozilla.gecko.sync.setup.SyncAccounts;
import org.mozilla.gecko.Locales.LocaleAwareActivity;
import org.mozilla.gecko.sync.syncadapter.SyncAdapter;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class SendTabActivity extends LocaleAwareActivity {
private interface TabSender {
public static final String[] STAGES_TO_SYNC = new String[] { "clients", "tabs" };
/**
* @return Return null if the account isn't correctly initialized. Return
* the account GUID otherwise.
*/
String getAccountGUID();
/**
* Sync this account, specifying only clients and tabs as the engines to sync.
*/
void sync();
}
private static class FxAccountTabSender implements TabSender {
private final AndroidFxAccount fxAccount;
public FxAccountTabSender(Context context, AndroidFxAccount fxAccount) {
this.fxAccount = fxAccount;
}
@Override
public String getAccountGUID() {
try {
final SharedPreferences prefs = this.fxAccount.getSyncPrefs();
return prefs.getString(SyncConfiguration.PREF_ACCOUNT_GUID, null);
} catch (Exception e) {
Logger.warn(LOG_TAG, "Could not get Firefox Account parameters or preferences; aborting.");
return null;
}
}
@Override
public void sync() {
fxAccount.requestSync(FirefoxAccounts.FORCE, STAGES_TO_SYNC, null);
}
}
private static class Sync11TabSender implements TabSender {
private final Account account;
private final AccountManager accountManager;
private final Context context;
private Sync11TabSender(Context context, Account syncAccount, AccountManager accountManager) {
this.context = context;
this.account = syncAccount;
this.accountManager = accountManager;
}
@Override
public String getAccountGUID() {
try {
final SharedPreferences prefs = SyncAccounts.blockingPrefsFromDefaultProfileV0(this.context, this.accountManager, this.account);
return prefs.getString(SyncConfiguration.PREF_ACCOUNT_GUID, null);
} catch (Exception e) {
Logger.warn(LOG_TAG, "Could not get Sync account parameters or preferences; aborting.");
return null;
}
}
@Override
public void sync() {
SyncAdapter.requestImmediateSync(this.account, STAGES_TO_SYNC);
}
}
public static final String LOG_TAG = "SendTabActivity";
private ClientRecordArrayAdapter arrayAdapter;
private TabSender tabSender;
private SendTabData sendTabData;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
sendTabData = getSendTabData(getIntent());
} catch (IllegalArgumentException e) {
notifyAndFinish(false);
return;
}
setContentView(R.layout.sync_send_tab);
final ListView listview = (ListView) findViewById(R.id.device_list);
listview.setItemsCanFocus(true);
listview.setTextFilterEnabled(true);
listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
arrayAdapter = new ClientRecordArrayAdapter(this, R.layout.sync_list_item);
listview.setAdapter(arrayAdapter);
TextView textView = (TextView) findViewById(R.id.title);
textView.setText(sendTabData.title);
textView = (TextView) findViewById(R.id.uri);
textView.setText(sendTabData.uri);
enableSend(false);
// Sending will be enabled in onResume, if appropriate.
}
protected static SendTabData getSendTabData(Intent intent) throws IllegalArgumentException {
if (intent == null) {
Logger.warn(LOG_TAG, "intent was null; aborting without sending tab.");
throw new IllegalArgumentException();
}
Bundle extras = intent.getExtras();
if (extras == null) {
Logger.warn(LOG_TAG, "extras was null; aborting without sending tab.");
throw new IllegalArgumentException();
}
SendTabData sendTabData = SendTabData.fromBundle(extras);
if (sendTabData == null) {
Logger.warn(LOG_TAG, "send tab data was null; aborting without sending tab.");
throw new IllegalArgumentException();
}
if (sendTabData.uri == null) {
Logger.warn(LOG_TAG, "uri was null; aborting without sending tab.");
throw new IllegalArgumentException();
}
if (sendTabData.title == null) {
Logger.warn(LOG_TAG, "title was null; ignoring and sending tab anyway.");
}
return sendTabData;
}
/**
* Ensure that the view's list of clients is backed by a recently populated
* array adapter.
*/
protected synchronized void updateClientList(final TabSender sender, final ClientRecordArrayAdapter adapter) {
// Fetching the client list hits the clients database, so we spin this onto
// a background task.
new AsyncTask<Void, Void, Collection<ClientRecord>>() {
@Override
protected Collection<ClientRecord> doInBackground(Void... params) {
return getOtherClients(sender);
}
@Override
protected void onPostExecute(final Collection<ClientRecord> clientArray) {
// We're allowed to update the UI from here.
Logger.debug(LOG_TAG, "Got " + clientArray.size() + " clients.");
adapter.setClientRecordList(clientArray);
if (clientArray.size() == 1) {
adapter.checkItem(0, true);
}
enableSend(adapter.getNumCheckedGUIDs() > 0);
}
}.execute();
}
@Override
public void onResume() {
ActivityUtils.prepareLogging();
Logger.info(LOG_TAG, "Called SendTabActivity.onResume.");
super.onResume();
/*
* First, decide if we are able to send anything.
*/
final Context applicationContext = getApplicationContext();
final AccountManager accountManager = AccountManager.get(applicationContext);
final Account[] fxAccounts = accountManager.getAccountsByType(FxAccountConstants.ACCOUNT_TYPE);
if (fxAccounts.length > 0) {
final AndroidFxAccount fxAccount = new AndroidFxAccount(applicationContext, fxAccounts[0]);
if (fxAccount.getState().getNeededAction() != Action.None) {
// We have a Firefox Account, but it's definitely not able to send a tab
// right now. Redirect to the status activity.
Logger.warn(LOG_TAG, "Firefox Account named like " + fxAccount.getObfuscatedEmail() +
" needs action before it can send a tab; redirecting to status activity.");
redirectToNewTask(FxAccountStatusActivity.class, false);
return;
}
this.tabSender = new FxAccountTabSender(applicationContext, fxAccount);
// will enableSend if appropriate.
updateClientList(tabSender, this.arrayAdapter);
Logger.info(LOG_TAG, "Allowing tab send for Firefox Account.");
registerDisplayURICommand();
return;
}
final Account[] syncAccounts = accountManager.getAccountsByType(SyncConstants.ACCOUNTTYPE_SYNC);
if (syncAccounts.length > 0) {
this.tabSender = new Sync11TabSender(applicationContext, syncAccounts[0], accountManager);
// will enableSend if appropriate.
updateClientList(tabSender, this.arrayAdapter);
Logger.info(LOG_TAG, "Allowing tab send for Sync account.");
registerDisplayURICommand();
return;
}
// Offer to set up a Firefox Account, and finish this activity.
final Intent intent = new Intent(FxAccountConstants.ACTION_FXA_GET_STARTED);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
notifyAndFinish(false);
}
private static void registerDisplayURICommand() {
final CommandProcessor processor = CommandProcessor.getProcessor();
processor.registerCommand("displayURI", new CommandRunner(3) {
@Override
public void executeCommand(final GlobalSession session, List<String> args) {
CommandProcessor.displayURI(args, session.getContext());
}
});
}
public void sendClickHandler(View view) {
Logger.info(LOG_TAG, "Send was clicked.");
final List<String> remoteClientGuids = arrayAdapter.getCheckedGUIDs();
if (remoteClientGuids == null) {
// Should never happen.
Logger.warn(LOG_TAG, "guids was null; aborting without sending tab.");
notifyAndFinish(false);
return;
}
final TabSender sender = this.tabSender;
if (sender == null) {
// This should never happen.
Logger.warn(LOG_TAG, "tabSender was null; aborting without sending tab.");
notifyAndFinish(false);
return;
}
// Fetching local client GUID hits the DB, and we want to update the UI
// afterward, so we perform the tab sending on another thread.
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... params) {
final CommandProcessor processor = CommandProcessor.getProcessor();
final String accountGUID = sender.getAccountGUID();
Logger.debug(LOG_TAG, "Retrieved local account GUID '" + accountGUID + "'.");
if (accountGUID == null) {
return false;
}
for (String remoteClientGuid : remoteClientGuids) {
processor.sendURIToClientForDisplay(sendTabData.uri, remoteClientGuid, sendTabData.title, accountGUID, getApplicationContext());
}
Logger.info(LOG_TAG, "Requesting immediate clients stage sync.");
sender.sync();
return true;
}
@Override
protected void onPostExecute(final Boolean success) {
// We're allowed to update the UI from here.
notifyAndFinish(success);
}
}.execute();
}
/**
* Notify the user about sent tabs status and then finish the activity.
* <p>
* "Success" is a bit of a misnomer: we wrote "displayURI" commands to the local
* command database, and they will be sent on next sync. There is no way to
* verify that the commands were successfully received by the intended remote
* client, so we lie and say they were sent.
*
* @param success true if tab was sent successfully; false otherwise.
*/
protected void notifyAndFinish(final boolean success) {
int textId;
if (success) {
textId = R.string.sync_text_tab_sent;
} else {
textId = R.string.sync_text_tab_not_sent;
}
Toast.makeText(this, textId, Toast.LENGTH_LONG).show();
finish();
}
public void enableSend(boolean shouldEnable) {
View sendButton = findViewById(R.id.send_button);
sendButton.setEnabled(shouldEnable);
sendButton.setClickable(shouldEnable);
}
/**
* @return a map from GUID to client record, including our own.
*/
protected Map<String, ClientRecord> getAllClients() {
ClientsDatabaseAccessor db = new ClientsDatabaseAccessor(this.getApplicationContext());
try {
return db.fetchAllClients();
} catch (NullCursorException e) {
Logger.warn(LOG_TAG, "NullCursorException while populating device list.", e);
return null;
} finally {
db.close();
}
}
/**
* @return a collection of client records, excluding our own.
*/
protected Collection<ClientRecord> getOtherClients(final TabSender sender) {
if (sender == null) {
Logger.warn(LOG_TAG, "No tab sender when fetching other client IDs.");
return new ArrayList<ClientRecord>(0);
}
final Map<String, ClientRecord> all = getAllClients();
if (all == null) {
return new ArrayList<ClientRecord>(0);
}
final String ourGUID = sender.getAccountGUID();
if (ourGUID == null) {
return all.values();
}
final ArrayList<ClientRecord> out = new ArrayList<ClientRecord>(all.size());
for (Entry<String, ClientRecord> entry : all.entrySet()) {
if (ourGUID.equals(entry.getKey())) {
continue;
}
out.add(entry.getValue());
}
return out;
}
// Adapted from FxAccountAbstractActivity.
protected void redirectToNewTask(Class<? extends Activity> activityClass, boolean success) {
Intent intent = new Intent(this, activityClass);
// Per http://stackoverflow.com/a/8992365, this triggers a known bug with
// the soft keyboard not being shown for the started activity. Why, Android, why?
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
notifyAndFinish(success);
}
}

View File

@ -87,9 +87,6 @@ MOZ_WEBGL_CONFORMANT=1
# Enable the Search Activity. # Enable the Search Activity.
MOZ_ANDROID_SEARCH_ACTIVITY=1 MOZ_ANDROID_SEARCH_ACTIVITY=1
# Enable the share handler.
MOZ_ANDROID_SHARE_OVERLAY=1
# Enable the Mozilla Location Service stumbler. # Enable the Mozilla Location Service stumbler.
MOZ_ANDROID_MLS_STUMBLER=1 MOZ_ANDROID_MLS_STUMBLER=1

View File

@ -73,22 +73,3 @@
<action android:name="@MOZ_ANDROID_SHARED_ACCOUNT_TYPE@.accounts.SYNC_ACCOUNT_DELETED_ACTION"/> <action android:name="@MOZ_ANDROID_SHARED_ACCOUNT_TYPE@.accounts.SYNC_ACCOUNT_DELETED_ACTION"/>
</intent-filter> </intent-filter>
</receiver> </receiver>
#ifndef MOZ_ANDROID_SHARE_OVERLAY
<activity
android:theme="@style/SyncTheme"
android:excludeFromRecents="true"
android:icon="@drawable/icon"
android:label="@string/sync_title_send_tab"
android:configChanges="keyboardHidden|orientation|screenSize|locale|layoutDirection"
android:windowSoftInputMode="adjustResize|stateHidden"
android:taskAffinity="org.mozilla.gecko.sync.setup"
android:name="org.mozilla.gecko.sync.setup.activities.SendTabActivity" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
#endif