!108 [SystemUI] 新增状态栏电话胶囊

Merge pull request !108 from lijinfengde123/master
This commit is contained in:
openharmony_ci
2022-01-21 09:47:01 +00:00
committed by Gitee
14 changed files with 72 additions and 44 deletions
@@ -43,9 +43,9 @@ export default class PluginDataSourceAdapter {
this.mWorker.postMessage(obtainMsg(Constants.INIT_CONFIG, configs));
}
loadData() {
loadData(userId) {
Log.showInfo(TAG, `loadData`)
this.mWorker.postMessage(obtainMsg(Constants.LOAD_DATA, {}));
this.mWorker.postMessage(obtainMsg(Constants.LOAD_DATA, userId));
}
clearAll() {
@@ -53,10 +53,10 @@ export default class PluginDataSourceManager {
this.mLoaders.clear();
}
loadData() {
loadData(userId) {
Log.showInfo(TAG, `loadData`);
this.mLoaders.forEach((sourceLoader) => {
sourceLoader.loadData();
sourceLoader.loadData(userId);
});
}
}
@@ -37,6 +37,7 @@ export default abstract class BaseMetaSourceLoader extends SourceLoader {
mPluginType: number = null;
mItemComponentDatas: ItemComponentData[] = [];
mCommonEventSubscriber = null;
mUserId: string = null;
constructor(config, channel, pluginType) {
super(channel);
@@ -65,8 +66,9 @@ export default abstract class BaseMetaSourceLoader extends SourceLoader {
this.removeAllItemComponentData();
}
loadData() {
Log.showInfo(TAG, `load loader`)
loadData(userId) {
Log.showInfo(TAG, `load loader userId = ` + userId)
this.mUserId = userId;
this.removeAllItemComponentData();
this.addAbilityItemComponentData({
"action": this.mAction
@@ -118,8 +120,8 @@ export default abstract class BaseMetaSourceLoader extends SourceLoader {
}
addAbilityItemComponentData(want): void{
Log.showInfo(TAG, `addAbilityItemComponentData, want: ${JSON.stringify(want)} BundleFlag: ${Constants.DEFAULT_BUNDLE_FLAG}`);
bundleManager.queryAbilityByWant(want, Constants.DEFAULT_BUNDLE_FLAG, Constants.DEFAULT_USER_ID,
Log.showInfo(TAG, `addAbilityItemComponentData, want: ${JSON.stringify(want)} BundleFlag: ${Constants.DEFAULT_BUNDLE_FLAG}this.mUserId:${this.mUserId}`);
bundleManager.queryAbilityByWant(want, Constants.DEFAULT_BUNDLE_FLAG, this.mUserId ? this.mUserId : Constants.DEFAULT_USER_ID,
(err, abilityInfos) => {
Log.showInfo(TAG, `addAbilityItemComponentData queryAbilityByWant callback, want: ${JSON.stringify(want)} err: ${JSON.stringify(err)} abilityInfos: ${abilityInfos.length} ${JSON.stringify(abilityInfos)} `)
if (err != 0) {
@@ -34,7 +34,7 @@ export default class PluginSourceLoader extends SourceLoader {
// todo 停止监听,清除数据
}
loadData() {
loadData(userId) {
// todo 重新获取一次数据
}
}
@@ -28,7 +28,7 @@ export default abstract class SourceLoader {
abstract stopLoad(): void;
abstract loadData(): void;
abstract loadData(userId): void;
addItem(itemData: ItemComponentData) {
Log.showInfo(TAG, `addItem, itemData: ${JSON.stringify(itemData)}`)
@@ -60,24 +60,24 @@ export default struct ControlCenterComplexToggleBluetoothComponent {
mClickEvent() {
Log.showInfo(TAG, `mClickEvent, BluetoothOpenStatus: ${this.BluetoothOpenStatus}`)
if (this.BluetoothOpenStatus) {
ViewModel.disableBluetooth()
} else {
ViewModel.enableBluetooth()
}
// if (this.BluetoothOpenStatus) {
// ViewModel.disableBluetooth()
// } else {
// ViewModel.enableBluetooth()
// }
}
mLongClickEvent() {
Log.showInfo(TAG, `mLongClickEvent, BluetoothOpenStatus: ${this.BluetoothOpenStatus}`)
this.showStatusBar = true
this.mWindowManager.setWindowMin((result) => {
this.mFeatureAbilityManager.openAbility(TAG, {
want: {
bundleName: 'com.ohos.settings',
abilityName: 'com.ohos.settings.MainAbility',
}
})
})
// this.showStatusBar = true
// this.mWindowManager.setWindowMin((result) => {
// this.mFeatureAbilityManager.openAbility(TAG, {
// want: {
// bundleName: 'com.ohos.settings',
// abilityName: 'com.ohos.settings.MainAbility',
// }
// })
// })
}
}
@@ -28,7 +28,7 @@ export class brightnessManager {
init(): void{
Log.showInfo(TAG, 'init');
this.uri = settings.getUriSync(SYSTEMUI_BRIGHTNESS);
this.uri = settings.getUri(SYSTEMUI_BRIGHTNESS);
Log.showInfo(TAG, 'settings geturi of brightness is ' + this.uri);
this.helper = featureAbility.acquireDataAbilityHelper(this.uri);
this.getValue();
@@ -36,7 +36,7 @@ export class brightnessManager {
registerBrightness() {
this.helper.on("dataChange", this.uri, (err) => {
let data = settings.getValueSync(this.helper, SYSTEMUI_BRIGHTNESS, '150')
let data = settings.getValue(this.helper, SYSTEMUI_BRIGHTNESS, '150')
Log.showInfo(TAG, `after brightness datachange settings getValue ${parseInt(data)}`);
mBrightnessValue.set(parseInt(data));
})
@@ -50,7 +50,7 @@ export class brightnessManager {
getValue() {
Log.showInfo(TAG, 'getValue');
let data = settings.getValueSync(this.helper, SYSTEMUI_BRIGHTNESS, '150');
let data = settings.getValue(this.helper, SYSTEMUI_BRIGHTNESS, '150');
Log.showInfo(TAG, `settings getValue ${parseInt(data)}`);
mBrightnessValue.set(parseInt(data));
}
@@ -61,7 +61,7 @@ export class brightnessManager {
Log.showInfo(TAG, `setValue ${value}`);
mBrightnessValue.set(value);
Log.showInfo(TAG, `brightness setValue ${value} end`);
settings.setValueSync(this.helper, SYSTEMUI_BRIGHTNESS, callback.value.toString());
settings.setValue(this.helper, SYSTEMUI_BRIGHTNESS, callback.value.toString());
Log.showInfo(TAG, `settings setValue ${callback.value} end`);
}
}
@@ -59,10 +59,10 @@ export default struct CapsuleIcon {
}
.alignItems(VerticalAlign.Center)
.margin({ left: $r("app.float.green_capsule_left_margin") })
.height(Constants.STATIC_BAR_ICON_HEIGHT * this.StatusCoefficient * Constants.CAPSULE_HEIGHT_MULTIPLE)
.height(Constants.STATIC_BAR_ICON_HEIGHT * this.StatusCoefficient * Constants.CAPSULE_HEIGHT_MULTIPLE + 'px')
.backgroundColor($r('app.color.background_color'))
.borderRadius($r('app.float.green_capsule_radius'))
.visibility(this.mCapsuleViewModel.mIsBackground ? Visibility.Visible : Visibility.Hidden)
.visibility(this.mCapsuleViewModel.mIsBackground ? Visibility.Visible : Visibility.None)
.onTouch(this.touchEvent.bind(this))
}
@@ -51,7 +51,7 @@ export class TimeModel {
let urivar = null;
let helper = null;
try {
urivar = settings.getUriSync('settings.time.format')
urivar = settings.getUri('settings.time.format')
helper = featureAbility.acquireDataAbilityHelper(urivar);
} catch (e) {
Log.showInfo(TAG, `settings getValue error: ${e.toString()}`);
@@ -62,7 +62,7 @@ export class TimeModel {
Log.showError(TAG, `failed to getAbilityWant because ${err.message}`);
return;
} else {
let getRetValue = settings.getValueSync(helper, 'settings.time.format', '24')
let getRetValue = settings.getValue(helper, 'settings.time.format', '24')
Log.showInfo(TAG, 'observer reveive notifychange on success format = ' + getRetValue)
if (getRetValue === '12') {
misUsing24hFormat = false;
@@ -15,6 +15,7 @@
import Resmgr from '@ohos.resourceManager';
import Log from '../../../../../../../../common/src/main/ets/default/Log.ets';
import SwitchUserManager from '../../../../../../../../common/src/main/ets/default/SwitchUserManager.ets';
import CheckEmptyUtils from '../../../../../../../../common/src/main/ets/default/CheckEmptyUtils.ets';
import PluginDataSourceAdapter from '../../../../../../../../common/src/main/ets/plugindatasource/PluginDataSourceAdapter.ets';
import Constants from '../common/Constants.ets';
@@ -47,6 +48,7 @@ export class ControlCenterService {
'addItem': this.onItemAdd.bind(this),
'removeItem': this.onItemRemove.bind(this)
});
SwitchUserManager.getInstance().registerListener(this);
{
CONTROLCENTER_SOURCE_CONFIG.MetaSource.filterIds = filterIds;
}
@@ -63,9 +65,20 @@ export class ControlCenterService {
this?.mAdapter.clearAll();
}
loadData() {
userChange(userInfo) {
Log.showInfo(TAG, `userChange userInfo ` + userInfo);
this.loadData(userInfo.userId);
}
loadData(userId) {
Log.showInfo(TAG, `loadData`)
this.mAdapter.loadData();
if (userId === null || userId === undefined) {
SwitchUserManager.getInstance().getCurrentUserInfo().then((userInfo) => {
this.mAdapter.loadData(userInfo.userId);
});
} else {
this.mAdapter.loadData(userId);
}
}
registerListener(listener: {
@@ -39,7 +39,7 @@ type NotificationContent = {
async function getUserId(uid) {
Log.showInfo(TAG, `getOsAccountLocalIdFromUid request.creatorUid = ${uid}`);
let userId = 0;
//todo userId = AccountManager.getAccountManager().getOsAccountLocalIdFromUid(uid)
userId = await AccountManager.getAccountManager().getOsAccountLocalIdFromUid(uid);
Log.showInfo(TAG, `getOsAccountLocalIdFromUid userId = ${userId}`);
return userId;
}
@@ -15,6 +15,7 @@
import Resmgr from '@ohos.resourceManager';
import Log from '../../../../../../../../common/src/main/ets/default/Log.ets';
import SwitchUserManager from '../../../../../../../../common/src/main/ets/default/SwitchUserManager.ets';
import CheckEmptyUtils from '../../../../../../../../common/src/main/ets/default/CheckEmptyUtils.ets';
import PluginDataSourceAdapter from '../../../../../../../../common/src/main/ets/plugindatasource/PluginDataSourceAdapter.ets';
import Constants from '../common/Constants.ets';
@@ -51,6 +52,7 @@ export class StatusBarService {
'addItem': this.onItemAdd.bind(this),
'removeItem': this.onItemRemove.bind(this)
});
SwitchUserManager.getInstance().registerListener(this);
{
STATUSBAR_SOURCE_CONFIG.MetaSource.filterIds = filterIds;
}
@@ -67,9 +69,20 @@ export class StatusBarService {
this?.mAdapter.clearAll();
}
loadData() {
userChange(userInfo) {
Log.showInfo(TAG, `userChange userInfo ` + userInfo);
this.loadData(userInfo.userId);
}
loadData(userId) {
Log.showInfo(TAG, `loadData`)
this.mAdapter.loadData();
if (userId === null || userId === undefined) {
SwitchUserManager.getInstance().getCurrentUserInfo().then((userInfo) => {
this.mAdapter.loadData(userInfo.userId);
});
} else {
this.mAdapter.loadData(userId);
}
}
registerListener(listener: {
@@ -28,7 +28,7 @@ export class VolumeModel {
init(): void{
Log.showInfo(TAG, 'init');
this.uri = settings.getUriSync(SYSTEMUI_AUDIOVOLUMETYPE_MEDIA);
this.uri = settings.getUri(SYSTEMUI_AUDIOVOLUMETYPE_MEDIA);
Log.showInfo(TAG, 'settings geturi of audio.AudioVolumeType.MEDIA is ' + this.uri);
this.helper = featureAbility.acquireDataAbilityHelper(this.uri);
this.getVolume();
@@ -36,7 +36,7 @@ export class VolumeModel {
registerVolume() {
this.helper.on("dataChange", this.uri, (err) => {
let data = settings.getValueSync(this.helper, SYSTEMUI_AUDIOVOLUMETYPE_MEDIA, '5')
let data = settings.getValue(this.helper, SYSTEMUI_AUDIOVOLUMETYPE_MEDIA, '5')
Log.showInfo(TAG, `after audio.AudioVolumeType.MEDIA datachange settings getValue ${parseInt(data)}`);
mVolumeValue.set(parseInt(data));
})
@@ -54,13 +54,13 @@ export class VolumeModel {
Log.showInfo(TAG, `setVolume ${value}`);
mVolumeValue.set(value);
Log.showInfo(TAG, `mVolumeValue setVolume ${value} end`);
settings.setValueSync(this.helper, SYSTEMUI_AUDIOVOLUMETYPE_MEDIA, callback.value.toString());
settings.setValue(this.helper, SYSTEMUI_AUDIOVOLUMETYPE_MEDIA, callback.value.toString());
Log.showInfo(TAG, `settings setVolume ${callback.value} end`);
}
getVolume() {
Log.showInfo(TAG, 'getVolume');
let data = settings.getValueSync(this.helper, SYSTEMUI_AUDIOVOLUMETYPE_MEDIA, '5');
let data = settings.getValue(this.helper, SYSTEMUI_AUDIOVOLUMETYPE_MEDIA, '5');
Log.showInfo(TAG, `settings getVolume ${parseInt(data)}`);
mVolumeValue.set(parseInt(data));
}
@@ -36,7 +36,7 @@ parentPort.onmessage = (msg) => {
clearAll();
break;
case Constants.LOAD_DATA:
loadData();
loadData(data.data);
break;
default:
Log.showError(TAG, `onMessage, unknown action type.`);
@@ -63,9 +63,9 @@ function clearAll() {
sManager?.clearAll();
}
function loadData() {
function loadData(userId) {
Log.showInfo(TAG, `loadData `);
sManager?.loadData();
sManager?.loadData(userId);
}
parentPort.onclose = function () {