me.imid.swipebacklayout.lib.app.SwipeBackActivityHelper Java Examples

The following examples show how to use me.imid.swipebacklayout.lib.app.SwipeBackActivityHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModSDK21.java    From SwipeBack with GNU General Public License v3.0 6 votes vote down vote up
public static void zygoteSDK21() {
	mSettings = Settings.getInstance(null);
	findAndHookMethod("com.android.internal.policy.impl.PhoneWindow", null, "setStatusBarColor", int.class, new XC_MethodHook() {
		@Override
		protected void afterHookedMethod(XC_MethodHook.MethodHookParam mhparams) throws Throwable {
			int color = Integer.valueOf(mhparams.args[0].toString());
			if (color == 0)
				return;
			SwipeBackActivityHelper helper = $(getAdditionalInstanceField(mhparams.thisObject, "helper"));
			if (helper != null) {
				ViewGroup root = $(helper.getSwipeBackLayout().getChildAt(0));
				View content = root.getChildAt(0);
				
				if (content.getBackground() instanceof WindowInsetsColorDrawable) {
					WindowInsetsColorDrawable d = $(content.getBackground());
					d.setTopDrawable(new ColorDrawable(color));
					((Method) mhparams.method).invoke(mhparams.thisObject, 0);	
				}
			}
		}
	});
}
 
Example #2
Source File: UniversalActivity.java    From FantasySlide with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    swipeBackActivityHelper = new SwipeBackActivityHelper(this);
    swipeBackActivityHelper.onActivityCreate();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    setTitle(getIntent().getStringExtra("title"));
}
 
Example #3
Source File: MySwipeBackActivity.java    From MaterialQQLite with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHelper = new SwipeBackActivityHelper(this);
    mHelper.onActivityCreate();

}
 
Example #4
Source File: SwipeBackHelper.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 5 votes vote down vote up
public void onCreate(Activity activity) {
    mHelper = new SwipeBackActivityHelper(activity);
    mHelper.onActivityCreate();
    SwipeBackLayout swipeBackLayout = mHelper.getSwipeBackLayout();
    float density = activity.getResources().getDisplayMetrics().density;
    swipeBackLayout.setEdgeSize((int) (10 * density + 0.5f));
    swipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_ALL);
}
 
Example #5
Source File: BaseSwipeBackActivity.java    From AFBaseLibrary with Apache License 2.0 4 votes vote down vote up
@Override
protected void init(Bundle savedInstanceState) {
    super.init(savedInstanceState);
    mHelper = new SwipeBackActivityHelper(this);
    mHelper.onActivityCreate();
}
 
Example #6
Source File: ModSDK21.java    From SwipeBack with GNU General Public License v3.0 4 votes vote down vote up
public static void afterOnCreateSDK21(SwipeBackActivityHelper helper, Activity activity, String packageName, String className) throws Throwable {
	mSettings.reload();
	if (mSettings.getBoolean(packageName, className, Settings.LOLLIPOP_HACK, false)) {
		setAdditionalInstanceField(activity.getWindow(), "helper", helper);
	}
}
 
Example #7
Source File: ModSDK21.java    From SwipeBack with GNU General Public License v3.0 4 votes vote down vote up
@TargetApi(21)
public static void afterOnPostCreateSDK21(XC_MethodHook.MethodHookParam mhparams) throws Throwable {
	Class<?> internalStyleable = findClass("com.android.internal.R.styleable", null);
	int[] internalTheme = $(getStaticObjectField(internalStyleable, "Theme"));
	int internalColorPrimary = getStaticIntField(internalStyleable, "Theme_colorPrimaryDark");
	
	SwipeBackActivityHelper helper = $(getAdditionalInstanceField(mhparams.thisObject, "helper"));
	if (helper != null) {
		final Activity activity = $(mhparams.thisObject);

		String packageName = activity.getApplicationInfo().packageName;
		String className = activity.getClass().getName();
		
		mSettings.reload();
		if (!mSettings.getBoolean(packageName, className, Settings.LOLLIPOP_HACK, false))
			return;
		
		ViewGroup root = $(helper.getSwipeBackLayout().getChildAt(0));
		View content = root.getChildAt(0);
		final WindowInsetsColorDrawable bkg = new WindowInsetsColorDrawable(content.getBackground());
		content.setBackground(bkg);
		
		TypedArray a = activity.getTheme().obtainStyledAttributes(internalTheme);
		int primary = a.getColor(internalColorPrimary, 0);
		a.recycle();

		if (primary != 0) {
			bkg.setTopDrawable(new ColorDrawable(primary));
		} else {
			content.setSystemUiVisibility(content.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
			content.setFitsSystemWindows(true);
		}

		root.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
			@Override
			public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
				bkg.setTopInset(insets.getSystemWindowInsetTop());
				activity.getWindow().setStatusBarColor(0);
				return insets;
			}
		});
	}
}