當前位置: 首頁>>代碼示例>>Java>>正文


Java Tile.setIcon方法代碼示例

本文整理匯總了Java中android.service.quicksettings.Tile.setIcon方法的典型用法代碼示例。如果您正苦於以下問題:Java Tile.setIcon方法的具體用法?Java Tile.setIcon怎麽用?Java Tile.setIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.service.quicksettings.Tile的用法示例。


在下文中一共展示了Tile.setIcon方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateState

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateState() {
    Tile tile = getQsTile();
    if(tile != null) {
        SharedPreferences pref = U.getSharedPreferences(this);
        tile.setIcon(Icon.createWithResource(this, pref.getBoolean("app_drawer_icon", false)
                ? R.drawable.ic_system
                : R.drawable.ic_allapps));

        if(U.canDrawOverlays(this))
            tile.setState(U.isServiceRunning(this, NotificationService.class)
                    ? Tile.STATE_ACTIVE
                    : Tile.STATE_INACTIVE);
        else
            tile.setState(Tile.STATE_UNAVAILABLE);

        tile.updateTile();
    }
}
 
開發者ID:farmerbb,項目名稱:Taskbar,代碼行數:19,代碼來源:QuickSettingsTileService.java

示例2: refreshTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
/** <br> UI. */

    @RequiresApi(api = Build.VERSION_CODES.N)
    public static void refreshTile(Context context, Tile tile) {
        if (tile == null) {
            return;
        }
        Location location = DatabaseHelper.getInstance(context).readLocationList().get(0);
        location.weather = DatabaseHelper.getInstance(context).readWeather(location);
        if (location.weather != null) {
            boolean f = PreferenceManager.getDefaultSharedPreferences(context)
                    .getBoolean(context.getString(R.string.key_fahrenheit), false);
            tile.setIcon(
                    Icon.createWithResource(
                            context,
                            WeatherHelper.getNotificationWeatherIcon(
                                    location.weather.realTime.weatherKind,
                                    TimeManager.getInstance(context).isDayTime())));
            tile.setLabel(
                    ValueUtils.buildCurrentTemp(
                            location.weather.realTime.temp,
                            false,
                            f));
            tile.updateTile();
        }
    }
 
開發者ID:WangDaYeeeeee,項目名稱:GeometricWeather,代碼行數:27,代碼來源:TileHelper.java

示例3: setBat

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void setBat(Intent intent) {
        int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);

        mIsCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
                status == BatteryManager.BATTERY_STATUS_FULL;

//        int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

        mBatteryPercent = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);

        Tile battery = getQsTile();

        int resId;

        if (mBatteryPercent >= 95) {
             resId = mIsCharging ? R.drawable.ic_battery_charging_full : R.drawable.ic_battery;
        } else if (mBatteryPercent >= 85) {
            resId = mIsCharging ? R.drawable.ic_battery_charging_90 : R.drawable.ic_battery_90;
        } else if (mBatteryPercent >= 70) {
            resId = mIsCharging ? R.drawable.ic_battery_charging_80 : R.drawable.ic_battery_80;
        } else if (mBatteryPercent >= 55) {
            resId = mIsCharging ? R.drawable.ic_battery_charging_60 : R.drawable.ic_battery_60;
        } else if (mBatteryPercent >= 40) {
            resId = mIsCharging ? R.drawable.ic_battery_charging_50 : R.drawable.ic_battery_50;
        } else if (mBatteryPercent >= 25) {
            resId = mIsCharging ? R.drawable.ic_battery_charging_30 : R.drawable.ic_battery_30;
        } else if (mBatteryPercent >= 15) {
            resId = mIsCharging ? R.drawable.ic_battery_charging_20 : R.drawable.ic_battery_20;
        } else {
            resId = mIsCharging ? R.drawable.ic_battery_charging_20 : R.drawable.ic_battery_alert;
        }

        battery.setIcon(Icon.createWithResource(this, resId));
        battery.setLabel(String.valueOf(mBatteryPercent).concat("%"));
        battery.updateTile();
    }
 
開發者ID:zacharee,項目名稱:SystemUITuner2,代碼行數:37,代碼來源:BatteryTileService.java

