Skip to content

Commit

Permalink
feat: Better UI on AndroidManifest Cards
Browse files Browse the repository at this point in the history
  • Loading branch information
trindadedev13 committed Dec 28, 2024
1 parent f80de6d commit 74d638c
Showing 1 changed file with 68 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;

import a.a.a.aB;
Expand All @@ -41,6 +42,7 @@

import pro.sketchware.utility.SketchwareUtil;
import pro.sketchware.utility.FileUtil;
import pro.sketchware.utility.UI;
import mod.hey.studios.code.SrcCodeEditor;
import mod.hey.studios.code.SrcCodeEditorLegacy;
import mod.hey.studios.util.Helper;
Expand Down Expand Up @@ -109,61 +111,78 @@ private void setupViews() {
LinearLayout content = findViewById(R.id.content);
LinearLayout cards = findViewById(R.id.cards);

LibraryItemView application_card = new LibraryItemView(this);
makeup(application_card, R.drawable.icons8_app_attrs, "Application", "Default properties for the app");
cards.addView(application_card);
application_card.setOnClickListener(v -> {
Intent intent = new Intent();
intent.setClass(getApplicationContext(), AndroidManifestInjectionDetails.class);
intent.putExtra("sc_id", sc_id);
intent.putExtra("file_name", activityName);
intent.putExtra("type", "application");
startActivity(intent);
});

{
LibraryItemView permission_card = new LibraryItemView(this);
makeup(permission_card, R.drawable.event_on_signin_complete_48dp, "Permissions", "Add custom Permissions to the app");
cards.addView(permission_card);
permission_card.setOnClickListener(_view -> {
Intent inta = new Intent();
inta.setClass(getApplicationContext(), AndroidManifestInjectionDetails.class);
inta.putExtra("sc_id", sc_id);
inta.putExtra("file_name", activityName);
inta.putExtra("type", "permission");
startActivity(inta);
});
}

{
LibraryItemView permission_card = new LibraryItemView(this);
makeup(permission_card, R.drawable.recycling_48, "Launcher Activity", "Change the default Launcher Activity");
cards.addView(permission_card);
permission_card.setOnClickListener(v -> showLauncherActDialog(AndroidManifestInjector.getLauncherActivity(sc_id)));
}

LibraryItemView allAct_card = new LibraryItemView(this);
makeup(allAct_card, R.drawable.icons8_all_activities_attrs, "All Activities", "Add attributes for all Activities");
cards.addView(allAct_card);
allAct_card.setOnClickListener(v -> {
Intent inta = new Intent();
inta.setClass(getApplicationContext(), AndroidManifestInjectionDetails.class);
inta.putExtra("sc_id", sc_id);
inta.putExtra("file_name", activityName);
inta.putExtra("type", "all");
startActivity(inta);
List<LibraryItemView> options = new ArrayList<>();

options.add(createOption(
"Application",
"Default properties for the app",
R.drawable.icons8_app_attrs,
v -> {
Intent intent = new Intent();
intent.setClass(getApplicationContext(), AndroidManifestInjectionDetails.class);
intent.putExtra("sc_id", sc_id);
intent.putExtra("file_name", activityName);
intent.putExtra("type", "application");
startActivity(intent);
}
));
options.add(createOption(
"Permissions",
"Add custom Permissions to the app",
R.drawable.event_on_signin_complete_48dp,
v -> {
Intent intent = new Intent();
intent.setClass(getApplicationContext(), AndroidManifestInjectionDetails.class);
intent.putExtra("sc_id", sc_id);
intent.putExtra("file_name", activityName);
intent.putExtra("type", "permission");
startActivity(intent);
}
));
options.add(createOption(
"Launcher Activity",
"Change the default Launcher Activity",
R.drawable.recycling_48,
v -> showLauncherActDialog(AndroidManifestInjector.getLauncherActivity(sc_id))
));
options.add(createOption(
"All Activities",
"Add attributes for all Activities",
R.drawable.icons8_all_activities_attrs,
v -> {
Intent intent = new Intent();
intent.setClass(getApplicationContext(), AndroidManifestInjectionDetails.class);
intent.putExtra("sc_id", sc_id);
intent.putExtra("file_name", activityName);
intent.putExtra("type", "all");
startActivity(intent);
}
));
options.add(createOption(
"App Components",
"Add extra components",
R.drawable.icons8_app_components,
v -> showAppComponentDialog()
));

options.forEach(option -> {
final int index = options.indexOf(option);
option.container.setBackgroundResource(UI.getShapedBackgroundForList(options, index));
cards.addView(option);
});

LibraryItemView appCom_card = new LibraryItemView(this);
makeup(appCom_card, R.drawable.icons8_app_components, "App Components", "Add extra components");
cards.addView(appCom_card);
appCom_card.setOnClickListener(v -> showAppComponentDialog());


act_list = new ListView(this);
act_list.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
act_list.setDividerHeight(0);
content.addView(act_list);
}

private final LibraryItemView createOption(final String title, final String description, final int icon, View.OnClickListener onClick) {
var card = new LibraryItemView(this);
makeup(card, icon, title, description);
card.setOnClickListener(onClick);
return card;
}

private void showAppComponentDialog() {
Intent intent = new Intent();
Expand Down

0 comments on commit 74d638c

Please sign in to comment.