Skip to content

Commit

Permalink
add myself icon
Browse files Browse the repository at this point in the history
  • Loading branch information
agenthun committed Dec 17, 2015
1 parent 7488c7e commit 52d78d7
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 14 deletions.
28 changes: 15 additions & 13 deletions reading_routine/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- <uses-permission android:name="android.permission.BLUETOOTH" />-->
<!-- <uses-permission android:name="android.permission.BLUETOOTH" /> -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- 文件存储 -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand All @@ -49,38 +49,36 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".activities.LoginActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar.Login"
android:windowSoftInputMode="adjustPan|stateHidden">
<!-- <intent-filter>

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

<activity
android:name=".activities.SignUpActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize|stateVisible" />

<activity
android:name=".activities.SignUpGridActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan|stateHidden" />

<activity
android:name=".activities.ForgetPasswordActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan|stateHidden" />

<activity
android:name=".activities.MainActivity"
android:configChanges="orientation|screenSize|screenLayout"
Expand All @@ -100,34 +98,38 @@
android:name=".activities.BookActivity"
android:label="@string/title_activity_book"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".activities.ReadingActivity"
android:theme="@style/AppTheme.NoActionBar.FullScreen" />

<activity
android:name="com.nbsp.materialfilepicker.ui.FilePickerActivity"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".activities.NoteDetailsActivity"
android:label="@string/title_activity_note_details"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".activities.ShoppingActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />

<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
</activity>

<activity
android:name=".activities.ProductActivity"
android:theme="@style/AppTheme.NoActionBar" />

<service
android:name=".services.AlarmNoiserService"
android:enabled="true"
android:exported="true" />
<service
android:name=".services.MyIntentService"
android:exported="false"></service>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.agenthun.readingroutine.activities;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.widget.EditText;
import android.widget.Toast;

Expand Down Expand Up @@ -51,6 +55,20 @@ protected void onCreate(Bundle savedInstanceState) {
userData = new UserData();
setIsTrial(true);
}

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_rr_launcher)
.setContentTitle("阅读提醒")
.setContentText("你的书该看了");

Intent intent = new Intent(this, LoginActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(LoginActivity.class);
stackBuilder.addNextIntent(intent);
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -18,6 +19,8 @@
import com.agenthun.readingroutine.datastore.UserData;
import com.agenthun.readingroutine.fragments.MenuFragment;
import com.agenthun.readingroutine.fragments.SettingsFragment;
import com.agenthun.readingroutine.services.AlarmNoiser;
import com.agenthun.readingroutine.services.AlarmNoiserService;
import com.agenthun.readingroutine.transitionmanagers.TActivity;
import com.agenthun.readingroutine.utils.Avatar;
import com.agenthun.readingroutine.utils.CircleTransformation;
Expand Down Expand Up @@ -233,6 +236,9 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
return false;
}
});

AlarmNoiser.startAlarmNoiserService(this, 5, AlarmNoiserService.class, AlarmNoiserService.ACTION);
Log.d(TAG, "onCreate() returned: startAlarmNoiserService");
}