示例4: _isRunning

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void _isRunning(Tile tile) {
    if (isCharging()) {
        tile.setState(Tile.STATE_ACTIVE);
        tile.setIcon(mIconEyeOpen);
        tile.setLabel(getString(R.string.tile_active_charging_text));
    } else {
        tile.setState(Tile.STATE_ACTIVE);
        tile.setIcon(mIconEyeOpen);
        long timeRemaining = MAX_TIME_SEC - mTimeRunning_sec;
        final String formatTime = formatTime(timeRemaining);
        tile.setLabel(getString(R.string.tile_active_text, formatTime));
    }
}
 
開發者ID:r3bl-alliance,項目名稱:stay-awake-app,代碼行數:14,代碼來源:MyTileService.java

示例5: updateTileUI

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
/**
 * Updates the QSTile icon and label
 * @param state - State of night light. True value means night light is on, and vice versa
 */
private void updateTileUI(boolean state) {
    Tile tile = this.getQsTile();

    if (tile == null) return;

    Icon newIcon;
    int newState;

    String title;

    // Change the tile to match the service status.
    if (state) {
        newIcon = Icon.createWithResource(getApplicationContext(), ic_lightbulb_outline);
        newState = Tile.STATE_ACTIVE;
        title = getString(R.string.on);
    } else {
        newIcon = Icon.createWithResource(getApplicationContext(), ic_lightbulb_outline_disabled);
        newState = Tile.STATE_INACTIVE;

        title = getString(R.string.off);
    }

    // Change the UI of the tile.
    tile.setLabel(title);
    tile.setIcon(newIcon);
    tile.setState(newState);

    // Need to call updateTile for the tile to pick up changes.
    tile.updateTile();
}
 
開發者ID:corphish,項目名稱:NightLight,代碼行數:35,代碼來源:QuickSettingsService.java

示例6: toggleTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void toggleTile(boolean enable) {
	Tile tile = getQsTile();

	if (enable) {
		tile.setLabel(getString(R.string.ui_enable));
		tile.setState(Tile.STATE_ACTIVE);
		tile.setIcon(Icon.createWithResource(this, R.drawable.qs_locked));
		tile.updateTile();
	} else {
		tile.setLabel(getString(R.string.ui_disable));
		tile.setState(Tile.STATE_INACTIVE);
		tile.setIcon(Icon.createWithResource(this, R.drawable.qs_unlocked));
		tile.updateTile();
	}
}
 
開發者ID:collaction,項目名稱:content-farm-blocker-android,代碼行數:16,代碼來源:ToggleTileService.java

示例7: updateView

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateView(boolean displayToast, boolean init) {
    Tile tile = getQsTile();
    if (BaseMethod.isAccessibilitySettingsOn(this)) {
        boolean KeyBlocked = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Config.ENABLED_KEYBLOCK, false);
        if (init) {
            if (KeyBlocked) {
                tile.setState(Tile.STATE_ACTIVE);
                tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_blocked));
            } else {
                tile.setState(Tile.STATE_INACTIVE);
                tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_not_blocked));
            }
        } else {
            if (tile.getState() == Tile.STATE_ACTIVE) {
                tile.setState(Tile.STATE_INACTIVE);
                tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_not_blocked));
            } else if (tile.getState() == Tile.STATE_INACTIVE) {
                tile.setState(Tile.STATE_ACTIVE);
                tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_blocked));
            }
        }
    } else {
        tile.setState(Tile.STATE_INACTIVE);
        tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_not_blocked));
        if (displayToast) {
            BaseMethod.RunAccessibilityService(this);
        }
    }
    tile.updateTile();
}
 
開發者ID:XFY9326,項目名稱:KeyBlocker,代碼行數:31,代碼來源:QuickSettingService.java

示例8: onTileAdded

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onTileAdded() {
    super.onTileAdded();
    Tile tile = getQsTile();
    if (tile != null) {
        tile.setIcon(Icon.createWithResource(this, StaticUtils.isStatusServiceRunning(this) ? R.drawable.ic_check_box_enabled : R.drawable.ic_check_box_disabled));
        tile.updateTile();
    }
}
 
開發者ID:TheAndroidMaster,項目名稱:Status,代碼行數:10,代碼來源:QuickToggleService.java

