优化 夜间模式的显示
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.stardust.autojs.core.console;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@@ -17,11 +18,12 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stardust.autojs.R;
|
||||
import com.stardust.concurrent.ConcurrentArrayList;
|
||||
import com.stardust.enhancedfloaty.ResizableExpandableFloatyWindow;
|
||||
import com.stardust.util.MapBuilder;
|
||||
import com.stardust.util.SparseArrayEntries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/2.
|
||||
@@ -30,6 +32,15 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class ConsoleView extends FrameLayout implements StardustConsole.LogListener {
|
||||
|
||||
private static final Map<Integer, Integer> ATTRS = new MapBuilder<Integer, Integer>()
|
||||
.put(R.styleable.ConsoleView_color_verbose, Log.VERBOSE)
|
||||
.put(R.styleable.ConsoleView_color_debug, Log.DEBUG)
|
||||
.put(R.styleable.ConsoleView_color_info, Log.INFO)
|
||||
.put(R.styleable.ConsoleView_color_warn, Log.WARN)
|
||||
.put(R.styleable.ConsoleView_color_error, Log.ERROR)
|
||||
.put(R.styleable.ConsoleView_color_assert, Log.ASSERT)
|
||||
.build();
|
||||
|
||||
static final SparseArray<Integer> COLORS = new SparseArrayEntries<Integer>()
|
||||
.entry(Log.VERBOSE, 0xdfc0c0c0)
|
||||
.entry(Log.DEBUG, 0xdfffffff)
|
||||
@@ -40,7 +51,7 @@ public class ConsoleView extends FrameLayout implements StardustConsole.LogListe
|
||||
.sparseArray();
|
||||
|
||||
private static final int REFRESH_INTERVAL = 100;
|
||||
private SparseArray<Integer> mColors = COLORS;
|
||||
private SparseArray<Integer> mColors = COLORS.clone();
|
||||
private StardustConsole mConsole;
|
||||
private RecyclerView mLogListRecyclerView;
|
||||
private EditText mEditText;
|
||||
@@ -51,25 +62,33 @@ public class ConsoleView extends FrameLayout implements StardustConsole.LogListe
|
||||
|
||||
public ConsoleView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
init(null);
|
||||
}
|
||||
|
||||
public ConsoleView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public ConsoleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public void setColors(SparseArray<Integer> colors) {
|
||||
mColors = colors;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
private void init(AttributeSet attrs) {
|
||||
inflate(getContext(), R.layout.console_view, this);
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ConsoleView);
|
||||
for (Map.Entry<Integer, Integer> attr : ATTRS.entrySet()) {
|
||||
int styleable = attr.getKey();
|
||||
int logLevel = attr.getValue();
|
||||
mColors.put(logLevel, typedArray.getColor(styleable, mColors.get(logLevel)));
|
||||
}
|
||||
}
|
||||
mLogListRecyclerView = findViewById(R.id.log_list);
|
||||
LinearLayoutManager manager = new LinearLayoutManager(getContext());
|
||||
mLogListRecyclerView.setLayoutManager(manager);
|
||||
|
||||
@@ -15,18 +15,8 @@ import java.util.Locale;
|
||||
public class GlobalStardustConsole extends StardustConsole {
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault());
|
||||
|
||||
private final SparseArray<Integer> mColors;
|
||||
|
||||
public GlobalStardustConsole(UiHandler uiHandler) {
|
||||
super(uiHandler);
|
||||
mColors = ConsoleView.COLORS.clone();
|
||||
mColors.put(android.util.Log.DEBUG, 0xcc000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConsoleView(ConsoleView consoleView) {
|
||||
super.setConsoleView(consoleView);
|
||||
consoleView.setColors(mColors);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.stardust.autojs.core.ui.inflater.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.InflateException;
|
||||
import android.view.View;
|
||||
|
||||
11
autojs/src/main/res/values/attrs.xml
Normal file
11
autojs/src/main/res/values/attrs.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="ConsoleView">
|
||||
<attr name="color_debug" format="reference|color"/>
|
||||
<attr name="color_verbose" format="reference|color"/>
|
||||
<attr name="color_info" format="reference|color"/>
|
||||
<attr name="color_warn" format="reference|color"/>
|
||||
<attr name="color_error" format="reference|color"/>
|
||||
<attr name="color_assert" format="reference|color"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user