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


Java Tile.setLabel方法代碼示例

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


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

示例1: updateTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
protected static void updateTile(TileService context) {
    if(context == null) return;

    Tile tile = context.getQsTile();

    if (ki4aService.current_status == Util.STATUS_SOCKS) {
        tile.setLabel(context.getString(R.string.text_status_connected));
        tile.setState(Tile.STATE_ACTIVE);
    }
    else if (ki4aService.current_status == Util.STATUS_CONNECTING) {
        tile.setLabel(context.getString(R.string.text_status_connecting));
        tile.setState(Tile.STATE_INACTIVE);
    }
    else if (ki4aService.current_status == Util.STATUS_DISCONNECT) {
        tile.setLabel(context.getString(R.string.text_status_disconnected));
        tile.setState(Tile.STATE_INACTIVE);
    }

    tile.updateTile();
}
 
開發者ID:staf621,項目名稱:ki4a,代碼行數:21,代碼來源:ki4aQuickSettingsService.java

示例2: onClick

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
    super.onClick();
    Log("Clicked");
    initPrefs();
    Tile tile = getQsTile();
    if (tile != null) {
        switch (tile.getState()) {
            case Tile.STATE_ACTIVE:
                prefs.setBool(Prefs.KEYS.ENABLED.toString(), false);
                setCurrentState(Tile.STATE_INACTIVE);
                break;
            case Tile.STATE_INACTIVE:
                prefs.setBool(Prefs.KEYS.ENABLED.toString(), true);
                setCurrentState(Tile.STATE_ACTIVE);
                break;
            default:
                tile.setLabel(getString(R.string.quick_settings_title) + " " + (prefs.enabled ? getString(R.string.quick_settings_service_active) : getString(R.string.quick_settings_service_inactive)));
                Log("Active");
                break;
        }
    } else {
        Log("Tile is null");
    }
}
 
開發者ID:rosenpin,項目名稱:AlwaysOnDisplayAmoled,代碼行數:26,代碼來源:QuickSettingsToggle.java

示例3: setCurrentState

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void setCurrentState(int state) {
    initPrefs();
    Tile tile = getQsTile();
    if (tile != null) {
        tile.setState(state);
        switch (state) {
            case Tile.STATE_ACTIVE:
                tile.setLabel(getString(R.string.quick_settings_title) + " " + getString(R.string.quick_settings_service_active));
                Log("Active");
                break;
            case Tile.STATE_INACTIVE:
                tile.setLabel(getString(R.string.quick_settings_title) + " " + getString(R.string.quick_settings_service_inactive));
                Log("Inactive");
                break;
            default:
                tile.setLabel(getString(R.string.quick_settings_title) + " " + (prefs.enabled ? getString(R.string.quick_settings_service_active) : getString(R.string.quick_settings_service_inactive)));
                Log("Active");
                break;
        }
        tile.updateTile();
    }
}
 
開發者ID:rosenpin,項目名稱:AlwaysOnDisplayAmoled,代碼行數:23,代碼來源:QuickSettingsToggle.java

示例4: 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

示例5: onClick

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
    super.onClick();
    Log.d(TAG, "onClick");

    Tile tile = getQsTile();
    if (tile != null) {
        if (tile.getState() == Tile.STATE_ACTIVE) {
            tile.setLabel("QuickStart");
            tile.setState(Tile.STATE_INACTIVE);
        } else {
            tile.setLabel("Running...");
            tile.setState(Tile.STATE_ACTIVE);
        }

        tile.updateTile();
    }
}
 
開發者ID:Alex-Jerry,項目名稱:LLApp,代碼行數:19,代碼來源:QuickService.java

示例6: updateTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateTile() {
    TelephonyManager manager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String code = manager.getSimOperator();
    String country = manager.getSimCountryIso();

    SharedPreferences preferences = PropUtil.getProtecredSharedPreferences(this);

    Tile tile = getQsTile();
    tile.setLabel(String.format("%s %s", code, country));
    if (preferences.getBoolean(PropUtil.PREFERENCE_ENABLED, PropUtil.PREFERENCE_ENABLED_DEFAULT)) {
        tile.setState(Tile.STATE_ACTIVE);
    }
    else {
        tile.setState(Tile.STATE_INACTIVE);
    }
    tile.updateTile();
}
 
開發者ID:GhostFlying,項目名稱:LocationReportEnabler,代碼行數:18,代碼來源:FakeOperatorTile.java

示例7: onStartListening

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
    public void onStartListening() {
        final Tile nightMode = getQsTile();
        boolean isActive;

        if (Build.VERSION.SDK_INT == 24) isActive = Settings.Secure.getInt(getContentResolver(), "twilight_mode", 0) == 1;
        else {
            isActive = Settings.Secure.getInt(getContentResolver(), NIGHT_DISPLAY_ACTIVATED, 0) == 1;
            nightMode.setLabel(getResources().getText(R.string.night_display));
        }

        nightMode.setState(isActive ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
        nightMode.updateTile();

//        service = this;

        mToggleIntent = new Intent("toggle_night");

        mToggleReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (intent.getAction().equals("toggle_night")) {
                    boolean state = intent.getBooleanExtra("state", false);
                    nightMode.setState(state ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
                    nightMode.updateTile();
                }
            }
        };

        IntentFilter filter = new IntentFilter("toggle_night");
        registerReceiver(mToggleReceiver, filter);
    }
 
開發者ID:zacharee,項目名稱:SystemUITuner2,代碼行數:33,代碼來源:NightModeTileService.java

示例8: 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

示例9: _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

示例10: 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

示例11: 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

示例12: onClick

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
    Tile tile = getQsTile();
    tile.setLabel(getString(R.string.quick_toggle));
    tile.setContentDescription(getString(R.string.app_name));
    tile.setState(Daedalus.switchService() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
    tile.updateTile();
}
 
開發者ID:iTXTech,項目名稱:Daedalus,代碼行數:9,代碼來源:DaedalusTileService.java

示例13: updateTile

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateTile() {
    boolean activate = DaedalusVpnService.isActivated();
    Tile tile = getQsTile();
    tile.setLabel(getString(R.string.quick_toggle));
    tile.setContentDescription(getString(R.string.app_name));
    tile.setState(activate ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
    tile.updateTile();
}
 
開發者ID:iTXTech,項目名稱:Daedalus,代碼行數:9,代碼來源:DaedalusTileService.java

示例14: onStopListening

import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onStopListening() {
    super.onStopListening();

    if (volumePollingSubscription != null) {
        volumePollingSubscription.unsubscribe();
    }

    Tile tile = getQsTile();
    tile.setLabel(getString(R.string.tile_label));
    tile.updateTile();
}
 
開發者ID:urandom,項目名稱:VolumeTile,代碼行數:13,代碼來源:Service.java

示例15: 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


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