51 lines
1.6 KiB
Java
51 lines
1.6 KiB
Java
package dev.iris.android;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.view.Gravity;
|
|
import android.widget.ScrollView;
|
|
import android.widget.TextView;
|
|
import org.linebender.android.rustview.RustView;
|
|
|
|
public final class IrisView extends RustView {
|
|
@Override
|
|
protected native long newViewPeer(Context context);
|
|
|
|
native void applyWindowInsetsNative(
|
|
long peer, int left, int top, int right, int bottom, int imeBottom, int imeVisible);
|
|
|
|
native void unregisterInsetsNative(long peer);
|
|
|
|
public IrisView(Context context) {
|
|
super(context);
|
|
}
|
|
|
|
void applyWindowInsets(
|
|
int left, int top, int right, int bottom, int imeBottom, int imeVisible) {
|
|
applyWindowInsetsNative(mViewPeer, left, top, right, bottom, imeBottom, imeVisible);
|
|
}
|
|
|
|
@Override
|
|
protected void onDetachedFromWindow() {
|
|
unregisterInsetsNative(mViewPeer);
|
|
super.onDetachedFromWindow();
|
|
}
|
|
|
|
void showRendererError(String report) {
|
|
Context context = getContext();
|
|
if (!(context instanceof Activity)) {
|
|
return;
|
|
}
|
|
Activity activity = (Activity) context;
|
|
TextView text = new TextView(activity);
|
|
text.setText(report);
|
|
text.setTextIsSelectable(true);
|
|
text.setGravity(Gravity.TOP | Gravity.START);
|
|
int pad = (int) (16 * activity.getResources().getDisplayMetrics().density);
|
|
text.setPadding(pad, pad, pad, pad);
|
|
ScrollView scroll = new ScrollView(activity);
|
|
scroll.addView(text);
|
|
activity.setContentView(scroll);
|
|
}
|
|
}
|