Skip to content

Commit

Permalink
Updated to use vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Domi04151309 committed Aug 25, 2018
1 parent e1c951e commit d2b9099
Show file tree
Hide file tree
Showing 31 changed files with 257 additions and 77 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionName "1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -20,7 +20,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
android:theme="@style/Theme.AppCompat.Light.Dialog"/>
<service
android:name=".QSShutdown"
android:icon="@drawable/shutdown"
android:icon="@drawable/ic_qs_shutdown"
android:label="@string/Shutdown"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
Expand All @@ -40,7 +40,7 @@
</service>
<service
android:name=".QSReboot"
android:icon="@drawable/reboot"
android:icon="@drawable/ic_qs_reboot"
android:label="@string/Reboot"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
Expand Down
29 changes: 14 additions & 15 deletions app/src/main/java/io/github/domi04151309/powerapp/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.domi04151309.powerapp;

import android.content.Intent;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
Expand All @@ -22,9 +21,9 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.shutdown).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Process p = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot -p" });
proc.waitFor();
p.waitFor();
} catch (Exception ex) {
Toast.makeText
(MainActivity.this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
Expand All @@ -34,9 +33,9 @@ public void onClick(View v) {
findViewById(R.id.reboot).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Process p = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot" });
proc.waitFor();
p.waitFor();
} catch (Exception ex) {
Toast.makeText(MainActivity.this, "Action failed! Please enable root!",
Toast.LENGTH_LONG).show();
Expand All @@ -46,9 +45,9 @@ public void onClick(View v) {
findViewById(R.id.recovery).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Process p = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot recovery" });
proc.waitFor();
p.waitFor();
} catch (Exception ex) {
Toast.makeText(MainActivity.this, "Action failed! Please enable root!",
Toast.LENGTH_LONG).show();
Expand All @@ -58,9 +57,9 @@ public void onClick(View v) {
findViewById(R.id.bootloader).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Process p = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot bootloader" });
proc.waitFor();
p.waitFor();
} catch (Exception ex) {
Toast.makeText(MainActivity.this, "Action failed! Please enable root!",
Toast.LENGTH_LONG).show();
Expand All @@ -70,9 +69,9 @@ public void onClick(View v) {
findViewById(R.id.soft_reboot).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Process p = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "setprop ctl.restart zygote" });
proc.waitFor();
p.waitFor();
} catch (Exception ex) {
Toast.makeText
(MainActivity.this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
Expand All @@ -82,9 +81,9 @@ public void onClick(View v) {
findViewById(R.id.system_ui).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Process p = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "killall com.android.systemui" });
proc.waitFor();
p.waitFor();
} catch (Exception ex) {
Toast.makeText
(MainActivity.this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
Expand All @@ -94,9 +93,9 @@ public void onClick(View v) {
findViewById(R.id.screen_off).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Process p = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "input keyevent KEYCODE_POWER" });
proc.waitFor();
p.waitFor();
} catch (Exception ex) {
Toast.makeText(MainActivity.this, "Action failed! Please enable root!",
Toast.LENGTH_LONG).show();
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/io/github/domi04151309/powerapp/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ public static class GeneralPreferenceFragment extends PreferenceFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_general);
setHasOptionsMenu(true);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
startActivity(new Intent(getActivity(), Preferences.class));
return true;
}
return super.onOptionsItemSelected(item);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public class QSReboot extends TileService{

@Override
public void onClick() {
boolean isCurrentlyLocked = this.isLocked();
boolean isCurrentlyLocked = isLocked();
if (!isCurrentlyLocked) {
try {
Process proc = Runtime.getRuntime()
Process p = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot" });
proc.waitFor();
p.waitFor();
} catch (Exception ex) {
Toast.makeText
(QSReboot.this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
(this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public class QSShutdown extends TileService{

@Override
public void onClick() {
boolean isCurrentlyLocked = this.isLocked();
boolean isCurrentlyLocked = isLocked();
if (!isCurrentlyLocked) {
try {
Process proc = Runtime.getRuntime()
Process p = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot -p" });
proc.waitFor();
p.waitFor();
} catch (Exception ex) {
Toast.makeText
(QSShutdown.this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
(this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
}
}
}
Expand Down
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/poweroff_round.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/reboot_round.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/recovery_round.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/res/drawable-xxhdpi/system_ui_round.png
Binary file not shown.
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/bootloader.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/transparent"
android:height="@dimen/frame"
android:width="@dimen/frame"/>
<item
android:gravity="center">
<shape android:shape="oval">
<size android:width="@dimen/outer_circle" android:height="@dimen/outer_circle"/>
<solid android:color="@color/green"/>
</shape>
</item>
<item
android:drawable="@drawable/ic_bootloader"
android:height="@dimen/inner_circle"
android:width="@dimen/inner_circle"
android:gravity="center"/>
</layer-list>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_bootloader.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#fff"
android:pathData="M15,9L9,9v6h6L15,9zM13,13h-2v-2h2v2zM21,11L21,9h-2L19,7c0,-1.1 -0.9,-2 -2,-2h-2L15,3h-2v2h-2L11,3L9,3v2L7,5c-1.1,0 -2,0.9 -2,2v2L3,9v2h2v2L3,13v2h2v2c0,1.1 0.9,2 2,2h2v2h2v-2h2v2h2v-2h2c1.1,0 2,-0.9 2,-2v-2h2v-2h-2v-2h2zM17,17L7,17L7,7h10v10z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_qs_reboot.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_qs_shutdown.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M13,3h-2v10h2L13,3zM17.83,5.17l-1.42,1.42C17.99,7.86 19,9.81 19,12c0,3.87 -3.13,7 -7,7s-7,-3.13 -7,-7c0,-2.19 1.01,-4.14 2.58,-5.42L6.17,5.17C4.23,6.82 3,9.26 3,12c0,4.97 4.03,9 9,9s9,-4.03 9,-9c0,-2.74 -1.23,-5.18 -3.17,-6.83z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_reboot.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#fff"
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_recovery.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#fff"
android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_restart.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#fff"
android:pathData="M12,6v3l4,-4 -4,-4v3c-4.42,0 -8,3.58 -8,8 0,1.57 0.46,3.03 1.24,4.26L6.7,14.8c-0.45,-0.83 -0.7,-1.79 -0.7,-2.8 0,-3.31 2.69,-6 6,-6zM18.76,7.74L17.3,9.2c0.44,0.84 0.7,1.79 0.7,2.8 0,3.31 -2.69,6 -6,6v-3l-4,4 4,4v-3c4.42,0 8,-3.58 8,-8 0,-1.57 -0.46,-3.03 -1.24,-4.26z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_screen_off.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#fff"
android:pathData="M10,16h4c0.55,0 1,-0.45 1,-1v-3c0,-0.55 -0.45,-1 -1,-1v-1c0,-1.11 -0.9,-2 -2,-2 -1.11,0 -2,0.9 -2,2v1c-0.55,0 -1,0.45 -1,1v3c0,0.55 0.45,1 1,1zM10.8,10c0,-0.66 0.54,-1.2 1.2,-1.2 0.66,0 1.2,0.54 1.2,1.2v1h-2.4v-1zM17,1L7,1c-1.1,0 -2,0.9 -2,2v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2L19,3c0,-1.1 -0.9,-2 -2,-2zM17,19L7,19L7,5h10v14z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_shutdown.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#fff"
android:pathData="M13,3h-2v10h2L13,3zM17.83,5.17l-1.42,1.42C17.99,7.86 19,9.81 19,12c0,3.87 -3.13,7 -7,7s-7,-3.13 -7,-7c0,-2.19 1.01,-4.14 2.58,-5.42L6.17,5.17C4.23,6.82 3,9.26 3,12c0,4.97 4.03,9 9,9s9,-4.03 9,-9c0,-2.74 -1.23,-5.18 -3.17,-6.83z"/>
</vector>
28 changes: 19 additions & 9 deletions app/src/main/res/drawable/reboot.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/transparent"
android:height="@dimen/frame"
android:width="@dimen/frame"/>
<item
android:gravity="center">
<shape android:shape="oval">
<size android:width="@dimen/outer_circle" android:height="@dimen/outer_circle"/>
<solid android:color="@color/green"/>
</shape>
</item>
<item
android:drawable="@drawable/ic_reboot"
android:height="@dimen/inner_circle"
android:width="@dimen/inner_circle"
android:gravity="center"/>
</layer-list>
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/recovery.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/transparent"
android:height="@dimen/frame"
android:width="@dimen/frame"/>
<item
android:gravity="center">
<shape android:shape="oval">
<size android:width="@dimen/outer_circle" android:height="@dimen/outer_circle"/>
<solid android:color="@color/green"/>
</shape>
</item>
<item
android:drawable="@drawable/ic_recovery"
android:height="@dimen/inner_circle"
android:width="@dimen/inner_circle"
android:gravity="center"/>
</layer-list>
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/restart_system_ui.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/transparent"
android:height="@dimen/frame"
android:width="@dimen/frame"/>
<item
android:gravity="center">
<shape android:shape="oval">
<size android:width="@dimen/outer_circle" android:height="@dimen/outer_circle"/>
<solid android:color="@color/yellow"/>
</shape>
</item>
<item
android:drawable="@drawable/ic_restart"
android:height="@dimen/inner_circle"
android:width="@dimen/inner_circle"
android:gravity="center"/>
</layer-list>
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/screen_off.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/transparent"
android:height="@dimen/frame"
android:width="@dimen/frame"/>
<item
android:gravity="center">
<shape android:shape="oval">
<size android:width="@dimen/outer_circle" android:height="@dimen/outer_circle"/>
<solid android:color="@color/blue"/>
</shape>
</item>
<item
android:drawable="@drawable/ic_screen_off"
android:height="@dimen/inner_circle"
android:width="@dimen/inner_circle"
android:gravity="center"/>
</layer-list>
Loading

0 comments on commit d2b9099

Please sign in to comment.