Remove old files, Fix crash on Android 4.1, Add font and keyboard mode settings, Fix icon (use PNG), Update some strings
10
README.md
@@ -1,3 +1,11 @@
|
||||
# NoteTand
|
||||
|
||||
Simple plain-text notes app with Bluetooth sync!
|
||||
Simple plain-text notes app with Bluetooth sync!
|
||||
|
||||
<table><tr>
|
||||
<td><a href="https://gitlab.com/octospacc/NoteTand"><b>GitLab.com</b></a></td>
|
||||
<td><a href="https://github.com/octospacc/NoteTand">GitHub</a></td>
|
||||
<td><a href="https://gitea.it/octospacc/NoteTand">Gitea.it</a></td>
|
||||
</tr></table>
|
||||
|
||||
<a href="https://octospacc.altervista.org/2025/09/19/la-nuova-appistica-notetand-per-scrivere-note-col-dente-blu-app-android-di-appunti-bluetooth/" target="_blank"><img alt="App Screenshot" src="https://octospacc.altervista.org/wp-content/uploads/2025/09/screenshot_2025-09-19-10-51-46-188_org7787245492189401085-665x1440.jpg" /></a>
|
@@ -8,7 +8,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.eu.octt.notetand"
|
||||
minSdk 10
|
||||
minSdk 9
|
||||
targetSdk 35
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
@@ -22,7 +22,7 @@ android {
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,5 +17,5 @@
|
||||
}
|
||||
],
|
||||
"elementType": "File",
|
||||
"minSdkVersionForDexing": 10
|
||||
"minSdkVersionForDexing": 9
|
||||
}
|
@@ -39,10 +39,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- <activity
|
||||
android:name=".MainActivity1"
|
||||
android:exported="true" /> -->
|
||||
|
||||
<activity
|
||||
android:name=".NoteActivity"
|
||||
android:label="@string/note"
|
||||
@@ -73,12 +69,7 @@
|
||||
android:exported="false"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
|
||||
<!-- <activity
|
||||
android:name=".BluetoothSyncActivity"
|
||||
android:exported="false"
|
||||
android:parentActivityName=".MainActivity1" /> -->
|
||||
|
||||
<provider
|
||||
<!-- <provider
|
||||
android:name=".NotesProvider"
|
||||
android:authorities="org.eu.octt.notetand"
|
||||
android:exported="true"
|
||||
@@ -87,8 +78,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
|
||||
</intent-filter>
|
||||
</provider>
|
||||
|
||||
</provider> -->
|
||||
|
||||
</application>
|
||||
|
||||
|
@@ -1,797 +0,0 @@
|
||||
package org.eu.octt.notetand;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothServerSocket;
|
||||
import android.bluetooth.BluetoothSocket;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BluetoothSyncActivity extends Activity {
|
||||
|
||||
private static final String TAG = "BluetoothSync";
|
||||
private static final UUID SERVICE_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
|
||||
private static final String SERVICE_NAME = "SyncNotesApp";
|
||||
private static final int REQUEST_DISCOVERABLE = 2001;
|
||||
private static final int DISCOVERABLE_DURATION = 300; // 5 minutes
|
||||
|
||||
// Protocol constants
|
||||
private static final String PROTOCOL_HANDSHAKE = "SYNCNOTES_HANDSHAKE";
|
||||
private static final String PROTOCOL_FILE_LIST = "FILE_LIST";
|
||||
private static final String PROTOCOL_FILE_REQUEST = "FILE_REQUEST";
|
||||
private static final String PROTOCOL_FILE_DATA = "FILE_DATA";
|
||||
private static final String PROTOCOL_SYNC_COMPLETE = "SYNC_COMPLETE";
|
||||
private static final String PROTOCOL_ERROR = "ERROR";
|
||||
|
||||
private BluetoothAdapter bluetoothAdapter;
|
||||
private TextView txtBluetoothStatus;
|
||||
private TextView txtSyncProgress;
|
||||
private Button btnMakeDiscoverable;
|
||||
private Button btnScanDevices;
|
||||
private Button btnCancelSync;
|
||||
private ListView listPairedDevices;
|
||||
private ListView listDiscoveredDevices;
|
||||
|
||||
private ArrayAdapter<String> pairedDevicesAdapter;
|
||||
private ArrayAdapter<String> discoveredDevicesAdapter;
|
||||
private ArrayList<BluetoothDevice> pairedDevicesList;
|
||||
private ArrayList<BluetoothDevice> discoveredDevicesList;
|
||||
|
||||
private AcceptThread acceptThread;
|
||||
private ConnectThread connectThread;
|
||||
private ConnectedThread connectedThread;
|
||||
private Handler mainHandler;
|
||||
private File notesDirectory;
|
||||
private boolean isScanning = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.bluetooth_sync_activity);
|
||||
|
||||
// Enable up navigation
|
||||
if (getActionBar() != null) {
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getActionBar().setTitle("Bluetooth Sync");
|
||||
}
|
||||
|
||||
mainHandler = new Handler(Looper.getMainLooper());
|
||||
initializeViews();
|
||||
setupNotesDirectory();
|
||||
initializeBluetooth();
|
||||
setupListeners();
|
||||
}
|
||||
|
||||
private void initializeViews() {
|
||||
txtBluetoothStatus = findViewById(R.id.txt_bluetooth_status);
|
||||
txtSyncProgress = findViewById(R.id.txt_sync_progress);
|
||||
btnMakeDiscoverable = findViewById(R.id.btn_make_discoverable);
|
||||
btnScanDevices = findViewById(R.id.btn_scan_devices);
|
||||
btnCancelSync = findViewById(R.id.btn_cancel_sync);
|
||||
listPairedDevices = findViewById(R.id.list_paired_devices);
|
||||
listDiscoveredDevices = findViewById(R.id.list_discovered_devices);
|
||||
|
||||
// Initialize device lists
|
||||
pairedDevicesList = new ArrayList<>();
|
||||
discoveredDevicesList = new ArrayList<>();
|
||||
|
||||
pairedDevicesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
|
||||
discoveredDevicesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
|
||||
|
||||
listPairedDevices.setAdapter(pairedDevicesAdapter);
|
||||
listDiscoveredDevices.setAdapter(discoveredDevicesAdapter);
|
||||
}
|
||||
|
||||
private void setupNotesDirectory() {
|
||||
String notesPath = getIntent().getStringExtra("notes_directory");
|
||||
if (notesPath != null) {
|
||||
notesDirectory = new File(notesPath);
|
||||
} else {
|
||||
File externalFilesDir = getExternalFilesDir(null);
|
||||
if (externalFilesDir != null) {
|
||||
notesDirectory = new File(externalFilesDir, "notes");
|
||||
} else {
|
||||
notesDirectory = new File(getFilesDir(), "notes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeBluetooth() {
|
||||
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
if (bluetoothAdapter == null) {
|
||||
updateStatus("Bluetooth not supported on this device");
|
||||
disableAllButtons();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bluetoothAdapter.isEnabled()) {
|
||||
updateStatus("Bluetooth is disabled");
|
||||
disableAllButtons();
|
||||
return;
|
||||
}
|
||||
|
||||
updateStatus("Bluetooth ready");
|
||||
loadPairedDevices();
|
||||
startAcceptThread();
|
||||
}
|
||||
|
||||
private void setupListeners() {
|
||||
btnMakeDiscoverable.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
makeDiscoverable();
|
||||
}
|
||||
});
|
||||
|
||||
btnScanDevices.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isScanning) {
|
||||
stopDeviceDiscovery();
|
||||
} else {
|
||||
startDeviceDiscovery();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnCancelSync.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
listPairedDevices.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
BluetoothDevice device = pairedDevicesList.get(position);
|
||||
connectToDevice(device);
|
||||
}
|
||||
});
|
||||
|
||||
listDiscoveredDevices.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
BluetoothDevice device = discoveredDevicesList.get(position);
|
||||
connectToDevice(device);
|
||||
}
|
||||
});
|
||||
|
||||
// Register for broadcasts when a device is discovered
|
||||
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
|
||||
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
|
||||
registerReceiver(discoveryReceiver, filter);
|
||||
}
|
||||
|
||||
private void loadPairedDevices() {
|
||||
pairedDevicesList.clear();
|
||||
pairedDevicesAdapter.clear();
|
||||
|
||||
if (checkBluetoothPermission()) {
|
||||
Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
|
||||
if (pairedDevices.size() > 0) {
|
||||
for (BluetoothDevice device : pairedDevices) {
|
||||
pairedDevicesList.add(device);
|
||||
String deviceInfo = device.getName() + "\n" + device.getAddress();
|
||||
pairedDevicesAdapter.add(deviceInfo);
|
||||
}
|
||||
} else {
|
||||
pairedDevicesAdapter.add("No paired devices found");
|
||||
}
|
||||
} else {
|
||||
pairedDevicesAdapter.add("Bluetooth permission required");
|
||||
}
|
||||
|
||||
pairedDevicesAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void makeDiscoverable() {
|
||||
if (!checkBluetoothPermission()) {
|
||||
Toast.makeText(this, "Bluetooth permission required", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
|
||||
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, DISCOVERABLE_DURATION);
|
||||
startActivityForResult(discoverableIntent, REQUEST_DISCOVERABLE);
|
||||
}
|
||||
|
||||
private void startDeviceDiscovery() {
|
||||
if (!checkBluetoothPermission()) {
|
||||
Toast.makeText(this, "Bluetooth permission required", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
discoveredDevicesList.clear();
|
||||
discoveredDevicesAdapter.clear();
|
||||
discoveredDevicesAdapter.notifyDataSetChanged();
|
||||
|
||||
if (bluetoothAdapter.isDiscovering()) {
|
||||
bluetoothAdapter.cancelDiscovery();
|
||||
}
|
||||
|
||||
boolean started = bluetoothAdapter.startDiscovery();
|
||||
if (started) {
|
||||
isScanning = true;
|
||||
btnScanDevices.setText("Stop Scan");
|
||||
updateProgress("Scanning for devices...");
|
||||
} else {
|
||||
Toast.makeText(this, "Failed to start device discovery", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void stopDeviceDiscovery() {
|
||||
if (checkBluetoothPermission() && bluetoothAdapter.isDiscovering()) {
|
||||
bluetoothAdapter.cancelDiscovery();
|
||||
}
|
||||
isScanning = false;
|
||||
btnScanDevices.setText("Scan for Devices");
|
||||
updateProgress("");
|
||||
}
|
||||
|
||||
private void connectToDevice(final BluetoothDevice device) {
|
||||
if (!checkBluetoothPermission()) {
|
||||
Toast.makeText(this, "Bluetooth permission required", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop discovery to save resources
|
||||
if (bluetoothAdapter.isDiscovering()) {
|
||||
bluetoothAdapter.cancelDiscovery();
|
||||
isScanning = false;
|
||||
btnScanDevices.setText("Scan for Devices");
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Connect to Device")
|
||||
.setMessage("Connect to " + device.getName() + " (" + device.getAddress() + ") for sync?")
|
||||
.setPositiveButton("Connect", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startConnectThread(device);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Cancel", null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void startConnectThread(BluetoothDevice device) {
|
||||
// Cancel any existing connection attempts
|
||||
if (connectThread != null) {
|
||||
connectThread.cancel();
|
||||
connectThread = null;
|
||||
}
|
||||
|
||||
connectThread = new ConnectThread(device);
|
||||
connectThread.start();
|
||||
updateProgress("Connecting to " + device.getName() + "...");
|
||||
}
|
||||
|
||||
private void startAcceptThread() {
|
||||
if (acceptThread != null) {
|
||||
acceptThread.cancel();
|
||||
}
|
||||
acceptThread = new AcceptThread();
|
||||
acceptThread.start();
|
||||
}
|
||||
|
||||
private boolean checkBluetoothPermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
return checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateStatus(String status) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
txtBluetoothStatus.setText(status);
|
||||
}
|
||||
});
|
||||
Log.d(TAG, "Status: " + status);
|
||||
}
|
||||
|
||||
private void updateProgress(String progress) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
txtSyncProgress.setText(progress);
|
||||
}
|
||||
});
|
||||
Log.d(TAG, "Progress: " + progress);
|
||||
}
|
||||
|
||||
private void disableAllButtons() {
|
||||
btnMakeDiscoverable.setEnabled(false);
|
||||
btnScanDevices.setEnabled(false);
|
||||
}
|
||||
|
||||
// BroadcastReceiver for Bluetooth device discovery
|
||||
private final BroadcastReceiver discoveryReceiver = new BroadcastReceiver() {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
|
||||
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
if (device != null && checkBluetoothPermission()) {
|
||||
String deviceName = device.getName();
|
||||
if (deviceName == null) {
|
||||
deviceName = "Unknown Device";
|
||||
}
|
||||
|
||||
// Avoid duplicates
|
||||
boolean alreadyAdded = false;
|
||||
for (BluetoothDevice existingDevice : discoveredDevicesList) {
|
||||
if (existingDevice.getAddress().equals(device.getAddress())) {
|
||||
alreadyAdded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!alreadyAdded) {
|
||||
discoveredDevicesList.add(device);
|
||||
String deviceInfo = deviceName + "\n" + device.getAddress();
|
||||
discoveredDevicesAdapter.add(deviceInfo);
|
||||
discoveredDevicesAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
|
||||
isScanning = false;
|
||||
btnScanDevices.setText("Scan for Devices");
|
||||
updateProgress("Discovery finished. Found " + discoveredDevicesList.size() + " devices.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Thread for accepting incoming connections
|
||||
private class AcceptThread extends Thread {
|
||||
private BluetoothServerSocket serverSocket;
|
||||
|
||||
public AcceptThread() {
|
||||
try {
|
||||
if (checkBluetoothPermission()) {
|
||||
serverSocket = bluetoothAdapter.listenUsingRfcommWithServiceRecord(
|
||||
SERVICE_NAME, SERVICE_UUID);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Socket listen() failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
BluetoothSocket socket = null;
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
socket = serverSocket.accept();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Socket accept() failed", e);
|
||||
break;
|
||||
}
|
||||
|
||||
if (socket != null) {
|
||||
// Connection accepted
|
||||
manageConnectedSocket(socket);
|
||||
try {
|
||||
serverSocket.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Could not close server socket", e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
try {
|
||||
if (serverSocket != null) {
|
||||
serverSocket.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Could not close server socket", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Thread for connecting to a device
|
||||
private class ConnectThread extends Thread {
|
||||
private BluetoothSocket socket;
|
||||
private BluetoothDevice device;
|
||||
|
||||
public ConnectThread(BluetoothDevice device) {
|
||||
this.device = device;
|
||||
|
||||
try {
|
||||
if (checkBluetoothPermission()) {
|
||||
socket = device.createRfcommSocketToServiceRecord(SERVICE_UUID);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Socket create() failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Cancel discovery to save resources
|
||||
if (checkBluetoothPermission() && bluetoothAdapter.isDiscovering()) {
|
||||
bluetoothAdapter.cancelDiscovery();
|
||||
}
|
||||
|
||||
try {
|
||||
if (checkBluetoothPermission()) {
|
||||
socket.connect();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Could not connect to device", e);
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateProgress("Connection failed: " + e.getMessage());
|
||||
Toast.makeText(BluetoothSyncActivity.this, "Connection failed", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException closeException) {
|
||||
Log.e(TAG, "Could not close client socket", closeException);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Connection successful
|
||||
manageConnectedSocket(socket);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
try {
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Could not close client socket", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Thread for managing a connected socket
|
||||
private class ConnectedThread extends Thread {
|
||||
private BluetoothSocket socket;
|
||||
private InputStream inputStream;
|
||||
private OutputStream outputStream;
|
||||
|
||||
public ConnectedThread(BluetoothSocket socket) {
|
||||
this.socket = socket;
|
||||
|
||||
try {
|
||||
inputStream = socket.getInputStream();
|
||||
outputStream = socket.getOutputStream();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error occurred when creating input/output streams", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
byte[] buffer = new byte[1024];
|
||||
int numBytes;
|
||||
|
||||
// Keep listening to the InputStream while connected
|
||||
while (true) {
|
||||
try {
|
||||
numBytes = inputStream.read(buffer);
|
||||
String receivedMessage = new String(buffer, 0, numBytes, "UTF-8");
|
||||
handleReceivedMessage(receivedMessage);
|
||||
} catch (IOException e) {
|
||||
Log.d(TAG, "Input stream was disconnected", e);
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateProgress("Connection lost");
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void write(String message) {
|
||||
try {
|
||||
byte[] bytes = message.getBytes("UTF-8");
|
||||
outputStream.write(bytes);
|
||||
Log.d(TAG, "Sent: " + message);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error occurred when sending data", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Could not close connected socket", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void manageConnectedSocket(BluetoothSocket socket) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateProgress("Connected! Starting sync...");
|
||||
}
|
||||
});
|
||||
|
||||
// Cancel existing threads
|
||||
if (connectThread != null) {
|
||||
connectThread.cancel();
|
||||
connectThread = null;
|
||||
}
|
||||
if (acceptThread != null) {
|
||||
acceptThread.cancel();
|
||||
acceptThread = null;
|
||||
}
|
||||
|
||||
// Start the connected thread
|
||||
connectedThread = new ConnectedThread(socket);
|
||||
connectedThread.start();
|
||||
|
||||
// Start the sync protocol
|
||||
startSyncProtocol();
|
||||
}
|
||||
|
||||
private void handleReceivedMessage(String message) {
|
||||
Log.d(TAG, "Received: " + message);
|
||||
|
||||
String[] parts = message.split("\\|", 2);
|
||||
String command = parts[0];
|
||||
String data = parts.length > 1 ? parts[1] : "";
|
||||
|
||||
switch (command) {
|
||||
case PROTOCOL_HANDSHAKE:
|
||||
handleHandshake(data);
|
||||
break;
|
||||
case PROTOCOL_FILE_LIST:
|
||||
handleFileList(data);
|
||||
break;
|
||||
case PROTOCOL_FILE_REQUEST:
|
||||
handleFileRequest(data);
|
||||
break;
|
||||
case PROTOCOL_FILE_DATA:
|
||||
handleFileData(data);
|
||||
break;
|
||||
case PROTOCOL_SYNC_COMPLETE:
|
||||
handleSyncComplete();
|
||||
break;
|
||||
case PROTOCOL_ERROR:
|
||||
handleError(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void startSyncProtocol() {
|
||||
if (connectedThread != null) {
|
||||
connectedThread.write(PROTOCOL_HANDSHAKE + "|" + android.os.Build.MODEL);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleHandshake(String deviceInfo) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateProgress("Handshake received from " + deviceInfo);
|
||||
}
|
||||
});
|
||||
|
||||
// Send our file list
|
||||
sendFileList();
|
||||
}
|
||||
|
||||
private void sendFileList() {
|
||||
List<NoteManager.NoteInfo> notes = NoteManager.getAllNoteInfo(notesDirectory);
|
||||
StringBuilder fileList = new StringBuilder();
|
||||
|
||||
for (NoteManager.NoteInfo note : notes) {
|
||||
if (fileList.length() > 0) {
|
||||
fileList.append(";");
|
||||
}
|
||||
fileList.append(note.name).append(",")
|
||||
.append(note.lastModified).append(",")
|
||||
.append(note.hash);
|
||||
}
|
||||
|
||||
if (connectedThread != null) {
|
||||
connectedThread.write(PROTOCOL_FILE_LIST + "|" + fileList.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFileList(String fileListData) {
|
||||
// Parse remote file list and determine what files to sync
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateProgress("Comparing files...");
|
||||
}
|
||||
});
|
||||
|
||||
// Simple implementation: request all files that are different
|
||||
// In a full implementation, you'd compare timestamps and hashes
|
||||
String[] files = fileListData.split(";");
|
||||
for (String fileInfo : files) {
|
||||
if (!fileInfo.isEmpty()) {
|
||||
String[] parts = fileInfo.split(",");
|
||||
if (parts.length >= 3) {
|
||||
String fileName = parts[0];
|
||||
long timestamp = Long.parseLong(parts[1]);
|
||||
String hash = parts[2];
|
||||
|
||||
// Check if we need this file
|
||||
NoteManager.NoteInfo localNote = NoteManager.getNoteInfo(notesDirectory, fileName);
|
||||
if (localNote == null || localNote.lastModified < timestamp || !localNote.hash.equals(hash)) {
|
||||
// Request this file
|
||||
if (connectedThread != null) {
|
||||
connectedThread.write(PROTOCOL_FILE_REQUEST + "|" + fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send sync complete when done
|
||||
mainHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (connectedThread != null) {
|
||||
connectedThread.write(PROTOCOL_SYNC_COMPLETE + "|");
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private void handleFileRequest(String fileName) {
|
||||
String content = NoteManager.loadNote(notesDirectory, fileName);
|
||||
if (content != null) {
|
||||
if (connectedThread != null) {
|
||||
connectedThread.write(PROTOCOL_FILE_DATA + "|" + fileName + ":" + content);
|
||||
}
|
||||
} else {
|
||||
if (connectedThread != null) {
|
||||
connectedThread.write(PROTOCOL_ERROR + "|File not found: " + fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFileData(String fileData) {
|
||||
int colonIndex = fileData.indexOf(':');
|
||||
if (colonIndex > 0) {
|
||||
String fileName = fileData.substring(0, colonIndex);
|
||||
String content = fileData.substring(colonIndex + 1);
|
||||
|
||||
boolean saved = NoteManager.saveNote(notesDirectory, fileName, content);
|
||||
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (saved) {
|
||||
updateProgress("Received file: " + fileName);
|
||||
} else {
|
||||
updateProgress("Failed to save: " + fileName);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSyncComplete() {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateProgress("Sync completed successfully!");
|
||||
Toast.makeText(BluetoothSyncActivity.this, "Sync completed!", Toast.LENGTH_LONG).show();
|
||||
|
||||
// Close connection after a delay
|
||||
mainHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finish();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void handleError(String error) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateProgress("Error: " + error);
|
||||
Toast.makeText(BluetoothSyncActivity.this, "Sync error: " + error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (requestCode == REQUEST_DISCOVERABLE) {
|
||||
if (resultCode > 0) {
|
||||
updateStatus("Device is discoverable for " + resultCode + " seconds");
|
||||
updateProgress("Waiting for incoming connections...");
|
||||
} else {
|
||||
updateStatus("Discoverable request denied");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
// Clean up threads
|
||||
if (connectThread != null) {
|
||||
connectThread.cancel();
|
||||
}
|
||||
if (connectedThread != null) {
|
||||
connectedThread.cancel();
|
||||
}
|
||||
if (acceptThread != null) {
|
||||
acceptThread.cancel();
|
||||
}
|
||||
|
||||
// Unregister broadcast receiver
|
||||
try {
|
||||
unregisterReceiver(discoveryReceiver);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Receiver was not registered
|
||||
}
|
||||
|
||||
// Stop discovery
|
||||
if (bluetoothAdapter != null && checkBluetoothPermission() && bluetoothAdapter.isDiscovering()) {
|
||||
bluetoothAdapter.cancelDiscovery();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
package org.eu.octt.notetand;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@@ -22,33 +22,14 @@ public class MainActivity extends CustomActivity {
|
||||
NoteManager.setup(this);
|
||||
|
||||
listNotes = findViewById(R.id.list_notes);
|
||||
// var notesList = NoteManager.getAllNoteNames(); // new ArrayList<String>();
|
||||
// var notesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, notesList);
|
||||
// listNotes.setAdapter(notesAdapter);
|
||||
|
||||
// // Use Android/data/packagename/files/notes structure
|
||||
// var notesDirectory = new File(getExternalFilesDir(null), "notes");
|
||||
// if (!notesDirectory.exists()) {
|
||||
// notesDirectory.mkdirs();
|
||||
// }
|
||||
|
||||
// for (var file : notesDirectory.listFiles()) {
|
||||
// for (var file : NoteManager.notesDirectory.listFiles()) {
|
||||
// if (file.isFile() && file.getName().toLowerCase().endsWith(".txt")) {
|
||||
// notesList.add(file.getName());
|
||||
// }
|
||||
// }
|
||||
// notesAdapter.notifyDataSetChanged();
|
||||
|
||||
listNotes.setOnItemClickListener((parent, view, position, id) ->
|
||||
launchNote(notesList.get(position), false));
|
||||
listNotes.setOnItemClickListener((parent, view, position, id) -> launchNote(notesList.get(position), false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
notesList = NoteManager.getAllNoteNames(); // new ArrayList<String>();
|
||||
notesList = NoteManager.getAllNoteNames();
|
||||
var notesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, notesList);
|
||||
listNotes.setAdapter(notesAdapter);
|
||||
notesAdapter.notifyDataSetChanged();
|
||||
|
@@ -1,380 +0,0 @@
|
||||
package org.eu.octt.notetand;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MainActivity1 extends Activity {
|
||||
|
||||
private static final int REQUEST_ENABLE_BT = 1001;
|
||||
private static final int REQUEST_PERMISSIONS = 1002;
|
||||
private static final int REQUEST_BLUETOOTH_PERMISSIONS = 1003;
|
||||
|
||||
private ListView listNotes;
|
||||
private TextView txtStatus;
|
||||
private TextView txtNoteCount;
|
||||
private Button btnSync;
|
||||
private Button btnAddNote;
|
||||
|
||||
private ArrayList<String> notesList;
|
||||
private ArrayAdapter<String> notesAdapter;
|
||||
private File notesDirectory;
|
||||
private BluetoothAdapter bluetoothAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main_activity_1);
|
||||
|
||||
initializeViews();
|
||||
setupNotesDirectory();
|
||||
checkPermissions();
|
||||
initializeBluetooth();
|
||||
loadNotes();
|
||||
setupListeners();
|
||||
}
|
||||
|
||||
private void initializeViews() {
|
||||
listNotes = findViewById(R.id.list_notes);
|
||||
txtStatus = findViewById(R.id.txt_status);
|
||||
txtNoteCount = findViewById(R.id.txt_note_count);
|
||||
btnSync = findViewById(R.id.btn_sync);
|
||||
btnAddNote = findViewById(R.id.btn_add_note);
|
||||
|
||||
notesList = new ArrayList<>();
|
||||
notesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, notesList);
|
||||
listNotes.setAdapter(notesAdapter);
|
||||
|
||||
// Register context menu for long press
|
||||
registerForContextMenu(listNotes);
|
||||
}
|
||||
|
||||
private void setupNotesDirectory() {
|
||||
// Use Android/data/packagename/files/notes structure
|
||||
File externalFilesDir = getExternalFilesDir(null);
|
||||
if (externalFilesDir != null) {
|
||||
notesDirectory = new File(externalFilesDir, "notes");
|
||||
if (!notesDirectory.exists()) {
|
||||
boolean created = notesDirectory.mkdirs();
|
||||
if (created) {
|
||||
updateStatus("Notes directory created");
|
||||
} else {
|
||||
updateStatus("Failed to create notes directory");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Fallback to internal storage
|
||||
notesDirectory = new File(getFilesDir(), "notes");
|
||||
if (!notesDirectory.exists()) {
|
||||
notesDirectory.mkdirs();
|
||||
}
|
||||
updateStatus("Using internal storage");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
ArrayList<String> permissionsNeeded = new ArrayList<>();
|
||||
|
||||
// Storage permissions (for API < 30)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
permissionsNeeded.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||
}
|
||||
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
permissionsNeeded.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
}
|
||||
|
||||
// Location permission for Bluetooth scanning
|
||||
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
permissionsNeeded.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
}
|
||||
|
||||
if (!permissionsNeeded.isEmpty()) {
|
||||
requestPermissions(permissionsNeeded.toArray(new String[0]), REQUEST_PERMISSIONS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeBluetooth() {
|
||||
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
if (bluetoothAdapter == null) {
|
||||
updateStatus("Bluetooth not supported");
|
||||
btnSync.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bluetoothAdapter.isEnabled()) {
|
||||
updateStatus("Bluetooth disabled");
|
||||
btnSync.setText("Enable BT");
|
||||
} else {
|
||||
updateStatus("Bluetooth ready");
|
||||
btnSync.setText("Sync");
|
||||
}
|
||||
}
|
||||
|
||||
private void loadNotes() {
|
||||
notesList.clear();
|
||||
|
||||
if (notesDirectory != null && notesDirectory.exists()) {
|
||||
File[] files = notesDirectory.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isFile() && file.getName().endsWith(".txt")) {
|
||||
String noteName = file.getName().replace(".txt", "");
|
||||
notesList.add(noteName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notesAdapter.notifyDataSetChanged();
|
||||
updateNoteCount();
|
||||
|
||||
if (notesList.isEmpty()) {
|
||||
updateStatus("No notes found. Tap + to create one.");
|
||||
} else {
|
||||
updateStatus("Loaded " + notesList.size() + " notes");
|
||||
}
|
||||
}
|
||||
|
||||
private void setupListeners() {
|
||||
btnAddNote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createNewNote();
|
||||
}
|
||||
});
|
||||
|
||||
btnSync.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
handleSyncButtonClick();
|
||||
}
|
||||
});
|
||||
|
||||
listNotes.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
String noteName = notesList.get(position);
|
||||
openNote(noteName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
if (v.getId() == R.id.list_notes) {
|
||||
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
|
||||
String noteName = notesList.get(info.position);
|
||||
menu.setHeaderTitle(noteName);
|
||||
menu.add(0, 1, 0, "Open");
|
||||
menu.add(0, 2, 0, "Delete");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||
final String noteName = notesList.get(info.position);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case 1: // Open
|
||||
openNote(noteName);
|
||||
return true;
|
||||
case 2: // Delete
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Delete Note")
|
||||
.setMessage("Are you sure you want to delete '" + noteName + "'?")
|
||||
.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
deleteNote(noteName);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Cancel", null)
|
||||
.show();
|
||||
return true;
|
||||
default:
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void createNewNote() {
|
||||
// For now, create a simple numbered note
|
||||
String newNoteName = "Note_" + System.currentTimeMillis();
|
||||
Intent intent = new Intent(this, NoteActivity.class);
|
||||
intent.putExtra("note_name", newNoteName);
|
||||
intent.putExtra("is_new", true);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void openNote(String noteName) {
|
||||
Intent intent = new Intent(this, NoteActivity.class);
|
||||
intent.putExtra("note_name", noteName);
|
||||
intent.putExtra("is_new", false);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void deleteNote(String noteName) {
|
||||
File noteFile = new File(notesDirectory, noteName + ".txt");
|
||||
if (noteFile.exists()) {
|
||||
boolean deleted = noteFile.delete();
|
||||
if (deleted) {
|
||||
updateStatus("Note deleted: " + noteName);
|
||||
loadNotes();
|
||||
} else {
|
||||
updateStatus("Failed to delete note");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSyncButtonClick() {
|
||||
if (bluetoothAdapter == null) {
|
||||
Toast.makeText(this, "Bluetooth not supported", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bluetoothAdapter.isEnabled()) {
|
||||
// Request to enable Bluetooth
|
||||
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
||||
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
|
||||
} else {
|
||||
// Check Bluetooth permissions for newer Android versions
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
checkBluetoothPermissions();
|
||||
} else {
|
||||
startBluetoothSync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBluetoothPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
ArrayList<String> permissionsNeeded = new ArrayList<>();
|
||||
|
||||
if (checkSelfPermission(Manifest.permission.BLUETOOTH_SCAN)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
permissionsNeeded.add(Manifest.permission.BLUETOOTH_SCAN);
|
||||
}
|
||||
if (checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
permissionsNeeded.add(Manifest.permission.BLUETOOTH_CONNECT);
|
||||
}
|
||||
if (checkSelfPermission(Manifest.permission.BLUETOOTH_ADVERTISE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
permissionsNeeded.add(Manifest.permission.BLUETOOTH_ADVERTISE);
|
||||
}
|
||||
|
||||
if (!permissionsNeeded.isEmpty()) {
|
||||
requestPermissions(permissionsNeeded.toArray(new String[0]),
|
||||
REQUEST_BLUETOOTH_PERMISSIONS);
|
||||
} else {
|
||||
startBluetoothSync();
|
||||
}
|
||||
} else {
|
||||
startBluetoothSync();
|
||||
}
|
||||
}
|
||||
|
||||
private void startBluetoothSync() {
|
||||
Intent intent = new Intent(this, BluetoothSyncActivity.class);
|
||||
intent.putExtra("notes_directory", notesDirectory.getAbsolutePath());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (requestCode == REQUEST_ENABLE_BT) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
updateStatus("Bluetooth enabled");
|
||||
btnSync.setText("Sync");
|
||||
} else {
|
||||
updateStatus("Bluetooth enable cancelled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
switch (requestCode) {
|
||||
case REQUEST_PERMISSIONS:
|
||||
boolean allGranted = true;
|
||||
for (int result : grantResults) {
|
||||
if (result != PackageManager.PERMISSION_GRANTED) {
|
||||
allGranted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allGranted) {
|
||||
updateStatus("Permissions granted");
|
||||
} else {
|
||||
updateStatus("Some permissions denied");
|
||||
}
|
||||
break;
|
||||
|
||||
case REQUEST_BLUETOOTH_PERMISSIONS:
|
||||
boolean bluetoothGranted = true;
|
||||
for (int result : grantResults) {
|
||||
if (result != PackageManager.PERMISSION_GRANTED) {
|
||||
bluetoothGranted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bluetoothGranted) {
|
||||
startBluetoothSync();
|
||||
} else {
|
||||
Toast.makeText(this, "Bluetooth permissions required for sync",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
loadNotes(); // Refresh notes list when returning from editor
|
||||
}
|
||||
|
||||
private void updateStatus(String status) {
|
||||
txtStatus.setText(status);
|
||||
}
|
||||
|
||||
private void updateNoteCount() {
|
||||
int count = notesList.size();
|
||||
txtNoteCount.setText(count + (count == 1 ? " note" : " notes"));
|
||||
}
|
||||
|
||||
public File getNotesDirectory() {
|
||||
return notesDirectory;
|
||||
}
|
||||
}
|
@@ -1,11 +1,13 @@
|
||||
package org.eu.octt.notetand;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
@@ -17,7 +19,6 @@ import android.widget.Toast;
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
public class NoteActivity extends CustomActivity {
|
||||
@@ -26,8 +27,6 @@ public class NoteActivity extends CustomActivity {
|
||||
private EditText editNoteName;
|
||||
private EditText editNoteContent;
|
||||
private TextView txtNoteInfo;
|
||||
// private Button btnSave;
|
||||
// private Button btnDelete;
|
||||
|
||||
private String originalNoteName;
|
||||
private String originalContent;
|
||||
@@ -54,8 +53,45 @@ public class NoteActivity extends CustomActivity {
|
||||
editNoteName = findViewById(R.id.edit_note_name);
|
||||
editNoteContent = findViewById(R.id.edit_note_content);
|
||||
txtNoteInfo = findViewById(R.id.txt_note_info);
|
||||
// btnSave = findViewById(R.id.btn_save);
|
||||
// btnDelete = findViewById(R.id.btn_delete);
|
||||
|
||||
var fontSize = SettingsManager.getFontSize();
|
||||
if (fontSize > 0)
|
||||
editNoteContent.setTextSize(fontSize);
|
||||
|
||||
Integer flag = null;
|
||||
var contentFlags = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
||||
switch (SettingsManager.getKeyboardMode()) {
|
||||
case "normal":
|
||||
editNoteContent.setInputType(contentFlags);
|
||||
break;
|
||||
case "no_suggestions":
|
||||
flag = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
||||
break;
|
||||
case "privacy":
|
||||
flag = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
|
||||
break;
|
||||
}
|
||||
if (flag != null) {
|
||||
editNoteContent.setInputType(contentFlags | flag);
|
||||
editNoteName.setInputType(InputType.TYPE_CLASS_TEXT | flag);
|
||||
}
|
||||
|
||||
Typeface typeface = null;
|
||||
switch (SettingsManager.getFontType()) {
|
||||
case "sans_serif":
|
||||
typeface = Typeface.SANS_SERIF;
|
||||
break;
|
||||
case "serif":
|
||||
typeface = Typeface.SERIF;
|
||||
break;
|
||||
case "monospace":
|
||||
typeface = Typeface.MONOSPACE;
|
||||
break;
|
||||
}
|
||||
if (typeface != null) {
|
||||
editNoteContent.setTypeface(typeface);
|
||||
editNoteName.setTypeface(typeface);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupNotesDirectory() {
|
||||
@@ -68,6 +104,7 @@ public class NoteActivity extends CustomActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private void loadNoteFromIntent() {
|
||||
Intent intent = getIntent();
|
||||
|
||||
@@ -80,7 +117,6 @@ public class NoteActivity extends CustomActivity {
|
||||
}
|
||||
|
||||
if (originalNoteName == null) {
|
||||
// originalNoteName = "Note_" + System.currentTimeMillis() + ".txt";
|
||||
originalNoteName = (new SimpleDateFormat("yyyy-MM-dd HH-mm-ss.SSS")).format(new Date()) + ' ' + EMOJIS[(new Random()).nextInt(EMOJIS.length)] + ".txt";
|
||||
isNewNote = true;
|
||||
}
|
||||
@@ -98,13 +134,7 @@ public class NoteActivity extends CustomActivity {
|
||||
originalContent = "";
|
||||
Toast.makeText(this, "Error loading note", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
// btnDelete.setVisibility(View.VISIBLE);
|
||||
//} else if (originalNoteName == null && originalContent == null) {
|
||||
// originalContent = intent.getStringExtra("content");
|
||||
} // else {
|
||||
// originalContent = "";
|
||||
// // btnDelete.setVisibility(View.GONE);
|
||||
// }
|
||||
}
|
||||
|
||||
if (originalContent == null) {
|
||||
originalContent = "";
|
||||
@@ -116,10 +146,6 @@ public class NoteActivity extends CustomActivity {
|
||||
}
|
||||
|
||||
private void setupListeners() {
|
||||
// btnSave.setOnClickListener(v -> saveNote());
|
||||
//
|
||||
// btnDelete.setOnClickListener(v -> confirmDeleteNote());
|
||||
|
||||
// Track changes to note name
|
||||
editNoteName.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
@@ -157,13 +183,7 @@ public class NoteActivity extends CustomActivity {
|
||||
hasUnsavedChanges = !currentName.equals(originalNoteName) || !currentContent.equals(originalContent);
|
||||
|
||||
// Update title to indicate unsaved changes
|
||||
//if (getActionBar() != null) {
|
||||
if (hasUnsavedChanges) {
|
||||
/*getActionBar().*/setTitle("* " + getString(R.string.note) /* currentName */);
|
||||
} else {
|
||||
/*getActionBar().*/setTitle(getString(R.string.note) /* currentName */);
|
||||
}
|
||||
//}
|
||||
setTitle((hasUnsavedChanges ? "* " : "") + getString(R.string.note));
|
||||
}
|
||||
|
||||
private void updateNoteInfo() {
|
||||
@@ -175,13 +195,12 @@ public class NoteActivity extends CustomActivity {
|
||||
if (isNewNote && !hasUnsavedChanges) {
|
||||
txtNoteInfo.setText(R.string.new_note);
|
||||
} else {
|
||||
txtNoteInfo.setText(String.format(Locale.getDefault(), "%d chars, %d words, %d lines", characterCount, wordCount, lineCount));
|
||||
txtNoteInfo.setText(getString(R.string.note_info_bar, characterCount, wordCount, lineCount));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveNote() {
|
||||
String noteName = editNoteName.getText().toString().trim();
|
||||
// String content = editNoteContent.getText().toString();
|
||||
|
||||
// Validate note name
|
||||
if (noteName.isEmpty()) {
|
||||
@@ -228,12 +247,8 @@ public class NoteActivity extends CustomActivity {
|
||||
originalContent = content;
|
||||
isNewNote = false;
|
||||
hasUnsavedChanges = false;
|
||||
// btnDelete.setVisibility(View.VISIBLE);
|
||||
|
||||
//if (getActionBar() != null) {
|
||||
/*getActionBar().*/setTitle(getString(R.string.note) /* noteName */);
|
||||
//}
|
||||
|
||||
setTitle(getString(R.string.note));
|
||||
Toast.makeText(this, R.string.note_saved, Toast.LENGTH_SHORT).show();
|
||||
updateNoteInfo();
|
||||
} else {
|
||||
@@ -291,17 +306,6 @@ public class NoteActivity extends CustomActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// switch (item.getItemId()) {
|
||||
// case android.R.id.home:
|
||||
// onBackPressed();
|
||||
// return true;
|
||||
// default:
|
||||
// return super.onOptionsItemSelected(item);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (hasUnsavedChanges) {
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package org.eu.octt.notetand;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothServerSocket;
|
||||
import android.bluetooth.BluetoothSocket;
|
||||
@@ -14,7 +12,6 @@ import android.widget.Toast;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ReceiveActivity extends CustomActivity {
|
||||
@@ -82,32 +79,15 @@ public class ReceiveActivity extends CustomActivity {
|
||||
writeStatus("Waiting for new client connection...");
|
||||
socket = server.accept();
|
||||
|
||||
// if (!socket.isConnected()) return;
|
||||
|
||||
var client = socket.getRemoteDevice();
|
||||
// textStatus.append("Connected to client!\n");
|
||||
// textStatus.append("Connected: " + client.getName() + " : " + client.getAddress() + '\n');
|
||||
writeStatus("Connected: " + client.getName() + " : " + NoteTand.censorMac(client.getAddress()));
|
||||
|
||||
// byte[] buffer = new byte[1024];
|
||||
// int bytes;
|
||||
//
|
||||
// while ((bytes = socket.getInputStream().read(buffer)) != -1) {
|
||||
// var received = new String(buffer, 0, bytes);
|
||||
//
|
||||
// // runOnUiThread(() -> Toast.makeText(this, "Received: " + received, Toast.LENGTH_SHORT).show());
|
||||
// // textStatus.append(received + '\n');
|
||||
// writeStatus("Receiving data...");
|
||||
// writeStatus("> " + received);
|
||||
// }
|
||||
|
||||
writeStatus("Reading data...");
|
||||
|
||||
var titleLength = ByteBuffer.wrap(readFully(4)).getInt(); // ByteBuffer.wrap(intBuffer).order(ByteOrder.BIG_ENDIAN).getInt(); // or LITTLE_ENDIAN
|
||||
var titleLength = ByteBuffer.wrap(readFully(4)).getInt();
|
||||
var titleBytes = readFully(titleLength);
|
||||
var noteTitle = new String(titleBytes, "UTF-8");
|
||||
|
||||
var bodyLength = ByteBuffer.wrap(readFully(4)).getInt(); // ByteBuffer.wrap(intBuffer).order(ByteOrder.BIG_ENDIAN).getInt();
|
||||
var bodyLength = ByteBuffer.wrap(readFully(4)).getInt();
|
||||
var bodyBytes = readFully(bodyLength);
|
||||
var noteBody = new String(bodyBytes, "UTF-8");
|
||||
|
||||
@@ -117,8 +97,6 @@ public class ReceiveActivity extends CustomActivity {
|
||||
} else {
|
||||
writeStatus("Content length mismatch! Expected " + titleLength + " + " + bodyLength + ", got " + titleBytes.length + " + " + bodyBytes.length);
|
||||
}
|
||||
|
||||
// writeStatus("Finished receiving!");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (!stopped) {
|
||||
@@ -150,7 +128,7 @@ public class ReceiveActivity extends CustomActivity {
|
||||
runOnUiThread(() -> textStatus.append(text + '\n'));
|
||||
}
|
||||
|
||||
byte[] readFully(/* InputStream in, byte[] buffer, */ int length) throws IOException {
|
||||
byte[] readFully(int length) throws IOException {
|
||||
byte[] buffer = new byte[length];
|
||||
int offset = 0;
|
||||
while (offset < length) {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package org.eu.octt.notetand;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
@@ -16,10 +15,7 @@ import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class SendActivity extends CustomActivity {
|
||||
BluetoothSocket socket;
|
||||
@@ -87,16 +83,13 @@ public class SendActivity extends CustomActivity {
|
||||
listPairedDevices.setOnItemClickListener((parent, view, position, id) -> {
|
||||
statusLog = "";
|
||||
dialog = new AlertDialog.Builder(this)
|
||||
.setTitle("Sending Note")
|
||||
.setTitle(R.string.sending_note)
|
||||
.setMessage("Preparing...")
|
||||
// .setNegativeButton("Abort", null)
|
||||
.setNeutralButton("Close", null)
|
||||
.setNeutralButton(R.string.close, null)
|
||||
.show();
|
||||
//.create();
|
||||
setDialogCancelable(false);
|
||||
//dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setEnabled(false);
|
||||
//dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setVisibility(ListView.GONE);
|
||||
//dialog.show();
|
||||
|
||||
var device = pairedDevicesList.get(position);
|
||||
new Thread(() -> {
|
||||
try {
|
||||
@@ -124,16 +117,13 @@ public class SendActivity extends CustomActivity {
|
||||
output.write(contentBytes);
|
||||
|
||||
writeStatus("Note sent!");
|
||||
//dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setVisibility(ListView.VISIBLE);
|
||||
//dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setEnabled(true);
|
||||
//dialog.setCancelable(true);
|
||||
setDialogCancelable(true);
|
||||
|
||||
socket.getInputStream().close();
|
||||
socket.getOutputStream().close();
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
Log.e("Bluetooth", "Connection failed", e);
|
||||
writeStatus(e.getMessage());
|
||||
setDialogCancelable(true);
|
||||
@@ -162,7 +152,6 @@ public class SendActivity extends CustomActivity {
|
||||
|
||||
void setDialogCancelable(boolean status) {
|
||||
runOnUiThread(() -> {
|
||||
//dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setVisibility(ListView.VISIBLE);
|
||||
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setEnabled(status);
|
||||
dialog.setCancelable(status);
|
||||
});
|
||||
|
@@ -1,15 +1,18 @@
|
||||
package org.eu.octt.notetand;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
@@ -19,35 +22,29 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SettingsActivity extends CustomActivity {
|
||||
// @Override
|
||||
// protected void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// // getFragmentManager().beginTransaction().add(new SettingsFragment(), "").commit();
|
||||
// // addPreferencesFromResource(R.xml.preferences);
|
||||
//
|
||||
// }
|
||||
|
||||
// class SettingsFragment extends Fragment {
|
||||
//
|
||||
// }
|
||||
|
||||
private ListView listView;
|
||||
private ArrayList<View> settingViews = new ArrayList<>();
|
||||
private final ArrayList<View> settingViews = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
listView = new ListView(this);
|
||||
var listView = new ListView(this);
|
||||
|
||||
settingViews.add(createCheckboxSetting(getString(R.string.censor_mac), "censor_mac", true));
|
||||
// autosave
|
||||
// default_location
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
settingViews.add(createSpinnerSetting(getString(R.string.app_theme), "theme", new String[]{"system", "material_dark", "material_light", "holo_dark", "holo_light"}, "system"));
|
||||
settingViews.add(createSpinnerSetting(getString(R.string.app_theme), "theme", SettingsManager.THEMES_FULL));
|
||||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
settingViews.add(createSpinnerSetting(getString(R.string.app_theme), "theme", new String[]{"system", "holo_dark", "holo_light"}, "system"));
|
||||
settingViews.add(createSpinnerSetting(getString(R.string.app_theme), "theme", SettingsManager.THEMES_LEGACY));
|
||||
|
||||
// settingViews.add(createNumberSetting(getString(R.string.font_size), "font_size"));
|
||||
settingViews.add(createNumberSetting(getString(R.string.font_size), "font_size", 0, 1));
|
||||
|
||||
settingViews.add(createSpinnerSetting(getString(R.string.font_type), "font_type", SettingsManager.FONT_TYPES));
|
||||
|
||||
settingViews.add(createSpinnerSetting(getString(R.string.keyboard_mode), "keyboard_mode", SettingsManager.KEYBOARD_MODES));
|
||||
|
||||
settingViews.add(createCheckboxSetting(getString(R.string.censor_mac), "censor_mac", true));
|
||||
|
||||
// Adapter to wrap views into ListView
|
||||
listView.setAdapter(new BaseAdapter() {
|
||||
@@ -76,41 +73,79 @@ public class SettingsActivity extends CustomActivity {
|
||||
}
|
||||
|
||||
private View createCheckboxSetting(String label, String key, boolean defaultValue) {
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
layout.setPadding(32, 32, 32, 32);
|
||||
var layout = createLayout(LinearLayout.HORIZONTAL);
|
||||
|
||||
TextView textView = new TextView(this);
|
||||
var textView = new TextView(this);
|
||||
textView.setText(label);
|
||||
textView.setTextSize(16);
|
||||
// textView.setTextSize(16);
|
||||
textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
|
||||
|
||||
CheckBox checkBox = new CheckBox(this);
|
||||
var checkBox = new CheckBox(this);
|
||||
checkBox.setChecked(SettingsManager.prefs.getBoolean(key, defaultValue));
|
||||
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
SettingsManager.prefs.edit().putBoolean(key, isChecked).apply();
|
||||
});
|
||||
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> SettingsManager.prefs.edit().putBoolean(key, isChecked).apply());
|
||||
|
||||
layout.addView(textView);
|
||||
layout.addView(checkBox);
|
||||
return layout;
|
||||
}
|
||||
|
||||
private View createSpinnerSetting(String label, String key, String[] options, String defaultValue) {
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
layout.setPadding(32, 32, 32, 32);
|
||||
private View createNumberSetting(String label, String key, int defaultValue, int min) {
|
||||
var layout = createLayout(LinearLayout.HORIZONTAL);
|
||||
|
||||
TextView textView = new TextView(this);
|
||||
var textView = new TextView(this);
|
||||
textView.setText(label);
|
||||
textView.setTextSize(16);
|
||||
// textView.setTextSize(16);
|
||||
textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
|
||||
|
||||
Spinner spinner = new Spinner(this);
|
||||
var editNumber = new EditText(this);
|
||||
editNumber.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
editNumber.setFilters(new InputFilter[]{(source, start, end, dest, dstart, dend) -> {
|
||||
try {
|
||||
String input = dest.toString() + source.toString();
|
||||
int value = Integer.parseInt(input);
|
||||
if (value >= min) {
|
||||
return null; // Accept the input
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
// Ignore invalid input
|
||||
}
|
||||
return ""; // Reject the input
|
||||
}});
|
||||
var number = SettingsManager.prefs.getInt(key, defaultValue);
|
||||
if (number >= min)
|
||||
editNumber.setText(String.valueOf(number));
|
||||
editNumber.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
var text = s.toString();
|
||||
SettingsManager.prefs.edit().putInt(key, !text.isEmpty() ? Integer.parseInt(text) : 0).apply();
|
||||
}
|
||||
});
|
||||
|
||||
layout.addView(textView);
|
||||
layout.addView(editNumber);
|
||||
return layout;
|
||||
}
|
||||
|
||||
private View createSpinnerSetting(String label, String key, String[] options) {
|
||||
var layout = createLayout(LinearLayout.VERTICAL);
|
||||
|
||||
var textView = new TextView(this);
|
||||
textView.setText(label);
|
||||
// textView.setTextSize(16);
|
||||
|
||||
var spinner = new Spinner(this);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, options);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spinner.setAdapter(adapter);
|
||||
|
||||
String currentValue = SettingsManager.prefs.getString(key, defaultValue);
|
||||
var currentValue = SettingsManager.prefs.getString(key, options[0]);
|
||||
int selectedIndex = Arrays.asList(options).indexOf(currentValue);
|
||||
spinner.setSelection(Math.max(selectedIndex, 0));
|
||||
|
||||
@@ -125,4 +160,11 @@ public class SettingsActivity extends CustomActivity {
|
||||
layout.addView(spinner);
|
||||
return layout;
|
||||
}
|
||||
|
||||
private LinearLayout createLayout(int orientation) {
|
||||
var layout = new LinearLayout(this);
|
||||
layout.setOrientation(orientation);
|
||||
layout.setPadding(16, 16, 16, 16);
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,11 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class SettingsManager {
|
||||
static final String[] THEMES_FULL = {"system", "material_dark", "material_light", "holo_dark", "holo_light"};
|
||||
static final String[] THEMES_LEGACY = {"system", "holo_dark", "holo_light"};
|
||||
static final String[] FONT_TYPES = {"default", "sans_serif", "serif", "monospace"};
|
||||
static final String[] KEYBOARD_MODES = {"autocorrect", "normal", "no_suggestions", "privacy"};
|
||||
|
||||
static SharedPreferences prefs;
|
||||
|
||||
static void setup(Context context) {
|
||||
@@ -18,6 +23,18 @@ public class SettingsManager {
|
||||
}
|
||||
|
||||
static String getTheme() {
|
||||
return prefs.getString("theme", "system");
|
||||
return prefs.getString("theme", THEMES_FULL[0]);
|
||||
}
|
||||
|
||||
static int getFontSize() {
|
||||
return prefs.getInt("font_size", 0);
|
||||
}
|
||||
|
||||
static String getFontType() {
|
||||
return prefs.getString("font_type", FONT_TYPES[0]);
|
||||
}
|
||||
|
||||
static String getKeyboardMode() {
|
||||
return prefs.getString("keyboard_mode", KEYBOARD_MODES[0]);
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
@@ -1,170 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
@@ -4,7 +4,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Header with note name and buttons -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -16,32 +15,26 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
android:hint="@string/note_name"
|
||||
android:inputType="text"
|
||||
android:textStyle="bold"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext" />
|
||||
|
||||
<!-- <Button
|
||||
android:id="@+id/btn_save"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Save" /> -->
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Note content editor -->
|
||||
<EditText
|
||||
android:id="@+id/edit_note_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
android:hint="@string/note_typing_hint"
|
||||
android:gravity="start|top"
|
||||
android:inputType="textMultiLine"
|
||||
android:inputType="text|textAutoCorrect|textMultiLine"
|
||||
android:scrollbars="vertical"
|
||||
android:fadeScrollbars="false" />
|
||||
|
||||
<!-- Footer with info and actions -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -55,14 +48,6 @@
|
||||
android:layout_weight="1"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666" />
|
||||
|
||||
<!-- <Button
|
||||
android:id="@+id/btn_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Delete"
|
||||
android:visibility="gone" /> -->
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@@ -8,6 +8,6 @@
|
||||
android:id="@+id/text_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="monospace" />
|
||||
android:typeface="monospace" />
|
||||
|
||||
</LinearLayout>
|
@@ -1,152 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<!-- Header -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Bluetooth Sync"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#333333"
|
||||
android:paddingBottom="16dp" />
|
||||
|
||||
<!-- Status Section -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="#F5F5F5"
|
||||
android:padding="12dp"
|
||||
android:layout_marginBottom="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Status"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#333333"
|
||||
android:paddingBottom="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_bluetooth_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Initializing..."
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_sync_progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666"
|
||||
android:paddingTop="4dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="16dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_make_discoverable"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Make Discoverable"
|
||||
android:background="@android:drawable/btn_default"
|
||||
android:textColor="#333333"
|
||||
android:layout_marginEnd="8dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_scan_devices"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Scan for Devices"
|
||||
android:background="@android:drawable/btn_default"
|
||||
android:textColor="#333333" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Devices Section -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Available Devices"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#333333"
|
||||
android:paddingBottom="8dp" />
|
||||
|
||||
<!-- Paired Devices -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Paired Devices:"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#666666"
|
||||
android:paddingBottom="4dp" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list_paired_devices"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="80dp"
|
||||
android:maxHeight="120dp"
|
||||
android:background="#FAFAFA"
|
||||
android:divider="#E0E0E0"
|
||||
android:dividerHeight="1dp"
|
||||
android:layout_marginBottom="12dp" />
|
||||
|
||||
<!-- Discovered Devices -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Discovered Devices:"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#666666"
|
||||
android:paddingBottom="4dp" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list_discovered_devices"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="#FAFAFA"
|
||||
android:divider="#E0E0E0"
|
||||
android:dividerHeight="1dp" />
|
||||
|
||||
<!-- Bottom Actions -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:gravity="center">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_cancel_sync"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Cancel"
|
||||
android:background="@android:drawable/btn_default"
|
||||
android:textColor="#333333"
|
||||
android:minWidth="100dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@@ -1,84 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<!-- Header with title and buttons -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="My Notes"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#333333" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_sync"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sync"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@android:drawable/btn_default"
|
||||
android:textColor="#333333"
|
||||
android:minWidth="80dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_add_note"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="+"
|
||||
android:textSize="20sp"
|
||||
android:background="@android:drawable/btn_default"
|
||||
android:textColor="#333333"
|
||||
android:minWidth="50dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Notes List -->
|
||||
<ListView
|
||||
android:id="@+id/list_notes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:divider="#E0E0E0"
|
||||
android:dividerHeight="1dp"
|
||||
android:background="#FAFAFA" />
|
||||
|
||||
<!-- Status Bar -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_status"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Ready"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_note_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0 notes"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@@ -1,26 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_new"
|
||||
android:icon="@android:drawable/ic_menu_add"
|
||||
android:title="@string/new_note"
|
||||
android:showAsAction="ifRoom" />
|
||||
android:showAsAction="ifRoom"
|
||||
tools:targetApi="honeycomb" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_receive"
|
||||
android:icon="@android:drawable/ic_menu_set_as"
|
||||
android:title="@string/receive_notes"
|
||||
android:showAsAction="ifRoom" />
|
||||
android:showAsAction="ifRoom"
|
||||
tools:targetApi="honeycomb" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:icon="@android:drawable/ic_menu_preferences"
|
||||
android:title="@string/settings"
|
||||
android:showAsAction="never" />
|
||||
android:showAsAction="never"
|
||||
tools:targetApi="honeycomb" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_about"
|
||||
android:icon="@android:drawable/ic_menu_info_details"
|
||||
android:title="@string/about"
|
||||
android:showAsAction="never" />
|
||||
android:showAsAction="never"
|
||||
tools:targetApi="honeycomb" />
|
||||
</menu>
|
@@ -1,26 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_save"
|
||||
android:icon="@android:drawable/ic_menu_save"
|
||||
android:title="@string/save"
|
||||
android:showAsAction="ifRoom" />
|
||||
android:showAsAction="ifRoom"
|
||||
tools:targetApi="honeycomb" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_send"
|
||||
android:icon="@android:drawable/ic_menu_send"
|
||||
android:title="@string/send"
|
||||
android:showAsAction="ifRoom" />
|
||||
android:showAsAction="ifRoom"
|
||||
tools:targetApi="honeycomb" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:icon="@android:drawable/ic_menu_share"
|
||||
android:title="@string/share_externally"
|
||||
android:showAsAction="never" />
|
||||
android:showAsAction="never"
|
||||
tools:targetApi="honeycomb" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_delete"
|
||||
android:icon="@android:drawable/ic_menu_delete"
|
||||
android:title="@string/delete"
|
||||
android:showAsAction="never" />
|
||||
android:showAsAction="never"
|
||||
tools:targetApi="honeycomb" />
|
||||
</menu>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 5.1 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 5.5 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 5.1 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.1 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 3.1 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.1 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 7.6 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 9.0 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 7.6 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 19 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 20 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 36 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 20 KiB |
@@ -6,6 +6,9 @@
|
||||
<string name="settings">Impostazioni</string>
|
||||
<string name="censor_mac">Censura Indirizzi MAC</string>
|
||||
<string name="app_theme">Tema della App</string>
|
||||
<string name="font_size">Dimensioni del Testo delle Note</string>
|
||||
<string name="font_type">Tipo di Font</string>
|
||||
<string name="keyboard_mode">Modalità della Tastiera</string>
|
||||
|
||||
<string name="note">Nota</string>
|
||||
<string name="note_name">Nome della Nota</string>
|
||||
@@ -17,6 +20,8 @@
|
||||
<string name="note_saved">Nota Salvata</string>
|
||||
<string name="note_deleted">Nota Eliminata</string>
|
||||
<string name="note_typing_hint">Scrivi la tua nota qui...</string>
|
||||
<string name="note_info_bar">%d caratteri, %d parole, %d righe</string>
|
||||
<string name="sending_note">Invio Nota</string>
|
||||
|
||||
<string name="share_externally">Condividi Esternamente</string>
|
||||
<string name="send">Invia</string>
|
||||
@@ -24,6 +29,7 @@
|
||||
<string name="discard">Scarta</string>
|
||||
<string name="delete">Elimina</string>
|
||||
<string name="cancel">Annulla</string>
|
||||
<string name="close">Chiudi</string>
|
||||
<string name="unsaved_changes">Modifiche Non Salvate</string>
|
||||
<string name="unsaved_changes_message">Hai modifiche non salvate. Cosa vuoi fare?</string>
|
||||
</resources>
|
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item name="txt_sync_progress" type="id" />
|
||||
<item name="txt_bluetooth_status" type="id" />
|
||||
</resources>
|
@@ -6,6 +6,9 @@
|
||||
<string name="settings">Settings</string>
|
||||
<string name="censor_mac">Censor MAC Addresses</string>
|
||||
<string name="app_theme">App Theme</string>
|
||||
<string name="font_size">Note Text Size</string>
|
||||
<string name="font_type">Font Type</string>
|
||||
<string name="keyboard_mode">Keyboard Mode</string>
|
||||
|
||||
<string name="note">Note</string>
|
||||
<string name="note_name">Note Name</string>
|
||||
@@ -13,10 +16,12 @@
|
||||
<string name="send_note">Send Note</string>
|
||||
<string name="receive_notes">Receive Notes</string>
|
||||
<string name="delete_note">Delete Note</string>
|
||||
<string name="delete_note_message">Are you sure you want to delete \'%s\'?</string>
|
||||
<string name="delete_note_message">Are you sure you want to delete \"%s\"?</string>
|
||||
<string name="note_saved">Note Saved</string>
|
||||
<string name="note_deleted">Note Deleted</string>
|
||||
<string name="note_typing_hint">Type your note here...</string>
|
||||
<string name="note_info_bar">%d chars, %d words, %d lines</string>
|
||||
<string name="sending_note">Sending Note</string>
|
||||
|
||||
<string name="share_externally">Share Externally</string>
|
||||
<string name="send">Send</string>
|
||||
@@ -24,6 +29,7 @@
|
||||
<string name="discard">Discard</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="close">Close</string>
|
||||
<string name="unsaved_changes">Unsaved Changes</string>
|
||||
<string name="unsaved_changes_message">You have unsaved changes. What would you like to do?</string>
|
||||
|
||||
|