setting stuff

This commit is contained in:
Mike Schwörer 2018-10-22 13:53:21 +02:00
parent 96a3cbc40a
commit 6dfd7e016b
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
7 changed files with 219 additions and 129 deletions

View File

@ -1,11 +1,13 @@
package com.blackforestbytes.simplecloudnotifier.model; package com.blackforestbytes.simplecloudnotifier.model;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri;
public class NotificationSettings public class NotificationSettings
{ {
public boolean EnableSound = false; public boolean EnableSound = false;
public String SoundSource = ""; public String SoundName = "";
public String SoundSource = Uri.EMPTY.toString();
public boolean RepeatSound = false; public boolean RepeatSound = false;
public boolean EnableLED = false; public boolean EnableLED = false;

View File

@ -51,27 +51,29 @@ public class SCNSettings
{ {
SharedPreferences sharedPref = SCNApp.getContext().getSharedPreferences("Config", Context.MODE_PRIVATE); SharedPreferences sharedPref = SCNApp.getContext().getSharedPreferences("Config", Context.MODE_PRIVATE);
quota_curr = sharedPref.getInt("quota_curr", 0); quota_curr = sharedPref.getInt( "quota_curr", 0);
quota_max = sharedPref.getInt("quota_max", 0); quota_max = sharedPref.getInt( "quota_max", 0);
user_id = sharedPref.getInt("user_id", -1); user_id = sharedPref.getInt( "user_id", -1);
user_key = sharedPref.getString("user_key", ""); user_key = sharedPref.getString("user_key", "");
fcm_token_local = sharedPref.getString("fcm_token_local", ""); fcm_token_local = sharedPref.getString("fcm_token_local", "");
fcm_token_server = sharedPref.getString("fcm_token_server", ""); fcm_token_server = sharedPref.getString("fcm_token_server", "");
Enabled = sharedPref.getBoolean("app_enabled", Enabled); Enabled = sharedPref.getBoolean("app_enabled", Enabled);
LocalCacheSize = sharedPref.getInt("local_cache_size", LocalCacheSize); LocalCacheSize = sharedPref.getInt("local_cache_size", LocalCacheSize);
PriorityLow.EnableLED = sharedPref.getBoolean("priority_low:enabled_led", PriorityLow.EnableLED); PriorityLow.EnableLED = sharedPref.getBoolean("priority_low:enabled_led", PriorityLow.EnableLED);
PriorityLow.EnableSound = sharedPref.getBoolean("priority_low:enabled_sound", PriorityLow.EnableSound); PriorityLow.EnableSound = sharedPref.getBoolean("priority_low:enabled_sound", PriorityLow.EnableSound);
PriorityLow.EnableVibration = sharedPref.getBoolean("priority_low:enabled_vibration", PriorityLow.EnableVibration); PriorityLow.EnableVibration = sharedPref.getBoolean("priority_low:enabled_vibration", PriorityLow.EnableVibration);
PriorityLow.RepeatSound = sharedPref.getBoolean("priority_low:repeat_sound", PriorityLow.RepeatSound); PriorityLow.RepeatSound = sharedPref.getBoolean("priority_low:repeat_sound", PriorityLow.RepeatSound);
PriorityLow.SoundSource = sharedPref.getString( "priority_low:sound_source", PriorityLow.SoundSource); PriorityLow.SoundName = sharedPref.getString( "priority_low:sound_name", PriorityLow.SoundName);
PriorityLow.LEDColor = sharedPref.getInt( "priority_low:led_color", PriorityLow.LEDColor); PriorityLow.SoundSource = sharedPref.getString( "priority_low:sound_source", PriorityLow.SoundSource);
PriorityLow.LEDColor = sharedPref.getInt( "priority_low:led_color", PriorityLow.LEDColor);
PriorityNorm.EnableLED = sharedPref.getBoolean("priority_norm:enabled_led", PriorityNorm.EnableLED); PriorityNorm.EnableLED = sharedPref.getBoolean("priority_norm:enabled_led", PriorityNorm.EnableLED);
PriorityNorm.EnableSound = sharedPref.getBoolean("priority_norm:enabled_sound", PriorityNorm.EnableSound); PriorityNorm.EnableSound = sharedPref.getBoolean("priority_norm:enabled_sound", PriorityNorm.EnableSound);
PriorityNorm.EnableVibration = sharedPref.getBoolean("priority_norm:enabled_vibration", PriorityNorm.EnableVibration); PriorityNorm.EnableVibration = sharedPref.getBoolean("priority_norm:enabled_vibration", PriorityNorm.EnableVibration);
PriorityNorm.RepeatSound = sharedPref.getBoolean("priority_norm:repeat_sound", PriorityNorm.RepeatSound); PriorityNorm.RepeatSound = sharedPref.getBoolean("priority_norm:repeat_sound", PriorityNorm.RepeatSound);
PriorityNorm.SoundName = sharedPref.getString( "priority_norm:sound_name", PriorityNorm.SoundName);
PriorityNorm.SoundSource = sharedPref.getString( "priority_norm:sound_source", PriorityNorm.SoundSource); PriorityNorm.SoundSource = sharedPref.getString( "priority_norm:sound_source", PriorityNorm.SoundSource);
PriorityNorm.LEDColor = sharedPref.getInt( "priority_norm:led_color", PriorityNorm.LEDColor); PriorityNorm.LEDColor = sharedPref.getInt( "priority_norm:led_color", PriorityNorm.LEDColor);
@ -79,6 +81,7 @@ public class SCNSettings
PriorityHigh.EnableSound = sharedPref.getBoolean("priority_high:enabled_sound", PriorityHigh.EnableSound); PriorityHigh.EnableSound = sharedPref.getBoolean("priority_high:enabled_sound", PriorityHigh.EnableSound);
PriorityHigh.EnableVibration = sharedPref.getBoolean("priority_high:enabled_vibration", PriorityHigh.EnableVibration); PriorityHigh.EnableVibration = sharedPref.getBoolean("priority_high:enabled_vibration", PriorityHigh.EnableVibration);
PriorityHigh.RepeatSound = sharedPref.getBoolean("priority_high:repeat_sound", PriorityHigh.RepeatSound); PriorityHigh.RepeatSound = sharedPref.getBoolean("priority_high:repeat_sound", PriorityHigh.RepeatSound);
PriorityHigh.SoundName = sharedPref.getString( "priority_high:sound_name", PriorityHigh.SoundName);
PriorityHigh.SoundSource = sharedPref.getString( "priority_high:sound_source", PriorityHigh.SoundSource); PriorityHigh.SoundSource = sharedPref.getString( "priority_high:sound_source", PriorityHigh.SoundSource);
PriorityHigh.LEDColor = sharedPref.getInt( "priority_high:led_color", PriorityHigh.LEDColor); PriorityHigh.LEDColor = sharedPref.getInt( "priority_high:led_color", PriorityHigh.LEDColor);
} }
@ -88,22 +91,22 @@ public class SCNSettings
SharedPreferences sharedPref = SCNApp.getContext().getSharedPreferences("Config", Context.MODE_PRIVATE); SharedPreferences sharedPref = SCNApp.getContext().getSharedPreferences("Config", Context.MODE_PRIVATE);
SharedPreferences.Editor e = sharedPref.edit(); SharedPreferences.Editor e = sharedPref.edit();
e.putInt( "quota_curr", quota_curr); e.putInt( "quota_curr", quota_curr);
e.putInt( "quota_max", quota_max); e.putInt( "quota_max", quota_max);
e.putInt( "user_id", user_id); e.putInt( "user_id", user_id);
e.putString("user_key", user_key); e.putString( "user_key", user_key);
e.putString("fcm_token_local", fcm_token_local); e.putString( "fcm_token_local", fcm_token_local);
e.putString("fcm_token_server", fcm_token_server); e.putString( "fcm_token_server", fcm_token_server);
e.putBoolean("app_enabled", Enabled); e.putBoolean("app_enabled", Enabled);
e.putInt( "local_cache_size", LocalCacheSize); e.putInt( "local_cache_size", LocalCacheSize);
e.putBoolean("priority_low:enabled_led", PriorityLow.EnableLED); e.putBoolean("priority_low:enabled_led", PriorityLow.EnableLED);
e.putBoolean("priority_low:enabled_sound", PriorityLow.EnableSound); e.putBoolean("priority_low:enabled_sound", PriorityLow.EnableSound);
e.putBoolean("priority_low:enabled_vibration", PriorityLow.EnableVibration); e.putBoolean("priority_low:enabled_vibration", PriorityLow.EnableVibration);
e.putBoolean("priority_low:repeat_sound", PriorityLow.RepeatSound); e.putBoolean("priority_low:repeat_sound", PriorityLow.RepeatSound);
e.putString( "priority_low:sound_source", PriorityLow.SoundSource); e.putString( "priority_low:sound_source", PriorityLow.SoundSource);
e.putInt( "priority_low:led_color", PriorityLow.LEDColor); e.putInt( "priority_low:led_color", PriorityLow.LEDColor);
e.putBoolean("priority_norm:enabled_led", PriorityNorm.EnableLED); e.putBoolean("priority_norm:enabled_led", PriorityNorm.EnableLED);
e.putBoolean("priority_norm:enabled_sound", PriorityNorm.EnableSound); e.putBoolean("priority_norm:enabled_sound", PriorityNorm.EnableSound);

View File

@ -16,9 +16,8 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import xyz.aprildown.ultimatemusicpicker.MusicPickerListener;
public class MainActivity extends AppCompatActivity implements MusicPickerListener public class MainActivity extends AppCompatActivity
{ {
public TabAdapter adpTabs; public TabAdapter adpTabs;
@ -54,14 +53,4 @@ public class MainActivity extends AppCompatActivity implements MusicPickerListen
CMessageList.inst().fullSave(); CMessageList.inst().fullSave();
} }
@Override
public void onMusicPick(@NotNull Uri uri, @NotNull String s) {
}
@Override
public void onPickCanceled() {
}
} }

