Skip to content

Commit

Permalink
Add the missing screenshot activity
Browse files Browse the repository at this point in the history
  • Loading branch information
nkming2 committed May 2, 2016
1 parent 75c1246 commit 052c1e2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,19 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".ScreenshotActivity"
android:label="@string/activity_label_screenshot"
android:noHistory="true"
android:excludeFromRecents="true"
android:theme="@android:style/Theme.NoDisplay"
android:taskAffinity="@string/affinity_main">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
31 changes: 31 additions & 0 deletions src/main/kotlin/com/nkming/powermenu/ShortcutActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.nkming.powermenu

import android.content.Context
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.WindowManager
import android.widget.Toast

class ShutdownActivity : AppCompatActivity()
Expand Down Expand Up @@ -99,3 +101,32 @@ class SleepActivity : AppCompatActivity()
finish()
}
}

class ScreenshotActivity : AppCompatActivity()
{
override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
val appContext = applicationContext
val wm = appContext.getSystemService(Context.WINDOW_SERVICE)
as WindowManager
val rotation = wm.defaultDisplay.rotation
val screenshotHandler = ScreenshotHandler(appContext)
SystemHelper.screenshot(appContext,
{
isSuccessful, filepath -> (
{
if (isSuccessful)
{
screenshotHandler.onScreenshotSuccess(filepath!!, rotation)
}
else
{
Toast.makeText(appContext, R.string.screenshot_fail,
Toast.LENGTH_LONG).show()
}
}())
})
finish()
}
}
1 change: 1 addition & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,5 @@
<string name="activity_label_reboot_bootloader">Reboot(Bootloader)</string>
<string name="activity_label_soft_reboot">Soft Reboot</string>
<string name="activity_label_sleep">Sleep</string>
<string name="activity_label_screenshot">Screenshot</string>
</resources>

0 comments on commit 052c1e2

Please sign in to comment.