Adding simple navigation drawer
This commit is contained in:
parent
8b779473ee
commit
0f9fa1d166
46
.idea/assetWizardSettings.xml
generated
Normal file
46
.idea/assetWizardSettings.xml
generated
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WizardSettings">
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="vectorWizard">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="vectorAssetStep">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="clipartAsset">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="url" value="jar:file:/Applications/Android%20Studio.app/Contents/plugins/android/lib/android.jar!/images/material_design_icons/navigation/ic_menu_black_24dp.xml" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="outputName" value="ic_menu_black_24dp" />
|
||||
<entry key="sourceFile" value="$USER_HOME$" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="UNCHECKED_WARNING" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
@ -27,6 +27,8 @@ dependencies {
|
||||
implementation project(':readropslibrary')
|
||||
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support:design:28.0.0'
|
||||
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?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.readrops.app">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
@ -10,11 +11,13 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
|
||||
|
||||
|
||||
<activity android:name=".MainActivity">
|
||||
<activity android:name=".MainActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
@ -17,6 +17,7 @@ import com.readrops.readropslibrary.localfeed.json.JSONItem;
|
||||
import com.readrops.readropslibrary.localfeed.rss.RSSItem;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.readrops.readropslibrary.localfeed.RSSNetwork.RSSType.RSS_2;
|
||||
@ -105,7 +106,7 @@ public class LocalFeedRepository extends ARepository implements QueryCallback {
|
||||
private void parseRSSItems(List<RSSItem> items, String feedUrl) {
|
||||
Feed feed = database.feedDao().getFeedByUrl(feedUrl);
|
||||
|
||||
List<Item> dbItems = null;
|
||||
List<Item> dbItems = new ArrayList<>();
|
||||
try {
|
||||
dbItems = Item.itemsFromRSS(items, feed);
|
||||
} catch (ParseException e) {
|
||||
@ -123,7 +124,12 @@ public class LocalFeedRepository extends ARepository implements QueryCallback {
|
||||
private void parseATOMItems(List<ATOMEntry> items, String feedUrl) {
|
||||
Feed feed = database.feedDao().getFeedByUrl(feedUrl);
|
||||
|
||||
List<Item> dbItems = Item.itemsFromATOM(items, feed);
|
||||
List<Item> dbItems = new ArrayList<>();
|
||||
try {
|
||||
dbItems = Item.itemsFromATOM(items, feed);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (Item dbItem : dbItems) {
|
||||
if (!Boolean.valueOf(database.itemDao().guidExist(dbItem.getGuid())))
|
||||
@ -134,7 +140,12 @@ public class LocalFeedRepository extends ARepository implements QueryCallback {
|
||||
private void parseJSONItems(List<JSONItem> items, String feedUrl) {
|
||||
Feed feed = database.feedDao().getFeedByUrl(feedUrl);
|
||||
|
||||
List<Item> dbItems = Item.itemsFromJSON(items, feed);
|
||||
List<Item> dbItems = new ArrayList<>();
|
||||
try {
|
||||
dbItems = Item.itemsFromJSON(items, feed);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (Item dbItem : dbItems) {
|
||||
if (!Boolean.valueOf(database.itemDao().guidExist(dbItem.getGuid())))
|
||||
|
@ -3,13 +3,20 @@ package com.readrops.app;
|
||||
import android.arch.lifecycle.ViewModelProvider;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.readrops.app.database.entities.Item;
|
||||
|
||||
@ -28,6 +35,9 @@ public class MainActivity extends AppCompatActivity implements SimpleCallback, S
|
||||
private MainItemListAdapter adapter;
|
||||
private SwipeRefreshLayout refreshLayout;
|
||||
|
||||
private NavigationView navigationView;
|
||||
private DrawerLayout drawerLayout;
|
||||
|
||||
private List<Item> itemList;
|
||||
|
||||
private TreeMap<LocalDateTime, Item> itemsMap;
|
||||
@ -39,6 +49,29 @@ public class MainActivity extends AppCompatActivity implements SimpleCallback, S
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar_main);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
drawerLayout = findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open_nav_drawer, R.string.close_nav_drawer);
|
||||
drawerLayout.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
navigationView = findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener((menuItem) -> {
|
||||
menuItem.setChecked(true);
|
||||
drawerLayout.closeDrawers();
|
||||
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.to_read:
|
||||
break;
|
||||
case R.id.non_read_articles:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
viewModel = ViewModelProvider.AndroidViewModelFactory.getInstance(this.getApplication()).create(MainViewModel.class);
|
||||
viewModel.setSimpleCallback(this);
|
||||
|
||||
@ -57,6 +90,38 @@ public class MainActivity extends AppCompatActivity implements SimpleCallback, S
|
||||
refreshLayout.setOnRefreshListener(this);
|
||||
|
||||
initRecyclerView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
drawerLayout.openDrawer(GravityCompat.START);
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (drawerLayout.isDrawerOpen(GravityCompat.START))
|
||||
drawerLayout.closeDrawers();
|
||||
else
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
recyclerView = findViewById(R.id.items_recycler_view);
|
||||
|
||||
adapter = new MainItemListAdapter();
|
||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
DividerItemDecoration decoration = new DividerItemDecoration(this, ((LinearLayoutManager) layoutManager).getOrientation());
|
||||
recyclerView.addItemDecoration(decoration);
|
||||
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
|
||||
@Override
|
||||
@ -73,11 +138,11 @@ public class MainActivity extends AppCompatActivity implements SimpleCallback, S
|
||||
|
||||
@Override
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
||||
if (i == ItemTouchHelper.LEFT)
|
||||
if (i == ItemTouchHelper.LEFT)
|
||||
adapter.notifyItemRemoved(viewHolder.getAdapterPosition());
|
||||
else {
|
||||
Log.d("", "");
|
||||
}
|
||||
Log.d("", "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,19 +152,6 @@ public class MainActivity extends AppCompatActivity implements SimpleCallback, S
|
||||
}).attachToRecyclerView(recyclerView);
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
recyclerView = findViewById(R.id.items_recycler_view);
|
||||
|
||||
adapter = new MainItemListAdapter();
|
||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
DividerItemDecoration decoration = new DividerItemDecoration(this, ((LinearLayoutManager) layoutManager).getOrientation());
|
||||
recyclerView.addItemDecoration(decoration);
|
||||
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import org.joda.time.LocalDateTime;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -160,7 +161,7 @@ public class Item {
|
||||
return dbItems;
|
||||
}
|
||||
|
||||
public static List<Item> itemsFromATOM(List<ATOMEntry> items, Feed feed) {
|
||||
public static List<Item> itemsFromATOM(List<ATOMEntry> items, Feed feed) throws ParseException {
|
||||
List<Item> dbItems = new ArrayList<>();
|
||||
|
||||
for (ATOMEntry item : items) {
|
||||
@ -170,7 +171,10 @@ public class Item {
|
||||
dbItem.setDescription(item.getSummary());
|
||||
dbItem.setGuid(item.getId());
|
||||
dbItem.setTitle(item.getTitle());
|
||||
|
||||
dbItem.setPubDate(item.getUpdated());
|
||||
dbItem.setFormatedDate(DateUtils.stringToDateTime(item.getUpdated(), DateUtils.ATOM_JSON_DATE_FORMAT));
|
||||
|
||||
dbItem.setLink(item.getLink().getHref());
|
||||
|
||||
dbItem.setFeedId(feed.getId());
|
||||
@ -179,7 +183,7 @@ public class Item {
|
||||
return dbItems;
|
||||
}
|
||||
|
||||
public static List<Item> itemsFromJSON(List<JSONItem> items, Feed feed) {
|
||||
public static List<Item> itemsFromJSON(List<JSONItem> items, Feed feed) throws ParseException {
|
||||
List<Item> dbItems = new ArrayList<>();
|
||||
|
||||
for (JSONItem item : items) {
|
||||
@ -190,7 +194,10 @@ public class Item {
|
||||
dbItem.setDescription(item.getSummary());
|
||||
dbItem.setGuid(item.getId());
|
||||
dbItem.setTitle(item.getTitle());
|
||||
|
||||
dbItem.setPubDate(item.getPubDate());
|
||||
dbItem.setFormatedDate(DateUtils.stringToDateTime(item.getPubDate(), DateUtils.ATOM_JSON_DATE_FORMAT));
|
||||
|
||||
dbItem.setLink(item.getUrl());
|
||||
|
||||
dbItem.setFeedId(feed.getId());
|
||||
|
9
app/src/main/res/drawable/ic_menu.xml
Normal file
9
app/src/main/res/drawable/ic_menu.xml
Normal file
@ -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,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_read_later.xml
Normal file
9
app/src/main/res/drawable/ic_read_later.xml
Normal file
@ -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="M18.4,10.6C16.55,8.99 14.15,8 11.5,8c-4.65,0 -8.58,3.03 -9.96,7.22L3.9,16c1.05,-3.19 4.05,-5.5 7.6,-5.5 1.95,0 3.73,0.72 5.12,1.88L13,16h9V7l-3.6,3.6z"/>
|
||||
</vector>
|
12
app/src/main/res/drawable/ic_rss_feed.xml
Normal file
12
app/src/main/res/drawable/ic_rss_feed.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<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="M6.18,17.82m-2.18,0a2.18,2.18 0,1 1,4.36 0a2.18,2.18 0,1 1,-4.36 0"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M4,4.44v2.83c7.03,0 12.73,5.7 12.73,12.73h2.83c0,-8.59 -6.97,-15.56 -15.56,-15.56zM4,10.1v2.83c3.9,0 7.07,3.17 7.07,7.07h2.83c0,-5.47 -4.43,-9.9 -9.9,-9.9z"/>
|
||||
</vector>
|
@ -1,20 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.v4.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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity"
|
||||
android:id="@+id/swipe_refresh_layout">
|
||||
android:id="@+id/drawer_layout">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/items_recycler_view"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
tools:listitem="@layout/compact_list_element">
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar_main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/items_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
tools:listitem="@layout/compact_list_element"/>
|
||||
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:fitsSystemWindows="true"
|
||||
app:menu="@menu/drawer_view"
|
||||
app:headerLayout="@layout/nav_header"/>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
16
app/src/main/res/layout/app_bar_main.xml
Normal file
16
app/src/main/res/layout/app_bar_main.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
17
app/src/main/res/layout/nav_header.xml
Normal file
17
app/src/main/res/layout/nav_header.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:background="?attr/colorPrimaryDark"
|
||||
android:padding="16dp"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark"
|
||||
android:orientation="vertical"
|
||||
android:gravity="bottom">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="text"/>
|
||||
|
||||
</LinearLayout>
|
15
app/src/main/res/menu/drawer_view.xml
Normal file
15
app/src/main/res/menu/drawer_view.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/non_read_articles"
|
||||
android:title="@string/non_read_articles"
|
||||
android:icon="@drawable/ic_rss_feed"
|
||||
/>
|
||||
|
||||
<item
|
||||
android:id="@+id/to_read"
|
||||
android:title="@string/to_read"
|
||||
android:icon="@drawable/ic_read_later"/>
|
||||
|
||||
</menu>
|
9
app/src/main/res/values-fr-rFR/strings.xml
Normal file
9
app/src/main/res/values-fr-rFR/strings.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Readrops</string>
|
||||
<string name="to_read">A lire</string>
|
||||
<string name="non_read_articles">Articles non lus</string>
|
||||
<string name="open_nav_drawer">Ouvrir le menu</string>
|
||||
<string name="close_nav_drawer">Fermer le menu</string>
|
||||
|
||||
</resources>
|
@ -1,3 +1,8 @@
|
||||
<resources>
|
||||
<string name="app_name">Readrops</string>
|
||||
<string name="app_name" translatable="false">Readrops</string>
|
||||
|
||||
<string name="to_read">To read</string>
|
||||
<string name="non_read_articles">Non read articles</string>
|
||||
<string name="open_nav_drawer">Open menu</string>
|
||||
<string name="close_nav_drawer">Close menu</string>
|
||||
</resources>
|
||||
|
@ -8,4 +8,9 @@
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user