Merge branch 'custom_notifications'
@@ -16,6 +16,13 @@
|
||||
</activity>
|
||||
<activity android:name=".PreferenceActivity"
|
||||
android:parentActivityName=".MainActivity"/>
|
||||
|
||||
<receiver android:name=".createnotification.NotificationAlarmReceiver"
|
||||
android:enabled="true">
|
||||
<intent-filter>
|
||||
<action android:name="net.headlezz.notificationbroadcast" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -10,6 +10,8 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import net.headlezz.notificationlogger.createnotification.NotificationCreationFragment;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package net.headlezz.notificationlogger;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class NotificationCreationFragment extends Fragment {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
TextView textView = new TextView(getContext());
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
textView.setText(getClass().getSimpleName());
|
||||
return textView;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package net.headlezz.notificationlogger.createnotification;
|
||||
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.support.v7.app.NotificationCompat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class DispatchableNotification {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private String mMessage;
|
||||
private String mTitle;
|
||||
private int mId;
|
||||
|
||||
private boolean mSound;
|
||||
private boolean mVibrate;
|
||||
private boolean mBlink;
|
||||
private boolean mAutoCancel;
|
||||
|
||||
private int mIcon;
|
||||
private String mCategory;
|
||||
|
||||
public DispatchableNotification(Context mContext, String mMessage, String mTitle, int mId, boolean mSound, boolean mVibrate, boolean mBlink, boolean mAutoCancel, int mIcon, String mCategory) {
|
||||
this.mContext = mContext;
|
||||
this.mMessage = mMessage;
|
||||
this.mTitle = mTitle;
|
||||
this.mId = mId;
|
||||
this.mSound = mSound;
|
||||
this.mVibrate = mVibrate;
|
||||
this.mBlink = mBlink;
|
||||
this.mAutoCancel = mAutoCancel;
|
||||
this.mIcon = mIcon;
|
||||
this.mCategory = mCategory;
|
||||
}
|
||||
|
||||
private Notification buildNotification() {
|
||||
int defaults;
|
||||
if (mSound && mVibrate && mBlink)
|
||||
defaults = Notification.DEFAULT_ALL;
|
||||
else {
|
||||
if (mSound) {
|
||||
if (mVibrate)
|
||||
defaults = Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;
|
||||
else if (mBlink)
|
||||
defaults = Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS;
|
||||
else
|
||||
defaults = Notification.DEFAULT_SOUND;
|
||||
} else if (mVibrate) {
|
||||
if (mBlink)
|
||||
defaults = Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS;
|
||||
else
|
||||
defaults = Notification.DEFAULT_VIBRATE;
|
||||
} else
|
||||
defaults = Notification.DEFAULT_LIGHTS;
|
||||
}
|
||||
|
||||
return new NotificationCompat.Builder(mContext)
|
||||
.setContentText(mMessage)
|
||||
.setContentTitle(mTitle)
|
||||
.setSmallIcon(mIcon)
|
||||
.setCategory(mCategory)
|
||||
.setAutoCancel(mAutoCancel)
|
||||
.setDefaults(defaults)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void dispatch() {
|
||||
NotificationManagerCompat.from(mContext).notify(mId, buildNotification());
|
||||
}
|
||||
|
||||
public void shedule(Date date) {
|
||||
Intent notificationIntent = new Intent();
|
||||
notificationIntent.setAction(NotificationAlarmReceiver.BROADCAST_INTENT_ACTION);
|
||||
Bundle b = new Bundle();
|
||||
serializeToBundle(b);
|
||||
notificationIntent.putExtras(b);
|
||||
|
||||
PendingIntent pI = PendingIntent.getBroadcast(mContext, mId, notificationIntent, 0);
|
||||
AlarmManager am = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
|
||||
am.set(AlarmManager.RTC_WAKEUP, date.getTime(), pI);
|
||||
}
|
||||
|
||||
public void serializeToBundle(Bundle b) {
|
||||
b.putString("message", mMessage);
|
||||
b.putString("title", mTitle);
|
||||
b.putInt("id", mId);
|
||||
b.putBoolean("sound", mSound);
|
||||
b.putBoolean("vibrate", mVibrate);
|
||||
b.putBoolean("blink", mBlink);
|
||||
b.putBoolean("autocancel", mAutoCancel);
|
||||
b.putInt("icon", mIcon);
|
||||
b.putString("category", mCategory);
|
||||
}
|
||||
|
||||
public static DispatchableNotification fromBundle(Context context, Bundle b) {
|
||||
return new DispatchableNotification.Builder(context)
|
||||
.setMessage(b.getString("message"))
|
||||
.setTitle(b.getString("title"))
|
||||
.setId(b.getInt("id"))
|
||||
.setSound(b.getBoolean("sound"))
|
||||
.setVibrate(b.getBoolean("vibrate"))
|
||||
.setBlink(b.getBoolean("blink"))
|
||||
.setAutoCancel(b.getBoolean("autocancel"))
|
||||
.setIcon(b.getInt("icon"))
|
||||
.setCategory(b.getString("category"))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private Context mContext;
|
||||
|
||||
private String mMessage;
|
||||
private String mTitle;
|
||||
private int mId;
|
||||
|
||||
private boolean mSound;
|
||||
private boolean mVibrate;
|
||||
private boolean mBlink;
|
||||
private boolean mAutoCancel;
|
||||
|
||||
private int mIcon;
|
||||
private String mCategory;
|
||||
|
||||
public Builder(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public Builder setMessage(String message) {
|
||||
this.mMessage = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setTitle(String title) {
|
||||
this.mTitle = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setId(int id) {
|
||||
this.mId = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSound(boolean sound) {
|
||||
this.mSound = sound;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setVibrate(boolean vibrate) {
|
||||
this.mVibrate = vibrate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBlink(boolean blink) {
|
||||
this.mBlink = blink;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAutoCancel(boolean autoCancel) {
|
||||
this.mAutoCancel = autoCancel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setIcon(int icon) {
|
||||
this.mIcon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCategory(String category) {
|
||||
this.mCategory = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DispatchableNotification build() {
|
||||
return new DispatchableNotification(
|
||||
mContext,
|
||||
mMessage,
|
||||
mTitle,
|
||||
mId,
|
||||
mSound,
|
||||
mVibrate,
|
||||
mBlink,
|
||||
mAutoCancel,
|
||||
mIcon,
|
||||
mCategory
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.headlezz.notificationlogger.createnotification;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import net.headlezz.notificationlogger.createnotification.DispatchableNotification;
|
||||
|
||||
public class NotificationAlarmReceiver extends BroadcastReceiver {
|
||||
|
||||
public static String BROADCAST_INTENT_ACTION = "net.headlezz.notificationbroadcast";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
DispatchableNotification dn = DispatchableNotification.fromBundle(context, intent.getExtras());
|
||||
dn.dispatch();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package net.headlezz.notificationlogger.createnotification;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import net.headlezz.notificationlogger.R;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class NotificationCreationFragment extends Fragment implements View.OnClickListener, NotificationScheduleHelper.NotificationScheduleManagerCallback {
|
||||
|
||||
// TODO intent
|
||||
|
||||
@Bind(R.id.create_etId)
|
||||
EditText etId;
|
||||
|
||||
@Bind(R.id.create_etTitle)
|
||||
EditText etTitle;
|
||||
|
||||
@Bind(R.id.create_etMessage)
|
||||
EditText etMessage;
|
||||
|
||||
@Bind(R.id.create_cbAutoCancel)
|
||||
CheckBox cbAutoCancel;
|
||||
|
||||
@Bind(R.id.create_cbBlink)
|
||||
CheckBox cbBlink;
|
||||
|
||||
@Bind(R.id.create_cbSound)
|
||||
CheckBox cbSound;
|
||||
|
||||
@Bind(R.id.create_cbVibrate)
|
||||
CheckBox cbVibrate;
|
||||
|
||||
@Bind(R.id.create_spCategory)
|
||||
Spinner spCategory;
|
||||
|
||||
@Bind(R.id.create_spIntent)
|
||||
Spinner spIntent;
|
||||
|
||||
@Bind(R.id.create_spIcon)
|
||||
Spinner spIcon;
|
||||
|
||||
@Bind(R.id.create_btDispatch)
|
||||
Button btDispatch;
|
||||
|
||||
@Bind(R.id.create_btSchedule)
|
||||
Button btSchedule;
|
||||
|
||||
final int[] mNotificationIcons = new int[]{
|
||||
R.drawable.ic_adb,
|
||||
R.drawable.ic_bluetooth_audio,
|
||||
R.drawable.ic_drive_eta,
|
||||
R.drawable.ic_event_note,
|
||||
R.drawable.ic_ondemand_video,
|
||||
R.drawable.ic_power,
|
||||
R.drawable.ic_sd_card,
|
||||
R.drawable.ic_sms
|
||||
};
|
||||
|
||||
final String[] categories = new String[] {
|
||||
NotificationCompat.CATEGORY_ALARM,
|
||||
NotificationCompat.CATEGORY_CALL,
|
||||
NotificationCompat.CATEGORY_EMAIL,
|
||||
NotificationCompat.CATEGORY_ERROR,
|
||||
NotificationCompat.CATEGORY_EVENT,
|
||||
NotificationCompat.CATEGORY_MESSAGE,
|
||||
NotificationCompat.CATEGORY_PROGRESS,
|
||||
NotificationCompat.CATEGORY_PROMO,
|
||||
NotificationCompat.CATEGORY_RECOMMENDATION,
|
||||
NotificationCompat.CATEGORY_SERVICE,
|
||||
NotificationCompat.CATEGORY_SOCIAL,
|
||||
NotificationCompat.CATEGORY_STATUS,
|
||||
NotificationCompat.CATEGORY_SYSTEM,
|
||||
NotificationCompat.CATEGORY_TRANSPORT
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.notification_creation_frag, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
ArrayAdapter<CharSequence> categoryAdapter = ArrayAdapter.createFromResource(getContext(), R.array.create_categories, android.R.layout.simple_spinner_item);
|
||||
categoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spCategory.setAdapter(categoryAdapter);
|
||||
|
||||
SpinnerIconAdapter iconAdapter = new SpinnerIconAdapter(getContext(), getResources().getStringArray(R.array.create_icons), mNotificationIcons);
|
||||
iconAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spIcon.setAdapter(iconAdapter);
|
||||
|
||||
btDispatch.setOnClickListener(this);
|
||||
btSchedule.setOnClickListener(this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean validationError = false;
|
||||
String message = etMessage.getText().toString();
|
||||
if(message.isEmpty()) {
|
||||
etMessage.setError("Message must not be empty.");
|
||||
validationError = true;
|
||||
}
|
||||
String title = etTitle.getText().toString();
|
||||
if(title.isEmpty()) {
|
||||
etTitle.setError("Title must not be empty.");
|
||||
validationError = true;
|
||||
}
|
||||
String idString = etId.getText().toString();
|
||||
int id = 1;
|
||||
try {
|
||||
id = Integer.parseInt(idString);
|
||||
} catch(NumberFormatException e) {
|
||||
etId.setError("Please enter a valid id");
|
||||
validationError = true;
|
||||
}
|
||||
|
||||
if(validationError)
|
||||
return;
|
||||
|
||||
DispatchableNotification dn = new DispatchableNotification.Builder(getContext())
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setId(id)
|
||||
.setIcon(mNotificationIcons[spIcon.getSelectedItemPosition()])
|
||||
.setSound(cbSound.isChecked())
|
||||
.setVibrate(cbVibrate.isChecked())
|
||||
.setBlink(cbBlink.isChecked())
|
||||
.setAutoCancel(cbAutoCancel.isChecked())
|
||||
.setCategory(categories[spCategory.getSelectedItemPosition()])
|
||||
.build();
|
||||
|
||||
if(v.getId() == R.id.create_btDispatch)
|
||||
dn.dispatch();
|
||||
else
|
||||
sheduleNotification(dn);
|
||||
}
|
||||
|
||||
private void sheduleNotification(DispatchableNotification dn) {
|
||||
new NotificationScheduleHelper(getContext(), dn, this).shedule();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onNotificationScheduleCreated(Date date, DispatchableNotification dn) {
|
||||
// delayn the shedule to see if user presses the undo button
|
||||
Snackbar snack = Snackbar.make(getView(), getString(R.string.create_shedule_snack, date.toString()), Snackbar.LENGTH_LONG);
|
||||
ScheduleSnackbarListener listener = new ScheduleSnackbarListener(dn, date);
|
||||
snack.setCallback(listener);
|
||||
snack.setAction(getString(R.string.create_shedule_snack_undo), listener);
|
||||
snack.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Snackbar listener to track if the user undoes the schedule operation
|
||||
*/
|
||||
class ScheduleSnackbarListener extends Snackbar.Callback implements View.OnClickListener {
|
||||
|
||||
private DispatchableNotification mNotification;
|
||||
private Date mDispatchDate;
|
||||
private boolean dispatch = true;
|
||||
|
||||
public ScheduleSnackbarListener(DispatchableNotification notification, Date dispatchDate) {
|
||||
mDispatchDate = dispatchDate;
|
||||
mNotification = notification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dispatch = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismissed(Snackbar snackbar, int event) {
|
||||
super.onDismissed(snackbar, event);
|
||||
if(dispatch)
|
||||
mNotification.shedule(mDispatchDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package net.headlezz.notificationlogger.createnotification;
|
||||
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
* Helper class to create the date to schedule a notification
|
||||
*/
|
||||
public class NotificationScheduleHelper {
|
||||
|
||||
private Context mContext;
|
||||
private DispatchableNotification mNotification;
|
||||
NotificationScheduleManagerCallback mCallback;
|
||||
|
||||
interface NotificationScheduleManagerCallback {
|
||||
void onNotificationScheduleCreated(Date date, DispatchableNotification dn);
|
||||
}
|
||||
|
||||
public NotificationScheduleHelper(Context context, DispatchableNotification dn, NotificationScheduleManagerCallback cb) {
|
||||
mContext = context;
|
||||
mNotification = dn;
|
||||
mCallback = cb;
|
||||
}
|
||||
|
||||
public void shedule() {
|
||||
openSheduleDialogs();
|
||||
}
|
||||
|
||||
private void openSheduleDialogs() {
|
||||
NotificationSheduleCreationListener mListener = new NotificationSheduleCreationListener();
|
||||
Calendar cal = new GregorianCalendar();
|
||||
DatePickerDialog dialog = new DatePickerDialog(mContext, mListener, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public void onTimeSet(int year, int monthOfYear, int dayOfMonth, int hour, int minute) {
|
||||
mCallback.onNotificationScheduleCreated(new Date(year-1900, monthOfYear, dayOfMonth, hour, minute), mNotification);
|
||||
}
|
||||
|
||||
|
||||
class NotificationSheduleCreationListener implements DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener {
|
||||
|
||||
private int year;
|
||||
private int monthOfYear;
|
||||
private int dayOfMonth;
|
||||
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
||||
this.year = year;
|
||||
this.monthOfYear = monthOfYear;
|
||||
this.dayOfMonth = dayOfMonth;
|
||||
Calendar cal = new GregorianCalendar();
|
||||
new TimePickerDialog(mContext, this, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE)+1, true).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
NotificationScheduleHelper.this.onTimeSet(year, monthOfYear, dayOfMonth, hourOfDay, minute);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package net.headlezz.notificationlogger.createnotification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.headlezz.notificationlogger.R;
|
||||
|
||||
public class SpinnerIconAdapter extends ArrayAdapter<CharSequence> {
|
||||
|
||||
private static final int DROPDOWN_RESOURCE = R.layout.simple_spinner_dropdown_item_with_icon;
|
||||
private static final int ITEM_RESOURCE = R.layout.simple_spinner_item_with_icon;
|
||||
|
||||
private int[] itemIcons;
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
public SpinnerIconAdapter(Context context, CharSequence[] items, int[] itemIcons) {
|
||||
super(context, ITEM_RESOURCE, items);
|
||||
if(itemIcons.length != getCount())
|
||||
throw new IllegalArgumentException("Icon resource size doesnt match item count");
|
||||
this.itemIcons = itemIcons;
|
||||
mInflater = LayoutInflater.from(getContext());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if(convertView == null) {
|
||||
convertView = mInflater.inflate(ITEM_RESOURCE, parent, false);
|
||||
}
|
||||
TextView textView = (TextView) convertView.findViewById(android.R.id.text1);
|
||||
textView.setText(getItem(position));
|
||||
ImageView iconView = (ImageView) convertView.findViewById(R.id.spinner_icon);
|
||||
Drawable icon = getContext().getResources().getDrawable(itemIcons[position]);
|
||||
iconView.setImageDrawable(icon);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
if(convertView == null) {
|
||||
convertView = mInflater.inflate(DROPDOWN_RESOURCE, parent, false);
|
||||
}
|
||||
TextView textView = (TextView) convertView.findViewById(android.R.id.text1);
|
||||
textView.setText(getItem(position));
|
||||
ImageView iconView = (ImageView) convertView.findViewById(R.id.spinner_icon);
|
||||
Drawable icon = getContext().getResources().getDrawable(itemIcons[position]);
|
||||
iconView.setImageDrawable(icon);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_adb.png
Normal file
|
After Width: | Height: | Size: 328 B |
BIN
app/src/main/res/drawable-hdpi/ic_bluetooth_audio.png
Normal file
|
After Width: | Height: | Size: 376 B |
BIN
app/src/main/res/drawable-hdpi/ic_drive_eta.png
Normal file
|
After Width: | Height: | Size: 295 B |
BIN
app/src/main/res/drawable-hdpi/ic_event_note.png
Normal file
|
After Width: | Height: | Size: 211 B |
BIN
app/src/main/res/drawable-hdpi/ic_ondemand_video.png
Normal file
|
After Width: | Height: | Size: 253 B |
BIN
app/src/main/res/drawable-hdpi/ic_power.png
Normal file
|
After Width: | Height: | Size: 206 B |
BIN
app/src/main/res/drawable-hdpi/ic_sd_card.png
Normal file
|
After Width: | Height: | Size: 198 B |
BIN
app/src/main/res/drawable-hdpi/ic_sms.png
Normal file
|
After Width: | Height: | Size: 193 B |
BIN
app/src/main/res/drawable-mdpi/ic_adb.png
Normal file
|
After Width: | Height: | Size: 187 B |
BIN
app/src/main/res/drawable-mdpi/ic_bluetooth_audio.png
Normal file
|
After Width: | Height: | Size: 265 B |
BIN
app/src/main/res/drawable-mdpi/ic_drive_eta.png
Normal file
|
After Width: | Height: | Size: 210 B |
BIN
app/src/main/res/drawable-mdpi/ic_event_note.png
Normal file
|
After Width: | Height: | Size: 115 B |
BIN
app/src/main/res/drawable-mdpi/ic_ondemand_video.png
Normal file
|
After Width: | Height: | Size: 211 B |
BIN
app/src/main/res/drawable-mdpi/ic_power.png
Normal file
|
After Width: | Height: | Size: 172 B |
BIN
app/src/main/res/drawable-mdpi/ic_sd_card.png
Normal file
|
After Width: | Height: | Size: 129 B |
BIN
app/src/main/res/drawable-mdpi/ic_sms.png
Normal file
|
After Width: | Height: | Size: 137 B |
BIN
app/src/main/res/drawable-xhdpi/ic_adb.png
Normal file
|
After Width: | Height: | Size: 320 B |
BIN
app/src/main/res/drawable-xhdpi/ic_bluetooth_audio.png
Normal file
|
After Width: | Height: | Size: 442 B |
BIN
app/src/main/res/drawable-xhdpi/ic_drive_eta.png
Normal file
|
After Width: | Height: | Size: 334 B |
BIN
app/src/main/res/drawable-xhdpi/ic_event_note.png
Normal file
|
After Width: | Height: | Size: 148 B |
BIN
app/src/main/res/drawable-xhdpi/ic_ondemand_video.png
Normal file
|
After Width: | Height: | Size: 277 B |
BIN
app/src/main/res/drawable-xhdpi/ic_power.png
Normal file
|
After Width: | Height: | Size: 204 B |
BIN
app/src/main/res/drawable-xhdpi/ic_sd_card.png
Normal file
|
After Width: | Height: | Size: 189 B |
BIN
app/src/main/res/drawable-xhdpi/ic_sms.png
Normal file
|
After Width: | Height: | Size: 169 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_adb.png
Normal file
|
After Width: | Height: | Size: 450 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_bluetooth_audio.png
Normal file
|
After Width: | Height: | Size: 587 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_drive_eta.png
Normal file
|
After Width: | Height: | Size: 483 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_event_note.png
Normal file
|
After Width: | Height: | Size: 181 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_ondemand_video.png
Normal file
|
After Width: | Height: | Size: 393 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_power.png
Normal file
|
After Width: | Height: | Size: 280 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_sd_card.png
Normal file
|
After Width: | Height: | Size: 283 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_sms.png
Normal file
|
After Width: | Height: | Size: 251 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_adb.png
Normal file
|
After Width: | Height: | Size: 676 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_bluetooth_audio.png
Normal file
|
After Width: | Height: | Size: 797 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_drive_eta.png
Normal file
|
After Width: | Height: | Size: 507 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_event_note.png
Normal file
|
After Width: | Height: | Size: 271 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_ondemand_video.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_power.png
Normal file
|
After Width: | Height: | Size: 288 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_sd_card.png
Normal file
|
After Width: | Height: | Size: 331 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_sms.png
Normal file
|
After Width: | Height: | Size: 263 B |
@@ -7,27 +7,25 @@
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/toolbar" />
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/main_menu_fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:contentDescription="@string/fab_cd_create_notification"
|
||||
android:layout_gravity="bottom|end|right"
|
||||
android:id="@+id/main_menu_fab_add_notification"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:fabSize="normal"
|
||||
android:src="@drawable/ic_action_add"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/main_menu_fab_add_notification"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:contentDescription="@string/fab_cd_create_notification"
|
||||
android:src="@drawable/ic_action_add"
|
||||
app:fabSize="normal" />
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
148
app/src/main/res/layout/notification_creation_frag.xml
Normal file
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/create_etTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:hint="@string/create_etTitleHint"
|
||||
android:lines="1" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/create_etMessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:hint="@string/create_etMessageHint" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/create_etId"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:hint="@string/create_etNotificationIdHint"
|
||||
android:inputType="number" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/create_IntentHeader" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/create_spIntent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
tools:listitem="@android:layout/simple_spinner_item" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/create_IconHeader" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/create_spIcon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
tools:listitem="@android:layout/simple_spinner_item" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/create_CategoryHeader" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/create_spCategory"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
tools:listitem="@android:layout/simple_spinner_item" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/create_cbSound"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/create_cbSound" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/create_cbVibrate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:checked="true"
|
||||
android:text="@string/create_cbVibrate" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/create_cbBlink"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:checked="true"
|
||||
android:text="@string/create_cbBlink" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/create_cbAutoCancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:checked="true"
|
||||
android:text="@string/create_cbAutoCancel" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/create_btSchedule"
|
||||
style="@style/Widget.AppCompat.Button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/create_btSchedule" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/create_btDispatch"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/create_btDispatch" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
style="?android:attr/spinnerDropDownItemStyle">
|
||||
|
||||
<ImageView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/spinner_icon"
|
||||
tools:src="@drawable/ic_adb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<include layout="@android:layout/simple_spinner_dropdown_item" />
|
||||
|
||||
</LinearLayout>
|
||||
17
app/src/main/res/layout/simple_spinner_item_with_icon.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
style="?android:attr/spinnerDropDownItemStyle">
|
||||
|
||||
<ImageView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/spinner_icon"
|
||||
tools:src="@drawable/ic_adb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<include layout="@android:layout/simple_spinner_item" />
|
||||
|
||||
</LinearLayout>
|
||||
12
app/src/main/res/layout/spinner_item_with_icon.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<include layout="@android:layout/simple_spinner_item" />
|
||||
|
||||
</LinearLayout>
|
||||
8
app/src/main/res/values/attrs.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<integer-array name="create_icons_icons">
|
||||
|
||||
</integer-array>
|
||||
|
||||
</resources>
|
||||
@@ -16,4 +16,47 @@
|
||||
<string name="fab_cd_create_notification">FAB: Create notification</string>
|
||||
<string name="title_create_notification">Create notification</string>
|
||||
<string name="title_blacklist">Blacklist</string>
|
||||
<string name="create_etTitleHint">Title</string>
|
||||
<string name="create_etMessageHint">Message</string>
|
||||
<string name="create_etNotificationIdHint">Notification ID</string>
|
||||
<string name="create_IntentHeader">Intent:</string>
|
||||
<string name="create_IconHeader">Icon:</string>
|
||||
<string name="create_CategoryHeader">Category:</string>
|
||||
<string name="create_cbSound">Sound</string>
|
||||
<string name="create_cbVibrate">Vibrate</string>
|
||||
<string name="create_cbBlink">Blink</string>
|
||||
<string name="create_cbAutoCancel">Auto cancel</string>
|
||||
<string name="create_btSchedule">schedule</string>
|
||||
<string name="create_btDispatch">dispatch</string>
|
||||
|
||||
<string name="create_shedule_snack">Notification sheduled for %1$s</string>
|
||||
<string name="create_shedule_snack_undo">Undo</string>
|
||||
|
||||
<string-array name="create_categories">
|
||||
<item>Alarm</item>
|
||||
<item>Call</item>
|
||||
<item>Email</item>
|
||||
<item>Error</item>
|
||||
<item>Event</item>
|
||||
<item>Message</item>
|
||||
<item>Progress</item>
|
||||
<item>Promo</item>
|
||||
<item>Recommendation</item>
|
||||
<item>Service</item>
|
||||
<item>Social</item>
|
||||
<item>Status</item>
|
||||
<item>System</item>
|
||||
<item>Transport</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="create_icons">
|
||||
<item>ADB</item>
|
||||
<item>Bluetooth</item>
|
||||
<item>Car</item>
|
||||
<item>Event</item>
|
||||
<item>Video</item>
|
||||
<item>Power</item>
|
||||
<item>SD card</item>
|
||||
<item>SMS</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||