Skip to content

Commit 29c0251

Browse files
committed
Move LauncherClient to google package
Signed-off-by: Saul Henriquez <saul_henriquez@hotmail.com>
1 parent deeedd1 commit 29c0251

File tree

15 files changed

+99
-42
lines changed

15 files changed

+99
-42
lines changed

Omega/src/com/neoapps/launcherclient/BaseClientService.kt renamed to Omega/src/com/google/android/libraries/launcherclient/BaseClientService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
package com.neoapps.launcherclient
19+
package com.google.android.libraries.launcherclient
2020

2121
import android.content.ComponentName
2222
import android.content.Context

Omega/src/com/neoapps/launcherclient/IScrollCallback.kt renamed to Omega/src/com/google/android/libraries/launcherclient/IScrollCallback.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.neoapps.launcherclient
1+
package com.google.android.libraries.launcherclient
22

33
interface IScrollCallback {
44
fun onOverlayScrollChanged(progress: Float)

Omega/src/com/neoapps/launcherclient/ISerializableScrollCallback.kt renamed to Omega/src/com/google/android/libraries/launcherclient/ISerializableScrollCallback.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.neoapps.launcherclient
1+
package com.google.android.libraries.launcherclient
22

33
interface ISerializableScrollCallback : IScrollCallback {
44
fun setPersistentFlags(myFlags: Int)

Omega/src/com/neoapps/launcherclient/LauncherClient.java renamed to Omega/src/com/google/android/libraries/launcherclient/LauncherClient.java

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
package com.neoapps.launcherclient;
19+
package com.google.android.libraries.launcherclient;
2020

2121
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
2222

@@ -41,8 +41,7 @@
4141
import android.view.WindowManager;
4242
import android.view.WindowManager.LayoutParams;
4343

44-
import com.google.android.libraries.launcherclient.ILauncherOverlay;
45-
import com.google.android.libraries.launcherclient.ILauncherOverlayCallback;
44+
import com.android.launcher3.qsb.OSEManager;
4645
import com.neoapps.neolauncher.preferences.NeoPrefs;
4746

4847
import java.lang.ref.WeakReference;
@@ -63,7 +62,7 @@ public void onReceive(Context context, Intent intent) {
6362
mLauncherService.disconnect();
6463
LauncherClient.loadApiVersion(context);
6564
if ((mActivityState & 2) != 0) {
66-
reconnect();
65+
connect();
6766
}
6867
}
6968
};
@@ -79,9 +78,6 @@ public void onReceive(Context context, Intent intent) {
7978
public boolean mDestroyed = false;
8079
private Bundle mLayoutBundle;
8180

82-
private NeoPrefs prefs;
83-
private String feedProvider = "";
84-
8581
public class OverlayCallback extends ILauncherOverlayCallback.Stub implements Callback {
8682
public LauncherClient mClient;
8783
private final Handler mUIHandler = new Handler(Looper.getMainLooper(), this);
@@ -142,7 +138,6 @@ public boolean handleMessage(Message message) {
142138

143139
public LauncherClient(Activity activity, IScrollCallback scrollCallback, StaticInteger flags) {
144140
mActivity = activity;
145-
prefs = NeoPrefs.getInstance();
146141
mScrollCallback = scrollCallback;
147142
mBaseService = new BaseClientService(activity, Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT);
148143
mFlags = flags.mData;
@@ -160,14 +155,22 @@ public LauncherClient(Activity activity, IScrollCallback scrollCallback, StaticI
160155
loadApiVersion(activity);
161156
}
162157

163-
reconnect();
158+
connect();
164159
if (mActivity.getWindow() != null &&
165160
mActivity.getWindow().peekDecorView() != null &&
166161
mActivity.getWindow().peekDecorView().isAttachedToWindow()) {
167162
onAttachedToWindow();
168163
}
169164
}
170165

166+
public void setEnableFeed(boolean enable) {
167+
if (enable) {
168+
mFlags |= 1;
169+
} else {
170+
mFlags &= ~1;
171+
}
172+
}
173+
171174
public final void onAttachedToWindow() {
172175
if (!mDestroyed) {
173176
setLayoutParams(mActivity.getWindow().getAttributes());
@@ -215,7 +218,7 @@ public final void onPause() {
215218
public final void onStart() {
216219
if (!mDestroyed) {
217220
mLauncherService.setStopped(false);
218-
reconnect();
221+
connect();
219222
mActivityState |= 1;
220223
if (mOverlay != null && mLayoutParams != null) {
221224
try {
@@ -252,12 +255,21 @@ public void onDestroy() {
252255
}
253256
}
254257

255-
private void reconnect() {
258+
private void connect() {
256259
if (!mDestroyed && (!mLauncherService.connect() || !mBaseService.connect())) {
257260
mActivity.runOnUiThread(() -> setServiceState(0));
258261
}
259262
}
260263

264+
public void reconnect() {
265+
mBaseService.disconnect();
266+
mLauncherService.disconnect();
267+
LauncherClient.loadApiVersion(mActivity);
268+
if ((mActivityState & 2) != 0) {
269+
connect();
270+
}
271+
}
272+
261273
public final void setLayoutParams(LayoutParams layoutParams) {
262274
if (mLayoutParams != layoutParams) {
263275
mLayoutParams = layoutParams;
@@ -419,7 +431,7 @@ private void setServiceState(int serviceState) {
419431
static Intent getIntent(Context context, boolean proxy) {
420432
String pkg = context.getPackageName();
421433
NeoPrefs prefs = NeoPrefs.getInstance();
422-
return new Intent("com.android.launcher3.WINDOW_OVERLAY")
434+
return new Intent(OSEManager.OVERLAY_ACTION)
423435
.setPackage(prefs.getFeedProvider().getValue())
424436
.setData(Uri.parse("app://" +
425437
pkg +

Omega/src/com/neoapps/launcherclient/LauncherClientBridge.java renamed to Omega/src/com/google/android/libraries/launcherclient/LauncherClientBridge.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
package com.neoapps.launcherclient;
1+
package com.google.android.libraries.launcherclient;
22

33
import android.content.ComponentName;
44
import android.content.ServiceConnection;
55
import android.os.IBinder;
66
import android.os.RemoteException;
77

8-
import com.neoapps.launcherclient.BaseClientService;
9-
108
import amirz.aidlbridge.IBridge;
119
import amirz.aidlbridge.IBridgeCallback;
1210

Omega/src/com/neoapps/launcherclient/LauncherClientCallbacks.kt renamed to Omega/src/com/google/android/libraries/launcherclient/LauncherClientCallbacks.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
package com.neoapps.launcherclient
19+
package com.google.android.libraries.launcherclient
2020

2121
interface LauncherClientCallbacks {
2222
fun onServiceStateChanged(overlayAttached: Boolean, hotwordActive: Boolean)

Omega/src/com/neoapps/launcherclient/LauncherClientService.java renamed to Omega/src/com/google/android/libraries/launcherclient/LauncherClientService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
package com.neoapps.launcherclient;
1+
package com.google.android.libraries.launcherclient;
22

33
import android.content.ComponentName;
44
import android.content.Context;
55
import android.os.IBinder;
66

7-
import com.google.android.libraries.launcherclient.ILauncherOverlay;
8-
import com.neoapps.launcherclient.BaseClientService;
9-
import com.neoapps.launcherclient.LauncherClient;
10-
117
import java.lang.ref.WeakReference;
128

139
public class LauncherClientService extends BaseClientService {

Omega/src/com/neoapps/launcherclient/StaticInteger.kt renamed to Omega/src/com/google/android/libraries/launcherclient/StaticInteger.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
package com.neoapps.launcherclient
19+
package com.google.android.libraries.launcherclient
2020

2121
class StaticInteger(data: Int) {
2222
@JvmField

Omega/src/com/neoapps/neolauncher/NeoLauncher.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import androidx.activity.result.contract.ActivityResultContracts.StartActivityFo
4242
import androidx.activity.result.contract.ActivityResultContracts.StartIntentSenderForResult
4343
import androidx.core.app.ActivityCompat
4444
import androidx.core.app.ActivityOptionsCompat
45+
import androidx.lifecycle.lifecycleScope
4546
import androidx.savedstate.SavedStateRegistry
4647
import androidx.savedstate.SavedStateRegistryController
4748
import androidx.savedstate.SavedStateRegistryOwner
@@ -69,14 +70,19 @@ import com.neoapps.neolauncher.theme.ThemeOverride
6970
import com.neoapps.neolauncher.util.Config
7071
import com.neoapps.neolauncher.util.Permissions
7172
import com.neoapps.neolauncher.util.hasStoragePermission
73+
import com.neoapps.neolauncher.util.unsafeLazy
7274
import kotlinx.coroutines.CoroutineScope
7375
import kotlinx.coroutines.Dispatchers
76+
import kotlinx.coroutines.flow.distinctUntilChanged
77+
import kotlinx.coroutines.flow.launchIn
78+
import kotlinx.coroutines.flow.onEach
7479
import kotlinx.coroutines.launch
7580
import org.koin.android.ext.android.inject
7681
import java.util.stream.Stream
7782

7883
class NeoLauncher : Launcher(), SavedStateRegistryOwner,
7984
ActivityResultRegistryOwner, ThemeManager.ThemeableActivity {
85+
private val defaultOverlay by unsafeLazy { OverlayCallbackImpl(this) }
8086
val prefs: NeoPrefs by inject()
8187
private val prefCallback = PreferencesChangeCallback(this)
8288
private var paused = false
@@ -126,6 +132,10 @@ class NeoLauncher : Launcher(), SavedStateRegistryOwner,
126132
}
127133
}
128134
}, null)
135+
prefs.feedProvider.get().distinctUntilChanged().onEach { provider ->
136+
val enable = provider != ""
137+
defaultOverlay.setEnableFeed(enable)
138+
}.launchIn(scope = lifecycleScope)
129139

130140
themeOverride = ThemeOverride(themeSet, this)
131141
themeOverride.applyTheme(this)
@@ -267,12 +277,7 @@ class NeoLauncher : Launcher(), SavedStateRegistryOwner,
267277
)
268278
}
269279

270-
override fun getDefaultOverlay(): LauncherOverlayManager {
271-
if (mOverlayManager == null) {
272-
mOverlayManager = OverlayCallbackImpl(this)
273-
}
274-
return mOverlayManager
275-
}
280+
override fun getDefaultOverlay(): LauncherOverlayManager = defaultOverlay
276281

277282
override fun onUiChangedWhileSleeping() {
278283
if (Utilities.ATLEAST_S) {

Omega/src/com/neoapps/neolauncher/OverlayCallbackImpl.kt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package com.neoapps.neolauncher
2020

21+
import android.util.Log
2122
import android.view.MotionEvent
2223
import androidx.core.content.edit
2324
import androidx.lifecycle.lifecycleScope
@@ -26,10 +27,10 @@ import com.android.launcher3.LauncherPrefs
2627
import com.android.systemui.plugins.shared.LauncherOverlayManager
2728
import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayCallbacks
2829
import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayTouchProxy
29-
import com.neoapps.launcherclient.IScrollCallback
30-
import com.neoapps.launcherclient.LauncherClient
31-
import com.neoapps.launcherclient.LauncherClientCallbacks
32-
import com.neoapps.launcherclient.StaticInteger
30+
import com.google.android.libraries.launcherclient.IScrollCallback
31+
import com.google.android.libraries.launcherclient.LauncherClient
32+
import com.google.android.libraries.launcherclient.LauncherClientCallbacks
33+
import com.google.android.libraries.launcherclient.StaticInteger
3334
import com.neoapps.neolauncher.preferences.NeoPrefs
3435
import kotlinx.coroutines.Job
3536
import kotlinx.coroutines.launch
@@ -55,6 +56,20 @@ class OverlayCallbackImpl(val launcher: Launcher) : LauncherOverlayTouchProxy,
5556
)
5657
}
5758

59+
fun reconnect() {
60+
mClient?.reconnect()
61+
}
62+
63+
fun setEnableFeed(enable: Boolean) {
64+
feedEnabled = enable
65+
mClient?.setEnableFeed(enable)
66+
reconnect()
67+
}
68+
69+
override fun onDeviceProvideChanged() {
70+
mClient?.redraw()
71+
}
72+
5873
override fun onAttachedToWindow() {
5974
job = launcher.launcher.lifecycleScope.launch {
6075
prefs.feedProvider.get().collect {
@@ -78,6 +93,7 @@ class OverlayCallbackImpl(val launcher: Launcher) : LauncherOverlayTouchProxy,
7893

7994

8095
override fun openOverlay() {
96+
Log.d("OverlayCallbackImpl", "openOverlay")
8197
mClient!!.showOverlay(true)
8298
}
8399

@@ -98,10 +114,6 @@ class OverlayCallbackImpl(val launcher: Launcher) : LauncherOverlayTouchProxy,
98114

99115
}
100116

101-
override fun setOverlayCallbacks(callbacks: LauncherOverlayCallbacks) {
102-
mLauncherOverlayCallbacks = callbacks
103-
}
104-
105117
override fun onOverlayScrollChanged(progress: Float) {
106118
if (mLauncherOverlayCallbacks != null) {
107119
mLauncherOverlayCallbacks!!.onOverlayScrollChanged(progress)
@@ -123,6 +135,10 @@ class OverlayCallbackImpl(val launcher: Launcher) : LauncherOverlayTouchProxy,
123135
mClient?.onDestroy()
124136
}
125137

138+
override fun setOverlayCallbacks(callbacks: LauncherOverlayCallbacks) {
139+
mLauncherOverlayCallbacks = callbacks
140+
}
141+
126142
override fun setPersistentFlags(myFlags: Int) {
127143
val newFlags = myFlags and (8 or 16)
128144
if (newFlags != mFlags) {

0 commit comments

Comments
 (0)