Feat[UX]: Make profile creation flow consistent

This commit is contained in:
Mathias-Boulay 2023-06-29 10:59:47 +02:00
parent 458331fd7c
commit 78f2dae9ce
9 changed files with 184 additions and 59 deletions

View File

@ -6,7 +6,6 @@ import static net.kdt.pojavlaunch.fragments.ProfileEditorFragment.DELETED_PROFIL
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.transition.Slide;
import android.transition.Transition;
import android.util.AttributeSet;
@ -26,8 +25,7 @@ import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.extra.ExtraConstants;
import net.kdt.pojavlaunch.extra.ExtraCore;
import net.kdt.pojavlaunch.fragments.ModdedProfileSelectFragment;
import net.kdt.pojavlaunch.fragments.ProfileEditorFragment;
import net.kdt.pojavlaunch.fragments.ProfileTypeSelectFragment;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.profiles.ProfileAdapter;
import net.kdt.pojavlaunch.profiles.ProfileAdapterExtra;
@ -62,9 +60,6 @@ public class mcVersionSpinner extends ExtendedTextView {
new ProfileAdapterExtra(VERSION_SPINNER_PROFILE_CREATE,
R.string.create_profile,
ResourcesCompat.getDrawable(getResources(), R.drawable.ic_add, null)),
new ProfileAdapterExtra(VERSION_SPINNER_PROFILE_CREATE_MODDED,
R.string.create_profile_modded,
ResourcesCompat.getDrawable(getResources(), R.drawable.ic_add_modded, null))
});
@ -91,6 +86,7 @@ public class mcVersionSpinner extends ExtendedTextView {
int endPadding = getContext().getResources().getDimensionPixelOffset(R.dimen._5sdp);
setPaddingRelative(startPadding, 0, endPadding, 0);
setCompoundDrawablePadding(startPadding);
int profileIndex;
String extra_value = (String) ExtraCore.consumeValue(ExtraConstants.REFRESH_VERSION_SPINNER);
if(extra_value != null){
@ -134,12 +130,8 @@ public class mcVersionSpinner extends ExtendedTextView {
ProfileAdapterExtra extra = (ProfileAdapterExtra) item;
switch (extra.id) {
case VERSION_SPINNER_PROFILE_CREATE:
Tools.swapFragment((FragmentActivity) getContext(), ProfileEditorFragment.class,
ProfileEditorFragment.TAG, true, new Bundle(1));
break;
case VERSION_SPINNER_PROFILE_CREATE_MODDED:
Tools.swapFragment((FragmentActivity) getContext(), ModdedProfileSelectFragment.class,
ModdedProfileSelectFragment.TAG, true, null);
Tools.swapFragment((FragmentActivity) getContext(), ProfileTypeSelectFragment.class,
ProfileTypeSelectFragment.TAG, true, null);
break;
}
}

View File

@ -6,19 +6,22 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
public class ModdedProfileSelectFragment extends Fragment {
public static final String TAG = "ModdedProfileSelectFragment";
public ModdedProfileSelectFragment() {
super(R.layout.fragment_mod_profile);
public class ProfileTypeSelectFragment extends Fragment {
public static final String TAG = "ProfileTypeSelectFragment";
public ProfileTypeSelectFragment() {
super(R.layout.fragment_profile_type);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.findViewById(R.id.vanilla_profile).setOnClickListener(v -> Tools.swapFragment(requireActivity(), ProfileEditorFragment.class,
ProfileEditorFragment.TAG, false, new Bundle(1)));
view.findViewById(R.id.modded_profile_fabric).setOnClickListener((v)->
Tools.swapFragment(requireActivity(), FabricInstallFragment.class, FabricInstallFragment.TAG, false, null));
view.findViewById(R.id.modded_profile_forge).setOnClickListener((v)->

View File

@ -7,29 +7,49 @@
android:background="@color/background_app"
android:paddingHorizontal="@dimen/fragment_padding_medium">
<TextView
android:id="@+id/title_textview"
style="@style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding_large"
android:text="@string/fabric_dl_loader_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view"
style="@style/ThickDivider"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/padding_large"
app:layout_constraintTop_toBottomOf="@+id/title_textview" />
<TextView
android:id="@+id/fabric_installer_label_loader_ver"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/fabric_dl_loader_version"
app:layout_constraintBottom_toTopOf="@+id/fabric_installer_loader_ver_spinner"
app:layout_constraintStart_toStartOf="@+id/fabric_installer_loader_ver_spinner"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintStart_toStartOf="@+id/fabric_installer_loader_ver_spinner" />
<Spinner
android:id="@+id/fabric_installer_loader_ver_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding_extra_large"
android:background="@drawable/background_line"
android:minHeight="48dp"
android:paddingVertical="0dp"
android:paddingStart="7dp"
android:paddingEnd="7dp"
android:layout_marginTop="@dimen/_24sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toBottomOf="@id/view" />
<ImageView
android:layout_width="wrap_content"
@ -81,12 +101,15 @@
android:id="@+id/fabric_installer_version_select_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_24sdp"
android:layout_marginTop="@dimen/padding_extra_large"
android:layout_marginEnd="@dimen/padding_medium"
android:background="@drawable/background_line"
android:hint="@string/version_select_hint"
android:paddingHorizontal="@dimen/_12sdp"
android:paddingHorizontal="@dimen/padding_heavy"
app:layout_constraintEnd_toStartOf="@+id/fabric_installer_game_version_change"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fabric_installer_retry_layout" />
@ -103,8 +126,8 @@
android:id="@+id/fabric_installer_start_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="@dimen/padding_heavy"
android:layout_marginBottom="@dimen/padding_heavy"
android:enabled="false"
android:text="@string/fabric_dl_install"
app:layout_constraintBottom_toTopOf="@+id/fabric_installer_progress_bar"

View File

@ -2,17 +2,36 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="@color/background_app"
android:paddingHorizontal="@dimen/fragment_padding_medium">
<TextView
android:id="@+id/title_textview"
style="@style/TextAppearance.AppCompat.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:gravity="center"
android:layout_marginTop="@dimen/padding_large"
android:text="@string/forge_dl_select_version" />
<View
android:id="@+id/view"
style="@style/ThickDivider"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/padding_large"
app:layout_constraintTop_toBottomOf="@+id/title_textview"
android:paddingBottom="@dimen/fragment_padding_medium"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/forge_dl_select_version"
android:paddingTop="@dimen/fragment_padding_medium"
android:paddingBottom="@dimen/fragment_padding_medium"
android:text=""
android:textColor="@color/primary_text" />
<ExpandableListView

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_app"
android:paddingHorizontal="@dimen/fragment_padding_medium"
android:orientation="vertical">
<com.kdt.mcgui.MineButton
android:id="@+id/modded_profile_fabric"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/modloader_dl_install_fabric" />
<com.kdt.mcgui.MineButton
android:id="@+id/modded_profile_forge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/modloader_dl_install_forge" />
</LinearLayout>

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_app"
android:paddingHorizontal="@dimen/fragment_padding_medium"
android:orientation="vertical">
<!-- Vanilla like version -->
<TextView
android:id="@+id/title_textview"
style="@style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/create_profile_vanilla_like_versions"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" />
<View
android:id="@+id/view"
style="@style/ThickDivider"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/padding_large"
app:layout_constraintTop_toBottomOf="@+id/title_textview"
/>
<com.kdt.mcgui.MineButton
android:id="@+id/vanilla_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/padding_large"
android:text="@string/create_profile_vanilla"
android:layout_marginTop="@dimen/padding_large"
app:layout_constraintTop_toBottomOf="@+id/view" />
<!-- Modded versions -->
<TextView
android:id="@+id/title_modded_textview"
style="@style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/create_profile_modded_versions"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline" />
<View
android:id="@+id/view_modded"
style="@style/ThickDivider"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/padding_large"
app:layout_constraintTop_toBottomOf="@+id/title_modded_textview"
/>
<com.kdt.mcgui.MineButton
android:id="@+id/modded_profile_fabric"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/padding_large"
android:layout_marginTop="@dimen/padding_large"
android:text="@string/modloader_dl_install_fabric"
app:layout_constraintTop_toBottomOf="@+id/view_modded"
tools:layout_editor_absoluteX="50dp" />
<com.kdt.mcgui.MineButton
android:id="@+id/modded_profile_forge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/padding_large"
android:layout_marginTop="@dimen/padding_large"
android:text="@string/modloader_dl_install_forge"
app:layout_constraintTop_toBottomOf="@+id/modded_profile_fabric" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.25" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -7,13 +7,13 @@
<dimen name="activity_vertical_margin">16dp</dimen>
<!-- Padding -->
<dimen name="padding_tiny">2dp</dimen>
<dimen name="padding_tiny_plus_one">3dp</dimen>
<dimen name="padding_small">4dp</dimen>
<dimen name="padding_medium">8dp</dimen>
<dimen name="padding_large">16dp</dimen>
<dimen name="padding_extra_large">24dp</dimen>
<dimen name="padding_extra_extra_large">32dp</dimen>
<dimen name="padding_tiny">@dimen/_1sdp</dimen>
<dimen name="padding_small">@dimen/_2sdp</dimen>
<dimen name="padding_medium">@dimen/_4sdp</dimen>
<dimen name="padding_heavy">@dimen/_12sdp</dimen>
<dimen name="padding_large">@dimen/_16sdp</dimen>
<dimen name="padding_extra_large">@dimen/_24sdp</dimen>
<dimen name="padding_extra_extra_large">@dimen/_32sdp</dimen>
<!-- Main Activity components -->
<dimen name="empty_icon_width">60dp</dimen>

View File

@ -385,5 +385,8 @@
<string name="fabric_dl_cant_read_meta">Failed to read Fabric metadata. Please try again later.</string>
<string name="modloader_dl_install_fabric">Create Fabric profile</string>
<string name="modloader_dl_install_forge">Create Forge profile</string>
<string name="create_profile_modded">Create modded profile</string>
<string name="create_profile_vanilla">Create vanilla profile</string>
<string name="create_profile_vanilla_like_versions">Vanilla-like versions</string>
<string name="create_profile_modded_versions">Modded versions</string>
<string name="fabric_dl_loader_title">Select versions</string>
</resources>

View File

@ -12,4 +12,12 @@
<item name="android:textSize">@dimen/_12ssp</item>
</style>
<style name="ThickDivider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/_1sdp</item>
<item name="android:background">?android:attr/listDivider</item>
</style>
</resources>