mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #11092 from t895/view-binding
Android: Use view binding
This commit is contained in:
@@ -4,6 +4,8 @@ android {
|
||||
compileSdkVersion 33
|
||||
ndkVersion "25.0.8775105"
|
||||
|
||||
viewBinding.enabled = true
|
||||
|
||||
compileOptions {
|
||||
// Flag to enable support for the new language APIs
|
||||
coreLibraryDesugaringEnabled true
|
||||
|
||||
+8
-16
@@ -5,17 +5,12 @@ package org.dolphinemu.dolphinemu.activities;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ActivityConvertBinding;
|
||||
import org.dolphinemu.dolphinemu.fragments.ConvertFragment;
|
||||
import org.dolphinemu.dolphinemu.utils.InsetsHelper;
|
||||
import org.dolphinemu.dolphinemu.utils.ThemeHelper;
|
||||
@@ -38,7 +33,8 @@ public class ConvertActivity extends AppCompatActivity
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_convert);
|
||||
ActivityConvertBinding binding = ActivityConvertBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
|
||||
@@ -52,17 +48,13 @@ public class ConvertActivity extends AppCompatActivity
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.fragment_convert, fragment).commit();
|
||||
}
|
||||
|
||||
MaterialToolbar tb = findViewById(R.id.toolbar_convert);
|
||||
CollapsingToolbarLayout ctb = findViewById(R.id.toolbar_convert_layout);
|
||||
ctb.setTitle(getString(R.string.convert_convert));
|
||||
setSupportActionBar(tb);
|
||||
binding.toolbarConvertLayout.setTitle(getString(R.string.convert_convert));
|
||||
setSupportActionBar(binding.toolbarConvert);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
AppBarLayout appBarLayout = findViewById(R.id.appbar_convert);
|
||||
NestedScrollView scrollView = findViewById(R.id.scroll_view_convert);
|
||||
View workaroundView = findViewById(R.id.workaround_view);
|
||||
InsetsHelper.setUpAppBarWithScrollView(this, appBarLayout, scrollView, workaroundView);
|
||||
ThemeHelper.enableScrollTint(this, tb, appBarLayout);
|
||||
InsetsHelper.setUpAppBarWithScrollView(this, binding.appbarConvert, binding.scrollViewConvert,
|
||||
binding.workaroundView);
|
||||
ThemeHelper.enableScrollTint(this, binding.toolbarConvert, binding.appbarConvert);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+23
-24
@@ -12,7 +12,6 @@ import android.os.Bundle;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
@@ -33,6 +32,9 @@ import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ActivityEmulationBinding;
|
||||
import org.dolphinemu.dolphinemu.databinding.DialogInputAdjustBinding;
|
||||
import org.dolphinemu.dolphinemu.databinding.DialogIrSensitivityBinding;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
@@ -62,7 +64,6 @@ import java.util.List;
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.slider.LabelFormatter;
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
public final class EmulationActivity extends AppCompatActivity implements ThemeProvider
|
||||
@@ -338,7 +339,8 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
|
||||
Rumble.initRumble(this);
|
||||
|
||||
setContentView(R.layout.activity_emulation);
|
||||
ActivityEmulationBinding binding = ActivityEmulationBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
// Find or create the EmulationFragment
|
||||
mEmulationFragment = (EmulationFragment) getSupportFragmentManager()
|
||||
@@ -905,11 +907,10 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
|
||||
private void adjustScale()
|
||||
{
|
||||
LayoutInflater inflater = LayoutInflater.from(this);
|
||||
View view = inflater.inflate(R.layout.dialog_input_adjust, null);
|
||||
DialogInputAdjustBinding dialogBinding = DialogInputAdjustBinding.inflate(getLayoutInflater());
|
||||
|
||||
final Slider scaleSlider = view.findViewById(R.id.input_scale_slider);
|
||||
final TextView scaleValue = view.findViewById(R.id.input_scale_value);
|
||||
final Slider scaleSlider = dialogBinding.inputScaleSlider;
|
||||
final TextView scaleValue = dialogBinding.inputScaleValue;
|
||||
scaleSlider.setValueTo(150);
|
||||
scaleSlider.setValue(IntSetting.MAIN_CONTROL_SCALE.getInt(mSettings));
|
||||
scaleSlider.setStepSize(1);
|
||||
@@ -918,8 +919,8 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
scaleValue.setText(((int) scaleSlider.getValue() + 50) + "%");
|
||||
|
||||
// alpha
|
||||
final Slider sliderOpacity = view.findViewById(R.id.input_opacity_slider);
|
||||
final TextView valueOpacity = view.findViewById(R.id.input_opacity_value);
|
||||
final Slider sliderOpacity = dialogBinding.inputOpacitySlider;
|
||||
final TextView valueOpacity = dialogBinding.inputOpacityValue;
|
||||
sliderOpacity.setValueTo(100);
|
||||
sliderOpacity.setValue(IntSetting.MAIN_CONTROL_OPACITY.getInt(mSettings));
|
||||
sliderOpacity.setStepSize(1);
|
||||
@@ -927,10 +928,9 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
(slider, progress, fromUser) -> valueOpacity.setText(((int) progress) + "%"));
|
||||
valueOpacity.setText(((int) sliderOpacity.getValue()) + "%");
|
||||
|
||||
|
||||
new MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.emulation_control_adjustments)
|
||||
.setView(view)
|
||||
.setView(dialogBinding.getRoot())
|
||||
.setPositiveButton(R.string.ok, (dialog, which) ->
|
||||
{
|
||||
IntSetting.MAIN_CONTROL_SCALE.setInt(mSettings, (int) scaleSlider.getValue());
|
||||
@@ -1008,12 +1008,12 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
|
||||
int ir_pitch = ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH, 20);
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(this);
|
||||
View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null);
|
||||
DialogIrSensitivityBinding dialogBinding =
|
||||
DialogIrSensitivityBinding.inflate(getLayoutInflater());
|
||||
|
||||
TextView text_slider_value_pitch = view.findViewById(R.id.text_ir_pitch);
|
||||
TextView units = view.findViewById(R.id.text_ir_pitch_units);
|
||||
Slider slider_pitch = view.findViewById(R.id.slider_pitch);
|
||||
TextView text_slider_value_pitch = dialogBinding.textIrPitch;
|
||||
TextView units = dialogBinding.textIrPitchUnits;
|
||||
Slider slider_pitch = dialogBinding.sliderPitch;
|
||||
|
||||
text_slider_value_pitch.setText(String.valueOf(ir_pitch));
|
||||
units.setText(getString(R.string.pitch));
|
||||
@@ -1026,9 +1026,9 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
|
||||
int ir_yaw = ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW, 25);
|
||||
|
||||
TextView text_slider_value_yaw = view.findViewById(R.id.text_ir_yaw);
|
||||
TextView units_yaw = view.findViewById(R.id.text_ir_yaw_units);
|
||||
Slider seekbar_yaw = view.findViewById(R.id.slider_width);
|
||||
TextView text_slider_value_yaw = dialogBinding.textIrYaw;
|
||||
TextView units_yaw = dialogBinding.textIrYawUnits;
|
||||
Slider seekbar_yaw = dialogBinding.sliderYaw;
|
||||
|
||||
text_slider_value_yaw.setText(String.valueOf(ir_yaw));
|
||||
units_yaw.setText(getString(R.string.yaw));
|
||||
@@ -1038,13 +1038,12 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
seekbar_yaw.addOnChangeListener((slider, progress, fromUser) -> text_slider_value_yaw.setText(
|
||||
String.valueOf((int) progress)));
|
||||
|
||||
|
||||
int ir_vertical_offset =
|
||||
ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET, 10);
|
||||
|
||||
TextView text_slider_value_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset);
|
||||
TextView units_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset_units);
|
||||
Slider seekbar_vertical_offset = view.findViewById(R.id.slider_vertical_offset);
|
||||
TextView text_slider_value_vertical_offset = dialogBinding.textIrVerticalOffset;
|
||||
TextView units_vertical_offset = dialogBinding.textIrVerticalOffsetUnits;
|
||||
Slider seekbar_vertical_offset = dialogBinding.sliderVerticalOffset;
|
||||
|
||||
text_slider_value_vertical_offset.setText(String.valueOf(ir_vertical_offset));
|
||||
units_vertical_offset.setText(getString(R.string.vertical_offset));
|
||||
@@ -1057,7 +1056,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
|
||||
new MaterialAlertDialogBuilder(this)
|
||||
.setTitle(getString(R.string.emulation_ir_sensitivity))
|
||||
.setView(view)
|
||||
.setView(dialogBinding.getRoot())
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i) ->
|
||||
{
|
||||
ini.setString(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH,
|
||||
|
||||
+14
-27
@@ -10,19 +10,15 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ActivityUserDataBinding;
|
||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
||||
import org.dolphinemu.dolphinemu.utils.InsetsHelper;
|
||||
import org.dolphinemu.dolphinemu.utils.Log;
|
||||
@@ -61,45 +57,36 @@ public class UserDataActivity extends AppCompatActivity
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_user_data);
|
||||
ActivityUserDataBinding binding = ActivityUserDataBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
|
||||
TextView textType = findViewById(R.id.text_type);
|
||||
TextView textPath = findViewById(R.id.text_path);
|
||||
TextView textAndroid11 = findViewById(R.id.text_android_11);
|
||||
Button buttonOpenSystemFileManager = findViewById(R.id.button_open_system_file_manager);
|
||||
Button buttonImportUserData = findViewById(R.id.button_import_user_data);
|
||||
Button buttonExportUserData = findViewById(R.id.button_export_user_data);
|
||||
|
||||
boolean android_10 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
|
||||
boolean android_11 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;
|
||||
boolean legacy = DirectoryInitialization.isUsingLegacyUserDirectory();
|
||||
|
||||
int user_data_new_location = android_10 ?
|
||||
R.string.user_data_new_location_android_10 : R.string.user_data_new_location;
|
||||
textType.setText(legacy ? R.string.user_data_old_location : user_data_new_location);
|
||||
binding.textType.setText(legacy ? R.string.user_data_old_location : user_data_new_location);
|
||||
|
||||
textPath.setText(DirectoryInitialization.getUserDirectory());
|
||||
binding.textPath.setText(DirectoryInitialization.getUserDirectory());
|
||||
|
||||
textAndroid11.setVisibility(android_11 && !legacy ? View.VISIBLE : View.GONE);
|
||||
binding.textAndroid11.setVisibility(android_11 && !legacy ? View.VISIBLE : View.GONE);
|
||||
|
||||
buttonOpenSystemFileManager.setVisibility(android_11 ? View.VISIBLE : View.GONE);
|
||||
buttonOpenSystemFileManager.setOnClickListener(view -> openFileManager());
|
||||
binding.buttonOpenSystemFileManager.setVisibility(android_11 ? View.VISIBLE : View.GONE);
|
||||
binding.buttonOpenSystemFileManager.setOnClickListener(view -> openFileManager());
|
||||
|
||||
buttonImportUserData.setOnClickListener(view -> importUserData());
|
||||
binding.buttonImportUserData.setOnClickListener(view -> importUserData());
|
||||
|
||||
buttonExportUserData.setOnClickListener(view -> exportUserData());
|
||||
binding.buttonExportUserData.setOnClickListener(view -> exportUserData());
|
||||
|
||||
MaterialToolbar tb = findViewById(R.id.toolbar_user_data);
|
||||
setSupportActionBar(tb);
|
||||
setSupportActionBar(binding.toolbarUserData);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
AppBarLayout appBarLayout = findViewById(R.id.appbar_user_data);
|
||||
NestedScrollView scrollView = findViewById(R.id.scroll_view_user_data);
|
||||
View workaroundView = findViewById(R.id.workaround_view);
|
||||
InsetsHelper.setUpAppBarWithScrollView(this, appBarLayout, scrollView, workaroundView);
|
||||
ThemeHelper.enableScrollTint(this, tb, appBarLayout);
|
||||
InsetsHelper.setUpAppBarWithScrollView(this, binding.appbarUserData,
|
||||
binding.scrollViewUserData, binding.workaroundView);
|
||||
ThemeHelper.enableScrollTint(this, binding.toolbarUserData, binding.appbarUserData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+23
-12
@@ -3,7 +3,6 @@
|
||||
package org.dolphinemu.dolphinemu.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -14,16 +13,16 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
|
||||
import org.dolphinemu.dolphinemu.databinding.CardGameBinding;
|
||||
import org.dolphinemu.dolphinemu.dialogs.GamePropertiesDialog;
|
||||
import org.dolphinemu.dolphinemu.model.GameFile;
|
||||
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
|
||||
import org.dolphinemu.dolphinemu.utils.GlideUtils;
|
||||
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> implements
|
||||
public final class GameAdapter extends RecyclerView.Adapter<GameAdapter.GameViewHolder> implements
|
||||
View.OnClickListener,
|
||||
View.OnLongClickListener
|
||||
{
|
||||
@@ -45,18 +44,17 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
|
||||
* @param viewType Not used here, but useful when more than one type of child will be used in the RecyclerView.
|
||||
* @return The created ViewHolder with references to all the child view's members.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public GameViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
|
||||
{
|
||||
// Create a new view.
|
||||
View gameCard = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.card_game, parent, false);
|
||||
CardGameBinding binding = CardGameBinding.inflate(LayoutInflater.from(parent.getContext()));
|
||||
|
||||
gameCard.setOnClickListener(this);
|
||||
gameCard.setOnLongClickListener(this);
|
||||
binding.getRoot().setOnClickListener(this);
|
||||
binding.getRoot().setOnLongClickListener(this);
|
||||
|
||||
// Use that view to create a ViewHolder.
|
||||
return new GameViewHolder(gameCard);
|
||||
return new GameViewHolder(binding);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,21 +70,34 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
|
||||
{
|
||||
Context context = holder.itemView.getContext();
|
||||
GameFile gameFile = mGameFiles.get(position);
|
||||
GlideUtils.loadGameCover(holder, holder.imageScreenshot, gameFile);
|
||||
GlideUtils.loadGameCover(holder, holder.binding.imageGameScreen, gameFile);
|
||||
|
||||
if (GameFileCacheManager.findSecondDisc(gameFile) != null)
|
||||
{
|
||||
holder.textGameCaption
|
||||
holder.binding.textGameCaption
|
||||
.setText(context.getString(R.string.disc_number, gameFile.getDiscNumber() + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.textGameCaption.setText(gameFile.getCompany());
|
||||
holder.binding.textGameCaption.setText(gameFile.getCompany());
|
||||
}
|
||||
|
||||
holder.gameFile = gameFile;
|
||||
}
|
||||
|
||||
public static class GameViewHolder extends RecyclerView.ViewHolder
|
||||
{
|
||||
public GameFile gameFile;
|
||||
public CardGameBinding binding;
|
||||
|
||||
public GameViewHolder(@NonNull CardGameBinding binding)
|
||||
{
|
||||
super(binding.getRoot());
|
||||
binding.getRoot().setTag(this);
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the LayoutManager to find out how much data we have.
|
||||
*
|
||||
|
||||
+25
-44
@@ -5,16 +5,15 @@ package org.dolphinemu.dolphinemu.dialogs;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.DialogGameDetailsBinding;
|
||||
import org.dolphinemu.dolphinemu.model.GameFile;
|
||||
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
|
||||
import org.dolphinemu.dolphinemu.utils.GlideUtils;
|
||||
@@ -34,90 +33,72 @@ public final class GameDetailsDialog extends DialogFragment
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState)
|
||||
{
|
||||
GameFile gameFile = GameFileCacheManager.addOrGet(getArguments().getString(ARG_GAME_PATH));
|
||||
|
||||
ViewGroup contents = (ViewGroup) getActivity().getLayoutInflater()
|
||||
.inflate(R.layout.dialog_game_details, null);
|
||||
|
||||
ImageView banner = contents.findViewById(R.id.banner);
|
||||
|
||||
TextView textTitle = contents.findViewById(R.id.text_game_title);
|
||||
TextView textDescription = contents.findViewById(R.id.text_description);
|
||||
|
||||
TextView textCountry = contents.findViewById(R.id.text_country);
|
||||
TextView textCompany = contents.findViewById(R.id.text_company);
|
||||
TextView textGameId = contents.findViewById(R.id.text_game_id);
|
||||
TextView textRevision = contents.findViewById(R.id.text_revision);
|
||||
|
||||
TextView textFileFormat = contents.findViewById(R.id.text_file_format);
|
||||
TextView textCompression = contents.findViewById(R.id.text_compression);
|
||||
TextView textBlockSize = contents.findViewById(R.id.text_block_size);
|
||||
|
||||
TextView labelFileFormat = contents.findViewById(R.id.label_file_format);
|
||||
TextView labelCompression = contents.findViewById(R.id.label_compression);
|
||||
TextView labelBlockSize = contents.findViewById(R.id.label_block_size);
|
||||
DialogGameDetailsBinding binding = DialogGameDetailsBinding.inflate(getLayoutInflater());
|
||||
|
||||
String country = getResources().getStringArray(R.array.countryNames)[gameFile.getCountry()];
|
||||
String description = gameFile.getDescription();
|
||||
String fileSize = NativeLibrary.FormatSize(gameFile.getFileSize(), 2);
|
||||
|
||||
textTitle.setText(gameFile.getTitle());
|
||||
textDescription.setText(gameFile.getDescription());
|
||||
binding.textGameTitle.setText(gameFile.getTitle());
|
||||
binding.textDescription.setText(gameFile.getDescription());
|
||||
if (description.isEmpty())
|
||||
{
|
||||
textDescription.setVisibility(View.GONE);
|
||||
binding.textDescription.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
textCountry.setText(country);
|
||||
textCompany.setText(gameFile.getCompany());
|
||||
textGameId.setText(gameFile.getGameId());
|
||||
textRevision.setText(String.valueOf(gameFile.getRevision()));
|
||||
binding.textCountry.setText(country);
|
||||
binding.textCompany.setText(gameFile.getCompany());
|
||||
binding.textGameId.setText(gameFile.getGameId());
|
||||
binding.textRevision.setText(String.valueOf(gameFile.getRevision()));
|
||||
|
||||
if (!gameFile.shouldShowFileFormatDetails())
|
||||
{
|
||||
labelFileFormat.setText(R.string.game_details_file_size);
|
||||
textFileFormat.setText(fileSize);
|
||||
binding.labelFileFormat.setText(R.string.game_details_file_size);
|
||||
binding.textFileFormat.setText(fileSize);
|
||||
|
||||
labelCompression.setVisibility(View.GONE);
|
||||
textCompression.setVisibility(View.GONE);
|
||||
labelBlockSize.setVisibility(View.GONE);
|
||||
textBlockSize.setVisibility(View.GONE);
|
||||
binding.labelCompression.setVisibility(View.GONE);
|
||||
binding.textCompression.setVisibility(View.GONE);
|
||||
binding.labelBlockSize.setVisibility(View.GONE);
|
||||
binding.textBlockSize.setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
long blockSize = gameFile.getBlockSize();
|
||||
String compression = gameFile.getCompressionMethod();
|
||||
|
||||
textFileFormat.setText(getResources().getString(R.string.game_details_size_and_format,
|
||||
binding.textFileFormat.setText(getResources().getString(R.string.game_details_size_and_format,
|
||||
gameFile.getFileFormatName(), fileSize));
|
||||
|
||||
if (compression.isEmpty())
|
||||
{
|
||||
textCompression.setText(R.string.game_details_no_compression);
|
||||
binding.textCompression.setText(R.string.game_details_no_compression);
|
||||
}
|
||||
else
|
||||
{
|
||||
textCompression.setText(gameFile.getCompressionMethod());
|
||||
binding.textCompression.setText(gameFile.getCompressionMethod());
|
||||
}
|
||||
|
||||
if (blockSize > 0)
|
||||
{
|
||||
textBlockSize.setText(NativeLibrary.FormatSize(blockSize, 0));
|
||||
binding.textBlockSize.setText(NativeLibrary.FormatSize(blockSize, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
labelBlockSize.setVisibility(View.GONE);
|
||||
textBlockSize.setVisibility(View.GONE);
|
||||
binding.labelBlockSize.setVisibility(View.GONE);
|
||||
binding.textBlockSize.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
GlideUtils.loadGameBanner(banner, gameFile);
|
||||
GlideUtils.loadGameBanner(binding.banner, gameFile);
|
||||
|
||||
return new MaterialAlertDialogBuilder(requireActivity())
|
||||
.setView(contents)
|
||||
.setView(binding.getRoot())
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemSubmenuBinding;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.ARCheat;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.CheatsViewModel;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.GeckoCheat;
|
||||
@@ -23,13 +24,13 @@ public class ActionViewHolder extends CheatItemViewHolder implements View.OnClic
|
||||
private int mString;
|
||||
private int mPosition;
|
||||
|
||||
public ActionViewHolder(@NonNull View itemView)
|
||||
public ActionViewHolder(@NonNull ListItemSubmenuBinding binding)
|
||||
{
|
||||
super(itemView);
|
||||
super(binding.getRoot());
|
||||
|
||||
mName = itemView.findViewById(R.id.text_setting_name);
|
||||
mName = binding.textSettingName;
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
binding.getRoot().setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void bind(CheatsActivity activity, CheatItem item, int position)
|
||||
|
||||
+52
-73
@@ -6,8 +6,6 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -15,78 +13,57 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.FragmentCheatDetailsBinding;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.Cheat;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.CheatsViewModel;
|
||||
|
||||
public class CheatDetailsFragment extends Fragment
|
||||
{
|
||||
private View mRoot;
|
||||
private ScrollView mScrollView;
|
||||
private TextInputLayout mEditNameLayout;
|
||||
private TextInputEditText mEditName;
|
||||
private TextInputLayout mEditCreatorLayout;
|
||||
private TextInputEditText mEditCreator;
|
||||
private TextInputLayout mEditNotesLayout;
|
||||
private TextInputEditText mEditNotes;
|
||||
private TextInputLayout mEditCodeLayout;
|
||||
private TextInputEditText mEditCode;
|
||||
private Button mButtonDelete;
|
||||
private Button mButtonEdit;
|
||||
private Button mButtonCancel;
|
||||
private Button mButtonOk;
|
||||
|
||||
private CheatsViewModel mViewModel;
|
||||
private Cheat mCheat;
|
||||
|
||||
private FragmentCheatDetailsBinding mBinding;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
return inflater.inflate(R.layout.fragment_cheat_details, container, false);
|
||||
mBinding = FragmentCheatDetailsBinding.inflate(inflater, container, false);
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
mRoot = view.findViewById(R.id.root);
|
||||
mScrollView = view.findViewById(R.id.scroll_view);
|
||||
mEditNameLayout = view.findViewById(R.id.edit_name);
|
||||
mEditName = view.findViewById(R.id.edit_name_input);
|
||||
mEditCreatorLayout = view.findViewById(R.id.edit_creator);
|
||||
mEditCreator = view.findViewById(R.id.edit_creator_input);
|
||||
mEditNotesLayout = view.findViewById(R.id.edit_notes);
|
||||
mEditNotes = view.findViewById(R.id.edit_notes_input);
|
||||
mEditCodeLayout = view.findViewById(R.id.edit_code);
|
||||
mEditCode = view.findViewById(R.id.edit_code_input);
|
||||
mButtonDelete = view.findViewById(R.id.button_delete);
|
||||
mButtonEdit = view.findViewById(R.id.button_edit);
|
||||
mButtonCancel = view.findViewById(R.id.button_cancel);
|
||||
mButtonOk = view.findViewById(R.id.button_ok);
|
||||
|
||||
CheatsActivity activity = (CheatsActivity) requireActivity();
|
||||
mViewModel = new ViewModelProvider(activity).get(CheatsViewModel.class);
|
||||
|
||||
mViewModel.getSelectedCheat().observe(getViewLifecycleOwner(), this::onSelectedCheatUpdated);
|
||||
mViewModel.getIsEditing().observe(getViewLifecycleOwner(), this::onIsEditingUpdated);
|
||||
|
||||
mButtonDelete.setOnClickListener(this::onDeleteClicked);
|
||||
mButtonEdit.setOnClickListener(this::onEditClicked);
|
||||
mButtonCancel.setOnClickListener(this::onCancelClicked);
|
||||
mButtonOk.setOnClickListener(this::onOkClicked);
|
||||
mBinding.buttonDelete.setOnClickListener(this::onDeleteClicked);
|
||||
mBinding.buttonEdit.setOnClickListener(this::onEditClicked);
|
||||
mBinding.buttonCancel.setOnClickListener(this::onCancelClicked);
|
||||
mBinding.buttonOk.setOnClickListener(this::onOkClicked);
|
||||
|
||||
CheatsActivity.setOnFocusChangeListenerRecursively(view,
|
||||
(v, hasFocus) -> activity.onDetailsViewFocusChange(hasFocus));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView()
|
||||
{
|
||||
super.onDestroyView();
|
||||
mBinding = null;
|
||||
}
|
||||
|
||||
private void clearEditErrors()
|
||||
{
|
||||
mEditNameLayout.setError(null);
|
||||
mEditCodeLayout.setError(null);
|
||||
mBinding.editName.setError(null);
|
||||
mBinding.editCode.setError(null);
|
||||
}
|
||||
|
||||
private void onDeleteClicked(View view)
|
||||
@@ -101,22 +78,24 @@ public class CheatDetailsFragment extends Fragment
|
||||
private void onEditClicked(View view)
|
||||
{
|
||||
mViewModel.setIsEditing(true);
|
||||
mButtonOk.requestFocus();
|
||||
mBinding.buttonOk.requestFocus();
|
||||
}
|
||||
|
||||
private void onCancelClicked(View view)
|
||||
{
|
||||
mViewModel.setIsEditing(false);
|
||||
onSelectedCheatUpdated(mCheat);
|
||||
mButtonDelete.requestFocus();
|
||||
mBinding.buttonDelete.requestFocus();
|
||||
}
|
||||
|
||||
private void onOkClicked(View view)
|
||||
{
|
||||
clearEditErrors();
|
||||
|
||||
int result = mCheat.trySet(mEditName.getText().toString(), mEditCreator.getText().toString(),
|
||||
mEditNotes.getText().toString(), mEditCode.getText().toString());
|
||||
int result = mCheat.trySet(mBinding.editNameInput.getText().toString(),
|
||||
mBinding.editCreatorInput.getText().toString(),
|
||||
mBinding.editNotesInput.getText().toString(),
|
||||
mBinding.editCodeInput.getText().toString());
|
||||
|
||||
switch (result)
|
||||
{
|
||||
@@ -131,23 +110,23 @@ public class CheatDetailsFragment extends Fragment
|
||||
mViewModel.notifySelectedCheatChanged();
|
||||
mViewModel.setIsEditing(false);
|
||||
}
|
||||
mButtonEdit.requestFocus();
|
||||
mBinding.buttonEdit.requestFocus();
|
||||
break;
|
||||
case Cheat.TRY_SET_FAIL_NO_NAME:
|
||||
mEditNameLayout.setError(getString(R.string.cheats_error_no_name));
|
||||
mScrollView.smoothScrollTo(0, mEditName.getTop());
|
||||
mBinding.editName.setError(getString(R.string.cheats_error_no_name));
|
||||
mBinding.scrollView.smoothScrollTo(0, mBinding.editNameInput.getTop());
|
||||
break;
|
||||
case Cheat.TRY_SET_FAIL_NO_CODE_LINES:
|
||||
mEditCodeLayout.setError(getString(R.string.cheats_error_no_code_lines));
|
||||
mScrollView.smoothScrollTo(0, mEditCode.getBottom());
|
||||
mBinding.editCode.setError(getString(R.string.cheats_error_no_code_lines));
|
||||
mBinding.scrollView.smoothScrollTo(0, mBinding.editCodeInput.getBottom());
|
||||
break;
|
||||
case Cheat.TRY_SET_FAIL_CODE_MIXED_ENCRYPTION:
|
||||
mEditCodeLayout.setError(getString(R.string.cheats_error_mixed_encryption));
|
||||
mScrollView.smoothScrollTo(0, mEditCode.getBottom());
|
||||
mBinding.editCode.setError(getString(R.string.cheats_error_mixed_encryption));
|
||||
mBinding.scrollView.smoothScrollTo(0, mBinding.editCodeInput.getBottom());
|
||||
break;
|
||||
default:
|
||||
mEditCodeLayout.setError(getString(R.string.cheats_error_on_line, result));
|
||||
mScrollView.smoothScrollTo(0, mEditCode.getBottom());
|
||||
mBinding.editCode.setError(getString(R.string.cheats_error_on_line, result));
|
||||
mBinding.scrollView.smoothScrollTo(0, mBinding.editCodeInput.getBottom());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -156,18 +135,18 @@ public class CheatDetailsFragment extends Fragment
|
||||
{
|
||||
clearEditErrors();
|
||||
|
||||
mRoot.setVisibility(cheat == null ? View.GONE : View.VISIBLE);
|
||||
mBinding.root.setVisibility(cheat == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
int creatorVisibility = cheat != null && cheat.supportsCreator() ? View.VISIBLE : View.GONE;
|
||||
int notesVisibility = cheat != null && cheat.supportsNotes() ? View.VISIBLE : View.GONE;
|
||||
int codeVisibility = cheat != null && cheat.supportsCode() ? View.VISIBLE : View.GONE;
|
||||
mEditCreatorLayout.setVisibility(creatorVisibility);
|
||||
mEditNotesLayout.setVisibility(notesVisibility);
|
||||
mEditCodeLayout.setVisibility(codeVisibility);
|
||||
mBinding.editCreator.setVisibility(creatorVisibility);
|
||||
mBinding.editNotes.setVisibility(notesVisibility);
|
||||
mBinding.editCode.setVisibility(codeVisibility);
|
||||
|
||||
boolean userDefined = cheat != null && cheat.getUserDefined();
|
||||
mButtonDelete.setEnabled(userDefined);
|
||||
mButtonEdit.setEnabled(userDefined);
|
||||
mBinding.buttonDelete.setEnabled(userDefined);
|
||||
mBinding.buttonEdit.setEnabled(userDefined);
|
||||
|
||||
// If the fragment was recreated while editing a cheat, it's vital that we
|
||||
// don't repopulate the fields, otherwise the user's changes will be lost
|
||||
@@ -175,10 +154,10 @@ public class CheatDetailsFragment extends Fragment
|
||||
|
||||
if (!isEditing && cheat != null)
|
||||
{
|
||||
mEditName.setText(cheat.getName());
|
||||
mEditCreator.setText(cheat.getCreator());
|
||||
mEditNotes.setText(cheat.getNotes());
|
||||
mEditCode.setText(cheat.getCode());
|
||||
mBinding.editNameInput.setText(cheat.getName());
|
||||
mBinding.editCreatorInput.setText(cheat.getCreator());
|
||||
mBinding.editNotesInput.setText(cheat.getNotes());
|
||||
mBinding.editCodeInput.setText(cheat.getCode());
|
||||
}
|
||||
|
||||
mCheat = cheat;
|
||||
@@ -186,14 +165,14 @@ public class CheatDetailsFragment extends Fragment
|
||||
|
||||
private void onIsEditingUpdated(boolean isEditing)
|
||||
{
|
||||
mEditName.setEnabled(isEditing);
|
||||
mEditCreator.setEnabled(isEditing);
|
||||
mEditNotes.setEnabled(isEditing);
|
||||
mEditCode.setEnabled(isEditing);
|
||||
mBinding.editNameInput.setEnabled(isEditing);
|
||||
mBinding.editCreatorInput.setEnabled(isEditing);
|
||||
mBinding.editNotesInput.setEnabled(isEditing);
|
||||
mBinding.editCodeInput.setEnabled(isEditing);
|
||||
|
||||
mButtonDelete.setVisibility(isEditing ? View.GONE : View.VISIBLE);
|
||||
mButtonEdit.setVisibility(isEditing ? View.GONE : View.VISIBLE);
|
||||
mButtonCancel.setVisibility(isEditing ? View.VISIBLE : View.GONE);
|
||||
mButtonOk.setVisibility(isEditing ? View.VISIBLE : View.GONE);
|
||||
mBinding.buttonDelete.setVisibility(isEditing ? View.GONE : View.VISIBLE);
|
||||
mBinding.buttonEdit.setVisibility(isEditing ? View.GONE : View.VISIBLE);
|
||||
mBinding.buttonCancel.setVisibility(isEditing ? View.VISIBLE : View.GONE);
|
||||
mBinding.buttonOk.setVisibility(isEditing ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
+17
-10
@@ -12,40 +12,47 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.divider.MaterialDividerItemDecoration;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.FragmentCheatListBinding;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.CheatsViewModel;
|
||||
import org.dolphinemu.dolphinemu.utils.InsetsHelper;
|
||||
|
||||
public class CheatListFragment extends Fragment
|
||||
{
|
||||
private FragmentCheatListBinding mBinding;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
return inflater.inflate(R.layout.fragment_cheat_list, container, false);
|
||||
mBinding = FragmentCheatListBinding.inflate(inflater, container, false);
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
RecyclerView recyclerView = view.findViewById(R.id.cheat_list);
|
||||
|
||||
CheatsActivity activity = (CheatsActivity) requireActivity();
|
||||
CheatsViewModel viewModel = new ViewModelProvider(activity).get(CheatsViewModel.class);
|
||||
|
||||
recyclerView.setAdapter(new CheatsAdapter(activity, viewModel));
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(activity));
|
||||
mBinding.cheatList.setAdapter(new CheatsAdapter(activity, viewModel));
|
||||
mBinding.cheatList.setLayoutManager(new LinearLayoutManager(activity));
|
||||
|
||||
MaterialDividerItemDecoration divider =
|
||||
new MaterialDividerItemDecoration(requireActivity(), LinearLayoutManager.VERTICAL);
|
||||
divider.setLastItemDecorated(false);
|
||||
recyclerView.addItemDecoration(divider);
|
||||
mBinding.cheatList.addItemDecoration(divider);
|
||||
|
||||
InsetsHelper.setUpList(getContext(), recyclerView);
|
||||
InsetsHelper.setUpList(getContext(), mBinding.cheatList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView()
|
||||
{
|
||||
super.onDestroyView();
|
||||
mBinding = null;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-15
@@ -10,43 +10,38 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemCheatBinding;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.Cheat;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.CheatsViewModel;
|
||||
|
||||
public class CheatViewHolder extends CheatItemViewHolder
|
||||
implements View.OnClickListener, CompoundButton.OnCheckedChangeListener
|
||||
{
|
||||
private final View mRoot;
|
||||
private final TextView mName;
|
||||
private final CheckBox mCheckbox;
|
||||
private final ListItemCheatBinding mBinding;
|
||||
|
||||
private CheatsViewModel mViewModel;
|
||||
private Cheat mCheat;
|
||||
private int mPosition;
|
||||
|
||||
public CheatViewHolder(@NonNull View itemView)
|
||||
public CheatViewHolder(@NonNull ListItemCheatBinding binding)
|
||||
{
|
||||
super(itemView);
|
||||
|
||||
mRoot = itemView.findViewById(R.id.root);
|
||||
mName = itemView.findViewById(R.id.text_name);
|
||||
mCheckbox = itemView.findViewById(R.id.checkbox);
|
||||
super(binding.getRoot());
|
||||
mBinding = binding;
|
||||
}
|
||||
|
||||
public void bind(CheatsActivity activity, CheatItem item, int position)
|
||||
{
|
||||
mCheckbox.setOnCheckedChangeListener(null);
|
||||
mBinding.checkbox.setOnCheckedChangeListener(null);
|
||||
|
||||
mViewModel = new ViewModelProvider(activity).get(CheatsViewModel.class);
|
||||
mCheat = item.getCheat();
|
||||
mPosition = position;
|
||||
|
||||
mName.setText(mCheat.getName());
|
||||
mCheckbox.setChecked(mCheat.getEnabled());
|
||||
mBinding.textName.setText(mCheat.getName());
|
||||
mBinding.checkbox.setChecked(mCheat.getEnabled());
|
||||
|
||||
mRoot.setOnClickListener(this);
|
||||
mCheckbox.setOnCheckedChangeListener(this);
|
||||
mBinding.root.setOnClickListener(this);
|
||||
mBinding.checkbox.setOnCheckedChangeListener(this);
|
||||
}
|
||||
|
||||
public void onClick(View root)
|
||||
|
||||
+24
-31
@@ -19,12 +19,11 @@ import androidx.core.view.WindowCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.slidingpanelayout.widget.SlidingPaneLayout;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ActivityCheatsBinding;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.Cheat;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.CheatsViewModel;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.GeckoCheat;
|
||||
@@ -48,13 +47,11 @@ public class CheatsActivity extends AppCompatActivity
|
||||
private boolean mIsWii;
|
||||
private CheatsViewModel mViewModel;
|
||||
|
||||
private SlidingPaneLayout mSlidingPaneLayout;
|
||||
private View mCheatList;
|
||||
private View mCheatDetails;
|
||||
|
||||
private View mCheatListLastFocus;
|
||||
private View mCheatDetailsLastFocus;
|
||||
|
||||
private ActivityCheatsBinding mBinding;
|
||||
|
||||
public static void launch(Context context, String gameId, String gameTdbId, int revision,
|
||||
boolean isWii)
|
||||
{
|
||||
@@ -86,38 +83,34 @@ public class CheatsActivity extends AppCompatActivity
|
||||
mViewModel = new ViewModelProvider(this).get(CheatsViewModel.class);
|
||||
mViewModel.load(mGameId, mRevision);
|
||||
|
||||
setContentView(R.layout.activity_cheats);
|
||||
mBinding = ActivityCheatsBinding.inflate(getLayoutInflater());
|
||||
setContentView(mBinding.getRoot());
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
|
||||
mSlidingPaneLayout = findViewById(R.id.sliding_pane_layout);
|
||||
mCheatList = findViewById(R.id.cheat_list);
|
||||
mCheatDetails = findViewById(R.id.cheat_details);
|
||||
mCheatListLastFocus = mBinding.cheatList;
|
||||
mCheatDetailsLastFocus = mBinding.cheatDetails;
|
||||
|
||||
mCheatListLastFocus = mCheatList;
|
||||
mCheatDetailsLastFocus = mCheatDetails;
|
||||
|
||||
mSlidingPaneLayout.addPanelSlideListener(this);
|
||||
mBinding.slidingPaneLayout.addPanelSlideListener(this);
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this,
|
||||
new TwoPaneOnBackPressedCallback(mSlidingPaneLayout));
|
||||
new TwoPaneOnBackPressedCallback(mBinding.slidingPaneLayout));
|
||||
|
||||
mViewModel.getSelectedCheat().observe(this, this::onSelectedCheatChanged);
|
||||
onSelectedCheatChanged(mViewModel.getSelectedCheat().getValue());
|
||||
|
||||
mViewModel.getOpenDetailsViewEvent().observe(this, this::openDetailsView);
|
||||
|
||||
MaterialToolbar tb = findViewById(R.id.toolbar_cheats);
|
||||
setSupportActionBar(tb);
|
||||
setSupportActionBar(mBinding.toolbarCheats);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
View workaroundView = findViewById(R.id.workaround_view);
|
||||
AppBarLayout appBarLayout = findViewById(R.id.appbar_cheats);
|
||||
InsetsHelper.setUpCheatsLayout(this, appBarLayout, mSlidingPaneLayout, mCheatDetails,
|
||||
workaroundView);
|
||||
InsetsHelper.setUpCheatsLayout(this, mBinding.appbarCheats, mBinding.slidingPaneLayout,
|
||||
mBinding.cheatDetails,
|
||||
mBinding.workaroundView);
|
||||
|
||||
@ColorInt int color = MaterialColors.getColor(tb, R.attr.colorSurfaceVariant);
|
||||
tb.setBackgroundColor(color);
|
||||
@ColorInt int color =
|
||||
MaterialColors.getColor(mBinding.toolbarCheats, R.attr.colorSurfaceVariant);
|
||||
mBinding.toolbarCheats.setBackgroundColor(color);
|
||||
ThemeHelper.setStatusBarColor(this, color);
|
||||
}
|
||||
|
||||
@@ -161,10 +154,10 @@ public class CheatsActivity extends AppCompatActivity
|
||||
{
|
||||
boolean cheatSelected = selectedCheat != null;
|
||||
|
||||
if (!cheatSelected && mSlidingPaneLayout.isOpen())
|
||||
mSlidingPaneLayout.close();
|
||||
if (!cheatSelected && mBinding.slidingPaneLayout.isOpen())
|
||||
mBinding.slidingPaneLayout.close();
|
||||
|
||||
mSlidingPaneLayout.setLockMode(cheatSelected ?
|
||||
mBinding.slidingPaneLayout.setLockMode(cheatSelected ?
|
||||
SlidingPaneLayout.LOCK_MODE_UNLOCKED : SlidingPaneLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||
}
|
||||
|
||||
@@ -172,11 +165,11 @@ public class CheatsActivity extends AppCompatActivity
|
||||
{
|
||||
if (hasFocus)
|
||||
{
|
||||
mCheatListLastFocus = mCheatList.findFocus();
|
||||
mCheatListLastFocus = mBinding.cheatList.findFocus();
|
||||
if (mCheatListLastFocus == null)
|
||||
throw new NullPointerException();
|
||||
|
||||
mSlidingPaneLayout.close();
|
||||
mBinding.slidingPaneLayout.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,11 +177,11 @@ public class CheatsActivity extends AppCompatActivity
|
||||
{
|
||||
if (hasFocus)
|
||||
{
|
||||
mCheatDetailsLastFocus = mCheatDetails.findFocus();
|
||||
mCheatDetailsLastFocus = mBinding.cheatDetails.findFocus();
|
||||
if (mCheatDetailsLastFocus == null)
|
||||
throw new NullPointerException();
|
||||
|
||||
mSlidingPaneLayout.open();
|
||||
mBinding.slidingPaneLayout.open();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +195,7 @@ public class CheatsActivity extends AppCompatActivity
|
||||
private void openDetailsView(boolean open)
|
||||
{
|
||||
if (open)
|
||||
mSlidingPaneLayout.open();
|
||||
mBinding.slidingPaneLayout.open();
|
||||
}
|
||||
|
||||
public Settings loadGameSpecificSettings()
|
||||
|
||||
+12
-9
@@ -10,6 +10,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemCheatBinding;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemHeaderBinding;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemSubmenuBinding;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.ARCheat;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.CheatsViewModel;
|
||||
import org.dolphinemu.dolphinemu.features.cheats.model.GeckoCheat;
|
||||
@@ -66,17 +69,17 @@ public class CheatsAdapter extends RecyclerView.Adapter<CheatItemViewHolder>
|
||||
switch (viewType)
|
||||
{
|
||||
case CheatItem.TYPE_CHEAT:
|
||||
View cheatView = inflater.inflate(R.layout.list_item_cheat, parent, false);
|
||||
addViewListeners(cheatView);
|
||||
return new CheatViewHolder(cheatView);
|
||||
ListItemCheatBinding listItemCheatBinding = ListItemCheatBinding.inflate(inflater);
|
||||
addViewListeners(listItemCheatBinding.getRoot());
|
||||
return new CheatViewHolder(listItemCheatBinding);
|
||||
case CheatItem.TYPE_HEADER:
|
||||
View headerView = inflater.inflate(R.layout.list_item_header, parent, false);
|
||||
addViewListeners(headerView);
|
||||
return new HeaderViewHolder(headerView);
|
||||
ListItemHeaderBinding listItemHeaderBinding = ListItemHeaderBinding.inflate(inflater);
|
||||
addViewListeners(listItemHeaderBinding.getRoot());
|
||||
return new HeaderViewHolder(listItemHeaderBinding);
|
||||
case CheatItem.TYPE_ACTION:
|
||||
View actionView = inflater.inflate(R.layout.list_item_submenu, parent, false);
|
||||
addViewListeners(actionView);
|
||||
return new ActionViewHolder(actionView);
|
||||
ListItemSubmenuBinding listItemSubmenuBinding = ListItemSubmenuBinding.inflate(inflater);
|
||||
addViewListeners(listItemSubmenuBinding.getRoot());
|
||||
return new ActionViewHolder(listItemSubmenuBinding);
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
+4
-3
@@ -8,16 +8,17 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemHeaderBinding;
|
||||
|
||||
public class HeaderViewHolder extends CheatItemViewHolder
|
||||
{
|
||||
private TextView mHeaderName;
|
||||
|
||||
public HeaderViewHolder(@NonNull View itemView)
|
||||
public HeaderViewHolder(@NonNull ListItemHeaderBinding binding)
|
||||
{
|
||||
super(itemView);
|
||||
super(binding.getRoot());
|
||||
|
||||
mHeaderName = itemView.findViewById(R.id.text_header_name);
|
||||
mHeaderName = binding.textHeaderName;
|
||||
}
|
||||
|
||||
public void bind(CheatsActivity activity, CheatItem item, int position)
|
||||
|
||||
+15
-10
@@ -6,14 +6,12 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.FragmentCheatWarningBinding;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||
@@ -28,6 +26,8 @@ public abstract class SettingDisabledWarningFragment extends Fragment
|
||||
private final MenuTag mSettingShortcut;
|
||||
private final int mText;
|
||||
|
||||
private FragmentCheatWarningBinding mBinding;
|
||||
|
||||
public SettingDisabledWarningFragment(AbstractBooleanSetting setting, MenuTag settingShortcut,
|
||||
int text)
|
||||
{
|
||||
@@ -38,10 +38,11 @@ public abstract class SettingDisabledWarningFragment extends Fragment
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
return inflater.inflate(R.layout.fragment_cheat_warning, container, false);
|
||||
mBinding = FragmentCheatWarningBinding.inflate(inflater, container, false);
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,11 +50,8 @@ public abstract class SettingDisabledWarningFragment extends Fragment
|
||||
{
|
||||
mView = view;
|
||||
|
||||
TextView textView = view.findViewById(R.id.text_warning);
|
||||
textView.setText(mText);
|
||||
|
||||
Button settingsButton = view.findViewById(R.id.button_settings);
|
||||
settingsButton.setOnClickListener(this);
|
||||
mBinding.textWarning.setText(mText);
|
||||
mBinding.buttonSettings.setOnClickListener(this);
|
||||
|
||||
CheatsActivity activity = (CheatsActivity) requireActivity();
|
||||
CheatsActivity.setOnFocusChangeListenerRecursively(view,
|
||||
@@ -73,6 +71,13 @@ public abstract class SettingDisabledWarningFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView()
|
||||
{
|
||||
super.onDestroyView();
|
||||
mBinding = null;
|
||||
}
|
||||
|
||||
public void onClick(View view)
|
||||
{
|
||||
SettingsActivity.launch(requireContext(), mSettingShortcut);
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemRiivolutionBinding;
|
||||
import org.dolphinemu.dolphinemu.features.riivolution.model.RiivolutionPatches;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -48,8 +48,8 @@ public class RiivolutionAdapter extends RecyclerView.Adapter<RiivolutionViewHold
|
||||
public RiivolutionViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
|
||||
{
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
return new RiivolutionViewHolder(
|
||||
inflater.inflate(R.layout.list_item_riivolution, parent, false));
|
||||
ListItemRiivolutionBinding binding = ListItemRiivolutionBinding.inflate(inflater);
|
||||
return new RiivolutionViewHolder(binding.getRoot(), binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+14
-27
@@ -5,22 +5,14 @@ package org.dolphinemu.dolphinemu.features.riivolution.ui;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
|
||||
import org.dolphinemu.dolphinemu.databinding.ActivityRiivolutionBootBinding;
|
||||
import org.dolphinemu.dolphinemu.features.riivolution.model.RiivolutionPatches;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
|
||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
||||
@@ -36,6 +28,8 @@ public class RiivolutionBootActivity extends AppCompatActivity
|
||||
|
||||
private RiivolutionPatches mPatches;
|
||||
|
||||
private ActivityRiivolutionBootBinding mBinding;
|
||||
|
||||
public static void launch(Context context, String gamePath, String gameId, int revision,
|
||||
int discNumber)
|
||||
{
|
||||
@@ -54,7 +48,8 @@ public class RiivolutionBootActivity extends AppCompatActivity
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_riivolution_boot);
|
||||
mBinding = ActivityRiivolutionBootBinding.inflate(getLayoutInflater());
|
||||
setContentView(mBinding.getRoot());
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
|
||||
@@ -69,11 +64,9 @@ public class RiivolutionBootActivity extends AppCompatActivity
|
||||
if (loadPath.isEmpty())
|
||||
loadPath = DirectoryInitialization.getUserDirectory() + "/Load";
|
||||
|
||||
TextView textSdRoot = findViewById(R.id.text_sd_root);
|
||||
textSdRoot.setText(getString(R.string.riivolution_sd_root, loadPath + "/Riivolution"));
|
||||
mBinding.textSdRoot.setText(getString(R.string.riivolution_sd_root, loadPath + "/Riivolution"));
|
||||
|
||||
Button buttonStart = findViewById(R.id.button_start);
|
||||
buttonStart.setOnClickListener((v) ->
|
||||
mBinding.buttonStart.setOnClickListener((v) ->
|
||||
{
|
||||
if (mPatches != null)
|
||||
mPatches.saveConfig();
|
||||
@@ -88,17 +81,13 @@ public class RiivolutionBootActivity extends AppCompatActivity
|
||||
runOnUiThread(() -> populateList(patches));
|
||||
}).start();
|
||||
|
||||
MaterialToolbar tb = findViewById(R.id.toolbar_riivolution);
|
||||
CollapsingToolbarLayout ctb = findViewById(R.id.toolbar_riivolution_layout);
|
||||
ctb.setTitle(getString(R.string.riivolution_riivolution));
|
||||
setSupportActionBar(tb);
|
||||
mBinding.toolbarRiivolutionLayout.setTitle(getString(R.string.riivolution_riivolution));
|
||||
setSupportActionBar(mBinding.toolbarRiivolution);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
AppBarLayout appBarLayout = findViewById(R.id.appbar_riivolution);
|
||||
NestedScrollView scrollView = findViewById(R.id.scroll_view_riivolution);
|
||||
View workaroundView = findViewById(R.id.workaround_view);
|
||||
InsetsHelper.setUpAppBarWithScrollView(this, appBarLayout, scrollView, workaroundView);
|
||||
ThemeHelper.enableScrollTint(this, tb, appBarLayout);
|
||||
InsetsHelper.setUpAppBarWithScrollView(this, mBinding.appbarRiivolution,
|
||||
mBinding.scrollViewRiivolution, mBinding.workaroundView);
|
||||
ThemeHelper.enableScrollTint(this, mBinding.toolbarRiivolution, mBinding.appbarRiivolution);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,9 +110,7 @@ public class RiivolutionBootActivity extends AppCompatActivity
|
||||
{
|
||||
mPatches = patches;
|
||||
|
||||
RecyclerView recyclerView = findViewById(R.id.recycler_view);
|
||||
|
||||
recyclerView.setAdapter(new RiivolutionAdapter(this, patches));
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mBinding.recyclerView.setAdapter(new RiivolutionAdapter(this, patches));
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
}
|
||||
}
|
||||
|
||||
+15
-22
@@ -6,60 +6,53 @@ import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemRiivolutionBinding;
|
||||
import org.dolphinemu.dolphinemu.features.riivolution.model.RiivolutionPatches;
|
||||
|
||||
public class RiivolutionViewHolder extends RecyclerView.ViewHolder
|
||||
implements AdapterView.OnItemClickListener
|
||||
{
|
||||
private final TextView mTextView;
|
||||
private final TextInputLayout mChoiceLayout;
|
||||
private final MaterialAutoCompleteTextView mChoiceDropdown;
|
||||
private final ListItemRiivolutionBinding mBinding;
|
||||
|
||||
private RiivolutionPatches mPatches;
|
||||
private RiivolutionItem mItem;
|
||||
|
||||
public RiivolutionViewHolder(@NonNull View itemView)
|
||||
public RiivolutionViewHolder(@NonNull View itemView, ListItemRiivolutionBinding binding)
|
||||
{
|
||||
super(itemView);
|
||||
|
||||
mTextView = itemView.findViewById(R.id.text_name);
|
||||
mChoiceLayout = itemView.findViewById(R.id.layout_choice);
|
||||
mChoiceDropdown = itemView.findViewById(R.id.dropdown_choice);
|
||||
mBinding = binding;
|
||||
}
|
||||
|
||||
public void bind(Context context, RiivolutionPatches patches, RiivolutionItem item)
|
||||
{
|
||||
// TODO: Remove workaround for text filtering issue in material components when fixed
|
||||
// https://github.com/material-components/material-components-android/issues/1464
|
||||
mChoiceDropdown.setSaveEnabled(false);
|
||||
mBinding.dropdownChoice.setSaveEnabled(false);
|
||||
|
||||
String text;
|
||||
if (item.mOptionIndex != -1)
|
||||
{
|
||||
mTextView.setVisibility(View.GONE);
|
||||
mBinding.textName.setVisibility(View.GONE);
|
||||
text = patches.getOptionName(item.mDiscIndex, item.mSectionIndex, item.mOptionIndex);
|
||||
mChoiceLayout.setHint(text);
|
||||
mBinding.layoutChoice.setHint(text);
|
||||
}
|
||||
else if (item.mSectionIndex != -1)
|
||||
{
|
||||
mTextView.setTextAppearance(context, R.style.TextAppearance_AppCompat_Medium);
|
||||
mChoiceLayout.setVisibility(View.GONE);
|
||||
mBinding.textName.setTextAppearance(context, R.style.TextAppearance_AppCompat_Medium);
|
||||
mBinding.layoutChoice.setVisibility(View.GONE);
|
||||
text = patches.getSectionName(item.mDiscIndex, item.mSectionIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
mChoiceLayout.setVisibility(View.GONE);
|
||||
mBinding.layoutChoice.setVisibility(View.GONE);
|
||||
text = patches.getDiscName(item.mDiscIndex);
|
||||
}
|
||||
mTextView.setText(text);
|
||||
mBinding.textName.setText(text);
|
||||
|
||||
if (item.mOptionIndex != -1)
|
||||
{
|
||||
@@ -78,11 +71,11 @@ public class RiivolutionViewHolder extends RecyclerView.ViewHolder
|
||||
i));
|
||||
}
|
||||
|
||||
mChoiceDropdown.setAdapter(adapter);
|
||||
mChoiceDropdown.setText(adapter.getItem(
|
||||
mBinding.dropdownChoice.setAdapter(adapter);
|
||||
mBinding.dropdownChoice.setText(adapter.getItem(
|
||||
patches.getSelectedChoice(mItem.mDiscIndex, mItem.mSectionIndex, mItem.mOptionIndex)),
|
||||
false);
|
||||
mChoiceDropdown.setOnItemClickListener(this);
|
||||
mBinding.dropdownChoice.setOnItemClickListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-10
@@ -28,6 +28,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.ActivitySettingsBinding;
|
||||
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
||||
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
||||
import org.dolphinemu.dolphinemu.utils.InsetsHelper;
|
||||
@@ -81,7 +82,8 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
||||
MainPresenter.skipRescanningLibrary();
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_settings);
|
||||
ActivitySettingsBinding binding = ActivitySettingsBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
|
||||
@@ -96,21 +98,17 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
||||
mPresenter = new SettingsActivityPresenter(this, getSettings());
|
||||
mPresenter.onCreate(savedInstanceState, menuTag, gameID, revision, isWii, this);
|
||||
|
||||
MaterialToolbar tb = findViewById(R.id.toolbar_settings);
|
||||
mToolbarLayout = findViewById(R.id.toolbar_settings_layout);
|
||||
setSupportActionBar(tb);
|
||||
mToolbarLayout = binding.toolbarSettingsLayout;
|
||||
setSupportActionBar(binding.toolbarSettings);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
AppBarLayout appBarLayout = findViewById(R.id.appbar_settings);
|
||||
FrameLayout frameLayout = findViewById(R.id.frame_content_settings);
|
||||
|
||||
// TODO: Remove this when CollapsingToolbarLayouts are fixed by Google
|
||||
// https://github.com/material-components/material-components-android/issues/1310
|
||||
ViewCompat.setOnApplyWindowInsetsListener(mToolbarLayout, null);
|
||||
|
||||
View workaroundView = findViewById(R.id.workaround_view);
|
||||
InsetsHelper.setUpSettingsLayout(this, appBarLayout, frameLayout, workaroundView);
|
||||
ThemeHelper.enableScrollTint(this, tb, appBarLayout);
|
||||
InsetsHelper.setUpSettingsLayout(this, binding.appbarSettings, binding.frameContentSettings,
|
||||
binding.workaroundView);
|
||||
ThemeHelper.enableScrollTint(this, binding.toolbarSettings, binding.appbarSettings);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+36
-41
@@ -8,7 +8,6 @@ import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -21,6 +20,12 @@ import com.google.android.material.slider.Slider;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.DialogInputStringBinding;
|
||||
import org.dolphinemu.dolphinemu.databinding.DialogSliderBinding;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemHeaderBinding;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemSettingBinding;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemSettingCheckboxBinding;
|
||||
import org.dolphinemu.dolphinemu.databinding.ListItemSubmenuBinding;
|
||||
import org.dolphinemu.dolphinemu.dialogs.MotionAlertDialog;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.view.CheckBoxSetting;
|
||||
@@ -79,59 +84,50 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
mClickedPosition = -1;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public SettingViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
|
||||
public SettingViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
|
||||
{
|
||||
View view;
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
|
||||
switch (viewType)
|
||||
{
|
||||
case SettingsItem.TYPE_HEADER:
|
||||
view = inflater.inflate(R.layout.list_item_header, parent, false);
|
||||
return new HeaderViewHolder(view, this);
|
||||
return new HeaderViewHolder(ListItemHeaderBinding.inflate(inflater), this);
|
||||
|
||||
case SettingsItem.TYPE_CHECKBOX:
|
||||
view = inflater.inflate(R.layout.list_item_setting_checkbox, parent, false);
|
||||
return new CheckBoxSettingViewHolder(view, this);
|
||||
return new CheckBoxSettingViewHolder(ListItemSettingCheckboxBinding.inflate(inflater),
|
||||
this);
|
||||
|
||||
case SettingsItem.TYPE_STRING_SINGLE_CHOICE:
|
||||
case SettingsItem.TYPE_SINGLE_CHOICE_DYNAMIC_DESCRIPTIONS:
|
||||
case SettingsItem.TYPE_SINGLE_CHOICE:
|
||||
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||
return new SingleChoiceViewHolder(view, this);
|
||||
return new SingleChoiceViewHolder(ListItemSettingBinding.inflate(inflater), this);
|
||||
|
||||
case SettingsItem.TYPE_SLIDER:
|
||||
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||
return new SliderViewHolder(view, this, mContext);
|
||||
return new SliderViewHolder(ListItemSettingBinding.inflate(inflater), this, mContext);
|
||||
|
||||
case SettingsItem.TYPE_SUBMENU:
|
||||
view = inflater.inflate(R.layout.list_item_submenu, parent, false);
|
||||
return new SubmenuViewHolder(view, this);
|
||||
return new SubmenuViewHolder(ListItemSubmenuBinding.inflate(inflater), this);
|
||||
|
||||
case SettingsItem.TYPE_INPUT_BINDING:
|
||||
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||
return new InputBindingSettingViewHolder(view, this, mContext);
|
||||
return new InputBindingSettingViewHolder(ListItemSettingBinding.inflate(inflater), this,
|
||||
mContext);
|
||||
|
||||
case SettingsItem.TYPE_RUMBLE_BINDING:
|
||||
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||
return new RumbleBindingViewHolder(view, this, mContext);
|
||||
return new RumbleBindingViewHolder(ListItemSettingBinding.inflate(inflater), this,
|
||||
mContext);
|
||||
|
||||
case SettingsItem.TYPE_FILE_PICKER:
|
||||
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||
return new FilePickerViewHolder(view, this);
|
||||
return new FilePickerViewHolder(ListItemSettingBinding.inflate(inflater), this);
|
||||
|
||||
case SettingsItem.TYPE_RUN_RUNNABLE:
|
||||
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||
return new RunRunnableViewHolder(view, this, mContext);
|
||||
return new RunRunnableViewHolder(ListItemSettingBinding.inflate(inflater), this, mContext);
|
||||
|
||||
case SettingsItem.TYPE_STRING:
|
||||
view = inflater.inflate(R.layout.list_item_setting, parent, false);
|
||||
return new InputStringSettingViewHolder(view, this);
|
||||
return new InputStringSettingViewHolder(ListItemSettingBinding.inflate(inflater), this);
|
||||
|
||||
case SettingsItem.TYPE_HYPERLINK_HEADER:
|
||||
view = inflater.inflate(R.layout.list_item_header, parent, false);
|
||||
return new HeaderHyperLinkViewHolder(view, this, mContext);
|
||||
return new HeaderHyperLinkViewHolder(ListItemHeaderBinding.inflate(inflater), this);
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid view type: " + viewType);
|
||||
@@ -139,7 +135,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(SettingViewHolder holder, int position)
|
||||
public void onBindViewHolder(@NonNull SettingViewHolder holder, int position)
|
||||
{
|
||||
holder.bind(getItem(position));
|
||||
}
|
||||
@@ -206,12 +202,12 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
{
|
||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
|
||||
View dialogView = inflater.inflate(R.layout.dialog_input_string, null);
|
||||
TextInputEditText input = dialogView.findViewById(R.id.input);
|
||||
DialogInputStringBinding binding = DialogInputStringBinding.inflate(inflater);
|
||||
TextInputEditText input = binding.input;
|
||||
input.setText(item.getSelectedValue(getSettings()));
|
||||
|
||||
mDialog = new MaterialAlertDialogBuilder(mView.getActivity())
|
||||
.setView(dialogView)
|
||||
.setView(binding.getRoot())
|
||||
.setMessage(item.getDescription())
|
||||
.setPositiveButton(R.string.ok, (dialogInterface, i) ->
|
||||
{
|
||||
@@ -275,26 +271,25 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
mSeekbarProgress = item.getSelectedValue(getSettings());
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(mView.getActivity());
|
||||
View view = inflater.inflate(R.layout.dialog_slider, null);
|
||||
DialogSliderBinding binding = DialogSliderBinding.inflate(inflater);
|
||||
|
||||
mDialog = new MaterialAlertDialogBuilder(mView.getActivity())
|
||||
.setTitle(item.getName())
|
||||
.setView(view)
|
||||
.setPositiveButton(R.string.ok, this)
|
||||
.show();
|
||||
|
||||
mTextSliderValue = view.findViewById(R.id.text_value);
|
||||
mTextSliderValue = binding.textValue;
|
||||
mTextSliderValue.setText(String.valueOf(mSeekbarProgress));
|
||||
|
||||
TextView units = view.findViewById(R.id.text_units);
|
||||
units.setText(item.getUnits());
|
||||
binding.textUnits.setText(item.getUnits());
|
||||
|
||||
Slider slider = view.findViewById(R.id.slider);
|
||||
Slider slider = binding.slider;
|
||||
slider.setValueFrom(item.getMin());
|
||||
slider.setValueTo(item.getMax());
|
||||
slider.setValue(mSeekbarProgress);
|
||||
slider.setStepSize(1);
|
||||
slider.addOnChangeListener(this);
|
||||
|
||||
mDialog = new MaterialAlertDialogBuilder(mView.getActivity())
|
||||
.setTitle(item.getName())
|
||||
.setView(binding.getRoot())
|
||||
.setPositiveButton(R.string.ok, this)
|
||||
.show();
|
||||
}
|
||||
|
||||
public void onSubmenuClick(SubmenuSetting item)
|
||||
|
||||
+15
-4
@@ -17,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.divider.MaterialDividerItemDecoration;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.databinding.FragmentSettingsBinding;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
|
||||
import org.dolphinemu.dolphinemu.utils.InsetsHelper;
|
||||
@@ -74,6 +75,8 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
||||
titles.put(MenuTag.WIIMOTE_EXTENSION_4, R.string.wiimote_extension_7);
|
||||
}
|
||||
|
||||
private FragmentSettingsBinding mBinding;
|
||||
|
||||
public static Fragment newInstance(MenuTag menuTag, String gameId, Bundle extras)
|
||||
{
|
||||
SettingsFragment fragment = new SettingsFragment();
|
||||
@@ -114,12 +117,13 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
||||
mPresenter.onCreate(menuTag, gameId, args);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NonNull
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
return inflater.inflate(R.layout.fragment_settings, container, false);
|
||||
mBinding = FragmentSettingsBinding.inflate(inflater, container, false);
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,7 +139,7 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
||||
|
||||
LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
||||
|
||||
RecyclerView recyclerView = view.findViewById(R.id.list_settings);
|
||||
RecyclerView recyclerView = mBinding.listSettings;
|
||||
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
recyclerView.setLayoutManager(manager);
|
||||
@@ -151,6 +155,13 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
|
||||
mPresenter.onViewCreated(menuTag, activity.getSettings());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView()
|
||||
{
|
||||
super.onDestroyView();
|
||||
mBinding = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach()
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user