Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinliu committed Oct 12, 2016
1 parent f3a1a15 commit c09a27b
Show file tree
Hide file tree
Showing 36 changed files with 605 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .gitignore
@@ -0,0 +1,67 @@
#Android generated
bin
gen
gen*

#Eclipse
.project
.classpath
.settings

#IntelliJ IDEA
.idea
*.iml
*.ipr
*.iws
out

#Maven
target
release.properties
pom.xml.*

#Ant
build.xml
local.properties
proguard.cfg

#Gradle
.gradle
build
gradle.properties
gradle/
gradlew
gradlew.bat

#OSX
.DS_Store

#Personal Files
signing.

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log
1 change: 1 addition & 0 deletions app/.gitignore
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions app/build.gradle
@@ -0,0 +1,30 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "cn.gavinliu.notificationbox"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
testCompile 'junit:junit:4.12'
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/Gavin/Develop/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 *;
#}
@@ -0,0 +1,26 @@
package cn.gavinliu.notificationbox;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("cn.gavinliu.notificationbox", appContext.getPackageName());
}
}
34 changes: 34 additions & 0 deletions app/src/main/AndroidManifest.xml
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.gavinliu.notificationbox">

<application
android:name=".NotificationBoxApp"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="false"
android:theme="@style/AppTheme">
<activity
android:name=".ui.main.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

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

<service
android:name=".service.NotificationListenerService"
android:label="@string/service_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService"/>
</intent-filter>
</service>

</application>

</manifest>
@@ -0,0 +1,15 @@
package cn.gavinliu.notificationbox;

import android.app.Application;

/**
* Created by Gavin on 2016/10/11.
*/

public class NotificationBoxApp extends Application {

@Override
public void onCreate() {
super.onCreate();
}
}
@@ -0,0 +1,8 @@
package cn.gavinliu.notificationbox.model;

/**
* Created by Gavin on 2016/10/11.
*/

public class AppInfo {
}
@@ -0,0 +1,21 @@
package cn.gavinliu.notificationbox.model;

import android.content.Intent;

/**
* Created by Gavin on 2016/10/11.
*/

public class NotificationInfo {

String packageName;

String title;

String text;

long time;

Intent mIntent;

}
@@ -0,0 +1,58 @@
package cn.gavinliu.notificationbox.service;

import android.app.Notification;
import android.content.Intent;
import android.os.IBinder;
import android.service.notification.StatusBarNotification;

/**
* Created by Gavin on 2016/10/11.
*/

public class NotificationListenerService extends android.service.notification.NotificationListenerService {

@Override
public IBinder onBind(Intent intent) {
return super.onBind(intent);
}

@Override
public boolean onUnbind(Intent intent) {
return super.onUnbind(intent);
}

@Override
public void onCreate() {
super.onCreate();
}

@Override
public void onDestroy() {
super.onDestroy();
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return super.onStartCommand(intent, flags, startId);
}

@Override
public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
super.onNotificationPosted(sbn, rankingMap);
}

@Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);

Notification notification = sbn.getNotification();

String title = notification.extras.getString(Notification.EXTRA_TITLE);
String text = notification.extras.getString(Notification.EXTRA_TEXT);
}

@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
super.onNotificationRemoved(sbn);
}
}
@@ -0,0 +1,11 @@
package cn.gavinliu.notificationbox.ui;

/**
* Created by Gavin on 2016/10/11.
*/

public interface BasePresenter {

void start();

}
11 changes: 11 additions & 0 deletions app/src/main/java/cn/gavinliu/notificationbox/ui/BaseView.java
@@ -0,0 +1,11 @@
package cn.gavinliu.notificationbox.ui;

/**
* Created by Gavin on 2016/10/11.
*/

public interface BaseView<T extends BasePresenter> {

void setPresenter(T presenter);

}
@@ -0,0 +1,8 @@
package cn.gavinliu.notificationbox.ui.detail;

/**
* Created by Gavin on 2016/10/11.
*/

public class DetailActivity {
}
@@ -0,0 +1,8 @@
package cn.gavinliu.notificationbox.ui.detail;

/**
* Created by Gavin on 2016/10/11.
*/

public class DetailFragment {
}
@@ -0,0 +1,52 @@
package cn.gavinliu.notificationbox.ui.main;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;

import cn.gavinliu.notificationbox.R;

public class MainActivity extends AppCompatActivity {

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

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();

if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}

0 comments on commit c09a27b

Please sign in to comment.