Sorted out a basic colour choice for Notifications, when you have Silent turned on. NB. I can't test it as my phone only has red as a colour.

This commit is contained in:
PhotonQyv 2017-08-29 20:10:41 +01:00
parent 0c09a86800
commit 0d6c60844c
6 changed files with 145 additions and 2 deletions

View File

@ -26,10 +26,14 @@ import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
@ -49,6 +53,9 @@ public class SettingsNotificationsFragment extends Fragment {
private Context context;
private int style;
int count = 0;
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
@ -217,6 +224,10 @@ public class SettingsNotificationsFragment extends Fragment {
}
});
final Spinner led_colour_spinner = (Spinner) rootView.findViewById(R.id.led_colour_spinner);
final TextView ledLabel = (TextView) rootView.findViewById(R.id.set_led_colour_label);
switchCompatSilent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -224,8 +235,55 @@ public class SettingsNotificationsFragment extends Fragment {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_NOTIF_SILENT, isChecked);
editor.apply();
if (isChecked) {
ledLabel.setEnabled(true);
led_colour_spinner.setEnabled(true);
} else {
ledLabel.setEnabled(false);
for (View lol : led_colour_spinner.getTouchables()) {
lol.setEnabled(false);
}
}
}
});
if (sharedpreferences.getBoolean(Helper.SET_NOTIF_SILENT, false)) {
ledLabel.setEnabled(true);
led_colour_spinner.setEnabled(true);
ArrayAdapter<CharSequence> adapterLEDColour = ArrayAdapter.createFromResource(getActivity(),
R.array.led_colours, android.R.layout.simple_spinner_item);
led_colour_spinner.setAdapter(adapterLEDColour);
int positionSpinnerLEDColour = (sharedpreferences.getInt(Helper.SET_LED_COLOUR, Helper.LED_COLOUR));
led_colour_spinner.setSelection(positionSpinnerLEDColour);
led_colour_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (count > 0) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putInt(Helper.SET_LED_COLOUR, position);
editor.apply();
} else {
count++;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
else {
ledLabel.setEnabled(false);
for (View lol : led_colour_spinner.getTouchables()) {
lol.setEnabled(false);
}
}
if( theme == Helper.THEME_LIGHT) {
settings_time_from.setTextColor(ContextCompat.getColor(context, R.color.white));
settings_time_to.setTextColor(ContextCompat.getColor(context, R.color.white));

View File

@ -200,6 +200,7 @@ public class Helper {
public static final String SET_PREVIEW_REPLIES = "set_preview_replies";
public static final String SET_PREVIEW_REPLIES_PP = "set_preview_replies_pp";
public static final String SET_TRANSLATOR = "set_translator";
public static final String SET_LED_COLOUR = "set_led_colour";
public static final int ATTACHMENT_ALWAYS = 1;
public static final int ATTACHMENT_WIFI = 2;
@ -210,6 +211,8 @@ public class Helper {
public static final int THEME_MENU = 2;
public static final int THEME_MENU_TABS = 3;
public static final int LED_COLOUR = 0;
public static final int TRANS_YANDEX = 0;
public static final int TRANS_GOOGLE = 1;
public static final int TRANS_NONE = 2;
@ -234,7 +237,6 @@ public class Helper {
public static final String EP_AUTHORIZE = "/oauth/authorize";
//Refresh job
//Refresh job
public static final int MINUTES_BETWEEN_NOTIFICATIONS_REFRESH = 15;
public static final int MINUTES_BETWEEN_HOME_TIMELINE = 30;
@ -599,7 +601,34 @@ public class Helper {
String soundUri = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.getPackageName() +"/";
notificationBuilder.setSound(Uri.parse(soundUri + R.raw.boop));
}
notificationBuilder.setLights(Color.BLUE, 500, 1000);
int ledColour = Color.BLUE;
switch (sharedpreferences.getInt(Helper.SET_LED_COLOUR, Helper.LED_COLOUR)) {
case 0: // BLUE
ledColour = Color.BLUE;
break;
case 1: // CYAN
ledColour = Color.CYAN;
break;
case 2: // MAGENTA
ledColour = Color.MAGENTA;
break;
case 3: // GREEN
ledColour = Color.GREEN;
break;
case 4: // RED
ledColour = Color.RED;
break;
case 5: // YELLOW
ledColour = Color.YELLOW;
break;
case 6: // WHITE
ledColour = Color.WHITE;
break;
}
notificationBuilder.setLights(ledColour, 500, 1000);
notificationBuilder.setContentTitle(title);
notificationBuilder.setLargeIcon(icon);
notificationManager.notify(notificationId, notificationBuilder.build());

View File

@ -173,6 +173,25 @@
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/set_led_colour_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:text="@string/set_led_colour"/>
<Spinner
android:id="@+id/led_colour_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/led_colours"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -335,6 +335,18 @@
<item>Nein</item>
</string-array>
<string name="set_led_colour">Set LED colour:</string>
<string-array name="led_colours">
<item>Blue</item>
<item>Cyan</item>
<item>Magenta</item>
<item>Green</item>
<item>Red</item>
<item>Yellow</item>
<item>White</item>
</string-array>
<string name="action_block">Blockiere</string>
<string name="action_unblock">Nicht mehr blockieren</string>
<string name="action_mute">Stummschalten</string>

View File

@ -329,6 +329,19 @@
<item>Google</item>
<item>Non</item>
</string-array>
<string name="set_led_colour">Set LED colour:</string>
<string-array name="led_colours">
<item>Blue</item>
<item>Cyan</item>
<item>Magenta</item>
<item>Green</item>
<item>Red</item>
<item>Yellow</item>
<item>White</item>
</string-array>
<string name="set_title_news">Actualités</string>
<string name="set_notification_news">Notifier lors de nouveaux pouets sur la page d\'accueil</string>
<string name="set_show_error_messages">Afficher les messages d\'erreur</string>

View File

@ -336,6 +336,18 @@
<item>No</item>
</string-array>
<string name="set_led_colour">Set LED colour:</string>
<string-array name="led_colours">
<item>Blue</item>
<item>Cyan</item>
<item>Magenta</item>
<item>Green</item>
<item>Red</item>
<item>Yellow</item>
<item>White</item>
</string-array>
<string name="set_title_news">News</string>
<string name="set_notification_news">Notify for new toots on the home timeline</string>
<string name="set_show_error_messages">Display error messages</string>