Commit 5229d933 authored by Ayush Shrivastava's avatar Ayush Shrivastava Committed by Katharina Fey
Browse files

android: refactor android codebase from qaul to irdest

parent 8a692923
# qauldroid
# irdest-droid
Arguably the primary client of the project exists on Android. Being
able to create mesh networks with people around you, without needing
......@@ -7,7 +7,7 @@ have phones, and that creating small scale networks with phones around
you, without having to rely to SIM cards, cell towers or pre-setup
WiFi networks can enable people to avoid censorship and surveillance.
At the moment the qaul android client is a prototype!
At the moment the [Irdest](https://irde.st) android client is a prototype!
## Things to do
......@@ -26,7 +26,7 @@ really work. It crashes when trying to open one of the custom views.
### Chat view and chat list view
One of the main abilities of the qaul app is a chat. There are
One of the main abilities of the [Irdest](https://irde.st) app is a chat. There are
already fragment layout XML files for the actual chat view, and the
chat list view, but none of that is working.
......@@ -51,7 +51,7 @@ maybe with sliding side tabs? Maybe something else works better.
### Filesharing view
The filesharing view shows all advertised and local files that are known by
qaul. Files that are only advertised should have a "get" button,
[Irdest](https://irde.st). Files that are only advertised should have a "get" button,
and files that are local should be able to be swiped away.
The list should be filterable by "files by friends"
......@@ -65,4 +65,4 @@ see if they are in range, and can transfer "Frames", which are opaque and
encrypted shards of data.
Currently the WiFi Direct code starts looking for peers, but never finds
any, and also there's no service to actually use this to transfer any data.
\ No newline at end of file
any, and also there's no service to actually use this to transfer any data.
......@@ -10,7 +10,7 @@ android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "net.qaul.app"
applicationId "irde.st.app"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
......@@ -52,7 +52,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.mikhaellopez:circularimageview:4.2.0'
}
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.qaul.app">
package="st.irde.app">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
......@@ -23,10 +23,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".ui.SettingsActivity"
android:label="@string/title_activity_settings"></activity>
android:name="st.irde.app.ui.SettingsActivity"
android:label="@string/title_activity_settings" />
<activity
android:name=".LoginActivity"
android:name="st.irde.app.LoginActivity"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -35,8 +35,8 @@
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:name="st.irde.app.MainActivity"
android:windowSoftInputMode="adjustPan" />
</application>
</manifest>
\ No newline at end of file
</manifest>
package net.qaul.app
package st.irde.app
import android.R.layout.simple_spinner_dropdown_item
import android.R.layout.simple_spinner_item
......@@ -9,12 +9,10 @@ import android.util.Log
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentTransaction
import net.qaul.app.ffi.NativeQaul
import net.qaul.app.ffi.models.Id
import net.qaul.app.ffi.models.UserProfile
import net.qaul.app.net.WifiP2PService
import net.qaul.app.ui.UserCreateFragment
import net.qaul.app.util.AppState
import st.irde.app.ffi.models.UserProfile
import st.irde.app.net.WifiP2PService
import st.irde.app.ui.UserCreateFragment
import st.irde.app.util.AppState
import android.widget.ArrayAdapter as ArrayAdapter
......@@ -22,8 +20,8 @@ import android.widget.ArrayAdapter as ArrayAdapter
class LoginActivity : AppCompatActivity() {
companion object {
init {
// The "android-support" crate creates a dynamic library called "libqauldroid"
// which we can include here simply via "qauldroid" because it's being put
// The "android-support" crate creates a dynamic library called "libirdestdroid"
// which we can include here simply via "irdestdroid" because it's being put
// into the library search path via ~ m a g i c ~
System.loadLibrary("irdestcore")
}
......
package net.qaul.app
package st.irde.app
import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationView
......
package net.qaul.app.ffi;
package st.irde.app.ffi;
import android.view.View;
import net.qaul.app.ffi.models.ChatMessage;
import net.qaul.app.ffi.models.ChatRoom;
import net.qaul.app.ffi.models.Frame;
import net.qaul.app.ffi.models.Id;
import net.qaul.app.ffi.models.UserProfile;
import st.irde.app.ffi.models.ChatMessage;
import st.irde.app.ffi.models.ChatRoom;
import st.irde.app.ffi.models.Frame;
import st.irde.app.ffi.models.Id;
import st.irde.app.ffi.models.UserProfile;
import java.util.ArrayList;
/**
* The native libqaul bridge interface.
* The native irdest-core bridge interface.
* <p>
* This file/class is written in Java because FFI integration between Kotlin and Rust
* might be more complicated than with Java (for example javah exists, where there
* doesn't seem to be a comparable kotlinh). This can be changed in the future, and
* this should definitely remain the only Java code, but this is simpler for now.
*/
public class NativeQaul {
private long libqaulState = 0;
public class NativeIrdest {
private long irdestCoreState = 0;
public NativeQaul(int port) {
this.libqaulState = setupState(port);
public NativeIrdest(int port) {
this.irdestCoreState = setupState(port);
}
public native Id idTest(Id id);
......@@ -39,17 +37,17 @@ public class NativeQaul {
* @param port the remote server port
*/
public void connectTpc(String addr, int port) {
connectTcp(libqaulState, addr, port);
connectTcp(irdestCoreState, addr, port);
}
private native void connectTcp(long qaul, String addr, int port);
private native void connectTcp(long irdest, String addr, int port);
/**
* Check if the instance has a valid login
*
* @return true if login is valid
*/
private native boolean checkLogin(long qaul);
private native boolean checkLogin(long irdest);
/**
* List available users
......@@ -59,20 +57,20 @@ public class NativeQaul {
* @return List of local users
*/
public ArrayList<UserProfile> usersList(boolean local) {
return usersList(libqaulState, local);
return usersList(irdestCoreState, local);
}
private native ArrayList<UserProfile> usersList(long qaul, boolean local);
private native ArrayList<UserProfile> usersList(long irdest, boolean local);
/**
* Create a new user
*
*/
public Id usersCreate(String handle, String name, String password) {
return usersCreate(libqaulState, handle, name, password);
return usersCreate(irdestCoreState, handle, name, password);
}
private native Id usersCreate(long qaul, String handle, String name, String password);
private native Id usersCreate(long irdest, String handle, String name, String password);
/**
* Get a particular user profile by ID
......@@ -80,10 +78,10 @@ public class NativeQaul {
* @return List of local users
*/
public UserProfile usersGet(Id id) {
return usersGet(libqaulState, id);
return usersGet(irdestCoreState, id);
}
private native UserProfile usersGet(long qaul, Id id);
private native UserProfile usersGet(long irdest, Id id);
/**
* Modify the local user profile and return the new data
......@@ -91,10 +89,10 @@ public class NativeQaul {
* @return Modified user profile
*/
public UserProfile usersModify(String handle, String name) {
return usersModify(libqaulState, handle, name);
return usersModify(irdestCoreState, handle, name);
}
private native UserProfile usersModify(long qaul, String handle, String name);
private native UserProfile usersModify(long irdest, String handle, String name);
/**
......@@ -105,10 +103,10 @@ public class NativeQaul {
* @return indicate whether the
*/
public boolean usersLogin(Id id, String pw) {
return usersLogin(libqaulState, id, pw);
return usersLogin(irdestCoreState, id, pw);
}
private native boolean usersLogin(long qaul, Id id, String pw);
private native boolean usersLogin(long irdest, Id id, String pw);
/**
* List available chat rooms for the current session
......@@ -116,10 +114,10 @@ public class NativeQaul {
* @return a list of available chat rooms
*/
public ArrayList<ChatRoom> chatList() {
return chatList(libqaulState);
return chatList(irdestCoreState);
}
private native ArrayList<ChatRoom> chatList(long qaul);
private native ArrayList<ChatRoom> chatList(long irdest);
/**
* Start a new chat with some friends.
......@@ -131,10 +129,10 @@ public class NativeQaul {
* @return the room ID for further commands
*/
public ChatRoom chatStart(String name, ArrayList<Id> friends) {
return chatStart(libqaulState, name, friends);
return chatStart(irdestCoreState, name, friends);
}
private native ChatRoom chatStart(long qaul, String name, ArrayList<Id> friends);
private native ChatRoom chatStart(long irdest, String name, ArrayList<Id> friends);
/**
* Get a room object for a particular Id
......@@ -143,10 +141,10 @@ public class NativeQaul {
* @return The room associated with the given id
*/
public ChatRoom chatGetRoom(Id id) {
return chatGetRoom(libqaulState, id);
return chatGetRoom(irdestCoreState, id);
}
private native ChatRoom chatGetRoom(long qaul, Id id);
private native ChatRoom chatGetRoom(long irdest, Id id);
/**
* Send a text message to a room
......@@ -156,10 +154,10 @@ public class NativeQaul {
* @return the created chat message to display
*/
public ChatMessage chatSendMessage(Id room, String content) {
return chatSendMessage(libqaulState, room, content);
return chatSendMessage(irdestCoreState, room, content);
}
private native ChatMessage chatSendMessage(long qaul, Id room, String content);
private native ChatMessage chatSendMessage(long irdest, Id room, String content);
/**
* Load all messages from a chat room
......@@ -168,10 +166,10 @@ public class NativeQaul {
* @return a list of messages in this room
*/
public ArrayList<ChatMessage> chatLoadMessages(Id room) {
return chatLoadMessages(libqaulState, room);
return chatLoadMessages(irdestCoreState, room);
}
private native ArrayList<ChatMessage> chatLoadMessages(long qaul, Id room);
private native ArrayList<ChatMessage> chatLoadMessages(long irdest, Id room);
/**
* Receive a data frame via wifi direct
......@@ -181,10 +179,10 @@ public class NativeQaul {
* @param encodedFrame encoded data frame, ignored by Java code and passed into Rust
*/
public void wdReceived(byte[] encodedFrame) {
wdReceived(this.libqaulState, encodedFrame);
wdReceived(this.irdestCoreState, encodedFrame);
}
private native void wdReceived(long qaul, byte[] encodedFrame);
private native void wdReceived(long irdest, byte[] encodedFrame);
/**
* Get a frame from the Rust code to send off to someone special
......@@ -192,8 +190,8 @@ public class NativeQaul {
* @return the next frame to send off with target informatieon
*/
public Frame wdToSend() {
return wdToSend(this.libqaulState);
return wdToSend(this.irdestCoreState);
}
private native Frame wdToSend(long qaul);
private native Frame wdToSend(long irdest);
}
package net.qaul.app.ffi.models;
package st.irde.app.ffi.models;
import java.util.ArrayList;
......@@ -16,4 +16,4 @@ public class Call {
this.participants = participants;
this.startTime = startTime;
}
}
\ No newline at end of file
}
package net.qaul.app.ffi.models;
package st.irde.app.ffi.models;
/**
* A chat message that is part of a chat room.
......
package net.qaul.app.ffi.models;
package st.irde.app.ffi.models;
import java.lang.reflect.Array;
import java.nio.ByteBuffer;
/**
......
package net.qaul.app.ffi.models;
package st.irde.app.ffi.models;
/**
* Represents a user ID in qaul
* Represents a user ID in irdest
*/
public class Id {
public String inner;
......@@ -9,4 +9,4 @@ public class Id {
public Id(String inner) {
this.inner = inner;
}
}
\ No newline at end of file
}
package net.qaul.app.ffi.models;
package st.irde.app.ffi.models;
/**
* A file received or available on the network
......
package net.qaul.app.net
package st.irde.app.net
import android.net.wifi.p2p.WifiP2pInfo
import android.util.Log
......@@ -19,4 +19,4 @@ class PeerHandler(val id: Int, val server: ServerSocket, val client: Socket) {
}
}
}
}
\ No newline at end of file
}
package net.qaul.app.net
package st.irde.app.net
import android.content.BroadcastReceiver
import android.content.Context
......@@ -7,7 +7,6 @@ import android.net.NetworkInfo
import android.net.wifi.p2p.*
import android.net.wifi.p2p.WifiP2pManager.*
import android.util.Log
import net.qaul.app.LoginActivity
/** A broadcast receiver that reacts to WifiP2P events */
class WifiDirectBroadcastReceiver(
......
package net.qaul.app.net
package st.irde.app.net
import android.annotation.SuppressLint
import android.app.Service
......@@ -172,4 +172,4 @@ class WifiP2PService : Service(), WifiP2pManager.ConnectionInfoListener {
}
}.start()
}
}
\ No newline at end of file
}
package net.qaul.app.ui
package st.irde.app.ui
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import net.qaul.app.R
import st.irde.app.R
private const val TITLE_TAG = "settingsActivityTitle"
......@@ -82,4 +82,4 @@ class SettingsActivity : AppCompatActivity(),
setPreferencesFromResource(R.xml.sync_preferences, rootKey)
}
}
}
\ No newline at end of file
}
package net.qaul.app.ui
package st.irde.app.ui
import android.os.Bundle
import android.view.LayoutInflater
......@@ -8,9 +8,9 @@ import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.fragment.app.Fragment
import net.qaul.app.LoginActivity
import net.qaul.app.R
import net.qaul.app.util.AppState
import st.irde.app.LoginActivity
import st.irde.app.R
import st.irde.app.util.AppState
class UserCreateFragment(val login: LoginActivity) : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, bundle: Bundle?): View? {
......
package net.qaul.app.ui.chat
package st.irde.app.ui.chat
import android.annotation.SuppressLint
import android.os.Bundle
......@@ -10,13 +10,12 @@ import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import net.qaul.app.R
import net.qaul.app.ffi.models.ChatRoom
import net.qaul.app.ffi.models.Id
import net.qaul.app.util.AppState
import net.qaul.app.util.defanSubFabs
import net.qaul.app.util.fanSubFabs
import net.qaul.app.util.rotateFab
import st.irde.app.R
import st.irde.app.ffi.models.ChatRoom
import st.irde.app.util.AppState
import st.irde.app.util.defanSubFabs
import st.irde.app.util.fanSubFabs
import st.irde.app.util.rotateFab
class ChatFragment : Fragment() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment