Browse Source

Added settings for notification light

main
M66B 6 years ago
parent
commit
d2cb26e325
5 changed files with 35 additions and 2 deletions
  1. +12
    -0
      app/src/main/java/eu/faircode/email/FragmentOptions.java
  2. +1
    -0
      app/src/main/java/eu/faircode/email/FragmentSetup.java
  3. +10
    -1
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java
  4. +11
    -1
      app/src/main/res/layout/fragment_options.xml
  5. +1
    -0
      app/src/main/res/values/strings.xml

+ 12
- 0
app/src/main/java/eu/faircode/email/FragmentOptions.java View File

@ -35,6 +35,7 @@ import androidx.annotation.Nullable;
public class FragmentOptions extends FragmentEx {
private CheckBox cbCompressImap;
private CheckBox cbAvatars;
private CheckBox cbLight;
private CheckBox cbDebug;
@Override
@ -47,6 +48,7 @@ public class FragmentOptions extends FragmentEx {
// Get controls
cbCompressImap = view.findViewById(R.id.cbCompressImap);
cbAvatars = view.findViewById(R.id.cbAvatars);
cbLight = view.findViewById(R.id.cbLight);
cbDebug = view.findViewById(R.id.cbDebug);
// Wire controls
@ -77,6 +79,14 @@ public class FragmentOptions extends FragmentEx {
}
});
cbLight.setChecked(prefs.getBoolean("light", false));
cbLight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("light", checked).apply();
}
});
cbDebug.setChecked(prefs.getBoolean("debug", false));
cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@ -85,6 +95,8 @@ public class FragmentOptions extends FragmentEx {
}
});
cbLight.setVisibility(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE);
return view;
}
}

+ 1
- 0
app/src/main/java/eu/faircode/email/FragmentSetup.java View File

@ -102,6 +102,7 @@ public class FragmentSetup extends FragmentEx {
static final List<String> EXPORT_SETTINGS = Arrays.asList(
"compress",
"avatars",
"light",
"theme"
);


+ 10
- 1
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -26,6 +26,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.media.RingtoneManager;
import android.net.ConnectivityManager;
import android.net.Network;
@ -270,6 +271,8 @@ public class ServiceSynchronize extends LifecycleService {
}
private Notification.Builder getNotificationUnseen(List<EntityMessage> messages) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Build pending intent
Intent intent = new Intent(this, ActivityView.class);
intent.setAction("unseen");
@ -301,7 +304,13 @@ public class ServiceSynchronize extends LifecycleService {
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setDeleteIntent(pid);
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("pro", false)) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O &&
prefs.getBoolean("light", true)) {
builder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS);
builder.setLights(0xff00ff00, 1000, 1000);
}
if (prefs.getBoolean("pro", false)) {
DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
StringBuilder sb = new StringBuilder();
for (EntityMessage message : messages) {


+ 11
- 1
app/src/main/res/layout/fragment_options.xml View File

@ -31,6 +31,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbCompressImap" />
<CheckBox
android:id="@+id/cbLight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAvatars" />
<CheckBox
android:id="@+id/cbDebug"
android:layout_width="wrap_content"
@ -39,6 +49,6 @@
android:layout_marginTop="12dp"
android:text="@string/title_advanced_debug"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAvatars" />
app:layout_constraintTop_toBottomOf="@id/cbLight" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

+ 1
- 0
app/src/main/res/values/strings.xml View File

@ -78,6 +78,7 @@
<string name="title_advanced">Advanced options</string>
<string name="title_advanced_compress_imap">Compress IMAP data</string>
<string name="title_advanced_avatars">Show contact photos</string>
<string name="title_advanced_light">Use notification light</string>
<string name="title_advanced_debug">Debug</string>
<string name="title_select">Select &#8230;</string>


Loading…
Cancel
Save