Skip to content

Commit

Permalink
Initial UpdaterService, including menu for start/stop
Browse files Browse the repository at this point in the history
  • Loading branch information
edeleastar committed May 4, 2014
1 parent e65748e commit a4bf40e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
2 changes: 2 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
</intent-filter>
</activity>
<activity android:name="com.marakana.yambax.PrefsActivity" android:label="@string/titlePrefs" />

<service android:name="com.marakana.yambax.UpdaterService" />
</application>


Expand Down
5 changes: 4 additions & 1 deletion res/menu/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/itemPrefs" android:title="@string/titlePrefs"
android:icon="@android:drawable/ic_menu_preferences"></item>

<item android:title="@string/titleServiceStart" android:id="@+id/itemServiceStart"
android:icon="@android:drawable/ic_media_play"></item>
<item android:title="@string/titleServiceStop" android:id="@+id/itemServiceStop"
android:icon="@android:drawable/ic_media_pause"></item>
</menu>
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
<string name="summaryUsername">Please enter your username</string>
<string name="summaryPassword">Please enter your password</string>
<string name="summaryApiRoot">URL of Root API for your service</string>

<string name="titleServiceStop">Stop Service</string>
<string name="titleServiceStart">Start Service</string>
</resources>
11 changes: 8 additions & 3 deletions src/com/marakana/yambax/StatusActivity.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ class StatusActivity extends Activity
true
}

override onOptionsItemSelected(MenuItem item)
override onOptionsItemSelected(MenuItem item)
{
startActivity(new Intent(this, typeof(PrefsActivity)))
true
switch (item.getItemId())
{
case R.id.itemServiceStart: startService (new Intent(this, typeof(UpdaterService)))
case R.id.itemServiceStop: stopService (new Intent(this, typeof(UpdaterService)))
case R.id.itemPrefs: startActivity(new Intent(this, typeof(PrefsActivity)))
}
true
}
}
27 changes: 27 additions & 0 deletions src/com/marakana/yambax/UpdaterService.xtend
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.marakana.yambax

import android.app.Service
import android.content.Intent

class UpdaterService extends Service
{
override onBind(Intent intent)
{
}

override onCreate()
{
super.onCreate
}

override onStartCommand(Intent intent, int flags, int startId)
{
super.onStartCommand(intent, flags, startId)
START_STICKY;
}

override onDestroy()
{
super.onDestroy
}
}

0 comments on commit a4bf40e

Please sign in to comment.