Skip to content

Commit

Permalink
Merge pull request #80 from yoinx/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JoeSchubert committed Nov 1, 2016
2 parents 9c9856b + 7e379f0 commit ec77f90
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ local.properties

# Misc
.DS_Store

app/*.apk
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,20 @@ public boolean showApplyOnBoot() {
public void init(Bundle savedInstanceState) {
super.init(savedInstanceState);

ModififactionInit();
ModificationVersionInit();
ModificationInit();
googlePlusInit();
licenseInit();
appSourceInit();
featureRequestInit();
donateInit();
}

private void ModififactionInit() {
private void ModificationInit() {
CardViewItem.DCardView mModificationCard = new CardViewItem.DCardView();
mModificationCard.setTitle(getString(R.string.modification));
mModificationCard.setDescription(getString(R.string.modification_summary));

addView(mModificationCard);
}

private void ModificationVersionInit() {
CardViewItem.DCardView mModificationVersionCard = new CardViewItem.DCardView();
mModificationVersionCard.setTitle(getString(R.string.modification_version));
mModificationVersionCard.setDescription(getString(R.string.modification_version_number, BuildConfig.VERSION_CODE));

addView(mModificationVersionCard);
}

private void googlePlusInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
import com.grarak.kerneladiutor.utils.database.CommandDB;
import com.grarak.kerneladiutor.utils.root.Control;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -117,11 +120,17 @@ public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0: {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Startup Comnmand", allcommands);
ClipData clip = ClipData.newPlainText("Startup Comnmands Shell", allcommands);
clipboard.setPrimaryClip(clip);
break;
}
case 1: {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Startup Comnmands RC", convert_to_rc(allcommands));
clipboard.setPrimaryClip(clip);
break;
}
case 2: {
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder.setMessage(getString(R.string.startup_commands_delete_all)).setPositiveButton(getString(R.string.startup_commands_delete_all_yes), dialogClickListener)
.setNegativeButton(getString(R.string.startup_commands_delete_all_no), dialogClickListener).show();
Expand Down Expand Up @@ -206,4 +215,24 @@ public void onClick(DialogInterface dialog, int which) {
}
};

private String convert_to_rc(String text) {
StringBuilder sb = new StringBuilder();
BufferedReader bufReader = new BufferedReader(new StringReader(text));
try {
String line = null;
while ((line = bufReader.readLine()) != null) {
String[] tar = line.split(" ");
if(tar[0].equals("echo")) {
String fparse[] = line.split(">");
String fcmd = fparse[0].replaceFirst("^echo", "");
sb.append("write" + fparse[1] + fcmd + "\n");
} else {
sb.append(line + "\n");
}
}
} catch (IOException x) {
}
return sb.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import com.grarak.kerneladiutor.utils.Constants;
import com.grarak.kerneladiutor.utils.kernel.Screen;

import static android.os.SystemClock.elapsedRealtime;

/**
* Created by willi on 08.03.15.
*/
Expand All @@ -42,7 +44,7 @@ public class AutoHighBrightnessModeService extends Service {
public static boolean HBM_Manually_Toggled = false;
public static float[] luxvalues = new float [3];


private static long prevuptime = 0;
private SensorManager sMgr;
Sensor light;

Expand Down Expand Up @@ -98,29 +100,32 @@ public void deactivateLightSensorRead() {
SensorEventListener _SensorEventListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
// Call Screen.hasScreenHBM() here in the if block to ensure that the appropriate variables are set when calling Screen.activateScreenHBM
if (Screen.isScreenAutoHBMActive(getApplicationContext()) && Screen.isScreenAutoHBMSmoothingActive(getApplicationContext()) && Screen.hasScreenHBM()) {
// This should average the last X lux values. X being user set or defaulting to 3.
// This will cause some delay in autohbm actually working as the values initialize at 0
avglux = 0;
for(int i = luxvalues.length - 1; i > 0; i--) {
luxvalues[i] = luxvalues[i - 1];
avglux += luxvalues[i];
}
luxvalues[0] = event.values[0];
avglux += luxvalues[0];
lux = Math.round(avglux / luxvalues.length);
} else {
lux = Math.round(event.values[0]);
}
if (Screen.isScreenAutoHBMActive(getApplicationContext()) && !HBM_Manually_Toggled) {
if (lux >= LuxThresh && !Screen.isScreenHBMActive()) {
Log.i("Kernel Adiutor: ", "AutoHBMService Activating HBM: received LUX value: " + lux + " Threshold: " + LuxThresh);
Screen.activateScreenHBM(true, getApplicationContext(), "Auto");
if (elapsedRealtime() - prevuptime >= 100) {
prevuptime = elapsedRealtime();
// Call Screen.hasScreenHBM() here in the if block to ensure that the appropriate variables are set when calling Screen.activateScreenHBM
if (Screen.isScreenAutoHBMActive(getApplicationContext()) && Screen.isScreenAutoHBMSmoothingActive(getApplicationContext()) && Screen.hasScreenHBM()) {
// This should average the last X lux values. X being user set or defaulting to 3.
// This will cause some delay in autohbm actually working as the values initialize at 0
avglux = 0;
for (int i = luxvalues.length - 1; i > 0; i--) {
luxvalues[i] = luxvalues[i - 1];
avglux += luxvalues[i];
}
luxvalues[0] = event.values[0];
avglux += luxvalues[0];
lux = Math.round(avglux / luxvalues.length);
} else {
lux = Math.round(event.values[0]);
}
if (lux < LuxThresh && Screen.isScreenHBMActive()) {
Log.i("Kernel Adiutor: ", "De-Activation: AutoHBMService: received LUX value: " + lux + " Threshold: " + LuxThresh);
Screen.activateScreenHBM(false, getApplicationContext(), "Auto");
if (Screen.isScreenAutoHBMActive(getApplicationContext()) && !HBM_Manually_Toggled) {
if (lux >= LuxThresh && !Screen.isScreenHBMActive()) {
Log.i("Kernel Adiutor: ", "AutoHBMService Activating HBM: received LUX value: " + lux + " Threshold: " + LuxThresh);
Screen.activateScreenHBM(true, getApplicationContext(), "Auto");
}
if (lux < LuxThresh && Screen.isScreenHBMActive()) {
Log.i("Kernel Adiutor: ", "De-Activation: AutoHBMService: received LUX value: " + lux + " Threshold: " + LuxThresh);
Screen.activateScreenHBM(false, getApplicationContext(), "Auto");
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
int N = appWidgetIds.length;
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
// Make sure that the widget is in the correct state when widgets are updating.
doupdate(context, Screen.isScreenHBMActive());

RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.hbm_widget_layout);
Intent intent = new Intent(context, HBMWidget.class);
intent.setAction("com.kerneladiutor.mod.action.TOGGLE_HBM");
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
int flag = PendingIntent.FLAG_UPDATE_CURRENT;
PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, flag);
views.setOnClickPendingIntent(R.id.imageView, pi);
Expand All @@ -68,7 +70,7 @@ public void onReceive(Context context, Intent intent) {
}
}
}
// Make sure that the widghet is in the correct state when the phone is unlocked.
// Make sure that the widget is in the correct state when the phone is unlocked.
if (intent.getAction().equals("android.intent.action.USER_PRESENT") && Screen.hasScreenHBM()) {
doupdate(context, Screen.isScreenHBMActive());
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,6 @@
<string name="modification">Modifizierte Version von Kernel Adiutor</string>
<string name="modification_summary">Diese Applikation wurde um verschiedene Features erweitert, die nicht in der Originalversion von Kernel Adiutor enthalten sind.</string>

<string name="modification_version">Modifizierte Version</string>

<string name="accessibility_service_label">KA Per-App-Monitor</string>
<string name="accessibility_service_desc">Dienst zur Überwachung, ob sich eine Vordergrund-App durch das Laden eines Per-App-Profils ändert.</string>
<string name="smb135x_wakelock_summary">smb135x-Wakelock ist erlaubt. Ausschalten, um dieses Wakelock außerhalb des Ladevorgangs zu verhindern.\n Aktuell: %s.</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@

<!-- Startup Commands -->
<string-array name="startup_commands_menu">
<item>@string/copy</item>
<item>@string/copy_as_shell</item>
<item>@string/copy_as_rc</item>
<item>@string/delete</item>
</string-array>

Expand Down
6 changes: 2 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
<string name="no_permission">No permission</string>
<string name="select_file">Select %s?</string>
<string name="no_files">No files in this path.</string>
<string name="copy">Copy</string>
<string name="copy_as_shell">Copy as Shell Script</string>
<string name="copy_as_rc">Copy as RC Script</string>

<!-- EditText -->
<string name="save">Save</string>
Expand Down Expand Up @@ -997,9 +998,6 @@
<string name="modification">Modified build of Kernel Adiutor</string>
<string name="modification_summary">This application is being modified for various custom features that are not included in the original Kernel Adiutor.</string>

<string name="modification_version">Modification Version</string>
<string name="modification_version_number" translatable="false">Build %d</string>

<string name="accessibility_service_label">KA Per App Monitor</string>
<string name="accessibility_service_desc">Service to monitor when foreground app changes for per-app profile loading</string>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/hbm_widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
android:initialLayout="@layout/hbm_widget_layout"
android:previewImage="@drawable/hbm_widget_preview"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="43200000" >
android:updatePeriodMillis="0" >
</appwidget-provider>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Jan 10 15:03:43 CET 2016
#Sun Oct 23 19:44:48 EDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.kerneladiutor.library.root;

import android.os.Build;
import android.util.Log;

import com.kerneladiutor.library.Tools;
Expand Down Expand Up @@ -78,8 +79,13 @@ public static String getKernelVersion() {
}

public static void mount(boolean writeable, String mountpoint) {
runCommand(writeable ? "mount -o remount,rw " + mountpoint + " " + mountpoint :
"mount -o remount,ro " + mountpoint + " " + mountpoint);
if (Build.VERSION.SDK_INT <= 23) {
runCommand(writeable ? "mount -o remount,rw " + mountpoint + " " + mountpoint :
"mount -o remount,ro " + mountpoint + " " + mountpoint);
} else {
runCommand(writeable ? "mount -o rw,remount -t auto " + mountpoint + " " + mountpoint :
"mount -o ro,remount -t auto " + mountpoint + " " + mountpoint);
}
}

public static void closeSU() {
Expand Down

1 comment on commit ec77f90

@huune
Copy link

@huune huune commented on ec77f90 Feb 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.