Basic data inspector - 6

This commit is contained in:
hajdam
2024-11-13 18:05:27 +01:00
parent eb3b9f1e4a
commit 16bc17921c
14 changed files with 35 additions and 15 deletions
+2 -2
View File
@@ -8,8 +8,8 @@ android {
applicationId "org.exbin.bined.editor.android"
minSdk 24
targetSdk 34
versionCode 8
versionName "0.2.3-SNAPSHOT"
versionCode 9
versionName "0.2.3"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
vectorDrawables.generatedDensities = []
}
@@ -16,7 +16,6 @@
package org.exbin.auxiliary.binary_data.delta.file;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
@@ -50,23 +49,22 @@ public class DeltaDataPageWindow {
private void loadPage(int index) {
long pageIndex = dataPages[index].pageIndex;
long pagePosition = pageIndex * PAGE_SIZE;
RandomAccessFile file = data.getAccessFile();
try {
long fileLength = file.length();
long fileLength = data.getDataLength();
byte[] page = dataPages[index].page;
int offset = 0;
int toRead = PAGE_SIZE;
if (pagePosition + PAGE_SIZE > fileLength) {
toRead = (int) (fileLength - pagePosition);
}
file.seek(pagePosition);
while (toRead > 0) {
int red = file.read(page, offset, toRead);
int red = data.read(pagePosition, page, offset, toRead);
if (red == -1) {
throw new IOException("Unexpected read error ");
}
toRead -= red;
offset += red;
pagePosition += red;
}
} catch (IOException ex) {
Logger.getLogger(DeltaDataPageWindow.class.getName()).log(Level.SEVERE, null, ex);
@@ -218,6 +218,6 @@ public class BasicCodeAreaColorsProfile implements CodeAreaColorsProfile {
}
private boolean isDarkMode() {
return context != null && (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) > 0;
return context != null && (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_YES) > 0;
}
}
@@ -23,7 +23,6 @@ import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -473,7 +472,7 @@ public class MainActivity extends AppCompatActivity implements FileDialog.OnFile
EditorPreferences editorPreferences = appPreferences.getEditorPreferences();
setupKeyPanel(editorPreferences.getKeysPanelMode());
DataInspectorMode dataInspectorMode = editorPreferences.getDataInspectorMode();
boolean showDataInspector = dataInspectorMode == DataInspectorMode.SHOW || (dataInspectorMode == DataInspectorMode.HORIZONTAL && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
boolean showDataInspector = dataInspectorMode == DataInspectorMode.SHOW || (dataInspectorMode == DataInspectorMode.LANDSCAPE && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
if (showDataInspector != dataInspectorShown) {
LinearLayout mainHorizontalLayout = findViewById(R.id.mainHorizontalLayout);
if (showDataInspector) {
@@ -487,7 +486,7 @@ public class MainActivity extends AppCompatActivity implements FileDialog.OnFile
dataInspectorShown = showDataInspector;
}
boolean isDarkMode = (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) > 0;
boolean isDarkMode = (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_YES) > 0;
basicValuesPositionColorModifier.setDarkMode(isDarkMode);
updateStatus();
@@ -1293,6 +1292,21 @@ public class MainActivity extends AppCompatActivity implements FileDialog.OnFile
@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
if (!codeArea.isFocused()) {
if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && isGoogleTV(codeArea.getContext())) {
codeArea.post(codeArea::requestFocus);
return true;
}
}
View currentFocus = getCurrentFocus();
if (currentFocus != null) {
return currentFocus.dispatchKeyEvent(keyEvent);
}
return false;
}
try {
if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_DEL || keyEvent.getKeyCode() == KeyEvent.KEYCODE_FORWARD_DEL) {
@@ -1308,7 +1322,7 @@ public class MainActivity extends AppCompatActivity implements FileDialog.OnFile
if (keyEvent.getEventTime() - keyEvent.getDownTime() > TimeUnit.SECONDS.toMillis(1)) {
codeArea.showContextMenu();
} else {
View keyStripeView = findViewById(R.id.keyPanel);
View keyStripeView = findViewById(R.id.button0);
keyStripeView.requestFocus();
}
} else if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && isGoogleTV(codeArea.getContext())) {
@@ -26,5 +26,5 @@ import javax.annotation.ParametersAreNonnullByDefault;
public enum DataInspectorMode {
HIDE,
SHOW,
HORIZONTAL
LANDSCAPE
}
@@ -122,7 +122,7 @@ public class EditorPreferences implements EditorOptions {
@Nonnull
@Override
public DataInspectorMode getDataInspectorMode() {
DataInspectorMode defaultDataInspectorMode = DataInspectorMode.HIDE;
DataInspectorMode defaultDataInspectorMode = DataInspectorMode.LANDSCAPE;
try {
return DataInspectorMode.valueOf(preferences.get(PREFERENCES_DATA_INSPECTOR_MODE, defaultDataInspectorMode.name()).toUpperCase());
} catch (IllegalArgumentException ex) {
+3
View File
@@ -5,17 +5,20 @@
<item
android:id="@+id/action_search"
android:icon="@drawable/ic_search_24"
android:iconTint="@color/menu_icon_state"
android:title="@string/action_search"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_undo"
android:icon="@drawable/ic_undo_24"
android:iconTint="@color/menu_icon_state"
android:title="@string/action_undo"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_redo"
android:icon="@drawable/ic_redo_24"
android:iconTint="@color/menu_icon_state"
android:title="@string/action_redo"
app:showAsAction="ifRoom" />
<item
@@ -0,0 +1,5 @@
- Added basic data inspector
- Support for partial file opening
- Support for D-Pad / Android TV
- Options for button size in keys panel
- Fix for button 9
@@ -8,7 +8,7 @@ Features
- Insert and overwrite edit modes
- TODO: Searching for text / hexadecimal code with matching highlighting
- Support for undo/redo
- TODO: Support for files with size up to exabytes
- Support for files with size up to exabytes
Translations
Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 KiB

After

Width:  |  Height:  |  Size: 463 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 KiB

After

Width:  |  Height:  |  Size: 555 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 KiB

After

Width:  |  Height:  |  Size: 352 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 KiB

After

Width:  |  Height:  |  Size: 574 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB