From 0ebe947a9cabd5be192a3038f1716469aa6862b2 Mon Sep 17 00:00:00 2001 From: Ray Li Date: Wed, 17 Apr 2019 22:16:43 -0500 Subject: [PATCH] Update BlurView v1.5.0 *Update BlurView to v1.5.0 to be compatible with AndroidX. *Update Gradle v3.4.0. --- app/build.gradle | 64 +- .../stream/customalertapp/MainActivity.java | 717 +++++++++--------- build.gradle | 32 +- customalert/build.gradle | 62 +- .../customalert/ui/CustomBlurDialogue.java | 7 +- gradle/wrapper/gradle-wrapper.properties | 12 +- 6 files changed, 448 insertions(+), 446 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d3ccc61..dd56a19 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,33 +1,33 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 28 - defaultConfig { - applicationId "stream.customalertsample" - minSdkVersion 15 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - vectorDrawables.useSupportLibrary true - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - repositories { - maven { url 'https://jitpack.io' } - maven { url "https://maven.google.com" } - } - implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation project(':customalert') - implementation 'com.github.searchy2:CustomButton:1.8.2' - - implementation 'androidx.appcompat:appcompat:1.0.2' - implementation 'com.google.android.material:material:1.0.0' - implementation 'androidx.cardview:cardview:1.0.0' +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "stream.customalertsample" + minSdkVersion 15 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + vectorDrawables.useSupportLibrary true + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + repositories { + maven { url 'https://jitpack.io' } + maven { url "https://maven.google.com" } + } + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation project(':customalert') + implementation 'com.github.searchy2:CustomButton:1.9.0' + + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.cardview:cardview:1.0.0' } \ No newline at end of file diff --git a/app/src/main/java/stream/customalertapp/MainActivity.java b/app/src/main/java/stream/customalertapp/MainActivity.java index 904ab4d..48ddc63 100644 --- a/app/src/main/java/stream/customalertapp/MainActivity.java +++ b/app/src/main/java/stream/customalertapp/MainActivity.java @@ -1,358 +1,359 @@ -package stream.customalertapp; - -import android.app.Activity; -import android.app.Dialog; -import android.content.Context; -import android.graphics.Typeface; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.Vibrator; -import androidx.appcompat.app.AppCompatActivity; -import androidx.cardview.widget.CardView; -import android.util.Log; -import android.view.View; -import android.view.Window; -import android.widget.AdapterView; -import android.widget.ImageView; -import android.widget.Toast; - -import java.util.ArrayList; - -import stream.customalert.CustomAlertDialogue; -import stream.custombutton.CustomButton; - -public class MainActivity extends AppCompatActivity{ - - ImageView mBackground; - CardView mCardView; - - private Context mContext; - - @Override - protected void onCreate(Bundle savedInstanceState) { - requestWindowFeature(Window.FEATURE_NO_TITLE); - super.onCreate(savedInstanceState); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - } - setContentView(R.layout.activity_main); - mContext = getApplicationContext(); - - mBackground = findViewById(R.id.background); - mCardView = findViewById(R.id.cardview); - - //Simple Alert - a simple popup message. - CustomButton btn1 = findViewById(R.id.btn1); - btn1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) - .setStyle(CustomAlertDialogue.Style.DIALOGUE) - .setTitle("Custom Alert") - .setMessage("This is a long description to test the dialogue's text wrapping functionality") - .setNegativeText("OK") - .setNegativeColor(R.color.negative) - .setNegativeTypeface(Typeface.DEFAULT_BOLD) - .setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() { - @Override - public void OnClick(View view, Dialog dialog) { - dialog.dismiss(); - } - }) - .setDecorView(getWindow().getDecorView()) - .build(); - alert.show(); - } - }); - - //Confirmation Alert - a popup dialogue with two customizable choices. - CustomButton btn2 = findViewById(R.id.btn2); - btn2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) - .setStyle(CustomAlertDialogue.Style.DIALOGUE) - .setCancelable(false) - .setTitle("Delete Items") - .setMessage("Delete all completed items?") - .setPositiveText("Confirm") - .setPositiveColor(R.color.negative) - .setPositiveTypeface(Typeface.DEFAULT_BOLD) - .setOnPositiveClicked(new CustomAlertDialogue.OnPositiveClicked() { - @Override - public void OnClick(View view, Dialog dialog) { - dialog.dismiss(); - Toast.makeText(mContext, "Items Deleted", Toast.LENGTH_SHORT).show(); - } - }) - .setNegativeText("Cancel") - .setNegativeColor(R.color.positive) - .setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() { - @Override - public void OnClick(View view, Dialog dialog) { - dialog.dismiss(); - } - }) - .setDecorView(getWindow().getDecorView()) - .build(); - alert.show(); - } - }); - - //Selector - a scrollable list of options. - CustomButton btn3 = findViewById(R.id.btn3); - btn3.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - ArrayList destructive = new ArrayList<>(); - destructive.add("Choice 1"); - - ArrayList other = new ArrayList<>(); - other.add("Choice 2"); - other.add("Choice 3"); - other.add("Choice 4"); - other.add("Choice 5"); - other.add("Choice 6"); - other.add("Choice 7"); - other.add("Choice 8"); - other.add("Choice 9"); - other.add("Choice 10"); - other.add("Choice 11"); - other.add("Choice 12"); - other.add("Choice 13"); - other.add("Choice 14"); - other.add("Choice 15"); - other.add("Choice 16"); - other.add("Choice 17"); - other.add("Choice 18"); - other.add("Choice 19"); - other.add("Choice 20"); - - CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) - .setStyle(CustomAlertDialogue.Style.SELECTOR) - .setDestructive(destructive) - .setOthers(other) - .setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View view, int i, long l) { - CustomAlertDialogue.getInstance().dismiss(); - Toast.makeText(mContext, "Selected " + i, Toast.LENGTH_SHORT).show(); - } - }) - .setDecorView(getWindow().getDecorView()) - .build(); - alert.show(); - Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); - vibe.vibrate(30); - } - }); - - //Action Sheet - a highly customizable bottom menu. - CustomButton btn4 = findViewById(R.id.btn4); - btn4.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - ArrayList other = new ArrayList(); - other.add("Copy"); - other.add("Forward"); - - CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) - .setStyle(CustomAlertDialogue.Style.ACTIONSHEET) - .setTitle("Action Sheet") - .setTitleColor(R.color.text_default) - .setCancelText("More...") - .setOnCancelClicked(new CustomAlertDialogue.OnCancelClicked() { - @Override - public void OnClick(View view, Dialog dialog) { - Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); - vibe.vibrate(10); - dialog.dismiss(); - Handler handler = new Handler(); - Runnable r = new Runnable() { - public void run() { - MoreSelector(); - } - }; - handler.postDelayed(r, 50); - } - }) - .setOthers(other) - .setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View view, int i, long l) { - String selection = adapterView.getItemAtPosition(i).toString(); - Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); - vibe.vibrate(10); - switch (selection) - { - case "Copy": - CustomAlertDialogue.getInstance().dismiss(); - Toast.makeText(mContext, "Copied", Toast.LENGTH_SHORT).show(); - break; - case "Forward": - CustomAlertDialogue.getInstance().dismiss(); - Toast.makeText(mContext, "Forwarded", Toast.LENGTH_SHORT).show(); - break; - } - } - }) - .setDecorView(getWindow().getDecorView()) - .build(); - alert.show(); - Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); - vibe.vibrate(30); - } - }); - - //Input Box - helps collect user input. Can be used as a contact/feedback form. - CustomButton btn5 = findViewById(R.id.btn5); - btn5.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - ArrayList lineHint = new ArrayList<>(); - lineHint.add("Username"); - lineHint.add("Email Address"); - lineHint.add("Name"); - lineHint.add("Zip Code"); - - ArrayList lineText = new ArrayList<>(); - lineText.add("sampleuser"); - lineText.add(null); - lineText.add("Sample User"); - - ArrayList boxHint = new ArrayList<>(); - boxHint.add("Message"); - - ArrayList boxText = new ArrayList<>(); - boxText.add("BoxText"); - - CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) - .setStyle(CustomAlertDialogue.Style.INPUT) - .setTitle("Submit Feedback") - .setMessage("We love to hear feedback! Please share your thoughts and comments:") - .setPositiveText("Submit") - .setPositiveColor(R.color.positive) - .setPositiveTypeface(Typeface.DEFAULT_BOLD) - .setOnInputClicked(new CustomAlertDialogue.OnInputClicked() { - @Override - public void OnClick(View view, Dialog dialog, ArrayList inputList) { - Toast.makeText(mContext, "Sent", Toast.LENGTH_SHORT).show(); - for (String input : inputList) - { - Log.d("Input", input); - } - dialog.dismiss(); - } - }) - .setNegativeText("Cancel") - .setNegativeColor(R.color.negative) - .setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() { - @Override - public void OnClick(View view, Dialog dialog) { - dialog.dismiss(); - } - }) - .setLineInputHint(lineHint) - .setLineInputText(lineText) - .setBoxInputHint(boxHint) - .setBoxInputText(boxText) - .setDecorView(getWindow().getDecorView()) - .build(); - alert.show(); - } - }); - } - - public void MoreSelector() - { - ArrayList destructive = new ArrayList(); - destructive.add("Delete"); - ArrayList other = new ArrayList(); - other.add("Details"); - - CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) - .setStyle(CustomAlertDialogue.Style.SELECTOR) - .setDestructive(destructive) - .setOthers(other) - .setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View view, int i, long l) { - String selection = adapterView.getItemAtPosition(i).toString(); - Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); - vibe.vibrate(10); - switch (selection) - { - case "Delete": - CustomAlertDialogue.getInstance().dismiss(); - Toast.makeText(mContext, "Deleted", Toast.LENGTH_SHORT).show(); - break; - case "Details": - CustomAlertDialogue.getInstance().dismiss(); - Toast.makeText(mContext, "Details", Toast.LENGTH_SHORT).show(); - break; - } - } - }) - .setDecorView(getWindow().getDecorView()) - .build(); - alert.show(); - } - - //Hide background for screenshots. - public void HideBackground(boolean hide) - { - if (hide) - { - mBackground.setVisibility(View.GONE); - mCardView.setVisibility(View.GONE); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - @Override - public void run() { - HideBackground(false); - } - }, 5000); - } - else - { - mBackground.setVisibility(View.VISIBLE); - mCardView.setVisibility(View.VISIBLE); - } - } - - @Override - protected void onPause() { - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { - //Removes flickering from setting window fullscreen - Handler handler = new Handler(); - handler.post(new Runnable() { - @Override - public void run() { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - } - }); - } - super.onPause(); - } - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { - if (hasFocus) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - } - } - super.onWindowFocusChanged(hasFocus); - } -} +package stream.customalertapp; + +import android.app.Dialog; +import android.content.Context; +import android.graphics.Typeface; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.os.Vibrator; +import android.util.Log; +import android.view.View; +import android.view.Window; +import android.widget.AdapterView; +import android.widget.ImageView; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.cardview.widget.CardView; + +import java.util.ArrayList; + +import stream.customalert.CustomAlertDialogue; +import stream.custombutton.CustomButton; + +public class MainActivity extends AppCompatActivity{ + + ImageView mBackground; + CardView mCardView; + + private Context mContext; + + @Override + protected void onCreate(Bundle savedInstanceState) { + requestWindowFeature(Window.FEATURE_NO_TITLE); + super.onCreate(savedInstanceState); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } + setContentView(R.layout.activity_main); + mContext = getApplicationContext(); + + mBackground = findViewById(R.id.background); + mCardView = findViewById(R.id.cardview); + + //Simple Alert - a simple popup message. + CustomButton btn1 = findViewById(R.id.btn1); + btn1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) + .setStyle(CustomAlertDialogue.Style.DIALOGUE) + .setTitle("Custom Alert") + .setMessage("This is a long description to test the dialogue's text wrapping functionality") + .setNegativeText("OK") + .setNegativeColor(R.color.negative) + .setNegativeTypeface(Typeface.DEFAULT_BOLD) + .setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() { + @Override + public void OnClick(View view, Dialog dialog) { + dialog.dismiss(); + } + }) + .setDecorView(getWindow().getDecorView()) + .build(); + alert.show(); + } + }); + + //Confirmation Alert - a popup dialogue with two customizable choices. + CustomButton btn2 = findViewById(R.id.btn2); + btn2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) + .setStyle(CustomAlertDialogue.Style.DIALOGUE) + .setCancelable(false) + .setTitle("Delete Items") + .setMessage("Delete all completed items?") + .setPositiveText("Confirm") + .setPositiveColor(R.color.negative) + .setPositiveTypeface(Typeface.DEFAULT_BOLD) + .setOnPositiveClicked(new CustomAlertDialogue.OnPositiveClicked() { + @Override + public void OnClick(View view, Dialog dialog) { + dialog.dismiss(); + Toast.makeText(mContext, "Items Deleted", Toast.LENGTH_SHORT).show(); + } + }) + .setNegativeText("Cancel") + .setNegativeColor(R.color.positive) + .setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() { + @Override + public void OnClick(View view, Dialog dialog) { + dialog.dismiss(); + } + }) + .setDecorView(getWindow().getDecorView()) + .build(); + alert.show(); + } + }); + + //Selector - a scrollable list of options. + CustomButton btn3 = findViewById(R.id.btn3); + btn3.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ArrayList destructive = new ArrayList<>(); + destructive.add("Choice 1"); + + ArrayList other = new ArrayList<>(); + other.add("Choice 2"); + other.add("Choice 3"); + other.add("Choice 4"); + other.add("Choice 5"); + other.add("Choice 6"); + other.add("Choice 7"); + other.add("Choice 8"); + other.add("Choice 9"); + other.add("Choice 10"); + other.add("Choice 11"); + other.add("Choice 12"); + other.add("Choice 13"); + other.add("Choice 14"); + other.add("Choice 15"); + other.add("Choice 16"); + other.add("Choice 17"); + other.add("Choice 18"); + other.add("Choice 19"); + other.add("Choice 20"); + + CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) + .setStyle(CustomAlertDialogue.Style.SELECTOR) + .setDestructive(destructive) + .setOthers(other) + .setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + CustomAlertDialogue.getInstance().dismiss(); + Toast.makeText(mContext, "Selected " + i, Toast.LENGTH_SHORT).show(); + } + }) + .setDecorView(getWindow().getDecorView()) + .build(); + alert.show(); + Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); + vibe.vibrate(30); + } + }); + + //Action Sheet - a highly customizable bottom menu. + CustomButton btn4 = findViewById(R.id.btn4); + btn4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ArrayList other = new ArrayList<>(); + other.add("Copy"); + other.add("Forward"); + + CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) + .setStyle(CustomAlertDialogue.Style.ACTIONSHEET) + .setTitle("Action Sheet") + .setTitleColor(R.color.text_default) + .setCancelText("More...") + .setOnCancelClicked(new CustomAlertDialogue.OnCancelClicked() { + @Override + public void OnClick(View view, Dialog dialog) { + Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); + vibe.vibrate(10); + dialog.dismiss(); + Handler handler = new Handler(); + Runnable r = new Runnable() { + public void run() { + MoreSelector(); + } + }; + handler.postDelayed(r, 50); + } + }) + .setOthers(other) + .setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + String selection = adapterView.getItemAtPosition(i).toString(); + Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); + vibe.vibrate(10); + switch (selection) + { + case "Copy": + CustomAlertDialogue.getInstance().dismiss(); + Toast.makeText(mContext, "Copied", Toast.LENGTH_SHORT).show(); + break; + case "Forward": + CustomAlertDialogue.getInstance().dismiss(); + Toast.makeText(mContext, "Forwarded", Toast.LENGTH_SHORT).show(); + break; + } + } + }) + .setDecorView(getWindow().getDecorView()) + .build(); + alert.show(); + Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); + vibe.vibrate(30); + } + }); + + //Input Box - helps collect user input. Can be used as a contact/feedback form. + CustomButton btn5 = findViewById(R.id.btn5); + btn5.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + ArrayList lineHint = new ArrayList<>(); + lineHint.add("Username"); + lineHint.add("Email Address"); + lineHint.add("Name"); + lineHint.add("Zip Code"); + + ArrayList lineText = new ArrayList<>(); + lineText.add("sampleuser"); + lineText.add(null); + lineText.add("Sample User"); + + ArrayList boxHint = new ArrayList<>(); + boxHint.add("Message"); + + ArrayList boxText = new ArrayList<>(); + boxText.add("BoxText"); + + CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) + .setStyle(CustomAlertDialogue.Style.INPUT) + .setTitle("Submit Feedback") + .setMessage("We love to hear feedback! Please share your thoughts and comments:") + .setPositiveText("Submit") + .setPositiveColor(R.color.positive) + .setPositiveTypeface(Typeface.DEFAULT_BOLD) + .setOnInputClicked(new CustomAlertDialogue.OnInputClicked() { + @Override + public void OnClick(View view, Dialog dialog, ArrayList inputList) { + Toast.makeText(mContext, "Sent", Toast.LENGTH_SHORT).show(); + for (String input : inputList) + { + Log.d("Input", input); + } + dialog.dismiss(); + } + }) + .setNegativeText("Cancel") + .setNegativeColor(R.color.negative) + .setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() { + @Override + public void OnClick(View view, Dialog dialog) { + dialog.dismiss(); + } + }) + .setLineInputHint(lineHint) + .setLineInputText(lineText) + .setBoxInputHint(boxHint) + .setBoxInputText(boxText) + .setDecorView(getWindow().getDecorView()) + .build(); + alert.show(); + } + }); + } + + public void MoreSelector() + { + ArrayList destructive = new ArrayList<>(); + destructive.add("Delete"); + ArrayList other = new ArrayList<>(); + other.add("Details"); + + CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this) + .setStyle(CustomAlertDialogue.Style.SELECTOR) + .setDestructive(destructive) + .setOthers(other) + .setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + String selection = adapterView.getItemAtPosition(i).toString(); + Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); + vibe.vibrate(10); + switch (selection) + { + case "Delete": + CustomAlertDialogue.getInstance().dismiss(); + Toast.makeText(mContext, "Deleted", Toast.LENGTH_SHORT).show(); + break; + case "Details": + CustomAlertDialogue.getInstance().dismiss(); + Toast.makeText(mContext, "Details", Toast.LENGTH_SHORT).show(); + break; + } + } + }) + .setDecorView(getWindow().getDecorView()) + .build(); + alert.show(); + } + + //Hide background for screenshots. + @SuppressWarnings("unused") + public void HideBackground(boolean hide) + { + if (hide) + { + mBackground.setVisibility(View.GONE); + mCardView.setVisibility(View.GONE); + Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + HideBackground(false); + } + }, 5000); + } + else + { + mBackground.setVisibility(View.VISIBLE); + mCardView.setVisibility(View.VISIBLE); + } + } + + @Override + protected void onPause() { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { + //Removes flickering from setting window fullscreen + Handler handler = new Handler(); + handler.post(new Runnable() { + @Override + public void run() { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } + }); + } + super.onPause(); + } + + @Override + public void onWindowFocusChanged(boolean hasFocus) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { + if (hasFocus) { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } + } + super.onWindowFocusChanged(hasFocus); + } +} diff --git a/build.gradle b/build.gradle index 0c81baa..5729446 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,17 @@ -buildscript { - repositories { - jcenter() - maven { url "https://maven.google.com" } - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.3.1' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - } -} - -allprojects { - repositories { - jcenter() - } +buildscript { + repositories { + jcenter() + maven { url "https://maven.google.com" } + google() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.4.0' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + } +} + +allprojects { + repositories { + jcenter() + } } \ No newline at end of file diff --git a/customalert/build.gradle b/customalert/build.gradle index 3aca6ec..6788baf 100644 --- a/customalert/build.gradle +++ b/customalert/build.gradle @@ -1,31 +1,31 @@ -apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' - -group='com.github.searchy2' -version = '2.5.1' - -android { - compileSdkVersion 28 - - defaultConfig { - minSdkVersion 15 - targetSdkVersion 28 - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - repositories { - maven { url 'https://jitpack.io' } - maven { url "https://maven.google.com" } - } - implementation fileTree(include: ['*.jar'], dir: 'libs') - api 'com.google.android.material:material:1.0.0' - api 'com.github.Dimezis.BlurView:blurview:version-1.4.0' -} - +apply plugin: 'com.android.library' +apply plugin: 'com.github.dcendents.android-maven' + +group='com.github.searchy2' +version = '2.5.1' + +android { + compileSdkVersion 28 + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 28 + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + repositories { + maven { url 'https://jitpack.io' } + maven { url "https://maven.google.com" } + } + implementation fileTree(include: ['*.jar'], dir: 'libs') + api 'com.google.android.material:material:1.0.0' + api 'com.eightbitlab:blurview:1.5.0' +} + diff --git a/customalert/src/main/java/stream/customalert/ui/CustomBlurDialogue.java b/customalert/src/main/java/stream/customalert/ui/CustomBlurDialogue.java index eeaa259..666bb16 100644 --- a/customalert/src/main/java/stream/customalert/ui/CustomBlurDialogue.java +++ b/customalert/src/main/java/stream/customalert/ui/CustomBlurDialogue.java @@ -57,9 +57,10 @@ public void create(View decorView, float radius) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setupWith(rootView) - .windowBackground(windowBackground) - .blurAlgorithm(new RenderScriptBlur(getContext())) - .blurRadius(radius); + .setFrameClearDrawable(windowBackground) + .setBlurAlgorithm(new RenderScriptBlur(getContext())) + .setBlurRadius(radius) + .setHasFixedTransformationMatrix(true); } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9d734fe..b5eac25 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Feb 12 10:58:49 CST 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +#Wed Apr 17 19:25:00 CDT 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip