Kaynağa Gözat

Add navigation drawer, swipe refresh layout, fix post image size

Infinite 3 yıl önce
ebeveyn
işleme
74decfb9c3

+ 4 - 0
app/build.gradle

@@ -33,6 +33,7 @@ dependencies {
     implementation 'androidx.appcompat:appcompat:1.3.0'
     implementation 'com.google.android.material:material:1.3.0'
     implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
+    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
     testImplementation 'junit:junit:4.+'
     androidTestImplementation 'androidx.test.ext:junit:1.1.2'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
@@ -42,4 +43,7 @@ dependencies {
     implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
     implementation 'com.squareup.okhttp3:logging-interceptor:3.3.0'
     implementation 'com.squareup.picasso:picasso:2.8'
+    implementation 'org.jsoup:jsoup:1.11.1'
+    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
+
 }

+ 0 - 1
app/src/main/AndroidManifest.xml

@@ -11,7 +11,6 @@
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/Theme.PenguinsRead">
-        <activity android:name=".activities.PostDetailsActivity" />
         <activity android:name=".activities.MainActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />

+ 151 - 58
app/src/main/java/club/thepenguins/android/activities/MainActivity.java

@@ -1,99 +1,192 @@
 package club.thepenguins.android.activities;
 
+import androidx.appcompat.app.ActionBarDrawerToggle;
 import androidx.appcompat.app.AppCompatActivity;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.view.GravityCompat;
+import androidx.drawerlayout.widget.DrawerLayout;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
 
+import android.content.res.Configuration;
 import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.ProgressBar;
+import android.view.MenuItem;
+
+
+import com.google.android.material.navigation.NavigationView;
 
-import java.util.ArrayList;
-import java.util.List;
 
 import club.thepenguins.android.R;
-import club.thepenguins.android.adapters.PostRecyclerAdapter;
-import club.thepenguins.android.api.APIService;
-import club.thepenguins.android.data.Model;
-import club.thepenguins.android.data.Posts;
-import club.thepenguins.android.utils.Constants;
-import retrofit2.Call;
-import retrofit2.Callback;
-import retrofit2.Response;
-import retrofit2.Retrofit;
-import retrofit2.converter.gson.GsonConverterFactory;
+
+import club.thepenguins.android.fragments.AboutFragment;
+import club.thepenguins.android.fragments.HomeFragment;
 
 public class MainActivity extends AppCompatActivity {
 
-    private static final String TAG = "MainAc";
-    private RecyclerView recyclerView;
-    private ProgressBar progressBar;
-    private LinearLayoutManager LayoutManager;
-    private ArrayList<Model> list;
-    private PostRecyclerAdapter adapter;
-    public static List<Posts> mListPost;
+
+    private DrawerLayout mDrawer;
+    private Toolbar toolbar;
+
+    private NavigationView nvDrawer;
+    private ActionBarDrawerToggle drawerToggle;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
 
-        recyclerView = findViewById(R.id.recycler_view);
-        progressBar = findViewById(R.id.progressbar);
 
-        LayoutManager = new LinearLayoutManager(MainActivity.this, LinearLayoutManager.VERTICAL, false);
-        recyclerView.setLayoutManager(LayoutManager);
+        toolbar = findViewById(R.id.toolbar);
+
+        setSupportActionBar(toolbar);
+        getSupportActionBar().setDisplayShowTitleEnabled(false);
+
+
+        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+        mDrawer = findViewById(R.id.drawer_layout);
+
+        nvDrawer = findViewById(R.id.nvView);
+
+        setupDrawerContent(nvDrawer);
+
+
+        mDrawer = findViewById(R.id.drawer_layout);
+
+        drawerToggle = setupDrawerToggle();
+
+        drawerToggle.setDrawerIndicatorEnabled(true);
+
+        drawerToggle.syncState();
+
+        mDrawer.addDrawerListener(drawerToggle);
+
+
+        FragmentManager fragmentManager = getSupportFragmentManager();
+
+        fragmentManager.beginTransaction().replace(R.id.flContent, HomeFragment.newInstance("null", "null")).commit();
+
+    }
+
+    @Override
+
+    protected void onPostCreate(Bundle savedInstanceState) {
+
+        super.onPostCreate(savedInstanceState);
+
+        drawerToggle.syncState();
+
+    }
+
+
+    @Override
+
+    public void onConfigurationChanged(Configuration newConfig) {
+
+        super.onConfigurationChanged(newConfig);
+
+        drawerToggle.onConfigurationChanged(newConfig);
+
+    }
+
+    private ActionBarDrawerToggle setupDrawerToggle() {
+
+        return new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.drawer_open, R.string.drawer_close);
+
+    }
+
+    @Override
+
+    public boolean onOptionsItemSelected(MenuItem item) {
+
+        switch (item.getItemId()) {
+
+            case android.R.id.home:
+
+                mDrawer.openDrawer(GravityCompat.START);
+
+                return true;
+
+        }
+
+        return super.onOptionsItemSelected(item);
+
+    }
+
+    private void setupDrawerContent(NavigationView navigationView) {
+
+        navigationView.setNavigationItemSelectedListener(
 
-        list = new ArrayList<>();
+                new NavigationView.OnNavigationItemSelectedListener() {
 
-        getRetrofit();
+                    @Override
 
-        adapter = new PostRecyclerAdapter(list, MainActivity.this);
+                    public boolean onNavigationItemSelected(MenuItem menuItem) {
+
+                        selectDrawerItem(menuItem);
+
+                        return true;
+
+                    }
+
+                });
 
-        recyclerView.setAdapter(adapter);
     }
 
-    private void getRetrofit() {
 
-        Retrofit retrofit = new Retrofit.Builder()
-                .baseUrl(Constants.BaseUrl)
-                .addConverterFactory(GsonConverterFactory.create())
-                .build();
+    public void selectDrawerItem(MenuItem menuItem) {
+
+        Fragment fragment = null;
+
+        Class fragmentClass = null;
+
+        switch (menuItem.getItemId()) {
+
+            case R.id.nav_first_fragment:
+
+                fragmentClass = HomeFragment.class;
+
+                break;
+
+            case R.id.aboutfrag:
+
+                fragmentClass = AboutFragment.class;
+
+                break;
+
+            //case R.id.nav_third_fragment:
+
+            // fragmentClass = ThirdFragment.class;
+
+            // break;
+
+            default:
+
+                // fragmentClass = FirstFragment.class;
 
-        APIService service = retrofit.create(APIService.class);
-        Call<List<Posts>> call = service.getPosts();
+        }
 
 
-        call.enqueue(new Callback<List<Posts>>() {
-            @Override
-            public void onResponse(Call<List<Posts>> call, Response<List<Posts>> response) {
+        try {
 
-                //Log.d(TAG, "onResponse: " + response.body().get();
+            fragment = (Fragment) fragmentClass.newInstance();
 
+        } catch (Exception e) {
 
-                mListPost = response.body();
-                progressBar.setVisibility(View.GONE);
-                for (int i = 0; i < response.body().size(); i++) {
+            e.printStackTrace();
 
-                    // getFeaturedImage();
+        }
 
-                    // getFeaturedImage(response.body().get(i).getLinks().getWpFeaturedmedia().get(0).getHref());
 
-                    list.add(new Model(response.body().get(i).getTitle().getRendered(), response.body().get(i).getContent().getRendered(), response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl(), response.body().get(i).getContent().getRendered()));
+        FragmentManager fragmentManager = getSupportFragmentManager();
 
-                    Log.d(TAG, "onResponse: " + response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl());
-                }
-                adapter.notifyDataSetChanged();
+        fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
 
-            }
+        menuItem.setChecked(true);
 
-            @Override
-            public void onFailure(Call<List<Posts>> call, Throwable t) {
+        setTitle(menuItem.getTitle());
+        mDrawer.closeDrawers();
 
-                Log.d(TAG, "onFailure: ", t);
-            }
-        });
     }
 
 

+ 0 - 48
app/src/main/java/club/thepenguins/android/activities/PostDetailsActivity.java

@@ -1,48 +0,0 @@
-package club.thepenguins.android.activities;
-
-import androidx.appcompat.app.AppCompatActivity;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.webkit.WebView;
-
-import club.thepenguins.android.R;
-
-public class PostDetailsActivity extends AppCompatActivity {
-
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_post_details);
-        // TextView textView = findViewById(R.id.postd);
-
-
-        Intent i = getIntent();
-        String post = i.getExtras().getString("content");
-
-        Log.d("PostDetails ", "onCreate: " + post);
-
-        /*
-
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
-            textView.setText(Html.fromHtml(post, Html.FROM_HTML_MODE_COMPACT));
-        } else {
-            textView.setText(Html.fromHtml(post));
-        }
-
-
-         */
-
-        WebView myWebView = (WebView) findViewById(R.id.webview);
-
-        myWebView.loadDataWithBaseURL(null, post, "text/html", "UTF-8", null);
-        myWebView.getSettings().setUserAgentString("Android");
-        myWebView.getSettings().setBuiltInZoomControls(true);
-        // myWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
-        //myWebView.getSettings().getLoadWithOverviewMode();
-        //myWebView.getSettings().setUseWideViewPort(true);
-
-    }
-}

+ 24 - 5
app/src/main/java/club/thepenguins/android/adapters/PostRecyclerAdapter.java

@@ -1,7 +1,6 @@
 package club.thepenguins.android.adapters;
 
 import android.content.Context;
-import android.content.Intent;
 import android.text.Html;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -10,7 +9,9 @@ import android.widget.ImageView;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
 import androidx.cardview.widget.CardView;
+import androidx.fragment.app.FragmentManager;
 import androidx.recyclerview.widget.RecyclerView;
 
 import com.squareup.picasso.Callback;
@@ -20,8 +21,8 @@ import com.squareup.picasso.Picasso;
 import java.util.ArrayList;
 
 import club.thepenguins.android.R;
-import club.thepenguins.android.activities.PostDetailsActivity;
 import club.thepenguins.android.data.Model;
+import club.thepenguins.android.fragments.PostFragment;
 
 public class PostRecyclerAdapter extends RecyclerView.Adapter<PostRecyclerAdapter.ViewHolder> {
 
@@ -88,15 +89,33 @@ public class PostRecyclerAdapter extends RecyclerView.Adapter<PostRecyclerAdapte
         holder.cardView.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                Intent intent = new Intent(ctx, PostDetailsActivity.class);
-                intent.putExtra("content", object.Content);
-                ctx.startActivity(intent);
+
+                FragmentManager fragmentManager = ((AppCompatActivity) ctx).getSupportFragmentManager();
+
+                fragmentManager.beginTransaction().replace(R.id.flContent, PostFragment.newInstance(object.Content, object.Image)).addToBackStack("DetailedPizza").commit();
+
             }
         });
 
 
     }
 
+    public void clear() {
+
+        data.clear();
+
+        notifyDataSetChanged();
+
+    }
+
+    public void addAll(ArrayList<Model> list) {
+
+        list.addAll(list);
+
+        notifyDataSetChanged();
+
+    }
+
     @Override
     public int getItemCount() {
         return data.size();

+ 0 - 1
app/src/main/java/club/thepenguins/android/data/Image.java

@@ -11,7 +11,6 @@ import java.util.List;
  */
 
 
-
 public class Image {
 
     @SerializedName("id")

+ 1 - 1
app/src/main/java/club/thepenguins/android/data/Model.java

@@ -3,7 +3,7 @@ package club.thepenguins.android.data;
 public class Model {
     public String title, subtitle, Image, Content;
 
-    public Model ( String mtitle, String msubtitle, String image){
+    public Model(String mtitle, String msubtitle, String image) {
 
         this.title = mtitle;
         this.subtitle = msubtitle;

+ 50 - 0
app/src/main/java/club/thepenguins/android/fragments/AboutFragment.java

@@ -0,0 +1,50 @@
+package club.thepenguins.android.fragments;
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import club.thepenguins.android.R;
+
+public class AboutFragment extends Fragment {
+
+    private static final String ARG_PARAM1 = "param1";
+    private static final String ARG_PARAM2 = "param2";
+
+    private String mParam1;
+    private String mParam2;
+
+    public AboutFragment() {
+        // Required empty public constructor
+    }
+
+
+    public static AboutFragment newInstance(String param1, String param2) {
+        AboutFragment fragment = new AboutFragment();
+        Bundle args = new Bundle();
+        args.putString(ARG_PARAM1, param1);
+        args.putString(ARG_PARAM2, param2);
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        if (getArguments() != null) {
+            mParam1 = getArguments().getString(ARG_PARAM1);
+            mParam2 = getArguments().getString(ARG_PARAM2);
+        }
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        // Inflate the layout for this fragment
+        return inflater.inflate(R.layout.fragment_about, container, false);
+    }
+}

+ 154 - 0
app/src/main/java/club/thepenguins/android/fragments/HomeFragment.java

@@ -0,0 +1,154 @@
+package club.thepenguins.android.fragments;
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import club.thepenguins.android.R;
+import club.thepenguins.android.adapters.PostRecyclerAdapter;
+import club.thepenguins.android.api.APIService;
+import club.thepenguins.android.data.Model;
+import club.thepenguins.android.data.Posts;
+import club.thepenguins.android.utils.Constants;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import retrofit2.Retrofit;
+import retrofit2.converter.gson.GsonConverterFactory;
+
+
+public class HomeFragment extends Fragment {
+
+
+    private static final String ARG_PARAM1 = "param1";
+    private static final String ARG_PARAM2 = "param2";
+    private String mParam1;
+    private String mParam2;
+    private RecyclerView recyclerView;
+    private LinearLayoutManager LayoutManager;
+    private ArrayList<Model> list;
+    private PostRecyclerAdapter adapter;
+    public static List<Posts> mListPost;
+    private SwipeRefreshLayout swipeContainer;
+
+
+    public static HomeFragment newInstance(String param1, String param2) {
+        HomeFragment fragment = new HomeFragment();
+        Bundle args = new Bundle();
+        args.putString(ARG_PARAM1, param1);
+        args.putString(ARG_PARAM2, param2);
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    public HomeFragment() {
+        // Required empty public constructor
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        if (getArguments() != null) {
+            mParam1 = getArguments().getString(ARG_PARAM1);
+            mParam2 = getArguments().getString(ARG_PARAM2);
+        }
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+
+
+        View rootView = inflater.inflate(R.layout.fragment_home, container, false);
+
+        getActivity().setTitle("Choose Fragment");
+
+
+        recyclerView = rootView.findViewById(R.id.recycler_view);
+
+        LayoutManager = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.VERTICAL, false);
+        recyclerView.setLayoutManager(LayoutManager);
+
+        swipeContainer = rootView.findViewById(R.id.swiperefresh);
+
+        list = new ArrayList<>();
+
+        getRetrofit();
+
+
+        adapter = new PostRecyclerAdapter(list, rootView.getContext());
+
+        recyclerView.setAdapter(adapter);
+
+        swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+
+            @Override
+
+            public void onRefresh() {
+
+                adapter.clear();
+                getRetrofit();
+            }
+
+        });
+
+
+        swipeContainer.setColorSchemeResources(android.R.color.holo_blue_bright,
+
+                android.R.color.holo_green_light,
+
+                android.R.color.holo_orange_light,
+
+                android.R.color.holo_red_light);
+
+        return rootView;
+    }
+
+    private void getRetrofit() {
+
+        swipeContainer.setRefreshing(true);
+
+        Retrofit retrofit = new Retrofit.Builder()
+                .baseUrl(Constants.BaseUrl)
+                .addConverterFactory(GsonConverterFactory.create())
+                .build();
+
+        APIService service = retrofit.create(APIService.class);
+        Call<List<Posts>> call = service.getPosts();
+
+
+        call.enqueue(new Callback<List<Posts>>() {
+            @Override
+            public void onResponse(Call<List<Posts>> call, Response<List<Posts>> response) {
+
+                mListPost = response.body();
+                for (int i = 0; i < response.body().size(); i++) {
+
+                    list.add(new Model(response.body().get(i).getTitle().getRendered(), response.body().get(i).getContent().getRendered(), response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl(), response.body().get(i).getContent().getRendered()));
+
+                    Log.d("Home", "onResponse: " + response.body().get(i).getEmbedded().getWpFeaturedmedia().get(0).getSourceUrl());
+                }
+                adapter.notifyDataSetChanged();
+                swipeContainer.setRefreshing(false);
+
+            }
+
+            @Override
+            public void onFailure(Call<List<Posts>> call, Throwable t) {
+
+                Log.d("Home", "onFailure: ", t);
+            }
+        });
+    }
+}

+ 117 - 0
app/src/main/java/club/thepenguins/android/fragments/PostFragment.java

@@ -0,0 +1,117 @@
+package club.thepenguins.android.fragments;
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
+
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+import club.thepenguins.android.R;
+
+public class PostFragment extends Fragment {
+
+    private static final String ARG_PARAM1 = "param1";
+    private static final String ARG_PARAM2 = "param2";
+    private String mParam1;
+    private String mParam2;
+
+    public PostFragment() {
+        // Required empty public constructor
+    }
+
+
+    public static PostFragment newInstance(String param1, String param2) {
+        PostFragment fragment = new PostFragment();
+        Bundle args = new Bundle();
+        args.putString(ARG_PARAM1, param1);
+        args.putString(ARG_PARAM2, param2);
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        if (getArguments() != null) {
+            mParam1 = getArguments().getString(ARG_PARAM1);
+            mParam2 = getArguments().getString(ARG_PARAM2);
+        }
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+
+        View rootView = inflater.inflate(R.layout.fragment_post, container, false);
+
+
+        /*
+        ImageView imageView = rootView.findViewById(R.id.postImage);
+
+        Picasso.get()
+                .load(mParam2)
+                .placeholder(R.color.preloadColor)
+                .fit()
+                .centerCrop()
+                .networkPolicy(NetworkPolicy.OFFLINE)
+                .into(imageView, new Callback() {
+                    @Override
+                    public void onSuccess() {
+
+                    }
+
+                    @Override
+                    public void onError(Exception e) {
+                        Picasso.get()
+                                .load(mParam2)
+                                .placeholder(R.color.preloadColor)
+                                .fit()
+                                .centerCrop()
+                                .into(imageView);
+                    }
+                });
+
+         */
+
+        Document doc = Jsoup.parse(mParam1);
+
+        Elements images = doc.select("img");
+        Elements iframes = doc.select("iframe");
+
+        for (Element image : images) {
+
+            image.attr("width", "100%");
+            image.attr("height", "240px");
+
+        }
+
+        for (Element iframe : iframes) {
+
+            if (iframe.attr("width").isEmpty()) {
+                iframe.attr("width", "100%");
+            }
+
+        }
+
+        String htmlString = doc.html();
+
+
+        WebView myWebView = rootView.findViewById(R.id.webview);
+
+        myWebView.loadDataWithBaseURL(null, htmlString, "text/html", "UTF-8", null);
+        myWebView.getSettings().getJavaScriptEnabled();
+
+
+        return rootView;
+    }
+
+
+}

BIN
app/src/main/res/font/unifrakturcook.ttf


+ 39 - 20
app/src/main/res/layout/activity_main.xml

@@ -1,27 +1,46 @@
-<?xml version="1.0" encoding="utf-8"?>
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.drawerlayout.widget.DrawerLayout
+
+    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/drawer_layout"
+
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    tools:context=".activities.MainActivity">
 
-    <RelativeLayout
+    android:layout_height="match_parent">
+
+
+
+
+    <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent"
+        android:orientation="vertical">
 
-        <androidx.recyclerview.widget.RecyclerView
+        <include
+            layout="@layout/toolbar"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" />
+
+        <FrameLayout
+            android:id="@+id/flContent"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:id="@+id/recycler_view">
-
-        </androidx.recyclerview.widget.RecyclerView>
-
-        <ProgressBar
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:id="@+id/progressbar"
-            android:layout_alignParentBottom="true"
-            android:layout_centerHorizontal="true" />
-    </RelativeLayout>
-</androidx.constraintlayout.widget.ConstraintLayout>
+            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+
+
+    </LinearLayout>
+
+    <com.google.android.material.navigation.NavigationView
+        android:id="@+id/nvView"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:layout_gravity="start"
+        android:background="@android:color/white"
+        app:menu="@menu/drawer_view"
+        app:headerLayout="@layout/nav_header"/>
+
+
+</androidx.drawerlayout.widget.DrawerLayout>

+ 0 - 12
app/src/main/res/layout/activity_post_details.xml

@@ -5,17 +5,5 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context=".activities.PostDetailsActivity">
-    <ScrollView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        >
 
-   <WebView
-       android:id="@+id/webview"
-       android:layout_width="match_parent"
-       android:layout_height="wrap_content"
-       >
-
-   </WebView>
-    </ScrollView>
 </RelativeLayout>

+ 14 - 0
app/src/main/res/layout/fragment_about.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/aboutfrag"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".fragments.AboutFragment">
+
+    <Button
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="About Us" />
+
+</FrameLayout>

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

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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=".fragments.HomeFragment">
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+            android:id="@+id/swiperefresh"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+
+
+            <androidx.recyclerview.widget.RecyclerView
+                android:id="@+id/recycler_view"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+            </androidx.recyclerview.widget.RecyclerView>
+        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
+
+    </RelativeLayout>
+
+</FrameLayout>

+ 27 - 0
app/src/main/res/layout/fragment_post.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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=".fragments.PostFragment">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+
+        <ScrollView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+
+            <WebView
+                android:id="@+id/webview"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+            </WebView>
+        </ScrollView>
+    </LinearLayout>
+
+</FrameLayout>

+ 33 - 0
app/src/main/res/layout/nav_header.xml

@@ -0,0 +1,33 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+
+    android:layout_width="match_parent"
+
+    android:layout_height="192dp"
+
+    android:background="?attr/colorPrimaryDark"
+
+    android:gravity="bottom"
+
+    android:orientation="vertical"
+
+    android:padding="16dp"
+
+    android:theme="@style/ThemeOverlay.AppCompat.Dark">
+
+
+    <TextView
+
+        android:layout_width="match_parent"
+
+        android:layout_height="wrap_content"
+
+        android:fontFamily="@font/unifrakturcook"
+        android:text="The Penguins Club"
+        android:textAppearance="@style/TextAppearance.AppCompat.Body1"
+
+        android:textColor="@android:color/white"
+
+        android:textSize="30sp" />
+
+
+</LinearLayout>

+ 32 - 0
app/src/main/res/layout/toolbar.xml

@@ -0,0 +1,32 @@
+<androidx.appcompat.widget.Toolbar
+
+    xmlns:android="http://schemas.android.com/apk/res/android"
+
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+
+    android:id="@+id/toolbar"
+
+    android:layout_width="match_parent"
+
+    android:layout_height="wrap_content"
+
+    android:background="?attr/colorPrimaryDark"
+
+    android:fitsSystemWindows="true"
+
+
+    android:minHeight="?attr/actionBarSize"
+
+    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
+
+    <TextView
+        android:id="@+id/toolbar_title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:fontFamily="@font/unifrakturcook"
+        android:text="The Penguins Club"
+        android:textSize="20sp" />
+
+
+</androidx.appcompat.widget.Toolbar>

+ 30 - 0
app/src/main/res/menu/drawer_view.xml

@@ -0,0 +1,30 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <group>
+        <item
+            android:id="@+id/nav_first_fragment"
+            android:title="Home" />
+    </group>
+    <item android:title="Categories">
+        <menu>
+            <group>
+                <item
+
+                    android:title="Linux" />
+                <item android:title="Nix" />
+                <item android:title="News" />
+                <item android:title="Hardware" />
+                <item android:title="Technology" />
+            </group>
+        </menu>
+    </item>
+    <item android:title="Sub items">
+        <menu>
+            <group>
+                <item
+                    android:id="@+id/aboutfrag"
+                    android:title="About Us" />
+                <item android:title="Sub item 2" />
+            </group>
+        </menu>
+    </item>
+</menu>

+ 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.PenguinsRead" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+    <style name="Theme.PenguinsRead" parent="Theme.MaterialComponents.DayNight.NoActionBar">
         <!-- Primary brand color. -->
         <item name="colorPrimary">@color/purple_200</item>
         <item name="colorPrimaryVariant">@color/purple_700</item>

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

@@ -1,3 +1,5 @@
 <resources>
     <string name="app_name">Penguins Read</string>
+    <string name="drawer_open">Open navigation drawer</string>
+    <string name="drawer_close">Close navigation drawer</string>
 </resources>

+ 1 - 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.PenguinsRead" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+    <style name="Theme.PenguinsRead" parent="Theme.MaterialComponents.DayNight.NoActionBar">
         <!-- Primary brand color. -->
         <item name="colorPrimary">@color/purple_500</item>
         <item name="colorPrimaryVariant">@color/purple_700</item>