From de49d73a487ce0d85199fcd1def1c4e78bd47c19 Mon Sep 17 00:00:00 2001 From: "melvin.biamont" Date: Sun, 17 Jun 2018 16:18:23 +0200 Subject: [PATCH 1/3] Possibility to use in an activity without statusbar --- app/build.gradle | 5 +-- .../irozon/sneakersample/MainActivity.java | 42 ++++++++++++++----- app/src/main/res/layout/activity_main.xml | 28 ++++++++----- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- sneaker/build.gradle | 9 ++-- .../main/java/com/irozon/sneaker/Utils.java | 13 +++--- 7 files changed, 62 insertions(+), 41 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f7791cc..e901a0c 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,6 @@ apply plugin: 'com.android.application' android { compileSdkVersion 27 - buildToolsVersion "27.0.3" defaultConfig { applicationId "com.irozon.sneakersample" minSdkVersion 19 @@ -27,8 +26,8 @@ dependencies { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.android.support:appcompat-v7:27.0.2' - compile 'com.android.support.constraint:constraint-layout:1.0.2' + compile 'com.android.support:appcompat-v7:27.1.1' + compile 'com.android.support.constraint:constraint-layout:1.1.1' testCompile 'junit:junit:4.12' compile project(':sneaker') diff --git a/app/src/main/java/com/irozon/sneakersample/MainActivity.java b/app/src/main/java/com/irozon/sneakersample/MainActivity.java index e09330e..114f0c0 100755 --- a/app/src/main/java/com/irozon/sneakersample/MainActivity.java +++ b/app/src/main/java/com/irozon/sneakersample/MainActivity.java @@ -4,6 +4,8 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; +import android.view.Window; +import android.view.WindowManager; import android.widget.Button; import com.irozon.sneaker.Sneaker; @@ -13,6 +15,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe Button btShowError; Button btShowSuccess; Button btShowWarning; + Button btToggleStatusBar; + + boolean isStatusBarVisible = true; @Override protected void onCreate(Bundle savedInstanceState) { @@ -22,10 +27,12 @@ protected void onCreate(Bundle savedInstanceState) { btShowError = (Button) findViewById(R.id.btShowError); btShowSuccess = (Button) findViewById(R.id.btShowSuccess); btShowWarning = (Button) findViewById(R.id.btShowWarning); + btToggleStatusBar = (Button) findViewById(R.id.btToggleStatusBar); btShowError.setOnClickListener(this); btShowSuccess.setOnClickListener(this); btShowWarning.setOnClickListener(this); + btToggleStatusBar.setOnClickListener(this); } @Override @@ -33,23 +40,36 @@ public void onClick(View v) { switch (v.getId()) { case R.id.btShowError: Sneaker.with(this) - .setTitle("Error!!") - .setMessage("This is the error message") - .setTypeface(Typeface.createFromAsset(this.getAssets(), "font/" + "Slabo27px-Regular.ttf")) - .sneakError(); + .setTitle("Error!!") + .setMessage("This is the error message") + .setTypeface(Typeface.createFromAsset(this.getAssets(), "font/" + "Slabo27px-Regular.ttf")) + .sneakError(); break; case R.id.btShowSuccess: Sneaker.with(this) - .setTitle("Success!!") - .setMessage("This is the success message") - .setCornerRadius(5, 7) - .sneakSuccess(); + .setTitle("Success!!") + .setMessage("This is the success message") + .setCornerRadius(5, 7) + .sneakSuccess(); break; case R.id.btShowWarning: Sneaker.with(this) - .setTitle("Warning!!") - .setMessage("This is the warning message") - .sneakWarning(); + .setTitle("Warning!!") + .setMessage("This is the warning message") + .sneakWarning(); + break; + case R.id.btToggleStatusBar: + Window w = getWindow(); + if (isStatusBarVisible) { + w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + w.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); + isStatusBarVisible = false; + } else { + w.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); + isStatusBarVisible = true; + } + break; } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index dcfe8ef..2894dad 100755 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,30 +1,36 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="16dp" + android:layout_marginStart="16dp" + android:gravity="center" + android:orientation="vertical" + tools:context="com.irozon.sneakersample.MainActivity">