android: Replace deprecated onBackPressed() and enable predictive back gestures
Doesn't really make a difference it seems.
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/ApplicationTheme"
|
android:theme="@style/ApplicationTheme"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
|
android:enableOnBackInvokedCallback="true"
|
||||||
android:allowBackup="false" >
|
android:allowBackup="false" >
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.MainActivity"
|
android:name=".ui.MainActivity"
|
||||||
|
|||||||
+11
-7
@@ -22,6 +22,7 @@ import android.view.MenuItem;
|
|||||||
|
|
||||||
import org.strongswan.android.data.VpnProfileDataSource;
|
import org.strongswan.android.data.VpnProfileDataSource;
|
||||||
|
|
||||||
|
import androidx.activity.OnBackPressedCallback;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@@ -40,6 +41,16 @@ public class SelectedApplicationsActivity extends AppCompatActivity
|
|||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handleOnBackPressed()
|
||||||
|
{
|
||||||
|
prepareResult();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
FragmentManager fm = getSupportFragmentManager();
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
mApps = (SelectedApplicationsListFragment)fm.findFragmentByTag(LIST_TAG);
|
mApps = (SelectedApplicationsListFragment)fm.findFragmentByTag(LIST_TAG);
|
||||||
if (mApps == null)
|
if (mApps == null)
|
||||||
@@ -62,13 +73,6 @@ public class SelectedApplicationsActivity extends AppCompatActivity
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed()
|
|
||||||
{
|
|
||||||
prepareResult();
|
|
||||||
super.onBackPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void prepareResult()
|
private void prepareResult()
|
||||||
{
|
{
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
|
|||||||
Reference in New Issue
Block a user