示例9: onStartListening

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onStartListening() {
    super.onStartListening();
    Tile tile = getQsTile();
    if (tile != null) {
        tile.setIcon(Icon.createWithResource(this, StaticUtils.isStatusServiceRunning(this) ? R.drawable.ic_check_box_enabled : R.drawable.ic_check_box_disabled));
        tile.updateTile();
    }
}
 
開發者ID:TheAndroidMaster,項目名稱:Status,代碼行數:10,代碼來源:QuickToggleService.java

示例10: updateTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateTile() {
    Tile tile = this.getQsTile();

    boolean isActive = this.getServiceStatus();

    String newLabel;
    Icon newIcon;
    int newState;
    if (isActive) {
        newLabel = "MyQs is active.";
        newIcon = Icon.createWithResource(getApplicationContext(),
                android.R.drawable.ic_dialog_alert);
        newState = Tile.STATE_ACTIVE;

        //open result activity
        Intent intent = new Intent(getApplicationContext(), ResultActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
    } else {
        newLabel = "MyQs is inactive.";
        newIcon = Icon.createWithResource(getApplicationContext(),
                R.mipmap.ic_tile_inactive);
        newState = Tile.STATE_INACTIVE;
    }

    tile.setIcon(newIcon);
    tile.setLabel(newLabel);
    tile.setState(newState);

    tile.updateTile();
}
 
開發者ID:kevalpatel2106,項目名稱:android-samples,代碼行數:32,代碼來源:QuickSettingsService.java

示例11: updateTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateTile() {
    final boolean keepActivities = getKeepActivities(getContentResolver());
    final Tile tile = getQsTile();
    tile.setIcon(Icon.createWithResource(getApplicationContext(), getIcon(keepActivities)));
    tile.setLabel(getString(getLabel(keepActivities)));
    tile.updateTile();
}
 
開發者ID:Stocard,項目名稱:KeepActivitiesTile,代碼行數:8,代碼來源:ToggleKeepActivities.java

示例12: updateInactiveTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateInactiveTile(Tile tile) {
    Icon inActiveIcon = Icon
            .createWithResource(getApplicationContext(),
                    R.drawable.ic_qs_night_mode_off);

    tile.setIcon(inActiveIcon);
    tile.setState(Tile.STATE_INACTIVE);
    tile.updateTile();
}
 
開發者ID:fython,項目名稱:Blackbulb,代碼行數:10,代碼來源:MaskTileService.java

示例13: updateActiveTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateActiveTile(Tile tile) {
    Icon activeIcon = Icon
            .createWithResource(getApplicationContext(),
                    R.drawable.ic_qs_night_mode_on);

    tile.setIcon(activeIcon);
    tile.setState(Tile.STATE_ACTIVE);
    tile.updateTile();
}
 
開發者ID:fython,項目名稱:Blackbulb,代碼行數:10,代碼來源:MaskTileService.java

示例14: updateTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateTile() {
    final boolean isDebugModeEnabled = getDebugModeState(getContentResolver());
    Log.d(DebugModeToggle.class.getSimpleName(), "Checking USB Debugging state, it's enabled = " + isDebugModeEnabled);
    final Tile tile = getQsTile();
    tile.setIcon(Icon.createWithResource(getApplicationContext(), getIcon(isDebugModeEnabled)));
    tile.updateTile();
}
 
開發者ID:mSobhy90,項目名稱:DebugModeTile,代碼行數:8,代碼來源:DebugModeToggle.java

示例15: updateTileWithPercentage

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateTileWithPercentage()
{
    Tile tile = getQsTile();

    tile.setIcon(Icon.createWithBitmap(drawCircularProgressBarWhiteOnTransparent(trafficWastedPercentage)));
    tile.setLabel(
            String.format("%1s: %2s%%", getString(R.string.quick_settings_tile_label), trafficWastedPercentage));
    tile.setState(Tile.STATE_ACTIVE); // leads to a standard 'active', white Tile

    tile.updateTile();
}
 
開發者ID:martinhellwig,項目名稱:DatapassWidget,代碼行數:12,代碼來源:DataPassTileService.java


注:本文中的android.service.quicksettings.Tile.setIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。