Search in sources :

Example 6 with BidiFormatter

use of android.text.BidiFormatter in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RunningProcessesView method refreshUi.

void refreshUi(boolean dataChanged) {
    if (dataChanged) {
        ServiceListAdapter adapter = mAdapter;
        adapter.refreshItems();
        adapter.notifyDataSetChanged();
    }
    if (mDataAvail != null) {
        mDataAvail.run();
        mDataAvail = null;
    }
    mMemInfoReader.readMemInfo();
    synchronized (mState.mLock) {
        if (mCurShowCached != mAdapter.mShowBackground) {
            mCurShowCached = mAdapter.mShowBackground;
            if (mCurShowCached) {
                mForegroundProcessPrefix.setText(getResources().getText(R.string.running_processes_header_used_prefix));
                mAppsProcessPrefix.setText(getResources().getText(R.string.running_processes_header_cached_prefix));
            } else {
                mForegroundProcessPrefix.setText(getResources().getText(R.string.running_processes_header_system_prefix));
                mAppsProcessPrefix.setText(getResources().getText(R.string.running_processes_header_apps_prefix));
            }
        }
        final long totalRam = mMemInfoReader.getTotalSize();
        final long medRam;
        final long lowRam;
        if (mCurShowCached) {
            lowRam = mMemInfoReader.getFreeSize() + mMemInfoReader.getCachedSize();
            medRam = mState.mBackgroundProcessMemory;
        } else {
            lowRam = mMemInfoReader.getFreeSize() + mMemInfoReader.getCachedSize() + mState.mBackgroundProcessMemory;
            medRam = mState.mServiceProcessMemory;
        }
        final long highRam = totalRam - medRam - lowRam;
        if (mCurTotalRam != totalRam || mCurHighRam != highRam || mCurMedRam != medRam || mCurLowRam != lowRam) {
            mCurTotalRam = totalRam;
            mCurHighRam = highRam;
            mCurMedRam = medRam;
            mCurLowRam = lowRam;
            BidiFormatter bidiFormatter = BidiFormatter.getInstance();
            String sizeStr = bidiFormatter.unicodeWrap(Formatter.formatShortFileSize(getContext(), lowRam));
            mBackgroundProcessText.setText(getResources().getString(R.string.running_processes_header_ram, sizeStr));
            sizeStr = bidiFormatter.unicodeWrap(Formatter.formatShortFileSize(getContext(), medRam));
            mAppsProcessText.setText(getResources().getString(R.string.running_processes_header_ram, sizeStr));
            sizeStr = bidiFormatter.unicodeWrap(Formatter.formatShortFileSize(getContext(), highRam));
            mForegroundProcessText.setText(getResources().getString(R.string.running_processes_header_ram, sizeStr));
            mColorBar.setRatios(highRam / (float) totalRam, medRam / (float) totalRam, lowRam / (float) totalRam);
        }
    }
}
Also used : BidiFormatter(android.text.BidiFormatter)

Example 7 with BidiFormatter

use of android.text.BidiFormatter in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothSettings method updateContent.

private void updateContent(int bluetoothState) {
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    int messageId = 0;
    switch(bluetoothState) {
        case BluetoothAdapter.STATE_ON:
            mDevicePreferenceMap.clear();
            if (isUiRestricted()) {
                messageId = R.string.bluetooth_empty_list_user_restricted;
                break;
            }
            getPreferenceScreen().removeAll();
            getPreferenceScreen().addPreference(mPairedDevicesCategory);
            getPreferenceScreen().addPreference(mAvailableDevicesCategory);
            getPreferenceScreen().addPreference(mMyDevicePreference);
            // Paired devices category
            addDeviceCategory(mPairedDevicesCategory, R.string.bluetooth_preference_paired_devices, BluetoothDeviceFilter.BONDED_DEVICE_FILTER, true);
            int numberOfPairedDevices = mPairedDevicesCategory.getPreferenceCount();
            if (isUiRestricted() || numberOfPairedDevices <= 0) {
                if (preferenceScreen.findPreference(KEY_PAIRED_DEVICES) != null) {
                    preferenceScreen.removePreference(mPairedDevicesCategory);
                }
            } else {
                if (preferenceScreen.findPreference(KEY_PAIRED_DEVICES) == null) {
                    preferenceScreen.addPreference(mPairedDevicesCategory);
                }
            }
            // Available devices category
            addDeviceCategory(mAvailableDevicesCategory, R.string.bluetooth_preference_found_devices, BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER, mInitialScanStarted);
            if (!mInitialScanStarted) {
                startScanning();
            }
            final Resources res = getResources();
            final Locale locale = res.getConfiguration().getLocales().get(0);
            final BidiFormatter bidiFormatter = BidiFormatter.getInstance(locale);
            mMyDevicePreference.setSummary(res.getString(R.string.bluetooth_is_visible_message, bidiFormatter.unicodeWrap(mLocalAdapter.getName())));
            getActivity().invalidateOptionsMenu();
            // threads to execute.
            if (mInitiateDiscoverable) {
                // Make the device visible to other devices.
                mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
                mInitiateDiscoverable = false;
            }
            // not break
            return;
        case BluetoothAdapter.STATE_TURNING_OFF:
            messageId = R.string.bluetooth_turning_off;
            break;
        case BluetoothAdapter.STATE_OFF:
            setOffMessage();
            if (isUiRestricted()) {
                messageId = R.string.bluetooth_empty_list_user_restricted;
            }
            break;
        case BluetoothAdapter.STATE_TURNING_ON:
            messageId = R.string.bluetooth_turning_on;
            mInitialScanStarted = false;
            break;
    }
    setDeviceListGroup(preferenceScreen);
    removeAllDevices();
    if (messageId != 0) {
        getEmptyTextView().setText(messageId);
    }
    if (!isUiRestricted()) {
        getActivity().invalidateOptionsMenu();
    }
}
Also used : Locale(java.util.Locale) PreferenceScreen(android.support.v7.preference.PreferenceScreen) BidiFormatter(android.text.BidiFormatter) Resources(android.content.res.Resources)

Aggregations

BidiFormatter (android.text.BidiFormatter)7 SimpleDateFormat (java.text.SimpleDateFormat)5 Resources (android.content.res.Resources)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 Locale (java.util.Locale)1