View File

@ -1,57 +1,65 @@
package com.blackforestbytes.simplecloudnotifier.view; package com.blackforestbytes.simplecloudnotifier.view;
import android.content.Context;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.Switch; import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import com.blackforestbytes.simplecloudnotifier.R; import com.blackforestbytes.simplecloudnotifier.R;
import com.blackforestbytes.simplecloudnotifier.SCNApp;
import com.blackforestbytes.simplecloudnotifier.model.SCNSettings; import com.blackforestbytes.simplecloudnotifier.model.SCNSettings;
import org.jetbrains.annotations.NotNull;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import xyz.aprildown.ultimatemusicpicker.MusicPickerListener;
import xyz.aprildown.ultimatemusicpicker.UltimateMusicPicker; import xyz.aprildown.ultimatemusicpicker.UltimateMusicPicker;
public class SettingsFragment extends Fragment public class SettingsFragment extends Fragment implements MusicPickerListener
{ {
private Switch prefAppEnabled; private Switch prefAppEnabled;
private Spinner prefLocalCacheSize; private Spinner prefLocalCacheSize;
private Button prefUpgradeAccount;
private Switch prefMsgLowEnableSound; private Switch prefMsgLowEnableSound;
private TextView tvMsgLowRingtone_value; private TextView tvMsgLowRingtone_value;
private View prevMsgLowRingtone; private View prefMsgLowRingtone;
private Switch prefMsgLowRepeatSound; private Switch prefMsgLowRepeatSound;
private Switch prefMsgLowEnableLED; private Switch prefMsgLowEnableLED;
private TextView tvMsgLowLedColor; private View prefMsgLowLedColor_container;
private ImageView prefMsgLowLedColor; private ImageView prefMsgLowLedColor_value;
private Switch prefMsgLowEnableVibrations; private Switch prefMsgLowEnableVibrations;
private Switch prefMsgNormEnableSound; private Switch prefMsgNormEnableSound;
private TextView tvMsgNormRingtone_value; private TextView tvMsgNormRingtone_value;
private View prevMsgNormRingtone; private View prefMsgNormRingtone;
private Switch prefMsgNormRepeatSound; private Switch prefMsgNormRepeatSound;
private Switch prefMsgNormEnableLED; private Switch prefMsgNormEnableLED;
private TextView tvMsgNormLedColor; private View prefMsgNormLedColor_container;
private ImageView prefMsgNormLedColor; private ImageView prefMsgNormLedColor_value;
private Switch prefMsgNormEnableVibrations; private Switch prefMsgNormEnableVibrations;
private Switch prefMsgHighEnableSound; private Switch prefMsgHighEnableSound;
private TextView tvMsgHighRingtone_value; private TextView tvMsgHighRingtone_value;
private View prevMsgHighRingtone; private View prefMsgHighRingtone;
private Switch prefMsgHighRepeatSound; private Switch prefMsgHighRepeatSound;
private Switch prefMsgHighEnableLED; private Switch prefMsgHighEnableLED;
private TextView tvMsgHighLedColor; private View prefMsgHighLedColor_container;
private ImageView prefMsgHighLedColor; private ImageView prefMsgHighLedColor_value;
private Switch prefMsgHighEnableVibrations; private Switch prefMsgHighEnableVibrations;
private int musicPickerSwitch = -1;
public SettingsFragment() public SettingsFragment()
{ {
// Required empty public constructor // Required empty public constructor
@ -62,70 +70,102 @@ public class SettingsFragment extends Fragment
{ {
View v = inflater.inflate(R.layout.fragment_settings, container, false); View v = inflater.inflate(R.layout.fragment_settings, container, false);
{ initFields(v);
prefAppEnabled = v.findViewById(R.id.prefAppEnabled); updateUI();
prefLocalCacheSize = v.findViewById(R.id.prefLocalCacheSize); initListener();
prefMsgLowEnableSound = v.findViewById(R.id.prefMsgLowEnableSound);
tvMsgLowRingtone_value = v.findViewById(R.id.tvMsgLowRingtone_value);
prevMsgLowRingtone = v.findViewById(R.id.prevMsgLowRingtone);
prefMsgLowRepeatSound = v.findViewById(R.id.prefMsgLowRepeatSound);
prefMsgLowEnableLED = v.findViewById(R.id.prefMsgLowEnableLED);
tvMsgLowLedColor = v.findViewById(R.id.tvMsgLowLedColor);
prefMsgLowLedColor = v.findViewById(R.id.prefMsgLowLedColor);
prefMsgLowEnableVibrations = v.findViewById(R.id.prefMsgLowEnableVibrations);
prefMsgNormEnableSound = v.findViewById(R.id.prefMsgNormEnableSound);
tvMsgNormRingtone_value = v.findViewById(R.id.tvMsgNormRingtone_value);
prevMsgNormRingtone = v.findViewById(R.id.prevMsgNormRingtone);
prefMsgNormRepeatSound = v.findViewById(R.id.prefMsgNormRepeatSound);
prefMsgNormEnableLED = v.findViewById(R.id.prefMsgNormEnableLED);
tvMsgNormLedColor = v.findViewById(R.id.tvMsgNormLedColor);
prefMsgNormLedColor = v.findViewById(R.id.prefMsgNormLedColor);
prefMsgNormEnableVibrations = v.findViewById(R.id.prefMsgNormEnableVibrations);
prefMsgHighEnableSound = v.findViewById(R.id.prefMsgHighEnableSound);
tvMsgHighRingtone_value = v.findViewById(R.id.tvMsgHighRingtone_value);
prevMsgHighRingtone = v.findViewById(R.id.prevMsgHighRingtone);
prefMsgHighRepeatSound = v.findViewById(R.id.prefMsgHighRepeatSound);
prefMsgHighEnableLED = v.findViewById(R.id.prefMsgHighEnableLED);
tvMsgHighLedColor = v.findViewById(R.id.tvMsgHighLedColor);
prefMsgHighLedColor = v.findViewById(R.id.prefMsgHighLedColor);
prefMsgHighEnableVibrations = v.findViewById(R.id.prefMsgHighEnableVibrations);
}
{
SCNSettings s = SCNSettings.inst();
prefAppEnabled.setChecked(s.Enabled);
prefAppEnabled.setOnCheckedChangeListener((a,b) -> onUpdate());
ArrayAdapter<Integer> plcsa = new ArrayAdapter<>(v.getContext(), android.R.layout.simple_spinner_item, SCNSettings.CHOOSABLE_CACHE_SIZES);
plcsa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
prefLocalCacheSize.setAdapter(plcsa);
prefLocalCacheSize.setSelection(getCacheSizeIndex(s.LocalCacheSize));
prefLocalCacheSize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { onUpdate(); }
@Override public void onNothingSelected(AdapterView<?> parent) { onUpdate(); }
});
//TODO ...
prevMsgLowRingtone.setOnClickListener((a) -> chooseRingtoneLow());
}
return v; return v;
} }
private void onUpdate() private void initFields(View v)
{
prefAppEnabled = v.findViewById(R.id.prefAppEnabled);
prefLocalCacheSize = v.findViewById(R.id.prefLocalCacheSize);
prefUpgradeAccount = v.findViewById(R.id.prefUpgradeAccount);
prefMsgLowEnableSound = v.findViewById(R.id.prefMsgLowEnableSound);
tvMsgLowRingtone_value = v.findViewById(R.id.tvMsgLowRingtone_value);
prefMsgLowRingtone = v.findViewById(R.id.prefMsgLowRingtone);
prefMsgLowRepeatSound = v.findViewById(R.id.prefMsgLowRepeatSound);
prefMsgLowEnableLED = v.findViewById(R.id.prefMsgLowEnableLED);
prefMsgLowLedColor_value = v.findViewById(R.id.prefMsgLowLedColor_value);
prefMsgLowLedColor_container = v.findViewById(R.id.prefMsgLowLedColor_container);
prefMsgLowEnableVibrations = v.findViewById(R.id.prefMsgLowEnableVibrations);
prefMsgNormEnableSound = v.findViewById(R.id.prefMsgNormEnableSound);
tvMsgNormRingtone_value = v.findViewById(R.id.tvMsgNormRingtone_value);
prefMsgNormRingtone = v.findViewById(R.id.prefMsgNormRingtone);
prefMsgNormRepeatSound = v.findViewById(R.id.prefMsgNormRepeatSound);
prefMsgNormEnableLED = v.findViewById(R.id.prefMsgNormEnableLED);
prefMsgNormLedColor_value = v.findViewById(R.id.prefMsgNormLedColor_value);
prefMsgNormLedColor_container = v.findViewById(R.id.prefMsgNormLedColor_container);
prefMsgNormEnableVibrations = v.findViewById(R.id.prefMsgNormEnableVibrations);
prefMsgHighEnableSound = v.findViewById(R.id.prefMsgHighEnableSound);
tvMsgHighRingtone_value = v.findViewById(R.id.tvMsgHighRingtone_value);
prefMsgHighRingtone = v.findViewById(R.id.prefMsgHighRingtone);
prefMsgHighRepeatSound = v.findViewById(R.id.prefMsgHighRepeatSound);
prefMsgHighEnableLED = v.findViewById(R.id.prefMsgHighEnableLED);
prefMsgHighLedColor_value = v.findViewById(R.id.prefMsgHighLedColor_value);
prefMsgHighLedColor_container = v.findViewById(R.id.prefMsgHighLedColor_container);
prefMsgHighEnableVibrations = v.findViewById(R.id.prefMsgHighEnableVibrations);
}
private void updateUI()
{
SCNSettings s = SCNSettings.inst();
Context c = getContext();
if (c == null) return;
prefAppEnabled.setChecked(s.Enabled);
ArrayAdapter<Integer> plcsa = new ArrayAdapter<>(c, android.R.layout.simple_spinner_item, SCNSettings.CHOOSABLE_CACHE_SIZES);
plcsa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
prefLocalCacheSize.setAdapter(plcsa);
prefLocalCacheSize.setSelection(getCacheSizeIndex(s.LocalCacheSize));
prefMsgLowEnableSound.setChecked(s.PriorityLow.EnableSound);
tvMsgLowRingtone_value.setText(s.PriorityLow.SoundName);
prefMsgLowRepeatSound.setChecked(s.PriorityLow.RepeatSound);
prefMsgLowEnableLED.setChecked(s.PriorityLow.EnableLED);
prefMsgLowLedColor_value.setColorFilter(s.PriorityLow.LEDColor);
prefMsgLowEnableVibrations.setChecked(s.PriorityLow.EnableVibration);
}
private void initListener()
{ {
SCNSettings s = SCNSettings.inst(); SCNSettings s = SCNSettings.inst();
s.Enabled = prefAppEnabled.isChecked(); prefAppEnabled.setOnCheckedChangeListener((a,b) -> { s.Enabled=b; saveAndUpdate(); });
s.LocalCacheSize = prefLocalCacheSize.getSelectedItemPosition()>=0 ? SCNSettings.CHOOSABLE_CACHE_SIZES[prefLocalCacheSize.getSelectedItemPosition()] : 100;
s.save(); prefLocalCacheSize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
s.LocalCacheSize = prefLocalCacheSize.getSelectedItemPosition()>=0 ? SCNSettings.CHOOSABLE_CACHE_SIZES[prefLocalCacheSize.getSelectedItemPosition()] : 100;
saveAndUpdate();
}
@Override public void onNothingSelected(AdapterView<?> parent) { /* */ }
});
prefUpgradeAccount.setOnClickListener(a -> onUpgradeAccount());
prefMsgLowEnableSound.setOnCheckedChangeListener((a,b) -> { s.PriorityLow.EnableSound=b; saveAndUpdate(); });
prefMsgLowRingtone.setOnClickListener(a -> chooseRingtoneLow());
prefMsgLowRepeatSound.setOnCheckedChangeListener((a,b) -> { s.PriorityLow.RepeatSound=b; saveAndUpdate(); });
prefMsgLowEnableLED.setOnCheckedChangeListener((a,b) -> { s.PriorityLow.EnableLED=b; saveAndUpdate(); });
prefMsgLowLedColor_container.setOnClickListener(a -> chooseLEDColorLow());
prefMsgLowEnableVibrations.setOnCheckedChangeListener((a,b) -> { s.PriorityLow.EnableVibration=b; saveAndUpdate(); });
}
private void saveAndUpdate()
{
SCNSettings.inst().save();
updateUI();
}
private void onUpgradeAccount()
{
//TODO
} }
private int getCacheSizeIndex(int value) private int getCacheSizeIndex(int value)
@ -139,14 +179,64 @@ public class SettingsFragment extends Fragment
private void chooseRingtoneLow() private void chooseRingtoneLow()
{ {
musicPickerSwitch = 1;
new UltimateMusicPicker() new UltimateMusicPicker()
.windowTitle("Choose notification sound") .windowTitle("Choose notification sound")
.removeSilent() .removeSilent()
.streamType(AudioManager.STREAM_ALARM) .streamType(AudioManager.STREAM_ALARM)
.ringtone() .ringtone()
.notification() .notification()
.alarm() .alarm()
.music() .music()
.goWithDialog(SCNApp.getMainActivity().getSupportFragmentManager()); .goWithDialog(getChildFragmentManager());
}
private void chooseRingtoneNorm()
{
musicPickerSwitch = 2;
new UltimateMusicPicker()
.windowTitle("Choose notification sound")
.removeSilent()
.streamType(AudioManager.STREAM_ALARM)
.ringtone()
.notification()
.alarm()
.music()
.goWithDialog(getChildFragmentManager());
}
private void chooseRingtoneHigh()
{
musicPickerSwitch = 3;
new UltimateMusicPicker()
.windowTitle("Choose notification sound")
.removeSilent()
.streamType(AudioManager.STREAM_ALARM)
.ringtone()
.notification()
.alarm()
.music()
.goWithDialog(getChildFragmentManager());
}
private void chooseLEDColorLow()
{
//
}
@Override
public void onMusicPick(@NotNull Uri uri, @NotNull String s)
{
if (musicPickerSwitch == 1) { SCNSettings.inst().PriorityLow.SoundSource =uri.toString(); SCNSettings.inst().PriorityLow.SoundName =s; saveAndUpdate(); }
if (musicPickerSwitch == 2) { SCNSettings.inst().PriorityNorm.SoundSource=uri.toString(); SCNSettings.inst().PriorityNorm.SoundName=s; saveAndUpdate(); }
if (musicPickerSwitch == 3) { SCNSettings.inst().PriorityHigh.SoundSource=uri.toString(); SCNSettings.inst().PriorityHigh.SoundName=s; saveAndUpdate(); }
musicPickerSwitch = -1;
}
@Override
public void onPickCanceled()
{
musicPickerSwitch = -1;
} }
} }

