Skip to content
This repository has been archived by the owner on May 12, 2019. It is now read-only.

Commit

Permalink
Updated changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sukso96100 committed Dec 13, 2013
1 parent 6def196 commit af7d5ef
Show file tree
Hide file tree
Showing 29 changed files with 226 additions and 62 deletions.
19 changes: 16 additions & 3 deletions ZionHighSchool/src/main/AndroidManifest.xml
Expand Up @@ -11,6 +11,7 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<uses-feature
android:name="android.hardware.sensor.accelerometer"
Expand Down Expand Up @@ -79,13 +80,25 @@
android:value="com.licubeclub.zionhs.MainActivity" />
</activity>

<service android:name="com.licubeclub.zionhs.ShakeDetectService" />

<service android:name="com.licubeclub.zionhs.ShakeDetectService">
<intent-filter>
<action android:name="com.licubeclub.zionhs" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<activity
android:name="com.licubeclub.zionhs.QuickLauncherActivity"
android:label="@string/title_activity_quick_launcher"
android:theme="@style/Theme.Zion.NoActionBar">
</activity>
<receiver
android:name="com.licubeclub.zionhs.AutoStarter"
android:enabled="true"
android:exported="false"
android:label="ShakeDetectServiceAutoStarter" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>

</manifest>
18 changes: 15 additions & 3 deletions ZionHighSchool/src/main/java/com/licubeclub/zionhs/Appinfo.java
Expand Up @@ -21,18 +21,22 @@ public class Appinfo extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.left_slide_in, R.anim.zoom_out);
setContentView(R.layout.activity_appinfo);

//Stop ShakeDetectService
Intent intent = new Intent(this, ShakeDetectService.class);
stopService(intent);
// Load Preference Value
SharedPreferences pref = getSharedPreferences("pref", Activity.MODE_PRIVATE);
CheckBox Toggle = (CheckBox)findViewById(R.id.quickexec); //checkbox
CheckBox Toggle = (CheckBox)findViewById(R.id.quickexec); //checkbox (QuickLaunch Toggle)
CheckBox NotiToggle = (CheckBox)findViewById(R.id.quickexec_noti); // QuickLaunch Notification Toggle
Spinner spinner = (Spinner) findViewById(R.id.quickexec_select); //spinner
Boolean Toggle_Boolean = pref.getBoolean("toggledata", false);
Boolean Toggle_Noti = pref.getBoolean("notitoggle", false);
int Spinner_int = pref.getInt("quickexec_select",0);
Toggle.setChecked(Toggle_Boolean);
NotiToggle.setChecked(Toggle_Noti);
spinner.setSelection(Spinner_int);

//Get app version name from Manifest
Expand Down Expand Up @@ -64,15 +68,18 @@ public void onClick(View v) {

public void onStop(){
super.onStop();

SharedPreferences pref = getSharedPreferences("pref", Activity.MODE_PRIVATE); // Save UI State
SharedPreferences.Editor editor = pref.edit(); //art Load Editor
SharedPreferences.Editor editor = pref.edit(); // Load Editor
CheckBox check1 = (CheckBox)findViewById(R.id.quickexec);
CheckBox noti = (CheckBox)findViewById(R.id.quickexec_noti);
Spinner spinner = (Spinner) findViewById(R.id.quickexec_select);
// Input values
int quickexec_selected_value = spinner.getSelectedItemPosition();
editor.putInt("quickexec_select", quickexec_selected_value);
editor.putBoolean("toggledata", check1.isChecked());
editor.commit(); // Save calues
editor.putBoolean("notitoggle", noti.isChecked());
editor.commit(); // Save values

final boolean quicklaunchon = getSharedPreferences("pref", Context.MODE_PRIVATE).getBoolean("toggledata", true);
if(quicklaunchon){
Expand All @@ -82,5 +89,10 @@ public void onStop(){
else{}
}

protected void onDestroy(){
super.onDestroy();

}


}
@@ -0,0 +1,33 @@
package com.licubeclub.zionhs;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
* Created by youngbin on 13. 12. 13.
*/
public class AutoStarter extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Log.i("AutoStarter","AutoStarter is Running");
//Load notification toggle value from SharedPreferences
boolean ToggleOn = context.getSharedPreferences("pref", Context.MODE_PRIVATE).getBoolean("toggledata", true);

if(ToggleOn){
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
Log.i("BOOTSVC", "Intent received");
Log.i("AutoStarter","Starting ShakeDetectService");
ComponentName cn = new ComponentName(context.getPackageName(), ShakeDetectService.class.getName());
ComponentName svcName = context.startService(new Intent().setComponent(cn));
if (svcName == null)
Log.i("AutoStarter","Cannot Start ShakeDetectService");
Log.e("BOOTSVC", "Could not start service " + cn.toString());
}
}
else{
//Do Nothing
}
}
}
Expand Up @@ -45,6 +45,7 @@ public void handleMessage(Message msg)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.left_slide_in, R.anim.zoom_out);
setContentView(R.layout.activity_meal);

cManager=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
Expand Down
Expand Up @@ -43,6 +43,7 @@ public void handleMessage(Message msg)
};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.left_slide_in, R.anim.zoom_out);
setContentView(R.layout.activity_notices);

