commit 83ea8b84736cce2028e81fa354634eef952092c5 Author: Trevor Slocum Date: Sat Nov 21 22:18:42 2020 -0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc1c87c --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +/.idea +/app/build +/app/go +/app/libs +/build +/captures +/local.properties +*.iml +*.sh +.DS_Store +.cxx +.externalNativeBuild +.gradle +local.properties diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7c20f89 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Trevor Slocum + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..476a9f3 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Xenia +[![CI status](https://gitlab.com/tslocum/xenia/badges/master/pipeline.svg)](https://gitlab.com/tslocum/xenia/commits/master) +[![Donate](https://img.shields.io/liberapay/receives/rocketnine.space.svg?logo=liberapay)](https://liberapay.com/rocketnine.space) + +[Gemini](https://gemini.circumlunar.space) browser for Android + +## Support + +Please share issues and suggestions [here](https://gitlab.com/tslocum/xenia/issues). diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..5ae14f6 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,34 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.2" + + defaultConfig { + applicationId "space.rocketnine.xenia" + minSdkVersion 23 + targetSdkVersion 30 + versionCode 10 + versionName "0.1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/app/src/androidTest/java/space/rocketnine/xenia/ExampleInstrumentedTest.java b/app/src/androidTest/java/space/rocketnine/xenia/ExampleInstrumentedTest.java new file mode 100644 index 0000000..46245eb --- /dev/null +++ b/app/src/androidTest/java/space/rocketnine/xenia/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package space.rocketnine.xenia; + +import android.content.Context; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("space.rocketnine.xenia", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..648d3e4 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..2ea2cd0 Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/space/rocketnine/xenia/App.java b/app/src/main/java/space/rocketnine/xenia/App.java new file mode 100644 index 0000000..1085b81 --- /dev/null +++ b/app/src/main/java/space/rocketnine/xenia/App.java @@ -0,0 +1,34 @@ +package space.rocketnine.xenia; + +import android.app.Application; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; + +public class App extends Application { + + @Override + public void onCreate() { + super.onCreate(); + + Intent serviceIntent = new Intent(this, XeniaService.class); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + startForegroundService(serviceIntent); + } else { + startService(serviceIntent); + } + + Thread openBrowser = new Thread(() -> { + try { + Thread.sleep(1000); + + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://127.0.0.1:1967/gemini/twins.rocketnine.space/")); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } catch (Exception e) { + e.getLocalizedMessage(); + } + }); + openBrowser.start(); + } +} diff --git a/app/src/main/java/space/rocketnine/xenia/MainActivity.java b/app/src/main/java/space/rocketnine/xenia/MainActivity.java new file mode 100644 index 0000000..ed37b1a --- /dev/null +++ b/app/src/main/java/space/rocketnine/xenia/MainActivity.java @@ -0,0 +1,41 @@ +package space.rocketnine.xenia; + +import android.app.Activity; +import android.app.NotificationManager; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.util.Log; +import android.view.View; + +public class MainActivity extends Activity { + String LOGTAG = "xenia"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Log.d(LOGTAG, "started"); + } + + public void openBrowser(View view) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://127.0.0.1:1967/gemini/twins.rocketnine.space/")); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + + public void exit(View view) { + NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); + notificationManager.cancelAll(); + + Intent intent = new Intent(MainActivity.this, XeniaService.class); + + getApplication().stopService(intent); + finishAffinity(); + + int pid = android.os.Process.myPid(); + android.os.Process.killProcess(pid); + } +} \ No newline at end of file diff --git a/app/src/main/java/space/rocketnine/xenia/XeniaService.java b/app/src/main/java/space/rocketnine/xenia/XeniaService.java new file mode 100644 index 0000000..335b707 --- /dev/null +++ b/app/src/main/java/space/rocketnine/xenia/XeniaService.java @@ -0,0 +1,86 @@ +package space.rocketnine.xenia; + +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.Build; +import android.os.Handler; +import android.os.IBinder; +import android.util.Log; + +import space.rocketnine.gmitohtml.Gmitohtml; + +public class XeniaService extends Service { + private final String channelID = "space.rocketnine.xenia"; + public Context context = this; + public Handler handler = null; + private final String channelName = "Xenia"; + private final String channelDescription = "Foreground service"; + + private void createNotificationChannel() { + // Create the NotificationChannel, but only on API 26+ because + // the NotificationChannel class is new and not in the support library + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + CharSequence name = channelName; + String description = channelDescription; + int importance = NotificationManager.IMPORTANCE_DEFAULT; + NotificationChannel channel = new NotificationChannel(channelID, name, importance); + channel.setDescription(description); + // Register the channel with the system; you can't change the importance + // or other notification behaviors after this + NotificationManager notificationManager = getSystemService(NotificationManager.class); + notificationManager.createNotificationChannel(channel); + } + } + + @Override + public void onCreate() { + Log.d("xenia", "service oncreate"); + + createNotificationChannel(); + + Notification.Builder builder = new Notification.Builder(this); + if (Build.VERSION.SDK_INT >= 26) { + builder.setChannelId(channelID); + } + builder.setSmallIcon(R.drawable.ic_stat_name); + builder.setContentText("Xenia is running. Tap to open"); + + Intent notificationIntent = new Intent(this, MainActivity.class); + notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); + PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); + + builder.setContentIntent(pendingIntent); + + startForeground(1337, builder.build()); + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + Log.d("xenia", "service starting"); + + try { + Gmitohtml.startDaemon("127.0.0.1:1967"); + } catch (Exception e) { + e.printStackTrace(); + } + + // If we get killed, after returning from here, restart + return START_STICKY; + } + + @Override + public IBinder onBind(Intent intent) { + // We don't provide binding, so return null + return null; + } + + @Override + public void onDestroy() { + Log.d("xenia", "service destroyed"); + } +} diff --git a/app/src/main/res/drawable-hdpi/ic_stat_name.png b/app/src/main/res/drawable-hdpi/ic_stat_name.png new file mode 100644 index 0000000..7ef077e Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_stat_name.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_stat_name.png b/app/src/main/res/drawable-mdpi/ic_stat_name.png new file mode 100644 index 0000000..1916c18 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_stat_name.png differ diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..da1dcd9 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-xhdpi/ic_stat_name.png b/app/src/main/res/drawable-xhdpi/ic_stat_name.png new file mode 100644 index 0000000..009ec91 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_stat_name.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_stat_name.png b/app/src/main/res/drawable-xxhdpi/ic_stat_name.png new file mode 100644 index 0000000..0c750e9 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_stat_name.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_stat_name.png b/app/src/main/res/drawable-xxxhdpi/ic_stat_name.png new file mode 100644 index 0000000..278f908 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_stat_name.png differ diff --git a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml new file mode 100644 index 0000000..46fc8de --- /dev/null +++ b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_gemini.png b/app/src/main/res/drawable/ic_gemini.png new file mode 100644 index 0000000..91c609d Binary files /dev/null and b/app/src/main/res/drawable/ic_gemini.png differ diff --git a/app/src/main/res/drawable/ic_home_black_24dp.xml b/app/src/main/res/drawable/ic_home_black_24dp.xml new file mode 100644 index 0000000..f8bb0b5 --- /dev/null +++ b/app/src/main/res/drawable/ic_home_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml new file mode 100644 index 0000000..78b75c3 --- /dev/null +++ b/app/src/main/res/drawable/ic_notifications_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..b14985c --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,21 @@ + + + +