Skip to content

Commit dec5d9a

Browse files
committed
refactoring
1 parent 7abcf54 commit dec5d9a

File tree

11 files changed

+41
-49
lines changed

11 files changed

+41
-49
lines changed

app/src/main/res/values/styles.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
<item name="alertDialogTheme">@style/AlertDialogTheme</item>
1212
</style>
1313

14-
<style name="SplashScreen" parent="@android:style/Theme.NoTitleBar.Fullscreen">
15-
<item name="android:windowBackground">@drawable/splash_screen</item>
16-
</style>
17-
1814
<style name="AppErrorTheme" parent="@style/Theme.Material3.DayNight">
1915
<item name="colorPrimary">#444444</item>
2016
<item name="colorPrimaryDark">#212121</item>

minecraft/src/main/AndroidManifest.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@
3535

3636
<application>
3737

38-
<!-- <activity-->
39-
<!-- android:name="com.mojang.minecraftpe.MainActivity"-->
40-
<!-- android:alwaysRetainTaskState="true"-->
41-
<!-- android:configChanges="fontScale|keyboard|keyboardHidden|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"-->
42-
<!-- android:excludeFromRecents="false"-->
43-
<!-- android:exported="true"-->
44-
<!-- android:launchMode="singleTask"-->
45-
<!-- android:screenOrientation="sensorLandscape" />-->
46-
4738
<meta-data
4839
android:name="appcenter_android_trial_id"
4940
android:value="@string/appcenter_android_id" />

xbox/src/main/AndroidManifest.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
android:configChanges="orientation"
99
android:exported="true"
1010
android:launchMode="singleTask"
11-
android:screenOrientation="sensorLandscape">
11+
android:screenOrientation="sensorLandscape"
12+
android:theme="@style/AppTheme">
1213
<intent-filter>
1314
<action android:name="android.intent.action.VIEW" />
1415
<data
@@ -21,17 +22,18 @@
2122
</activity>
2223

2324
<activity
24-
android:theme="@style/AppTheme"
2525
android:name="com.microsoft.xal.browser.WebKitWebViewController"
2626
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize"
27-
android:screenOrientation="sensorLandscape" />
27+
android:screenOrientation="sensorLandscape"
28+
android:theme="@style/AppTheme" />
2829

2930
<activity
3031
android:name="com.microsoft.xal.browser.BrowserLaunchActivity"
3132
android:configChanges="orientation"
3233
android:exported="false"
3334
android:launchMode="singleTask"
34-
android:screenOrientation="sensorLandscape" />
35+
android:screenOrientation="sensorLandscape"
36+
android:theme="@style/AppTheme" />
3537

3638
</application>
3739

File renamed without changes.
File renamed without changes.

xbox/src/main/java/com/microsoft/xal/browser/BrowserLaunchActivity.java

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import androidx.annotation.NonNull;
2626
import androidx.annotation.Nullable;
27+
import androidx.appcompat.app.AppCompatActivity;
2728
import androidx.browser.customtabs.CustomTabsIntent;
2829

