diff --git a/.idea/modules.xml b/.idea/modules.xml index dded10d14c672c230cbd4829a1c2c6317eeedf5c..fd03da75cfcf5d129472c3b73d7fabe7dae82874 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,6 @@ <project version="4"> <component name="ProjectModuleManager"> <modules> - <module fileurl="file://$PROJECT_DIR$/SEProject.iml" filepath="$PROJECT_DIR$/SEProject.iml" /> <module fileurl="file://$PROJECT_DIR$/SEProject.iml" filepath="$PROJECT_DIR$/SEProject.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> </modules> diff --git a/app/build.gradle b/app/build.gradle index 0e7b67ce5facbab57886660a2b6e7d7fc83158c9..5742fe4a243e97a76b2936448e4633cdfe49f77e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,9 +29,12 @@ dependencies { compile 'com.android.support:appcompat-v7:25.2.0' compile 'com.google.firebase:firebase-auth:10.2.0' compile 'com.android.support:support-v4:24.2.1' - testCompile 'junit:junit:4.12' compile 'com.roughike:bottom-bar:2.0.2' + compile 'com.android.volley:volley:1.0.0' + compile 'com.android.support.constraint:constraint-layout:1.0.2' + testCompile 'junit:junit:4.12' } + apply plugin: 'com.google.gms.google-services' \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0d263e4fd025bab850f86961a4e7dfd549c39d71..876e6316e8bed496896946899e6818b3c3dc896e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,12 +3,15 @@ package="com.mapps.seproject"> <uses-permission android:name="android.permission.INTERNET" /> - <uses-feature android:name="android.hardware.camera2"/> - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> + + <uses-feature android:name="android.hardware.camera2" /> + + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <application + android:name=".app.AppController" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="CleanIndia" @@ -21,18 +24,22 @@ android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" - android:resource="@xml/file_paths"></meta-data> + android:resource="@xml/file_paths" /> </provider> <activity android:name=".LoginActivity"> + + </activity> + <activity android:name=".RegisterActivity" /> + <activity android:name=".MainActivity" /> + <activity android:name=".StartActivty"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> - <activity android:name=".RegisterActivity" /> - <activity android:name=".MainActivity"></activity> + <activity android:name=".MunicipalActivity"></activity> </application> </manifest> \ No newline at end of file diff --git a/app/src/main/java/com/mapps/seproject/FeedImageView.java b/app/src/main/java/com/mapps/seproject/FeedImageView.java new file mode 100644 index 0000000000000000000000000000000000000000..7eda7d1b9dd8625b144b6b8d6ef36733470258b1 --- /dev/null +++ b/app/src/main/java/com/mapps/seproject/FeedImageView.java @@ -0,0 +1,255 @@ +package com.mapps.seproject; + + +/** + * Created by root on 20/4/17. + */ +import android.content.Context; +import android.support.v7.widget.AppCompatImageView; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; + + +import com.android.volley.VolleyError; +import com.android.volley.toolbox.ImageLoader; + + +public class FeedImageView extends AppCompatImageView { + + + + public interface ResponseObserver { + public void onError(); + + public void onSuccess(); + } + + private ResponseObserver mObserver; + + public void setResponseObserver(ResponseObserver observer) { + mObserver = observer; + } + + /** + * The URL of the network image to load + */ + private String mUrl; + + /** + * Resource ID of the image to be used as a placeholder until the network + * image is loaded. + */ + private int mDefaultImageId; + + /** + * Resource ID of the image to be used if the network response fails. + */ + private int mErrorImageId; + + /** + * Local copy of the ImageLoader. + */ + private ImageLoader mImageLoader; + + /** + * Current ImageContainer. (either in-flight or finished) + */ + private ImageLoader.ImageContainer mImageContainer; + + public FeedImageView(Context context) { + this(context, null); + } + + public FeedImageView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public FeedImageView(Context context, AttributeSet attrs, + int defStyle) { + super(context, attrs, defStyle); + } + + + public void setImageUrl(String url, ImageLoader imageLoader) { + mUrl = url; + mImageLoader = imageLoader; + // The URL has potentially changed. See if we need to load it. + loadImageIfNecessary(false); + } + + /** + * Sets the default image resource ID to be used for this view until the + * attempt to load it completes. + */ + public void setDefaultImageResId(int defaultImage) { + mDefaultImageId = defaultImage; + } + + /** + * Sets the error image resource ID to be used for this view in the event + * that the image requested fails to load. + */ + public void setErrorImageResId(int errorImage) { + mErrorImageId = errorImage; + } + + /** + * Loads the image for the view if it isn't already loaded. + * + * @param isInLayoutPass + * True if this was invoked from a layout pass, false otherwise. + */ + private void loadImageIfNecessary(final boolean isInLayoutPass) { + final int width = getWidth(); + int height = getHeight(); + + boolean isFullyWrapContent = getLayoutParams() != null + && getLayoutParams().height == LayoutParams.WRAP_CONTENT + && getLayoutParams().width == LayoutParams.WRAP_CONTENT; + // if the view's bounds aren't known yet, and this is not a + // wrap-content/wrap-content + // view, hold off on loading the image. + if (width == 0 && height == 0 && !isFullyWrapContent) { + return; + } + + // if the URL to be loaded in this view is empty, cancel any old + // requests and clear the + // currently loaded image. + if (TextUtils.isEmpty(mUrl)) { + if (mImageContainer != null) { + mImageContainer.cancelRequest(); + mImageContainer = null; + } + setDefaultImageOrNull(); + return; + } + + // if there was an old request in this view, check if it needs to be + // canceled. + if (mImageContainer != null && mImageContainer.getRequestUrl() != null) { + if (mImageContainer.getRequestUrl().equals(mUrl)) { + // if the request is from the same URL, return. + return; + } else { + // if there is a pre-existing request, cancel it if it's + // fetching a different URL. + mImageContainer.cancelRequest(); + setDefaultImageOrNull(); + } + } + + // The pre-existing content of this view didn't match the current URL. + // Load the new image + // from the network. + ImageLoader.ImageContainer newContainer = mImageLoader.get(mUrl, + new ImageLoader.ImageListener() { + @Override + public void onErrorResponse(VolleyError error) { + if (mErrorImageId != 0) { + setImageResource(mErrorImageId); + } + + if (mObserver != null) { + mObserver.onError(); + } + } + + @Override + public void onResponse(final ImageLoader.ImageContainer response, + boolean isImmediate) { + // If this was an immediate response that was delivered + // inside of a layout + // pass do not set the image immediately as it will + // trigger a requestLayout + // inside of a layout. Instead, defer setting the image + // by posting back to + // the main thread. + if (isImmediate && isInLayoutPass) { + post(new Runnable() { + @Override + public void run() { + onResponse(response, false); + } + }); + return; + } + + int bWidth = 0, bHeight = 0; + if (response.getBitmap() != null) { + + setImageBitmap(response.getBitmap()); + bWidth = response.getBitmap().getWidth(); + bHeight = response.getBitmap().getHeight(); + adjustImageAspect(bWidth, bHeight); + + } else if (mDefaultImageId != 0) { + setImageResource(mDefaultImageId); + } + + if (mObserver != null) { + mObserver.onSuccess(); + + } + } + }); + + // update the ImageContainer to be the new bitmap container. + mImageContainer = newContainer; + + } + + private void setDefaultImageOrNull() { + if (mDefaultImageId != 0) { + setImageResource(mDefaultImageId); + } else { + setImageBitmap(null); + } + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, + int bottom) { + super.onLayout(changed, left, top, right, bottom); + loadImageIfNecessary(true); + } + + @Override + protected void onDetachedFromWindow() { + if (mImageContainer != null) { + // If the view was bound to an image request, cancel it and clear + // out the image from the view. + mImageContainer.cancelRequest(); + setImageBitmap(null); + // also clear out the container so we can reload the image if + // necessary. + mImageContainer = null; + } + super.onDetachedFromWindow(); + } + + @Override + protected void drawableStateChanged() { + super.drawableStateChanged(); + invalidate(); + } + + /* + * Adjusting imageview height + * */ + private void adjustImageAspect(int bWidth, int bHeight) { + LinearLayout.LayoutParams params = (LayoutParams) getLayoutParams(); + + if (bWidth == 0 || bHeight == 0) + return; + + int swidth = getWidth(); + int new_height = 0; + new_height = swidth * bHeight / bWidth; + params.width = swidth; + params.height = new_height; + setLayoutParams(params); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/mapps/seproject/MunicipalActivity.java b/app/src/main/java/com/mapps/seproject/MunicipalActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..e3e21c2d7c8efed00f3c458a9cb518c7de5b07ed --- /dev/null +++ b/app/src/main/java/com/mapps/seproject/MunicipalActivity.java @@ -0,0 +1,142 @@ +package com.mapps.seproject; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.Menu; +import android.widget.ListView; + +import com.android.volley.Cache; +import com.android.volley.Request; +import com.android.volley.Response; +import com.android.volley.VolleyError; +import com.android.volley.VolleyLog; +import com.android.volley.toolbox.JsonObjectRequest; +import com.mapps.seproject.adapter.FeedListAdapter; +import com.mapps.seproject.app.AppController; +import com.mapps.seproject.data.FeedItem; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; + +public class MunicipalActivity extends AppCompatActivity { + private static final String TAG = MunicipalActivity.class.getSimpleName(); + private ListView listView; + private FeedListAdapter listAdapter; + private List<FeedItem> feedItems; + private String URL_FEED = "http://api.androidhive.info/feed/feed.json"; + + @SuppressLint("NewApi") + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_municipal); + + listView = (ListView) findViewById(R.id.list); + + feedItems = new ArrayList<FeedItem>(); + + listAdapter = new FeedListAdapter(this, feedItems); + listView.setAdapter(listAdapter); + + // These two lines not needed, + // just to get the look of facebook (changing background color & hiding the icon) + + getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#3b5998"))); + getSupportActionBar().setIcon( + new ColorDrawable(getResources().getColor(android.R.color.transparent))); + + // We first check for cached request + Cache cache = AppController.getInstance().getRequestQueue().getCache(); + Cache.Entry entry = cache.get(URL_FEED); + if (entry != null) { + // fetch the data from cache + try { + String data = new String(entry.data, "UTF-8"); + try { + parseJsonFeed(new JSONObject(data)); + } catch (JSONException e) { + e.printStackTrace(); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + } else { + // making fresh volley request and getting json + JsonObjectRequest jsonReq = new JsonObjectRequest(Request.Method.GET, + URL_FEED, null, new Response.Listener<JSONObject>() { + + @Override + public void onResponse(JSONObject response) { + VolleyLog.d(TAG, "Response: " + response.toString()); + if (response != null) { + parseJsonFeed(response); + } + } + }, new Response.ErrorListener() { + + @Override + public void onErrorResponse(VolleyError error) { + VolleyLog.d(TAG, "Error: " + error.getMessage()); + } + }); + + // Adding request to volley request queue + AppController.getInstance().addToRequestQueue(jsonReq); + } + + } + + /** + * Parsing json reponse and passing the data to feed view list adapter + * */ + private void parseJsonFeed(JSONObject response) { + try { + JSONArray feedArray = response.getJSONArray("feed"); + + for (int i = 0; i < feedArray.length(); i++) { + JSONObject feedObj = (JSONObject) feedArray.get(i); + + FeedItem item = new FeedItem(); + item.setId(feedObj.getInt("id")); + item.setName(feedObj.getString("name")); + + // Image might be null sometimes + String image = feedObj.isNull("image") ? null : feedObj + .getString("image"); + item.setImge(image); + item.setStatus(feedObj.getString("status")); + item.setProfilePic(feedObj.getString("profilePic")); + item.setTimeStamp(feedObj.getString("timeStamp")); + + // url might be null sometimes + String feedUrl = feedObj.isNull("url") ? null : feedObj + .getString("url"); + item.setUrl(feedUrl); + + feedItems.add(item); + } + + // notify data changes to list adapater + listAdapter.notifyDataSetChanged(); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.main, menu); + return true; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/mapps/seproject/StartActivty.java b/app/src/main/java/com/mapps/seproject/StartActivty.java new file mode 100644 index 0000000000000000000000000000000000000000..23a8f94adf4077f0e264751e9c16895953428258 --- /dev/null +++ b/app/src/main/java/com/mapps/seproject/StartActivty.java @@ -0,0 +1,35 @@ +package com.mapps.seproject; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +public class StartActivty extends AppCompatActivity implements View.OnClickListener { + + Button user; + Button municipal; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_start_activty); + user = (Button) findViewById(R.id.user_entry); + municipal = (Button) findViewById(R.id.municipal_entry); + user.setOnClickListener(this); + municipal.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + if(v==user){ + startActivity(new Intent(StartActivty.this,LoginActivity.class)); + + } + if(v==municipal){ + startActivity(new Intent(StartActivty.this,MunicipalActivity.class)); + } + } +} diff --git a/app/src/main/java/com/mapps/seproject/adapter/FeedListAdapter.java b/app/src/main/java/com/mapps/seproject/adapter/FeedListAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..12f7fa89330c1de73aea21b30683827b5a115256 --- /dev/null +++ b/app/src/main/java/com/mapps/seproject/adapter/FeedListAdapter.java @@ -0,0 +1,133 @@ +package com.mapps.seproject.adapter; + +import android.app.Activity; +import android.content.Context; +import android.text.Html; +import android.text.TextUtils; +import android.text.format.DateUtils; +import android.text.method.LinkMovementMethod; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.TextView; + +import com.android.volley.toolbox.ImageLoader; +import com.android.volley.toolbox.NetworkImageView; +import com.mapps.seproject.FeedImageView; +import com.mapps.seproject.R; +import com.mapps.seproject.app.AppController; +import com.mapps.seproject.data.FeedItem; + +import java.util.List; + +/** + * Created by root on 20/4/17. + */ + +public class FeedListAdapter extends BaseAdapter { + private Activity activity; + private LayoutInflater inflater; + private List<FeedItem> feedItems; + ImageLoader imageLoader = AppController.getInstance().getImageLoader(); + + public FeedListAdapter(Activity activity, List<FeedItem> feedItems) { + this.activity = activity; + this.feedItems = feedItems; + } + + @Override + public int getCount() { + return feedItems.size(); + } + + @Override + public Object getItem(int location) { + return feedItems.get(location); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + + if (inflater == null) + inflater = (LayoutInflater) activity + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + if (convertView == null) + convertView = inflater.inflate(R.layout.feed_item, null); + + if (imageLoader == null) + imageLoader = AppController.getInstance().getImageLoader(); + + TextView name = (TextView) convertView.findViewById(R.id.name); + TextView timestamp = (TextView) convertView + .findViewById(R.id.timestamp); + TextView statusMsg = (TextView) convertView + .findViewById(R.id.txtStatusMsg); + TextView url = (TextView) convertView.findViewById(R.id.txtUrl); + NetworkImageView profilePic = (NetworkImageView) convertView + .findViewById(R.id.profilePic); + FeedImageView feedImageView = (FeedImageView) convertView + .findViewById(R.id.feedImage1); + + FeedItem item = feedItems.get(position); + + name.setText(item.getName()); + + // Converting timestamp into x ago format + CharSequence timeAgo = DateUtils.getRelativeTimeSpanString( + Long.parseLong(item.getTimeStamp()), + System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS); + timestamp.setText(timeAgo); + + // Chcek for empty status message + if (!TextUtils.isEmpty(item.getStatus())) { + statusMsg.setText(item.getStatus()); + statusMsg.setVisibility(View.VISIBLE); + } else { + // status is empty, remove from view + statusMsg.setVisibility(View.GONE); + } + + // Checking for null feed url + if (item.getUrl() != null) { + url.setText(Html.fromHtml("<a href=\"" + item.getUrl() + "\">" + + item.getUrl() + "</a> ")); + + // Making url clickable + url.setMovementMethod(LinkMovementMethod.getInstance()); + url.setVisibility(View.VISIBLE); + } else { + // url is null, remove from the view + url.setVisibility(View.GONE); + } + + // user profile pic + profilePic.setImageUrl(item.getProfilePic(), imageLoader); + + // Feed image + if (item.getImge() != null) { + feedImageView.setImageUrl(item.getImge(), imageLoader); + feedImageView.setVisibility(View.VISIBLE); + feedImageView + .setResponseObserver(new FeedImageView.ResponseObserver() { + @Override + public void onError() { + } + + @Override + public void onSuccess() { + } + }); + } else { + feedImageView.setVisibility(View.GONE); + } + + return convertView; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/mapps/seproject/app/AppController.java b/app/src/main/java/com/mapps/seproject/app/AppController.java new file mode 100644 index 0000000000000000000000000000000000000000..e6231e8f3939c58f2bed87a83f7d929dc02d9134 --- /dev/null +++ b/app/src/main/java/com/mapps/seproject/app/AppController.java @@ -0,0 +1,75 @@ +package com.mapps.seproject.app; + +import android.app.Application; +import android.text.TextUtils; + +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.toolbox.ImageLoader; +import com.android.volley.toolbox.Volley; +import com.mapps.seproject.volley.LruBitmapCache; + +/** + * Created by root on 20/4/17. + */ + +public class AppController extends Application { + + public static final String TAG = AppController.class.getSimpleName(); + + private RequestQueue mRequestQueue; + private ImageLoader mImageLoader; + LruBitmapCache mLruBitmapCache; + + private static AppController mInstance; + + @Override + public void onCreate() { + super.onCreate(); + mInstance = this; + } + + public static synchronized AppController getInstance() { + return mInstance; + } + + public RequestQueue getRequestQueue() { + if (mRequestQueue == null) { + mRequestQueue = Volley.newRequestQueue(getApplicationContext()); + } + + return mRequestQueue; + } + + public ImageLoader getImageLoader() { + getRequestQueue(); + if (mImageLoader == null) { + getLruBitmapCache(); + mImageLoader = new ImageLoader(this.mRequestQueue, mLruBitmapCache); + } + + return this.mImageLoader; + } + + public LruBitmapCache getLruBitmapCache() { + if (mLruBitmapCache == null) + mLruBitmapCache = new LruBitmapCache(); + return this.mLruBitmapCache; + } + + public <T> void addToRequestQueue(Request<T> req, String tag) { + req.setTag(TextUtils.isEmpty(tag) ? TAG : tag); + getRequestQueue().add(req); + } + + public <T> void addToRequestQueue(Request<T> req) { + req.setTag(TAG); + getRequestQueue().add(req); + } + + public void cancelPendingRequests(Object tag) { + if (mRequestQueue != null) { + mRequestQueue.cancelAll(tag); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/mapps/seproject/data/FeedItem.java b/app/src/main/java/com/mapps/seproject/data/FeedItem.java new file mode 100644 index 0000000000000000000000000000000000000000..75ce9d5dcc7d4c09adf951b314fcf64eb2d5b0dd --- /dev/null +++ b/app/src/main/java/com/mapps/seproject/data/FeedItem.java @@ -0,0 +1,81 @@ +package com.mapps.seproject.data; + +/** + * Created by root on 20/4/17. + */ + +public class FeedItem { + private int id; + private String name, status, image, profilePic, timeStamp, url; + + public FeedItem() { + } + + public FeedItem(int id, String name, String image, String status, + String profilePic, String timeStamp, String url) { + super(); + this.id = id; + this.name = name; + this.image = image; + this.status = status; + this.profilePic = profilePic; + this.timeStamp = timeStamp; + this.url = url; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImge() { + return image; + } + + public void setImge(String image) { + this.image = image; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getProfilePic() { + return profilePic; + } + + public void setProfilePic(String profilePic) { + this.profilePic = profilePic; + } + + public String getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(String timeStamp) { + this.timeStamp = timeStamp; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/mapps/seproject/volley/LruBitmapCache.java b/app/src/main/java/com/mapps/seproject/volley/LruBitmapCache.java new file mode 100644 index 0000000000000000000000000000000000000000..889cc6387c993ffb824207f6e7e4b725917b11a8 --- /dev/null +++ b/app/src/main/java/com/mapps/seproject/volley/LruBitmapCache.java @@ -0,0 +1,45 @@ +package com.mapps.seproject.volley; + + + +import android.graphics.Bitmap; +import android.support.v4.util.LruCache; + +import com.android.volley.toolbox.ImageLoader; + +/** + * Created by root on 20/4/17. + */ + +public class LruBitmapCache extends LruCache<String, Bitmap> implements + ImageLoader.ImageCache { + public static int getDefaultLruCacheSize() { + final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); + final int cacheSize = maxMemory / 8; + + return cacheSize; + } + + public LruBitmapCache() { + this(getDefaultLruCacheSize()); + } + + public LruBitmapCache(int sizeInKiloBytes) { + super(sizeInKiloBytes); + } + + @Override + protected int sizeOf(String key, Bitmap value) { + return value.getRowBytes() * value.getHeight() / 1024; + } + + @Override + public Bitmap getBitmap(String url) { + return get(url); + } + + @Override + public void putBitmap(String url, Bitmap bitmap) { + put(url, bitmap); + } +} diff --git a/app/src/main/res/drawable/bg_parent_rounded_corner.xml b/app/src/main/res/drawable/bg_parent_rounded_corner.xml new file mode 100644 index 0000000000000000000000000000000000000000..475f547550b913025b592e8374839e670c5f5fec --- /dev/null +++ b/app/src/main/res/drawable/bg_parent_rounded_corner.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <!-- view background color --> + <solid android:color="@color/feed_item_bg" > + </solid> + + <!-- view border color and width --> + <stroke + android:width="@dimen/feed_item_border_width" + android:color="@color/feed_item_border" > + </stroke> + + <!-- Here is the corner radius --> + <corners android:radius="@dimen/feed_item_corner_radius" > + </corners> + +</shape> diff --git a/app/src/main/res/layout/activity_municipal.xml b/app/src/main/res/layout/activity_municipal.xml new file mode 100644 index 0000000000000000000000000000000000000000..b4c94c116b081c6989d4d93de117c0458b67ba90 --- /dev/null +++ b/app/src/main/res/layout/activity_municipal.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <ListView + android:id="@+id/list" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:divider="@null" /> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_start_activty.xml b/app/src/main/res/layout/activity_start_activty.xml new file mode 100644 index 0000000000000000000000000000000000000000..2b8ac3622da33afc86aab1a755819dc600539c2f --- /dev/null +++ b/app/src/main/res/layout/activity_start_activty.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright 2016 Google Inc. All Rights Reserved. + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<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" + android:background="@android:color/holo_orange_light" + tools:context="com.mapps.seproject.StartActivty"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + + android:orientation="vertical"> + + <TextView + style="@style/WelcomeScreenHeaderTextStyle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="CLEAN INDIA" + android:textAlignment="center" /> + + <Button + android:id="@+id/user_entry" + style="@style/Widget.AppCompat.Button.Colored" + android:layout_width="200dp" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:text="PUBLIC" /> + + <Button + android:id="@+id/municipal_entry" + style="@style/Widget.AppCompat.Button.Colored" + android:layout_width="200dp" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:text="MUNICIPALITY" /> + </LinearLayout> +</FrameLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/feed_item.xml b/app/src/main/res/layout/feed_item.xml new file mode 100644 index 0000000000000000000000000000000000000000..f894e752b5b1463a1eaf6ee519f2e98865aa82d5 --- /dev/null +++ b/app/src/main/res/layout/feed_item.xml @@ -0,0 +1,84 @@ +<?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="match_parent" + android:background="@color/feed_bg" + android:orientation="vertical" > + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="fill_parent" + + android:layout_marginLeft="@dimen/feed_item_margin" + android:layout_marginRight="@dimen/feed_item_margin" + android:layout_marginTop="@dimen/feed_item_margin" + android:background="@drawable/bg_parent_rounded_corner" + android:orientation="vertical" + android:paddingBottom="@dimen/feed_item_padding_top_bottom" + android:paddingTop="@dimen/feed_item_padding_top_bottom" > + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingLeft="@dimen/feed_item_padding_left_right" + android:paddingRight="@dimen/feed_item_padding_left_right" > + + <com.android.volley.toolbox.NetworkImageView + android:id="@+id/profilePic" + android:layout_width="@dimen/feed_item_profile_pic" + android:layout_height="@dimen/feed_item_profile_pic" + android:scaleType="fitCenter" > + </com.android.volley.toolbox.NetworkImageView> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingLeft="@dimen/feed_item_profile_info_padd" > + + <TextView + android:id="@+id/name" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:textSize="@dimen/feed_item_profile_name" + android:textStyle="bold" /> + + <TextView + android:id="@+id/timestamp" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:textColor="@color/timestamp" + android:textSize="@dimen/feed_item_timestamp" /> + </LinearLayout> + </LinearLayout> + + <TextView + android:id="@+id/txtStatusMsg" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:paddingBottom="5dp" + android:paddingLeft="@dimen/feed_item_status_pad_left_right" + android:paddingRight="@dimen/feed_item_status_pad_left_right" + android:paddingTop="@dimen/feed_item_status_pad_top" /> + + <TextView + android:id="@+id/txtUrl" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:linksClickable="true" + android:paddingBottom="10dp" + android:paddingLeft="@dimen/feed_item_status_pad_left_right" + android:paddingRight="@dimen/feed_item_status_pad_left_right" + android:textColorLink="@color/link" /> + + <com.mapps.seproject.FeedImageView + android:id="@+id/feedImage1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/white" + android:scaleType="fitXY" + android:visibility="visible" /> + </LinearLayout> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml new file mode 100644 index 0000000000000000000000000000000000000000..d96fc3bac55fe224f29754f5dd6c8070aebe44fb --- /dev/null +++ b/app/src/main/res/menu/main.xml @@ -0,0 +1,10 @@ +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + + <item + android:id="@+id/action_settings" + android:orderInCategory="100" + app:showAsAction="never" + android:title="settings"/> + +</menu> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index fbe1e871c820d8ea84ef45426f27af2346a72a54..751b56336f5674ed717897e0af7722a7f2841f68 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,4 +3,10 @@ <color name="colorPrimary">#3f51b5</color> <color name="colorPrimaryDark">#303F9F</color> <color name="colorAccent">#ff4081</color> + <color name="white">#ffffff</color> + <color name="feed_bg">#d3d6db</color> + <color name="feed_item_bg">#ffffff</color> + <color name="feed_item_border">#c2c3c8</color> + <color name="link">#0a80d1</color> + <color name="timestamp">#a0a3a7</color> </resources> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 47c82246738c4d056e8030d3a259206f42e8e15d..fce28cce495dfc35f1a0ca48626e69a27be6844f 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,5 +1,19 @@ <resources> <!-- Default screen margins, per the Android Design guidelines. --> - <dimen name="activity_horizontal_margin">16dp</dimen> + +<dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen> + + + <dimen name="feed_item_margin">10dp</dimen> + <dimen name="feed_item_padding_top_bottom">20dp</dimen> + <dimen name="feed_item_padding_left_right">15dp</dimen> + <dimen name="feed_item_profile_pic">50dp</dimen> + <dimen name="feed_item_profile_info_padd">10dp</dimen> + <dimen name="feed_item_profile_name">15dp</dimen> + <dimen name="feed_item_timestamp">13dp</dimen> + <dimen name="feed_item_status_pad_left_right">15dp</dimen> + <dimen name="feed_item_status_pad_top">13dp</dimen> + <dimen name="feed_item_corner_radius">3dp</dimen> + <dimen name="feed_item_border_width">1dp</dimen> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 5885930df6d10edf3d6df40d6556297d11f953da..3d69665412fd77d0dfbb6b12dd818c76dd1d62f0 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -8,4 +8,11 @@ <item name="colorAccent">@color/colorAccent</item> </style> + <style name="WelcomeScreenHeaderTextStyle"> + <item name="android:textSize">50sp</item> + <item name="android:textColor">@android:color/white</item> + <item name="android:textStyle">bold</item> + <item name="android:layout_marginBottom">60dp</item> + </style> + </resources>