Minor cleanup, UI size fixes

This commit is contained in:
khanhduytran0 2020-12-17 13:00:38 +07:00
parent 7d7f0de7e2
commit 9e4b648263
2 changed files with 41 additions and 38 deletions

View File

@ -296,51 +296,16 @@ public class PojavLoginActivity extends BaseActivity
Tools.updateWindowSize(this); Tools.updateWindowSize(this);
final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
final View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(uiOptions);
if (loginLayout != null && imageLogo != null) { if (loginLayout != null && imageLogo != null) {
imageLogo.setTranslationY(loginLayout.getY() - (imageLogo.getHeight() / 2f)); imageLogo.setTranslationY(loginLayout.getY() - (imageLogo.getHeight() / 2f));
} }
// Clear current profile // Clear current profile
PojavProfile.setCurrentProfile(this, null); PojavProfile.setCurrentProfile(this, null);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Uri data = intent.getData();
Log.i("MicroAuth",data.toString());
if (data != null && data.getScheme().equals("ms-xal-00000000402b5328") && data.getHost().equals("auth")) {
String error = data.getQueryParameter("error");
String error_description = data.getQueryParameter("error_description");
if (error != null) {
// "The user has denied access to the scope requested by the client application": user pressed Cancel button, skip it
if (!error_description.startsWith("The user has denied access to the scope requested by the client application")) {
Toast.makeText(this, "Error: " + error + ": " + error_description, Toast.LENGTH_LONG).show();
}
} else {
String code = data.getQueryParameter("code");
new MicrosoftAuthTask(this, new RefreshListener(){
@Override
public void onFailed(Throwable e) {
Tools.showError(PojavLoginActivity.this, e);
}
@Override
public void onSuccess(MinecraftAccount b) {
mProfile = b;
playProfile(false);
}
}).execute("false", code);
// Toast.makeText(this, "Logged in to Microsoft account, but NYI", Toast.LENGTH_LONG).show();
}
}
} }
private boolean isJavaRuntimeInstalled(AssetManager am) { private boolean isJavaRuntimeInstalled(AssetManager am) {
boolean prefValue = firstLaunchPrefs.getBoolean(PREF_IS_INSTALLED_JAVARUNTIME, false); boolean prefValue = firstLaunchPrefs.getBoolean(PREF_IS_INSTALLED_JAVARUNTIME, false);
try { try {
@ -664,6 +629,39 @@ public class PojavLoginActivity extends BaseActivity
CustomTabs.openTab(this, "https://login.live.com/oauth20_authorize.srf?client_id=00000000402b5328&response_type=code&scope=service%3A%3Auser.auth.xboxlive.com%3A%3AMBI_SSL&redirect_url=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf"); CustomTabs.openTab(this, "https://login.live.com/oauth20_authorize.srf?client_id=00000000402b5328&response_type=code&scope=service%3A%3Auser.auth.xboxlive.com%3A%3AMBI_SSL&redirect_url=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf");
} }
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Uri data = intent.getData();
Log.i("MicroAuth", data.toString());
if (data != null && data.getScheme().equals("ms-xal-00000000402b5328") && data.getHost().equals("auth")) {
String error = data.getQueryParameter("error");
String error_description = data.getQueryParameter("error_description");
if (error != null) {
// "The user has denied access to the scope requested by the client application": user pressed Cancel button, skip it
if (!error_description.startsWith("The user has denied access to the scope requested by the client application")) {
Toast.makeText(this, "Error: " + error + ": " + error_description, Toast.LENGTH_LONG).show();
}
} else {
String code = data.getQueryParameter("code");
new MicrosoftAuthTask(this, new RefreshListener(){
@Override
public void onFailed(Throwable e) {
Tools.showError(PojavLoginActivity.this, e);
}
@Override
public void onSuccess(MinecraftAccount b) {
mProfile = b;
playProfile(false);
}
}).execute("false", code);
// Toast.makeText(this, "Logged in to Microsoft account, but NYI", Toast.LENGTH_LONG).show();
}
}
}
public void loginSavedAcc(View view) { public void loginSavedAcc(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
@ -737,7 +735,7 @@ public class PojavLoginActivity extends BaseActivity
@Override @Override
public void onSuccess(MinecraftAccount b) { public void onSuccess(MinecraftAccount b) {
mProfile = b; mProfile = b;
playProfile(false); playProfile(true);
} }
}).execute("true", acc.msaRefreshToken); }).execute("true", acc.msaRefreshToken);
} else if (acc.accessToken.length() >= 5) { } else if (acc.accessToken.length() >= 5) {

View File

@ -302,6 +302,11 @@ public final class Tools
currentDisplayMetrics = getDisplayMetrics(ctx); currentDisplayMetrics = getDisplayMetrics(ctx);
CallbackBridge.windowWidth = currentDisplayMetrics.widthPixels; CallbackBridge.windowWidth = currentDisplayMetrics.widthPixels;
CallbackBridge.windowHeight = currentDisplayMetrics.heightPixels; CallbackBridge.windowHeight = currentDisplayMetrics.heightPixels;
if (CallbackBridge.windowWidth < CallbackBridge.windowHeight) {
CallbackBridge.windowWidth = currentDisplayMetrics.heightPixels;
CallbackBridge.windowHeight = currentDisplayMetrics.widthPixels;
}
} }
public static float dpToPx(float dp) { public static float dpToPx(float dp) {