Эх сурвалжийг харах

new branch and more changes

Evgeny Polivanov 2 жил өмнө
parent
commit
fae9db7e11
26 өөрчлөгдсөн 454 нэмэгдсэн , 132 устгасан
  1. 17 0
      .idea/deploymentTargetDropDown.xml
  2. 7 0
      .idea/misc.xml
  3. 7 0
      app/build.gradle
  4. 19 18
      app/src/main/AndroidManifest.xml
  5. 40 39
      app/src/main/java/com/drinkertea/test2smack/BlankFragment.java
  6. 32 0
      app/src/main/java/com/drinkertea/test2smack/ChatsRooms.java
  7. 40 17
      app/src/main/java/com/drinkertea/test2smack/FragmentRooms.java
  8. 29 8
      app/src/main/java/com/drinkertea/test2smack/MainActivity.java
  9. 26 0
      app/src/main/java/com/drinkertea/test2smack/ui/main/PageViewModel.java
  10. 53 0
      app/src/main/java/com/drinkertea/test2smack/ui/main/SectionsPagerAdapter.java
  11. 9 0
      app/src/main/res/drawable/ic_dashboard_black_24dp.xml
  12. 9 0
      app/src/main/res/drawable/ic_home_black_24dp.xml
  13. 9 0
      app/src/main/res/drawable/ic_notifications_black_24dp.xml
  14. 28 0
      app/src/main/res/layout/activity_chats_rooms.xml
  15. 54 30
      app/src/main/res/layout/activity_main.xml
  16. 6 9
      app/src/main/res/layout/fragment_blank.xml
  17. 7 9
      app/src/main/res/layout/fragment_rooms.xml
  18. 19 0
      app/src/main/res/menu/bottom_nav_menu.xml
  19. 3 0
      app/src/main/res/values-land/dimens.xml
  20. 1 1
      app/src/main/res/values-night/themes.xml
  21. 3 0
      app/src/main/res/values-w1240dp/dimens.xml
  22. 3 0
      app/src/main/res/values-w600dp/dimens.xml
  23. 6 0
      app/src/main/res/values-w820dp/dimens.xml
  24. 8 0
      app/src/main/res/values/dimens.xml
  25. 9 0
      app/src/main/res/values/strings.xml
  26. 10 1
      app/src/main/res/values/themes.xml

+ 17 - 0
.idea/deploymentTargetDropDown.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="deploymentTargetDropDown">
+    <runningDeviceTargetSelectedWithDropDown>
+      <Target>
+        <type value="RUNNING_DEVICE_TARGET" />
+        <deviceKey>
+          <Key>
+            <type value="VIRTUAL_DEVICE_PATH" />
+            <value value="C:\Users\poliv\.android\avd\of_R_of_Pixel_API_31.avd" />
+          </Key>
+        </deviceKey>
+      </Target>
+    </runningDeviceTargetSelectedWithDropDown>
+    <timeTargetWasSelectedWithDropDown value="2022-07-22T13:44:26.567036600Z" />
+  </component>
+</project>

+ 7 - 0
.idea/misc.xml

@@ -7,9 +7,16 @@
         <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/drawable/ic_launcher_background.xml" value="0.2025" />
         <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/activity_chat.xml" value="0.22" />
         <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/activity_chats_list.xml" value="0.3546875" />
+        <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/activity_chats_rooms.xml" value="0.3546875" />
         <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/activity_main.xml" value="0.33" />
+        <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/activity_main2.xml" value="0.3546875" />
         <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/activity_room.xml" value="0.246875" />
         <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/activity_rooms.xml" value="0.1" />
+        <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/fragment_blank.xml" value="0.3546875" />
+        <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/fragment_chats.xml" value="0.23802083333333332" />
+        <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/fragment_chats_rooms.xml" value="0.340625" />
+        <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/layout/fragment_rooms.xml" value="0.3546875" />
+        <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/menu/bottom_nav_menu.xml" value="0.23802083333333332" />
         <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.2025" />
         <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" value="0.2025" />
         <entry key="..\:/Users/poliv/AndroidStudioProjects/test2Smack/app/src/main/res/xml/network_security_config.xml" value="0.24583333333333332" />

+ 7 - 0
app/build.gradle

@@ -25,6 +25,9 @@ android {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
+    buildFeatures {
+        viewBinding true
+    }
 
 }
 
@@ -40,6 +43,10 @@ dependencies {
     implementation 'androidx.appcompat:appcompat:1.4.2'
     implementation 'com.google.android.material:material:1.6.1'
     implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
+    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
+    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
+    implementation 'androidx.navigation:navigation-fragment:2.4.2'
+    implementation 'androidx.navigation:navigation-ui:2.4.2'
     testImplementation 'junit:junit:4.13.2'
     androidTestImplementation 'androidx.test.ext:junit:1.1.3'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

+ 19 - 18
app/src/main/AndroidManifest.xml

@@ -1,63 +1,64 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
-    package="com.drinkertea.test2smack">
+    package="com.drinkertea.test2smack" >
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
-    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
-    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
+
     <meta-data
         android:name="com.drinkertea.test2smack.default_notification_channel_id"
         android:value="@string/default_notification_channel_id" />
 
     <application
         android:allowBackup="true"
-        android:requestLegacyExternalStorage="true"
-        android:preserveLegacyExternalStorage="true"
         android:dataExtractionRules="@xml/data_extraction_rules"
         android:fullBackupContent="@xml/backup_rules"
         android:icon="@mipmap/ic_launcher"
         android:label="ShariX Open Chat"
-
-        android:usesCleartextTraffic="true"
+        android:preserveLegacyExternalStorage="true"
+        android:requestLegacyExternalStorage="true"
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/Theme.Test2Smack"
-        tools:targetApi="31">
-        <activity
-            android:name=".Room"
-            android:exported="false" />
+        android:usesCleartextTraffic="true"
+        tools:targetApi="31" >
         <activity
-            android:name=".rooms"
-            android:exported="false" />
+            android:name=".ChatsRooms"
+            android:exported="false"
+            android:label="@string/title_activity_chats_rooms"
+            android:theme="@style/Theme.Test2Smack.NoActionBar" />
         <activity
-            android:name=".ChatsList"
+            android:name=".Room"
             android:exported="false" />
         <activity
             android:name=".ChatActivity"
             android:exported="false" />
         <activity
             android:name=".MainActivity"
-            android:exported="true">
+            android:exported="true" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+
         <provider
             android:name="androidx.core.content.FileProvider"
             android:authorities="${applicationId}.provider"
             android:exported="false"
-            android:grantUriPermissions="true">
+            android:grantUriPermissions="true" >
             <meta-data
                 android:name="android.support.FILE_PROVIDER_PATHS"
-                android:resource="@xml/provider_paths"/>
+                android:resource="@xml/provider_paths" />
         </provider>
+
         <service android:name=".NotificationService" />
     </application>
 

+ 40 - 39
app/src/main/java/com/drinkertea/test2smack/ChatsList.java → app/src/main/java/com/drinkertea/test2smack/BlankFragment.java

@@ -1,22 +1,16 @@
 package com.drinkertea.test2smack;
 
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.app.NotificationCompat;
-import androidx.core.app.NotificationManagerCompat;
-import androidx.core.app.TaskStackBuilder;
-
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
 import android.content.Intent;
 import android.graphics.Color;
-import android.graphics.Typeface;
-import android.icu.text.SymbolTable;
-import android.os.Build;
+import android.graphics.drawable.GradientDrawable;
 import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+
 import android.os.Handler;
+import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
@@ -24,27 +18,24 @@ import org.jivesoftware.smack.chat2.Chat;
 import org.jivesoftware.smack.chat2.IncomingChatMessageListener;
 import org.jivesoftware.smack.packet.Message;
 import org.jivesoftware.smack.packet.Presence;
-import org.jivesoftware.smack.roster.Roster;
-import org.jivesoftware.smack.roster.RosterEntry;
 import org.jivesoftware.smack.roster.RosterListener;
 import org.jxmpp.jid.EntityBareJid;
 import org.jxmpp.jid.Jid;
 import org.jxmpp.jid.impl.JidCreate;
-import org.jxmpp.stringprep.XmppStringprepException;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Timer;
 import java.util.TimerTask;
+
 class FishNameComparator implements Comparator<ChatItem>
 {
     public int compare(ChatItem left, ChatItem right) {
         return right.status.compareTo(left.status);
     }
 }
-public class ChatsList extends AppCompatActivity {
+public class BlankFragment extends Fragment {
 
     LinearLayout linearLayout;
     final Handler handler = new Handler();
@@ -52,25 +43,29 @@ public class ChatsList extends AppCompatActivity {
     TimerTask timerTask = new TimerTask() {
         @Override
         public void run() {
-        handler.post(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    generateChatsList();
-                }catch (Exception ex){
-                    System.out.println(ex.getMessage());
+            handler.post(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        generateChatsList();
+                    }catch (Exception ex){
+                        System.out.println(ex.getMessage());
+                    }
                 }
-            }
-        });
+            });
         }
     };
-
+    private View view;
     @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_chats_list);
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        view = inflater.inflate(R.layout.fragment_blank, container, false);
+        init();
+        return view;
 
-        linearLayout = (LinearLayout) findViewById(R.id.chatsListLayout);
+    }
+    public void init(){
+        linearLayout = (LinearLayout) view.findViewById(R.id.chatsListLayout);
         XMPPClass.GenerateChatList();
         generateChatsList();
         runMessageListener();
@@ -81,10 +76,11 @@ public class ChatsList extends AppCompatActivity {
         linearLayout.removeAllViews();
         Collections.sort(XMPPClass.chatItems, new FishNameComparator());
         for (ChatItem chatItem : XMPPClass.chatItems){
-            TextView Name = new TextView(this);
-            TextView Status = new TextView(this);
-            TextView NewMessage = new TextView(this);
-            LinearLayout Container = new LinearLayout(this);
+
+            TextView Name = new TextView(view.getContext());
+            TextView Status = new TextView(view.getContext());
+            TextView NewMessage = new TextView(view.getContext());
+            LinearLayout Container = new LinearLayout(view.getContext());
 
             Name.setTextColor(Color.parseColor("#000000"));
             Name.setTextSize(16);
@@ -117,8 +113,12 @@ public class ChatsList extends AppCompatActivity {
                     LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
 
             layoutParams.setMargins(55, 15, 55, 15);
+            layoutParams.height = 195;
             Container.setLayoutParams(layoutParams);
-
+            GradientDrawable border = new GradientDrawable();
+            border.setColor(Color.parseColor("#ffffff"));
+            border.setStroke(5, Color.parseColor("#0081FF"));
+            Container.setBackgroundDrawable(border);
             LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(
                     LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
 
@@ -126,7 +126,7 @@ public class ChatsList extends AppCompatActivity {
             Name.setLayoutParams(textParams);
             Status.setLayoutParams(textParams);
             NewMessage.setLayoutParams(textParams);
-            Container.setBackgroundColor(Color.parseColor("#C0C0C0"));
+            //Container.setBackgroundColor(Color.parseColor("#C0C0C0"));
             Container.addView(Name);
             Container.addView(Status);
             Container.addView(NewMessage);
@@ -136,7 +136,7 @@ public class ChatsList extends AppCompatActivity {
                     try {
                         XMPPClass.chatJid = JidCreate.entityBareFrom(chatItem.jid);
                         chatItem.message = null;
-                        Intent intent = new Intent(ChatsList.this, ChatActivity.class);
+                        Intent intent = new Intent(view.getContext(), ChatActivity.class);
                         startActivity(intent);
                     }catch (Exception ex){
 
@@ -146,7 +146,7 @@ public class ChatsList extends AppCompatActivity {
             });
             linearLayout.addView(Container);
         }
-        timer.schedule(timerTask, 0, 10000);
+        timer.schedule(timerTask, 0, 15000);
     }
 
     public void runMessageListener(){
@@ -192,4 +192,5 @@ public class ChatsList extends AppCompatActivity {
             }
         });
     }
+
 }

+ 32 - 0
app/src/main/java/com/drinkertea/test2smack/ChatsRooms.java

@@ -0,0 +1,32 @@
+package com.drinkertea.test2smack;
+
+import android.os.Bundle;
+
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.snackbar.Snackbar;
+import com.google.android.material.tabs.TabLayout;
+
+import androidx.viewpager.widget.ViewPager;
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.drinkertea.test2smack.ui.main.SectionsPagerAdapter;
+import com.drinkertea.test2smack.databinding.ActivityChatsRoomsBinding;
+
+public class ChatsRooms extends AppCompatActivity {
+
+    private ActivityChatsRoomsBinding binding;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        binding = ActivityChatsRoomsBinding.inflate(getLayoutInflater());
+        setContentView(binding.getRoot());
+
+        SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
+        ViewPager viewPager = binding.viewPager;
+        viewPager.setAdapter(sectionsPagerAdapter);
+        TabLayout tabs = binding.tabs;
+        tabs.setupWithViewPager(viewPager);
+    }
+}

+ 40 - 17
app/src/main/java/com/drinkertea/test2smack/rooms.java → app/src/main/java/com/drinkertea/test2smack/FragmentRooms.java

@@ -1,27 +1,47 @@
 package com.drinkertea.test2smack;
 
-import androidx.appcompat.app.AppCompatActivity;
-
 import android.content.Intent;
 import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
 import android.os.Bundle;
+import android.os.Handler;
+import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
+import androidx.fragment.app.Fragment;
+
+import org.jivesoftware.smack.chat2.Chat;
+import org.jivesoftware.smack.chat2.IncomingChatMessageListener;
 import org.jivesoftware.smack.packet.Message;
-import org.jivesoftware.smackx.muc.MultiUserChat;
+import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smack.roster.RosterListener;
 import org.jxmpp.jid.EntityBareJid;
+import org.jxmpp.jid.Jid;
+import org.jxmpp.jid.impl.JidCreate;
 
-public class rooms extends AppCompatActivity {
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Timer;
+import java.util.TimerTask;
 
-    LinearLayout mainListRooms;
 
+public class FragmentRooms extends Fragment {
+
+    LinearLayout mainListRooms;
+    private View view;
     @Override
-    protected void onCreate(Bundle savedInstanceState)  {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_rooms);
-        mainListRooms = (LinearLayout) findViewById(R.id.roomsListLayout);
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        view = inflater.inflate(R.layout.fragment_rooms, container, false);
+        init();
+        return view;
+
+    }
+    public void init(){
+        mainListRooms = (LinearLayout) view.findViewById(R.id.roomsListLayout);
         try {
             GenerateRoomsList();
         } catch (Exception e) {
@@ -29,22 +49,24 @@ public class rooms extends AppCompatActivity {
         }
     }
 
-
     public void GenerateRoomsList() throws Exception{
         for(EntityBareJid entity : XMPPClass.GenerateRoomList()){
-            LinearLayout Container = new LinearLayout(this);
-            TextView NameRoom = new TextView(this);
-            TextView JIDRoom = new TextView(this);
+            LinearLayout Container = new LinearLayout(view.getContext());
+            TextView NameRoom = new TextView(view.getContext());
+            TextView JIDRoom = new TextView(view.getContext());
 
             Container.setOrientation(LinearLayout.VERTICAL);
-            Container.setBackgroundColor(Color.parseColor("#C0C0C0"));
+
             LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                     LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-
+            layoutParams.height = 195;
+            GradientDrawable border = new GradientDrawable();
+            border.setColor(Color.parseColor("#ffffff"));
+            border.setStroke(5, Color.parseColor("#0081FF"));
             layoutParams.setMargins(55, 15, 55, 15);
             Container.setPadding(15, 15, 15, 15);
             Container.setLayoutParams(layoutParams);
-
+            Container.setBackgroundDrawable(border);
             NameRoom.setTextColor(Color.parseColor("#000000"));
             NameRoom.setText(entity.asBareJid().toString().split("@")[0].toUpperCase());
 
@@ -56,7 +78,7 @@ public class rooms extends AppCompatActivity {
                 @Override
                 public void onClick(View view) {
                     XMPPClass.XMPP_JoinRoom(entity.asEntityBareJidString(), "Test Room User");
-                    Intent intent = new Intent(rooms.this, Room.class);
+                    Intent intent = new Intent(view.getContext(), Room.class);
                     startActivity(intent);
                 }
             });
@@ -64,4 +86,5 @@ public class rooms extends AppCompatActivity {
             mainListRooms.addView(Container);
         }
     }
+
 }

+ 29 - 8
app/src/main/java/com/drinkertea/test2smack/MainActivity.java

@@ -10,11 +10,16 @@ import android.app.Activity;
 import android.app.Dialog;
 import android.app.ProgressDialog;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 import android.os.Bundle;
 import android.os.Handler;
+import android.text.method.HideReturnsTransformationMethod;
+import android.text.method.PasswordTransformationMethod;
 import android.view.View;
+import android.widget.CheckBox;
 import android.widget.EditText;
+import android.widget.Switch;
 
 import com.dcastalia.localappupdate.DownloadApk;
 
@@ -52,6 +57,8 @@ public class MainActivity extends AppCompatActivity {
 
     private EditText ETemail;
     private EditText ETpassword;
+    private SharedPreferences pref;
+    private Switch switchPass;
     String email;
     String password;
 
@@ -59,9 +66,12 @@ public class MainActivity extends AppCompatActivity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
-
+        pref = getSharedPreferences("login_pass_pref", MODE_PRIVATE);
         ETemail = (EditText) findViewById(R.id.ETEmail);
         ETpassword = (EditText) findViewById(R.id.ETPassword);
+        switchPass = (Switch) findViewById(R.id.SwitchBoxPassword);
+        ETemail.setText(pref.getString("email", ""));
+        ETpassword.setText(pref.getString("pass", ""));
     }
 
     public void RunService(){
@@ -75,14 +85,21 @@ public class MainActivity extends AppCompatActivity {
 
     public void goToPageWithChats(View view){
         try {
+            SharedPreferences.Editor editor = pref.edit();
+
             email = ETemail.getText().toString();
             password = ETpassword.getText().toString();
             //Авторизация
             boolean isLogin = XMPPClass.XMPP_Connection(email, password);
             //Переход и заупск сервера
             if (isLogin && XMPPClass.connection.getUser() != null){
-                RunService();
-                Intent intent = new Intent(this, ChatsList.class);
+                editor.putString("email", email);
+                editor.putString("pass", password);
+                editor.apply();
+                //RunService();
+                //Intent intent = new Intent(this, ChatsList.class);
+                //startActivity(intent);
+                Intent intent = new Intent(this, ChatsRooms.class);
                 startActivity(intent);
             }
             else {
@@ -94,7 +111,7 @@ public class MainActivity extends AppCompatActivity {
     }
 
     public void testMethod(View view) throws Exception{
-        email = ETemail.getText().toString();
+        /*email = ETemail.getText().toString();
         password = ETpassword.getText().toString();
         boolean isLogin = XMPPClass.XMPP_Connection(email, password);
 
@@ -109,7 +126,7 @@ public class MainActivity extends AppCompatActivity {
         }
         else {
             System.out.println("Error connect!");
-        }
+        }*/
     }
 
     public void stopNotificationClick(View view) throws Exception{
@@ -132,8 +149,12 @@ public class MainActivity extends AppCompatActivity {
         }
     }
 
-    @Override
-    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
-        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+    public void showPass(View view) {
+        if(switchPass.isChecked()){
+            ETpassword.setTransformationMethod(new HideReturnsTransformationMethod());
+        }
+        else {
+            ETpassword.setTransformationMethod(new PasswordTransformationMethod());
+        }
     }
 }

+ 26 - 0
app/src/main/java/com/drinkertea/test2smack/ui/main/PageViewModel.java

@@ -0,0 +1,26 @@
+package com.drinkertea.test2smack.ui.main;
+
+import androidx.arch.core.util.Function;
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.Transformations;
+import androidx.lifecycle.ViewModel;
+
+public class PageViewModel extends ViewModel {
+
+    private MutableLiveData<Integer> mIndex = new MutableLiveData<>();
+    private LiveData<String> mText = Transformations.map(mIndex, new Function<Integer, String>() {
+        @Override
+        public String apply(Integer input) {
+            return "Hello world from section: " + input;
+        }
+    });
+
+    public void setIndex(int index) {
+        mIndex.setValue(index);
+    }
+
+    public LiveData<String> getText() {
+        return mText;
+    }
+}

+ 53 - 0
app/src/main/java/com/drinkertea/test2smack/ui/main/SectionsPagerAdapter.java

@@ -0,0 +1,53 @@
+package com.drinkertea.test2smack.ui.main;
+
+import android.content.Context;
+
+import androidx.annotation.Nullable;
+import androidx.annotation.StringRes;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentPagerAdapter;
+
+import com.drinkertea.test2smack.BlankFragment;
+import com.drinkertea.test2smack.FragmentRooms;
+import com.drinkertea.test2smack.R;
+
+
+public class SectionsPagerAdapter extends FragmentPagerAdapter {
+
+    @StringRes
+    private static final int[] TAB_TITLES = new int[]{R.string.tab_text_1, R.string.tab_text_2};
+    private final Context mContext;
+
+    public SectionsPagerAdapter(Context context, FragmentManager fm) {
+        super(fm);
+        mContext = context;
+    }
+
+    @Override
+    public Fragment getItem(int position) {
+        switch (position){
+            case 0:
+
+                BlankFragment blankFragment = new BlankFragment();
+                return blankFragment;
+            case 1:
+                FragmentRooms fragmentRooms = new FragmentRooms();
+                return fragmentRooms;
+            default:
+                return null;
+        }
+    }
+
+    @Nullable
+    @Override
+    public CharSequence getPageTitle(int position) {
+        return mContext.getResources().getString(TAB_TITLES[position]);
+    }
+
+    @Override
+    public int getCount() {
+        // Show 2 total pages.
+        return 2;
+    }
+}

+ 9 - 0
app/src/main/res/drawable/ic_dashboard_black_24dp.xml

@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M3,13h8L11,3L3,3v10zM3,21h8v-6L3,15v6zM13,21h8L21,11h-8v10zM13,3v6h8L21,3h-8z" />
+</vector>

+ 9 - 0
app/src/main/res/drawable/ic_home_black_24dp.xml

@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
+</vector>

+ 9 - 0
app/src/main/res/drawable/ic_notifications_black_24dp.xml

@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z" />
+</vector>

+ 28 - 0
app/src/main/res/layout/activity_chats_rooms.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".ChatsRooms">
+
+    <com.google.android.material.appbar.AppBarLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:theme="@style/Theme.Test2Smack.AppBarOverlay">
+
+
+        <com.google.android.material.tabs.TabLayout
+            android:id="@+id/tabs"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" />
+    </com.google.android.material.appbar.AppBarLayout>
+
+    <androidx.viewpager.widget.ViewPager
+        android:id="@+id/view_pager"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout>

+ 54 - 30
app/src/main/res/layout/activity_main.xml

@@ -11,11 +11,36 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:orientation="vertical"
+        android:padding="25dp"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintBottom_toTopOf="@+id/linearLayout2">
+        app:layout_constraintBottom_toTopOf="@+id/loginPassLayout">
+        <ImageView
+            android:src="@mipmap/ic_launcher_adaptive_fore"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
+        <TextView
+            android:text="ShariX Open Chat"
+            android:textAlignment="center"
+            android:textColor="#0081FF"
+            android:textSize="18dp"
+            android:textStyle="bold"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
 
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/loginPassLayout"
+        android:orientation="vertical"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/linearLayout3"
+        tools:ignore="MissingConstraints">
         <EditText
             android:id="@+id/ETEmail"
             android:layout_width="250dp"
@@ -23,58 +48,57 @@
             android:hint="Email"
             app:layout_constraintBottom_toTopOf="@+id/ETPassword" />
         <TextView
-            android:textColor="@color/teal_700"
+            android:textColor="#0081FF"
+            android:paddingLeft="5dp"
             android:textSize="10dp"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:text="without @msg.sharix-app.org"/>
-        <EditText
-            android:id="@+id/ETPassword"
-            android:layout_width="250dp"
-            android:layout_height="wrap_content"
-            android:hint="Password"
-            android:inputType="textPassword"
-            app:layout_constraintTop_toBottomOf="@+id/ETEmail"
-            tools:ignore="MissingConstraints" />
-    </LinearLayout>
-
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+            <EditText
+                android:id="@+id/ETPassword"
+                android:layout_width="205dp"
+                android:layout_height="wrap_content"
+                android:hint="Password"
+                android:inputType="textPassword"
+                app:layout_constraintTop_toBottomOf="@+id/ETEmail"
+                tools:ignore="MissingConstraints" />
+            <Switch
+                android:id="@+id/SwitchBoxPassword"
+                android:onClick="showPass"
+                android:layout_width="match_parent"
+                android:checked="false"
+                android:thumbTint="#0081FF"
+                android:trackTint="#0081FF"
+                android:background="@android:color/transparent"
+                android:layout_height="match_parent"
+                tools:ignore="UseSwitchCompatOrMaterialXml" />
+        </LinearLayout>
 
+    </LinearLayout>
     <LinearLayout
         android:id="@+id/linearLayout2"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:orientation="vertical"
+        android:padding="40dp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/linearLayout3"
         tools:ignore="MissingConstraints">
 
         <Button
             android:id="@+id/BtnConnect"
             android:layout_width="200dp"
             android:layout_height="40dp"
+            android:layout_marginBottom="40dp"
             android:onClick="goToPageWithChats"
-            android:text="Join to Chats"
+            android:text="Sign In"
             app:layout_constraintBottom_toTopOf="@+id/test"
             app:layout_constraintTop_toBottomOf="@+id/ETPassword" />
 
-        <Button
-            android:id="@+id/test"
-            android:layout_width="200dp"
-            android:layout_height="40dp"
-            android:onClick="testMethod"
-            android:text="Join to Rooms"
-            app:layout_constraintBottom_toTopOf="@+id/button"
-            app:layout_constraintTop_toBottomOf="@+id/BtnConnect" />
-
-        <Button
-            android:id="@+id/button"
-            android:layout_width="200dp"
-            android:layout_height="40dp"
-            android:onClick="stopNotificationClick"
-            android:text="Stop notification"
-            app:layout_constraintTop_toBottomOf="@+id/test" />
         <Button
             android:id="@+id/UpdateButton"
             android:layout_width="200dp"

+ 6 - 9
app/src/main/res/layout/activity_chats_list.xml → app/src/main/res/layout/fragment_blank.xml

@@ -1,17 +1,14 @@
 <?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"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    tools:context=".ChatsList">
+    tools:context=".BlankFragment">
+
     <ScrollView
         android:id="@+id/chatsListScroll"
-        android:layout_width="409dp"
-        android:layout_height="600dp"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent">
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
 
         <LinearLayout
             android:id="@+id/chatsListLayout"
@@ -40,4 +37,4 @@
         </LinearLayout>
     </ScrollView>
 
-</androidx.constraintlayout.widget.ConstraintLayout>
+</FrameLayout>

+ 7 - 9
app/src/main/res/layout/activity_rooms.xml → app/src/main/res/layout/fragment_rooms.xml

@@ -1,17 +1,14 @@
 <?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"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    tools:context=".rooms">
+    tools:context=".BlankFragment">
+
     <ScrollView
         android:id="@+id/roomsListScroll"
-        android:layout_width="409dp"
-        android:layout_height="600dp"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent">
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
 
         <LinearLayout
             android:id="@+id/roomsListLayout"
@@ -21,4 +18,5 @@
 
         </LinearLayout>
     </ScrollView>
-</androidx.constraintlayout.widget.ConstraintLayout>
+
+</FrameLayout>

+ 19 - 0
app/src/main/res/menu/bottom_nav_menu.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item
+        android:id="@+id/navigation_home"
+        android:icon="@drawable/ic_home_black_24dp"
+        android:title="@string/title_home" />
+
+    <item
+        android:id="@+id/navigation_dashboard"
+        android:icon="@drawable/ic_dashboard_black_24dp"
+        android:title="@string/title_dashboard" />
+
+    <item
+        android:id="@+id/navigation_notifications"
+        android:icon="@drawable/ic_notifications_black_24dp"
+        android:title="@string/title_notifications" />
+
+</menu>

+ 3 - 0
app/src/main/res/values-land/dimens.xml

@@ -0,0 +1,3 @@
+<resources>
+    <dimen name="fab_margin">48dp</dimen>
+</resources>

+ 1 - 1
app/src/main/res/values-night/themes.xml

@@ -1,6 +1,6 @@
 <resources xmlns:tools="http://schemas.android.com/tools">
     <!-- Base application theme. -->
-    <style name="Theme.Test2Smack" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+    <style name="Theme.Test2Smack" parent="Theme.MaterialComponents.DayNight.NoActionBar">
         <!-- Primary brand color. -->
         <item name="colorPrimary">@color/purple_200</item>
         <item name="colorPrimaryVariant">@color/purple_700</item>

+ 3 - 0
app/src/main/res/values-w1240dp/dimens.xml

@@ -0,0 +1,3 @@
+<resources>
+    <dimen name="fab_margin">200dp</dimen>
+</resources>

+ 3 - 0
app/src/main/res/values-w600dp/dimens.xml

@@ -0,0 +1,3 @@
+<resources>
+    <dimen name="fab_margin">48dp</dimen>
+</resources>

+ 6 - 0
app/src/main/res/values-w820dp/dimens.xml

@@ -0,0 +1,6 @@
+<resources>
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+    <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>

+ 8 - 0
app/src/main/res/values/dimens.xml

@@ -0,0 +1,8 @@
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+    <dimen name="appbar_padding">16dp</dimen>
+    <dimen name="fab_margin">16dp</dimen>
+    <dimen name="appbar_padding_top">8dp</dimen>
+</resources>

+ 9 - 0
app/src/main/res/values/strings.xml

@@ -1,4 +1,13 @@
 <resources>
     <string name="app_name">test2Smack</string>
     <string name="default_notification_channel_id">myChannel</string>
+    <string name="title_activity_main2">MainActivity2</string>
+    <string name="title_home">Home</string>
+    <string name="title_dashboard">Dashboard</string>
+    <string name="title_notifications">Notifications</string>
+    <string name="title_activity_chats_rooms">ChatsRooms</string>
+    <string name="tab_text_1">Chats</string>
+    <string name="tab_text_2">Rooms</string>
+    <!-- TODO: Remove or change this placeholder text -->
+    <string name="hello_blank_fragment">Hello blank fragment</string>
 </resources>

+ 10 - 1
app/src/main/res/values/themes.xml

@@ -1,6 +1,6 @@
 <resources xmlns:tools="http://schemas.android.com/tools">
     <!-- Base application theme. -->
-    <style name="Theme.Test2Smack" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+    <style name="Theme.Test2Smack" parent="Theme.MaterialComponents.DayNight.NoActionBar">
         <!-- Primary brand color. -->
         <item name="colorPrimary">@color/purple_500</item>
         <item name="colorPrimaryVariant">@color/purple_700</item>
@@ -13,4 +13,13 @@
         <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
         <!-- Customize your theme here. -->
     </style>
+
+    <style name="Theme.Test2Smack.NoActionBar">
+        <item name="windowActionBar">false</item>
+        <item name="windowNoTitle">true</item>
+    </style>
+
+    <style name="Theme.Test2Smack.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
+
+    <style name="Theme.Test2Smack.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
 </resources>