Skip to content

Commit 7ca10d2

Browse files
committed
V:1.3.5.0.
Mocks perfil + Notification changes + Histories modification arguments.
1 parent 128c534 commit 7ca10d2

18 files changed

+409
-120
lines changed

TALLER2/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ android {
88
versionCode 1
99
versionName "1.0"
1010
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
11+
//applicationId "com.example.fernandon.android_client.TALLER2.AppMain"
1112
}
1213
buildTypes {
1314
release {

TALLER2/src/main/AndroidManifest.xml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="com.example.fernandon.android_client.TALLER2"> <!-- To auto-complete the email text field in the login form with the user's emails -->
45
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
56
<uses-permission android:name="android.permission.READ_PROFILE"/>
67
<uses-permission android:name="android.permission.READ_CONTACTS"/>
78
<uses-permission android:name="android.permission.INTERNET"/>
89
<application
9-
android:name=".AppMain">
10+
android:name=".AppMain"
11+
android:theme="@style/AppTheme"
12+
android:supportsRtl="true">
13+
1014
<meta-data android:name="com.facebook.sdk.ApplicationId"
11-
android:value="@string/facebook_app_id"/>
15+
android:value="@string/app_id_face"/>
16+
17+
<!--provider android:authorities="com.facebook.app.FacebookContentProvider188344395278473"
18+
tools:replace="android:authorities"
19+
android:name="com.facebook.FacebookContentProvider"
20+
android:exported="true"/-->
1221
<activity
1322
android:name=".LoginActivity"
1423
android:label="@string/app_name">
@@ -29,7 +38,7 @@
2938
</activity>
3039
<activity
3140
android:name=".MainActivity"
32-
android:label="@string/title_activity_main"
41+
android:label=" "
3342
android:theme="@style/AppTheme.NoActionBar">
3443
<intent-filter android:order="1">
3544
<action android:name="android.intent.action.VIEW"/>
@@ -43,7 +52,7 @@
4352
</activity>
4453
<activity
4554
android:name=".MiPerfilActivity"
46-
android:label="@string/title_activity_mi_perfil"
55+
android:label=" "
4756
android:theme="@style/AppTheme.NoActionBar">
4857
<intent-filter android:order="1">
4958
<action android:name="android.intent.action.VIEW"/>

TALLER2/src/main/java/com/example/fernandon/android_client/TALLER2/MainActivity.java

Lines changed: 56 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@
3434
import com.example.fernandon.android_client.TALLER2.model.ListadoHistoriasFragment;
3535
import com.example.fernandon.android_client.TALLER2.model.ListadoNotificacionesFragment;
3636
import com.example.fernandon.android_client.TALLER2.model.Notificacion;
37+
import com.example.fernandon.android_client.TALLER2.model.PerfilFragment;
3738

3839
public class MainActivity extends AppCompatActivity implements SearchView.OnQueryTextListener,
3940
ListadoAmistadesFragment.AmistadesListListener,
4041
ListadoHistoriasFragment.HistoriasListListener,
4142
ListadoConversacionesFragment.ConversacionesListListener,
4243
ListadoNotificacionesFragment.NotificacionesListListener{
4344

44-
//private SectionsPagerAdapter mAdapter;
45-
//private ActionBar actionBar;
4645
private SectionsPagerAdapter mSectionsPagerAdapter;
4746
private ViewPager mViewPager;
4847

@@ -61,29 +60,53 @@ protected void onCreate(Bundle savedInstanceState) {
6160
mViewPager = (ViewPager) findViewById(R.id.container);
6261
mViewPager.setAdapter(mSectionsPagerAdapter);
6362

63+
ImageButton b_menu = findViewById( R.id.buttonMenu );
64+
b_menu.setOnClickListener(new View.OnClickListener(){
65+
@Override
66+
public void onClick(View view){
67+
goMenu();
68+
}
69+
});
70+
ImageButton b_chat = findViewById( R.id.buttonChat );
71+
b_chat.setOnClickListener(new View.OnClickListener(){
72+
@Override
73+
public void onClick(View view){
74+
goChat();
75+
}
76+
});
77+
78+
ImageButton b_amigos = findViewById( R.id.buttonAmigos );
79+
b_amigos.setOnClickListener(new View.OnClickListener(){
80+
@Override
81+
public void onClick(View view){
82+
goAmistades();
83+
}
84+
});
85+
86+
ImageButton b_notif = findViewById( R.id.buttonNotificaciones );
87+
b_notif.setOnClickListener(new View.OnClickListener(){
88+
@Override
89+
public void onClick(View view){
90+
goNotif();
91+
}
92+
});
93+
6494
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
6595
fab.setOnClickListener(new View.OnClickListener() {
6696
@Override
6797
public void onClick(View view) {
68-
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
69-
.setAction("Action", null).show();
98+
// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
99+
// .setAction("Action", null).show();
70100
}
71101
});
72102

73103
}
74104

75-
public void goMenu(){
76-
Intent intent = new Intent(this, LoginActivity.class);
77-
startActivity(intent);
78-
}
79-
public void goChat(){
80-
Intent intent = new Intent(this, LoginActivity.class);
81-
startActivity(intent);
82-
}
83-
public void goNotif(){
84-
Intent intent = new Intent(this, LoginActivity.class);
85-
startActivity(intent);
86-
}
105+
public void goMenu(){ mViewPager.setCurrentItem(0); }
106+
public void goAmistades(){ mViewPager.setCurrentItem(1); }
107+
public void goNotif(){ mViewPager.setCurrentItem(2); }
108+
public void goChat(){ mViewPager.setCurrentItem(3); }
109+
87110

88111

89112
@Override
@@ -99,17 +122,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
99122
// automatically handle clicks on the Home/Up button, so long
100123
// as you specify a parent activity in AndroidManifest.xml.
101124
int id = item.getItemId();
125+
if (id == R.id.buttonChat) {goChat(); return true;}
126+
if (id == R.id.buttonNotificaciones) {goNotif(); return true;}
127+
if (id == R.id.buttonAmigos) {goAmistades(); return true;}
128+
if (id == R.id.buttonMenu) {goMenu(); return true;}
129+
if (id == R.id.action_logout) {exit(); return true;}
102130

103-
if (id == R.id.action_logout){
104-
exit();
105-
return true;
106-
107-
}
108-
/*if (id == R.id.action_perfil) {
109-
goPerfil();
110-
return true;
111-
}*/
112-
131+
//if (id == R.id.action_perfil) {goPerfil(); return true; }
113132
return super.onOptionsItemSelected(item);
114133
}
115134

@@ -134,29 +153,24 @@ public boolean onQueryTextChange(String newText) {
134153

135154
@Override
136155
public void onAmistadClicked(Amistad amistad) {
137-
Intent intent = new Intent();
138-
intent.setClass(this, MiPerfilActivity.class);
139-
startActivity(intent);
140156
}
141157

142158
@Override
143159
public void onHistoriaClicked(Historia historia) {
144-
Intent intent = new Intent();
145-
intent.setClass(this, MiPerfilActivity.class);
146-
startActivity(intent);
147160
}
148161
@Override
149-
public void onAmistadClicked(Conversacion conversacion){
150-
Intent intent = new Intent();
151-
intent.setClass(this, MiPerfilActivity.class);
152-
startActivity(intent);
162+
public void onConversacionClickedRechazar(Conversacion conversacion){
163+
String rechazar = "rechazo";
164+
conversacion.notify();
165+
}
166+
@Override
167+
public void onConversacionClickedAceptar(Conversacion conversacion){
153168
}
154-
155169
@Override
156170
public void onNotificacionClicked(Notificacion notificacion) {
157-
Intent intent = new Intent();
158-
intent.setClass(this, MiPerfilActivity.class);
159-
startActivity(intent);
171+
// Intent intent = new Intent();
172+
// intent.setClass(this, MiPerfilActivity.class);
173+
// startActivity(intent);
160174
}
161175

162176
/**
@@ -188,59 +202,13 @@ public static PlaceholderFragment newInstance(int sectionNumber) {
188202
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
189203

190204
final View rootView = inflater.inflate(R.layout.fragment_main, container, false);
191-
192205
ImageButton b_menu = (ImageButton) rootView.findViewById(R.id.buttonMenu);
193206
b_menu.setOnClickListener(new View.OnClickListener() {
194207
@Override
195208
public void onClick(View v) {
196-
LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.menu_cambiante);
197-
ll.removeAllViews();
198-
ll.addView( getLayoutInflater().inflate(R.layout.activity_historias, null));
209+
v.setVisibility(View.GONE);
199210
}
200211
});
201-
202-
ImageButton b_amigos = (ImageButton) rootView.findViewById(R.id.buttonAmigos);
203-
b_amigos.setOnClickListener(new View.OnClickListener() {
204-
@Override
205-
public void onClick(View v) {
206-
LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.menu_cambiante);
207-
ll.removeAllViews();
208-
ll.addView( getLayoutInflater().inflate(R.layout.activity_amistades_nuevas, null));
209-
}
210-
});
211-
212-
ImageButton b_notificaciones = (ImageButton) rootView.findViewById(R.id.buttonNotificaciones);
213-
b_notificaciones.setOnClickListener(new View.OnClickListener() {
214-
@Override
215-
public void onClick(View v) {
216-
LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.menu_cambiante);
217-
ll.removeAllViews();
218-
ll.addView( getLayoutInflater().inflate(R.layout.activity_opciones, null));
219-
}
220-
});
221-
222-
ImageButton b_chat = (ImageButton) rootView.findViewById(R.id.buttonChat);
223-
b_chat.setOnClickListener(new View.OnClickListener() {
224-
@Override
225-
public void onClick(View v) {
226-
LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.menu_cambiante);
227-
ll.removeAllViews();
228-
ll.addView( getLayoutInflater().inflate(R.layout.activity_conversaciones, null));
229-
230-
}
231-
});
232-
233-
// ImageButton b_options = (ImageButton) rootView.findViewById(R.id.buttonOptions);
234-
// b_options.setOnClickListener(new View.OnClickListener() {
235-
// @Override
236-
// public void onClick(View v) {
237-
// LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.menu_cambiante);
238-
// ll.removeAllViews();
239-
// ll.addView( getLayoutInflater().inflate(R.layout.activity_opciones, null));
240-
// }
241-
// });
242-
243-
244212
return rootView;
245213

246214
}
@@ -249,10 +217,7 @@ public void pantallaPPAL(){
249217
Intent intent = new Intent(this, MiPerfilActivity.class);
250218
startActivity(intent);
251219
}
252-
/**
253-
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
254-
* one of the sections/tabs/pages.
255-
*/
220+
256221
public class SectionsPagerAdapter extends FragmentPagerAdapter {
257222

258223
public SectionsPagerAdapter(FragmentManager fm) {

TALLER2/src/main/java/com/example/fernandon/android_client/TALLER2/adapters/ConversacionListAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public void onBindViewHolder(ConversacionesViewHolder holder, int position) {
6565
holder.mView.setOnClickListener(new View.OnClickListener() {
6666
@Override
6767
public void onClick(View v) {
68-
mConversacionesListListener.onAmistadClicked(conversacion);
68+
mConversacionesListListener.onConversacionClickedRechazar(conversacion);
69+
mConversacionesListListener.onConversacionClickedAceptar(conversacion);
6970
}
7071
});
7172
}

TALLER2/src/main/java/com/example/fernandon/android_client/TALLER2/adapters/NotificacionesListAdapter.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.example.fernandon.android_client.TALLER2.adapters;
22

3+
import android.graphics.Bitmap;
4+
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
5+
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
36
import android.support.v7.widget.RecyclerView;
47
import android.view.LayoutInflater;
58
import android.view.View;
@@ -56,7 +59,17 @@ public NotificacionesListAdapter.NotificacionesViewHolder onCreateViewHolder(Vie
5659
public void onBindViewHolder(NotificacionesViewHolder holder, int position) {
5760
final Notificacion notificacion = mNotificaciones.get(position);
5861

59-
holder.mPicture.setImageBitmap(notificacion.getPicture());
62+
Bitmap originalBitmap = notificacion.getPicture();
63+
if (originalBitmap.getWidth() > originalBitmap.getHeight()){
64+
originalBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, originalBitmap.getHeight(), originalBitmap.getHeight());
65+
}else if (originalBitmap.getWidth() < originalBitmap.getHeight()) {
66+
originalBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, originalBitmap.getWidth(), originalBitmap.getWidth());
67+
}
68+
RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(
69+
holder.mView.getContext().getResources(), originalBitmap);
70+
roundedDrawable.setCornerRadius(originalBitmap.getHeight());
71+
72+
holder.mPicture.setImageDrawable(roundedDrawable);
6073
holder.mTitulo.setText(notificacion.getmTitulo());
6174
holder.mDescripcion.setText(notificacion.getDescription());
6275

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package com.example.fernandon.android_client.TALLER2.adapters;
2+
3+
import android.support.v7.widget.RecyclerView;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.ImageView;
8+
import android.widget.TextView;
9+
import com.example.fernandon.android_client.TALLER2.R;
10+
import com.example.fernandon.android_client.TALLER2.model.Perfil;
11+
import com.example.fernandon.android_client.TALLER2.model.PerfilFragment;
12+
//import com.example.fernandon.android_client.TALLER2.model.Amistad;
13+
//import com.example.fernandon.android_client.TALLER2.model.ListadoAmistadesFragment;
14+
15+
import java.util.List;
16+
17+
/**
18+
* Created by FernandoN on 18/04/2018.
19+
*/
20+
21+
public class PerfilListAdapter extends RecyclerView.Adapter<PerfilListAdapter.PerfilViewHolder>{
22+
23+
private final PerfilFragment.PerfilListener mPerfilListener;
24+
private List<Perfil> mPerfiles;
25+
26+
public PerfilListAdapter(List<Perfil> perfiles, PerfilFragment.PerfilListener listener){
27+
mPerfiles = perfiles;
28+
mPerfilListener = listener;
29+
}
30+
31+
public static class PerfilViewHolder extends RecyclerView.ViewHolder {
32+
private final View mView;
33+
private final ImageView mPicture;
34+
private final TextView mName;
35+
36+
PerfilViewHolder(View itemView) {
37+
super(itemView);
38+
mView = itemView;
39+
mPicture = (ImageView) itemView.findViewById(R.id.id_imagencontactonuevo);
40+
mName = (TextView) itemView.findViewById(R.id.id_nomcontactonuevo);
41+
}
42+
}
43+
44+
@Override
45+
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
46+
super.onAttachedToRecyclerView(recyclerView);
47+
}
48+
49+
@Override
50+
public PerfilViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
51+
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_contacto_pendiente, parent, false);
52+
// AmistadesViewHolder amistadesViewHolder = new AmistadesViewHolder(parent.getChildAt(0));
53+
PerfilViewHolder perfilViewHolder = new PerfilViewHolder(v);
54+
return perfilViewHolder;
55+
}
56+
57+
@Override
58+
public void onBindViewHolder(PerfilViewHolder holder, int position) {
59+
final Perfil perfil = mPerfiles.get(position);
60+
holder.mPicture.setImageBitmap(perfil.getPicture());
61+
holder.mName.setText(perfil.getNombre());
62+
63+
64+
holder.mView.setOnClickListener(new View.OnClickListener() {
65+
@Override
66+
public void onClick(View v) {
67+
mPerfilListener.onPerfilClicked(perfil);
68+
}
69+
});
70+
}
71+
72+
@Override
73+
public int getItemCount() {
74+
return mPerfiles.size();
75+
}
76+
}

TALLER2/src/main/java/com/example/fernandon/android_client/TALLER2/model/ListadoConversacionesFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public class ListadoConversacionesFragment extends Fragment {
2020

2121

2222
public interface ConversacionesListListener {
23-
void onAmistadClicked(Conversacion conversacion);
23+
void onConversacionClickedRechazar(Conversacion conversacion);
24+
void onConversacionClickedAceptar(Conversacion conversacion);
2425
}
2526

2627
public ListadoConversacionesFragment() {

0 commit comments

Comments
 (0)