Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1faf196
commit 0c254c9
Showing
38 changed files
with
1,575 additions
and
1,004 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 0 additions & 78 deletions
78
app/src/main/java/org/thoughtcrime/securesms/LogSubmitActivity.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/src/main/java/org/thoughtcrime/securesms/components/ListenableHorizontalScrollView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.thoughtcrime.securesms.components; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.widget.HorizontalScrollView; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
/** | ||
* Unfortunately {@link HorizontalScrollView#setOnScrollChangeListener(OnScrollChangeListener)} | ||
* wasn't added until API 23, so now we have to do this ourselves. | ||
*/ | ||
public class ListenableHorizontalScrollView extends HorizontalScrollView { | ||
|
||
private OnScrollListener listener; | ||
|
||
public ListenableHorizontalScrollView(Context context) { | ||
super(context); | ||
} | ||
|
||
public ListenableHorizontalScrollView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public void setOnScrollListener(@Nullable OnScrollListener listener) { | ||
this.listener = listener; | ||
} | ||
|
||
@Override | ||
protected void onScrollChanged(int newLeft, int newTop, int oldLeft, int oldTop) { | ||
if (listener != null) { | ||
listener.onScroll(newLeft, oldLeft); | ||
} | ||
super.onScrollChanged(newLeft, newTop, oldLeft, oldTop); | ||
} | ||
|
||
public interface OnScrollListener { | ||
void onScroll(int newLeft, int oldLeft); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/org/thoughtcrime/securesms/logsubmit/CompleteLogLine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.thoughtcrime.securesms.logsubmit; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
/** | ||
* A {@link LogLine} with proper IDs. | ||
*/ | ||
public class CompleteLogLine implements LogLine { | ||
|
||
private final long id; | ||
private final LogLine line; | ||
|
||
public CompleteLogLine(long id, @NonNull LogLine line) { | ||
this.id = id; | ||
this.line = line; | ||
} | ||
|
||
@Override | ||
public long getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public @NonNull String getText() { | ||
return line.getText(); | ||
} | ||
|
||
@Override | ||
public @NonNull Style getStyle() { | ||
return line.getStyle(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogLine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.thoughtcrime.securesms.logsubmit; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.annimon.stream.Stream; | ||
|
||
import java.util.List; | ||
import java.util.regex.Pattern; | ||
|
||
interface LogLine { | ||
|
||
long getId(); | ||
@NonNull String getText(); | ||
@NonNull Style getStyle(); | ||
|
||
static List<LogLine> fromText(@NonNull CharSequence text) { | ||
return Stream.of(Pattern.compile("\\n").split(text)) | ||
.map(s -> new SimpleLogLine(s, Style.NONE)) | ||
.map(line -> (LogLine) line) | ||
.toList(); | ||
} | ||
|
||
enum Style { | ||
NONE, VERBOSE, DEBUG, INFO, WARNING, ERROR | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.thoughtcrime.securesms.logsubmit; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import java.util.List; | ||
|
||
interface LogSection { | ||
/** | ||
* The title to show at the top of the log section. | ||
*/ | ||
@NonNull String getTitle(); | ||
|
||
/** | ||
* The full content of your log section. We use a {@link CharSequence} instead of a | ||
* {@link List<LogLine> } for performance reasons. Scrubbing large swaths of text is faster than | ||
* one line at a time. | ||
*/ | ||
@NonNull CharSequence getContent(@NonNull Context context); | ||
} |
54 changes: 54 additions & 0 deletions
54
app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionFeatureFlags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.thoughtcrime.securesms.logsubmit; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.annimon.stream.Stream; | ||
|
||
import org.thoughtcrime.securesms.util.FeatureFlags; | ||
import org.thoughtcrime.securesms.util.Util; | ||
|
||
import java.util.Map; | ||
|
||
public class LogSectionFeatureFlags implements LogSection { | ||
|
||
@Override | ||
public @NonNull String getTitle() { | ||
return "FEATURE FLAGS"; | ||
} | ||
|
||
@Override | ||
public @NonNull CharSequence getContent(@NonNull Context context) { | ||
StringBuilder out = new StringBuilder(); | ||
Map<String, Boolean> memory = FeatureFlags.getMemoryValues(); | ||
Map<String, Boolean> disk = FeatureFlags.getDiskValues(); | ||
Map<String, Boolean> forced = FeatureFlags.getForcedValues(); | ||
int remoteLength = Stream.of(memory.keySet()).map(String::length).max(Integer::compareTo).orElse(0); | ||
int diskLength = Stream.of(disk.keySet()).map(String::length).max(Integer::compareTo).orElse(0); | ||
int forcedLength = Stream.of(forced.keySet()).map(String::length).max(Integer::compareTo).orElse(0); | ||
|
||
out.append("-- Memory\n"); | ||
for (Map.Entry<String, Boolean> entry : memory.entrySet()) { | ||
out.append(Util.rightPad(entry.getKey(), remoteLength)).append(": ").append(entry.getValue()).append("\n"); | ||
} | ||
out.append("\n"); | ||
|
||
out.append("-- Disk\n"); | ||
for (Map.Entry<String, Boolean> entry : disk.entrySet()) { | ||
out.append(Util.rightPad(entry.getKey(), diskLength)).append(": ").append(entry.getValue()).append("\n"); | ||
} | ||
out.append("\n"); | ||
|
||
out.append("-- Forced\n"); | ||
if (forced.isEmpty()) { | ||
out.append("None\n"); | ||
} else { | ||
for (Map.Entry<String, Boolean> entry : forced.entrySet()) { | ||
out.append(Util.rightPad(entry.getKey(), forcedLength)).append(": ").append(entry.getValue()).append("\n"); | ||
} | ||
} | ||
|
||
return out; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionJobs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.thoughtcrime.securesms.logsubmit; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies; | ||
|
||
import java.util.List; | ||
|
||
public class LogSectionJobs implements LogSection { | ||
|
||
@Override | ||
public @NonNull String getTitle() { | ||
return "JOBS"; | ||
} | ||
|
||
@Override | ||
public @NonNull CharSequence getContent(@NonNull Context context) { | ||
return ApplicationDependencies.getJobManager().getDebugInfo(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionLogcat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.thoughtcrime.securesms.logsubmit; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import org.thoughtcrime.securesms.logging.Log; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
public class LogSectionLogcat implements LogSection { | ||
|
||
@Override | ||
public @NonNull String getTitle() { | ||
return "LOGCAT"; | ||
} | ||
|
||
@Override | ||
public @NonNull CharSequence getContent(@NonNull Context context) { | ||
try { | ||
final Process process = Runtime.getRuntime().exec("logcat -d"); | ||
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); | ||
final StringBuilder log = new StringBuilder(); | ||
final String separator = System.getProperty("line.separator"); | ||
|
||
String line; | ||
while ((line = bufferedReader.readLine()) != null) { | ||
log.append(line); | ||
log.append(separator); | ||
} | ||
return log.toString(); | ||
} catch (IOException ioe) { | ||
return "Failed to retrieve."; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.thoughtcrime.securesms.logsubmit; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import org.thoughtcrime.securesms.ApplicationContext; | ||
|
||
import java.util.concurrent.ExecutionException; | ||
|
||
public class LogSectionLogger implements LogSection { | ||
|
||
@Override | ||
public @NonNull String getTitle() { | ||
return "LOGGER"; | ||
} | ||
|
||
@Override | ||
public @NonNull CharSequence getContent(@NonNull Context context) { | ||
try { | ||
return ApplicationContext.getInstance(context).getPersistentLogger().getLogs().get(); | ||
} catch (ExecutionException | InterruptedException e) { | ||
return "Failed to retrieve."; | ||
} | ||
} | ||
} |
Oops, something went wrong.