Search in sources :

Example 61 with Context

use of android.content.Context in project platform_frameworks_base by android.

the class GridTouchVerticalSpacingStackFromBottomTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mActivity = getActivity();
    mGridView = getActivity().getGridView();
    final Context context = mActivity.getApplicationContext();
    mViewConfig = ViewConfiguration.get(context);
}
Also used : Context(android.content.Context)

Example 62 with Context

use of android.content.Context in project platform_frameworks_base by android.

the class MtpDevice method open.

/**
     * Opens the MTP device.  Once the device is open it takes ownership of the
     * {@link android.hardware.usb.UsbDeviceConnection}.
     * The connection will be closed when you call {@link #close()}
     * The connection will also be closed if this method fails.
     *
     * @param connection an open {@link android.hardware.usb.UsbDeviceConnection} for the device
     * @return true if the device was successfully opened.
     */
public boolean open(UsbDeviceConnection connection) {
    boolean result = false;
    Context context = connection.getContext();
    if (context != null) {
        UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
        if (!userManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER)) {
            result = native_open(mDevice.getDeviceName(), connection.getFileDescriptor());
        }
    }
    if (!result) {
        connection.close();
    }
    return result;
}
Also used : Context(android.content.Context) UserManager(android.os.UserManager)

Example 63 with Context

use of android.content.Context in project platform_frameworks_base by android.

the class NfcAdapterExtras method get.

/**
     * Get the {@link NfcAdapterExtras} for the given {@link NfcAdapter}.
     *
     * <p class="note">
     * Requires the {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} permission.
     *
     * @param adapter a {@link NfcAdapter}, must not be null
     * @return the {@link NfcAdapterExtras} object for the given {@link NfcAdapter}
     */
public static NfcAdapterExtras get(NfcAdapter adapter) {
    Context context = adapter.getContext();
    if (context == null) {
        throw new UnsupportedOperationException("You must pass a context to your NfcAdapter to use the NFC extras APIs");
    }
    synchronized (NfcAdapterExtras.class) {
        if (sService == null) {
            initService(adapter);
        }
        NfcAdapterExtras extras = sNfcExtras.get(adapter);
        if (extras == null) {
            extras = new NfcAdapterExtras(adapter);
            sNfcExtras.put(adapter, extras);
        }
        return extras;
    }
}
Also used : Context(android.content.Context) INfcAdapterExtras(android.nfc.INfcAdapterExtras)

Example 64 with Context

use of android.content.Context in project platform_frameworks_base by android.

the class NekoLand method showNameDialog.

private void showNameDialog(final Cat cat) {
    final Context context = new ContextThemeWrapper(this, android.R.style.Theme_Material_Light_Dialog_NoActionBar);
    // TODO: Move to XML, add correct margins.
    View view = LayoutInflater.from(context).inflate(R.layout.edit_text, null);
    final EditText text = (EditText) view.findViewById(android.R.id.edit);
    text.setText(cat.getName());
    text.setSelection(cat.getName().length());
    final int size = context.getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);
    Drawable catIcon = cat.createIcon(this, size, size).loadDrawable(this);
    new AlertDialog.Builder(context).setTitle(" ").setIcon(catIcon).setView(view).setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            cat.logRename(context);
            cat.setName(text.getText().toString().trim());
            mPrefs.addCat(cat);
        }
    }).show();
}
Also used : Context(android.content.Context) EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper) DialogInterface(android.content.DialogInterface) Drawable(android.graphics.drawable.Drawable) OnClickListener(android.content.DialogInterface.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 65 with Context

use of android.content.Context in project platform_frameworks_base by android.

the class SectionBreakDocumentsAdapterWrapperTest method setUp.

public void setUp() {
    final Context testContext = TestContext.createStorageTestContext(getContext(), AUTHORITY);
    DocumentsAdapter.Environment env = new TestEnvironment(testContext);
    mModel = new TestModel(AUTHORITY);
    mAdapter = new SectionBreakDocumentsAdapterWrapper(env, new ModelBackedDocumentsAdapter(env, new IconHelper(testContext, State.MODE_GRID)));
    mModel.addUpdateListener(mAdapter);
}
Also used : Context(android.content.Context)

Aggregations

Context (android.content.Context)3233 Intent (android.content.Intent)676 View (android.view.View)400 Test (org.junit.Test)346 BroadcastReceiver (android.content.BroadcastReceiver)338 IntentFilter (android.content.IntentFilter)301 TextView (android.widget.TextView)258 Resources (android.content.res.Resources)226 PendingIntent (android.app.PendingIntent)188 PackageManager (android.content.pm.PackageManager)164 File (java.io.File)156 IOException (java.io.IOException)150 LayoutInflater (android.view.LayoutInflater)139 ImageView (android.widget.ImageView)135 Drawable (android.graphics.drawable.Drawable)128 Uri (android.net.Uri)115 RemoteException (android.os.RemoteException)102 ArrayList (java.util.ArrayList)102 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)101 Bundle (android.os.Bundle)95