1
0
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:
NeoTheFox 2018-07-26 23:11:33 +03:00
parent 20331b629b
commit bccc0bca6c
5 changed files with 53 additions and 32 deletions

View File

@ -1,7 +1,7 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 26 compileSdkVersion 27
defaultConfig { defaultConfig {
applicationId "space.neothefox.laytray" applicationId "space.neothefox.laytray"
minSdkVersion 23 minSdkVersion 23
@ -21,10 +21,10 @@ android {
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') 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.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:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.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'
} }

View File

@ -13,7 +13,6 @@ import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode; import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.drawable.Icon; import android.graphics.drawable.Icon;
import android.os.Build; import android.os.Build;
@ -27,7 +26,8 @@ import static android.graphics.Paint.ANTI_ALIAS_FLAG;
public class IconService extends AccessibilityService public class IconService extends AccessibilityService
implements SharedPreferences.OnSharedPreferenceChangeListener{ 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(); private final AccessibilityServiceInfo serviceInfo = new AccessibilityServiceInfo();
SharedPreferences layouts; SharedPreferences layouts;
@ -53,12 +53,16 @@ implements SharedPreferences.OnSharedPreferenceChangeListener{
iconManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); iconManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
iconChannel = new NotificationChannel( iconChannel = new NotificationChannel(
"laytray", channelId,
"LayTray", "LayTray IconChannel",
Integer.parseInt(options.getString("notificationImportance", "0"))); NotificationManager.IMPORTANCE_DEFAULT);
iconChannel.setShowBadge(false); iconChannel.setShowBadge(false);
iconChannel.enableLights(false);
iconChannel.enableVibration(false);
iconChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET); iconChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
iconManager.createNotificationChannel(iconChannel);
} }
} }
@ -81,12 +85,11 @@ implements SharedPreferences.OnSharedPreferenceChangeListener{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{ {
iconChannel.setImportance( indicator = new Notification.Builder(this, channelId)
Integer.parseInt(options.getString("notificationImportance", "0")));
indicator = new Notification.Builder(this, "laytray")
.setSmallIcon(smallIcon) .setSmallIcon(smallIcon)
.setContentTitle(toast) .setContentTitle(toast)
.setOngoing(true) .setOngoing(true)
.setVisibility(Notification.VISIBILITY_SECRET)
.build(); .build();
} }
else { else {

View File

@ -8,11 +8,12 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.os.Build; import android.os.Build;
import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -21,7 +22,6 @@ import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.util.Log;
import android.widget.Space; import android.widget.Space;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -47,7 +47,13 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
addButton.setOnClickListener(this); addButton.setOnClickListener(this);
layouts.registerOnSharedPreferenceChangeListener(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); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.unsupported_device) builder.setTitle(R.string.unsupported_device)
@ -55,13 +61,6 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
.setNeutralButton(R.string.close, this) .setNeutralButton(R.string.close, this)
.show(); .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() protected void updateLayouts()

View File

@ -6,23 +6,20 @@ import android.app.FragmentManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.preference.RingtonePreference; import android.provider.Settings;
import android.text.TextUtils; import android.support.annotation.Nullable;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBar;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
@ -205,7 +202,29 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
// to their values. When their values change, their summaries are // to their values. When their values change, their summaries are
// updated to reflect the new value, per the Android Design // updated to reflect the new value, per the Android Design
// guidelines. // guidelines.
//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("notificationImportance"));
bindPreferenceSummaryToValue(findPreference("textMode")); bindPreferenceSummaryToValue(findPreference("textMode"));
bindPreferenceSummaryToValue(findPreference("textSize")); bindPreferenceSummaryToValue(findPreference("textSize"));

View File

@ -6,7 +6,7 @@
<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">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> <string name="close">Close</string>
<!-- Strings related to Settings --> <!-- Strings related to Settings -->