Skip to content

Commit 3918305

Browse files
devlearnerStypox
authored andcommitted
Ensure our transparent activity doesn't block touch events to underlying windows
so we won't hold up UI while fetching media info for Add to Playlist or Download actions lest user might think it freezes when in fact a network request is underway
1 parent c1f37d8 commit 3918305

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

app/src/main/java/org/schabi/newpipe/RouterActivity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import android.view.LayoutInflater;
1717
import android.view.View;
1818
import android.view.ViewGroup;
19+
import android.view.WindowManager;
1920
import android.widget.Button;
2021
import android.widget.RadioButton;
2122
import android.widget.RadioGroup;
@@ -120,6 +121,14 @@ protected void onCreate(final Bundle savedInstanceState) {
120121
? R.style.RouterActivityThemeLight : R.style.RouterActivityThemeDark);
121122
Localization.assureCorrectAppLanguage(this);
122123

124+
// Pass-through touch events to background activities
125+
// so that our transparent window won't lock UI in the mean time
126+
// network request is underway before showing PlaylistDialog or DownloadDialog
127+
// (courtesy of https://stackoverflow.com/a/10606141)
128+
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
129+
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
130+
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
131+
123132
super.onCreate(savedInstanceState);
124133
Icepick.restoreInstanceState(this, savedInstanceState);
125134

0 commit comments

Comments
 (0)