@Override
Expand Down Expand Up @@ -341,6 +347,8 @@ public void onBackPressed() {
@Override
protected void onDestroy() {
super.onDestroy();
AlarmNoiser.stopAlarmNoiserService(this, AlarmNoiserService.class, AlarmNoiserService.ACTION);
Log.d(TAG, "onDestroy() returned: stopAlarmNoiserService");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.agenthun.readingroutine.services;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;

/**
* @project ReadingRoutine
* @authors agenthun
* @date 15/12/16 下午8:30.
*/
public class AlarmNoiser {
public static void startAlarmNoiserService(Context context, int seconds, Class<?> cls, String action) {
AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

Intent intent = new Intent(context, cls);
intent.setAction(action);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

long triggerAlarmTime = SystemClock.elapsedRealtime();
manager.setRepeating(AlarmManager.ELAPSED_REALTIME, triggerAlarmTime, seconds * 1000, pendingIntent);
}

public static void stopAlarmNoiserService(Context context, Class<?> cls, String action) {
AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

Intent intent = new Intent(context, cls);
intent.setAction(action);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

manager.cancel(pendingIntent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.agenthun.readingroutine.services;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log;

import com.agenthun.readingroutine.R;
import com.agenthun.readingroutine.activities.MainActivity;

public class AlarmNoiserService extends Service {
private static final String TAG = "AlarmNoiserService";
public static final String ACTION = "com.agenthun.readingroutine.services.AlarmNoiserService";

NotificationCompat.Builder mBuilder;

public AlarmNoiserService() {
}

@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}

@Override
public void onCreate() {
Log.d(TAG, "AlarmNoiserService onCreate() returned: ");
super.onCreate();
}

private void initNotifiManager() {
mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_reading_routine_white)
.setContentTitle("阅读提醒")
.setContentText("你的书该看了");
}

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

int count = 0;

class AlarmNoiserThread extends Thread {
@Override
public void run() {
Log.d(TAG, "run() returned: ");
count++;
if (count % 5 == 0) {
showNotification();
Log.d(TAG, "run() returned: new message");
}
}
}

private void showNotification() {
Intent intent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(intent);
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.notify(0, mBuilder.build());
Log.d(TAG, "showNotification() returned: ");
}

@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestroy() returned: ");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.agenthun.readingroutine.services;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;

/**
* An {@link IntentService} subclass for handling asynchronous task requests in
* a service on a separate handler thread.
* <p/>
* TODO: Customize class - update intent actions, extra parameters and static
* helper methods.
*/
public class MyIntentService extends IntentService {
// TODO: Rename actions, choose action names that describe tasks that this
// IntentService can perform, e.g. ACTION_FETCH_NEW_ITEMS
private static final String ACTION_FOO = "com.agenthun.readingroutine.services.action.FOO";
private static final String ACTION_BAZ = "com.agenthun.readingroutine.services.action.BAZ";

// TODO: Rename parameters
private static final String EXTRA_PARAM1 = "com.agenthun.readingroutine.services.extra.PARAM1";
private static final String EXTRA_PARAM2 = "com.agenthun.readingroutine.services.extra.PARAM2";

public MyIntentService() {
super("MyIntentService");
}

/**
* Starts this service to perform action Foo with the given parameters. If
* the service is already performing a task this action will be queued.
*
* @see IntentService
*/
// TODO: Customize helper method
public static void startActionFoo(Context context, String param1, String param2) {
Intent intent = new Intent(context, MyIntentService.class);
intent.setAction(ACTION_FOO);
intent.putExtra(EXTRA_PARAM1, param1);
intent.putExtra(EXTRA_PARAM2, param2);
context.startService(intent);
}

/**
* Starts this service to perform action Baz with the given parameters. If
* the service is already performing a task this action will be queued.
*
* @see IntentService
*/
// TODO: Customize helper method
public static void startActionBaz(Context context, String param1, String param2) {
Intent intent = new Intent(context, MyIntentService.class);
intent.setAction(ACTION_BAZ);
intent.putExtra(EXTRA_PARAM1, param1);
intent.putExtra(EXTRA_PARAM2, param2);
context.startService(intent);
}

@Override
protected void onHandleIntent(Intent intent) {
if (intent != null) {
final String action = intent.getAction();
if (ACTION_FOO.equals(action)) {
final String param1 = intent.getStringExtra(EXTRA_PARAM1);
final String param2 = intent.getStringExtra(EXTRA_PARAM2);
handleActionFoo(param1, param2);
} else if (ACTION_BAZ.equals(action)) {
final String param1 = intent.getStringExtra(EXTRA_PARAM1);
final String param2 = intent.getStringExtra(EXTRA_PARAM2);
handleActionBaz(param1, param2);
}
}
}

/**
* Handle action Foo in the provided background thread with the provided
* parameters.
*/
private void handleActionFoo(String param1, String param2) {
// TODO: Handle action Foo
throw new UnsupportedOperationException("Not yet implemented");
}

/**
* Handle action Baz in the provided background thread with the provided
* parameters.
*/
private void handleActionBaz(String param1, String param2) {
// TODO: Handle action Baz
throw new UnsupportedOperationException("Not yet implemented");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ public enum Avatar {
THIRTEEN(R.drawable.avatar_13_raster),
FOURTEEN(R.drawable.avatar_14_raster),
FIFTEEN(R.drawable.avatar_15_raster),
SIXTEEN(R.drawable.avatar_16_raster);
SIXTEEN(R.drawable.avatar_16_raster),
SEVENTEEN(R.drawable.avatar_17_raster),
EIGHTEEN(R.drawable.avatar_18_raster),
NINETEEN(R.drawable.avatar_19_raster),
TWENTY(R.drawable.avatar_20_raster),
TWENTY_1(R.drawable.avatar_20_1_raster);

private int mResId;

Expand Down
Binary file modified reading_routine/src/main/res/drawable-xxhdpi/avatar_17_raster.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified reading_routine/src/main/res/drawable-xxhdpi/avatar_18_raster.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified reading_routine/src/main/res/drawable-xxhdpi/avatar_19_raster.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified reading_routine/src/main/res/drawable-xxhdpi/avatar_1_raster.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified reading_routine/src/main/res/drawable-xxhdpi/avatar_2_raster.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified reading_routine/src/main/res/drawable-xxhdpi/avatar_3_raster.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 52d78d7

Please sign in to comment.