cManager=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
Expand Down
Expand Up @@ -12,14 +12,14 @@ public class QuickLauncherActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.slide_in_towrad_top, R.anim.zoom_out);
setContentView(R.layout.activity_quick_launcher);

//Stop ShakeDetectService for a few seconds
Intent intent = new Intent(this, ShakeDetectService.class);
stopService(intent);
}


@Override
public void onResume(){
super.onResume();
Expand All @@ -39,6 +39,7 @@ public void onResume(){
} catch (InterruptedException ignore) {}

Intent MainActivity = new Intent(QuickLauncherActivity.this, MainActivity.class);
overridePendingTransition(0, 0);
startActivity(MainActivity);

finish();
Expand Down Expand Up @@ -105,13 +106,9 @@ else if(target == 4){
}
}



protected void onDestroy(){
super.onDestroy();
Intent shakedetectservice = new Intent(this, ShakeDetectService.class);
startService(shakedetectservice);
}


}
Expand Up @@ -8,6 +8,7 @@ public class Schedule extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.left_slide_in, R.anim.zoom_out);
setContentView(R.layout.activity_schedule);

}
Expand Down
Expand Up @@ -12,6 +12,7 @@ public class Schoolinfo extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.left_slide_in, R.anim.zoom_out);
setContentView(R.layout.activity_schoolinfo);

View maps_card = findViewById(R.id.maps_card);
Expand Down
Expand Up @@ -15,6 +15,7 @@ public class Schoolintro extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.left_slide_in, R.anim.zoom_out);
setContentView(R.layout.activity_schoolintro);

mPager = (ViewPager)findViewById(R.id.pager);
Expand Down
@@ -1,8 +1,12 @@
package com.licubeclub.zionhs;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.IBinder;
Expand All @@ -17,24 +21,30 @@ public class ShakeDetectService extends Service {
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private ShakeDetector mShakeDetector;
private static final int MY_NOTIFICATION_ID=1;
private NotificationManager notificationManager;
private Notification myNotification;

@Override
public void onCreate() {
//Load notification toggle value from SharedPreferences
SharedPreferences pref = getSharedPreferences("pref", Context.MODE_PRIVATE);
Boolean NotiOn = pref.getBoolean("notitoggle", true);
Log.d("ShakeDetectService","Service Started");

// ShakeDetector initialization
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager
.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
mShakeDetector = new ShakeDetector();
mShakeDetector.setOnShakeListener(new ShakeDetector.OnShakeListener() {

@Override
public void onShake(int count) {
Log.d("ShakeDetectService","Shaken!");
//Following thing will be executed when shaking detected

//Following thing will be executed when shaking detected
//vibrate
Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(100);
Expand All @@ -45,18 +55,43 @@ public void onShake(int count) {
getApplication().startActivity(intent);
}
});

if(NotiOn){
//Show Notification
notificationManager =
(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
myNotification = new Notification(R.drawable.ic_stat_quicklaunch,
getText(R.string.noti_shake_start),
System.currentTimeMillis());
Context context = getApplicationContext();
CharSequence notificationTitle = getText(R.string.noti_shake_title);
CharSequence notificationText = getText(R.string.noti_shake_title_sub);
Intent myIntent = new Intent(getBaseContext(), Appinfo.class);;
PendingIntent pendingIntent
= PendingIntent.getActivity(getBaseContext(),
0, myIntent,
Intent.FLAG_ACTIVITY_NEW_TASK);
myNotification.defaults |= Notification.DEFAULT_SOUND;
myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
myNotification.flags = Notification.FLAG_ONGOING_EVENT;
myNotification.setLatestEventInfo(context,
notificationTitle,
notificationText,
pendingIntent);
notificationManager.notify(MY_NOTIFICATION_ID, myNotification);
}
else{
//Do Nothing
}
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// The service is starting, due to a call to startService()
mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
return flags;

}



@Override
public IBinder onBind(Intent intent) {
// We don't provide binding, so return null
Expand All @@ -65,6 +100,17 @@ public IBinder onBind(Intent intent) {

@Override
public void onDestroy() {
super.onDestroy();
//Load notification toggle value from SharedPreferences
SharedPreferences pref = getSharedPreferences("pref", Context.MODE_PRIVATE);
Boolean NotiOn = pref.getBoolean("notitoggle", true);

mSensorManager.unregisterListener(mShakeDetector);
if(NotiOn){
notificationManager.cancel(MY_NOTIFICATION_ID);
}
else{
//Do Nothing
}
}
}
25 changes: 25 additions & 0 deletions ZionHighSchool/src/main/res/anim/left_slide_in.xml
@@ -0,0 +1,25 @@
<!-- Copyright 2013 Young Bin Han
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>
<translate
android:fromXDelta="100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
11 changes: 11 additions & 0 deletions ZionHighSchool/src/main/res/anim/slide_in_towrad_top.xml
@@ -0,0 +1,11 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>
<translate
android:fromXDelta="0%" android:toXDelta="0%"
android:fromYDelta="100%" android:toYDelta="0%"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
22 changes: 0 additions & 22 deletions ZionHighSchool/src/main/res/anim/slide_up_left.xml

This file was deleted.

0 comments on commit af7d5ef

Please sign in to comment.