Search in sources :

Example 81 with Context

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

the class SaveFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();
    final View view = inflater.inflate(R.layout.fragment_save, container, false);
    final ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
    icon.setImageDrawable(IconUtils.loadMimeIcon(context, getArguments().getString(EXTRA_MIME_TYPE)));
    mDisplayName = (EditText) view.findViewById(android.R.id.title);
    mDisplayName.addTextChangedListener(mDisplayNameWatcher);
    mDisplayName.setText(getArguments().getString(EXTRA_DISPLAY_NAME));
    mDisplayName.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // key.
            if (event.getAction() != KeyEvent.ACTION_DOWN) {
                return false;
            }
            // documents once the textView is empty, we are going to trap it here.
            if (keyCode == KeyEvent.KEYCODE_DEL && TextUtils.isEmpty(mDisplayName.getText())) {
                return true;
            }
            if (keyCode == KeyEvent.KEYCODE_ENTER && mSave.isEnabled()) {
                performSave();
                return true;
            }
            return false;
        }
    });
    mSave = (Button) view.findViewById(android.R.id.button1);
    mSave.setOnClickListener(mSaveListener);
    mSave.setEnabled(false);
    mProgress = (ProgressBar) view.findViewById(android.R.id.progress);
    return view;
}
Also used : Context(android.content.Context) KeyEvent(android.view.KeyEvent) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View)

Example 82 with Context

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

the class DocumentHolderTest method setUp.

public void setUp() throws Exception {
    Context context = getContext();
    LayoutInflater inflater = LayoutInflater.from(context);
    mHolder = new DocumentHolder(getContext(), inflater.inflate(R.layout.item_doc_list, null)) {

        @Override
        public void bind(Cursor cursor, String modelId, State state) {
        }
    };
    mListener = new TestListener();
    mHolder.addEventListener(mListener);
    mHolder.itemView.requestLayout();
    mHolder.itemView.invalidate();
}
Also used : Context(android.content.Context) State(com.android.documentsui.State) LayoutInflater(android.view.LayoutInflater) Cursor(android.database.Cursor)

Example 83 with Context

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

the class ModelBackedDocumentsAdapterTest method setUp.

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

Example 84 with Context

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

the class TileAdapter method onCreateViewHolder.

@Override
public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
    final Context context = parent.getContext();
    LayoutInflater inflater = LayoutInflater.from(context);
    if (viewType == TYPE_DIVIDER) {
        return new Holder(inflater.inflate(R.layout.qs_customize_tile_divider, parent, false));
    }
    if (viewType == TYPE_EDIT) {
        return new Holder(inflater.inflate(R.layout.qs_customize_divider, parent, false));
    }
    FrameLayout frame = (FrameLayout) inflater.inflate(R.layout.qs_customize_tile_frame, parent, false);
    frame.addView(new CustomizeTileView(context, new QSIconView(context)));
    return new Holder(frame);
}
Also used : Context(android.content.Context) LayoutInflater(android.view.LayoutInflater) ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) Holder(com.android.systemui.qs.customize.TileAdapter.Holder) FrameLayout(android.widget.FrameLayout) QSIconView(com.android.systemui.qs.QSIconView)

Example 85 with Context

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

the class ServiceWatcher method start.

/**
     * Start this watcher, including binding to the current best match and
     * re-binding to any better matches down the road.
     * <p>
     * Note that if there are no matching encryption-aware services, we may not
     * bind to a real service until after the current user is unlocked.
     *
     * @returns {@code true} if a potential service implementation was found.
     */
public boolean start() {
    if (isServiceMissing())
        return false;
    synchronized (mLock) {
        bindBestPackageLocked(mServicePackageName, false);
    }
    // listen for user change
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
    intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
    mContext.registerReceiverAsUser(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();
            final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
            if (Intent.ACTION_USER_SWITCHED.equals(action)) {
                switchUser(userId);
            } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
                unlockUser(userId);
            }
        }
    }, UserHandle.ALL, intentFilter, null, mHandler);
    // listen for relevant package changes if service overlay is enabled.
    if (mServicePackageName == null) {
        mPackageMonitor.register(mContext, null, UserHandle.ALL, true);
    }
    return true;
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

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