Skip to content

Commit 0522b48

Browse files
authored
Revert "Delete io.flutter.app android v1 embedding" (flutter#32232)
1 parent 7d93d6b commit 0522b48

File tree

14 files changed

+977
-9
lines changed

14 files changed

+977
-9
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,11 @@ FILE: ../../../flutter/shell/platform/android/flutter_main.h
11821182
FILE: ../../../flutter/shell/platform/android/flutter_shell_native_unittests.cc
11831183
FILE: ../../../flutter/shell/platform/android/io/flutter/FlutterInjector.java
11841184
FILE: ../../../flutter/shell/platform/android/io/flutter/Log.java
1185+
FILE: ../../../flutter/shell/platform/android/io/flutter/app/FlutterActivity.java
1186+
FILE: ../../../flutter/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java
1187+
FILE: ../../../flutter/shell/platform/android/io/flutter/app/FlutterActivityEvents.java
1188+
FILE: ../../../flutter/shell/platform/android/io/flutter/app/FlutterApplication.java
1189+
FILE: ../../../flutter/shell/platform/android/io/flutter/app/FlutterFragmentActivity.java
11851190
FILE: ../../../flutter/shell/platform/android/io/flutter/app/FlutterPlayStoreSplitApplication.java
11861191
FILE: ../../../flutter/shell/platform/android/io/flutter/app/FlutterPluginRegistry.java
11871192
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java

shell/platform/android/AndroidManifest.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,25 @@
33
Use of this source code is governed by a BSD-style license that can be
44
found in the LICENSE file.
55
-->
6-
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.flutter.embedding" android:versionCode="1" android:versionName="0.0.1">
6+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.flutter.app" android:versionCode="1" android:versionName="0.0.1">
77

88
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="31" />
99
<uses-permission android:name="android.permission.INTERNET" />
1010
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1111
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
1212

13+
<application android:label="Flutter Shell" android:name="FlutterApplication" android:debuggable="true">
14+
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
15+
android:hardwareAccelerated="true"
16+
android:launchMode="standard"
17+
android:name="FlutterActivity"
18+
android:theme="@android:style/Theme.Black.NoTitleBar"
19+
android:windowSoftInputMode="adjustResize"
20+
android:exported="true">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
<category android:name="android.intent.category.LAUNCHER" />
24+
</intent-filter>
25+
</activity>
26+
</application>
1327
</manifest>

shell/platform/android/BUILD.gn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ embedding_source_jar_path = "$root_out_dir/$embedding_sources_jar_filename"
153153
android_java_sources = [
154154
"io/flutter/FlutterInjector.java",
155155
"io/flutter/Log.java",
156+
"io/flutter/app/FlutterActivity.java",
157+
"io/flutter/app/FlutterActivityDelegate.java",
158+
"io/flutter/app/FlutterActivityEvents.java",
159+
"io/flutter/app/FlutterApplication.java",
160+
"io/flutter/app/FlutterFragmentActivity.java",
156161
"io/flutter/app/FlutterPlayStoreSplitApplication.java",
157162
"io/flutter/app/FlutterPluginRegistry.java",
158163
"io/flutter/embedding/android/AndroidTouchProcessor.java",
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.app;
6+
7+
import android.app.Activity;
8+
import android.content.Context;
9+
import android.content.Intent;
10+
import android.content.res.Configuration;
11+
import android.os.Bundle;
12+
import androidx.annotation.NonNull;
13+
import io.flutter.app.FlutterActivityDelegate.ViewFactory;
14+
import io.flutter.plugin.common.PluginRegistry;
15+
import io.flutter.view.FlutterNativeView;
16+
import io.flutter.view.FlutterView;
17+
18+
/**
19+
* Deprecated base class for activities that use Flutter.
20+
*
21+
* @deprecated {@link io.flutter.embedding.android.FlutterActivity} is the new API that now replaces
22+
* this class. See https://flutter.dev/go/android-project-migration for more migration details.
23+
*/
24+
@Deprecated
25+
public class FlutterActivity extends Activity
26+
implements FlutterView.Provider, PluginRegistry, ViewFactory {
27+
private static final String TAG = "FlutterActivity";
28+
29+
private final FlutterActivityDelegate delegate = new FlutterActivityDelegate(this, this);
30+
31+
// These aliases ensure that the methods we forward to the delegate adhere
32+
// to relevant interfaces versus just existing in FlutterActivityDelegate.
33+
private final FlutterActivityEvents eventDelegate = delegate;
34+
private final FlutterView.Provider viewProvider = delegate;
35+
private final PluginRegistry pluginRegistry = delegate;
36+
37+
/**
38+
* Returns the Flutter view used by this activity; will be null before {@link #onCreate(Bundle)}
39+
* is called.
40+
*/
41+
@Override
42+
public FlutterView getFlutterView() {
43+
return viewProvider.getFlutterView();
44+
}
45+
46+
/**
47+
* Hook for subclasses to customize the creation of the {@code FlutterView}.
48+
*
49+
* <p>The default implementation returns {@code null}, which will cause the activity to use a
50+
* newly instantiated full-screen view.
51+
*/
52+
@Override
53+
public FlutterView createFlutterView(Context context) {
54+
return null;
55+
}
56+
57+
/**
58+
* Hook for subclasses to customize the creation of the {@code FlutterNativeView}.
59+
*
60+
* <p>The default implementation returns {@code null}, which will cause the activity to use a
61+
* newly instantiated native view object.
62+
*/
63+
@Override
64+
public FlutterNativeView createFlutterNativeView() {
65+
return null;
66+
}
67+
68+
@Override
69+
public boolean retainFlutterNativeView() {
70+
return false;
71+
}
72+
73+
@Override
74+
public final boolean hasPlugin(String key) {
75+
return pluginRegistry.hasPlugin(key);
76+
}
77+
78+
@Override
79+
public final <T> T valuePublishedByPlugin(String pluginKey) {
80+
return pluginRegistry.valuePublishedByPlugin(pluginKey);
81+
}
82+
83+
@Override
84+
public final Registrar registrarFor(String pluginKey) {
85+
return pluginRegistry.registrarFor(pluginKey);
86+
}
87+
88+
@Override
89+
protected void onCreate(Bundle savedInstanceState) {
90+
super.onCreate(savedInstanceState);
91+
eventDelegate.onCreate(savedInstanceState);
92+
}
93+
94+
@Override
95+
protected void onStart() {
96+
super.onStart();
97+
eventDelegate.onStart();
98+
}
99+
100+
@Override
101+
protected void onResume() {
102+
super.onResume();
103+
eventDelegate.onResume();
104+
}
105+
106+
@Override
107+
protected void onDestroy() {
108+
eventDelegate.onDestroy();
109+
super.onDestroy();
110+
}
111+
112+
@Override
113+
public void onBackPressed() {
114+
if (!eventDelegate.onBackPressed()) {
115+
super.onBackPressed();
116+
}
117+
}
118+
119+
@Override
120+
protected void onStop() {
121+
eventDelegate.onStop();
122+
super.onStop();
123+
}
124+
125+
@Override
126+
protected void onPause() {
127+
super.onPause();
128+
eventDelegate.onPause();
129+
}
130+
131+
@Override
132+
protected void onPostResume() {
133+
super.onPostResume();
134+
eventDelegate.onPostResume();
135+
}
136+
137+
// @Override - added in API level 23
138+
public void onRequestPermissionsResult(
139+
int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
140+
eventDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
141+
}
142+
143+
@Override
144+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
145+
if (!eventDelegate.onActivityResult(requestCode, resultCode, data)) {
146+
super.onActivityResult(requestCode, resultCode, data);
147+
}
148+
}
149+
150+
@Override
151+
protected void onNewIntent(Intent intent) {
152+
eventDelegate.onNewIntent(intent);
153+
}
154+
155+
@Override
156+
public void onUserLeaveHint() {
157+
eventDelegate.onUserLeaveHint();
158+
}
159+
160+
@Override
161+
public void onTrimMemory(int level) {
162+
eventDelegate.onTrimMemory(level);
163+
}
164+
165+
@Override
166+
public void onLowMemory() {
167+
eventDelegate.onLowMemory();
168+
}
169+
170+
@Override
171+
public void onConfigurationChanged(Configuration newConfig) {
172+
super.onConfigurationChanged(newConfig);
173+
eventDelegate.onConfigurationChanged(newConfig);
174+
}
175+
}

0 commit comments

Comments
 (0)