fix some error & add some new layout

This commit is contained in:
Tungstend 2022-11-08 19:25:25 +08:00
parent c562db8cbe
commit e266504076
13 changed files with 252 additions and 20 deletions

View File

@ -118,6 +118,27 @@ public class AccountUI extends FCLCommonUI implements View.OnClickListener {
public void onStart() {
super.onStart();
refresh();
skinGLSurfaceView.onResume();
}
@Override
public void onPause() {
super.onPause();
skinGLSurfaceView.onPause();
}
@Override
public void onResume() {
super.onResume();
if (isShowing()) {
skinGLSurfaceView.onResume();
}
}
@Override
public void onStop() {
super.onStop();
skinGLSurfaceView.onPause();
}
@Override

View File

@ -0,0 +1,14 @@
package com.tungsten.fcl.ui.account;
import android.content.Context;
import androidx.annotation.NonNull;
import com.tungsten.fcllibrary.component.dialog.FCLDialog;
public class AddAuthlibInjectorServerDialog extends FCLDialog {
public AddAuthlibInjectorServerDialog(@NonNull Context context) {
super(context);
}
}

View File

@ -3,6 +3,8 @@ package com.tungsten.fcl.ui.account;
import static com.tungsten.fcl.setting.ConfigHolder.config;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
@ -23,6 +25,7 @@ import com.tungsten.fclcore.auth.AccountFactory;
import com.tungsten.fclcore.auth.CharacterSelector;
import com.tungsten.fclcore.auth.NoSelectedCharacterException;
import com.tungsten.fclcore.auth.authlibinjector.AuthlibInjectorAccountFactory;
import com.tungsten.fclcore.auth.authlibinjector.AuthlibInjectorServer;
import com.tungsten.fclcore.auth.microsoft.MicrosoftAccountFactory;
import com.tungsten.fclcore.auth.offline.OfflineAccountFactory;
import com.tungsten.fclcore.auth.yggdrasil.GameProfile;
@ -35,10 +38,12 @@ import com.tungsten.fcllibrary.component.FCLAdapter;
import com.tungsten.fcllibrary.component.dialog.FCLDialog;
import com.tungsten.fcllibrary.component.view.FCLButton;
import com.tungsten.fcllibrary.component.view.FCLEditText;
import com.tungsten.fcllibrary.component.view.FCLImageButton;
import com.tungsten.fcllibrary.component.view.FCLTabLayout;
import com.tungsten.fcllibrary.component.view.FCLTextView;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
public class CreateAccountDialog extends FCLDialog implements View.OnClickListener {
@ -235,9 +240,11 @@ public class CreateAccountDialog extends FCLDialog implements View.OnClickListen
private static class MicrosoftDetails implements Details {
private final Context context;
private final View view;
public MicrosoftDetails(Context context) {
this.context = context;
this.view = LayoutInflater.from(context).inflate(R.layout.dialog_create_account_microsoft, null);
}
@Override
@ -257,26 +264,86 @@ public class CreateAccountDialog extends FCLDialog implements View.OnClickListen
@Override
public View getView() throws IllegalStateException {
return null;
return view;
}
}
private static class ExternalDetails implements Details {
private static class ExternalDetails implements Details, View.OnClickListener {
private static final String[] ALLOWED_LINKS = { "homepage", "register" };
private final Context context;
private final View view;
private FCLTextView serverName;
private FCLImageButton home;
private FCLImageButton register;
private FCLImageButton setting;
private final FCLEditText username;
private final FCLEditText password;
public ExternalDetails(Context context) {
this.context = context;
this.view = LayoutInflater.from(context).inflate(R.layout.dialog_create_account_external, null);
serverName = view.findViewById(R.id.server_name);
home = view.findViewById(R.id.home);
register = view.findViewById(R.id.register);
setting = view.findViewById(R.id.setting);
username = view.findViewById(R.id.username);
password = view.findViewById(R.id.password);
setting.setOnClickListener(this);
refreshAuthenticateServer(config().getAuthlibInjectorServers().size() == 0 ? null : config().getAuthlibInjectorServers().get(0));
}
private void refreshAuthenticateServer(AuthlibInjectorServer authlibInjectorServer) {
if (authlibInjectorServer == null) {
serverName.setText(context.getString(R.string.account_create_server_not_select));
home.setVisibility(View.GONE);
register.setVisibility(View.GONE);
}
else {
serverName.setText(authlibInjectorServer.getName());
Map<String, String> links = authlibInjectorServer.getLinks();
if (links.get("homepage") != null) {
home.setVisibility(View.VISIBLE);
home.setOnClickListener(view -> {
Uri uri = Uri.parse(links.get("homepage"));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
context.startActivity(intent);
});
} else {
home.setVisibility(View.GONE);
}
if (links.get("register") != null) {
register.setVisibility(View.VISIBLE);
register.setOnClickListener(view -> {
Uri uri = Uri.parse(links.get("register"));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
context.startActivity(intent);
});
} else {
register.setVisibility(View.GONE);
}
}
}
@Override
public String getUsername() throws IllegalStateException {
return null;
if (StringUtils.isBlank(username.getText().toString())) {
throw new IllegalStateException(context.getString(R.string.account_create_alert));
}
return username.getText().toString();
}
@Override
public String getPassword() throws IllegalStateException {
return null;
if (StringUtils.isBlank(password.getText().toString())) {
throw new IllegalStateException(context.getString(R.string.account_create_alert));
}
return password.getText().toString();
}
@Override
@ -286,7 +353,14 @@ public class CreateAccountDialog extends FCLDialog implements View.OnClickListen
@Override
public View getView() throws IllegalStateException {
return null;
return view;
}
@Override
public void onClick(View view) {
if (view == setting) {
}
}
}

View File

@ -0,0 +1,10 @@
<vector
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM6,10L6,7L4,7v3L1,10v2h3v3h2v-3h3v-2L6,10zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
</vector>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_width="400dp"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="10dp">

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.appcompat.widget.LinearLayoutCompat
android:paddingTop="10dp"
@ -10,7 +11,100 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_weight="1"
android:singleLine="true"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/account_create_server"
android:layout_gravity="center"/>
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_marginStart="5dp"
android:id="@+id/server_name"
android:singleLine="true"
android:layout_width="115dp"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<com.tungsten.fcllibrary.component.view.FCLImageButton
android:layout_marginStart="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_home_24"
app:auto_tint="true"
android:id="@+id/home"/>
<com.tungsten.fcllibrary.component.view.FCLImageButton
android:layout_marginStart="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_person_add_24"
app:auto_tint="true"
android:id="@+id/register"/>
<com.tungsten.fcllibrary.component.view.FCLImageButton
android:layout_marginStart="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_baseline_settings_24"
app:auto_tint="true"
android:id="@+id/setting"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_weight="1"
android:singleLine="true"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/account_create_username"
android:layout_gravity="center"/>
<com.tungsten.fcllibrary.component.view.FCLEditText
android:singleLine="true"
android:id="@+id/username"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_weight="1"
android:singleLine="true"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/account_create_password"
android:layout_gravity="center"/>
<com.tungsten.fcllibrary.component.view.FCLEditText
android:singleLine="true"
android:inputType="textPassword"
android:id="@+id/password"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>

View File

@ -1,33 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.LinearLayoutCompat
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_weight="1"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/account_create_username"
android:layout_gravity="center"/>
<com.tungsten.fcllibrary.component.view.FCLEditText
android:singleLine="true"
android:id="@+id/username"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="10dp"/>
android:layout_gravity="center"/>
</androidx.appcompat.widget.LinearLayoutCompat>

View File

@ -37,6 +37,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textSize="16sp"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintWidth_percent="0.4"
app:layout_constraintStart_toStartOf="parent"
@ -49,12 +50,12 @@
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginBottom="50dp"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintWidth_percent="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/refresh"/>
app:layout_constraintBottom_toTopOf="@+id/bar"/>
<com.tungsten.fcllibrary.component.view.FCLImageButton
android:id="@+id/refresh"
@ -71,8 +72,8 @@
<com.tungsten.fcllibrary.component.view.FCLProgressBar
android:id="@+id/refresh_progress"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="10dp"
app:layout_constraintHorizontal_bias="0.44"
app:layout_constraintBottom_toTopOf="@+id/bar"
@ -94,8 +95,8 @@
<com.tungsten.fcllibrary.component.view.FCLProgressBar
android:id="@+id/skin_progress"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="10dp"
app:layout_constraintHorizontal_bias="0.56"
app:layout_constraintBottom_toTopOf="@+id/bar"

View File

@ -26,6 +26,7 @@
<string name="account_create_register">注册</string>
<string name="account_create_alert">请先提供足够的账户信息!</string>
<string name="account_injector_server">认证服务器</string>
<string name="account_create_server_not_select">没有认证服务器</string>
<string name="account_login">登录</string>
<string name="account_methods_offline">离线账户</string>
<string name="account_methods_yggdrasil">Mojang 账户</string>

View File

@ -30,6 +30,7 @@
<string name="account_create_username">Username</string>
<string name="account_create_password">Password</string>
<string name="account_create_server">Authentication server</string>
<string name="account_create_server_not_select">No Authentication Server</string>
<string name="account_create_home">Home</string>
<string name="account_create_register">Register</string>
<string name="account_create_alert">Please provide enough account info first!</string>

View File

@ -69,7 +69,6 @@ public class ThemeEngine {
} else {
window.getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
}
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
window.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION