diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/QueryLog.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/QueryLog.java index 7394f02..b8cbb5a 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/QueryLog.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/QueryLog.java @@ -12,7 +12,7 @@ import java.util.List; public class QueryLog { - private final static int MAX_HISTORY_SIZE = 64; + private final static int MAX_HISTORY_SIZE = 192; private static QueryLog _instance; public static QueryLog instance() { if (_instance == null) synchronized (QueryLog.class) { if (_instance == null) _instance = new QueryLog(); } return _instance; } diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/SCNSettings.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/SCNSettings.java index 029d1ce..5c578bc 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/SCNSettings.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/SCNSettings.java @@ -53,6 +53,7 @@ public class SCNSettings public boolean Enabled = true; public int LocalCacheSize = 500; public boolean EnableDeleteSwipe = false; + public int PreviewLineCount = 6; public final NotificationSettings PriorityLow = new NotificationSettings(PriorityEnum.LOW); public final NotificationSettings PriorityNorm = new NotificationSettings(PriorityEnum.NORMAL); @@ -77,6 +78,7 @@ public class SCNSettings Enabled = sharedPref.getBoolean("app_enabled", Enabled); LocalCacheSize = sharedPref.getInt("local_cache_size", LocalCacheSize); EnableDeleteSwipe = sharedPref.getBoolean("do_del_swipe", EnableDeleteSwipe); + PreviewLineCount = sharedPref.getInt("preview_line_count", PreviewLineCount); PriorityLow.EnableLED = sharedPref.getBoolean("priority_low:enabled_led", PriorityLow.EnableLED); PriorityLow.EnableSound = sharedPref.getBoolean("priority_low:enabled_sound", PriorityLow.EnableSound); @@ -124,6 +126,7 @@ public class SCNSettings e.putBoolean("app_enabled", Enabled); e.putInt( "local_cache_size", LocalCacheSize); e.putBoolean("do_del_swipe", EnableDeleteSwipe); + e.putInt( "preview_line_count", PreviewLineCount); e.putBoolean("priority_low:enabled_led", PriorityLow.EnableLED); e.putBoolean("priority_low:enabled_sound", PriorityLow.EnableSound); diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/util/TextChangedListener.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/util/TextChangedListener.java new file mode 100644 index 0000000..0d24f63 --- /dev/null +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/util/TextChangedListener.java @@ -0,0 +1,25 @@ +package com.blackforestbytes.simplecloudnotifier.util; + +import android.text.Editable; +import android.text.TextWatcher; + +public abstract class TextChangedListener implements TextWatcher { + private T target; + + public TextChangedListener(T target) { + this.target = target; + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) {} + + @Override + public void afterTextChanged(Editable s) { + this.onTextChanged(target, s); + } + + public abstract void onTextChanged(T target, Editable s); +} diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/MessageAdapter.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/MessageAdapter.java index 21cb332..4c95e0e 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/MessageAdapter.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/MessageAdapter.java @@ -13,6 +13,7 @@ import com.blackforestbytes.simplecloudnotifier.R; import com.blackforestbytes.simplecloudnotifier.SCNApp; import com.blackforestbytes.simplecloudnotifier.model.CMessage; import com.blackforestbytes.simplecloudnotifier.model.CMessageList; +import com.blackforestbytes.simplecloudnotifier.model.SCNSettings; import com.google.android.material.button.MaterialButton; import java.lang.ref.WeakReference; @@ -186,17 +187,19 @@ public class MessageAdapter extends RecyclerView.Adapter { if (data != null && data.IsExpandedInAdapter && !force) return; if (data != null) data.IsExpandedInAdapter = true; - if (tvMessage != null) tvMessage.setMaxLines(999); + if (tvMessage != null) tvMessage.setMaxLines(9999); if (btnDelete != null) btnDelete.setVisibility(View.VISIBLE); if (btnShare != null) btnShare.setVisibility(View.VISIBLE); } + private int norm(int i) { return (i<=0)?0:((i>9999)?9999:i); } + private void collapse(boolean force) { if (data != null && !data.IsExpandedInAdapter && !force) return; if (data != null) data.IsExpandedInAdapter = false; - if (tvMessage != null) tvMessage.setMaxLines(6); + if (tvMessage != null) tvMessage.setMaxLines(norm(SCNSettings.inst().PreviewLineCount)); if (btnDelete != null) btnDelete.setVisibility(View.GONE); if (btnShare != null) btnShare.setVisibility(View.GONE); } diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/SettingsFragment.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/SettingsFragment.java index 6e15076..5985a7f 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/SettingsFragment.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/SettingsFragment.java @@ -1,5 +1,6 @@ package com.blackforestbytes.simplecloudnotifier.view; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Color; import android.media.AudioAttributes; @@ -10,6 +11,7 @@ import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.text.Editable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -17,6 +19,7 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.EditText; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.Spinner; @@ -32,6 +35,7 @@ import com.blackforestbytes.simplecloudnotifier.lib.lambda.FI; import com.blackforestbytes.simplecloudnotifier.lib.string.Str; import com.blackforestbytes.simplecloudnotifier.model.SCNSettings; import com.blackforestbytes.simplecloudnotifier.service.IABService; +import com.blackforestbytes.simplecloudnotifier.util.TextChangedListener; import org.jetbrains.annotations.NotNull; @@ -51,6 +55,7 @@ public class SettingsFragment extends Fragment implements MusicPickerListener private TextView prefUpgradeAccount_msg; private TextView prefUpgradeAccount_info; private Switch prefEnableDeleteSwipe; + private EditText prefPreviewLineCount; private Switch prefMsgLowEnableSound; private TextView prefMsgLowRingtone_value; @@ -117,6 +122,7 @@ public class SettingsFragment extends Fragment implements MusicPickerListener prefUpgradeAccount_msg = v.findViewById(R.id.prefUpgradeAccount2); prefUpgradeAccount_info = v.findViewById(R.id.prefUpgradeAccount_info); prefEnableDeleteSwipe = v.findViewById(R.id.prefEnableDeleteSwipe); + prefPreviewLineCount = v.findViewById(R.id.prefPreviewLineCount); prefMsgLowEnableSound = v.findViewById(R.id.prefMsgLowEnableSound); prefMsgLowRingtone_value = v.findViewById(R.id.prefMsgLowRingtone_value); @@ -159,6 +165,7 @@ public class SettingsFragment extends Fragment implements MusicPickerListener prefLocalCacheSize.setAdapter(plcsa); } + @SuppressLint("SetTextI18n") private void updateUI() { SCNSettings s = SCNSettings.inst(); @@ -167,6 +174,7 @@ public class SettingsFragment extends Fragment implements MusicPickerListener if (prefAppEnabled.isChecked() != s.Enabled) prefAppEnabled.setChecked(s.Enabled); if (prefEnableDeleteSwipe.isChecked() != s.EnableDeleteSwipe) prefEnableDeleteSwipe.setChecked(s.EnableDeleteSwipe); + if (!prefPreviewLineCount.getText().toString().equals(Integer.toString(s.PreviewLineCount))) prefPreviewLineCount.setText(Integer.toString(s.PreviewLineCount)); prefUpgradeAccount.setVisibility( SCNSettings.inst().promode_local ? View.GONE : View.VISIBLE); prefUpgradeAccount_info.setVisibility(SCNSettings.inst().promode_local ? View.GONE : View.VISIBLE); @@ -220,6 +228,12 @@ public class SettingsFragment extends Fragment implements MusicPickerListener prefAppEnabled.setOnCheckedChangeListener((a,b) -> { boolean prev=s.Enabled; s.Enabled=b; saveAndUpdate(); updateEnabled(prev, b); }); prefEnableDeleteSwipe.setOnCheckedChangeListener((a,b) -> { s.EnableDeleteSwipe=b; saveAndUpdate(); }); + prefPreviewLineCount.addTextChangedListener(new TextChangedListener(prefPreviewLineCount) { + @Override + public void onTextChanged(EditText target, Editable ed) { + if (!ed.toString().isEmpty()) try { s.PreviewLineCount=Integer.parseInt(ed.toString()); saveAndUpdate(); } catch (Exception e) { /* */ } + } + }); prefLocalCacheSize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml index 7742e58..90b4ec2 100644 --- a/android/app/src/main/res/layout/activity_main.xml +++ b/android/app/src/main/res/layout/activity_main.xml @@ -1,15 +1,16 @@ - + android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto"> @@ -19,6 +20,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/toolbar" + app:titleTextColor="@color/colorOnPrimary" + app:tabTextColor="@color/colorOnPrimary" + app:tabSelectedTextColor="@color/colorSecondary" android:background="?attr/colorPrimary" android:elevation="6dp" android:minHeight="?attr/actionBarSize" /> diff --git a/android/app/src/main/res/layout/fragment_settings.xml b/android/app/src/main/res/layout/fragment_settings.xml index 6e7d47e..96c913b 100644 --- a/android/app/src/main/res/layout/fragment_settings.xml +++ b/android/app/src/main/res/layout/fragment_settings.xml @@ -95,6 +95,46 @@ android:layout_height="wrap_content" android:minHeight="48dp" /> + + + + + + + + + + #3F51B5 #FFFFFF + #ecf0f1 + #FF5722 + #000 #fa315b diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index f250e22..1a5a526 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -30,6 +30,7 @@ Enable notification vibration Upgrade account Delete messages by swiping left + Number of visibile lines in collapsed messages Thank you for supporting the app and using the pro mode Increase your daily quota, remove the ad banner and support the developer (that\'s me) Volume icon diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index e549594..7c9e4bf 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -4,14 +4,17 @@ -