Search in sources :

Example 41 with LayoutInflater

use of android.view.LayoutInflater in project platform_frameworks_base by android.

the class NavigationBarInflaterView method inflateButton.

@Nullable
protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape, int indexInParent) {
    LayoutInflater inflater = landscape ? mLandscapeInflater : mLayoutInflater;
    float size = extractSize(buttonSpec);
    String button = extractButton(buttonSpec);
    View v = null;
    if (HOME.equals(button)) {
        v = inflater.inflate(R.layout.home, parent, false);
        if (landscape && isSw600Dp()) {
            setupLandButton(v);
        }
    } else if (BACK.equals(button)) {
        v = inflater.inflate(R.layout.back, parent, false);
        if (landscape && isSw600Dp()) {
            setupLandButton(v);
        }
    } else if (RECENT.equals(button)) {
        v = inflater.inflate(R.layout.recent_apps, parent, false);
        if (landscape && isSw600Dp()) {
            setupLandButton(v);
        }
    } else if (MENU_IME.equals(button)) {
        v = inflater.inflate(R.layout.menu_ime, parent, false);
    } else if (NAVSPACE.equals(button)) {
        v = inflater.inflate(R.layout.nav_key_space, parent, false);
    } else if (CLIPBOARD.equals(button)) {
        v = inflater.inflate(R.layout.clipboard, parent, false);
    } else if (button.startsWith(KEY)) {
        String uri = extractImage(button);
        int code = extractKeycode(button);
        v = inflater.inflate(R.layout.custom_key, parent, false);
        ((KeyButtonView) v).setCode(code);
        if (uri != null) {
            ((KeyButtonView) v).loadAsync(uri);
        }
    } else {
        return null;
    }
    if (size != 0) {
        ViewGroup.LayoutParams params = v.getLayoutParams();
        params.width = (int) (params.width * size);
    }
    parent.addView(v);
    addToDispatchers(v, landscape);
    View lastView = landscape ? mLastRot90 : mLastRot0;
    if (lastView != null) {
        v.setAccessibilityTraversalAfter(lastView.getId());
    }
    if (landscape) {
        mLastRot90 = v;
    } else {
        mLastRot0 = v;
    }
    return v;
}
Also used : KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) KeyButtonView(com.android.systemui.statusbar.policy.KeyButtonView) View(android.view.View) Nullable(android.annotation.Nullable)

Example 42 with LayoutInflater

use of android.view.LayoutInflater in project platform_frameworks_base by android.

the class PipRecentsOverlayManager method initViews.

private void initViews(Context context) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mOverlayView = inflater.inflate(R.layout.tv_pip_recents_overlay, null);
    mPipControlsView = (PipRecentsControlsView) mOverlayView.findViewById(R.id.pip_controls);
    mRecentsView = mOverlayView.findViewById(R.id.recents);
    mRecentsView.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                clearFocus();
            }
        }
    });
    mOverlayView.measure(UNSPECIFIED, UNSPECIFIED);
    mPipRecentsControlsViewLayoutParams = new WindowManager.LayoutParams(mOverlayView.getMeasuredWidth(), mOverlayView.getMeasuredHeight(), LayoutParams.TYPE_SYSTEM_DIALOG, LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT);
    mPipRecentsControlsViewLayoutParams.gravity = TOP | CENTER_HORIZONTAL;
    mPipRecentsControlsViewFocusedLayoutParams = new WindowManager.LayoutParams(mOverlayView.getMeasuredWidth(), mOverlayView.getMeasuredHeight(), LayoutParams.TYPE_SYSTEM_DIALOG, 0, PixelFormat.TRANSLUCENT);
    mPipRecentsControlsViewFocusedLayoutParams.gravity = TOP | CENTER_HORIZONTAL;
}
Also used : LayoutInflater(android.view.LayoutInflater) LayoutParams(android.view.WindowManager.LayoutParams) View(android.view.View) WindowManager(android.view.WindowManager)

Example 43 with LayoutInflater

use of android.view.LayoutInflater in project platform_frameworks_base by android.

the class UsbConfirmActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Intent intent = getIntent();
    mDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
    mAccessory = (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
    mResolveInfo = (ResolveInfo) intent.getParcelableExtra("rinfo");
    PackageManager packageManager = getPackageManager();
    String appName = mResolveInfo.loadLabel(packageManager).toString();
    final AlertController.AlertParams ap = mAlertParams;
    ap.mIcon = mResolveInfo.loadIcon(packageManager);
    ap.mTitle = appName;
    if (mDevice == null) {
        ap.mMessage = getString(R.string.usb_accessory_confirm_prompt, appName);
        mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mAccessory);
    } else {
        ap.mMessage = getString(R.string.usb_device_confirm_prompt, appName);
        mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mDevice);
    }
    ap.mPositiveButtonText = getString(android.R.string.ok);
    ap.mNegativeButtonText = getString(android.R.string.cancel);
    ap.mPositiveButtonListener = this;
    ap.mNegativeButtonListener = this;
    // add "always use" checkbox
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ap.mView = inflater.inflate(com.android.internal.R.layout.always_use_checkbox, null);
    mAlwaysUse = (CheckBox) ap.mView.findViewById(com.android.internal.R.id.alwaysUse);
    if (mDevice == null) {
        mAlwaysUse.setText(R.string.always_use_accessory);
    } else {
        mAlwaysUse.setText(R.string.always_use_device);
    }
    mAlwaysUse.setOnCheckedChangeListener(this);
    mClearDefaultHint = (TextView) ap.mView.findViewById(com.android.internal.R.id.clearDefaultHint);
    mClearDefaultHint.setVisibility(View.GONE);
    setupAlert();
}
Also used : PackageManager(android.content.pm.PackageManager) LayoutInflater(android.view.LayoutInflater) Intent(android.content.Intent) AlertController(com.android.internal.app.AlertController)

