Skip to content

Commit

Permalink
Used Grid layout
Browse files Browse the repository at this point in the history
Added grid layout, Added Al Jazeera, Google news and Washngton times
  • Loading branch information
Amuri-Bonface committed Jul 27, 2019
1 parent 552dfad commit e229999
Show file tree
Hide file tree
Showing 40 changed files with 115 additions and 40 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
// buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.news.droiddebo.mytimes"
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 28
versionCode 5
versionName "2.0"
Expand All @@ -23,6 +23,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
/*buildTypes.each {
it.buildConfigField('String', 'NEWS_API_KEY', "b46d2d93dc4d474aaa81864563640575")
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', "\"6df0...9ac\""
Expand All @@ -36,9 +40,10 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "com.android.support:appcompat-v7:$android_support_version"
implementation('com.mikepenz:materialdrawer:5.9.2@aar') {
implementation('com.mikepenz:materialdrawer:6.0.3@aar') {
transitive = true
}

implementation "com.android.support:appcompat-v7:$android_support_version"
implementation "com.android.support:design:$android_support_version"
implementation "com.android.support:recyclerview-v7:$android_support_version"
Expand All @@ -50,5 +55,7 @@ dependencies {
implementation "com.android.support:support-v4:$android_support_version"
implementation "com.android.support:support-vector-drawable:$android_support_version"
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.3'
implementation('com.mikepenz:crossfadedrawerlayout:1.0.1@aar')
implementation 'com.squareup.picasso:picasso:2.5.2'

}
Binary file added app/src/main/assets/fonts/blacklist.ttf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/sliderimages/ic_bbcnews.webp
Binary file not shown.
Binary file not shown.
80 changes: 70 additions & 10 deletions app/src/main/java/com/news/droiddebo/mytimes/view/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,36 @@
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.mikepenz.crossfadedrawerlayout.view.CrossfadeDrawerLayout;
import com.mikepenz.materialdrawer.AccountHeader;
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.MiniDrawer;
import com.mikepenz.materialdrawer.interfaces.ICrossfader;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
import com.mikepenz.materialdrawer.model.SectionDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.Nameable;
import com.mikepenz.materialdrawer.util.DrawerUIUtils;
import com.mikepenz.materialize.util.UIUtils;
import com.news.droiddebo.mytimes.MyTimesApplication;
import com.news.droiddebo.mytimes.R;
import com.news.droiddebo.mytimes.adapter.DataAdapter;
Expand All @@ -54,9 +62,12 @@
import retrofit2.Callback;
import retrofit2.Response;




public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {

private String[] SOURCE_ARRAY = {"google-news-in", "bbc-news", "the-hindu", "the-times-of-india",
private String[] SOURCE_ARRAY = {"google-news", "bbc-news", "al-jazeera-english", "the-washington-times",
"buzzfeed", "mashable", "mtv-news", "bbc-sport", "espn-cric-info", "talksport", "medical-news-today",
"national-geographic", "crypto-coins-news", "engadget", "the-next-web", "the-verge", "techcrunch", "techradar", "ign", "polygon"};
private String SOURCE;
Expand All @@ -71,6 +82,8 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
private Parcelable listState;
private Typeface montserrat_regular;
private TextView mTitle;
private CrossfadeDrawerLayout crossfadeDrawerLayout = null;


@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -88,8 +101,10 @@ protected void onCreate(Bundle savedInstanceState) {
onLoadingSwipeRefreshLayout();

createDrawer(savedInstanceState, toolbar, montserrat_regular);

}


private void createToolbar() {
toolbar = findViewById(R.id.toolbar_main_activity);
setSupportActionBar(toolbar);
Expand All @@ -105,20 +120,21 @@ private void createRecyclerView() {
swipeRefreshLayout = findViewById(R.id.swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
recyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this));
int numberOfColumns=2;
recyclerView.setLayoutManager(new GridLayoutManager(MainActivity.this,numberOfColumns));
}

private void createDrawer(Bundle savedInstanceState, final Toolbar toolbar, Typeface montserrat_regular) {
PrimaryDrawerItem item0 = new PrimaryDrawerItem().withIdentifier(0).withName("GENERAL")
.withTypeface(montserrat_regular).withSelectable(false);
PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(1).withName("Google News India")
PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(1).withName("Google News")
.withIcon(R.drawable.ic_googlenews).withTypeface(montserrat_regular);
PrimaryDrawerItem item2 = new PrimaryDrawerItem().withIdentifier(2).withName("BBC News")
.withIcon(R.drawable.ic_bbcnews).withTypeface(montserrat_regular);
PrimaryDrawerItem item3 = new PrimaryDrawerItem().withIdentifier(3).withName("The Hindu")
.withIcon(R.drawable.ic_thehindu).withTypeface(montserrat_regular);
PrimaryDrawerItem item4 = new PrimaryDrawerItem().withIdentifier(4).withName("The Times of India")
.withIcon(R.drawable.ic_timesofindia).withTypeface(montserrat_regular);
PrimaryDrawerItem item3 = new PrimaryDrawerItem().withIdentifier(3).withName("AL Jazeera English")
.withIcon(R.drawable.ic_aj_jazeera).withTypeface(montserrat_regular);
PrimaryDrawerItem item4 = new PrimaryDrawerItem().withIdentifier(4).withName("Washington Times")
.withIcon(R.drawable.ic_ic_washington_post).withTypeface(montserrat_regular);
SectionDrawerItem item5 = new SectionDrawerItem().withIdentifier(5).withName("ENTERTAINMENT")
.withTypeface(montserrat_regular);
PrimaryDrawerItem item6 = new PrimaryDrawerItem().withIdentifier(6).withName("Buzzfeed")
Expand Down Expand Up @@ -174,14 +190,20 @@ private void createDrawer(Bundle savedInstanceState, final Toolbar toolbar, Type

accountHeader = new AccountHeaderBuilder()
.withActivity(this)
.withHeaderBackground(R.drawable.ic_back)
.withHeaderBackground(R.drawable.ic_launcher)
.withSavedInstance(savedInstanceState)
.build();

result = new DrawerBuilder()
.withAccountHeader(accountHeader)
.withActivity(this)
.withDrawerLayout(R.layout.crossfade_drawer)
.withToolbar(toolbar)
.withDrawerWidthDp(72)
.withHasStableIds(true)
.withGenerateMiniDrawer(true)
.withTranslucentStatusBar(true)
.withActionBarDrawerToggleAnimated(true)
.withSelectedItem(1)
.addDrawerItems(item0, item1, item2, item3, item4, item5, item6, item7, item8, item9,
item10, item11, item12, item13, item14, item15, item16, item17, item18, item19,
Expand Down Expand Up @@ -295,7 +317,7 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
openAboutActivity();
break;
case 28:
Intent browserSource = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/debo1994/MyTimes"));
Intent browserSource = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Amuri-Bonface"));
startActivity(browserSource);
break;
case 29:
Expand All @@ -313,6 +335,44 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
})
.withSavedInstance(savedInstanceState)
.build();
//Setting crossfader drawer------------------------------------------------------------

crossfadeDrawerLayout = (CrossfadeDrawerLayout) result.getDrawerLayout();

//define maxDrawerWidth
crossfadeDrawerLayout.setMaxWidthPx(DrawerUIUtils.getOptimalDrawerWidth(this));

//add second view (which is the miniDrawer)
final MiniDrawer miniResult = result.getMiniDrawer();

//build the view for the MiniDrawer
View view = miniResult.build(this);

//set the background of the MiniDrawer as this would be transparent
view.setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(this, com.mikepenz.materialdrawer.R.attr.material_drawer_background, com.mikepenz.materialdrawer.R.color.material_drawer_background));

//we do not have the MiniDrawer view during CrossfadeDrawerLayout creation so we will add it here
crossfadeDrawerLayout.getSmallView().addView(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

//define the crossfader to be used with the miniDrawer. This is required to be able to automatically toggle open / close
miniResult.withCrossFader(new ICrossfader() {
@Override
public void crossfade() {
boolean isFaded = isCrossfaded();
crossfadeDrawerLayout.crossfade(400);

//only close the drawer if we were already faded and want to close it now
if (isFaded) {
result.getDrawerLayout().closeDrawer(GravityCompat.START);
}
}

@Override
public boolean isCrossfaded() {
return crossfadeDrawerLayout.isCrossfaded();
}
});

}


Expand Down Expand Up @@ -419,7 +479,7 @@ private void openSearchActivity() {

private void sendEmail() {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto: d.basak.db@gmail.com"));
emailIntent.setData(Uri.parse("mailto: amuribonface@gmail.com"));
startActivity(Intent.createChooser(emailIntent, "Send feedback"));
}

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/color/gradient_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:startColor="#FF512F"
android:endColor="#F09819"
android:angle="45"/>
</shape>
</item>
</selector>
Binary file added app/src/main/res/drawable-hdpi/ic_aj_jazeera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-hdpi/ic_back.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-hdpi/ic_thehindu.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-hdpi/ic_timesofindia.webp
Binary file not shown.
Binary file added app/src/main/res/drawable-mdpi/ic_aj_jazeera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-mdpi/ic_back.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-mdpi/ic_thehindu.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-mdpi/ic_timesofindia.webp
Binary file not shown.
Binary file added app/src/main/res/drawable-xhdpi/ic_aj_jazeera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-xhdpi/ic_back.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-xhdpi/ic_thehindu.webp
Binary file not shown.
Binary file removed app/src/main/res/drawable-xhdpi/ic_timesofindia.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-xxhdpi/ic_back.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-xxhdpi/ic_thehindu.webp
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-xxxhdpi/ic_back.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-xxxhdpi/ic_thehindu.webp
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions app/src/main/res/layout-v21/crossfade_drawer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mikepenz.crossfadedrawerlayout.view.CrossfadeDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/material_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" />
15 changes: 2 additions & 13 deletions app/src/main/res/layout/card_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@
android:layout_width="match_parent"
android:layout_height="60dp">

<ImageView
android:id="@+id/iv_card_info"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:contentDescription="@string/iv_card_my_info"
android:scaleType="centerCrop"
android:src="@drawable/ic_profile_pic" />

<TextView
android:id="@+id/tv_card_info"
android:layout_width="match_parent"
Expand All @@ -37,10 +27,9 @@
android:layout_marginEnd="@dimen/tv_card_layout_margin"
android:layout_marginRight="@dimen/tv_card_layout_margin"
android:layout_marginTop="@dimen/tv_card_layout_margin"
android:layout_toEndOf="@id/iv_card_info"
android:layout_toRightOf="@id/iv_card_info"

android:gravity="center"
android:text="@string/debajyoti_basak"
android:text="@string/amuri"
android:textColor="@android:color/black"
android:textSize="16sp"
android:textStyle="normal" />
Expand Down
18 changes: 10 additions & 8 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#ff0ab3ff</color>
<color name="colorPrimaryDark">#ff0ab3ff</color>
<color name="colorAccent">#ffff00</color>
<color name="navigationBarColor">#ff0ab3ff</color>

<color name="colorPrimary">#e67e22</color>
<color name="colorPrimaryDark">#d35400</color>
<color name="colorAccent">#fff</color>

<color name="navigationBarColor">#F44336</color>
<color name="colorCardView">#FFFFFF</color>
<color name="colorBackground">#E5E5E5</color>
<color name="colorDarkBackground">#227585</color>
Expand All @@ -12,12 +14,12 @@

<!-- OVERWRITE THESE COLORS FOR A LIGHT THEME -->
<!-- MaterialDrawer DEFAULT colors -->
<color name="material_drawer_background">#ff0ab3ff</color>
<color name="material_drawer_background">@android:color/white</color>
<!-- Material DEFAULT text / items colors -->
<color name="material_drawer_primary_text">@android:color/white</color>
<color name="material_drawer_secondary_text">@android:color/white</color>
<color name="material_drawer_primary_text">@android:color/black</color>
<color name="material_drawer_secondary_text">@android:color/black</color>
<!-- Material DEFAULT drawer colors -->
<color name="material_drawer_selected">#ff06a4f1</color>
<color name="material_drawer_selected">#FF5722</color>
<color name="material_drawer_selected_text">@android:color/white</color>
<color name="material_drawer_header_selection_text">#FFF</color>
</resources>
10 changes: 5 additions & 5 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<resources>
<string name="app_name">MyTimes</string>
<string name="app_name">World News</string>
<string name="title_activity_article">MyTimes</string>
<string name="article_activity_author">AUTHOR:</string>
<string name="article_activity_source">SOURCE: Times of India</string>
<string name="article_activity_source">SOURCE: </string>
<string name="article_activity_date">DATE:</string>
<string name="menu_title_url">url</string>
<string name="iv_card_content_description_image">Image of the news response</string>
<string name="collasping_image">Collasping Image</string>
<string name="menu_title_about">About the app</string>
<string name="tv_made_with_love_by">Made with &#9829; by</string>
<string name="tv_made_with_love_by">Made with &#9829; </string>
<string name="iv_card_my_info">My Photo</string>
<string name="tv_libraries_used">Libraries Used</string>
<string name="toolbar_default_text">Google News India</string>
<string name="toolbar_default_text">Google News</string>
<string name="title_about_the_app">About the app</string>
<string name="debajyoti_basak">Debajyoti Basak</string>
<string name="amuri">Amuri Bonface</string>
<string name="mytimes_logo">MyTimes Logo</string>
<string name="newsapi_tag">A beautiful News Reader powered by www.newsapi.org</string>
<string name="material_drawer">Material Drawer</string>
Expand Down

0 comments on commit e229999

Please sign in to comment.