Commit 616ba36e by Baoxy

build: 本地完成应用使用情况界面(暂时屏蔽)

parent 30b6389c
...@@ -109,7 +109,8 @@ ...@@ -109,7 +109,8 @@
<activity <activity
android:name=".function.setting.AppUseActivity" android:name=".function.setting.AppUseActivity"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:theme="@style/SettingTheme"></activity> android:theme="@style/SettingTheme"
android:configChanges="orientation|keyboardHidden"></activity>
<activity <activity
android:name=".ManagerAuthActivity" android:name=".ManagerAuthActivity"
......
<vector android:height="24dp" android:tint="#E5E5E5"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/>
</vector>
<vector android:height="24dp" android:tint="#E5E5E5"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
</vector>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
android:id="@+id/tv_setting_title" android:id="@+id/tv_setting_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:background="#FFF2F2F2" android:background="#F6F6F6"
android:drawableStart="@mipmap/ic_back" android:drawableStart="@mipmap/ic_back"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:gravity="center_vertical" android:gravity="center_vertical"
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
android:textColor="#363636" android:textColor="#363636"
android:textSize="16sp" /> android:textSize="16sp" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
...@@ -41,7 +46,6 @@ ...@@ -41,7 +46,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="48dp" android:layout_height="48dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:onClick="close"
android:textColor="#363636" android:textColor="#363636"
android:textSize="16sp" /> android:textSize="16sp" />
...@@ -52,19 +56,21 @@ ...@@ -52,19 +56,21 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp" android:layout_marginRight="10dp"
android:layout_marginRight="10dp" /> android:layout_marginBottom="6dp" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="40dp"
android:layout_margin="10dp" android:layout_marginLeft="10dp"
android:layout_marginTop="6dp"
android:layout_marginRight="10dp"
android:background="@drawable/select_date_select" android:background="@drawable/select_date_select"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="48dp" android:layout_height="match_parent"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="16dp" android:paddingLeft="16dp"
...@@ -82,7 +88,7 @@ ...@@ -82,7 +88,7 @@
<TextView <TextView
android:id="@+id/tv_date_start" android:id="@+id/tv_date_start"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="48dp" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:gravity="center"
android:text="开始时间" android:text="开始时间"
...@@ -100,7 +106,7 @@ ...@@ -100,7 +106,7 @@
<TextView <TextView
android:id="@+id/tv_date_end" android:id="@+id/tv_date_end"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="48dp" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:gravity="center"
android:text="结束时间" android:text="结束时间"
...@@ -108,46 +114,30 @@ ...@@ -108,46 +114,30 @@
android:textSize="15sp" /> android:textSize="15sp" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView <TextView
android:id="@+id/tv_app_use_total_time" android:id="@+id/tv_app_use_total_time"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="48dp" android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:onClick="close"
android:textColor="#363636" android:textColor="#363636"
android:textSize="16sp" /> android:textSize="16sp" />
<com.qmuiteam.qmui.widget.QMUIEmptyView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="48dp"
android:onClick="more"
android:drawableEnd="@drawable/ic_chevron_right_gray_24dp"
android:gravity="center_vertical"
android:text="@string/edu_item_app_use_more"
android:textColor="#ABABAB"
android:textSize="15sp" />
</LinearLayout>
<com.secspace.lib.common.function.view.UseTimeProgress <com.secspace.lib.common.function.view.UseTimeProgress
android:id="@+id/use_time_progress" android:id="@+id/use_time_progress"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" /> android:layout_marginRight="10dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_tree"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />
</LinearLayout> </LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="35dp"
android:background="@color/bg_white">
<LinearLayout
android:id="@+id/item_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/item_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
tools:src="@mipmap/ic_launcher_home" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom"
android:orientation="horizontal">
<TextView
android:id="@+id/item_tv_app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="#363636"
android:text="微信"
android:textSize="14sp" />
<TextView
android:id="@+id/item_tv_app_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="#363636"
android:text="(21次)"
android:textSize="14sp" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/item_tv_app_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="#363636"
android:text="20分钟"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_weight="1">
<com.secspace.lib.common.function.view.UseTimeProgress
android:id="@+id/item_use_time_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="5dp"/>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/item_indicator"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
tools:src="@mipmap/ic_launcher_home" />
</LinearLayout>
<LinearLayout
android:id="@+id/item_child"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Space
android:layout_width="35dp"
android:layout_height="35dp"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/item_tv_app_details_start"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#ACACAC"
android:text="2020-04-07 17:33"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#ACACAC"
android:layout_margin="10dp"
android:text="-"
android:textSize="14sp" />
<TextView
android:id="@+id/item_tv_app_details_end"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#ACACAC"
android:text="2020-04-07 17:33"
android:textSize="14sp" />
</LinearLayout>
<Space
android:layout_width="35dp"
android:layout_height="35dp"/>
</LinearLayout>
</FrameLayout>
...@@ -380,9 +380,10 @@ ...@@ -380,9 +380,10 @@
<string name="edu_item_input_encryted_title">请输入密保答案用于修改密码</string> <string name="edu_item_input_encryted_title">请输入密保答案用于修改密码</string>
<string name="edu_item_app_use_title">应用使用情况</string> <string name="edu_item_app_use_title">应用使用情况</string>
<string name="edu_item_app_use_last_day">最近一天使用时长: %1$s分钟</string> <string name="edu_item_app_use_last_day">最近一天使用时长: %1$s</string>
<string name="edu_item_app_use_more">生成报告</string> <string name="edu_item_app_use_more">生成报告</string>
<string name="edu_item_app_use_total">使用总时长: %1$s分钟</string> <string name="edu_item_app_use_total">使用总时长: %1$s</string>
<string name="edu_item_app_use_count">(%1$d次)</string>
<string name="edu_item_app_use_time">%1$s</string>
</resources> </resources>
...@@ -205,6 +205,7 @@ public abstract class BaseContainerView extends FrameLayout ...@@ -205,6 +205,7 @@ public abstract class BaseContainerView extends FrameLayout
if (distance < viewConfig.getScaledTouchSlop()) { if (distance < viewConfig.getScaledTouchSlop()) {
// The background was clicked, so just go home // The background was clicked, so just go home
Launcher.getLauncher(getContext()).showWorkspace(true); Launcher.getLauncher(getContext()).showWorkspace(true);
Launcher.forceReload();
return true; return true;
} }
} }
......
package com.android.launcher3.function.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.launcher3.R;
import com.secspace.lib.common.function.entity.UseAppListEntity;
import com.secspace.lib.common.function.view.UseTimeProgress;
import java.util.LinkedList;
import java.util.List;
import static com.secspace.lib.common.utils.UtilsKt.formatDateTime;
public class TreeAdapter extends RecyclerView.Adapter<TreeAdapter.ViewHolder> implements TreeStateChangeListener {
private final static int ITEM_STATE_CLOSE = 0;
private final static int ITEM_STATE_OPEN = 1;
private Context mContext;
private List<UseAppListEntity> mList;
private float totalTime;
public TreeAdapter(Context context, List<UseAppListEntity> list, long totalTime) {
initList(list, 0);
this.totalTime = totalTime;
this.mList = new LinkedList<>();
this.mContext = context;
this.mList.addAll(list);
}
private void initList(List<UseAppListEntity> list, int itemLevel) {
if (list == null || list.size() <= 0) return;
for (UseAppListEntity item: list) {
item.setItemLevel(itemLevel);
if (item.getChild() != null && item.getChild().size() > 0) {
initList(item.getChild(), itemLevel + 1);
}
}
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_app_list, viewGroup, false));
}
@Override
public void onBindViewHolder(@NonNull final ViewHolder viewHolder, int i) {
final UseAppListEntity treeItem = mList.get(i);
viewHolder.mAppName.setText(treeItem.getAppName());
viewHolder.mCount.setText(String.format(mContext.getString(R.string.edu_item_app_use_count), treeItem.getCount()));
viewHolder.mUseTime.setText(String.format(mContext.getString(R.string.edu_item_app_use_time), formatDateTime(treeItem.getUseTime())));
if(treeItem.getItemLevel() == 0){
viewHolder.mParent.setVisibility(View.VISIBLE);
viewHolder.mChild.setVisibility(View.GONE);
viewHolder.mIndicator.setVisibility(View.VISIBLE);
if (treeItem.getItemState() == ITEM_STATE_OPEN) {
viewHolder.mIndicator.setImageResource(R.drawable.ic_expand_more);
} else {
viewHolder.mIndicator.setImageResource(R.drawable.ic_expand_less_24dp);
}
if(treeItem.getIcon() != null){
viewHolder.mIcon.setImageDrawable(treeItem.getIcon());
}
viewHolder.mProgress.setProgress(treeItem.getUseTime()/totalTime * 100, treeItem.getAppName());
}else{
viewHolder.mParent.setVisibility(View.GONE);
viewHolder.mChild.setVisibility(View.VISIBLE);
viewHolder.mStartTime.setText(treeItem.getStartTime());
viewHolder.mEndTime.setText(treeItem.getEndTime());
viewHolder.mChild.setBackgroundColor(0xFFF2F2F2);
}
if (treeItem.getChild() != null && treeItem.getChild().size() > 0) {
if (treeItem.getItemState() == ITEM_STATE_OPEN) {
viewHolder.mIndicator.setImageResource(R.drawable.ic_expand_more);
} else {
viewHolder.mIndicator.setImageResource(R.drawable.ic_expand_less_24dp);
}
}
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (treeItem.getItemState() == ITEM_STATE_CLOSE) {
onOpen(treeItem, viewHolder.getAdapterPosition());
} else {
onClose(treeItem, viewHolder.getAdapterPosition());
}
}
});
}
@Override
public int getItemCount() {
return mList.size();
}
private void closeChild(UseAppListEntity entity) {
if (entity.getChild() != null) {
for (UseAppListEntity child: entity.getChild()) {
child.setItemState(ITEM_STATE_CLOSE);
closeChild(child);
}
}
}
@Override
public void onOpen(UseAppListEntity entity, int position) {
if (entity.getChild() != null && entity.getChild().size() > 0) {
mList.addAll(position + 1, entity.getChild());
entity.setItemState(ITEM_STATE_OPEN);
notifyItemRangeInserted(position + 1, entity.getChild().size());
notifyItemChanged(position);
}
}
@Override
public void onClose(UseAppListEntity entity, int position) {
if (entity.getChild() != null && entity.getChild().size() > 0) {
int nextSameOrHigherLevelNodePosition = mList.size() - 1;
if (mList.size() > position + 1) {
for (int i = position + 1; i < mList.size(); i++) {
if (mList.get(i).getItemLevel() <= mList.get(position).getItemLevel()) {
nextSameOrHigherLevelNodePosition = i - 1;
break;
}
}
closeChild(mList.get(position));
if (nextSameOrHigherLevelNodePosition > position) {
mList.subList(position + 1, nextSameOrHigherLevelNodePosition + 1).clear();
entity.setItemState(ITEM_STATE_CLOSE);
notifyItemRangeRemoved(position + 1, nextSameOrHigherLevelNodePosition - position);
notifyItemChanged(position);
}
}
}
}
class ViewHolder extends RecyclerView.ViewHolder {
LinearLayout mParent;
ImageView mIcon;
TextView mAppName;
TextView mCount;
TextView mUseTime;
UseTimeProgress mProgress;
ImageView mIndicator;
LinearLayout mChild;
TextView mStartTime;
TextView mEndTime;
ViewHolder(@NonNull View itemView) {
super(itemView);
mParent = itemView.findViewById(R.id.item_parent);
mChild = itemView.findViewById(R.id.item_child);
mIcon = itemView.findViewById(R.id.item_icon);
mAppName = itemView.findViewById(R.id.item_tv_app_name);
mCount = itemView.findViewById(R.id.item_tv_app_count);
mUseTime = itemView.findViewById(R.id.item_tv_app_time);
mProgress = itemView.findViewById(R.id.item_use_time_progress);
mIndicator = itemView.findViewById(R.id.item_indicator);
mStartTime = itemView.findViewById(R.id.item_tv_app_details_start);
mEndTime = itemView.findViewById(R.id.item_tv_app_details_end);
}
}
}
package com.android.launcher3.function.adapter;
import com.secspace.lib.common.function.entity.UseAppListEntity;
public interface TreeStateChangeListener {
void onOpen(UseAppListEntity entity, int position);
void onClose(UseAppListEntity entity, int position);
}
...@@ -209,6 +209,7 @@ public class DialogUIUtils { ...@@ -209,6 +209,7 @@ public class DialogUIUtils {
CharSequence sure, CharSequence cancel, boolean isVertical, boolean cancleable, boolean outsideTouchable, DialogUIListener listener) { CharSequence sure, CharSequence cancel, boolean isVertical, boolean cancleable, boolean outsideTouchable, DialogUIListener listener) {
return DialogAssigner.getInstance().assignAlertPasswordCanVer(activity, title, msg, thirdTx, hint1, hint2, sure, cancel, isVertical, cancleable, outsideTouchable, listener); return DialogAssigner.getInstance().assignAlertPasswordCanVer(activity, title, msg, thirdTx, hint1, hint2, sure, cancel, isVertical, cancleable, outsideTouchable, listener);
} }
/** /**
* 短时间中下位置显示。线程安全,可以在非UI线程调用。 * 短时间中下位置显示。线程安全,可以在非UI线程调用。
*/ */
......
...@@ -68,7 +68,8 @@ object WorkManager { ...@@ -68,7 +68,8 @@ object WorkManager {
} }
// LoadingDialog.getInstance(launcher).show("切换中") // LoadingDialog.getInstance(launcher).show("切换中")
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
openAccessibility(launcher) // TODO 暂时屏蔽
// openAccessibility(launcher)
SwitchInMdm.onInit(launcher) SwitchInMdm.onInit(launcher)
activate(launcher) activate(launcher)
withContext(Dispatchers.Main){ withContext(Dispatchers.Main){
......
package com.secspace.lib.common.function.entity
import android.graphics.drawable.Drawable
data class UseAppListEntity(var itemLevel: Int) {
var appName: String = ""
var appPackage: String = ""
var icon: Drawable? = null
var useTime: Long = 0
var count: Long = 0
var startTime: String = ""
var endTime: String = ""
var itemState: Int = 0
var child: List<UseAppListEntity>? = null
}
\ No newline at end of file
...@@ -104,6 +104,15 @@ public class AppUseProgress extends View { ...@@ -104,6 +104,15 @@ public class AppUseProgress extends View {
paintColors.add(0xFF9BFA13); paintColors.add(0xFF9BFA13);
paintColors.add(0xFFFAB613); paintColors.add(0xFFFAB613);
paintColors.add(0xFFE5E5E5); paintColors.add(0xFFE5E5E5);
paintColors.add(0xFFE5E5E5);
paintColors.add(0xFFE5E5E5);
paintColors.add(0xFFE5E5E5);
paintColors.add(0xFFE5E5E5);
paintColors.add(0xFFE5E5E5);
paintColors.add(0xFFE5E5E5);
paintColors.add(0xFFE5E5E5);
paintColors.add(0xFFE5E5E5);
paintColors.add(0xFFE5E5E5);
} }
public void setData(List<UseAppEntity> useAppEntities, long allTime) { public void setData(List<UseAppEntity> useAppEntities, long allTime) {
......
...@@ -8,6 +8,7 @@ import android.graphics.Rect; ...@@ -8,6 +8,7 @@ import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View; import android.view.View;
import android.view.animation.LinearInterpolator; import android.view.animation.LinearInterpolator;
...@@ -33,7 +34,7 @@ public class UseTimeProgress extends View { ...@@ -33,7 +34,7 @@ public class UseTimeProgress extends View {
*/ */
private float mProgress; private float mProgress;
//描述文字的高度 //描述文字的高度
private float textHeight; // private float textHeight;
//描述文字的高度 //描述文字的高度
private float textWidth; private float textWidth;
...@@ -127,11 +128,8 @@ public class UseTimeProgress extends View { ...@@ -127,11 +128,8 @@ public class UseTimeProgress extends View {
progressHeight = dp2px(6); progressHeight = dp2px(6);
roundRectRadius = dp2px(3); roundRectRadius = dp2px(3);
textPaintSize = sp2px(10); textPaintSize = sp2px(10);
textHeight = dp2px(10); // textHeight = dp2px(10);
progressMarginTop = dp2px(4); // progressMarginTop = dp2px(4);
//view真实的高度
mViewHeight = (int) (progressMarginTop + progressPaintWidth * 2 + progressHeight);
} }
...@@ -214,7 +212,7 @@ public class UseTimeProgress extends View { ...@@ -214,7 +212,7 @@ public class UseTimeProgress extends View {
switch (mode) { switch (mode) {
case MeasureSpec.UNSPECIFIED: case MeasureSpec.UNSPECIFIED:
case MeasureSpec.AT_MOST: case MeasureSpec.AT_MOST:
mHeight = mViewHeight; mHeight = progressMarginTop + progressPaintWidth * 2 + progressHeight;
break; break;
case MeasureSpec.EXACTLY: case MeasureSpec.EXACTLY:
mHeight = height; mHeight = height;
...@@ -226,7 +224,7 @@ public class UseTimeProgress extends View { ...@@ -226,7 +224,7 @@ public class UseTimeProgress extends View {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
super.onDraw(canvas); super.onDraw(canvas);
mWidth = getMeasuredWidth();
//绘制文字 //绘制文字
// drawText(canvas, textString); // drawText(canvas, textString);
//背景 //背景
...@@ -237,16 +235,17 @@ public class UseTimeProgress extends View { ...@@ -237,16 +235,17 @@ public class UseTimeProgress extends View {
private void drawBgProgress(Canvas canvas) { private void drawBgProgress(Canvas canvas) {
bgRectF.left = 0; bgRectF.left = 0;
bgRectF.top = textHeight + progressMarginTop; bgRectF.top = progressMarginTop;
bgRectF.right = this.getMeasuredWidth(); bgRectF.right = this.getMeasuredWidth();
bgRectF.bottom = bgRectF.top + progressHeight; bgRectF.bottom = bgRectF.top + progressHeight;
canvas.drawRoundRect(bgRectF, roundRectRadius, roundRectRadius, bgPaint); canvas.drawRoundRect(bgRectF, roundRectRadius, roundRectRadius, bgPaint);
Log.e("TAG1", " this.getMeasuredWidth():" + this.getMeasuredWidth());
} }
private void drawProgress(Canvas canvas) { private void drawProgress(Canvas canvas) {
progressRectF.left = 0; progressRectF.left = 0;
progressRectF.top = textHeight + progressMarginTop; progressRectF.top = progressMarginTop;
progressRectF.right = currentProgress; progressRectF.right = mProgress * this.getMeasuredWidth() / 100;
progressRectF.bottom = progressRectF.top + progressHeight; progressRectF.bottom = progressRectF.top + progressHeight;
canvas.drawRoundRect(progressRectF, roundRectRadius, roundRectRadius, progressPaint); canvas.drawRoundRect(progressRectF, roundRectRadius, roundRectRadius, progressPaint);
} }
...@@ -261,7 +260,7 @@ public class UseTimeProgress extends View { ...@@ -261,7 +260,7 @@ public class UseTimeProgress extends View {
textRect.left = (int) moveDis; textRect.left = (int) moveDis;
textRect.top = 0; textRect.top = 0;
textRect.right = (int) (textPaint.measureText(textString) + moveDis); textRect.right = (int) (textPaint.measureText(textString) + moveDis);
textRect.bottom = (int) textHeight; // textRect.bottom = (int) textHeight;
Paint.FontMetricsInt fontMetrics = textPaint.getFontMetricsInt(); Paint.FontMetricsInt fontMetrics = textPaint.getFontMetricsInt();
int baseline = (textRect.bottom + textRect.top - fontMetrics.bottom - fontMetrics.top) / 2; int baseline = (textRect.bottom + textRect.top - fontMetrics.bottom - fontMetrics.top) / 2;
//文字绘制到整个布局的中心位置 //文字绘制到整个布局的中心位置
...@@ -281,8 +280,6 @@ public class UseTimeProgress extends View { ...@@ -281,8 +280,6 @@ public class UseTimeProgress extends View {
@Override @Override
public void onAnimationUpdate(ValueAnimator valueAnimator) { public void onAnimationUpdate(ValueAnimator valueAnimator) {
float value = (float) valueAnimator.getAnimatedValue(); float value = (float) valueAnimator.getAnimatedValue();
textString = "已售" + formatNum((int) value) + "%";
textWidth = textPaint.measureText(textString);
currentProgress = value * mWidth / 100; currentProgress = value * mWidth / 100;
if (progressListener != null) { if (progressListener != null) {
progressListener.currentProgressListener(value); progressListener.currentProgressListener(value);
...@@ -318,8 +315,16 @@ public class UseTimeProgress extends View { ...@@ -318,8 +315,16 @@ public class UseTimeProgress extends View {
} }
public UseTimeProgress setProgress(float progress) { public UseTimeProgress setProgress(float progress) {
return setProgress(progress, "NoTag");
}
public UseTimeProgress setProgress(float progress, String tag) {
mWidth = this.getMeasuredWidth();
mProgress = progress; mProgress = progress;
initAnimation(); // initAnimation();
currentProgress = mProgress * mWidth / 100;
Log.e("TAG1", "tag: "+ tag + " mProgress:" + mProgress + " mWidth:" + mWidth);
invalidate();
return this; return this;
} }
......
...@@ -13,6 +13,8 @@ import com.skr.activation.utils.DesUtil ...@@ -13,6 +13,8 @@ import com.skr.activation.utils.DesUtil
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.File import java.io.File
import java.io.FileWriter import java.io.FileWriter
import java.text.SimpleDateFormat
import java.util.*
fun decrypt(strMi: String): String { fun decrypt(strMi: String): String {
...@@ -98,3 +100,27 @@ fun write2File(source: String, filePath: String) { ...@@ -98,3 +100,27 @@ fun write2File(source: String, filePath: String) {
fileWriter.write(source) fileWriter.write(source)
} }
} }
fun formatDate2MdHm(date: Long): String{
val format = SimpleDateFormat("MM-dd HH:mm", Locale.US)
return format.format(Date(date))
}
fun formatDateTime(minute: Long): String {
var stringTimes = ""
val days = minute / (60 * 24)
val hours = minute % (60 * 24) / 60
val minutes = minute % 60
when {
days > 0 -> {
stringTimes = days.toString() + "天" + hours + "时" + minutes + "分"
}
hours > 0 -> {
stringTimes = hours.toString() + "时" + minutes + "分"
}
minutes > 0 -> {
stringTimes = minutes.toString() + "分"
}
}
return stringTimes
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment