mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-22 07:12:19 +00:00
Added bottom navigation bar and placeholders for fragments: chat, settings, start chat.
This commit is contained in:
parent
53f7453f12
commit
a8fb301965
@ -3,6 +3,9 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<compositeConfiguration>
|
||||||
|
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
||||||
|
</compositeConfiguration>
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
@ -41,6 +41,6 @@ dependencies {
|
|||||||
}
|
}
|
||||||
implementation 'org.slf4j:slf4j-log4j12:+'
|
implementation 'org.slf4j:slf4j-log4j12:+'
|
||||||
implementation group: 'com.h2database', name: 'h2-mvstore', version: '1.4.197'
|
implementation group: 'com.h2database', name: 'h2-mvstore', version: '1.4.197'
|
||||||
//implementation 'org.jboss:jdk-misc:2.Final'
|
implementation 'com.google.android.material:material:1.1.0-alpha04'
|
||||||
//implementation group: 'jboss', name: 'jboss-serialization', version: '4.2.2.GA'
|
implementation 'androidx.preference:preference:1.1.0-alpha03'
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:name=".helpers.AppHelper">
|
android:name=".helpers.AppHelper">
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name=".views.MainActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
@ -1,29 +1,75 @@
|
|||||||
package io.github.chronosx88.influence;
|
package io.github.chronosx88.influence.views;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import io.github.chronosx88.influence.R;
|
||||||
import io.github.chronosx88.influence.contracts.MainPresenterContract;
|
import io.github.chronosx88.influence.contracts.MainPresenterContract;
|
||||||
import io.github.chronosx88.influence.contracts.MainViewContract;
|
import io.github.chronosx88.influence.contracts.MainViewContract;
|
||||||
import io.github.chronosx88.influence.contracts.observer.Observer;
|
import io.github.chronosx88.influence.contracts.observer.Observer;
|
||||||
import io.github.chronosx88.influence.helpers.AppHelper;
|
import io.github.chronosx88.influence.helpers.AppHelper;
|
||||||
import io.github.chronosx88.influence.helpers.MessageActions;
|
import io.github.chronosx88.influence.helpers.MessageActions;
|
||||||
import io.github.chronosx88.influence.presenters.MainPresenter;
|
import io.github.chronosx88.influence.presenters.MainPresenter;
|
||||||
|
import io.github.chronosx88.influence.views.fragments.ChatFragment;
|
||||||
|
import io.github.chronosx88.influence.views.fragments.SettingsFragment;
|
||||||
|
import io.github.chronosx88.influence.views.fragments.StartChatFragment;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements Observer, MainViewContract {
|
public class MainActivity extends AppCompatActivity implements Observer, MainViewContract {
|
||||||
|
|
||||||
private MainPresenterContract presenter;
|
private MainPresenterContract presenter;
|
||||||
private ProgressDialog progressDialog;
|
private ProgressDialog progressDialog;
|
||||||
|
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
||||||
|
= new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||||
|
|
||||||
|
Fragment selectedFragment = null;
|
||||||
|
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_chats:
|
||||||
|
selectedFragment = new ChatFragment();
|
||||||
|
break;
|
||||||
|
case R.id.action_settings:
|
||||||
|
selectedFragment = new SettingsFragment();
|
||||||
|
break;
|
||||||
|
case R.id.action_start_chat:
|
||||||
|
selectedFragment = new StartChatFragment();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
transaction.replace(R.id.main_fragment_container, selectedFragment);
|
||||||
|
transaction.commit();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
BottomNavigationView navigation = findViewById(R.id.main_bottom_navigation);
|
||||||
|
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
||||||
|
|
||||||
|
getSupportFragmentManager()
|
||||||
|
.beginTransaction()
|
||||||
|
.replace(R.id.main_fragment_container, new ChatFragment())
|
||||||
|
.commit();
|
||||||
|
|
||||||
presenter = new MainPresenter(this);
|
presenter = new MainPresenter(this);
|
||||||
AppHelper.getObservable().register(this);
|
AppHelper.getObservable().register(this);
|
||||||
|
|
@ -0,0 +1,22 @@
|
|||||||
|
package io.github.chronosx88.influence.views.fragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import io.github.chronosx88.influence.R;
|
||||||
|
|
||||||
|
public class ChatFragment extends Fragment {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
return inflater.inflate(R.layout.chat_fragment, container, false);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.github.chronosx88.influence.views.fragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import io.github.chronosx88.influence.R;
|
||||||
|
|
||||||
|
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
@Override
|
||||||
|
public void onCreatePreferences(Bundle bundle, String s) {
|
||||||
|
setPreferencesFromResource(R.xml.main_settings, s);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package io.github.chronosx88.influence.views.fragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import io.github.chronosx88.influence.R;
|
||||||
|
|
||||||
|
public class StartChatFragment extends Fragment {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
return inflater.inflate(R.layout.start_chat_fragment, container, false);
|
||||||
|
}
|
||||||
|
}
|
5
app/src/main/res/drawable/ic_chat_white.xml
Normal file
5
app/src/main/res/drawable/ic_chat_white.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM6,9h12v2L6,11L6,9zM14,14L6,14v-2h8v2zM18,8L6,8L6,6h12v2z"/>
|
||||||
|
</vector>
|
5
app/src/main/res/drawable/ic_person_add_white.xml
Normal file
5
app/src/main/res/drawable/ic_person_add_white.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM6,10L6,7L4,7v3L1,10v2h3v3h2v-3h3v-2L6,10zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
|
||||||
|
</vector>
|
5
app/src/main/res/drawable/ic_settings_white.xml
Normal file
5
app/src/main/res/drawable/ic_settings_white.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
|
||||||
|
</vector>
|
@ -4,4 +4,21 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity"/>
|
tools:context=".views.MainActivity"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/main_fragment_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="10"/>
|
||||||
|
|
||||||
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
android:id="@+id/main_bottom_navigation"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
app:menu="@menu/main_bottom_nav_menu"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="bottom"/>
|
||||||
|
</LinearLayout>
|
13
app/src/main/res/layout/chat_fragment.xml
Normal file
13
app/src/main/res/layout/chat_fragment.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Temporary placeholder #1"
|
||||||
|
android:textSize="34sp"/>
|
||||||
|
</LinearLayout>
|
14
app/src/main/res/layout/start_chat_fragment.xml
Normal file
14
app/src/main/res/layout/start_chat_fragment.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Temporary placeholder #3"
|
||||||
|
android:textSize="34sp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
15
app/src/main/res/menu/main_bottom_nav_menu.xml
Normal file
15
app/src/main/res/menu/main_bottom_nav_menu.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_chats"
|
||||||
|
android:icon="@drawable/ic_chat_white"
|
||||||
|
android:title="Чаты"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:icon="@drawable/ic_settings_white"
|
||||||
|
android:title="Настройки" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_start_chat"
|
||||||
|
android:icon="@drawable/ic_person_add_white"
|
||||||
|
android:title="Начать чат" />
|
||||||
|
</menu>
|
18
app/src/main/res/xml/main_settings.xml
Normal file
18
app/src/main/res/xml/main_settings.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<Preference
|
||||||
|
android:key="peerID"
|
||||||
|
android:title="Мой Peer ID"
|
||||||
|
android:summary=""/>
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="bootstrapAddress"
|
||||||
|
android:title="Адрес Bootstrap-ноды"
|
||||||
|
android:summary="Bootstrap-нода необходима для подключения к сети" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="allowWorkBackground"
|
||||||
|
android:title="Работать в фоне (not implemented)"
|
||||||
|
android:summary="Позволять узлу работать в фоне (может повысить потребление трафика и батареи)"/>
|
||||||
|
<Preference
|
||||||
|
android:key="exportEncryptionKeys"
|
||||||
|
android:title="Экспортировать ключи шифрования (not implemented)" />
|
||||||
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user