Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
remove old model & editor
Browse files Browse the repository at this point in the history
  • Loading branch information
weg2022 committed Jul 24, 2023
1 parent 990a42f commit f7c6945
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 343 deletions.
10 changes: 1 addition & 9 deletions app/src/main/java/com/apkide/ui/IDEEditor.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.apkide.ui;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;

import com.apkide.ui.views.CodeEditText;
Expand All @@ -23,15 +22,8 @@ public IDEEditor(Context context, AttributeSet attrs, int defStyle) {
}

private void initView() {
setFont(Typeface.createFromAsset(getContext().getAssets(), "fonts/CascadiaMono-Regular.ttf"));
syncConfigure();

}


@Override
public void syncConfigure() {
setTabSize(AppPreferences.getEditorTabSize());
setFontSize(AppPreferences.getEditorFontSize());
super.syncConfigure();
}
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/apkide/ui/IDEEditorPager.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ public List<IDEEditor> getEditors() {

public void syncConfigure() {
for (int i = 0; i < myViews.size(); i++) {
getEditor(i).syncConfigure();
getEditor(i).getEditorView().redraw();

}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/apkide/ui/MainUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void onConfigurationChanged(@NonNull Configuration newConfig) {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.startsWith("editor")){
mainBinding.mainEditorPager.syncConfigure();

}
}

Expand Down
58 changes: 0 additions & 58 deletions app/src/main/java/com/apkide/ui/project/ApkToolProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
import static com.apkide.ui.FileSystem.exists;
import static java.io.File.separator;

import com.apkide.common.FileUtils;
import com.apkide.engine.EngineSolution;
import com.apkide.engine.service.CodeModels;
import com.apkide.ui.FileSystem;

import java.util.ArrayList;
import java.util.List;

public class ApkToolProject implements ConfigurationMarker {

Expand Down Expand Up @@ -45,55 +38,4 @@ public static String getSmaliDir(String rootPath) {
return rootPath + separator + "smali";
}

public static EngineSolution emptySolution() {
return new EngineSolution(new ArrayList<>(), null, CodeModels.getFilePatternMap());
}

public static EngineSolution createSolution(String rootPath, String androidJarPath) {
ArrayList<EngineSolution.Project> projects = new ArrayList<>();
projects.add(createProject(rootPath));
projects.add(createAndroidSDKProject(androidJarPath));
return new EngineSolution(projects, null, CodeModels.getFilePatternMap());
}

private static EngineSolution.Project createProject(String rootPath) {
String projectName = FileUtils.getFileName(rootPath);
String buildPath = "";
ArrayList<EngineSolution.File> files = new ArrayList<>();
List<String> list = FileSystem.getChildEntries(rootPath);
for (String path : list) {
if (FileSystem.isNormalDirectory(path)) {
String fileName = FileSystem.getName(path);
if (fileName.equalsIgnoreCase("smali")) {
files.add(new EngineSolution.File(path, "Smali", null, false, false));
} else if (fileName.startsWith("smali_")) {
//TODO:需要改进判断 smali 源文件目录
files.add(new EngineSolution.File(path, "Smali", null, false, false));
}
}
}
files.add(new EngineSolution.File(rootPath + separator + "src", "Java", null, false, false));
files.add(new EngineSolution.File(rootPath + separator + "res", "XML", null, false, false));
//files.add(new EngineSolution.File(getAndroidManifestXml(rootPath), "XML", null, true, true));
ArrayList<String> assembles = new ArrayList<>();
assembles.add("android.jar");
assembles.add(projectName);
return new EngineSolution.Project(projectName, rootPath, projectName,
files, assembles, true,
"", buildPath, "1.8", false, false,
new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
}

private static EngineSolution.Project createAndroidSDKProject(String androidJarPath) {
ArrayList<EngineSolution.File> files = new ArrayList<>();
files.add(new EngineSolution.File(androidJarPath, "Java Binary", "", false, true));
ArrayList<String> assembles = new ArrayList<>();
assembles.add("android.jar");
return new EngineSolution.Project("android.jar",
androidJarPath, "android.jar",
files, assembles, false,
"", "", "",
false, false,
new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
}
}
81 changes: 0 additions & 81 deletions app/src/main/java/com/apkide/ui/views/CodeEditText.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
package com.apkide.ui.views;

import static java.lang.Math.max;

import android.content.Context;
import android.graphics.Typeface;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import androidx.annotation.NonNull;

import com.apkide.common.AppLog;
import com.apkide.ui.views.editor.Editor;
import com.apkide.ui.views.editor.EditorColor;
import com.apkide.ui.views.editor.TextAttribute;

public class CodeEditText extends ViewGroup {
public CodeEditText(Context context) {
Expand All @@ -40,24 +28,6 @@ private void initView() {
addView(new EditorView(getContext()));
}

public void setFont(Typeface typeface){
getEditorView().setTypeface(typeface);
}
public void setFontSize(int fontSize){
getEditorView().setFontSize(fontSize);
}

public void setTabSize(int tabSize){
getEditorView().setTabSize(tabSize);
}

public void syncConfigure(){
getEditorView().syncConfigure();
}
public void setText(@NonNull CharSequence text){
getEditorView().setText(text);
}

public String getFilePath() {
return filePath;
}
Expand All @@ -69,7 +39,6 @@ public EditorView getEditorView() {
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
getChildAt(0).layout(0, 0, r - l, b - t);
getEditorView().redraw();
}

@Override
Expand All @@ -79,54 +48,4 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(view.getMeasuredWidth(),view.getMeasuredHeight());
}

public class EditorView extends Editor {
private final WindowManager windowManager;

public EditorView(Context context) {
super(context);
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
}

@Override
protected void registerColorScheme() {
setFontColor(new EditorColor(0xff212121));
setCaretColor(new EditorColor(0xff212121));
setCaretLineColor(new EditorColor(0xfff5f5f5));
setLineNumberColor(new EditorColor(0xffd0d0d0));
setWhitespaceColor(new EditorColor(0xffd0d0d0));
setSelectionColor(new EditorColor(0xff0099cc));
setSelectionBackgroundColor(new EditorColor(0xffa6d2ff));
setKeywordTextAttribute(new TextAttribute(new EditorColor(0xff2c82c8), Typeface.BOLD));
setOperatorTextAttribute(new TextAttribute(new EditorColor(0xff007c1f)));
setSeparatorTextAttribute(new TextAttribute(new EditorColor(0xff212121)));
setNumberLiteralTextAttribute(new TextAttribute(new EditorColor(0xffbc0000)));
setStringLiteralTextAttribute(new TextAttribute(new EditorColor(0xffbc0000)));
setMetadataTextAttribute(new TextAttribute(new EditorColor(0xff9E880D)));
setIdentifierTextAttribute(new TextAttribute(new EditorColor(0xff212121)));
setNamespaceIdentifierTextAttribute(new TextAttribute(new EditorColor(0xff5d5d5d),Typeface.ITALIC));
setClassIdentifierTextAttribute(new TextAttribute(new EditorColor(0xff0096ff)));
setTypeIdentifierTextAttribute(new TextAttribute(new EditorColor(0xff0096ff)));
setVariableIdentifierTextAttribute(new TextAttribute(new EditorColor(0xff212121)));
setFunctionIdentifierTextAttribute(new TextAttribute(new EditorColor(0xff174ad4)));
setParameterIdentifierTextAttribute(new TextAttribute(new EditorColor(0xff212121)));
setCommentTextAttribute(new TextAttribute(new EditorColor(0xff009b00)));
setDocCommentTextAttribute(new TextAttribute(new EditorColor(0xff009b00), Typeface.ITALIC));
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width;
int height;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
width = windowManager.getCurrentWindowMetrics().getBounds().width();
height = windowManager.getCurrentWindowMetrics().getBounds().height();
} else {
width = windowManager.getDefaultDisplay().getWidth();
height = windowManager.getDefaultDisplay().getHeight();
}
setMeasuredDimension(max(getMeasuredWidth(), width), max(getMeasuredHeight(), height));
AppLog.d("w:"+getMeasuredWidth()+" h:"+getMeasuredHeight());
}
}
}

This file was deleted.

Loading

0 comments on commit f7c6945

Please sign in to comment.