Skip to content

Commit

Permalink
Updated layout and added System UI restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Domi04151309 committed Aug 3, 2018
1 parent c17e297 commit 95d7a76
Show file tree
Hide file tree
Showing 28 changed files with 141 additions and 408 deletions.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/release
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
compileSdkVersion 28
defaultConfig {
applicationId "io.github.domi04151309.powerapp"
minSdkVersion 23
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -20,10 +20,10 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
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'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support:support-annotations:27.1.1'
}
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:fullBackupContent="@xml/backup_descriptor">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -29,14 +28,11 @@ protected void onPostCreate(Bundle savedInstanceState) {
getDelegate().onPostCreate(savedInstanceState);
}

public ActionBar getSupportActionBar() {
ActionBar getSupportActionBar() {
return getDelegate().getSupportActionBar();
}

public void setSupportActionBar(@Nullable Toolbar toolbar) {
getDelegate().setSupportActionBar(toolbar);
}

@NonNull
@Override
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
Expand Down
76 changes: 41 additions & 35 deletions app/src/main/java/io/github/domi04151309/powerapp/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;

import java.io.DataOutputStream;
Expand All @@ -19,19 +17,24 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String userTheme = preferences.getString("AppStyle", "8");
if (userTheme.equals("8"))
setTheme(R.style.AppTheme_8);
else if (userTheme.equals("7"))
setTheme(R.style.AppTheme_7);
else if (userTheme.equals("dark"))
setTheme(R.style.AppTheme_Dark);
else if (userTheme.equals("black"))
setTheme(R.style.AppTheme_Black);
switch (userTheme) {
case "8":
setTheme(R.style.AppTheme_8);
break;
case "7":
setTheme(R.style.AppTheme_7);
break;
case "dark":
setTheme(R.style.AppTheme_Dark);
break;
case "black":
setTheme(R.style.AppTheme_Black);
break;
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final ImageButton btn1 = (ImageButton) findViewById(R.id.shutdown);
btn1.setOnClickListener(new View.OnClickListener() {
findViewById(R.id.shutdown).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Expand All @@ -43,8 +46,7 @@ public void onClick(View v) {
}
}
});
final ImageButton btn2 = (ImageButton) findViewById(R.id.reboot);
btn2.setOnClickListener(new View.OnClickListener() {
findViewById(R.id.reboot).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Expand All @@ -56,47 +58,55 @@ public void onClick(View v) {
}
}
});
final ImageButton btn3 = (ImageButton) findViewById(R.id.soft_reboot);
btn3.setOnClickListener(new View.OnClickListener() {
findViewById(R.id.recovery).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "setprop ctl.restart zygote" });
.exec(new String[]{ "su", "-c", "reboot recovery" });
proc.waitFor();
} catch (Exception ex) {
Toast.makeText
(MainActivity.this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
Toast.makeText(MainActivity.this, "Action failed! Please enable root!",
Toast.LENGTH_LONG).show();
}
}
});
final ImageButton btn4 = (ImageButton) findViewById(R.id.recovery);
btn4.setOnClickListener(new View.OnClickListener() {
findViewById(R.id.bootloader).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot recovery" });
.exec(new String[]{ "su", "-c", "reboot bootloader" });
proc.waitFor();
} catch (Exception ex) {
Toast.makeText(MainActivity.this, "Action failed! Please enable root!",
Toast.LENGTH_LONG).show();
}
}
});
final ImageButton btn5 = (ImageButton) findViewById(R.id.bootloader);
btn5.setOnClickListener(new View.OnClickListener() {
findViewById(R.id.soft_reboot).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot bootloader" });
.exec(new String[]{ "su", "-c", "setprop ctl.restart zygote" });
proc.waitFor();
} catch (Exception ex) {
Toast.makeText(MainActivity.this, "Action failed! Please enable root!",
Toast.LENGTH_LONG).show();
Toast.makeText
(MainActivity.this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
}
}
});
final ImageButton btn6 = (ImageButton) findViewById(R.id.screen_off);
btn6.setOnClickListener(new View.OnClickListener() {
findViewById(R.id.system_ui).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "killall com.android.systemui" });
proc.waitFor();
} catch (Exception ex) {
Toast.makeText
(MainActivity.this, "Action failed! Please enable root!", Toast.LENGTH_LONG).show();
}
}
});
findViewById(R.id.screen_off).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Process proc = Runtime.getRuntime()
Expand All @@ -108,9 +118,7 @@ public void onClick(View v) {
}
}
});

Button btn7 = findViewById(R.id.root);
btn7.setOnClickListener(new View.OnClickListener() {
findViewById(R.id.root).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Process p;
Expand All @@ -125,9 +133,7 @@ public void onClick(View v) {
}
}
});

Button btn8 = findViewById(R.id.prefBtn);
btn8.setOnClickListener(new View.OnClickListener() {
findViewById(R.id.prefBtn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, Preferences.class));
Expand Down
24 changes: 15 additions & 9 deletions app/src/main/java/io/github/domi04151309/powerapp/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class Preferences extends AppCompatPreferenceActivity {

SharedPreferences.OnSharedPreferenceChangeListener spChanged = new
private final SharedPreferences.OnSharedPreferenceChangeListener spChanged = new
SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
Expand All @@ -26,14 +26,20 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String userTheme = preferences.getString("AppStyle", "8");
if (userTheme.equals("8"))
setTheme(R.style.AppTheme_8);
else if (userTheme.equals("7"))
setTheme(R.style.AppTheme_7);
else if (userTheme.equals("dark"))
setTheme(R.style.AppTheme_Dark);
else if (userTheme.equals("black"))
setTheme(R.style.AppTheme_Black);
switch (userTheme) {
case "8":
setTheme(R.style.AppTheme_8);
break;
case "7":
setTheme(R.style.AppTheme_7);
break;
case "dark":
setTheme(R.style.AppTheme_Dark);
break;
case "black":
setTheme(R.style.AppTheme_Black);
break;
}
super.onCreate(savedInstanceState);
setupActionBar();
getFragmentManager().beginTransaction()
Expand Down
34 changes: 0 additions & 34 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions app/src/main/res/drawable/ic_back.xml

This file was deleted.

Loading

0 comments on commit 95d7a76

Please sign in to comment.