mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-11 21:55:34 -04:00
Design: UI more like Minecraft Launcher, change how font replaced
This commit is contained in:
parent
efffa26f2f
commit
3d0264923d
@ -11,8 +11,6 @@ import net.kdt.pojavlaunch.*;
|
||||
|
||||
public class MineButton extends Button
|
||||
{
|
||||
private static FontChanger fontChangerMinecraftTen;
|
||||
|
||||
private ColorDrawable left = new ColorDrawable(Color.parseColor("#80000000"));
|
||||
private ColorDrawable top = new ColorDrawable(Color.parseColor("#64FC20"));
|
||||
private ColorDrawable right = new ColorDrawable(Color.parseColor("#40000000"));
|
||||
@ -54,10 +52,7 @@ public class MineButton extends Button
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
if (fontChangerMinecraftTen == null) fontChangerMinecraftTen = new FontChanger(getContext().getAssets(), "font/minecraft-ten.ttf");
|
||||
fontChangerMinecraftTen.replaceFont(this);
|
||||
public void init() {
|
||||
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
|
@ -8,37 +8,18 @@ import android.widget.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import java.util.*;
|
||||
import android.content.*;
|
||||
import com.kdt.mcgui.*;
|
||||
|
||||
public class MineActivity extends AppCompatActivity implements View.OnClickListener
|
||||
{
|
||||
private int topId = 150001;
|
||||
private boolean showBeforeView = true;
|
||||
|
||||
private static FontChanger fontChanger;
|
||||
|
||||
private ImageButton menu;
|
||||
private LinearLayout content, undertop;
|
||||
|
||||
private LayoutInflater li;
|
||||
|
||||
public static ViewGroup replaceFonts(Context ctx, ViewGroup viewTree) {
|
||||
if (fontChanger == null) fontChanger = new FontChanger(ctx.getAssets(), "font/NotoSans-Bold.ttf");
|
||||
return fontChanger.replaceFonts(viewTree);
|
||||
}
|
||||
|
||||
public static View replaceFont(Context ctx, TextView view) {
|
||||
if (fontChanger == null) fontChanger = new FontChanger(ctx.getAssets(), "font/NotoSans-Bold.ttf");
|
||||
return fontChanger.replaceFont(view);
|
||||
}
|
||||
|
||||
public ViewGroup replaceFonts(ViewGroup viewTree) {
|
||||
return replaceFonts(this, viewTree);
|
||||
}
|
||||
|
||||
public View replaceFont(TextView view) {
|
||||
return replaceFont(this, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
this.onCreate(savedInstanceState, true);
|
||||
@ -65,7 +46,7 @@ public class MineActivity extends AppCompatActivity implements View.OnClickListe
|
||||
li.inflate(R.layout.top_bar, top, true);
|
||||
li.inflate(R.layout.bottom_bar, btm, true);
|
||||
|
||||
replaceFonts(btm);
|
||||
FontChanger.changeFonts(btm);
|
||||
|
||||
// replaceFont((TextView) top.findViewById(R.id.topbar_navmenu_changelang));
|
||||
Spinner changeLangSpinner = ((Spinner) top.findViewById(R.id.topbar_navmenu_changelang));
|
||||
@ -107,7 +88,7 @@ public class MineActivity extends AppCompatActivity implements View.OnClickListe
|
||||
}
|
||||
|
||||
li.inflate(resource, content, true);
|
||||
replaceFonts(content);
|
||||
FontChanger.changeFonts(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,7 +100,7 @@ public class MineActivity extends AppCompatActivity implements View.OnClickListe
|
||||
|
||||
content.addView(view);
|
||||
if (view instanceof ViewGroup) {
|
||||
replaceFonts((ViewGroup) view);
|
||||
FontChanger.changeFonts((ViewGroup) view);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,35 +4,31 @@ import android.content.res.*;
|
||||
import android.graphics.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import android.content.*;
|
||||
import com.kdt.mcgui.*;
|
||||
|
||||
public class FontChanger
|
||||
{
|
||||
private Typeface typeface;
|
||||
|
||||
public FontChanger(Typeface typeface) {
|
||||
this.typeface = typeface;
|
||||
}
|
||||
|
||||
public FontChanger(AssetManager assets, String assetsFontFileName) {
|
||||
typeface = Typeface.createFromAsset(assets, assetsFontFileName);
|
||||
}
|
||||
|
||||
public ViewGroup replaceFonts(ViewGroup viewTree)
|
||||
{
|
||||
View child;
|
||||
private static Typeface fNotoSans, fMinecraftTen;
|
||||
|
||||
public static void initFonts(Context ctx) {
|
||||
fNotoSans = Typeface.createFromAsset(ctx.getAssets(), "font/NotoSans-Bold.ttf");
|
||||
fMinecraftTen = Typeface.createFromAsset(ctx.getAssets(), "font/minecraft-ten.ttf");
|
||||
}
|
||||
|
||||
public static void changeFonts(ViewGroup viewTree) {
|
||||
View child;
|
||||
for(int i = 0; i < viewTree.getChildCount(); ++i) {
|
||||
child = viewTree.getChildAt(i);
|
||||
if (child instanceof ViewGroup) {
|
||||
replaceFonts((ViewGroup) child);
|
||||
changeFonts((ViewGroup) child);
|
||||
} else if (child instanceof TextView) {
|
||||
replaceFont((TextView) child);
|
||||
changeFont((TextView) child);
|
||||
}
|
||||
}
|
||||
return viewTree;
|
||||
}
|
||||
}
|
||||
|
||||
public View replaceFont(TextView view) {
|
||||
view.setTypeface(typeface);
|
||||
return view;
|
||||
public static void changeFont(TextView view) {
|
||||
view.setTypeface(view instanceof MineButton ? fMinecraftTen : fNotoSans);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ public class PojavApplication extends Application
|
||||
specialButtons[2].name = getString(R.string.control_primary);
|
||||
specialButtons[3].name = getString(R.string.control_secondary);
|
||||
specialButtons[4].name = getString(R.string.control_mouse);
|
||||
|
||||
FontChanger.initFonts(this);
|
||||
} catch (Throwable th) {
|
||||
Intent ferrorIntent = new Intent(this, FatalErrorActivity.class);
|
||||
ferrorIntent.putExtra("throwable", th);
|
||||
|
@ -133,7 +133,7 @@ public class PojavLoginActivity extends AppCompatActivity
|
||||
LinearLayout startScr = new LinearLayout(PojavLoginActivity.this);
|
||||
LayoutInflater.from(PojavLoginActivity.this).inflate(R.layout.start_screen, startScr);
|
||||
|
||||
MineActivity.replaceFonts(PojavLoginActivity.this, startScr);
|
||||
FontChanger.changeFonts(startScr);
|
||||
|
||||
progress = (ProgressBar) startScr.findViewById(R.id.startscreenProgress);
|
||||
//startScr.addView(progress);
|
||||
|
@ -49,20 +49,20 @@
|
||||
android:inputType="textPassword"
|
||||
android:layout_marginBottom="5dp"/>
|
||||
|
||||
<Switch
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/login_online_remember"
|
||||
android:layout_gravity="right"
|
||||
android:layout_gravity="left"
|
||||
android:text="@string/login_online_check_keeplogin"
|
||||
android:id="@+id/login_switch_remember"/>
|
||||
|
||||
<Switch
|
||||
<CheckBox
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:text="@string/login_offline_switch"
|
||||
android:layout_gravity="left"
|
||||
android:text="@string/login_offline_label"
|
||||
android:id="@+id/login_switch_offline"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -20,10 +20,12 @@
|
||||
<string name="login_online_password_hint">Password</string>
|
||||
<string name="login_online_password_question">Forgot password?</string>
|
||||
<string name="login_online_remember">Remember me?</string>
|
||||
<string name="login_online_check_keeplogin">Keep me logged in</string>
|
||||
<string name="login_online_login_label">Login</string>
|
||||
<string name="login_online_create_account">(Create new account?)</string>
|
||||
|
||||
<string name="login_offline_switch">Offline account?</string>
|
||||
<string name="login_offline_label">Login as offline account</string>
|
||||
<string name="login_offline_alert_skip">Skip</string>
|
||||
|
||||
<string name="login_error_short_username">Username must be at least 3 characters</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user