mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
Use google-java-format Gradle plugin
This commit is contained in:
@@ -21,15 +21,12 @@ import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.appcompat.widget.TooltipCompat;
|
||||
import androidx.core.util.Pair;
|
||||
|
||||
import com.itsaky.androidide.app.StudioActivity;
|
||||
import com.itsaky.androidide.databinding.ActivityAboutBinding;
|
||||
import com.itsaky.androidide.databinding.LayoutAboutItemsBinding;
|
||||
import com.itsaky.androidide.models.License;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.itsaky.androidide;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.itsaky.androidide.app.StudioActivity;
|
||||
import com.itsaky.androidide.databinding.ActivityCrashHandlerBinding;
|
||||
import com.itsaky.androidide.fragments.CrashReportFragment;
|
||||
|
||||
@@ -38,7 +38,6 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
@@ -48,7 +47,6 @@ import androidx.transition.Fade;
|
||||
import androidx.transition.Slide;
|
||||
import androidx.transition.TransitionManager;
|
||||
import androidx.transition.TransitionSet;
|
||||
|
||||
import com.blankj.utilcode.util.DeviceUtils;
|
||||
import com.blankj.utilcode.util.ThrowableUtils;
|
||||
import com.itsaky.androidide.adapters.WidgetGroupItemAdapter;
|
||||
@@ -71,14 +69,12 @@ import com.itsaky.inflater.ILayoutInflater;
|
||||
import com.itsaky.inflater.IView;
|
||||
import com.itsaky.inflater.IViewGroup;
|
||||
import com.itsaky.inflater.impl.BaseView;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
public class DesignerActivity extends StudioActivity
|
||||
implements WidgetItemAdapter.OnDragStartListener {
|
||||
|
||||
@@ -17,18 +17,15 @@
|
||||
*/
|
||||
package com.itsaky.androidide;
|
||||
|
||||
import abhishekti7.unicorn.filepicker.UnicornFilePicker;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.transition.TransitionManager;
|
||||
|
||||
import abhishekti7.unicorn.filepicker.UnicornFilePicker;
|
||||
|
||||
import com.blankj.utilcode.util.FileIOUtils;
|
||||
import com.blankj.utilcode.util.SizeUtils;
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
@@ -48,7 +45,6 @@ import com.itsaky.androidide.utils.Environment;
|
||||
import com.itsaky.androidide.utils.FileUtil;
|
||||
import com.itsaky.androidide.utils.InputStreamLineReader;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -35,7 +35,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.activity.result.ActivityResult;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
@@ -51,7 +50,6 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.transition.Slide;
|
||||
import androidx.transition.TransitionManager;
|
||||
|
||||
import com.blankj.utilcode.util.ClipboardUtils;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.blankj.utilcode.util.IntentUtils;
|
||||
@@ -117,9 +115,8 @@ import com.itsaky.lsp.models.InitializeParams;
|
||||
import com.itsaky.lsp.models.Range;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
import com.unnamed.b.atv.model.TreeNode;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import io.github.rosemoe.sora.event.ContentChangeEvent;
|
||||
import io.github.rosemoe.sora.event.Unsubscribe;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -134,11 +131,9 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.github.rosemoe.sora.event.ContentChangeEvent;
|
||||
import io.github.rosemoe.sora.event.Unsubscribe;
|
||||
import me.piruin.quickaction.ActionItem;
|
||||
import me.piruin.quickaction.QuickAction;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
public class EditorActivity extends StudioActivity
|
||||
implements FileTreeFragment.FileActionListener,
|
||||
|
||||
@@ -20,15 +20,12 @@
|
||||
|
||||
package com.itsaky.androidide;
|
||||
|
||||
import abhishekti7.unicorn.filepicker.UnicornFilePicker;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.transition.TransitionManager;
|
||||
|
||||
import abhishekti7.unicorn.filepicker.UnicornFilePicker;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.transition.MaterialContainerTransform;
|
||||
import com.itsaky.androidide.app.StudioActivity;
|
||||
@@ -48,7 +45,6 @@ import com.itsaky.androidide.utils.DialogUtils;
|
||||
import com.itsaky.androidide.utils.ProjectFinder;
|
||||
import com.itsaky.androidide.utils.TransformUtils;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -22,9 +22,7 @@ package com.itsaky.androidide;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.itsaky.androidide.app.StudioActivity;
|
||||
import com.itsaky.androidide.databinding.ActivityPreferencesBinding;
|
||||
import com.itsaky.androidide.fragments.preferences.IDEPreferences;
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.itsaky.androidide.app.StudioActivity;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
|
||||
@@ -29,9 +29,7 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ClipboardUtils;
|
||||
import com.blankj.utilcode.util.KeyboardUtils;
|
||||
import com.blankj.utilcode.util.SizeUtils;
|
||||
@@ -56,12 +54,10 @@ import com.itsaky.terminal.TerminalSessionClient;
|
||||
import com.itsaky.terminal.TextStyle;
|
||||
import com.itsaky.terminal.view.TerminalView;
|
||||
import com.itsaky.terminal.view.TerminalViewClient;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Map;
|
||||
import org.json.JSONException;
|
||||
|
||||
public class TerminalActivity extends StudioActivity {
|
||||
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
package com.itsaky.androidide.adapters;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.attrinfo.models.Attr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -25,9 +25,7 @@ import android.widget.BaseAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -39,89 +37,89 @@ import java.util.Objects;
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public class AttrValueCompletionAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
|
||||
private final List<String> items;
|
||||
private final List<String> filtered;
|
||||
private final Context context;
|
||||
private final Filter mFilter =
|
||||
new Filter () {
|
||||
new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering (CharSequence constraint) {
|
||||
final var result = new FilterResults ();
|
||||
if (TextUtils.isEmpty (constraint)) {
|
||||
final var list = new ArrayList<> (items);
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
final var result = new FilterResults();
|
||||
if (TextUtils.isEmpty(constraint)) {
|
||||
final var list = new ArrayList<>(items);
|
||||
result.values = list;
|
||||
result.count = list.size ();
|
||||
result.count = list.size();
|
||||
return result;
|
||||
}
|
||||
|
||||
final var match = constraint.toString ().trim ().toLowerCase (Locale.ROOT);
|
||||
final var list = new ArrayList<String> ();
|
||||
|
||||
final var match = constraint.toString().trim().toLowerCase(Locale.ROOT);
|
||||
final var list = new ArrayList<String>();
|
||||
for (String item : items) {
|
||||
if (item.contains (match)) {
|
||||
list.add (item);
|
||||
if (item.contains(match)) {
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
result.values = list;
|
||||
result.count = list.size ();
|
||||
result.count = list.size();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void publishResults (
|
||||
protected void publishResults(
|
||||
CharSequence constraint, @NonNull FilterResults results) {
|
||||
//noinspection unchecked
|
||||
List<String> items = (List<String>) results.values;
|
||||
Objects.requireNonNull (items);
|
||||
|
||||
filtered.clear ();
|
||||
filtered.addAll (items);
|
||||
|
||||
if (items.isEmpty ()) {
|
||||
notifyDataSetInvalidated ();
|
||||
Objects.requireNonNull(items);
|
||||
|
||||
filtered.clear();
|
||||
filtered.addAll(items);
|
||||
|
||||
if (items.isEmpty()) {
|
||||
notifyDataSetInvalidated();
|
||||
} else {
|
||||
notifyDataSetChanged ();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public AttrValueCompletionAdapter (Context context, List<String> items) {
|
||||
|
||||
public AttrValueCompletionAdapter(Context context, List<String> items) {
|
||||
this.context = context;
|
||||
this.items = items;
|
||||
this.filtered = new ArrayList<> (items);
|
||||
this.filtered = new ArrayList<>(items);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount () {
|
||||
return this.filtered.size ();
|
||||
public int getCount() {
|
||||
return this.filtered.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getItem (int position) {
|
||||
return filtered.get (position);
|
||||
public Object getItem(int position) {
|
||||
return filtered.get(position);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getItemId (int position) {
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView (int position, View convertView, ViewGroup parent) {
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView =
|
||||
((LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE))
|
||||
.inflate (android.R.layout.simple_list_item_1, parent, false);
|
||||
((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
|
||||
.inflate(android.R.layout.simple_list_item_1, parent, false);
|
||||
}
|
||||
|
||||
((TextView) convertView).setText (getItem (position).toString ());
|
||||
|
||||
|
||||
((TextView) convertView).setText(getItem(position).toString());
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Filter getFilter () {
|
||||
public Filter getFilter() {
|
||||
return mFilter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,17 +17,14 @@
|
||||
package com.itsaky.androidide.adapters;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import com.itsaky.androidide.fragments.attr.BaseValueEditorFragment;
|
||||
import com.itsaky.androidide.models.XMLAttribute;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -25,9 +25,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
@@ -45,196 +43,196 @@ import com.itsaky.apiinfo.models.Info;
|
||||
import com.itsaky.apiinfo.models.MethodInfo;
|
||||
import com.itsaky.lsp.models.CompletionItem;
|
||||
import com.itsaky.lsp.models.CompletionItemKind;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.github.rosemoe.sora.widget.component.EditorAutoCompletion;
|
||||
import io.github.rosemoe.sora.widget.component.EditorCompletionAdapter;
|
||||
import java.util.List;
|
||||
|
||||
public class CompletionListAdapter extends EditorCompletionAdapter {
|
||||
|
||||
private static final Logger LOG = Logger.instance ("CompletionListAdapter");
|
||||
|
||||
|
||||
private static final Logger LOG = Logger.instance("CompletionListAdapter");
|
||||
|
||||
@Override
|
||||
public void attachValues (EditorAutoCompletion window, List<io.github.rosemoe.sora.lang.completion.CompletionItem> items) {
|
||||
super.attachValues (window, items);
|
||||
public void attachValues(
|
||||
EditorAutoCompletion window,
|
||||
List<io.github.rosemoe.sora.lang.completion.CompletionItem> items) {
|
||||
super.attachValues(window, items);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemHeight () {
|
||||
public int getItemHeight() {
|
||||
return (int)
|
||||
TypedValue.applyDimension (
|
||||
TypedValue.COMPLEX_UNIT_DIP, 40, Resources.getSystem ().getDisplayMetrics ());
|
||||
TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP, 40, Resources.getSystem().getDisplayMetrics());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected View getView (
|
||||
protected View getView(
|
||||
int position, View convertView, ViewGroup parent, boolean isCurrentCursorPosition) {
|
||||
final LayoutCompletionItemBinding binding =
|
||||
LayoutCompletionItemBinding.inflate (
|
||||
LayoutInflater.from (getContext ()), parent, false);
|
||||
|
||||
var item = (CompletionItem) getItem (position);
|
||||
String label = item.getLabel (), desc = item.getDetail (), type = item.getKind ().toString ();
|
||||
String header = type.length () <= 0 ? "O" : String.valueOf (type.charAt (0));
|
||||
|
||||
binding.completionIconText.setText (header);
|
||||
binding.completionLabel.setText (label);
|
||||
binding.completionType.setText (type);
|
||||
binding.completionDetail.setText (desc);
|
||||
binding.completionIconText.setTypeface (TypefaceUtils.jetbrainsMono (), Typeface.BOLD);
|
||||
if (desc.isEmpty ()) {
|
||||
binding.completionDetail.setVisibility (View.GONE);
|
||||
LayoutCompletionItemBinding.inflate(
|
||||
LayoutInflater.from(getContext()), parent, false);
|
||||
|
||||
var item = (CompletionItem) getItem(position);
|
||||
String label = item.getLabel(), desc = item.getDetail(), type = item.getKind().toString();
|
||||
String header = type.length() <= 0 ? "O" : String.valueOf(type.charAt(0));
|
||||
|
||||
binding.completionIconText.setText(header);
|
||||
binding.completionLabel.setText(label);
|
||||
binding.completionType.setText(type);
|
||||
binding.completionDetail.setText(desc);
|
||||
binding.completionIconText.setTypeface(TypefaceUtils.jetbrainsMono(), Typeface.BOLD);
|
||||
if (desc.isEmpty()) {
|
||||
binding.completionDetail.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
if (isCurrentCursorPosition) {
|
||||
binding.getRoot ()
|
||||
.setBackgroundColor (
|
||||
ContextCompat.getColor (
|
||||
getContext (), R.color.completionList_backgroundSelected));
|
||||
binding.getRoot()
|
||||
.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
getContext(), R.color.completionList_backgroundSelected));
|
||||
} else {
|
||||
binding.getRoot ()
|
||||
.setBackgroundColor (
|
||||
ContextCompat.getColor (
|
||||
getContext (), R.color.completionList_background));
|
||||
binding.getRoot()
|
||||
.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
getContext(), R.color.completionList_background));
|
||||
}
|
||||
|
||||
binding.completionApiInfo.setVisibility (View.GONE);
|
||||
|
||||
showApiInfoIfNeeded (item, binding.completionApiInfo);
|
||||
|
||||
return binding.getRoot ();
|
||||
|
||||
binding.completionApiInfo.setVisibility(View.GONE);
|
||||
|
||||
showApiInfoIfNeeded(item, binding.completionApiInfo);
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void showApiInfoIfNeeded (final CompletionItem item, final TextView completionApiInfo) {
|
||||
|
||||
new Thread (
|
||||
() -> {
|
||||
final ApiInfo apiInfo = StudioApp.getInstance ().apiInfo ();
|
||||
boolean hasRead = apiInfo != null && apiInfo.hasRead ();
|
||||
boolean isValid = isValidForApiVersion (item);
|
||||
|
||||
if (hasRead && isValid) {
|
||||
|
||||
JsonElement element = new Gson ().toJsonTree (item.getData ());
|
||||
if (element == null || !element.isJsonObject ()) {
|
||||
return;
|
||||
}
|
||||
JsonObject data = element.getAsJsonObject ();
|
||||
if (!data.has ("className")) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String className = data.get ("className").getAsString ();
|
||||
CompletionItemKind kind = item.getKind ();
|
||||
|
||||
ClassInfo clazz = apiInfo.getClassByName (className);
|
||||
if (clazz == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Info info = clazz;
|
||||
|
||||
// If this Info is not a class info, find the right member
|
||||
if (kind == CompletionItemKind.METHOD
|
||||
&& data.has ("erasedParameterTypes")
|
||||
&& data.has ("memberName")) {
|
||||
JsonElement erasedParameterTypesElement =
|
||||
data.get ("erasedParameterTypes");
|
||||
if (erasedParameterTypesElement.isJsonArray ()) {
|
||||
String simpleName = data.get ("memberName").getAsString ();
|
||||
JsonArray erasedParameterTypes =
|
||||
erasedParameterTypesElement.getAsJsonArray ();
|
||||
String[] paramTypes =
|
||||
new String[erasedParameterTypes.size ()];
|
||||
for (int i = 0; i < erasedParameterTypes.size (); i++) {
|
||||
paramTypes[i] =
|
||||
erasedParameterTypes.get (i).getAsString ();
|
||||
|
||||
private void showApiInfoIfNeeded(final CompletionItem item, final TextView completionApiInfo) {
|
||||
|
||||
new Thread(
|
||||
() -> {
|
||||
final ApiInfo apiInfo = StudioApp.getInstance().apiInfo();
|
||||
boolean hasRead = apiInfo != null && apiInfo.hasRead();
|
||||
boolean isValid = isValidForApiVersion(item);
|
||||
|
||||
if (hasRead && isValid) {
|
||||
|
||||
JsonElement element = new Gson().toJsonTree(item.getData());
|
||||
if (element == null || !element.isJsonObject()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MethodInfo method = clazz.getMethod (simpleName, paramTypes);
|
||||
|
||||
if (method != null) {
|
||||
info = method;
|
||||
JsonObject data = element.getAsJsonObject();
|
||||
if (!data.has("className")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (kind == CompletionItemKind.FIELD
|
||||
&& data.has ("memberName")) {
|
||||
String simpleName = data.get ("memberName").getAsString ();
|
||||
FieldInfo field = clazz.getFieldByName (simpleName);
|
||||
|
||||
if (field != null) {
|
||||
info = field;
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder infoBuilder = new StringBuilder ();
|
||||
if (info.since > 1) {
|
||||
infoBuilder.append (
|
||||
completionApiInfo
|
||||
.getContext ()
|
||||
.getString (
|
||||
R.string.msg_api_info_since,
|
||||
info.since));
|
||||
infoBuilder.append ("\n");
|
||||
}
|
||||
|
||||
if (info.removed > 0) {
|
||||
infoBuilder.append (
|
||||
completionApiInfo
|
||||
.getContext ()
|
||||
.getString (
|
||||
R.string.msg_api_info_removed,
|
||||
info.removed));
|
||||
infoBuilder.append ("\n");
|
||||
}
|
||||
|
||||
if (info.deprecated > 0) {
|
||||
infoBuilder.append (
|
||||
completionApiInfo
|
||||
.getContext ()
|
||||
.getString (
|
||||
R.string.msg_api_info_deprecated,
|
||||
info.deprecated));
|
||||
infoBuilder.append ("\n");
|
||||
}
|
||||
|
||||
ThreadUtils.runOnUiThread (
|
||||
() -> {
|
||||
if (infoBuilder.toString ().trim ().length () > 0) {
|
||||
completionApiInfo.setText (
|
||||
infoBuilder.toString ().trim ());
|
||||
completionApiInfo.setVisibility (View.VISIBLE);
|
||||
} else {
|
||||
completionApiInfo.setVisibility (View.GONE);
|
||||
|
||||
final String className = data.get("className").getAsString();
|
||||
CompletionItemKind kind = item.getKind();
|
||||
|
||||
ClassInfo clazz = apiInfo.getClassByName(className);
|
||||
if (clazz == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Info info = clazz;
|
||||
|
||||
// If this Info is not a class info, find the right member
|
||||
if (kind == CompletionItemKind.METHOD
|
||||
&& data.has("erasedParameterTypes")
|
||||
&& data.has("memberName")) {
|
||||
JsonElement erasedParameterTypesElement =
|
||||
data.get("erasedParameterTypes");
|
||||
if (erasedParameterTypesElement.isJsonArray()) {
|
||||
String simpleName = data.get("memberName").getAsString();
|
||||
JsonArray erasedParameterTypes =
|
||||
erasedParameterTypesElement.getAsJsonArray();
|
||||
String[] paramTypes =
|
||||
new String[erasedParameterTypes.size()];
|
||||
for (int i = 0; i < erasedParameterTypes.size(); i++) {
|
||||
paramTypes[i] =
|
||||
erasedParameterTypes.get(i).getAsString();
|
||||
}
|
||||
|
||||
MethodInfo method = clazz.getMethod(simpleName, paramTypes);
|
||||
|
||||
if (method != null) {
|
||||
info = method;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.start ();
|
||||
} else if (kind == CompletionItemKind.FIELD
|
||||
&& data.has("memberName")) {
|
||||
String simpleName = data.get("memberName").getAsString();
|
||||
FieldInfo field = clazz.getFieldByName(simpleName);
|
||||
|
||||
if (field != null) {
|
||||
info = field;
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder infoBuilder = new StringBuilder();
|
||||
if (info.since > 1) {
|
||||
infoBuilder.append(
|
||||
completionApiInfo
|
||||
.getContext()
|
||||
.getString(
|
||||
R.string.msg_api_info_since,
|
||||
info.since));
|
||||
infoBuilder.append("\n");
|
||||
}
|
||||
|
||||
if (info.removed > 0) {
|
||||
infoBuilder.append(
|
||||
completionApiInfo
|
||||
.getContext()
|
||||
.getString(
|
||||
R.string.msg_api_info_removed,
|
||||
info.removed));
|
||||
infoBuilder.append("\n");
|
||||
}
|
||||
|
||||
if (info.deprecated > 0) {
|
||||
infoBuilder.append(
|
||||
completionApiInfo
|
||||
.getContext()
|
||||
.getString(
|
||||
R.string.msg_api_info_deprecated,
|
||||
info.deprecated));
|
||||
infoBuilder.append("\n");
|
||||
}
|
||||
|
||||
ThreadUtils.runOnUiThread(
|
||||
() -> {
|
||||
if (infoBuilder.toString().trim().length() > 0) {
|
||||
completionApiInfo.setText(
|
||||
infoBuilder.toString().trim());
|
||||
completionApiInfo.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
completionApiInfo.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.start();
|
||||
}
|
||||
|
||||
private boolean isValidForApiVersion (CompletionItem item) {
|
||||
|
||||
private boolean isValidForApiVersion(CompletionItem item) {
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
final CompletionItemKind type = item.getKind ();
|
||||
final var data = item.getData ();
|
||||
final CompletionItemKind type = item.getKind();
|
||||
final var data = item.getData();
|
||||
if (
|
||||
|
||||
// These represent a class type
|
||||
(type == CompletionItemKind.CLASS
|
||||
|
||||
// These represent a class type
|
||||
(type == CompletionItemKind.CLASS
|
||||
|| type == CompletionItemKind.INTERFACE
|
||||
|| type == CompletionItemKind.ENUM
|
||||
|
||||
|
||||
// These represent a method type
|
||||
|| type == CompletionItemKind.METHOD
|
||||
|| type == CompletionItemKind.CONSTRUCTOR
|
||||
|
||||
|
||||
// A field type
|
||||
|| type == CompletionItemKind.FIELD)
|
||||
&& data != null) {
|
||||
return !TextUtils.isEmpty (data.getClassName ());
|
||||
&& data != null) {
|
||||
return !TextUtils.isEmpty(data.getClassName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,17 +20,14 @@ package com.itsaky.androidide.adapters;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.databinding.LayoutDiagnosticItemBinding;
|
||||
import com.itsaky.androidide.interfaces.DiagnosticClickListener;
|
||||
import com.itsaky.lsp.models.DiagnosticItem;
|
||||
import com.itsaky.lsp.models.DiagnosticSeverity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -23,16 +23,13 @@ package com.itsaky.androidide.adapters;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.databinding.LayoutDiagnosticGroupBinding;
|
||||
import com.itsaky.androidide.interfaces.DiagnosticClickListener;
|
||||
import com.itsaky.androidide.models.DiagnosticGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiagnosticsAdapter extends RecyclerView.Adapter<DiagnosticsAdapter.VH> {
|
||||
|
||||
@@ -22,14 +22,12 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.fragments.DiagnosticsListFragment;
|
||||
import com.itsaky.androidide.fragments.IDELogFragment;
|
||||
import com.itsaky.androidide.fragments.LogViewFragment;
|
||||
import com.itsaky.androidide.fragments.SearchResultFragment;
|
||||
import com.itsaky.androidide.fragments.SimpleOutputFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -20,10 +20,8 @@ package com.itsaky.androidide.adapters;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.databinding.LayoutSimpleIconTextBinding;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,12 +22,9 @@ package com.itsaky.androidide.adapters;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.databinding.LayoutOptionssheetItemBinding;
|
||||
import com.itsaky.androidide.models.SheetOption;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OptionsSheetAdapter extends RecyclerView.Adapter<OptionsSheetAdapter.VH> {
|
||||
|
||||
@@ -24,11 +24,9 @@ import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.transition.ChangeBounds;
|
||||
import androidx.transition.TransitionManager;
|
||||
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.itsaky.androidide.R;
|
||||
@@ -37,7 +35,6 @@ import com.itsaky.androidide.databinding.LayoutProjectsItemBinding;
|
||||
import com.itsaky.androidide.project.AndroidProject;
|
||||
import com.itsaky.androidide.tasks.TaskExecutor;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -24,17 +24,14 @@ import android.graphics.PorterDuff;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.itsaky.androidide.databinding.LayoutSearchResultGroupBinding;
|
||||
import com.itsaky.androidide.databinding.LayoutSearchResultItemBinding;
|
||||
import com.itsaky.androidide.models.SearchResult;
|
||||
import com.itsaky.androidide.syntax.highlighters.JavaHighlighter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
package com.itsaky.androidide.adapters;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.models.IconTextListItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,14 +20,11 @@ package com.itsaky.androidide.adapters;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.databinding.LayoutSymbolItemBinding;
|
||||
import com.itsaky.androidide.views.SymbolInputView.Symbol;
|
||||
import com.itsaky.androidide.views.editor.IDEEditor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -20,15 +20,12 @@ package com.itsaky.androidide.adapters;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.databinding.LayoutTextActionItemBinding;
|
||||
import com.itsaky.androidide.managers.PreferenceManager;
|
||||
import com.itsaky.androidide.views.editor.IDEEditor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
package com.itsaky.androidide.adapters;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.models.IconTextListItem;
|
||||
import com.itsaky.androidide.models.UIWidgetGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WidgetGroupItemAdapter extends SimpleIconTextAdapter
|
||||
|
||||
@@ -19,15 +19,12 @@ package com.itsaky.androidide.adapters;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.DesignerActivity;
|
||||
import com.itsaky.androidide.models.IconTextListItem;
|
||||
import com.itsaky.androidide.models.UIWidget;
|
||||
import com.itsaky.androidide.ui.WidgetDragData;
|
||||
import com.itsaky.androidide.ui.WidgetDragShadowBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WidgetItemAdapter extends SimpleIconTextAdapter
|
||||
|
||||
@@ -24,15 +24,12 @@ import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.databinding.LayoutAttrEditorSheetItemBinding;
|
||||
import com.itsaky.androidide.models.XMLAttribute;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class XMLAttributeListAdapter extends RecyclerView.Adapter<XMLAttributeListAdapter.VH> {
|
||||
|
||||
@@ -26,15 +26,12 @@ import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.app.StudioActivity;
|
||||
import com.itsaky.androidide.databinding.LayoutFiletreeItemBinding;
|
||||
import com.itsaky.androidide.utils.Environment;
|
||||
import com.unnamed.b.atv.model.TreeNode;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileTreeViewHolder extends TreeNode.BaseNodeViewHolder<File> {
|
||||
|
||||
@@ -22,14 +22,12 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.AttrRes;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
package com.itsaky.androidide.app;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ThrowableUtils;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import com.itsaky.androidide.CrashHandlerActivity;
|
||||
@@ -38,7 +36,6 @@ import com.itsaky.lsp.java.JavaLanguageServer;
|
||||
import com.itsaky.lsp.xml.XMLLanguageServer;
|
||||
import com.itsaky.sdk.SDKInfo;
|
||||
import com.itsaky.widgets.WidgetInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
package com.itsaky.androidide.fragments;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.itsaky.androidide.app.StudioActivity;
|
||||
|
||||
public class BaseFragment extends Fragment {
|
||||
|
||||
@@ -27,11 +27,9 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.blankj.utilcode.util.ClipboardUtils;
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.app.BaseApplication;
|
||||
|
||||
@@ -22,16 +22,13 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.adapters.DiagnosticsAdapter;
|
||||
import com.itsaky.androidide.views.EmptyView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DiagnosticsListFragment extends Fragment {
|
||||
|
||||
@@ -27,11 +27,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.transition.ChangeBounds;
|
||||
import androidx.transition.TransitionManager;
|
||||
|
||||
import com.blankj.utilcode.util.FileIOUtils;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.blankj.utilcode.util.IntentUtils;
|
||||
@@ -48,7 +46,6 @@ import com.itsaky.androidide.views.editor.CodeEditorView;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
import com.unnamed.b.atv.model.TreeNode;
|
||||
import com.unnamed.b.atv.view.AndroidTreeView;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -220,8 +217,8 @@ public class FileTreeFragment extends BottomSheetDialogFragment
|
||||
FileIOUtils.writeFileFromString(
|
||||
gradleProps,
|
||||
"# Specify global Gradle properties in this file\n"
|
||||
+ "# These properties will be applicable for every project you build"
|
||||
+ " with Gradle.");
|
||||
+ "# These properties will be applicable for every project you build"
|
||||
+ " with Gradle.");
|
||||
}
|
||||
TreeNode home = new TreeNode(gradleHome);
|
||||
home.setViewHolder(new FileTreeViewHolder(getContext()));
|
||||
|
||||
@@ -19,16 +19,12 @@ package com.itsaky.androidide.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.itsaky.androidide.language.logs.LogLanguageImpl;
|
||||
import com.itsaky.androidide.models.LogLine;
|
||||
|
||||
import io.github.rosemoe.sora.lang.Language;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -21,16 +21,13 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.itsaky.androidide.databinding.FragmentNonEditableEditorBinding;
|
||||
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE;
|
||||
import com.itsaky.androidide.utils.TypefaceUtils;
|
||||
import com.itsaky.androidide.views.editor.IDEEditor;
|
||||
|
||||
import io.github.rosemoe.sora.lang.EmptyLanguage;
|
||||
|
||||
public abstract class NonEditableEditorFragment extends Fragment {
|
||||
|
||||
@@ -26,10 +26,8 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.EditorActivity;
|
||||
import com.itsaky.androidide.adapters.ProjectsListAdapter;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
@@ -37,7 +35,6 @@ import com.itsaky.androidide.databinding.LayoutProjectsBinding;
|
||||
import com.itsaky.androidide.project.AndroidProject;
|
||||
import com.itsaky.androidide.tasks.TaskExecutor;
|
||||
import com.itsaky.androidide.utils.ProjectFinder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,13 +22,11 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.adapters.SearchListAdapter;
|
||||
import com.itsaky.androidide.views.EmptyView;
|
||||
|
||||
|
||||
@@ -19,12 +19,9 @@ package com.itsaky.androidide.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
+42
-45
@@ -21,15 +21,12 @@ import static com.itsaky.androidide.utils.Logger.instance;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
||||
import com.itsaky.androidide.adapters.AttrValueCompletionAdapter;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.androidide.utils.TextWatcherAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -39,68 +36,68 @@ import java.util.concurrent.CompletableFuture;
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public abstract class AbstractReferenceEditor extends BaseValueEditorFragment {
|
||||
|
||||
private static final Logger LOG = instance ("ReferenceEditor");
|
||||
|
||||
private static final Logger LOG = instance("ReferenceEditor");
|
||||
public TextWatcherAdapter resInputWatcher;
|
||||
|
||||
|
||||
@Override
|
||||
protected void notifyValueChanged (@NonNull String newValue) {
|
||||
protected void notifyValueChanged(@NonNull String newValue) {
|
||||
try {
|
||||
super.notifyValueChanged (newValue);
|
||||
super.notifyValueChanged(newValue);
|
||||
} catch (Throwable e) {
|
||||
LOG.error ("Unable to update resource value to '" + newValue + "'", e);
|
||||
LOG.error("Unable to update resource value to '" + newValue + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setupReferenceInput (MaterialAutoCompleteTextView referenceInput) {
|
||||
Objects.requireNonNull (referenceInput);
|
||||
|
||||
referenceInput.setText (attribute.getValue ());
|
||||
|
||||
|
||||
protected void setupReferenceInput(MaterialAutoCompleteTextView referenceInput) {
|
||||
Objects.requireNonNull(referenceInput);
|
||||
|
||||
referenceInput.setText(attribute.getValue());
|
||||
|
||||
if (resInputWatcher != null) {
|
||||
referenceInput.removeTextChangedListener (resInputWatcher);
|
||||
referenceInput.removeTextChangedListener(resInputWatcher);
|
||||
}
|
||||
|
||||
|
||||
resInputWatcher =
|
||||
new TextWatcherAdapter () {
|
||||
new TextWatcherAdapter() {
|
||||
@Override
|
||||
public void afterTextChanged (@NonNull Editable s) {
|
||||
final var text = s.toString ().trim ();
|
||||
if (TextUtils.isEmpty (text)) {
|
||||
public void afterTextChanged(@NonNull Editable s) {
|
||||
final var text = s.toString().trim();
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
return;
|
||||
}
|
||||
|
||||
notifyValueChanged (text);
|
||||
|
||||
notifyValueChanged(text);
|
||||
}
|
||||
};
|
||||
|
||||
referenceInput.addTextChangedListener (resInputWatcher);
|
||||
|
||||
CompletableFuture.supplyAsync (this::computeReferenceItems)
|
||||
.whenComplete (
|
||||
(list, error) -> handleAutoCompleteResult (list, error, referenceInput));
|
||||
|
||||
referenceInput.addTextChangedListener(resInputWatcher);
|
||||
|
||||
CompletableFuture.supplyAsync(this::computeReferenceItems)
|
||||
.whenComplete(
|
||||
(list, error) -> handleAutoCompleteResult(list, error, referenceInput));
|
||||
}
|
||||
|
||||
protected void handleAutoCompleteResult (
|
||||
|
||||
protected void handleAutoCompleteResult(
|
||||
List<String> list, Throwable error, AutoCompleteTextView referenceInput) {
|
||||
if (list == null || list.isEmpty ()) {
|
||||
LOG.error ("No completion items found");
|
||||
LOG.error ("Error was:", error);
|
||||
if (list == null || list.isEmpty()) {
|
||||
LOG.error("No completion items found");
|
||||
LOG.error("Error was:", error);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG.debug ("Found", list.size (), "resource items for completion");
|
||||
|
||||
ThreadUtils.runOnUiThread (
|
||||
|
||||
LOG.debug("Found", list.size(), "resource items for completion");
|
||||
|
||||
ThreadUtils.runOnUiThread(
|
||||
() -> {
|
||||
final var adapter = new AttrValueCompletionAdapter (requireContext (), list);
|
||||
referenceInput.setThreshold (1);
|
||||
referenceInput.setAdapter (adapter);
|
||||
adapter.notifyDataSetChanged ();
|
||||
final var adapter = new AttrValueCompletionAdapter(requireContext(), list);
|
||||
referenceInput.setThreshold(1);
|
||||
referenceInput.setAdapter(adapter);
|
||||
adapter.notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
protected List<String> computeReferenceItems () {
|
||||
return new ArrayList<> ();
|
||||
|
||||
protected List<String> computeReferenceItems() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,8 @@ package com.itsaky.androidide.fragments.attr;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.itsaky.androidide.models.XMLAttribute;
|
||||
import com.itsaky.inflater.IAttribute;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,15 +22,12 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RadioButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
||||
import com.itsaky.androidide.databinding.LayoutBooleanAttrEditorBinding;
|
||||
import com.itsaky.inflater.values.FrameworkValues;
|
||||
import com.itsaky.inflater.values.ValuesTableFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -39,57 +36,57 @@ import java.util.stream.Collectors;
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public class BooleanEditor extends AbstractReferenceEditor {
|
||||
|
||||
|
||||
private LayoutBooleanAttrEditorBinding binding;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView (
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
this.binding = LayoutBooleanAttrEditorBinding.inflate (inflater, container, false);
|
||||
return this.binding.getRoot ();
|
||||
this.binding = LayoutBooleanAttrEditorBinding.inflate(inflater, container, false);
|
||||
return this.binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated (@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated (view, savedInstanceState);
|
||||
|
||||
this.binding.choiceGroup.setOnCheckedChangeListener (
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
this.binding.choiceGroup.setOnCheckedChangeListener(
|
||||
(group, checkedId) -> {
|
||||
final var checked = (RadioButton) group.findViewById (checkedId);
|
||||
notifyValueChanged (checked.getText ().toString ().trim ());
|
||||
final var checked = (RadioButton) group.findViewById(checkedId);
|
||||
notifyValueChanged(checked.getText().toString().trim());
|
||||
});
|
||||
|
||||
switch (attribute.getValue ()) {
|
||||
|
||||
switch (attribute.getValue()) {
|
||||
case "true":
|
||||
this.binding.boolTrue.setChecked (true);
|
||||
this.binding.boolTrue.setChecked(true);
|
||||
break;
|
||||
case "false":
|
||||
this.binding.boolFalse.setChecked (true);
|
||||
this.binding.boolFalse.setChecked(true);
|
||||
}
|
||||
|
||||
setupReferenceInput (
|
||||
(MaterialAutoCompleteTextView) this.binding.booleanResInput.getEditText ());
|
||||
|
||||
setupReferenceInput(
|
||||
(MaterialAutoCompleteTextView) this.binding.booleanResInput.getEditText());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<String> computeReferenceItems () {
|
||||
final var list = new ArrayList<String> ();
|
||||
final var tables = ValuesTableFactory.getAllTables ();
|
||||
for (var entry : tables.entrySet ()) {
|
||||
final var dimens = entry.getValue ().getTable ("bool");
|
||||
protected List<String> computeReferenceItems() {
|
||||
final var list = new ArrayList<String>();
|
||||
final var tables = ValuesTableFactory.getAllTables();
|
||||
for (var entry : tables.entrySet()) {
|
||||
final var dimens = entry.getValue().getTable("bool");
|
||||
if (dimens != null) {
|
||||
list.addAll (
|
||||
dimens.keySet ().stream ().map ("@bool/"::concat).collect (Collectors.toSet ()));
|
||||
list.addAll(
|
||||
dimens.keySet().stream().map("@bool/"::concat).collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
|
||||
list.addAll (
|
||||
FrameworkValues.listBools ().stream ()
|
||||
.map ("@android:bool/"::concat)
|
||||
.collect (Collectors.toList ()));
|
||||
|
||||
list.addAll(
|
||||
FrameworkValues.listBools().stream()
|
||||
.map("@android:bool/"::concat)
|
||||
.collect(Collectors.toList()));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,8 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.colorpicker.ColorPickerView;
|
||||
@@ -34,7 +32,6 @@ import com.itsaky.androidide.databinding.LayoutColorAttrEditorBinding;
|
||||
import com.itsaky.androidide.utils.DialogUtils;
|
||||
import com.itsaky.inflater.values.FrameworkValues;
|
||||
import com.itsaky.inflater.values.ValuesTableFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -43,77 +40,82 @@ import java.util.stream.Collectors;
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public class ColorEditor extends AbstractReferenceEditor {
|
||||
|
||||
|
||||
private LayoutColorAttrEditorBinding binding;
|
||||
private Dialog colorPickerDialog;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView (@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
this.binding = LayoutColorAttrEditorBinding.inflate (inflater, container, false);
|
||||
return this.binding.getRoot ();
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
this.binding = LayoutColorAttrEditorBinding.inflate(inflater, container, false);
|
||||
return this.binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated (@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated (view, savedInstanceState);
|
||||
|
||||
this.binding.pickColor.setOnClickListener (v -> getColorPickerDialog ().show ());
|
||||
setupReferenceInput ((MaterialAutoCompleteTextView) this.binding.colorResInput.getEditText ());
|
||||
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
this.binding.pickColor.setOnClickListener(v -> getColorPickerDialog().show());
|
||||
setupReferenceInput(
|
||||
(MaterialAutoCompleteTextView) this.binding.colorResInput.getEditText());
|
||||
|
||||
try {
|
||||
final var col = Color.parseColor (attribute.getValue ());
|
||||
this.binding.colorPreview.setCardBackgroundColor (col);
|
||||
final var col = Color.parseColor(attribute.getValue());
|
||||
this.binding.colorPreview.setCardBackgroundColor(col);
|
||||
} catch (Throwable th) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<String> computeReferenceItems () {
|
||||
final var list = new ArrayList<String> ();
|
||||
final var tables = ValuesTableFactory.getAllTables ();
|
||||
for (var entry : tables.entrySet ()) {
|
||||
final var dimens = entry.getValue ().getTable ("color");
|
||||
protected List<String> computeReferenceItems() {
|
||||
final var list = new ArrayList<String>();
|
||||
final var tables = ValuesTableFactory.getAllTables();
|
||||
for (var entry : tables.entrySet()) {
|
||||
final var dimens = entry.getValue().getTable("color");
|
||||
if (dimens != null) {
|
||||
list.addAll (
|
||||
dimens.keySet ().stream ()
|
||||
.map ("@color/"::concat)
|
||||
.collect (Collectors.toSet ()));
|
||||
list.addAll(
|
||||
dimens.keySet().stream()
|
||||
.map("@color/"::concat)
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
|
||||
list.addAll (
|
||||
FrameworkValues.listColors ().stream ()
|
||||
.map ("@android:color/"::concat)
|
||||
.collect (Collectors.toList ()));
|
||||
|
||||
final var resTable = StudioApp.getInstance ().getResourceTable ();
|
||||
list.addAll (resTable.listResourceNames ("color"));
|
||||
|
||||
|
||||
list.addAll(
|
||||
FrameworkValues.listColors().stream()
|
||||
.map("@android:color/"::concat)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
final var resTable = StudioApp.getInstance().getResourceTable();
|
||||
list.addAll(resTable.listResourceNames("color"));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private Dialog getColorPickerDialog () {
|
||||
|
||||
|
||||
private Dialog getColorPickerDialog() {
|
||||
|
||||
if (colorPickerDialog == null) {
|
||||
final var builder = DialogUtils.newMaterialDialogBuilder (requireContext ());
|
||||
ColorPickerView colorPickerView = new ColorPickerView (requireContext ());
|
||||
|
||||
builder.setView (colorPickerView);
|
||||
|
||||
colorPickerView.setOnPickListener ((color, hexCode) -> {
|
||||
if (colorPickerDialog != null) {
|
||||
colorPickerDialog.dismiss ();
|
||||
}
|
||||
|
||||
this.binding.colorPreview.setCardBackgroundColor (color);
|
||||
notifyValueChanged (hexCode);
|
||||
});
|
||||
|
||||
colorPickerDialog = builder.create ();
|
||||
final var builder = DialogUtils.newMaterialDialogBuilder(requireContext());
|
||||
ColorPickerView colorPickerView = new ColorPickerView(requireContext());
|
||||
|
||||
builder.setView(colorPickerView);
|
||||
|
||||
colorPickerView.setOnPickListener(
|
||||
(color, hexCode) -> {
|
||||
if (colorPickerDialog != null) {
|
||||
colorPickerDialog.dismiss();
|
||||
}
|
||||
|
||||
this.binding.colorPreview.setCardBackgroundColor(color);
|
||||
notifyValueChanged(hexCode);
|
||||
});
|
||||
|
||||
colorPickerDialog = builder.create();
|
||||
}
|
||||
|
||||
|
||||
return colorPickerDialog;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.databinding.LayoutDimensionAttrEditorBinding;
|
||||
@@ -35,7 +33,6 @@ import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.androidide.utils.TextWatcherAdapter;
|
||||
import com.itsaky.inflater.values.FrameworkValues;
|
||||
import com.itsaky.inflater.values.ValuesTableFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -46,96 +43,96 @@ import java.util.stream.Collectors;
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public class DimensionEditor extends AbstractReferenceEditor {
|
||||
|
||||
private static final Logger LOG = Logger.instance ("DimensionEditor");
|
||||
|
||||
private static final Logger LOG = Logger.instance("DimensionEditor");
|
||||
public TextWatcherAdapter dimensionInputWatcher;
|
||||
|
||||
|
||||
private LayoutDimensionAttrEditorBinding binding;
|
||||
private String[] dimensionUnits;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView (
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
this.binding = LayoutDimensionAttrEditorBinding.inflate (inflater, container, false);
|
||||
return this.binding.getRoot ();
|
||||
this.binding = LayoutDimensionAttrEditorBinding.inflate(inflater, container, false);
|
||||
return this.binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated (@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated (view, savedInstanceState);
|
||||
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
final var dimensionInput =
|
||||
Objects.requireNonNull (this.binding.dimensionInput.getEditText ());
|
||||
setDimensionValue (dimensionInput);
|
||||
Objects.requireNonNull(this.binding.dimensionInput.getEditText());
|
||||
setDimensionValue(dimensionInput);
|
||||
if (dimensionInputWatcher != null) {
|
||||
dimensionInput.removeTextChangedListener (dimensionInputWatcher);
|
||||
dimensionInput.removeTextChangedListener(dimensionInputWatcher);
|
||||
}
|
||||
|
||||
|
||||
dimensionInputWatcher =
|
||||
new TextWatcherAdapter () {
|
||||
new TextWatcherAdapter() {
|
||||
@Override
|
||||
public void afterTextChanged (@NonNull Editable s) {
|
||||
final var text = s.toString ().trim ();
|
||||
public void afterTextChanged(@NonNull Editable s) {
|
||||
final var text = s.toString().trim();
|
||||
final var unit =
|
||||
getDimensionUnits ()[binding.unitSelector.getSelectedItemPosition ()];
|
||||
|
||||
getDimensionUnits()[binding.unitSelector.getSelectedItemPosition()];
|
||||
|
||||
// This will call CommonParseUtils#parseDimension
|
||||
notifyValueChanged (text.concat (unit));
|
||||
notifyValueChanged(text.concat(unit));
|
||||
}
|
||||
};
|
||||
|
||||
dimensionInput.addTextChangedListener (dimensionInputWatcher);
|
||||
|
||||
|
||||
dimensionInput.addTextChangedListener(dimensionInputWatcher);
|
||||
|
||||
final var dimensionResInput =
|
||||
(MaterialAutoCompleteTextView)
|
||||
Objects.requireNonNull (binding.dimensionResInput.getEditText ());
|
||||
setupReferenceInput (dimensionResInput);
|
||||
Objects.requireNonNull(binding.dimensionResInput.getEditText());
|
||||
setupReferenceInput(dimensionResInput);
|
||||
}
|
||||
|
||||
private void setDimensionValue (EditText dimensionInput) {
|
||||
final var val = attribute.getValue ();
|
||||
var dimension = val.substring (0, val.length () - 2);
|
||||
if (TextUtils.isDigitsOnly (dimension)) {
|
||||
dimensionInput.setText (dimension);
|
||||
final var arr = requireContext ().getResources ().getStringArray (R.array.dimension_units);
|
||||
final var index = Arrays.asList (arr).indexOf (val.substring (dimension.length ()));
|
||||
|
||||
private void setDimensionValue(EditText dimensionInput) {
|
||||
final var val = attribute.getValue();
|
||||
var dimension = val.substring(0, val.length() - 2);
|
||||
if (TextUtils.isDigitsOnly(dimension)) {
|
||||
dimensionInput.setText(dimension);
|
||||
final var arr = requireContext().getResources().getStringArray(R.array.dimension_units);
|
||||
final var index = Arrays.asList(arr).indexOf(val.substring(dimension.length()));
|
||||
if (index >= 0) {
|
||||
this.binding.unitSelector.setSelection (index);
|
||||
this.binding.unitSelector.setSelection(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
private String[] getDimensionUnits () {
|
||||
private String[] getDimensionUnits() {
|
||||
if (dimensionUnits == null) {
|
||||
dimensionUnits =
|
||||
requireContext ().getResources ().getStringArray (R.array.dimension_units);
|
||||
requireContext().getResources().getStringArray(R.array.dimension_units);
|
||||
}
|
||||
|
||||
|
||||
return dimensionUnits;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<String> computeReferenceItems () {
|
||||
final var list = new ArrayList<String> ();
|
||||
final var tables = ValuesTableFactory.getAllTables ();
|
||||
for (var entry : tables.entrySet ()) {
|
||||
final var dimens = entry.getValue ().getTable ("dimen");
|
||||
protected List<String> computeReferenceItems() {
|
||||
final var list = new ArrayList<String>();
|
||||
final var tables = ValuesTableFactory.getAllTables();
|
||||
for (var entry : tables.entrySet()) {
|
||||
final var dimens = entry.getValue().getTable("dimen");
|
||||
if (dimens != null) {
|
||||
list.addAll (
|
||||
dimens.keySet ().stream ()
|
||||
.map ("@dimen/"::concat)
|
||||
.collect (Collectors.toSet ()));
|
||||
list.addAll(
|
||||
dimens.keySet().stream()
|
||||
.map("@dimen/"::concat)
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
|
||||
list.addAll (
|
||||
FrameworkValues.listDimens ().stream ()
|
||||
.map ("@android:dimen/"::concat)
|
||||
.collect (Collectors.toList ()));
|
||||
|
||||
list.addAll(
|
||||
FrameworkValues.listDimens().stream()
|
||||
.map("@android:dimen/"::concat)
|
||||
.collect(Collectors.toList()));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@ package com.itsaky.androidide.fragments.attr;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.chip.Chip;
|
||||
import com.google.android.material.chip.ChipGroup;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
@@ -30,35 +28,35 @@ import com.itsaky.androidide.utils.Logger;
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public class EnumEditor extends FixedValueEditor {
|
||||
|
||||
private static final Logger LOG = Logger.instance ("EnumEditor");
|
||||
|
||||
|
||||
private static final Logger LOG = Logger.instance("EnumEditor");
|
||||
|
||||
@Override
|
||||
public void onViewCreated (@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated (view, savedInstanceState);
|
||||
|
||||
this.chipGroup.setSingleSelection (true);
|
||||
this.chipGroup.setSelectionRequired (true);
|
||||
|
||||
final var val = this.attribute.getValue ();
|
||||
for (int i = 0; i < this.chipGroup.getChildCount (); i++) {
|
||||
final var chip = (Chip) this.chipGroup.getChildAt (i);
|
||||
if (val.equals (chip.getText ().toString ().trim ())) {
|
||||
chip.setChecked (true);
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
this.chipGroup.setSingleSelection(true);
|
||||
this.chipGroup.setSelectionRequired(true);
|
||||
|
||||
final var val = this.attribute.getValue();
|
||||
for (int i = 0; i < this.chipGroup.getChildCount(); i++) {
|
||||
final var chip = (Chip) this.chipGroup.getChildAt(i);
|
||||
if (val.equals(chip.getText().toString().trim())) {
|
||||
chip.setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCheckChanged (@NonNull ChipGroup group, int checkedId) {
|
||||
final var chip = (Chip) group.findViewById (group.getCheckedChipId ());
|
||||
protected void onCheckChanged(@NonNull ChipGroup group, int checkedId) {
|
||||
final var chip = (Chip) group.findViewById(group.getCheckedChipId());
|
||||
if (chip == null) {
|
||||
LOG.error ("Unable to update enum value. Checked Chip view is null.");
|
||||
LOG.error("Unable to update enum value. Checked Chip view is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
final var val = chip.getText ().toString ().trim ();
|
||||
notifyValueChanged (val);
|
||||
|
||||
final var val = chip.getText().toString().trim();
|
||||
notifyValueChanged(val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,12 @@ import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.android.material.chip.Chip;
|
||||
import com.google.android.material.chip.ChipGroup;
|
||||
import com.itsaky.androidide.R;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,14 +23,11 @@ import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.chip.Chip;
|
||||
import com.google.android.material.chip.ChipGroup;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -48,12 +45,12 @@ public class FlagEditor extends FixedValueEditor {
|
||||
this.chipGroup.setSingleSelection(false);
|
||||
this.chipGroup.setSelectionRequired(true);
|
||||
this.chipGroup.setOnCheckedChangeListener(null); // does not work for multiple selections
|
||||
|
||||
final var values = Arrays.asList (this.attribute.getValue ().split ("\\|"));
|
||||
for (int i = 0; i < this.chipGroup.getChildCount (); i++) {
|
||||
final var chip = (Chip) this.chipGroup.getChildAt (i);
|
||||
if (values.contains (chip.getText ().toString ().trim ())) {
|
||||
chip.setChecked (true);
|
||||
|
||||
final var values = Arrays.asList(this.attribute.getValue().split("\\|"));
|
||||
for (int i = 0; i < this.chipGroup.getChildCount(); i++) {
|
||||
final var chip = (Chip) this.chipGroup.getChildAt(i);
|
||||
if (values.contains(chip.getText().toString().trim())) {
|
||||
chip.setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,16 +21,13 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.databinding.LayoutReferenceAttrEditorBinding;
|
||||
import com.itsaky.inflater.values.FrameworkValues;
|
||||
import com.itsaky.inflater.values.ValuesTableFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -39,47 +36,45 @@ import java.util.stream.Collectors;
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public class ReferenceEditor extends AbstractReferenceEditor {
|
||||
|
||||
|
||||
private LayoutReferenceAttrEditorBinding binding;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView (@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
this.binding = LayoutReferenceAttrEditorBinding.inflate (inflater, container, false);
|
||||
return this.binding.getRoot ();
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
this.binding = LayoutReferenceAttrEditorBinding.inflate(inflater, container, false);
|
||||
return this.binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated (@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated (view, savedInstanceState);
|
||||
|
||||
setupReferenceInput ((MaterialAutoCompleteTextView) this.binding.resInput.getEditText ());
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
setupReferenceInput((MaterialAutoCompleteTextView) this.binding.resInput.getEditText());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<String> computeReferenceItems () {
|
||||
final var resTable = StudioApp.getInstance ().getResourceTable ();
|
||||
final var list = new ArrayList<> (resTable.listResourceNames (null));
|
||||
|
||||
final var tables = ValuesTableFactory.getAllTables ();
|
||||
for (var entry : tables.entrySet ()) {
|
||||
final var resourceMap = entry.getValue ().getResourceMap ();
|
||||
for (var resourceEntries : resourceMap.entrySet ()) {
|
||||
final var name = resourceEntries.getKey ();
|
||||
list.addAll (
|
||||
resourceEntries
|
||||
.getValue ()
|
||||
.keySet ()
|
||||
.stream ()
|
||||
.map (("@android:" + name + "/")::concat)
|
||||
.collect (Collectors.toList ()
|
||||
)
|
||||
);
|
||||
protected List<String> computeReferenceItems() {
|
||||
final var resTable = StudioApp.getInstance().getResourceTable();
|
||||
final var list = new ArrayList<>(resTable.listResourceNames(null));
|
||||
|
||||
final var tables = ValuesTableFactory.getAllTables();
|
||||
for (var entry : tables.entrySet()) {
|
||||
final var resourceMap = entry.getValue().getResourceMap();
|
||||
for (var resourceEntries : resourceMap.entrySet()) {
|
||||
final var name = resourceEntries.getKey();
|
||||
list.addAll(
|
||||
resourceEntries.getValue().keySet().stream()
|
||||
.map(("@android:" + name + "/")::concat)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
list.addAll (FrameworkValues.listAllResources ());
|
||||
|
||||
|
||||
list.addAll(FrameworkValues.listAllResources());
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,16 +21,13 @@ import android.text.Editable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
||||
import com.itsaky.androidide.databinding.LayoutStringAttrEditorBinding;
|
||||
import com.itsaky.androidide.utils.TextWatcherAdapter;
|
||||
import com.itsaky.inflater.values.FrameworkValues;
|
||||
import com.itsaky.inflater.values.ValuesTableFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -40,50 +37,55 @@ import java.util.stream.Collectors;
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public class StringEditor extends AbstractReferenceEditor {
|
||||
|
||||
|
||||
private LayoutStringAttrEditorBinding binding;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView (@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
this.binding = LayoutStringAttrEditorBinding.inflate (inflater, container, false);
|
||||
return this.binding.getRoot ();
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
this.binding = LayoutStringAttrEditorBinding.inflate(inflater, container, false);
|
||||
return this.binding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated (@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated (view, savedInstanceState);
|
||||
|
||||
final var stringInput = Objects.requireNonNull (this.binding.stringInput.getEditText ());
|
||||
stringInput.addTextChangedListener (new TextWatcherAdapter () {
|
||||
@Override
|
||||
public void afterTextChanged (@NonNull Editable s) {
|
||||
notifyValueChanged (s.toString ());
|
||||
}
|
||||
});
|
||||
|
||||
stringInput.setText (this.attribute.getValue ());
|
||||
setupReferenceInput ((MaterialAutoCompleteTextView) this.binding.stringResInput.getEditText ());
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
final var stringInput = Objects.requireNonNull(this.binding.stringInput.getEditText());
|
||||
stringInput.addTextChangedListener(
|
||||
new TextWatcherAdapter() {
|
||||
@Override
|
||||
public void afterTextChanged(@NonNull Editable s) {
|
||||
notifyValueChanged(s.toString());
|
||||
}
|
||||
});
|
||||
|
||||
stringInput.setText(this.attribute.getValue());
|
||||
setupReferenceInput(
|
||||
(MaterialAutoCompleteTextView) this.binding.stringResInput.getEditText());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<String> computeReferenceItems () {
|
||||
final var list = new ArrayList<String> ();
|
||||
final var tables = ValuesTableFactory.getAllTables ();
|
||||
for (var entry : tables.entrySet ()) {
|
||||
final var dimens = entry.getValue ().getTable ("string");
|
||||
protected List<String> computeReferenceItems() {
|
||||
final var list = new ArrayList<String>();
|
||||
final var tables = ValuesTableFactory.getAllTables();
|
||||
for (var entry : tables.entrySet()) {
|
||||
final var dimens = entry.getValue().getTable("string");
|
||||
if (dimens != null) {
|
||||
list.addAll (
|
||||
dimens.keySet ().stream ()
|
||||
.map ("@string/"::concat)
|
||||
.collect (Collectors.toSet ()));
|
||||
list.addAll(
|
||||
dimens.keySet().stream()
|
||||
.map("@string/"::concat)
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
|
||||
list.addAll (
|
||||
FrameworkValues.listStrings ().stream ()
|
||||
.map ("@android:string/"::concat)
|
||||
.collect (Collectors.toList ()));
|
||||
|
||||
list.addAll(
|
||||
FrameworkValues.listStrings().stream()
|
||||
.map("@android:string/"::concat)
|
||||
.collect(Collectors.toList()));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
-2
@@ -24,10 +24,8 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.managers.PreferenceManager;
|
||||
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
package com.itsaky.androidide.fragments.preferences;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.itsaky.androidide.R;
|
||||
@@ -33,7 +31,6 @@ import com.itsaky.androidide.fragments.sheets.ProgressSheet;
|
||||
import com.itsaky.androidide.tasks.TaskExecutor;
|
||||
import com.itsaky.androidide.utils.DialogUtils;
|
||||
import com.itsaky.androidide.utils.Environment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BuildPreferences extends BasePreferenceFragment
|
||||
|
||||
@@ -35,12 +35,10 @@ import static com.itsaky.androidide.models.PrefBasedJavaServerSettings.KEY_JAVA_
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
|
||||
@@ -20,12 +20,10 @@ package com.itsaky.androidide.fragments.preferences;
|
||||
import static com.itsaky.androidide.managers.PreferenceManager.*;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
|
||||
public class GeneralPreferences extends BasePreferenceFragment
|
||||
|
||||
@@ -22,11 +22,9 @@ import static com.itsaky.androidide.utils.Logger.instance;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.itsaky.androidide.AboutActivity;
|
||||
import com.itsaky.androidide.BuildConfig;
|
||||
import com.itsaky.androidide.R;
|
||||
@@ -34,7 +32,6 @@ import com.itsaky.androidide.app.BaseApplication;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
public class IDEPreferences extends BasePreferenceFragment {
|
||||
|
||||
@@ -21,11 +21,9 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.transition.TransitionManager;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.adapters.SimpleIconTextAdapter;
|
||||
@@ -42,9 +40,6 @@ import com.itsaky.inflater.IAttribute;
|
||||
import com.itsaky.inflater.IView;
|
||||
import com.itsaky.inflater.impl.UiAttribute;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -53,6 +48,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
public class AttrEditorSheet extends BottomSheetDialogFragment
|
||||
implements SimpleIconTextAdapter.OnBindListener<IconTextListItem> {
|
||||
|
||||
@@ -33,10 +33,8 @@ import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.itsaky.androidide.adapters.AttrValueFormatTabAdapter;
|
||||
import com.itsaky.androidide.databinding.LayoutAttrValueEditorBinding;
|
||||
@@ -49,15 +47,12 @@ import com.itsaky.androidide.fragments.attr.FlagEditor;
|
||||
import com.itsaky.androidide.fragments.attr.FloatEditor;
|
||||
import com.itsaky.androidide.fragments.attr.FractionEditor;
|
||||
import com.itsaky.androidide.fragments.attr.IntegerEditor;
|
||||
import com.itsaky.androidide.fragments.attr.AbstractReferenceEditor;
|
||||
import com.itsaky.androidide.fragments.attr.ReferenceEditor;
|
||||
import com.itsaky.androidide.fragments.attr.StringEditor;
|
||||
import com.itsaky.androidide.models.XMLAttribute;
|
||||
import com.itsaky.attrinfo.models.Attr;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Sheet for editing value of an attribute.
|
||||
|
||||
@@ -22,18 +22,15 @@ import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.adapters.AttrListAdapter;
|
||||
import com.itsaky.androidide.databinding.LayoutAddAttrSheetBinding;
|
||||
import com.itsaky.attrinfo.models.Attr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -23,9 +23,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.itsaky.androidide.databinding.LayoutSheetBinding;
|
||||
|
||||
|
||||
@@ -23,14 +23,11 @@ package com.itsaky.androidide.fragments.sheets;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.itsaky.androidide.adapters.OptionsSheetAdapter;
|
||||
import com.itsaky.androidide.models.SheetOption;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -26,9 +26,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.databinding.LayoutProgressSheetBinding;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
|
||||
@@ -22,13 +22,10 @@ import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.utils.TypefaceUtils;
|
||||
import com.itsaky.androidide.views.editor.IDEEditor;
|
||||
|
||||
import io.github.rosemoe.sora.lang.EmptyLanguage;
|
||||
|
||||
public class TextSheetFragment extends BaseBottomSheetFragment {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.handlers;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.managers.PreferenceManager;
|
||||
@@ -31,7 +30,6 @@ import com.itsaky.androidide.tasks.GradleTask;
|
||||
import com.itsaky.androidide.tasks.gradle.build.ApkGeneratingTask;
|
||||
import com.itsaky.androidide.utils.DialogUtils;
|
||||
import com.itsaky.androidide.utils.Environment;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.handlers;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import com.blankj.utilcode.util.ClipboardUtils;
|
||||
import com.blankj.utilcode.util.FileIOUtils;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
@@ -34,7 +33,6 @@ import com.itsaky.androidide.utils.Environment;
|
||||
import com.itsaky.androidide.utils.ProjectWriter;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
import com.unnamed.b.atv.model.TreeNode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.itsaky.androidide.interfaces;
|
||||
|
||||
import com.itsaky.androidide.models.DiagnosticGroup;
|
||||
import com.itsaky.lsp.models.DiagnosticItem;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface DiagnosticClickListener {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.language;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.lsp.api.ICompletionProvider;
|
||||
import com.itsaky.lsp.api.ILanguageServer;
|
||||
@@ -26,14 +25,10 @@ import com.itsaky.lsp.models.CompletionItem;
|
||||
import com.itsaky.lsp.models.CompletionParams;
|
||||
import com.itsaky.lsp.models.CompletionResult;
|
||||
import com.itsaky.lsp.models.Position;
|
||||
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionHelper;
|
||||
import io.github.rosemoe.sora.text.CharPosition;
|
||||
import io.github.rosemoe.sora.text.ContentReference;
|
||||
import io.github.rosemoe.sora.util.MyCharacter;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -42,6 +37,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Predicate;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Common implementation of completion provider which requests completions to provided language
|
||||
|
||||
@@ -17,16 +17,13 @@
|
||||
package com.itsaky.androidide.language;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.lsp.api.ILanguageServer;
|
||||
import com.itsaky.lsp.models.DiagnosticItem;
|
||||
|
||||
import io.github.rosemoe.sora.lang.Language;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.rosemoe.sora.lang.Language;
|
||||
|
||||
/**
|
||||
* Base class for language implementations in the IDE.
|
||||
*
|
||||
|
||||
@@ -31,19 +31,16 @@ import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.get;
|
||||
import com.itsaky.androidide.lexers.groovy.GroovyLexer;
|
||||
import com.itsaky.androidide.utils.CharSequenceReader;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
import io.github.rosemoe.sora.lang.analysis.SimpleAnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.styling.CodeBlock;
|
||||
import io.github.rosemoe.sora.lang.styling.MappedSpans;
|
||||
import io.github.rosemoe.sora.lang.styling.Styles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Stack;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CodePointCharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Stack;
|
||||
|
||||
public class GroovyAnalyzer extends SimpleAnalyzeManager<Void> {
|
||||
|
||||
private static final Logger LOG = Logger.instance("GroovyAnalyzer");
|
||||
|
||||
@@ -20,17 +20,14 @@
|
||||
package com.itsaky.androidide.language.groovy;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.itsaky.lsp.models.CompletionItem;
|
||||
import com.itsaky.lsp.models.CompletionItemKind;
|
||||
import com.itsaky.lsp.models.InsertTextFormat;
|
||||
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionHelper;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionPublisher;
|
||||
import io.github.rosemoe.sora.text.CharPosition;
|
||||
import io.github.rosemoe.sora.text.ContentReference;
|
||||
import io.github.rosemoe.sora.util.MyCharacter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -18,14 +18,11 @@
|
||||
package com.itsaky.androidide.language.groovy;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.language.IDELanguage;
|
||||
import com.itsaky.androidide.lexers.groovy.GroovyLexer;
|
||||
import com.itsaky.androidide.utils.CharSequenceReader;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
import io.github.rosemoe.sora.lang.analysis.AnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionCancelledException;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionPublisher;
|
||||
@@ -35,12 +32,10 @@ import io.github.rosemoe.sora.text.CharPosition;
|
||||
import io.github.rosemoe.sora.text.ContentReference;
|
||||
import io.github.rosemoe.sora.text.TextUtils;
|
||||
import io.github.rosemoe.sora.widget.SymbolPairMatch;
|
||||
|
||||
import java.io.StringReader;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
public class GroovyLanguage extends IDELanguage {
|
||||
|
||||
private final GroovyAnalyzer analyzer;
|
||||
|
||||
@@ -28,7 +28,6 @@ import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.get;
|
||||
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.withoutCompletion;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.lexers.java.JavaLexer;
|
||||
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE;
|
||||
import com.itsaky.androidide.utils.CharSequenceReader;
|
||||
@@ -40,24 +39,21 @@ import com.itsaky.lsp.models.DiagnosticResult;
|
||||
import com.itsaky.lsp.models.DiagnosticSeverity;
|
||||
import com.itsaky.lsp.models.Position;
|
||||
import com.itsaky.lsp.models.Range;
|
||||
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CodePointCharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import io.github.rosemoe.sora.lang.analysis.SimpleAnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.styling.CodeBlock;
|
||||
import io.github.rosemoe.sora.lang.styling.MappedSpans;
|
||||
import io.github.rosemoe.sora.lang.styling.Span;
|
||||
import io.github.rosemoe.sora.lang.styling.Styles;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import io.github.rosemoe.sora.lang.analysis.SimpleAnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.styling.CodeBlock;
|
||||
import io.github.rosemoe.sora.lang.styling.MappedSpans;
|
||||
import io.github.rosemoe.sora.lang.styling.Span;
|
||||
import io.github.rosemoe.sora.lang.styling.Styles;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CodePointCharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Code analyzer for the Java Language
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
package com.itsaky.androidide.language.java;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.language.CommonCompletionProvider;
|
||||
import com.itsaky.androidide.language.IDELanguage;
|
||||
@@ -30,16 +28,6 @@ import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.androidide.views.editor.IDEEditor;
|
||||
import com.itsaky.lsp.api.ILanguageServer;
|
||||
import com.itsaky.lsp.models.DiagnosticItem;
|
||||
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.rosemoe.sora.lang.analysis.AnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionCancelledException;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionPublisher;
|
||||
@@ -49,6 +37,13 @@ import io.github.rosemoe.sora.text.CharPosition;
|
||||
import io.github.rosemoe.sora.text.ContentReference;
|
||||
import io.github.rosemoe.sora.text.TextUtils;
|
||||
import io.github.rosemoe.sora.widget.SymbolPairMatch;
|
||||
import java.io.StringReader;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class JavaLanguage extends IDELanguage {
|
||||
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
package com.itsaky.androidide.language.logs;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.language.IDELanguage;
|
||||
import com.itsaky.androidide.models.LogLine;
|
||||
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE;
|
||||
|
||||
import io.github.rosemoe.sora.lang.analysis.AnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.analysis.SimpleAnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionCancelledException;
|
||||
@@ -35,7 +32,6 @@ import io.github.rosemoe.sora.lang.styling.Styles;
|
||||
import io.github.rosemoe.sora.text.CharPosition;
|
||||
import io.github.rosemoe.sora.text.ContentReference;
|
||||
import io.github.rosemoe.sora.widget.SymbolPairMatch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -21,26 +21,22 @@ import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.OPERATO
|
||||
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.TEXT_SELECTED;
|
||||
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.forComment;
|
||||
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.get;
|
||||
|
||||
import static io.github.rosemoe.sora.widget.schemes.EditorColorScheme.LITERAL;
|
||||
|
||||
import com.itsaky.androidide.lexers.xml.XMLLexer;
|
||||
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE;
|
||||
import com.itsaky.androidide.utils.CharSequenceReader;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
import io.github.rosemoe.sora.lang.analysis.SimpleAnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.styling.CodeBlock;
|
||||
import io.github.rosemoe.sora.lang.styling.MappedSpans;
|
||||
import io.github.rosemoe.sora.lang.styling.Styles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Stack;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CodePointCharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* Simple analyzer implementation for the XML files.
|
||||
*
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
package com.itsaky.androidide.language.xml;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.language.CommonCompletionProvider;
|
||||
import com.itsaky.androidide.language.IDELanguage;
|
||||
@@ -29,14 +27,6 @@ import com.itsaky.androidide.utils.JavaCharacter;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.androidide.views.editor.IDEEditor;
|
||||
import com.itsaky.lsp.api.ILanguageServer;
|
||||
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.github.rosemoe.sora.lang.analysis.AnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionCancelledException;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionPublisher;
|
||||
@@ -44,6 +34,11 @@ import io.github.rosemoe.sora.lang.smartEnter.NewlineHandler;
|
||||
import io.github.rosemoe.sora.text.CharPosition;
|
||||
import io.github.rosemoe.sora.text.ContentReference;
|
||||
import io.github.rosemoe.sora.widget.SymbolPairMatch;
|
||||
import java.io.StringReader;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class XMLLanguage extends IDELanguage {
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package com.itsaky.androidide.lsp;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.blankj.utilcode.util.FileIOUtils;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
@@ -48,9 +47,7 @@ import com.itsaky.lsp.models.Location;
|
||||
import com.itsaky.lsp.models.Range;
|
||||
import com.itsaky.lsp.models.TextEdit;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
|
||||
import io.github.rosemoe.sora.text.Content;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.models;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ApkMetadata {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.models;
|
||||
|
||||
import com.itsaky.lsp.models.DiagnosticItem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
package com.itsaky.androidide.models;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.itsaky.androidide.R;
|
||||
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class LogLine {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.models;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.androidide.managers.PreferenceManager;
|
||||
import com.itsaky.lsp.java.models.DefaultJavaServerSettings;
|
||||
@@ -31,7 +30,8 @@ import com.itsaky.lsp.java.models.DefaultJavaServerSettings;
|
||||
public class PrefBasedJavaServerSettings extends DefaultJavaServerSettings {
|
||||
|
||||
public static final String KEY_JAVA_PREF_MATCH_LOWER = "idepref_editor_java_matchLower";
|
||||
public static final String KEY_JAVA_PREF_GOOGLE_CODE_STYLE = "idepref_editor_java_googleCodeStyle";
|
||||
public static final String KEY_JAVA_PREF_GOOGLE_CODE_STYLE =
|
||||
"idepref_editor_java_googleCodeStyle";
|
||||
|
||||
private static PrefBasedJavaServerSettings instance;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.models;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.models;
|
||||
|
||||
import com.itsaky.lsp.models.Range;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SearchResult extends Range {
|
||||
|
||||
@@ -20,9 +20,7 @@ package com.itsaky.androidide.models;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,14 +19,11 @@ package com.itsaky.androidide.models;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Model class for holding data about a group that will be displayed in Widgets list in UI Designer
|
||||
|
||||
@@ -19,18 +19,14 @@ package com.itsaky.androidide.models;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
import com.itsaky.attrinfo.models.Attr;
|
||||
import com.itsaky.inflater.IAttribute;
|
||||
import com.itsaky.inflater.impl.UiAttribute;
|
||||
import com.itsaky.xml.INamespace;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
/**
|
||||
* A model that is used to show attributes list of a view.
|
||||
|
||||
@@ -22,9 +22,7 @@ package com.itsaky.androidide.project;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.project;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -19,11 +19,9 @@ package com.itsaky.androidide.project;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.inflater.IResourceTable;
|
||||
import com.itsaky.inflater.values.ValuesTableFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.Collection;
|
||||
@@ -31,282 +29,282 @@ import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ProjectResourceTable implements IResourceTable {
|
||||
|
||||
private static final Logger LOG = Logger.instance ("ProjectResourceFinder");
|
||||
|
||||
private static final Logger LOG = Logger.instance("ProjectResourceFinder");
|
||||
private File resDir;
|
||||
private File color;
|
||||
private File layout;
|
||||
private File[] drawables;
|
||||
private File[] mipmaps;
|
||||
|
||||
|
||||
@Override
|
||||
public File findDrawable (@NonNull String name) {
|
||||
public File findDrawable(@NonNull String name) {
|
||||
for (File drawable : drawables) {
|
||||
final File file = findFileWithName (drawable.listFiles (), name);
|
||||
final File file = findFileWithName(drawable.listFiles(), name);
|
||||
if (file != null) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public File findLayout (@NonNull String name) {
|
||||
return findFileWithName (this.layout.listFiles (), name);
|
||||
public File findLayout(@NonNull String name) {
|
||||
return findFileWithName(this.layout.listFiles(), name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String findString (@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable (resDir);
|
||||
|
||||
public String findString(@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable(resDir);
|
||||
|
||||
if (table == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var resource = table.findString (name);
|
||||
|
||||
final var resource = table.findString(name);
|
||||
if (resource == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var value = resource.getValue ();
|
||||
if (value.startsWith ("@string/")) {
|
||||
var ref = value.substring ("@string/".length ());
|
||||
if (name.equals (ref)) {
|
||||
|
||||
final var value = resource.getValue();
|
||||
if (value.startsWith("@string/")) {
|
||||
var ref = value.substring("@string/".length());
|
||||
if (name.equals(ref)) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String findBoolean (@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable (resDir);
|
||||
|
||||
public String findBoolean(@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable(resDir);
|
||||
|
||||
if (table == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var resource = table.findBoolean (name);
|
||||
|
||||
final var resource = table.findBoolean(name);
|
||||
if (resource == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var val = resource.getValue ();
|
||||
if (val.startsWith ("@bool/")) {
|
||||
final var ref = val.substring ("@bool/".length ());
|
||||
if (ref.equals (name)) {
|
||||
|
||||
final var val = resource.getValue();
|
||||
if (val.startsWith("@bool/")) {
|
||||
final var ref = val.substring("@bool/".length());
|
||||
if (ref.equals(name)) {
|
||||
// recursive reference
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String findInteger (@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable (resDir);
|
||||
|
||||
public String findInteger(@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable(resDir);
|
||||
|
||||
if (table == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var resource = table.findInteger (name);
|
||||
|
||||
final var resource = table.findInteger(name);
|
||||
if (resource == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var val = resource.getValue ();
|
||||
if (val.startsWith ("@integer/")) {
|
||||
final var ref = val.substring ("@integer/".length ());
|
||||
if (ref.equals (name)) {
|
||||
|
||||
final var val = resource.getValue();
|
||||
if (val.startsWith("@integer/")) {
|
||||
final var ref = val.substring("@integer/".length());
|
||||
if (ref.equals(name)) {
|
||||
// recursive reference
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String findColor (@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable (resDir);
|
||||
|
||||
public String findColor(@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable(resDir);
|
||||
|
||||
if (table == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var resource = table.findColor (name);
|
||||
|
||||
final var resource = table.findColor(name);
|
||||
if (resource == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var value = resource.getValue ();
|
||||
if (value.startsWith ("@color/")) {
|
||||
var ref = value.substring ("@color/".length ());
|
||||
if (name.equals (ref)) {
|
||||
|
||||
final var value = resource.getValue();
|
||||
if (value.startsWith("@color/")) {
|
||||
var ref = value.substring("@color/".length());
|
||||
if (name.equals(ref)) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] findArray (@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable (resDir);
|
||||
public String[] findArray(@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable(resDir);
|
||||
if (table == null) {
|
||||
return new String[]{name};
|
||||
return new String[] {name};
|
||||
}
|
||||
|
||||
final var resource = table.findArray (name);
|
||||
|
||||
final var resource = table.findArray(name);
|
||||
if (resource == null) {
|
||||
return new String[]{name};
|
||||
return new String[] {name};
|
||||
}
|
||||
|
||||
return resource.getValues ();
|
||||
|
||||
return resource.getValues();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String findDimension (@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable (resDir);
|
||||
|
||||
public String findDimension(@NonNull String name) {
|
||||
final var table = ValuesTableFactory.getTable(resDir);
|
||||
|
||||
if (table == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var resource = table.findDimension (name);
|
||||
|
||||
final var resource = table.findDimension(name);
|
||||
if (resource == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
final var value = resource.getValue ();
|
||||
if (value.startsWith ("@dimen/")) {
|
||||
var ref = value.substring ("@dimen/".length ());
|
||||
if (name.equals (ref)) {
|
||||
|
||||
final var value = resource.getValue();
|
||||
if (value.startsWith("@dimen/")) {
|
||||
var ref = value.substring("@dimen/".length());
|
||||
if (name.equals(ref)) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Collection<String> listResourceNames (@Nullable String type) {
|
||||
public Collection<String> listResourceNames(@Nullable String type) {
|
||||
if (type == null) {
|
||||
return listAllResourceNames ();
|
||||
return listAllResourceNames();
|
||||
} else {
|
||||
final var set = new HashSet<String> ();
|
||||
final var set = new HashSet<String>();
|
||||
switch (type) {
|
||||
case "drawable":
|
||||
for (var folder : this.drawables) {
|
||||
listAndAddTo (set, folder, type);
|
||||
listAndAddTo(set, folder, type);
|
||||
}
|
||||
break;
|
||||
case "layout":
|
||||
listAndAddTo (set, this.layout, type);
|
||||
listAndAddTo(set, this.layout, type);
|
||||
break;
|
||||
case "color":
|
||||
listAndAddTo (set, this.color, type);
|
||||
listAndAddTo(set, this.color, type);
|
||||
break;
|
||||
case "mipmap":
|
||||
for (var folder : this.mipmaps) {
|
||||
listAndAddTo (set, folder, type);
|
||||
listAndAddTo(set, folder, type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
private void listAndAddTo (HashSet<String> set, @NonNull File dir, String type) {
|
||||
final var files = dir.listFiles ();
|
||||
|
||||
private void listAndAddTo(HashSet<String> set, @NonNull File dir, String type) {
|
||||
final var files = dir.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (var file : files) {
|
||||
var name = file.getName ();
|
||||
if (!name.contains (".")) {
|
||||
var name = file.getName();
|
||||
if (!name.contains(".")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
name = name.substring (0, name.lastIndexOf ('.'));
|
||||
name = String.format (Locale.ROOT, "@%s/%s", type, name);
|
||||
set.add (name);
|
||||
|
||||
name = name.substring(0, name.lastIndexOf('.'));
|
||||
name = String.format(Locale.ROOT, "@%s/%s", type, name);
|
||||
set.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
private Collection<String> listAllResourceNames () {
|
||||
final var set = new HashSet<> (listResourceNames ("color"));
|
||||
set.addAll (listResourceNames ("drawable"));
|
||||
set.addAll (listResourceNames ("mipmap"));
|
||||
set.addAll (listResourceNames ("layout"));
|
||||
private Collection<String> listAllResourceNames() {
|
||||
final var set = new HashSet<>(listResourceNames("color"));
|
||||
set.addAll(listResourceNames("drawable"));
|
||||
set.addAll(listResourceNames("mipmap"));
|
||||
set.addAll(listResourceNames("layout"));
|
||||
return set;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setInflatingFile (@NonNull File file) {
|
||||
if (file.getParentFile () == null) {
|
||||
throw new IllegalArgumentException ("Invalid inflating file");
|
||||
public void setInflatingFile(@NonNull File file) {
|
||||
if (file.getParentFile() == null) {
|
||||
throw new IllegalArgumentException("Invalid inflating file");
|
||||
}
|
||||
|
||||
setupDirectories (
|
||||
|
||||
setupDirectories(
|
||||
file // layout file
|
||||
.getParentFile () // layout dir
|
||||
.getParentFile ()); // res dir
|
||||
.getParentFile() // layout dir
|
||||
.getParentFile()); // res dir
|
||||
}
|
||||
|
||||
private void setupDirectories (File resDir) {
|
||||
|
||||
|
||||
private void setupDirectories(File resDir) {
|
||||
|
||||
if (resDir == null) {
|
||||
LOG.error ("Null resource directory passed to resource finder. Ignoring.");
|
||||
LOG.error("Null resource directory passed to resource finder. Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.resDir = resDir;
|
||||
this.color = new File (resDir, "color");
|
||||
this.layout = new File (resDir, "layout");
|
||||
|
||||
final File[] drawables = resDir.listFiles (new NameStartsWith ("drawable"));
|
||||
this.color = new File(resDir, "color");
|
||||
this.layout = new File(resDir, "layout");
|
||||
|
||||
final File[] drawables = resDir.listFiles(new NameStartsWith("drawable"));
|
||||
this.drawables = drawables == null ? new File[0] : drawables;
|
||||
|
||||
final File[] mipmaps = resDir.listFiles (new NameStartsWith ("mipmap"));
|
||||
|
||||
final File[] mipmaps = resDir.listFiles(new NameStartsWith("mipmap"));
|
||||
this.mipmaps = mipmaps == null ? new File[0] : mipmaps;
|
||||
}
|
||||
|
||||
private File findFileWithName (File[] files, String name) {
|
||||
|
||||
private File findFileWithName(File[] files, String name) {
|
||||
if (files == null || name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
for (File file : files) {
|
||||
var simpleName = file.getName ();
|
||||
|
||||
if (simpleName.startsWith (name)) {
|
||||
var simpleName = file.getName();
|
||||
|
||||
if (simpleName.startsWith(name)) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static class NameStartsWith implements FileFilter {
|
||||
|
||||
|
||||
private final String name;
|
||||
|
||||
public NameStartsWith (String name) {
|
||||
|
||||
public NameStartsWith(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean accept (@NonNull File file) {
|
||||
return file.getName ().startsWith (name);
|
||||
public boolean accept(@NonNull File file) {
|
||||
return file.getName().startsWith(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ package com.itsaky.androidide.services;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.itsaky.androidide.models.LogLine;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
|
||||
@@ -23,16 +23,13 @@ package com.itsaky.androidide.services;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.google.firebase.messaging.FirebaseMessagingService;
|
||||
import com.google.firebase.messaging.RemoteMessage;
|
||||
import com.itsaky.androidide.BuildConfig;
|
||||
import com.itsaky.androidide.SplashActivity;
|
||||
import com.itsaky.androidide.app.StudioApp;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MessagingService extends FirebaseMessagingService {
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.itsaky.androidide.services.builder;
|
||||
import com.itsaky.androidide.project.IDEModule;
|
||||
import com.itsaky.androidide.project.IDEProject;
|
||||
import com.itsaky.androidide.tasks.GradleTask;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/** A client should implement this interface to get callbacks about a build */
|
||||
|
||||
@@ -21,7 +21,6 @@ import static com.itsaky.androidide.managers.ToolsManager.getCommonAsset;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import com.blankj.utilcode.util.FileIOUtils;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.blankj.utilcode.util.ResourceUtils;
|
||||
@@ -44,9 +43,6 @@ import com.itsaky.androidide.utils.Environment;
|
||||
import com.itsaky.androidide.utils.InputStreamLineReader;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
import com.itsaky.toaster.Toaster;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -62,6 +58,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
public class IDEService {
|
||||
|
||||
|
||||
@@ -18,12 +18,10 @@
|
||||
package com.itsaky.androidide.services.builder;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.itsaky.androidide.project.IDEModule;
|
||||
import com.itsaky.androidide.project.IDEProject;
|
||||
import com.itsaky.androidide.tasks.GradleTask;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.itsaky.androidide.syntax.colorschemes;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import io.github.rosemoe.sora.lang.styling.TextStyle;
|
||||
import io.github.rosemoe.sora.widget.schemes.EditorColorScheme;
|
||||
|
||||
|
||||
@@ -19,18 +19,14 @@ package com.itsaky.androidide.syntax.highlighters;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.BackgroundColorSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
|
||||
import com.itsaky.androidide.lexers.java.JavaLexer;
|
||||
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE;
|
||||
|
||||
import io.github.rosemoe.sora.widget.schemes.EditorColorScheme;
|
||||
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class JavaHighlighter implements Highlighter {
|
||||
|
||||
|
||||
@@ -22,9 +22,7 @@ package com.itsaky.androidide.tasks;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@@ -21,10 +21,8 @@
|
||||
package com.itsaky.androidide.tasks.callables;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.itsaky.androidide.adapters.viewholders.FileTreeViewHolder;
|
||||
import com.unnamed.b.atv.model.TreeNode;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
package com.itsaky.androidide.tasks.callables;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.itsaky.androidide.models.License;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
package com.itsaky.androidide.tasks.callables;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.itsaky.androidide.interfaces.ProjectWriterCallback;
|
||||
import com.itsaky.androidide.models.NewProjectDetails;
|
||||
import com.itsaky.androidide.models.ProjectTemplate;
|
||||
import com.itsaky.androidide.utils.ProjectWriter;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class ProjectCreatorCallable implements Callable<Void> {
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
package com.itsaky.androidide.tasks.callables;
|
||||
|
||||
import com.blankj.utilcode.util.ZipUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.itsaky.androidide.models.ApkMetadata;
|
||||
import com.itsaky.androidide.tasks.BaseGradleTask;
|
||||
import com.itsaky.androidide.utils.JSONUtility;
|
||||
import com.itsaky.androidide.utils.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user