Adding initial commit.
0
app/.exists
Normal file
40
app/build.gradle
Normal file
@ -0,0 +1,40 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'me.sergiotarxz.bedrockstation'
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId "me.sergiotarxz.bedrockstation"
|
||||
minSdk 33
|
||||
targetSdk 34
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation libs.appcompat
|
||||
implementation libs.material
|
||||
implementation libs.activity
|
||||
implementation libs.constraintlayout
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.ext.junit
|
||||
androidTestImplementation libs.espresso.core
|
||||
}
|
21
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
0
app/src/.exists
Normal file
0
app/src/androidTest/.exists
Normal file
0
app/src/androidTest/java/.exists
Normal file
0
app/src/androidTest/java/me/.exists
Normal file
0
app/src/androidTest/java/me/sergiotarxz/.exists
Normal file
@ -0,0 +1,26 @@
|
||||
package me.sergiotarxz.bedrockstation;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("me.sergiotarxz.bedrockstation", appContext.getPackageName());
|
||||
}
|
||||
}
|
0
app/src/main/.exists
Normal file
35
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.BedrockStation"
|
||||
tools:targetApi="31">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<service
|
||||
android:name=".ProxyService"
|
||||
android:foregroundServiceType="dataSync"
|
||||
android:exported="false"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
0
app/src/main/java/.exists
Normal file
0
app/src/main/java/me/.exists
Normal file
0
app/src/main/java/me/sergiotarxz/.exists
Normal file
49
app/src/main/java/me/sergiotarxz/bedrockstation/DB.java
Normal file
@ -0,0 +1,49 @@
|
||||
package me.sergiotarxz.bedrockstation;
|
||||
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.content.Context;
|
||||
|
||||
public class DB extends SQLiteOpenHelper {
|
||||
public static final String DATABASE_NAME = "bedrockstation.sqlite3";
|
||||
|
||||
public static final String[] MIGRATIONS = {
|
||||
"CREATE TABLE options (\n"
|
||||
+ "id INTEGER PRIMARY KEY,\n"
|
||||
+ "key TEXT UNIQUE,\n"
|
||||
+ "value TEXT\n"
|
||||
+ ");",
|
||||
"INSERT OR IGNORE INTO options(key, value) VALUES(\"host_cache\", \"192.168.2.1\");",
|
||||
"INSERT OR IGNORE INTO options(key, value) VALUES(\"port_cache\", \"19132\");",
|
||||
};
|
||||
|
||||
public DB(Context context) {
|
||||
super(context, DATABASE_NAME, null, MIGRATIONS.length);
|
||||
}
|
||||
|
||||
private SQLiteDatabase db = null;
|
||||
|
||||
public SQLiteDatabase getInstance() {
|
||||
if (db == null) {
|
||||
db = this.getWritableDatabase();
|
||||
}
|
||||
return db;
|
||||
}
|
||||
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
onUpgrade(db, 0, MIGRATIONS.length);
|
||||
}
|
||||
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
if (oldVersion > newVersion) {
|
||||
throw new RuntimeException("Downgrade of DB not supported");
|
||||
}
|
||||
for (int i = oldVersion; i < newVersion; i++) {
|
||||
db.execSQL(MIGRATIONS[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
throw new RuntimeException("Downgrade of DB not supported");
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package me.sergiotarxz.bedrockstation;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
public final class DBContract {
|
||||
private DBContract() {}
|
||||
|
||||
public static class Options implements BaseColumns {
|
||||
public static final String TABLE_NAME = "options";
|
||||
public static final String COLUMN_NAME_ID = "id";
|
||||
public static final String COLUMN_NAME_KEY = "key";
|
||||
public static final String COLUMN_NAME_VALUE = "value";
|
||||
}
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
package me.sergiotarxz.bedrockstation;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Gravity;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.content.Intent;
|
||||
import me.sergiotarxz.bedrockstation.ProxyService;
|
||||
import me.sergiotarxz.bedrockstation.Options;
|
||||
import me.sergiotarxz.bedrockstation.DB;
|
||||
import android.widget.Toast;
|
||||
import androidx.activity.result.contract.ActivityResultContracts.RequestPermission;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.Context;
|
||||
import android.content.ComponentName;
|
||||
import android.os.IBinder;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
interface Lambda {
|
||||
void l();
|
||||
};
|
||||
|
||||
ProxyService proxyService = null;
|
||||
boolean mBound = false;
|
||||
private Button button;
|
||||
boolean serverStarted = false;
|
||||
private EditText hostEditText = null;
|
||||
private EditText portEditText = null;
|
||||
|
||||
private ServiceConnection connection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName className,
|
||||
IBinder service) {
|
||||
ProxyService.LocalBinder binder = (ProxyService.LocalBinder) service;
|
||||
proxyService = binder.getService();
|
||||
if (proxyService.isServerStarted()) {
|
||||
onStartProxyService();
|
||||
} else {
|
||||
onFinishProxyService();
|
||||
}
|
||||
proxyService.setActivity(MainActivity.this);
|
||||
mBound = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName arg0) {
|
||||
mBound = false;
|
||||
onFinishProxyService();
|
||||
}
|
||||
};
|
||||
|
||||
private void onChangeEditText(EditText edit, Lambda l) {
|
||||
edit.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
l.l();
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void finishServiceProxy() {
|
||||
Intent intent = new Intent(this, ProxyService.class);
|
||||
intent.setAction(ProxyService.Action.END);
|
||||
this.startForegroundService(intent);
|
||||
}
|
||||
|
||||
private void startServiceProxy() {
|
||||
Intent intent = new Intent(this, ProxyService.class);
|
||||
this.startForegroundService(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
Intent intent = new Intent(this, ProxyService.class);
|
||||
bindService(intent, connection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
unbindService(connection);
|
||||
|
||||
}
|
||||
|
||||
public void onStartProxyService() {
|
||||
button.setText("Finish Proxy");
|
||||
serverStarted = true;
|
||||
}
|
||||
|
||||
public void onFinishProxyService() {
|
||||
button.setText("Start Proxy");
|
||||
serverStarted = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
layout.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.MATCH_PARENT));
|
||||
layout.setGravity(Gravity.CENTER);
|
||||
layout.setId(1);
|
||||
SQLiteDatabase db = new DB(this).getInstance();
|
||||
Options options = new Options(db);
|
||||
button = new Button(this);
|
||||
button.setOnClickListener( (View view) -> {
|
||||
if(!serverStarted) {
|
||||
if (!getSystemService(NotificationManager.class)
|
||||
.areNotificationsEnabled()) {
|
||||
requestPermissionLauncher.launch(android.Manifest.permission.POST_NOTIFICATIONS);
|
||||
return;
|
||||
}
|
||||
startServiceProxy();
|
||||
return;
|
||||
}
|
||||
finishServiceProxy();
|
||||
});
|
||||
if (serverStarted) {
|
||||
button.setText("Finish Proxy");
|
||||
} else {
|
||||
button.setText("Start Proxy");
|
||||
}
|
||||
LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT,
|
||||
LayoutParams.WRAP_CONTENT);
|
||||
LayoutParams editTextLayoutParams = new LinearLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT,
|
||||
LayoutParams.WRAP_CONTENT);
|
||||
editTextLayoutParams.width = 500;
|
||||
button.setLayoutParams(buttonLayoutParams);
|
||||
LinearLayout hostLayout = new LinearLayout(this);
|
||||
hostLayout.setGravity(Gravity.CENTER);
|
||||
TextView hostIndicator = new TextView(this);
|
||||
hostIndicator.setText("IP: ");
|
||||
hostEditText = new EditText(this);
|
||||
hostEditText.setText(options.get(Options.HOST_CACHE));
|
||||
onChangeEditText(hostEditText, () -> {
|
||||
String text = hostEditText.getText().toString();
|
||||
options.set(Options.HOST_CACHE, text);
|
||||
});
|
||||
hostEditText.setLayoutParams(editTextLayoutParams);
|
||||
hostLayout.addView(hostIndicator);
|
||||
hostLayout.addView(hostEditText);
|
||||
LinearLayout portLayout = new LinearLayout(this);
|
||||
portLayout.setGravity(Gravity.CENTER);
|
||||
TextView portIndicator = new TextView(this);
|
||||
portEditText = new EditText(this);
|
||||
onChangeEditText(portEditText, () -> {
|
||||
String text = portEditText.getText().toString();
|
||||
options.set(Options.PORT_CACHE, text);
|
||||
});
|
||||
portEditText.setLayoutParams(editTextLayoutParams);
|
||||
portIndicator.setText("Port: ");
|
||||
portEditText.setText(options.get(Options.PORT_CACHE));
|
||||
portLayout.addView(portIndicator);
|
||||
portLayout.addView(portEditText);
|
||||
layout.addView(hostLayout);
|
||||
layout.addView(portLayout);
|
||||
layout.addView(button);
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
private ActivityResultLauncher<String> requestPermissionLauncher =
|
||||
registerForActivityResult(new RequestPermission(), isGranted -> {
|
||||
if (isGranted) {
|
||||
startServiceProxy();
|
||||
} else {
|
||||
Toast.makeText(this, "You need notifications to run the proxy", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
51
app/src/main/java/me/sergiotarxz/bedrockstation/Options.java
Normal file
@ -0,0 +1,51 @@
|
||||
package me.sergiotarxz.bedrockstation;
|
||||
|
||||
import me.sergiotarxz.bedrockstation.DBContract;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.content.ContentValues;
|
||||
|
||||
public class Options {
|
||||
public static final String PORT_CACHE = "port_cache";
|
||||
public static final String HOST_CACHE = "host_cache";
|
||||
|
||||
private SQLiteDatabase db = null;
|
||||
public Options(SQLiteDatabase db) {
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public String set(String key, String value) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(DBContract.Options.COLUMN_NAME_KEY, key);
|
||||
contentValues.put(DBContract.Options.COLUMN_NAME_VALUE, value);
|
||||
db.replace(DBContract.Options.TABLE_NAME, null, contentValues);
|
||||
return value;
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
String[] projection = {
|
||||
DBContract.Options.COLUMN_NAME_VALUE
|
||||
};
|
||||
String selection = DBContract.Options.COLUMN_NAME_KEY + " = ?";
|
||||
String[] selectionArgs = { key };
|
||||
Cursor cursor = db.query(
|
||||
DBContract.Options.TABLE_NAME,
|
||||
projection,
|
||||
selection,
|
||||
selectionArgs,
|
||||
null,
|
||||
null,
|
||||
""
|
||||
);
|
||||
if (!cursor.moveToNext()) {
|
||||
return "";
|
||||
}
|
||||
String result = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(
|
||||
DBContract.Options.COLUMN_NAME_VALUE
|
||||
)
|
||||
);
|
||||
cursor.close();
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
package me.sergiotarxz.bedrockstation;
|
||||
|
||||
import android.util.Log;
|
||||
import androidx.core.app.ServiceCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.app.Service;
|
||||
import android.app.Notification;
|
||||
import android.content.Intent;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.NotificationChannel;
|
||||
import java.net.InetSocketAddress;
|
||||
import android.app.PendingIntent;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import me.sergiotarxz.bedrockstation.DB;
|
||||
import android.widget.Toast;
|
||||
import android.os.StrictMode;
|
||||
|
||||
import me.sergiotarxz.bedrockstation.ProxyThread;
|
||||
|
||||
public class ProxyService extends Service {
|
||||
|
||||
static String CHANNEL_ID = "sthaoes";
|
||||
Thread proxyThread = null;
|
||||
|
||||
public class LocalBinder extends Binder {
|
||||
ProxyService getService() {
|
||||
return ProxyService.this;
|
||||
}
|
||||
}
|
||||
|
||||
private final IBinder binder = new LocalBinder();
|
||||
|
||||
private MainActivity activity = null;
|
||||
|
||||
public void setActivity(MainActivity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return binder;
|
||||
}
|
||||
|
||||
static ProxyService instance = null;
|
||||
static public ProxyService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public class Action {
|
||||
static final String START = "start";
|
||||
static final String END = "end";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "BedrockProxy", NotificationManager.IMPORTANCE_DEFAULT);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void startForeground() {
|
||||
try {
|
||||
Intent intent = new Intent(this, ProxyService.class);
|
||||
intent.setAction(Action.END);
|
||||
PendingIntent pendingIntent = PendingIntent.getForegroundService(this, 100, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle("Bedrock Proxy is running")
|
||||
.setContentText("Press this notification to kill")
|
||||
.setSmallIcon(R.drawable.ic_launcher_foreground)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setOngoing(true)
|
||||
.build();
|
||||
int type = 0;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
type = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC;
|
||||
}
|
||||
this.startForeground(
|
||||
1,
|
||||
notification,
|
||||
type
|
||||
);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent,
|
||||
int flags,
|
||||
int startId) {
|
||||
if (intent.getAction() == null) {
|
||||
intent.setAction(Action.START);
|
||||
}
|
||||
if (intent.getAction() == Action.START) {
|
||||
startForeground();
|
||||
startServer();
|
||||
}
|
||||
if (intent.getAction() == Action.END) {
|
||||
Log.w("bedrockstation", "HOLA");
|
||||
finishServer();
|
||||
stopForeground(true);
|
||||
}
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
public boolean isServerStarted() {
|
||||
return proxyThread != null && proxyThread.isAlive();
|
||||
}
|
||||
|
||||
public void finishServer() {
|
||||
if (isServerStarted()) {
|
||||
((ProxyThread) proxyThread).terminate();
|
||||
try {
|
||||
proxyThread.join();
|
||||
activity.onFinishProxyService();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createServer(InetSocketAddress address) {
|
||||
try {
|
||||
proxyThread = new ProxyThread(address);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void startServer() {
|
||||
if (!isServerStarted()) {
|
||||
Options options = new Options(new DB(this).getInstance());
|
||||
String host = options.get(Options.HOST_CACHE);
|
||||
|
||||
int port = 0;
|
||||
try {
|
||||
port = Integer.parseInt(options.get(Options.PORT_CACHE));
|
||||
} catch (Exception e) {
|
||||
Log.e("bedrockstation", Log.getStackTraceString(e));
|
||||
Toast.makeText(this, "Port is not a number", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
createServer(new InetSocketAddress(host, port));
|
||||
proxyThread.start();
|
||||
activity.onStartProxyService();
|
||||
}
|
||||
}
|
||||
}
|
133
app/src/main/java/me/sergiotarxz/bedrockstation/ProxyThread.java
Normal file
@ -0,0 +1,133 @@
|
||||
package me.sergiotarxz.bedrockstation;
|
||||
|
||||
import java.nio.channels.DatagramChannel;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.SelectableChannel;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.HashMap;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Set;
|
||||
import java.net.StandardSocketOptions;
|
||||
import java.util.Iterator;
|
||||
import java.lang.Thread;
|
||||
import android.util.Log;
|
||||
|
||||
interface Lambda {
|
||||
void l() throws Exception;
|
||||
};
|
||||
|
||||
public class ProxyThread extends Thread
|
||||
{
|
||||
IdentityHashMap<Object, Lambda> objectToFunc;
|
||||
HashMap<String, DatagramChannel> addressToServer;
|
||||
Selector selector;
|
||||
DatagramChannel server;
|
||||
InetSocketAddress remoteServerAddress;
|
||||
|
||||
|
||||
private volatile boolean running = true;
|
||||
|
||||
public void terminate() {
|
||||
running = false;
|
||||
}
|
||||
|
||||
public ProxyThread(InetSocketAddress remoteServerAddress) throws Exception {
|
||||
this.remoteServerAddress = remoteServerAddress;
|
||||
objectToFunc = new IdentityHashMap<Object, Lambda>();
|
||||
addressToServer = new HashMap<String, DatagramChannel>();
|
||||
selector = Selector.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
server = createServer();
|
||||
while (running) {
|
||||
selector.select(1000);
|
||||
Set<SelectionKey> selectedKeys = selector.selectedKeys();
|
||||
Iterator<SelectionKey> iter = selectedKeys.iterator();
|
||||
while (iter.hasNext()) {
|
||||
SelectionKey key = iter.next();
|
||||
SelectableChannel channel = key.channel();
|
||||
if (!(channel instanceof DatagramChannel)) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
DatagramChannel dchannel = (DatagramChannel) channel;
|
||||
if (key.isReadable()) {
|
||||
objectToFunc.get(dchannel).l();
|
||||
}
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
server.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(Log.getStackTraceString(e));
|
||||
}
|
||||
}
|
||||
|
||||
public DatagramChannel createServer() throws Exception {
|
||||
DatagramChannel datagramChannel = DatagramChannel.open();
|
||||
InetSocketAddress serverAddress = new InetSocketAddress("0.0.0.0", remoteServerAddress.getPort());
|
||||
datagramChannel.bind(serverAddress);
|
||||
datagramChannel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
|
||||
datagramChannel.configureBlocking(false);
|
||||
objectToFunc.put(datagramChannel, () -> {
|
||||
onServerCanRead(datagramChannel);
|
||||
});
|
||||
datagramChannel.register(selector, SelectionKey.OP_READ);
|
||||
System.out.println("Redirecting UDP connections from (" + "0.0.0.0" + ":" + remoteServerAddress.getPort() + ") to (" + remoteServerAddress.getHostString() + ":" + remoteServerAddress.getPort() + ")");
|
||||
return datagramChannel;
|
||||
}
|
||||
|
||||
public DatagramChannel createClientFinalServer(SocketAddress finalClientAddress) throws Exception {
|
||||
DatagramChannel datagramChannel = DatagramChannel.open();
|
||||
InetSocketAddress serverAddress = remoteServerAddress;
|
||||
datagramChannel.bind(null);
|
||||
datagramChannel.configureBlocking(false);
|
||||
objectToFunc.put(datagramChannel, () -> {
|
||||
onClientFinalServerCanRead(datagramChannel, finalClientAddress);
|
||||
});
|
||||
datagramChannel.register(selector, SelectionKey.OP_READ);
|
||||
return datagramChannel;
|
||||
}
|
||||
|
||||
public void onClientFinalServerCanRead(
|
||||
DatagramChannel finalServerConnection,
|
||||
SocketAddress finalClientAddress
|
||||
) throws Exception {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(1024);
|
||||
finalServerConnection.receive(buffer);
|
||||
byte[] array = buffer.array();
|
||||
int size = buffer.capacity() - (buffer.capacity() - buffer.position());
|
||||
server.send(ByteBuffer.wrap(array, 0, size), finalClientAddress);
|
||||
}
|
||||
|
||||
public void onServerCanRead(
|
||||
DatagramChannel server
|
||||
) throws Exception {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(1024);
|
||||
SocketAddress clientAddress = server.receive(buffer);
|
||||
int size = buffer.capacity() - (buffer.capacity() - buffer.position());
|
||||
byte[] array = buffer.array();
|
||||
getClientFinalConnection(clientAddress)
|
||||
.send(ByteBuffer.wrap(array, 0, size), new InetSocketAddress("192.168.2.1", 19132));
|
||||
}
|
||||
|
||||
public DatagramChannel getClientFinalConnection( SocketAddress clientAddress ) throws Exception {
|
||||
DatagramChannel connection = addressToServer.get(clientAddress.toString());
|
||||
if (connection != null) {
|
||||
return connection;
|
||||
}
|
||||
connection = createClientFinalServer(clientAddress);
|
||||
if (clientAddress instanceof InetSocketAddress) {
|
||||
InetSocketAddress clientAddressInet = (InetSocketAddress) clientAddress;
|
||||
System.out.println("New UDP Client at (" + clientAddressInet.getHostString() + ":" + clientAddressInet.getPort() + ")");
|
||||
}
|
||||
addressToServer.put(clientAddress.toString(), connection);
|
||||
return connection;
|
||||
}
|
||||
}
|
0
app/src/main/res/.exists
Normal file
0
app/src/main/res/drawable/.exists
Normal file
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<?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>
|
30
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<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>
|
0
app/src/main/res/layout/.exists
Normal file
19
app/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
0
app/src/main/res/mipmap-anydpi/.exists
Normal file
6
app/src/main/res/mipmap-anydpi/ic_launcher.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
6
app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
0
app/src/main/res/mipmap-hdpi/.exists
Normal file
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 2.8 KiB |
0
app/src/main/res/mipmap-mdpi/.exists
Normal file
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 982 B |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 1.7 KiB |
0
app/src/main/res/mipmap-xhdpi/.exists
Normal file
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 3.8 KiB |
0
app/src/main/res/mipmap-xxhdpi/.exists
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 5.8 KiB |
0
app/src/main/res/mipmap-xxxhdpi/.exists
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 7.6 KiB |
0
app/src/main/res/values-night/.exists
Normal file
7
app/src/main/res/values-night/themes.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.BedrockStation" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
</resources>
|
0
app/src/main/res/values/.exists
Normal file
5
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
3
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">BedrockStation</string>
|
||||
</resources>
|
9
app/src/main/res/values/themes.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.BedrockStation" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.BedrockStation" parent="Base.Theme.BedrockStation" />
|
||||
</resources>
|
0
app/src/main/res/xml/.exists
Normal file
13
app/src/main/res/xml/backup_rules.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
19
app/src/main/res/xml/data_extraction_rules.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
0
app/src/test/.exists
Normal file
0
app/src/test/java/.exists
Normal file
0
app/src/test/java/me/.exists
Normal file
0
app/src/test/java/me/sergiotarxz/.exists
Normal file
@ -0,0 +1,17 @@
|
||||
package me.sergiotarxz.bedrockstation;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
4
build.gradle
Normal file
@ -0,0 +1,4 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
}
|
21
gradle.properties
Normal file
@ -0,0 +1,21 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
0
gradle/.exists
Normal file
22
gradle/libs.versions.toml
Normal file
@ -0,0 +1,22 @@
|
||||
[versions]
|
||||
agp = "8.5.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
espressoCore = "3.5.1"
|
||||
appcompat = "1.6.1"
|
||||
material = "1.10.0"
|
||||
activity = "1.8.0"
|
||||
constraintlayout = "2.1.4"
|
||||
|
||||
[libraries]
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
23
settings.gradle
Normal file
@ -0,0 +1,23 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google {
|
||||
content {
|
||||
includeGroupByRegex("com\\.android.*")
|
||||
includeGroupByRegex("com\\.google.*")
|
||||
includeGroupByRegex("androidx.*")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "BedrockStation"
|
||||
include ':app'
|