diff --git a/app/build.gradle b/app/build.gradle index d9669a8..af99fbc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "space.neothefox.laytray" minSdkVersion 23 targetSdkVersion 26 - versionCode 7 - versionName "1.6" + versionCode 8 + versionName "1.7" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/java/space/neothefox/laytray/MainActivity.java b/app/src/main/java/space/neothefox/laytray/MainActivity.java index e45c326..69ab4c2 100644 --- a/app/src/main/java/space/neothefox/laytray/MainActivity.java +++ b/app/src/main/java/space/neothefox/laytray/MainActivity.java @@ -1,8 +1,11 @@ package space.neothefox.laytray; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.graphics.Color; import android.os.Build; import android.provider.Settings; @@ -26,7 +29,7 @@ import android.widget.Toast; import java.util.Map; public class MainActivity extends AppCompatActivity -implements View.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListener { +implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListener { LinearLayout layoutLister; SharedPreferences layouts; @@ -44,6 +47,15 @@ implements View.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListe addButton.setOnClickListener(this); layouts.registerOnSharedPreferenceChangeListener(this); + if(!isPackageInstalled("com.blackberry.keyboard", getApplicationContext().getPackageManager())) + { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.unsupported_device) + .setMessage(R.string.unsupported_device_description) + .setNeutralButton(R.string.close, this) + .show(); + } + if (!isAccessibilitySettingsOn(getApplicationContext())) { Toast.makeText(this, R.string.toast_enableme, Toast.LENGTH_LONG).show(); @@ -250,4 +262,17 @@ implements View.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListe updateLayouts(); } + private boolean isPackageInstalled(String packagename, PackageManager packageManager) { + try { + packageManager.getPackageInfo(packagename, 0); + return true; + } catch (PackageManager.NameNotFoundException e) { + return false; + } +} + + @Override + public void onClick(DialogInterface dialogInterface, int i) { + this.finish(); + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f19830e..8450f74 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,7 +5,9 @@ Associate layout name with layout icon Settings You have to enable the service! - + Unsupported phone + This phone is missing the BlackBerry Keyboard. LayTray will not work without it. + Close