mirror of https://github.com/jitsi/jitsi-meet
* Regardless of whether the SDK client/consumer employs JitsiMeetActivity or JitsiMeetView, default to finishing the associated Activity upon invoking the back button (which is what Activity#onBackPressed() is documented to do). * Do not break the public API of JitsiMeetView and, thus, Jitsi Meet SDK for Android.pull/1987/head
parent
35dab19b30
commit
ec58aa9959
@ -0,0 +1,65 @@ |
||||
/* |
||||
* Copyright @ 2017-present Atlassian Pty Ltd |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.jitsi.meet.sdk; |
||||
|
||||
import android.app.Activity; |
||||
|
||||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; |
||||
|
||||
/** |
||||
* Defines the default behavior of <tt>JitsiMeetActivity</tt> and |
||||
* <tt>JitsiMeetView</tt> upon invoking the back button if no |
||||
* <tt>JitsiMeetView</tt> handles the invocation. For example, a |
||||
* <tt>JitsiMeetView</tt> may (1) handle the invocation of the back button |
||||
* during a conference by leaving the conference and (2) not handle the |
||||
* invocation when not in a conference. |
||||
*/ |
||||
public class DefaultHardwareBackBtnHandlerImpl |
||||
implements DefaultHardwareBackBtnHandler { |
||||
|
||||
/** |
||||
* The <tt>Activity</tt> to which the default handling of the back button |
||||
* is being provided by this instance. |
||||
*/ |
||||
private final Activity activity; |
||||
|
||||
/** |
||||
* Initializes a new <tt>DefaultHardwareBackBtnHandlerImpl</tt> instance to |
||||
* provide the default handling of the back button to a specific |
||||
* <tt>Activity</tt>. |
||||
* |
||||
* @param activity - the <tt>Activity</tt> to which the new instance is to |
||||
* provide the default behavior of the back button |
||||
*/ |
||||
public DefaultHardwareBackBtnHandlerImpl(Activity activity) { |
||||
this.activity = activity; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritDoc} |
||||
* |
||||
* Finishes the associated <tt>Activity</tt>. |
||||
*/ |
||||
@Override |
||||
public void invokeDefaultOnBackPressed() { |
||||
// Technically, we'd like to invoke Activity#onBackPressed().
|
||||
// Practically, it's not possible. Fortunately, the documentation of
|
||||
// Activity#onBackPressed() specifies that "[t]he default implementation
|
||||
// simply finishes the current activity,"
|
||||
activity.finish(); |
||||
} |
||||
} |
Loading…
Reference in new issue