1
0
mirror of https://gitlab.com/neothefox/LayTray synced 2026-03-23 21:54:54 +03:00

Check if Blackberry Keyboard is installed on start

Bumped version to 1.7
This commit is contained in:
NeoTheFox 2018-07-18 16:02:05 +03:00
parent cf94f7c9bb
commit 4c92f97ab3
3 changed files with 31 additions and 4 deletions

View File

@ -6,8 +6,8 @@ android {
applicationId "space.neothefox.laytray" applicationId "space.neothefox.laytray"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 26 targetSdkVersion 26
versionCode 7 versionCode 8
versionName "1.6" versionName "1.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {

View File

@ -1,8 +1,11 @@
package space.neothefox.laytray; package space.neothefox.laytray;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.os.Build; import android.os.Build;
import android.provider.Settings; import android.provider.Settings;
@ -26,7 +29,7 @@ import android.widget.Toast;
import java.util.Map; import java.util.Map;
public class MainActivity extends AppCompatActivity public class MainActivity extends AppCompatActivity
implements View.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListener { implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListener {
LinearLayout layoutLister; LinearLayout layoutLister;
SharedPreferences layouts; SharedPreferences layouts;
@ -44,6 +47,15 @@ implements View.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListe
addButton.setOnClickListener(this); addButton.setOnClickListener(this);
layouts.registerOnSharedPreferenceChangeListener(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())) { if (!isAccessibilitySettingsOn(getApplicationContext())) {
Toast.makeText(this, R.string.toast_enableme, Toast.makeText(this, R.string.toast_enableme,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
@ -250,4 +262,17 @@ implements View.OnClickListener, SharedPreferences.OnSharedPreferenceChangeListe
updateLayouts(); 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();
}
} }

View File

@ -5,7 +5,9 @@
<string name="activity_info">Associate layout name with layout icon</string> <string name="activity_info">Associate layout name with layout icon</string>
<string name="title_activity_settings">Settings</string> <string name="title_activity_settings">Settings</string>
<string name="toast_enableme">You have to enable the service!</string> <string name="toast_enableme">You have to enable the service!</string>
<string name="unsupported_device">Unsupported phone</string>
<string name="unsupported_device_description">This phone is missing the BlackBerry Keyboard. LayTray will not work without it.</string>
<string name="close">Close</string>
<!-- Strings related to Settings --> <!-- Strings related to Settings -->
<!-- Example General settings --> <!-- Example General settings -->