2930
/**
@@ -33,7 +34,7 @@
3334
* @author https://github.com/TimScriptov
3435
*/
3536
@SuppressWarnings("JavaJniMissingFunction")
36-
public class BrowserLaunchActivity extends Activity {
37+
public class BrowserLaunchActivity extends AppCompatActivity {
3738
public static final String END_URL = "END_URL";
3839
public static final String IN_PROC_BROWSER = "IN_PROC_BROWSER";
3940
public static final String OPERATION_ID = "OPERATION_ID";
@@ -63,16 +64,16 @@ public class BrowserLaunchActivity extends Activity {
6364

6465
public static void showUrl(long operationId, Context context, @NonNull String startUrl, String endUrl, int showTypeInt, String[] requestHeaderKeys, String[] requestHeaderValues, boolean useInProcBrowser) {
6566
if (!startUrl.isEmpty() && !endUrl.isEmpty()) {
66-
ShowUrlType fromInt = ShowUrlType.fromInt(showTypeInt);
67+
final ShowUrlType fromInt = ShowUrlType.fromInt(showTypeInt);
6768
if (fromInt == null) {
6869
urlOperationFailed(operationId, false, null);
6970
return;
7071
} else if (requestHeaderKeys.length != requestHeaderValues.length) {
7172
urlOperationFailed(operationId, false, null);
7273
return;
7374
} else {
74-
Intent intent = new Intent(context, BrowserLaunchActivity.class);
75-
Bundle bundle = new Bundle();
75+
final Intent intent = new Intent(context, BrowserLaunchActivity.class);
76+
final Bundle bundle = new Bundle();
7677
bundle.putLong(OPERATION_ID, operationId);
7778
bundle.putString(START_URL, startUrl);
7879
bundle.putString(END_URL, endUrl);
@@ -92,7 +93,7 @@ public static void showUrl(long operationId, Context context, @NonNull String st
9293
@Override
9394
public void onCreate(Bundle bundle) {
9495
super.onCreate(bundle);
95-
Bundle extras = getIntent().getExtras();
96+
final Bundle extras = getIntent().getExtras();
9697
if (!checkNativeCodeLoaded()) {
9798
startActivity(getApplicationContext().getPackageManager().getLaunchIntentForPackage(getApplicationContext().getPackageName()));
9899
finish();
@@ -103,7 +104,7 @@ public void onCreate(Bundle bundle) {
103104
m_browserInfo = bundle.getString(BROWSER_INFO_STATE_KEY);
104105
} else if (extras != null) {
105106
m_operationId = extras.getLong(OPERATION_ID, 0L);
106-
BrowserLaunchParameters FromArgs = BrowserLaunchParameters.FromArgs(extras);
107+
final BrowserLaunchParameters FromArgs = BrowserLaunchParameters.FromArgs(extras);
107108
m_launchParameters = FromArgs;
108109
if (FromArgs != null && m_operationId != 0) {
109110
return;
@@ -121,14 +122,14 @@ public void onCreate(Bundle bundle) {
121122
@Override
122123
protected void onResume() {
123124
super.onResume();
124-
boolean z = m_customTabsInProgress;
125+
final boolean z = m_customTabsInProgress;
125126
if (!z && m_launchParameters != null) {
126-
BrowserLaunchParameters browserLaunchParameters = m_launchParameters;
127+
final BrowserLaunchParameters browserLaunchParameters = m_launchParameters;
127128
m_launchParameters = null;
128129
startAuthSession(browserLaunchParameters);
129130
} else if (z) {
130131
m_customTabsInProgress = false;
131-
Uri data = getIntent().getData();
132+
final Uri data = getIntent().getData();
132133
if (data != null) {
133134
finishOperation(WebResult.SUCCESS, data.toString());
134135
return;
@@ -154,14 +155,15 @@ public void onNewIntent(Intent intent) {
154155

155156
@Override
156157
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
158+
super.onActivityResult(requestCode, resultCode, intent);
157159
if (requestCode == WEB_KIT_WEB_VIEW_REQUEST) {
158-
if (resultCode == -1) {
159-
String string = intent.getExtras().getString(WebKitWebViewController.RESPONSE_KEY, "");
160+
if (resultCode == RESULT_OK) {
161+
final String string = intent.getExtras().getString(WebKitWebViewController.RESPONSE_KEY, "");
160162
if (!string.isEmpty()) {
161163
finishOperation(WebResult.SUCCESS, string);
162164
return;
163165
}
164-
} else if (resultCode == 0) {
166+
} else if (resultCode == RESULT_CANCELED) {
165167
finishOperation(WebResult.CANCEL, null);
166168
return;
167169
}
@@ -179,9 +181,9 @@ protected void onDestroy() {
179181
}
180182

181183
private void startAuthSession(@NonNull BrowserLaunchParameters browserLaunchParameters) {
182-
BrowserSelectionResult selectBrowser = BrowserSelector.selectBrowser(getApplicationContext(), browserLaunchParameters.UseInProcBrowser);
184+
final BrowserSelectionResult selectBrowser = BrowserSelector.selectBrowser(getApplicationContext(), browserLaunchParameters.UseInProcBrowser);
183185
m_browserInfo = selectBrowser.toString();
184-
String packageName = selectBrowser.packageName();
186+
final String packageName = selectBrowser.packageName();
185187
if (packageName == null) {
186188
startWebView(browserLaunchParameters.StartUrl, browserLaunchParameters.EndUrl, browserLaunchParameters.ShowType, browserLaunchParameters.RequestHeaderKeys, browserLaunchParameters.RequestHeaderValues);
187189
return;
@@ -196,18 +198,18 @@ private void startCustomTabsInBrowser(String packageName, String startUrl, Strin
196198
}
197199
m_customTabsInProgress = true;
198200
m_sharedBrowserUsed = true;
199-
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
201+
final CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
200202
builder.setShowTitle(true);
201-
CustomTabsIntent build = builder.build();
203+
final CustomTabsIntent build = builder.build();
202204
build.intent.setData(Uri.parse(startUrl));
203205
build.intent.setPackage(packageName);
204206
startActivity(build.intent);
205207
}
206208

207209
private void startWebView(String startUrl, String endUrl, ShowUrlType showUrlType, String[] requestHeaderKeys, String[] requestHeaderValues) {
208210
m_sharedBrowserUsed = false;
209-
Intent intent = new Intent(getApplicationContext(), WebKitWebViewController.class);
210-
Bundle bundle = new Bundle();
211+
final Intent intent = new Intent(getApplicationContext(), WebKitWebViewController.class);
212+
final Bundle bundle = new Bundle();
211213
bundle.putString(START_URL, startUrl);
212214
bundle.putString(END_URL, endUrl);
213215
bundle.putSerializable(SHOW_TYPE, showUrlType);
@@ -218,13 +220,13 @@ private void startWebView(String startUrl, String endUrl, ShowUrlType showUrlTyp
218220
}
219221

220222
private void finishOperation(WebResult webResult, String finalUrl) {
221-
long j = m_operationId;
223+
final long j = m_operationId;
222224
m_operationId = 0L;
223225
finish();
224226
if (j == 0) {
225227
return;
226228
}
227-
int result = XalWebResult.mWebResult[webResult.ordinal()];
229+
final int result = XalWebResult.mWebResult[webResult.ordinal()];
228230
if (result == 1) {
229231
urlOperationSucceeded(j, finalUrl, m_sharedBrowserUsed, m_browserInfo);
230232
} else if (result == 2) {
@@ -269,12 +271,12 @@ private BrowserLaunchParameters(String startUrl, String endUrl, String[] request
269271

270272
@Nullable
271273
public static BrowserLaunchParameters FromArgs(@NonNull Bundle bundle) {
272-
String startUrl = bundle.getString(START_URL);
273-
String endUrl = bundle.getString(END_URL);
274-
String[] headerKeys = bundle.getStringArray(REQUEST_HEADER_KEYS);
275-
String[] headerValues = bundle.getStringArray(REQUEST_HEADER_VALUES);
276-
ShowUrlType showUrlType = (ShowUrlType) bundle.get(SHOW_TYPE);
277-
boolean z = bundle.getBoolean(BrowserLaunchActivity.IN_PROC_BROWSER);
274+
final String startUrl = bundle.getString(START_URL);
275+
final String endUrl = bundle.getString(END_URL);
276+
final String[] headerKeys = bundle.getStringArray(REQUEST_HEADER_KEYS);
277+
final String[] headerValues = bundle.getStringArray(REQUEST_HEADER_VALUES);
278+
final ShowUrlType showUrlType = (ShowUrlType) bundle.get(SHOW_TYPE);
279+
final boolean z = bundle.getBoolean(BrowserLaunchActivity.IN_PROC_BROWSER);
278280
if (startUrl == null || endUrl == null || headerKeys == null || headerValues == null || headerKeys.length != headerValues.length) {
279281
return null;
280282
}

xbox/src/main/java/com/microsoft/xal/browser/IntentHandler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@
1616
*/
1717
package com.microsoft.xal.browser;
1818

19-
import android.app.Activity;
2019
import android.content.Intent;
2120
import android.os.Bundle;
2221

22+
import androidx.appcompat.app.AppCompatActivity;
23+
2324
/**
2425
* 13.08.2022
2526
*
2627
* @author Тимашков Иван
2728
* @author https://github.com/TimScriptov
2829
*/
29-
public class IntentHandler extends Activity {
30+
public class IntentHandler extends AppCompatActivity {
3031
@Override
3132
public void onCreate(Bundle bundle) {
3233
super.onCreate(bundle);
3334
Intent intent = new Intent(this, BrowserLaunchActivity.class);
3435
intent.setData(getIntent().getData());
35-
intent.addFlags(603979776);
36+
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
3637
startActivity(intent);
3738
finish();
3839
}

0 commit comments

Comments
 (0)