Commit 15a10478 authored by ankitasingh's avatar ankitasingh

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/app.iml
#	app/build.gradle
#	app/src/main/AndroidManifest.xml
#	app/src/main/res/values/strings.xml
parents 099f153a 6f5876de
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".RedirectMyPosts"></activity>
<activity android:name=".ItemDetails" /> <activity android:name=".ItemDetails" />
<activity android:name=".MyPosts" /> <activity android:name=".MyPosts" />
<activity <activity
......
...@@ -3,45 +3,50 @@ package com.example.instilostandfound; ...@@ -3,45 +3,50 @@ package com.example.instilostandfound;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
public class ItemDetails extends AppCompatActivity implements View.OnClickListener { public class ItemDetails extends AppCompatActivity implements View.OnClickListener {
String category, name, key; String category, name, key;
int type; int type;
Bundle details_bundle;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_details); setContentView(R.layout.activity_item_details);
Intent intent = getIntent(); Intent intent = getIntent();
category = intent.getStringExtra("category"); details_bundle = intent.getExtras();
name = intent.getStringExtra("name");
key = intent.getStringExtra("key"); ((TextView)findViewById(R.id.category)).setText(details_bundle.getString("category"));
type = intent.getIntExtra("type",-1); ((TextView)findViewById(R.id.name)).setText(details_bundle.getString("name"));
TextView cat_row = (TextView) findViewById(R.id.category); ((TextView) findViewById(R.id.place)).setText(details_bundle.getString("place"));
cat_row.setText(category); ((TextView) findViewById(R.id.description)).setText(details_bundle.getString("description"));
TextView name_row = (TextView) findViewById(R.id.name); ((TextView) findViewById(R.id.date)).setText(details_bundle.getString("date"));
name_row.setText(name);
findViewById(R.id.edit_post).setOnClickListener(this);
findViewById(R.id.resolve_post).setOnClickListener(this);
} }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()){ switch (v.getId()){
case R.id.edit_post: case R.id.edit_post:
if(type == 0){ if(details_bundle.getString("type").equals("lost")){
Intent intent = new Intent(ItemDetails.this, LostItem.class); Intent intent = new Intent(ItemDetails.this, LostItem.class);
intent.putExtra("key", key); intent.putExtras(details_bundle);
startActivity(intent); startActivity(intent);
} }
else if(type == 1){ else if(details_bundle.getString("type").equals("found")){
Intent intent = new Intent(ItemDetails.this, FoundItem.class); Intent intent = new Intent(ItemDetails.this, FoundItem.class);
intent.putExtra("key", key); intent.putExtras(details_bundle);
startActivity(intent); startActivity(intent);
} }
Log.d("..................", "hiiiiiiiiiii");
break; break;
case R.id.resolve_post: case R.id.resolve_post:
break; break;
......
...@@ -10,30 +10,99 @@ import android.widget.ArrayAdapter; ...@@ -10,30 +10,99 @@ import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast; import android.widget.Toast;
public class MyPosts extends AppCompatActivity { import java.util.ArrayList;
String items[] = new String[] {"apple", "banana"}; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MyPosts extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_posts); setContentView(R.layout.activity_my_posts);
ListView listView = (ListView) findViewById(R.id.listview); final List<Map<String, String>> of = new ArrayList<Map<String, String>>();
final List<Map<String, String>> ol = new ArrayList<Map<String, String>>();
Map<String, String> of1 = new HashMap<String, String>();
of1.put("key", "123");
of1.put("category","electronics");
of1.put("name","Phone");
of1.put("description","Lenovo Z+. Black colour.");
of1.put("date","28th Oct 2019");
of1.put("type","found");
of1.put("place","CC103");
of.add(of1);
Map<String, String> of2 = new HashMap<String, String>();
of2.put("key", "456");
of2.put("category","money");
of2.put("name","wallet");
of2.put("description","green colour baggit");
of2.put("date","28th Oct 2019");
of2.put("type","lost");
of2.put("place","sic201");
ol.add(of2);
final Intent intent = getIntent();
ListView listView = (ListView) findViewById(R.id.listviewlost);
if(intent.getStringExtra("type").equals("lost")){
String ol_names[] = new String[ol.size()];
for(int i=0; i<ol.size();i++){
ol_names[i] = ol.get(i).get("name");
}
ArrayAdapter<String> adaptor = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, ol_names);
listView.setAdapter(adaptor);
}
else if(intent.getStringExtra("type").equals("found")){
String of_names[] = new String[of.size()];
for(int i=0; i<of.size();i++){
of_names[i] = of.get(i).get("name");
}
ArrayAdapter<String> adaptor = new ArrayAdapter<String>(this, ArrayAdapter<String> adaptor = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items); android.R.layout.simple_list_item_1, of_names);
listView.setAdapter(adaptor); listView.setAdapter(adaptor);
}
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(MyPosts.this, items[position], Toast.LENGTH_SHORT).show(); Intent intent1 = new Intent(MyPosts.this, ItemDetails.class);
Intent intent = new Intent(MyPosts.this, ItemDetails.class); if(intent.getStringExtra("type").equals(("found"))){
intent.putExtra("category", "Electronics");
intent.putExtra("name", "Phone"); intent1.putExtra("category", "Electronics");
intent.putExtra("key", "123"); intent1.putExtra("name", of.get(position).get("name"));
intent.putExtra("type", 1); intent1.putExtra("place", of.get(position).get("place"));
startActivity(intent); intent1.putExtra("description", of.get(position).get("description"));
intent1.putExtra("date", of.get(position).get("date"));
intent1.putExtra("key", of.get(position).get("key"));
intent1.putExtra("type", of.get(position).get("type"));
}
else if(intent.getStringExtra("type").equals(("lost"))){
intent1.putExtra("category", "Electronics");
intent1.putExtra("name", ol.get(position).get("name"));
intent1.putExtra("place", ol.get(position).get("place"));
intent1.putExtra("description", ol.get(position).get("description"));
intent1.putExtra("date", ol.get(position).get("date"));
intent1.putExtra("key", ol.get(position).get("key"));
intent1.putExtra("type", ol.get(position).get("type"));
}
startActivity(intent1);
} }
}); });
} }
} }
...@@ -71,7 +71,8 @@ public class Navigation extends AppCompatActivity implements NavigationView.OnNa ...@@ -71,7 +71,8 @@ public class Navigation extends AppCompatActivity implements NavigationView.OnNa
startActivity(getIntent()); startActivity(getIntent());
break; break;
case R.id.my_posts: case R.id.my_posts:
intent = new Intent(this, MyPosts.class); intent = new Intent(this, RedirectMyPosts.class);
intent.putExtra("username", username);
startActivity(intent); startActivity(intent);
break; break;
case R.id.logout: case R.id.logout:
......
package com.example.instilostandfound;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class RedirectMyPosts extends AppCompatActivity implements View.OnClickListener {
String username;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_redirect_my_posts);
Intent i = getIntent();
username = i.getStringExtra("username");
findViewById(R.id.lost_button).setOnClickListener(this);
findViewById(R.id.found_button).setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.lost_button:
Intent intent = new Intent(RedirectMyPosts.this, MyPosts.class);
intent.putExtra("type", "lost");
intent.putExtra("username", username);
startActivity(intent);
break;
case R.id.found_button:
intent = new Intent(RedirectMyPosts.this, MyPosts.class);
intent.putExtra("username", username);
intent.putExtra("type", "found");
startActivity(intent);
break;
}
}
}
...@@ -52,6 +52,63 @@ ...@@ -52,6 +52,63 @@
android:text="" /> android:text="" />
</TableRow> </TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="114dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="Place" />
<TextView
android:id="@+id/place"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="114dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="Description" />
<TextView
android:id="@+id/description"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="114dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="Date" />
<TextView
android:id="@+id/date"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="" />
</TableRow>
</TableLayout> </TableLayout>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<ListView <ListView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/listview"> android:id="@+id/listviewlost">
</ListView> </ListView>
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RedirectMyPosts"
android:background="@drawable/myposts_bg">
<Button
android:id="@+id/lost_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="150dp"
android:layout_marginBottom="100dp"
android:background="@color/colorPrimary"
android:textColor="@color/cardview_light_background"
android:text="Lost"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="@+id/found_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="140dp"
android:layout_marginBottom="24dp"
android:text="Found"
android:background="@color/colorPrimary"
android:textColor="@color/cardview_light_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
...@@ -19,5 +19,7 @@ ...@@ -19,5 +19,7 @@
<string name="my_posts">My Posts</string> <string name="my_posts">My Posts</string>
<string name="logout">Logout</string> <string name="logout">Logout</string>
<string name="title_activity_camera">Camera</string> <string name="title_activity_camera">Camera</string>
<string name="title_activity_test">test</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment