From 6cf932b2a714a1011849b3b2eb2fce8d0808f4aa Mon Sep 17 00:00:00 2001 From: "Yevhen Babiichuk (DustDFG)" Date: Fri, 9 Jan 2026 11:51:41 +0200 Subject: [PATCH] Convert newpipe/ExitActivity to kotlin --- .../java/org/schabi/newpipe/ExitActivity.java | 50 ------------------- .../java/org/schabi/newpipe/ExitActivity.kt | 38 ++++++++++++++ 2 files changed, 38 insertions(+), 50 deletions(-) delete mode 100644 app/src/main/java/org/schabi/newpipe/ExitActivity.java create mode 100644 app/src/main/java/org/schabi/newpipe/ExitActivity.kt diff --git a/app/src/main/java/org/schabi/newpipe/ExitActivity.java b/app/src/main/java/org/schabi/newpipe/ExitActivity.java deleted file mode 100644 index bd1351f0c..000000000 --- a/app/src/main/java/org/schabi/newpipe/ExitActivity.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.schabi.newpipe; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; - -import org.schabi.newpipe.util.NavigationHelper; - -/* - * Copyright (C) Hans-Christoph Steiner 2016 - * ExitActivity.java is part of NewPipe. - * - * NewPipe is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * NewPipe is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NewPipe. If not, see . - */ - -public class ExitActivity extends Activity { - - public static void exitAndRemoveFromRecentApps(final Activity activity) { - final Intent intent = new Intent(activity, ExitActivity.class); - - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS - | Intent.FLAG_ACTIVITY_CLEAR_TASK - | Intent.FLAG_ACTIVITY_NO_ANIMATION); - - activity.startActivity(intent); - } - - @SuppressLint("NewApi") - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - finishAndRemoveTask(); - - NavigationHelper.restartApp(this); - } -} diff --git a/app/src/main/java/org/schabi/newpipe/ExitActivity.kt b/app/src/main/java/org/schabi/newpipe/ExitActivity.kt new file mode 100644 index 000000000..854a07c43 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/ExitActivity.kt @@ -0,0 +1,38 @@ +/* + * SPDX-FileCopyrightText: 2016-2026 NewPipe contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package org.schabi.newpipe + +import android.annotation.SuppressLint +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import org.schabi.newpipe.util.NavigationHelper +class ExitActivity : Activity() { + @SuppressLint("NewApi") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + finishAndRemoveTask() + + NavigationHelper.restartApp(this) + } + + companion object { + @JvmStatic + fun exitAndRemoveFromRecentApps(activity: Activity) { + val intent = Intent(activity, ExitActivity::class.java) + + intent.addFlags( + Intent.FLAG_ACTIVITY_NEW_TASK + or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS + or Intent.FLAG_ACTIVITY_CLEAR_TASK + or Intent.FLAG_ACTIVITY_NO_ANIMATION + ) + + activity.startActivity(intent) + } + } +}