Search in sources :

Example 16 with FrameLayout

use of android.widget.FrameLayout in project GreenDroid by cyrilmottier.

the class GDActivity method setActionBarContentView.

/**
     * <p>
     * Set the activity content to an explicit view. This view is placed
     * directly into the activity's view hierarchy. It can itself be a complex
     * view hierarchy.
     * </p>
     * <p>
     * This method is an equivalent to setContentView(View, LayoutParams) that
     * automatically wraps the given layout in an {@link ActionBarHost} if
     * needed.
     * </p>
     * 
     * @param view The desired content to display.
     * @param params Layout parameters for the view.
     * @see #setActionBarContentView(View)
     * @see #setActionBarContentView(int)
     */
public void setActionBarContentView(View view, LayoutParams params) {
    final FrameLayout contentView = getContentView();
    contentView.removeAllViews();
    contentView.addView(view, params);
}
Also used : FrameLayout(android.widget.FrameLayout)

Example 17 with FrameLayout

use of android.widget.FrameLayout in project GreenDroid by cyrilmottier.

the class GDActivity method setActionBarContentView.

/**
     * <p>
     * Set the activity content from a layout resource. The resource will be
     * inflated, adding all top-level views to the activity.
     * </p>
     * <p>
     * This method is an equivalent to setContentView(int) that automatically
     * wraps the given layout in an {@link ActionBarHost} if needed..
     * </p>
     * 
     * @param resID Resource ID to be inflated.
     * @see #setActionBarContentView(View)
     * @see #setActionBarContentView(View, LayoutParams)
     */
public void setActionBarContentView(int resID) {
    final FrameLayout contentView = getContentView();
    contentView.removeAllViews();
    LayoutInflater.from(this).inflate(resID, contentView);
}
Also used : FrameLayout(android.widget.FrameLayout)

Example 18 with FrameLayout

use of android.widget.FrameLayout in project android_frameworks_base by ParanoidAndroid.

