create notification layout

This commit is contained in:
danijoo
2016-01-01 13:37:46 +01:00
parent 8618a5defb
commit b493755550
49 changed files with 372 additions and 22 deletions

View File

@@ -3,21 +3,75 @@ 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;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import butterknife.Bind;
import butterknife.ButterKnife;
public class NotificationCreationFragment extends Fragment {
@Bind(R.id.create_etId)
EditText mEtId;
@Bind(R.id.create_etTitle)
EditText mEtTitle;
@Bind(R.id.create_etMessage)
EditText mEtMessage;
@Bind(R.id.create_cbAutoCancel)
CheckBox mCbAutoCancel;
@Bind(R.id.create_cbBlink)
CheckBox mCbBlink;
@Bind(R.id.create_cbSound)
CheckBox mCbSound;
@Bind(R.id.create_cbVibrate)
CheckBox mCbVibrate;
@Bind(R.id.create_spCategory)
Spinner mSpCategory;
@Bind(R.id.create_spIntent)
Spinner mSpIntent;
@Bind(R.id.create_spIcon)
Spinner mSpIcon;
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
};
@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;
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);
mSpCategory.setAdapter(categoryAdapter);
SpinnerIconAdapter iconAdapter = new SpinnerIconAdapter(getContext(), getResources().getStringArray(R.array.create_icons), mNotificationIcons);
iconAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpIcon.setAdapter(iconAdapter);
return view;
}
}

View File

@@ -0,0 +1,55 @@
package net.headlezz.notificationlogger;
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;
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;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

View File

@@ -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>

View 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_btShedule"
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>

View 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_dropdown_item" />
</LinearLayout>

View 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>

View 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>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer-array name="create_icons_icons">
</integer-array>
</resources>

View File

@@ -16,4 +16,45 @@
<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-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>Reminder</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>