-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from PSPDFKit/reinhard/344-additional-configu…
…ration Add more Android configuration options
- Loading branch information
Showing
13 changed files
with
210 additions
and
67 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
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
31 changes: 31 additions & 0 deletions
31
android/src/main/java/com/pspdfkit/react/events/PdfViewNavigationButtonClickedEvent.java
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,31 @@ | ||
package com.pspdfkit.react.events; | ||
|
||
import androidx.annotation.IdRes; | ||
|
||
import com.facebook.react.bridge.Arguments; | ||
import com.facebook.react.bridge.WritableMap; | ||
import com.facebook.react.uimanager.events.Event; | ||
import com.facebook.react.uimanager.events.RCTEventEmitter; | ||
|
||
/** | ||
* Event sent by the {@link com.pspdfkit.views.PdfView} when navigation button was clicked. | ||
*/ | ||
public class PdfViewNavigationButtonClickedEvent extends Event<PdfViewNavigationButtonClickedEvent> { | ||
|
||
public static final String EVENT_NAME = "pdfViewNavgigationButtonClicked"; | ||
|
||
public PdfViewNavigationButtonClickedEvent(@IdRes int viewId) { | ||
super(viewId); | ||
} | ||
|
||
@Override | ||
public String getEventName() { | ||
return EVENT_NAME; | ||
} | ||
|
||
@Override | ||
public void dispatch(RCTEventEmitter rctEventEmitter) { | ||
WritableMap eventData = Arguments.createMap(); | ||
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), eventData); | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
android/src/main/java/com/pspdfkit/views/ConfigurationChangeReportingPdfUiFragment.java
This file was deleted.
Oops, something went wrong.
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
67 changes: 67 additions & 0 deletions
67
android/src/main/java/com/pspdfkit/views/ReactPdfUiFragment.java
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,67 @@ | ||
package com.pspdfkit.views; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.widget.Toolbar; | ||
|
||
import com.pspdfkit.configuration.activity.PdfActivityConfiguration; | ||
import com.pspdfkit.react.R; | ||
import com.pspdfkit.ui.PdfUiFragment; | ||
|
||
/** | ||
* This {@link PdfUiFragment} provides additional callbacks to improve integration into react native. | ||
* <p/> | ||
* <ul> | ||
* <li>A callback when the configuration was changed.</li> | ||
* <li>A method to show and hide the navigation button in the toolbar, as well as a callback for when it is clicked.</li> | ||
* </ul> | ||
*/ | ||
public class ReactPdfUiFragment extends PdfUiFragment { | ||
|
||
@Nullable private ReactPdfUiFragmentListener reactPdfUiFragmentListener; | ||
|
||
void setReactPdfUiFragmentListener(@Nullable ReactPdfUiFragmentListener listener) { | ||
this.reactPdfUiFragmentListener = listener; | ||
} | ||
|
||
@Override | ||
public void performApplyConfiguration(@NonNull PdfActivityConfiguration configuration) { | ||
super.performApplyConfiguration(configuration); | ||
|
||
if (this.reactPdfUiFragmentListener != null) { | ||
reactPdfUiFragmentListener.onConfigurationChanged(this); | ||
} | ||
} | ||
|
||
|
||
/** When set to true will add a navigation arrow to the toolbar. */ | ||
void setShowNavigationButtonInToolbar(final boolean showNavigationButtonInToolbar) { | ||
if (getView() == null) { | ||
return; | ||
} | ||
Toolbar toolbar = getView().findViewById(R.id.pspdf__toolbar_main); | ||
if (showNavigationButtonInToolbar) { | ||
toolbar.setNavigationIcon(R.drawable.pspdf__ic_navigation_arrow); | ||
toolbar.setNavigationOnClickListener(v -> { | ||
if (reactPdfUiFragmentListener != null) { | ||
reactPdfUiFragmentListener.onNavigationButtonClicked(this); | ||
} | ||
}); | ||
} else { | ||
toolbar.setNavigationIcon(null); | ||
toolbar.setNavigationOnClickListener(null); | ||
} | ||
} | ||
|
||
/** | ||
* Listener that notifies of actions taken directly in the PdfUiFragment. | ||
*/ | ||
public interface ReactPdfUiFragmentListener { | ||
|
||
/** Called when the configuration changed, reset your {@link com.pspdfkit.ui.PdfFragment} listeners in here. */ | ||
void onConfigurationChanged(@NonNull PdfUiFragment pdfUiFragment); | ||
|
||
/** Called when the back navigation button was clicked. */ | ||
void onNavigationButtonClicked(@NonNull PdfUiFragment pdfUiFragment); | ||
} | ||
} |
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,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/> | ||
</vector> |
Oops, something went wrong.