Skip to content

Commit

Permalink
[app] replace new code view
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed Jul 23, 2022
1 parent 1f89c71 commit a508f29
Show file tree
Hide file tree
Showing 55 changed files with 827 additions and 1,381 deletions.
Binary file modified .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private fun ServicePopupMenu(
MenuItem(
"stop",
stringResource(id = R.string.service_stop),
R.drawable.ic_close_fill
R.drawable.module_profile_ic_close_fill
),
MenuItem(
"addToGlobalVar",
Expand Down Expand Up @@ -412,7 +412,7 @@ private fun ProcessPopupMenu(
MenuItem(
"stop",
stringResource(id = R.string.service_stop),
R.drawable.ic_close_fill
R.drawable.module_profile_ic_close_fill
),
MenuItem(
"addToGlobalVar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,13 @@ static void showLicenseDialog(Activity activity) {
" Copyright (C) 2016 Tim Malseed",
new ApacheSoftwareLicense20()));

notices.addNotice(
new Notice(
"MPAndroidChart",
"https://github.com/PhilJay/MPAndroidChart",
"Copyright 2019 Philipp Jahoda",
new ApacheSoftwareLicense20()));

notices.addNotice(
new Notice(
"easy-rules",
"https://github.com/j-easy/easy-rules",
"Copyright (c) 2019 Mahmoud Ben Hassine ([email protected])",
new MITLicense()));

notices.addNotice(
new Notice(
"Timber",
"https://github.com/JakeWharton/timber",
"Copyright 2013 Jake Wharton",
new ApacheSoftwareLicense20()));

notices.addNotice(
new Notice(
"Xposed",
Expand Down Expand Up @@ -136,13 +122,6 @@ static void showLicenseDialog(Activity activity) {
null,
new MozillaPublicLicense20()));

notices.addNotice(
new Notice(
"android_native_code_view",
"https://github.com/vic797/android_native_code_view",
"Copyright 2017 Victor Campos",
new ApacheSoftwareLicense20()));

notices.addNotice(
new Notice(
"ApkBuilder",
Expand Down Expand Up @@ -185,6 +164,13 @@ static void showLicenseDialog(Activity activity) {
null,
new MITLicense()));

notices.addNotice(
new Notice(
"CodeView",
"https://github.com/AmrDeveloper/CodeView",
"Copyright (c) 2020 - Present Amr Hesham",
new MITLicense()));

new LicensesDialog.Builder(Objects.requireNonNull(activity))
.setNotices(notices)
.setIncludeOwnLicense(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/common_view_margin_default"
android:text="@string/service_stop"
app:icon="@drawable/ic_close_fill" />
app:icon="@drawable/module_profile_ic_close_fill" />
</RelativeLayout>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ object Libs {
const val listenablefutureEmpty =
"com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava"

// https://github.com/AmrDeveloper/CodeView
const val codeView = "io.github.amrdeveloper:codeview:1.3.5"

}

object Rules {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class TypefaceHelper {

private static Typeface sGoogleFont;
private static Typeface sGoogleFontBold;
private static Typeface sJetbrainsMono;
private static Typeface sJetbrainsMonoRegular;
private static Typeface sJetbrainsMonoMedium;

public static Typeface googleSans(Context context) {
synchronized (TypefaceHelper.class) {
Expand All @@ -31,12 +32,21 @@ public static Typeface googleSansBold(Context context) {
}
}

public static Typeface jetbrainsMono(Context context) {
public static Typeface jetbrainsMonoRegular(Context context) {
synchronized (TypefaceHelper.class) {
if (sJetbrainsMono == null) {
sJetbrainsMono = Typeface.createFromAsset(context.getAssets(), "fonts/google/jetbrains/JetBrainsMonoRegular.ttf");
if (sJetbrainsMonoRegular == null) {
sJetbrainsMonoRegular = Typeface.createFromAsset(context.getAssets(), "fonts/google/jetbrains/JetBrainsMonoRegular.ttf");
}
return sJetbrainsMono;
return sJetbrainsMonoRegular;
}
}

public static Typeface jetbrainsMonoMedium(Context context) {
synchronized (TypefaceHelper.class) {
if (sJetbrainsMonoMedium == null) {
sJetbrainsMonoMedium = Typeface.createFromAsset(context.getAssets(), "fonts/google/jetbrains/JetBrainsMonoMedium.ttf");
}
return sJetbrainsMonoMedium;
}
}
}
4 changes: 2 additions & 2 deletions android/modules/module_profile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ dependencies {
releaseImplementation(Libs.Others.chuckerNoop)
debugImplementation(Libs.Others.chucker)

debugImplementation(Libs.Others.codeView)

implementation(project(":modules:module_common"))
implementation(project(":modules:module_compose_common"))
implementation(project(":android_framework:base"))
Expand All @@ -109,6 +111,4 @@ dependencies {
implementation(project(":third_party:recyclerview-fastscroll"))
implementation(project(":third_party:search"))
implementation(project(":third_party:dateformatter"))

implementation(project(":third_party:nativesyntax"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.common.collect.Lists;
import com.vic797.syntaxhighlight.SyntaxListener;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -36,7 +35,7 @@
import util.CollectionUtils;
import util.ObjectsUtils;

public class GlobalVarEditorActivity extends ThemeActivity implements SyntaxListener {
public class GlobalVarEditorActivity extends ThemeActivity {

private static final int REQ_PICK_APPS = 0x100;

Expand Down Expand Up @@ -91,7 +90,7 @@ private void initView() {
checkRuleAndUpdateTips(globalVar.listToJson());
}

binding.editText.addTextChangedListener(new TextWatcherAdapter() {
binding.codeView.addTextChangedListener(new TextWatcherAdapter() {
@Override
public void afterTextChanged(Editable s) {
String current = getCurrentEditingContent();
Expand Down Expand Up @@ -137,11 +136,11 @@ public void afterTextChanged(Editable editable) {
return true;
}
if (item.getItemId() == R.id.action_text_size_inc) {
binding.editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, binding.editText.getTextSize() + 5f);
binding.codeView.setTextSize(TypedValue.COMPLEX_UNIT_PX, binding.codeView.getTextSize() + 5f);
return true;
}
if (item.getItemId() == R.id.action_text_size_dec) {
binding.editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, binding.editText.getTextSize() - 5f);
binding.codeView.setTextSize(TypedValue.COMPLEX_UNIT_PX, binding.codeView.getTextSize() - 5f);
return true;
}
if (R.id.action_delete == item.getItemId()) {
Expand All @@ -156,16 +155,14 @@ public void afterTextChanged(Editable editable) {
binding.setLifecycleOwner(this);
binding.executePendingBindings();

binding.editText.setTypeface(TypefaceHelper.jetbrainsMono(thisActivity()));
binding.lineLayout.setTypeface(TypefaceHelper.jetbrainsMono(thisActivity()));
binding.lineLayout.attachEditText(binding.editText);
binding.codeView.setTypeface(TypefaceHelper.jetbrainsMonoRegular(thisActivity()));

setTitle(globalVar.getName());
}

private String getCurrentEditingContent() {
if (binding.editText.getText() == null) return "";
return binding.editText.getText().toString().trim();
if (binding.codeView.getText() == null) return "";
return binding.codeView.getText().toString().trim();
}

private String getCurrentEditingTitle() {
Expand Down Expand Up @@ -282,24 +279,4 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
binding.setContent(globalVar.listToJson());
}
}

@Override
public void onLineClick(Editable editable, String text, int line) {
// Noop.
}

@Override
public void onHighlightStart(Editable editable) {
// Noop.
}

@Override
public void onHighlightEnd(Editable editable) {
// Noop.
}

@Override
public void onError(Exception e) {
// Noop.
}
}
Loading

0 comments on commit a508f29

Please sign in to comment.