Example 44 with LayoutInflater

use of android.view.LayoutInflater in project platform_frameworks_base by android.

the class UsbDebuggingActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (SystemProperties.getInt("service.adb.tcp.port", 0) == 0) {
        mDisconnectedReceiver = new UsbDisconnectedReceiver(this);
    }
    Intent intent = getIntent();
    String fingerprints = intent.getStringExtra("fingerprints");
    mKey = intent.getStringExtra("key");
    if (fingerprints == null || mKey == null) {
        finish();
        return;
    }
    final AlertController.AlertParams ap = mAlertParams;
    ap.mTitle = getString(R.string.usb_debugging_title);
    ap.mMessage = getString(R.string.usb_debugging_message, fingerprints);
    ap.mPositiveButtonText = getString(android.R.string.ok);
    ap.mNegativeButtonText = getString(android.R.string.cancel);
    ap.mPositiveButtonListener = this;
    ap.mNegativeButtonListener = this;
    // add "always allow" checkbox
    LayoutInflater inflater = LayoutInflater.from(ap.mContext);
    View checkbox = inflater.inflate(com.android.internal.R.layout.always_use_checkbox, null);
    mAlwaysAllow = (CheckBox) checkbox.findViewById(com.android.internal.R.id.alwaysUse);
    mAlwaysAllow.setText(getString(R.string.usb_debugging_always));
    ap.mView = checkbox;
    setupAlert();
}
Also used : LayoutInflater(android.view.LayoutInflater) Intent(android.content.Intent) AlertController(com.android.internal.app.AlertController) View(android.view.View)

Example 45 with LayoutInflater

use of android.view.LayoutInflater in project platform_frameworks_base by android.

the class AppWidgetHostView method getDefaultView.

/**
     * Inflate and return the default layout requested by AppWidget provider.
     */
protected View getDefaultView() {
    if (LOGD) {
        Log.d(TAG, "getDefaultView");
    }
    View defaultView = null;
    Exception exception = null;
    try {
        if (mInfo != null) {
            Context theirContext = getRemoteContext();
            mRemoteContext = theirContext;
            LayoutInflater inflater = (LayoutInflater) theirContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            inflater = inflater.cloneInContext(theirContext);
            inflater.setFilter(sInflaterFilter);
            AppWidgetManager manager = AppWidgetManager.getInstance(mContext);
            Bundle options = manager.getAppWidgetOptions(mAppWidgetId);
            int layoutId = mInfo.initialLayout;
            if (options.containsKey(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY)) {
                int category = options.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY);
                if (category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) {
                    int kgLayoutId = mInfo.initialKeyguardLayout;
                    // If a default keyguard layout is not specified, use the standard
                    // default layout.
                    layoutId = kgLayoutId == 0 ? layoutId : kgLayoutId;
                }
            }
            defaultView = inflater.inflate(layoutId, this, false);
        } else {
            Log.w(TAG, "can't inflate defaultView because mInfo is missing");
        }
    } catch (RuntimeException e) {
        exception = e;
    }
    if (exception != null) {
        Log.w(TAG, "Error inflating AppWidget " + mInfo + ": " + exception.toString());
    }
    if (defaultView == null) {
        if (LOGD)
            Log.d(TAG, "getDefaultView couldn't find any view, so inflating error");
        defaultView = getErrorView();
    }
    return defaultView;
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) LayoutInflater(android.view.LayoutInflater) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Paint(android.graphics.Paint)

Aggregations

LayoutInflater (android.view.LayoutInflater)1292 View (android.view.View)803 TextView (android.widget.TextView)615 ImageView (android.widget.ImageView)259 ViewGroup (android.view.ViewGroup)139 Context (android.content.Context)131 ListView (android.widget.ListView)123 LinearLayout (android.widget.LinearLayout)106 RecyclerView (android.support.v7.widget.RecyclerView)104 AdapterView (android.widget.AdapterView)100 Intent (android.content.Intent)92 AlertDialog (android.app.AlertDialog)88 DialogInterface (android.content.DialogInterface)81 Button (android.widget.Button)57 Bundle (android.os.Bundle)54 FrameLayout (android.widget.FrameLayout)49 TypedArray (android.content.res.TypedArray)43 Activity (android.app.Activity)41 AlertDialog (android.support.v7.app.AlertDialog)41 EditText (android.widget.EditText)41