View File

@ -26,6 +26,7 @@
<TextView <TextView
android:background="@color/colorHeader" android:background="@color/colorHeader"
android:textColor="@color/colorHeaderForeground"
android:textSize="16sp" android:textSize="16sp"
android:padding="4dp" android:padding="4dp"
android:text="@string/str_common_settings" android:text="@string/str_common_settings"
@ -104,7 +105,7 @@
<Button <Button
android:id="@+id/prefUpgradeAccount" android:id="@+id/prefUpgradeAccount"
android:text="Upgrade account" android:text="@string/str_upgrade_account"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@ -129,6 +130,7 @@
<TextView <TextView
android:background="@color/colorHeader" android:background="@color/colorHeader"
android:textColor="@color/colorHeaderForeground"
android:textSize="16sp" android:textSize="16sp"
android:padding="4dp" android:padding="4dp"
android:text="@string/str_header_prio0" android:text="@string/str_header_prio0"
@ -168,7 +170,7 @@
android:minHeight="48dp"> android:minHeight="48dp">
<LinearLayout <LinearLayout
android:id="@+id/prevMsgLowRingtone" android:id="@+id/prefMsgLowRingtone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
@ -252,6 +254,7 @@
android:background="#c0c0c0"/> android:background="#c0c0c0"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/prefMsgLowLedColor_container"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -259,13 +262,12 @@
android:minHeight="48dp"> android:minHeight="48dp">
<TextView <TextView
android:id="@+id/tvMsgLowLedColor"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/str_ledcolor" android:text="@string/str_ledcolor"
android:textColor="#000" android:textColor="#000"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/prefMsgLowLedColor" app:layout_constraintEnd_toStartOf="@+id/prefMsgLowLedColor_value"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -273,7 +275,7 @@
<ImageView <ImageView
android:src="@drawable/circle" android:src="@drawable/circle"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:id="@+id/prefMsgLowLedColor" android:id="@+id/prefMsgLowLedColor_value"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:spinnerMode="dialog" android:spinnerMode="dialog"
@ -326,6 +328,7 @@
<TextView <TextView
android:background="@color/colorHeader" android:background="@color/colorHeader"
android:textColor="@color/colorHeaderForeground"
android:textSize="16sp" android:textSize="16sp"
android:padding="4dp" android:padding="4dp"
android:text="@string/str_header_prio1" android:text="@string/str_header_prio1"
@ -365,7 +368,7 @@
android:minHeight="48dp"> android:minHeight="48dp">
<LinearLayout <LinearLayout
android:id="@+id/prevMsgNormRingtone" android:id="@+id/prefMsgNormRingtone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
@ -449,6 +452,7 @@
android:background="#c0c0c0"/> android:background="#c0c0c0"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/prefMsgNormLedColor_container"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -456,13 +460,12 @@
android:minHeight="48dp"> android:minHeight="48dp">
<TextView <TextView
android:id="@+id/tvMsgNormLedColor"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/str_ledcolor" android:text="@string/str_ledcolor"
android:textColor="#000" android:textColor="#000"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/prefMsgNormLedColor" app:layout_constraintEnd_toStartOf="@+id/prefMsgNormLedColor_value"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -470,7 +473,7 @@
<ImageView <ImageView
android:src="@drawable/circle" android:src="@drawable/circle"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:id="@+id/prefMsgNormLedColor" android:id="@+id/prefMsgNormLedColor_value"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:spinnerMode="dialog" android:spinnerMode="dialog"
@ -523,6 +526,7 @@
<TextView <TextView
android:background="@color/colorHeader" android:background="@color/colorHeader"
android:textColor="@color/colorHeaderForeground"
android:textSize="16sp" android:textSize="16sp"
android:padding="4dp" android:padding="4dp"
android:text="@string/str_header_prio2" android:text="@string/str_header_prio2"
@ -562,7 +566,7 @@
android:minHeight="48dp"> android:minHeight="48dp">
<LinearLayout <LinearLayout
android:id="@+id/prevMsgHighRingtone" android:id="@+id/prefMsgHighRingtone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
@ -646,6 +650,7 @@
android:background="#c0c0c0"/> android:background="#c0c0c0"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/prefMsgHighLedColor_container"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -653,13 +658,12 @@
android:minHeight="48dp"> android:minHeight="48dp">
<TextView <TextView
android:id="@+id/tvMsgHighLedColor"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/str_ledcolor" android:text="@string/str_ledcolor"
android:textColor="#000" android:textColor="#000"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/prefMsgHighLedColor" app:layout_constraintEnd_toStartOf="@+id/prefMsgHighLedColor_value"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -667,7 +671,7 @@
<ImageView <ImageView
android:src="@drawable/circle" android:src="@drawable/circle"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:id="@+id/prefMsgHighLedColor" android:id="@+id/prefMsgHighLedColor_value"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:spinnerMode="dialog" android:spinnerMode="dialog"

View File

@ -3,7 +3,8 @@
<color name="colorPrimary">#3F51B5</color> <color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color> <color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color> <color name="colorAccent">#FF4081</color>
<color name="colorHeader">#67809F</color> <color name="colorHeader">#3F51B5</color>
<color name="colorHeaderForeground">#FFFFFF</color>
<color name="colorBlack">#000</color> <color name="colorBlack">#000</color>
</resources> </resources>

View File

@ -27,4 +27,5 @@
<string name="str_enable_led">Enable notification light</string> <string name="str_enable_led">Enable notification light</string>
<string name="str_ledcolor">Notification light color</string> <string name="str_ledcolor">Notification light color</string>
<string name="str_enable_vibration">Enable notification vibration</string> <string name="str_enable_vibration">Enable notification vibration</string>
<string name="str_upgrade_account">Upgrade account</string>
</resources> </resources>