Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Merged branch master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiberlin committed Feb 9, 2017
2 parents f6f9d34 + 4d2cb3f commit dc69fa5
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 59 deletions.
9 changes: 5 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@
android:name="com.happening.poc_happening.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name="com.happening.poc_happening.datastore.AndroidDatabaseManager"
android:theme="@style/AppTheme"/>
<activity
android:name="com.happening.poc_happening.datastore.AndroidDatabaseManager"
android:theme="@style/AppTheme" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ public void onRequestPermissionsResult(int requestCode, String permissions[], in
private void configureLog4j() {
String fileName = Environment.getExternalStorageDirectory() + "/" + "happen.log";
String filePattern = "%d - [%c] - %p : %m%n";
int maxBackupSize = 10;
long maxFileSize = 1024;
int maxBackupSize = 1;
long maxFileSize = 1024 * 10;
Log4jHelper.Configure(fileName, filePattern, maxBackupSize, maxFileSize);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import android.os.Environment;
import android.os.FileObserver;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;
import android.widget.Button;
import android.widget.TextView;

import com.happening.poc_happening.R;
Expand All @@ -22,58 +23,54 @@
public class TestSuiteFragment extends Fragment {

private static TestSuiteFragment instance = null;
private static BandwidthTester bwt;
private static FileObserver fileObserver;
// private static String logName;
private static TextView logContent;
private View rootView = null;

private BandwidthTester bwt = null;
private FileObserver fileObserver = null;
private String logName;
private TextView logContent;
private String fileContent = "";

public static TestSuiteFragment getInstance() {
instance = new TestSuiteFragment();
return instance;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_test_suite, container, false);
// logContent
startLogger();

// bandwidth tester
if (bwt == null) {
bwt = new BandwidthTester();
}
rootView.findViewById(R.id.button_bandwidth).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (bwt.isRunning()) {
bwt.stop();
} else {
bwt.start();
}
}
});
return instance;
}

// logContent
logName = Environment.getExternalStorageDirectory() + "/" + "happen.log";
logContent = (TextView) rootView.findViewById(R.id.bandwidth_test_log);
private static void startLogger() {

final String logName = Environment.getExternalStorageDirectory() + "/" + "happen.log";
fileObserver = new FileObserver(logName) {
@Override
public void onEvent(int event, String path) {
public void onEvent(int event, final String path) {
if (event == MODIFY) {
readLogFile();
logContent.post(new Runnable() {
public void run() {
final String log = readLogFile(logName);
Log.d("logger", path + " read " + log);
logContent.setText(log);
}
});
}

if (event == DELETE_SELF || event == DELETE) {
Log.d("logger", "voll");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
startLogger();
}
}
};

readLogFile();
fileObserver.startWatching();

return rootView;
}

private void readLogFile() {
private static String readLogFile(String logName) {
String fileContent = "";
try {
File log = new File(logName);
FileInputStream fi = new FileInputStream(log);
Expand All @@ -87,34 +84,53 @@ private void readLogFile() {
e.printStackTrace();
}

return fileContent;

logContent.post(new Runnable() {
public void run() {
logContent.setText(fileContent);
}
});

// scrollDown((ScrollView) rootView.findViewById(R.id.log_scroll));
}

private void scrollDown(final ScrollView scrollView) {
scrollView.post(new Runnable() {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_test_suite, container, false);
logContent = (TextView) rootView.findViewById(R.id.bandwidth_test_log);

// bandwidth tester
if (bwt == null) {
bwt = new BandwidthTester();
}

final Button startBandwidthTest = (Button) rootView.findViewById(R.id.button_bandwidth);

if (bwt.isRunning()) {
startBandwidthTest.setText("Bandwidth - running");
} else {
startBandwidthTest.setText("Bandwidth - stopped");
}

startBandwidthTest.setOnClickListener(new View.OnClickListener() {
@Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
public void onClick(View v) {
if (bwt.isRunning()) {
bwt.stop();
startBandwidthTest.setText("Bandwidth - stopped");
} else {
bwt.start();
startBandwidthTest.setText("Bandwidth - running");
}
}
});

return rootView;
}

@Override
public void onResume() {
fileObserver.startWatching();
super.onResume();
fileObserver.startWatching();
}

@Override
public void onStop() {
fileObserver.stopWatching();
super.onStop();
fileObserver.stopWatching();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

import de.mindpipe.android.logging.log4j.LogConfigurator;

/**
* Created by Fabian on 11.01.2017.
*/

public class Log4jHelper {
private final static LogConfigurator _logConfigurator = new LogConfigurator();

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_test_suite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:id="@+id/button_bandwidth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test Bandwidth" />
android:text="Bandwidth - stopped" />

<ScrollView
android:id="@+id/log_scroll"
Expand Down

0 comments on commit dc69fa5

Please sign in to comment.