the class PreferenceActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.android.internal.R.layout.preference_list_content);
    mListFooter = (FrameLayout) findViewById(com.android.internal.R.id.list_footer);
    mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs_frame);
    boolean hidingHeaders = onIsHidingHeaders();
    mSinglePane = hidingHeaders || !onIsMultiPane();
    String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
    Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
    int initialTitle = getIntent().getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE, 0);
    int initialShortTitle = getIntent().getIntExtra(EXTRA_SHOW_FRAGMENT_SHORT_TITLE, 0);
    if (savedInstanceState != null) {
        // We are restarting from a previous saved state; used that to
        // initialize, instead of starting fresh.
        ArrayList<Header> headers = savedInstanceState.getParcelableArrayList(HEADERS_TAG);
        if (headers != null) {
            mHeaders.addAll(headers);
            int curHeader = savedInstanceState.getInt(CUR_HEADER_TAG, (int) HEADER_ID_UNDEFINED);
            if (curHeader >= 0 && curHeader < mHeaders.size()) {
                setSelectedHeader(mHeaders.get(curHeader));
            }
        }
    } else {
        if (initialFragment != null && mSinglePane) {
            // If we are just showing a fragment, we want to run in
            // new fragment mode, but don't need to compute and show
            // the headers.
            switchToHeader(initialFragment, initialArguments);
            if (initialTitle != 0) {
                CharSequence initialTitleStr = getText(initialTitle);
                CharSequence initialShortTitleStr = initialShortTitle != 0 ? getText(initialShortTitle) : null;
                showBreadCrumbs(initialTitleStr, initialShortTitleStr);
            }
        } else {
            // We need to try to build the headers.
            onBuildHeaders(mHeaders);
            // the currently selected preference fragment.
            if (mHeaders.size() > 0) {
                if (!mSinglePane) {
                    if (initialFragment == null) {
                        Header h = onGetInitialHeader();
                        switchToHeader(h);
                    } else {
                        switchToHeader(initialFragment, initialArguments);
                    }
                }
            }
        }
    }
    // visibility for other configurations.
    if (initialFragment != null && mSinglePane) {
        // Single pane, showing just a prefs fragment.
        findViewById(com.android.internal.R.id.headers).setVisibility(View.GONE);
        mPrefsContainer.setVisibility(View.VISIBLE);
        if (initialTitle != 0) {
            CharSequence initialTitleStr = getText(initialTitle);
            CharSequence initialShortTitleStr = initialShortTitle != 0 ? getText(initialShortTitle) : null;
            showBreadCrumbs(initialTitleStr, initialShortTitleStr);
        }
    } else if (mHeaders.size() > 0) {
        setListAdapter(new HeaderAdapter(this, mHeaders));
        if (!mSinglePane) {
            // Multi-pane.
            getListView().setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
            if (mCurHeader != null) {
                setSelectedHeader(mCurHeader);
            }
            mPrefsContainer.setVisibility(View.VISIBLE);
        }
    } else {
        // If there are no headers, we are in the old "just show a screen
        // of preferences" mode.
        setContentView(com.android.internal.R.layout.preference_list_content_single);
        mListFooter = (FrameLayout) findViewById(com.android.internal.R.id.list_footer);
        mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs);
        mPreferenceManager = new PreferenceManager(this, FIRST_REQUEST_CODE);
        mPreferenceManager.setOnPreferenceTreeClickListener(this);
    }
    // see if we should show Back/Next buttons
    Intent intent = getIntent();
    if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
        findViewById(com.android.internal.R.id.button_bar).setVisibility(View.VISIBLE);
        Button backButton = (Button) findViewById(com.android.internal.R.id.back_button);
        backButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                setResult(RESULT_CANCELED);
                finish();
            }
        });
        Button skipButton = (Button) findViewById(com.android.internal.R.id.skip_button);
        skipButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                setResult(RESULT_OK);
                finish();
            }
        });
        mNextButton = (Button) findViewById(com.android.internal.R.id.next_button);
        mNextButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                setResult(RESULT_OK);
                finish();
            }
        });
        // set our various button parameters
        if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) {
            String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
            if (TextUtils.isEmpty(buttonText)) {
                mNextButton.setVisibility(View.GONE);
            } else {
                mNextButton.setText(buttonText);
            }
        }
        if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) {
            String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
            if (TextUtils.isEmpty(buttonText)) {
                backButton.setVisibility(View.GONE);
            } else {
                backButton.setText(buttonText);
            }
        }
        if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) {
            skipButton.setVisibility(View.VISIBLE);
        }
    }
}
Also used : Bundle(android.os.Bundle) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) Button(android.widget.Button) FrameLayout(android.widget.FrameLayout) OnClickListener(android.view.View.OnClickListener)

Example 19 with FrameLayout

use of android.widget.FrameLayout in project android_frameworks_base by ParanoidAndroid.

the class AlertController method setupView.

private void setupView() {
    LinearLayout contentPanel = (LinearLayout) mWindow.findViewById(R.id.contentPanel);
    setupContent(contentPanel);
    boolean hasButtons = setupButtons();
    LinearLayout topPanel = (LinearLayout) mWindow.findViewById(R.id.topPanel);
    TypedArray a = mContext.obtainStyledAttributes(null, com.android.internal.R.styleable.AlertDialog, com.android.internal.R.attr.alertDialogStyle, 0);
    boolean hasTitle = setupTitle(topPanel);
    View buttonPanel = mWindow.findViewById(R.id.buttonPanel);
    if (!hasButtons) {
        buttonPanel.setVisibility(View.GONE);
        mWindow.setCloseOnTouchOutsideIfNotSet(true);
    }
    FrameLayout customPanel = null;
    if (mView != null) {
        customPanel = (FrameLayout) mWindow.findViewById(R.id.customPanel);
        FrameLayout custom = (FrameLayout) mWindow.findViewById(R.id.custom);
        custom.addView(mView, new LayoutParams(MATCH_PARENT, MATCH_PARENT));
        if (mViewSpacingSpecified) {
            custom.setPadding(mViewSpacingLeft, mViewSpacingTop, mViewSpacingRight, mViewSpacingBottom);
        }
        if (mListView != null) {
            ((LinearLayout.LayoutParams) customPanel.getLayoutParams()).weight = 0;
        }
    } else {
        mWindow.findViewById(R.id.customPanel).setVisibility(View.GONE);
    }
    /* Only display the divider if we have a title and a 
         * custom view or a message.
         */
    if (hasTitle) {
        View divider = null;
        if (mMessage != null || mView != null || mListView != null) {
            divider = mWindow.findViewById(R.id.titleDivider);
        } else {
            divider = mWindow.findViewById(R.id.titleDividerTop);
        }
        if (divider != null) {
            divider.setVisibility(View.VISIBLE);
        }
    }
    setBackground(topPanel, contentPanel, customPanel, hasButtons, a, hasTitle, buttonPanel);
    a.recycle();
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) TypedArray(android.content.res.TypedArray) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) CheckedTextView(android.widget.CheckedTextView) ListView(android.widget.ListView) LinearLayout(android.widget.LinearLayout)

