Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will & Claire Notification HW #14

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions NotificationHW/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
1 change: 1 addition & 0 deletions NotificationHW/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions NotificationHW/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions NotificationHW/.idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions NotificationHW/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions NotificationHW/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions NotificationHW/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions NotificationHW/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions NotificationHW/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions NotificationHW/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions NotificationHW/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
26 changes: 26 additions & 0 deletions NotificationHW/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.example.wasabi.notificationhw"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
17 changes: 17 additions & 0 deletions NotificationHW/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\Wasabi\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.wasabi.notificationhw;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
21 changes: 21 additions & 0 deletions NotificationHW/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wasabi.notificationhw">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ClaireActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".WillActivity"></activity>
</application>

</manifest>
Binary file added NotificationHW/app/src/main/ic_pikachu-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added NotificationHW/app/src/main/ic_profile-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package com.example.wasabi.notificationhw;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.Button;
import android.widget.RemoteViews;
import android.widget.TextView;

public class ClaireActivity extends AppCompatActivity {

public static int INBOX_NOTIFICATION_ID = 100;
public static int BIGTEXT_NOTIFICATION_ID = 200;
public static int ACTION_NOTIFICATION_ID = 300;
public static int BONUS_NOTIFICATION_ID = 400;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_claire);

Button inboxButton = (Button)findViewById(R.id.inbox_button);
Button bigTextButton = (Button)findViewById(R.id.bigtext_button);
Button actionButton = (Button)findViewById(R.id.action_button);
Button bonusButton = (Button)findViewById(R.id.bonus_button);
Button nextButton = (Button)findViewById(R.id.next_button);

nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(ClaireActivity.this, WillActivity.class));
}
});

inboxButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(ClaireActivity.this);
builder.setStyle(new NotificationCompat.InboxStyle().setBigContentTitle("5 new messages")
.addLine("Cheeta: Bananas on sale")
.addLine("George: Curious about your blog post")
.addLine("Nikko: Need a ride to Evolve?")
.setSummaryText("+2 more"));
builder.setSmallIcon(android.R.drawable.ic_dialog_info);
builder.setContentTitle("5 new messages");
builder.setContentText("Scroll down to read");
Intent intent = new Intent(ClaireActivity.this,ClaireActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(ClaireActivity.this, (int)System.currentTimeMillis(), intent, 0);
builder.setContentIntent(pIntent);
builder.setAutoCancel(true);

NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(INBOX_NOTIFICATION_ID,builder.build());
}
});

bigTextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(ClaireActivity.this);
builder.setStyle(new NotificationCompat.BigTextStyle().setBigContentTitle("94833")
.bigText("Breaking News: Your Seamless order is being prepared. Our crystal ball estimates your delivery time between 1:30 PM and 1:40 PM."));
builder.setSmallIcon(android.R.drawable.ic_menu_camera);
builder.setContentTitle("94833");
builder.setContentText("New story is delivered.");
Intent intent = new Intent(ClaireActivity.this,ClaireActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(ClaireActivity.this, (int)System.currentTimeMillis(), intent, 0);
builder.addAction(android.R.drawable.ic_menu_send, "REPLY", pIntent);
builder.setAutoCancel(true);

NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(INBOX_NOTIFICATION_ID,builder.build());
}
});

bigTextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(ClaireActivity.this);
builder.setStyle(new NotificationCompat.BigTextStyle().setBigContentTitle("94833")
.bigText("Breaking News: Your Seamless order is being prepared. Our crystal ball estimates your delivery time between 1:30 PM and 1:40 PM."));
builder.setSmallIcon(android.R.drawable.ic_menu_camera);
builder.setContentTitle("94833");
builder.setContentText("New story is delivered.");
Intent intent = new Intent(ClaireActivity.this,ClaireActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(ClaireActivity.this, (int)System.currentTimeMillis(), intent, 0);
builder.addAction(android.R.drawable.ic_menu_send,"REPLY",pIntent);
builder.setAutoCancel(true);

NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(BIGTEXT_NOTIFICATION_ID,builder.build());
}
});

actionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(ClaireActivity.this);

Spannable sb = new SpannableString("Dinner tonight?");
sb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

builder.setSmallIcon(android.R.drawable.ic_menu_call);
builder.setContentTitle("Michael");
builder.setContentText("Message from Michael");
builder.setStyle(new NotificationCompat.InboxStyle().setBigContentTitle("Michael")
.addLine(sb)
.addLine("Let's grab some dinner. Are your free?")
.setSummaryText("[email protected]"));

Intent intent = new Intent(ClaireActivity.this,ClaireActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(ClaireActivity.this, (int)System.currentTimeMillis(), intent, 0);
builder.addAction(android.R.drawable.ic_menu_upload,"ARCHIVE",pIntent);
builder.addAction(android.R.drawable.ic_menu_send,"REPLY",pIntent);
builder.setAutoCancel(true);

NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(ACTION_NOTIFICATION_ID,builder.build());
}
});

bonusButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(ClaireActivity.this);

Spannable sb = new SpannableString("Dinner tonight?");
sb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setImageViewResource(R.id.album_art, R.drawable.profile);
contentView.setTextViewText(R.id.title_tv, "Midnight City");
contentView.setTextViewText(R.id.artist_tv, "M83 - Hurry Up, We're Dreaming");


builder.setSmallIcon(android.R.drawable.ic_media_play);
builder.setContentTitle("Midnight City");
builder.setContentText("M83");

builder.addAction(android.R.drawable.ic_media_pause, null, null);
builder.addAction(android.R.drawable.ic_media_play,null,null);
builder.addAction(android.R.drawable.ic_menu_close_clear_cancel,null,null);
builder.setContent(contentView);

Intent intent = new Intent(ClaireActivity.this,ClaireActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(ClaireActivity.this, (int)System.currentTimeMillis(), intent, 0);
builder.setContentIntent(pIntent);
builder.setAutoCancel(true);

NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(BONUS_NOTIFICATION_ID,builder.build());
}
});
}
}
Loading