use of org.telegram.ui.Components.PasscodeView in project Telegram-FOSS by Telegram-FOSS-Team.
the class BubbleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
ApplicationLoader.postInitApplication();
requestWindowFeature(Window.FEATURE_NO_TITLE);
setTheme(R.style.Theme_TMessages);
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
if (SharedConfig.passcodeHash.length() > 0 && !SharedConfig.allowScreenCapture) {
try {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
} catch (Exception e) {
FileLog.e(e);
}
}
super.onCreate(savedInstanceState);
if (SharedConfig.passcodeHash.length() != 0 && SharedConfig.appLocked) {
SharedConfig.lastPauseTime = (int) (SystemClock.elapsedRealtime() / 1000);
}
AndroidUtilities.fillStatusBarHeight(this);
Theme.createDialogsResources(this);
Theme.createChatResources(this, false);
actionBarLayout = new ActionBarLayout(this);
actionBarLayout.setInBubbleMode(true);
actionBarLayout.setRemoveActionBarExtraHeight(true);
drawerLayoutContainer = new DrawerLayoutContainer(this);
drawerLayoutContainer.setAllowOpenDrawer(false, false);
setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
RelativeLayout launchLayout = new RelativeLayout(this);
drawerLayoutContainer.addView(launchLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
launchLayout.addView(actionBarLayout, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
actionBarLayout.init(mainFragmentsStack);
actionBarLayout.setDelegate(this);
passcodeView = new PasscodeView(this);
drawerLayoutContainer.addView(passcodeView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
actionBarLayout.removeAllFragments();
handleIntent(getIntent(), false, savedInstanceState != null, false, UserConfig.selectedAccount, 0);
}
use of org.telegram.ui.Components.PasscodeView in project Telegram-FOSS by Telegram-FOSS-Team.
the class LaunchActivity method showPasscodeActivity.
public void showPasscodeActivity(boolean fingerprint, boolean animated, int x, int y, Runnable onShow, Runnable onStart) {
if (drawerLayoutContainer == null) {
return;
}
if (passcodeView == null) {
passcodeView = new PasscodeView(this);
drawerLayoutContainer.addView(passcodeView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
SharedConfig.appLocked = true;
if (SecretMediaViewer.hasInstance() && SecretMediaViewer.getInstance().isVisible()) {
SecretMediaViewer.getInstance().closePhoto(false, false);
} else if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
PhotoViewer.getInstance().closePhoto(false, true);
} else if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
ArticleViewer.getInstance().close(false, true);
}
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject != null && messageObject.isRoundVideo()) {
MediaController.getInstance().cleanupPlayer(true, true);
}
passcodeView.onShow(fingerprint, animated, x, y, () -> {
actionBarLayout.setVisibility(View.INVISIBLE);
if (AndroidUtilities.isTablet()) {
if (layersActionBarLayout.getVisibility() == View.VISIBLE) {
layersActionBarLayout.setVisibility(View.INVISIBLE);
}
rightActionBarLayout.setVisibility(View.INVISIBLE);
}
if (onShow != null) {
onShow.run();
}
}, onStart);
SharedConfig.isWaitingForPasscodeEnter = true;
drawerLayoutContainer.setAllowOpenDrawer(false, false);
passcodeView.setDelegate(() -> {
SharedConfig.isWaitingForPasscodeEnter = false;
if (passcodeSaveIntent != null) {
handleIntent(passcodeSaveIntent, passcodeSaveIntentIsNew, passcodeSaveIntentIsRestore, true);
passcodeSaveIntent = null;
}
drawerLayoutContainer.setAllowOpenDrawer(true, false);
actionBarLayout.setVisibility(View.VISIBLE);
actionBarLayout.showLastFragment();
if (AndroidUtilities.isTablet()) {
layersActionBarLayout.showLastFragment();
rightActionBarLayout.showLastFragment();
if (layersActionBarLayout.getVisibility() == View.INVISIBLE) {
layersActionBarLayout.setVisibility(View.VISIBLE);
}
rightActionBarLayout.setVisibility(View.VISIBLE);
}
});
}
use of org.telegram.ui.Components.PasscodeView in project Telegram-FOSS by Telegram-FOSS-Team.
the class ExternalActionActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
ApplicationLoader.postInitApplication();
requestWindowFeature(Window.FEATURE_NO_TITLE);
setTheme(R.style.Theme_TMessages);
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
if (SharedConfig.passcodeHash.length() > 0 && !SharedConfig.allowScreenCapture) {
try {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
} catch (Exception e) {
FileLog.e(e);
}
}
super.onCreate(savedInstanceState);
if (SharedConfig.passcodeHash.length() != 0 && SharedConfig.appLocked) {
SharedConfig.lastPauseTime = (int) (SystemClock.elapsedRealtime() / 1000);
}
AndroidUtilities.fillStatusBarHeight(this);
Theme.createDialogsResources(this);
Theme.createChatResources(this, false);
actionBarLayout = new ActionBarLayout(this);
drawerLayoutContainer = new DrawerLayoutContainer(this);
drawerLayoutContainer.setAllowOpenDrawer(false, false);
setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
if (AndroidUtilities.isTablet()) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
RelativeLayout launchLayout = new RelativeLayout(this);
drawerLayoutContainer.addView(launchLayout);
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) launchLayout.getLayoutParams();
layoutParams1.width = LayoutHelper.MATCH_PARENT;
layoutParams1.height = LayoutHelper.MATCH_PARENT;
launchLayout.setLayoutParams(layoutParams1);
backgroundTablet = new SizeNotifierFrameLayout(this) {
@Override
protected boolean isActionBarVisible() {
return false;
}
};
backgroundTablet.setOccupyStatusBar(false);
backgroundTablet.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
launchLayout.addView(backgroundTablet, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
launchLayout.addView(actionBarLayout, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
FrameLayout shadowTablet = new FrameLayout(this);
shadowTablet.setBackgroundColor(0x7F000000);
launchLayout.addView(shadowTablet, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
shadowTablet.setOnTouchListener((v, event) -> {
if (!actionBarLayout.fragmentsStack.isEmpty() && event.getAction() == MotionEvent.ACTION_UP) {
float x = event.getX();
float y = event.getY();
int[] location = new int[2];
layersActionBarLayout.getLocationOnScreen(location);
int viewX = location[0];
int viewY = location[1];
if (layersActionBarLayout.checkTransitionAnimation() || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY && y < viewY + layersActionBarLayout.getHeight()) {
return false;
} else {
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
a--;
}
layersActionBarLayout.closeLastFragment(true);
}
return true;
}
}
return false;
});
shadowTablet.setOnClickListener(v -> {
});
layersActionBarLayout = new ActionBarLayout(this);
layersActionBarLayout.setRemoveActionBarExtraHeight(true);
layersActionBarLayout.setBackgroundView(shadowTablet);
layersActionBarLayout.setUseAlphaAnimations(true);
layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
launchLayout.addView(layersActionBarLayout, LayoutHelper.createRelative(530, (AndroidUtilities.isSmallTablet() ? 528 : 700)));
layersActionBarLayout.init(layerFragmentsStack);
layersActionBarLayout.setDelegate(this);
layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
} else {
RelativeLayout launchLayout = new RelativeLayout(this);
drawerLayoutContainer.addView(launchLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
backgroundTablet = new SizeNotifierFrameLayout(this) {
@Override
protected boolean isActionBarVisible() {
return false;
}
};
backgroundTablet.setOccupyStatusBar(false);
backgroundTablet.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
launchLayout.addView(backgroundTablet, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
launchLayout.addView(actionBarLayout, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
// drawerLayoutContainer.setDrawerLayout(listView);
drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
actionBarLayout.init(mainFragmentsStack);
actionBarLayout.setDelegate(this);
passcodeView = new PasscodeView(this);
drawerLayoutContainer.addView(passcodeView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
actionBarLayout.removeAllFragments();
if (layersActionBarLayout != null) {
layersActionBarLayout.removeAllFragments();
}
handleIntent(getIntent(), false, savedInstanceState != null, false, UserConfig.selectedAccount, 0);
needLayout();
}
Aggregations