Example 20 with FrameLayout

use of android.widget.FrameLayout in project android_frameworks_base by ParanoidAndroid.

the class BaseStatusBar method start.

public void start() {
    mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
    mDisplay = mWindowManager.getDefaultDisplay();
    // set up
    mProvisioningObserver.onChange(false);
    mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true, mProvisioningObserver);
    mBarService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE));
    mStatusBarContainer = new FrameLayout(mContext);
    mLocale = mContext.getResources().getConfiguration().locale;
    mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale);
    // Connect in to the status bar manager service
    StatusBarIconList iconList = new StatusBarIconList();
    ArrayList<IBinder> notificationKeys = new ArrayList<IBinder>();
    ArrayList<StatusBarNotification> notifications = new ArrayList<StatusBarNotification>();
    mCommandQueue = new CommandQueue(this, iconList);
    int[] switches = new int[7];
    ArrayList<IBinder> binders = new ArrayList<IBinder>();
    try {
        mBarService.registerStatusBar(mCommandQueue, iconList, notificationKeys, notifications, switches, binders);
    } catch (RemoteException ex) {
    // If the system process isn't there we're doomed anyway.
    }
    mHaloActive = Settings.System.getInt(mContext.getContentResolver(), Settings.System.HALO_ACTIVE, 0) == 1;
    createAndAddWindows();
    disable(switches[0]);
    setSystemUiVisibility(switches[1], 0xffffffff);
    topAppWindowChanged(switches[2] != 0);
    // StatusBarManagerService has a back up of IME token and it's restored here.
    setImeWindowStatus(binders.get(0), switches[3], switches[4]);
    setHardKeyboardStatus(switches[5] != 0, switches[6] != 0);
    // Set up the initial icon state
    int N = iconList.size();
    int viewIndex = 0;
    for (int i = 0; i < N; i++) {
        StatusBarIcon icon = iconList.getIcon(i);
        if (icon != null) {
            addIcon(iconList.getSlot(i), i, viewIndex, icon);
            viewIndex++;
        }
    }
    // Set up the initial notification state
    N = notificationKeys.size();
    if (N == notifications.size()) {
        for (int i = 0; i < N; i++) {
            addNotification(notificationKeys.get(i), notifications.get(i));
        }
    } else {
        Log.wtf(TAG, "Notification list length mismatch: keys=" + N + " notifications=" + notifications.size());
    }
    if (DEBUG) {
        Slog.d(TAG, String.format("init: icons=%d disabled=0x%08x lights=0x%08x menu=0x%08x imeButton=0x%08x", iconList.size(), switches[0], switches[1], switches[2], switches[3]));
    }
    mCurrentUserId = ActivityManager.getCurrentUser();
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_USER_SWITCHED);
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (Intent.ACTION_USER_SWITCHED.equals(action)) {
                mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
                if (true)
                    Slog.v(TAG, "userId " + mCurrentUserId + " is in the house");
                userSwitched(mCurrentUserId);
            }
        }
    }, filter);
    // Only watch for per app color changes when the setting is in check
    if (ColorUtils.getPerAppColorState(mContext)) {
        // Reset all colors
        Bitmap currentBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
        mCurrentCanvas = new Canvas(currentBitmap);
        mCurrentCanvas.drawColor(0xFF000000);
        BitmapDrawable currentBitmapDrawable = new BitmapDrawable(currentBitmap);
        Bitmap newBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
        mNewCanvas = new Canvas(newBitmap);
        mNewCanvas.drawColor(0xFF000000);
        BitmapDrawable newBitmapDrawable = new BitmapDrawable(newBitmap);
        mTransition = new TransitionDrawable(new Drawable[] { currentBitmapDrawable, newBitmapDrawable });
        mBarView.setBackground(mTransition);
        mLastIconColor = ColorUtils.getColorSettingInfo(mContext, Settings.System.STATUS_ICON_COLOR);
        mLastBackgroundColor = ColorUtils.getColorSettingInfo(mContext, ExtendedPropertiesUtils.isTablet() ? Settings.System.NAV_BAR_COLOR : Settings.System.STATUS_BAR_COLOR);
        updateIconColor();
        updateBackgroundColor();
        // Listen for status bar icon color changes
        mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.STATUS_ICON_COLOR), false, new ContentObserver(new Handler()) {

            @Override
            public void onChange(boolean selfChange) {
                updateIconColor();
            }
        });
        // Listen for status bar background color changes
        mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(ExtendedPropertiesUtils.isTablet() ? Settings.System.NAV_BAR_COLOR : Settings.System.STATUS_BAR_COLOR), false, new ContentObserver(new Handler()) {

            @Override
            public void onChange(boolean selfChange) {
                updateBackgroundColor();
            }
        });
        // Listen for per-app-color state changes, this one will revert to stock colors all over
        mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.PER_APP_COLOR), false, new ContentObserver(new Handler()) {

            @Override
            public void onChange(boolean selfChange) {
                if (!ColorUtils.getPerAppColorState(mContext)) {
                    for (int i = 0; i < ExtendedPropertiesUtils.PARANOID_COLORS_COUNT; i++) {
                        ColorUtils.ColorSettingInfo colorInfo = ColorUtils.getColorSettingInfo(mContext, Settings.System.STATUS_ICON_COLOR);
                        ColorUtils.setColor(mContext, ExtendedPropertiesUtils.PARANOID_COLORS_SETTINGS[i], colorInfo.systemColorString, "NULL", 1, 250);
                    }
                }
            }
        });
    }
    attachPie();
    // Listen for PIE gravity
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.PIE_GRAVITY), false, new ContentObserver(new Handler()) {

        @Override
        public void onChange(boolean selfChange) {
            updatePieControls();
        }
    });
    // Listen for HALO state
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.HALO_ACTIVE), false, new ContentObserver(new Handler()) {

        @Override
        public void onChange(boolean selfChange) {
            updateHalo();
        }
    });
    mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(Settings.System.HALO_SIZE), false, new ContentObserver(new Handler()) {

        @Override
        public void onChange(boolean selfChange) {
            restartHalo();
        }
    });
    updateHalo();
    SettingsObserver settingsObserver = new SettingsObserver(new Handler());
    settingsObserver.observe();
}
Also used : ArrayList(java.util.ArrayList) IBinder(android.os.IBinder) Bitmap(android.graphics.Bitmap) StatusBarNotification(android.service.notification.StatusBarNotification) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) ContentObserver(android.database.ContentObserver) Context(android.content.Context) IntentFilter(android.content.IntentFilter) TransitionDrawable(android.graphics.drawable.TransitionDrawable) StatusBarIconList(com.android.internal.statusbar.StatusBarIconList) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) Handler(android.os.Handler) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BroadcastReceiver(android.content.BroadcastReceiver) Paint(android.graphics.Paint) FrameLayout(android.widget.FrameLayout) RemoteException(android.os.RemoteException)

Aggregations

FrameLayout (android.widget.FrameLayout)619 View (android.view.View)238 TextView (android.widget.TextView)136 ViewGroup (android.view.ViewGroup)125 ImageView (android.widget.ImageView)93 LinearLayout (android.widget.LinearLayout)89 ListView (android.widget.ListView)54 AdapterView (android.widget.AdapterView)47 Button (android.widget.Button)44 LayoutInflater (android.view.LayoutInflater)42 Bitmap (android.graphics.Bitmap)40 LayoutParams (android.view.ViewGroup.LayoutParams)37 AbsListView (android.widget.AbsListView)37 Context (android.content.Context)34 Activity (android.app.Activity)25 Intent (android.content.Intent)25 TextureView (android.view.TextureView)25 ColorDrawable (android.graphics.drawable.ColorDrawable)23 FileOutputStream (java.io.FileOutputStream)23 Drawable (android.graphics.drawable.Drawable)20