mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-12 06:05:10 -04:00
Removed all NavigationViews, replaced with ListViews...
... which allowed me to remove the Google Material dependency once and for all!
This commit is contained in:
parent
6afc22e474
commit
bd3d83d2e3
@ -123,7 +123,9 @@ dependencies {
|
||||
implementation 'commons-codec:commons-codec:1.14'
|
||||
// implementation 'com.wu-man:android-bsf-api:3.1.3'
|
||||
implementation 'androidx.preference:preference:1.1.1'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
//implementation 'androidx.core:core:1.7.0'
|
||||
implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
|
||||
implementation 'androidx.viewpager2:viewpager2:1.0.0'
|
||||
implementation 'androidx.annotation:annotation:1.3.0'
|
||||
|
||||
implementation "androidx.constraintlayout:constraintlayout:2.1.2"
|
||||
|
@ -19,7 +19,7 @@ import android.widget.*;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.drawerlayout.widget.*;
|
||||
import com.google.android.material.navigation.*;
|
||||
|
||||
import com.kdt.LoggerView;
|
||||
|
||||
import java.io.*;
|
||||
@ -57,10 +57,13 @@ public class BaseMainActivity extends BaseActivity {
|
||||
MinecraftProfile minecraftProfile;
|
||||
|
||||
private DrawerLayout drawerLayout;
|
||||
private NavigationView navDrawer;
|
||||
private ListView navDrawer;
|
||||
|
||||
private NavigationView.OnNavigationItemSelectedListener gameActionListener;
|
||||
public NavigationView.OnNavigationItemSelectedListener ingameControlsEditorListener;
|
||||
private ArrayAdapter<String> gameActionArrayAdapter;
|
||||
private AdapterView.OnItemClickListener gameActionClickListener;
|
||||
public ArrayAdapter<String> ingameControlsEditorArrayAdapter;
|
||||
public AdapterView.OnItemClickListener ingameControlsEditorListener;
|
||||
//public NavigationView.OnNavigationItemSelectedListener ingameControlsEditorListener;
|
||||
|
||||
protected volatile JMinecraftVersionList.Version mVersionInfo;
|
||||
|
||||
@ -116,26 +119,32 @@ public class BaseMainActivity extends BaseActivity {
|
||||
drawerLayout = findViewById(R.id.main_drawer_options);
|
||||
|
||||
navDrawer = findViewById(R.id.main_navigation_view);
|
||||
gameActionListener = menuItem -> {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.nav_forceclose: dialogForceClose(BaseMainActivity.this);
|
||||
break;
|
||||
case R.id.nav_viewlog: openLogOutput();
|
||||
break;
|
||||
case R.id.nav_debug: minecraftGLView.togglepointerDebugging();
|
||||
break;
|
||||
case R.id.nav_customkey: dialogSendCustomKey();
|
||||
break;
|
||||
case R.id.nav_mousespd: adjustMouseSpeedLive();
|
||||
break;
|
||||
case R.id.nav_customctrl: openCustomControls();
|
||||
break;
|
||||
}
|
||||
|
||||
gameActionArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.menu_ingame));
|
||||
gameActionClickListener = (parent, view, position, id) -> {
|
||||
switch(position) {
|
||||
case 0:
|
||||
dialogForceClose(BaseMainActivity.this);
|
||||
break;
|
||||
case 1:
|
||||
openLogOutput();
|
||||
break;
|
||||
case 2:
|
||||
minecraftGLView.togglepointerDebugging();
|
||||
break;
|
||||
case 3:
|
||||
dialogSendCustomKey();
|
||||
break;
|
||||
case 4:
|
||||
adjustMouseSpeedLive();
|
||||
break;
|
||||
case 5:
|
||||
openCustomControls();
|
||||
}
|
||||
drawerLayout.closeDrawers();
|
||||
return true;
|
||||
};
|
||||
navDrawer.setNavigationItemSelectedListener(gameActionListener);
|
||||
navDrawer.setAdapter(gameActionArrayAdapter);
|
||||
navDrawer.setOnItemClickListener(gameActionClickListener);
|
||||
|
||||
touchpad = findViewById(R.id.main_touchpad);
|
||||
|
||||
@ -299,12 +308,11 @@ public class BaseMainActivity extends BaseActivity {
|
||||
|
||||
boolean isInEditor;
|
||||
private void openCustomControls() {
|
||||
if(ingameControlsEditorListener == null) return;
|
||||
if(ingameControlsEditorListener == null || ingameControlsEditorArrayAdapter == null) return;
|
||||
|
||||
((MainActivity)this).mControlLayout.setModifiable(true);
|
||||
navDrawer.getMenu().clear();
|
||||
navDrawer.inflateMenu(R.menu.menu_customctrl);
|
||||
navDrawer.setNavigationItemSelectedListener(ingameControlsEditorListener);
|
||||
navDrawer.setAdapter(ingameControlsEditorArrayAdapter);
|
||||
navDrawer.setOnItemClickListener(ingameControlsEditorListener);
|
||||
isInEditor = true;
|
||||
}
|
||||
|
||||
@ -321,9 +329,8 @@ public class BaseMainActivity extends BaseActivity {
|
||||
}
|
||||
//((MainActivity) this).mControlLayout.loadLayout((CustomControls)null);
|
||||
}
|
||||
navDrawer.getMenu().clear();
|
||||
navDrawer.inflateMenu(R.menu.menu_runopt);
|
||||
navDrawer.setNavigationItemSelectedListener(gameActionListener);
|
||||
navDrawer.setAdapter(gameActionArrayAdapter);
|
||||
navDrawer.setOnItemClickListener(gameActionClickListener);
|
||||
isInEditor = false;
|
||||
}
|
||||
private void openLogOutput() {
|
||||
|
@ -10,7 +10,6 @@ import android.widget.*;
|
||||
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.kdt.pickafile.*;
|
||||
import java.io.*;
|
||||
@ -21,7 +20,7 @@ import net.kdt.pojavlaunch.customcontrols.*;
|
||||
|
||||
public class CustomControlsActivity extends BaseActivity {
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private NavigationView mDrawerNavigationView;
|
||||
private ListView mDrawerNavigationView;
|
||||
private ControlLayout mControlLayout;
|
||||
|
||||
public boolean isModified = false;
|
||||
@ -40,9 +39,30 @@ public class CustomControlsActivity extends BaseActivity {
|
||||
|
||||
mControlLayout = (ControlLayout) findViewById(R.id.customctrl_controllayout);
|
||||
mDrawerLayout = (DrawerLayout) findViewById(R.id.customctrl_drawerlayout);
|
||||
mDrawerNavigationView = (NavigationView) findViewById(R.id.customctrl_navigation_view);
|
||||
mDrawerNavigationView = (ListView) findViewById(R.id.customctrl_navigation_view);
|
||||
|
||||
mDrawerNavigationView.setNavigationItemSelectedListener(
|
||||
mDrawerNavigationView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,getResources().getStringArray(R.array.menu_customcontrol)));
|
||||
mDrawerNavigationView.setOnItemClickListener((parent, view, position, id) -> {
|
||||
switch(position) {
|
||||
case 0:
|
||||
mControlLayout.addControlButton(new ControlData("New"));
|
||||
break;
|
||||
case 1:
|
||||
mControlLayout.addDrawer(new ControlDrawerData());
|
||||
break;
|
||||
case 2:
|
||||
load(mControlLayout);
|
||||
break;
|
||||
case 3:
|
||||
save(false, mControlLayout);
|
||||
break;
|
||||
case 4:
|
||||
dialogSelectDefaultCtrl(mControlLayout);
|
||||
break;
|
||||
}
|
||||
mDrawerLayout.closeDrawers();
|
||||
});
|
||||
/*mDrawerNavigationView.setNavigationItemSelectedListener(
|
||||
menuItem -> {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.menu_ctrl_load:
|
||||
@ -66,7 +86,7 @@ public class CustomControlsActivity extends BaseActivity {
|
||||
mDrawerLayout.closeDrawers();
|
||||
return true;
|
||||
});
|
||||
|
||||
*/
|
||||
mControlLayout.setActivity(this);
|
||||
mControlLayout.setModifiable(true);
|
||||
|
||||
|
@ -3,6 +3,9 @@ package net.kdt.pojavlaunch;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.*;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
|
||||
import net.kdt.pojavlaunch.customcontrols.*;
|
||||
@ -22,34 +25,32 @@ public class MainActivity extends BaseMainActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
initLayout(R.layout.activity_basemain);
|
||||
|
||||
// Set the sustained performance mode for available APIs
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
getWindow().setSustainedPerformanceMode(PREF_SUSTAINED_PERFORMANCE);
|
||||
|
||||
super.ingameControlsEditorListener = menuItem -> {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.menu_ctrl_load:
|
||||
CustomControlsActivity.load(mControlLayout);
|
||||
break;
|
||||
case R.id.menu_ctrl_add:
|
||||
ingameControlsEditorArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.menu_customcontrol));
|
||||
ingameControlsEditorListener = (parent, view, position, id) -> {
|
||||
switch(position) {
|
||||
case 0:
|
||||
mControlLayout.addControlButton(new ControlData("New"));
|
||||
break;
|
||||
case R.id.menu_ctrl_add_drawer:
|
||||
case 1:
|
||||
mControlLayout.addDrawer(new ControlDrawerData());
|
||||
break;
|
||||
case R.id.menu_ctrl_selectdefault:
|
||||
CustomControlsActivity.dialogSelectDefaultCtrl(mControlLayout);
|
||||
case 2:
|
||||
CustomControlsActivity.load(mControlLayout);
|
||||
break;
|
||||
case R.id.menu_ctrl_save:
|
||||
case 3:
|
||||
CustomControlsActivity.save(true,mControlLayout);
|
||||
break;
|
||||
case 4:
|
||||
CustomControlsActivity.dialogSelectDefaultCtrl(mControlLayout);
|
||||
break;
|
||||
}
|
||||
//Toast.makeText(MainActivity.this, menuItem.getTitle() + ":" + menuItem.getItemId(), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
};
|
||||
|
||||
// Recompute the gui scale when options are changed
|
||||
optionListener = MCOptionUtils::getMcScale;
|
||||
MCOptionUtils.addMCOptionListener(optionListener);
|
||||
|
@ -38,10 +38,6 @@ import static android.os.Build.VERSION_CODES.Q;
|
||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_IGNORE_NOTCH;
|
||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE;
|
||||
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
|
||||
public final class Tools {
|
||||
public static final boolean ENABLE_DEV_FEATURES = BuildConfig.DEBUG;
|
||||
|
||||
|
@ -55,10 +55,11 @@
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
<ListView
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:background="?attr/colorBackgroundFloating"
|
||||
android:fitsSystemWindows="false"
|
||||
app:menu="@menu/menu_runopt"
|
||||
android:id="@+id/main_navigation_view"/>
|
||||
|
@ -26,13 +26,13 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
<ListView
|
||||
android:id="@+id/customctrl_navigation_view"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:fitsSystemWindows="true"
|
||||
app:menu="@menu/menu_customctrl"
|
||||
android:id="@+id/customctrl_navigation_view"/>
|
||||
android:background="?attr/colorBackgroundFloating"
|
||||
android:fitsSystemWindows="false" />
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
|
||||
|
@ -5,6 +5,23 @@
|
||||
<!-- <item name="4">@string/mcl_setting_renderer_vulkan_zink</item> -->
|
||||
<item name="5">@string/mcl_setting_renderer_virgl</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="menu_customcontrol">
|
||||
<item name="0">@string/customctrl_addbutton</item>
|
||||
<item name="1">@string/customctrl_addbutton_drawer</item>
|
||||
<item name="2">@string/global_load</item>
|
||||
<item name="3">@string/global_save</item>
|
||||
<item name="4">@string/customctrl_selectdefault</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="menu_ingame">
|
||||
<item>@string/control_forceclose</item>
|
||||
<item>@string/control_viewout</item>
|
||||
<item>@string/control_adebug</item>
|
||||
<item>@string/control_customkey</item>
|
||||
<item>@string/mcl_setting_title_mousespeed</item>
|
||||
<item>@string/mcl_option_customcontrol</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="renderer_values">
|
||||
<item>opengles2</item> <!-- gl4es_extra 1.1.4 with OpenGL ES 2/"3" -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user