mirror of
https://gitlab.com/neothefox/LayTray
synced 2026-03-23 21:54:54 +03:00
Quick fix for Oreo
Changes to settings for Oreo
This commit is contained in:
parent
20331b629b
commit
bccc0bca6c
@ -1,7 +1,7 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 26
|
||||
compileSdkVersion 27
|
||||
defaultConfig {
|
||||
applicationId "space.neothefox.laytray"
|
||||
minSdkVersion 23
|
||||
@ -21,10 +21,10 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
|
||||
implementation 'com.android.support:support-v4:26.1.0'
|
||||
implementation 'com.android.support:support-v4:27.1.1'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
implementation 'com.android.support:design:26.1.0'
|
||||
implementation 'com.android.support:design:27.1.1'
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Build;
|
||||
@ -27,7 +26,8 @@ import static android.graphics.Paint.ANTI_ALIAS_FLAG;
|
||||
public class IconService extends AccessibilityService
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener{
|
||||
|
||||
public String TAG = "layicon";
|
||||
public static String TAG = "layicon";
|
||||
public static String channelId = "space.neothefox.laytray.IC";
|
||||
private final AccessibilityServiceInfo serviceInfo = new AccessibilityServiceInfo();
|
||||
|
||||
SharedPreferences layouts;
|
||||
@ -53,12 +53,16 @@ implements SharedPreferences.OnSharedPreferenceChangeListener{
|
||||
|
||||
iconManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
|
||||
iconChannel = new NotificationChannel(
|
||||
"laytray",
|
||||
"LayTray",
|
||||
Integer.parseInt(options.getString("notificationImportance", "0")));
|
||||
channelId,
|
||||
"LayTray IconChannel",
|
||||
NotificationManager.IMPORTANCE_DEFAULT);
|
||||
iconChannel.setShowBadge(false);
|
||||
iconChannel.enableLights(false);
|
||||
iconChannel.enableVibration(false);
|
||||
iconChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
|
||||
iconManager.createNotificationChannel(iconChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,12 +85,11 @@ implements SharedPreferences.OnSharedPreferenceChangeListener{
|
||||
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
{
|
||||
iconChannel.setImportance(
|
||||
Integer.parseInt(options.getString("notificationImportance", "0")));
|
||||
indicator = new Notification.Builder(this, "laytray")
|
||||
indicator = new Notification.Builder(this, channelId)
|
||||
.setSmallIcon(smallIcon)
|
||||
.setContentTitle(toast)
|
||||
.setOngoing(true)
|
||||
.setVisibility(Notification.VISIBILITY_SECRET)
|
||||
.build();
|
||||
}
|
||||
else {
|
||||
|
||||
@ -8,11 +8,12 @@ import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@ -21,7 +22,6 @@ import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.util.Log;
|
||||
import android.widget.Space;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@ -47,7 +47,13 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
|
||||
addButton.setOnClickListener(this);
|
||||
layouts.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
if(!isPackageInstalled("com.blackberry.keyboard", getApplicationContext().getPackageManager()))
|
||||
if (!isAccessibilitySettingsOn(getApplicationContext())) {
|
||||
Toast.makeText(this, R.string.toast_enableme,
|
||||
Toast.LENGTH_LONG).show();
|
||||
startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
|
||||
}
|
||||
|
||||
if(!isPackageInstalled("com.blackberry.keyboard", getApplicationContext().getPackageManager()) && !BuildConfig.DEBUG)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.unsupported_device)
|
||||
@ -55,13 +61,6 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
|
||||
.setNeutralButton(R.string.close, this)
|
||||
.show();
|
||||
}
|
||||
|
||||
if (!isAccessibilitySettingsOn(getApplicationContext())) {
|
||||
Toast.makeText(this, R.string.toast_enableme,
|
||||
Toast.LENGTH_LONG).show();
|
||||
startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void updateLayouts()
|
||||
|
||||
@ -6,23 +6,20 @@ import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.RingtonePreference;
|
||||
import android.text.TextUtils;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
@ -205,7 +202,29 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
// to their values. When their values change, their summaries are
|
||||
// updated to reflect the new value, per the Android Design
|
||||
// guidelines.
|
||||
bindPreferenceSummaryToValue(findPreference("notificationImportance"));
|
||||
|
||||
//With Oreo this setting should be set by the system dialog
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Preference notificationImportance = getPreferenceScreen().findPreference("notificationImportance");
|
||||
PreferenceGroup parent = notificationImportance.getParent();
|
||||
parent.removePreference(notificationImportance);
|
||||
Preference notificationImportanceOreo = new Preference(parent.getContext());
|
||||
notificationImportanceOreo.setTitle(R.string.pref_title_notification_importance);
|
||||
notificationImportanceOreo.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, "space.neothefox.laytray");
|
||||
intent.putExtra(Settings.EXTRA_CHANNEL_ID, IconService.channelId);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
parent.addPreference(notificationImportanceOreo);
|
||||
}
|
||||
else
|
||||
bindPreferenceSummaryToValue(findPreference("notificationImportance"));
|
||||
|
||||
bindPreferenceSummaryToValue(findPreference("textMode"));
|
||||
bindPreferenceSummaryToValue(findPreference("textSize"));
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<string name="title_activity_settings">Settings</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="unsupported_device_description" translatable="false">This phone is missing the BlackBerry Keyboard. LayTray will not work without it.</string>
|
||||
<string name="close">Close</string>
|
||||
<!-- Strings related to Settings -->
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user