Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ protected void onCreate(Bundle savedInstanceState) {
startActivity(new Intent(this, DozeStatsActivity.class));
finish();
}
mListView.scrollToPosition(0);
}
}

Expand Down
257 changes: 173 additions & 84 deletions app/src/main/java/com/suyashsrijan/forcedoze/ForceDozeService.java

Large diffs are not rendered by default.

36 changes: 34 additions & 2 deletions app/src/main/java/com/suyashsrijan/forcedoze/LogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.HorizontalScrollView;
import android.widget.ScrollView;

import com.afollestad.materialdialogs.MaterialDialog;
import com.nanotasks.BackgroundWork;
Expand All @@ -33,6 +35,10 @@ public class LogActivity extends AppCompatActivity {
boolean isSuAvailable;
MaterialDialog progressDialog = null;

private ScrollView mSVLog;
private HorizontalScrollView mHSVLog;
private EditText logcatEd;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -93,20 +99,46 @@ public void onSuccess(Context context, List<String> result) {
if (progressDialog != null) {
progressDialog.cancel();
}
EditText logcatEd = (EditText) findViewById(R.id.editText);
logcatEd = (EditText) findViewById(R.id.editText);
mSVLog = (ScrollView) findViewById(R.id.svLog);
mHSVLog = (HorizontalScrollView) findViewById(R.id.hsvLog);


if (result != null) {
log = result;
logcatEd.setLongClickable(false);
logcatEd.setFocusable(false);
logcatEd.setClickable(true);
logcatEd.setText(result.toString());
logcatEd.setHorizontallyScrolling(true);

StringBuilder sb = new StringBuilder();
for (String res : result) {
sb.append(res.replaceAll("ForceDozeService", "FDS")
.replaceAll("ForceDoze","FD"));
sb.append("\n");
}
logcatEd.setText(sb.toString());
} else {
log = null;
logcatEd.setLongClickable(false);
logcatEd.setFocusable(false);
logcatEd.setClickable(true);
logcatEd.setText("Unable to get logcat");
}

mSVLog.post(new Runnable() {
@Override
public void run() {
mSVLog.scrollTo(0, logcatEd.getHeight());
}
});

mHSVLog.post(new Runnable() {
@Override
public void run() {
mHSVLog.scrollTo(0, 0);
}
});
}

@Override
Expand Down
30 changes: 20 additions & 10 deletions app/src/main/res/layout/activity_log.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.suyashsrijan.forcedoze.LogActivity">

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="@+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
<ScrollView
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/svLog"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<HorizontalScrollView
android:id="@+id/hsvLog"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:inputType="textMultiLine"
android:id="@+id/editText" />

</HorizontalScrollView>
</ScrollView>
</RelativeLayout>
6 changes: 3 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<string name="persistent_notification_setting_title">Show persistent notification</string>
<string name="lockscreen_timeout_setting_summary">Ignore lockscreen timeout and enable Doze immediately after screen off</string>
<string name="lockscreen_timeout_setting_title">Ignore lockscreen timeout</string>
<string name="doze_delay_setting_summary">Add a delay before Doze mode kicks in after screen-off</string>
<string name="doze_delay_setting_summary">Add a delay before Doze mode kicks in after screen-off. In seconds.</string>
<string name="doze_delay_setting_title">Doze delay</string>
<string name="whitelist_apps_setting_summary">Whitelist apps from Doze mode</string>
<string name="whitelist_apps_setting_text">Whitelist apps</string>
Expand Down Expand Up @@ -102,8 +102,8 @@
<string name="turn_off_internet_doze_setting_summary">Disables WiFi/mobile data during Doze</string>
<string name="disable_wifi_during_doze_setting_summary">Turn off WiFi during Doze</string>
<string name="disable_wifi_during_doze_setting_title">Disable WiFi during Doze</string>
<string name="disable_data_during_doze_setting_summary">Turn off mobile data during Doze</string>
<string name="disable_data_during_doze_setting_title">Disable mobile data during Doze</string>
<string name="disable_data_during_doze_setting_summary">Turn off mobile data during Doze. Requires root.</string>
<string name="disable_data_during_doze_setting_title">Disable mobile data during Doze (root)</string>
<string name="motion_sensing_disable_non_root_setting_summary">Prevent device movement from turning off Doze (non-root, experimental)</string>
<string name="motion_sensing_disable_non_root_setting_title">Disable motion sensing for Doze</string>
<string name="tasker_broadcast_setting_title">Tasker broadcasts</string>
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/xml/prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
android:key="turnOffWiFiInDoze"
android:summary="@string/disable_wifi_during_doze_setting_summary"
android:title="@string/disable_wifi_during_doze_setting_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="optionTryWiFi"
android:summary="Tries to connect WiFi for 15secs after screen on. If unsuccessful turn off WiFi for 20mins. Repeat."
android:title="WiFi timeout" />
<CheckBoxPreference
android:defaultValue="false"
android:key="turnOffDataInDoze"
Expand Down Expand Up @@ -109,4 +114,4 @@
android:targetPackage="com.suyashsrijan.forcedoze" />
</Preference>
</PreferenceCategory>
</PreferenceScreen>
</PreferenceScreen>