-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8576b0f
commit c3e821e
Showing
12 changed files
with
123 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.getcapacitor; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
public class App { | ||
|
||
/** | ||
* Interface for callbacks when app status changes. | ||
*/ | ||
public interface AppStatusChangeListener { | ||
void onAppStatusChanged(Boolean isActive); | ||
} | ||
|
||
/** | ||
* Interface for callbacks when back button is pressed. | ||
*/ | ||
public interface BackButtonListener { | ||
void onBackButton(); | ||
} | ||
|
||
/** | ||
* Interface for callbacks when app is restored with pending plugin call. | ||
*/ | ||
public interface AppRestoredListener { | ||
void onAppRestored(PluginResult result); | ||
} | ||
|
||
@Nullable | ||
private AppStatusChangeListener statusChangeListener; | ||
|
||
@Nullable | ||
private BackButtonListener backButtonListener; | ||
|
||
@Nullable | ||
private AppRestoredListener appRestoredListener; | ||
|
||
private boolean isActive = false; | ||
|
||
public boolean isActive() { | ||
return isActive; | ||
} | ||
|
||
/** | ||
* Set the object to receive callbacks. | ||
* @param listener | ||
*/ | ||
public void setStatusChangeListener(@Nullable AppStatusChangeListener listener) { | ||
this.statusChangeListener = listener; | ||
} | ||
|
||
/** | ||
* Set the object to receive callbacks. | ||
* @param listener | ||
*/ | ||
public void setBackButtonListener(@Nullable BackButtonListener listener) { | ||
this.backButtonListener = listener; | ||
} | ||
|
||
/** | ||
* Set the object to receive callbacks. | ||
* @param listener | ||
*/ | ||
public void setAppRestoredListener(@Nullable AppRestoredListener listener) { | ||
this.appRestoredListener = listener; | ||
} | ||
|
||
protected void fireRestoredResult(PluginResult result) { | ||
if (appRestoredListener != null) { | ||
appRestoredListener.onAppRestored(result); | ||
} | ||
} | ||
|
||
public void fireStatusChange(boolean isActive) { | ||
this.isActive = isActive; | ||
if (statusChangeListener != null) { | ||
statusChangeListener.onAppStatusChanged(isActive); | ||
} | ||
} | ||
|
||
public void fireBackButton() { | ||
if (backButtonListener != null) { | ||
backButtonListener.onBackButton(); | ||
} | ||
} | ||
|
||
public boolean hasBackButtonListeners() { | ||
return backButtonListener != null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 0 additions & 147 deletions
147
android/capacitor/src/main/java/com/getcapacitor/plugin/App.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.