Commit 15180ba73e8e06ebd2574957f5cf5bda05b87d28

Authored by geraldo morais
1 parent b4cc0803
Exists in master

Modificado os botoes de voto

Showing 47 changed files with 604 additions and 75 deletions   Show diff stats
app/app.iml
... ... @@ -120,45 +120,45 @@
120 120 </content>
121 121 <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
122 122 <orderEntry type="sourceFolder" forTests="false" />
123   - <orderEntry type="library" exported="" name="play-services-wallet-7.5.0" level="project" />
124   - <orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
125   - <orderEntry type="library" exported="" name="play-services-cast-7.5.0" level="project" />
126   - <orderEntry type="library" exported="" name="mediarouter-v7-22.0.0" level="project" />
127   - <orderEntry type="library" exported="" name="recyclerview-v7-22.2.0" level="project" />
128   - <orderEntry type="library" exported="" name="play-services-drive-7.5.0" level="project" />
129   - <orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
130   - <orderEntry type="library" exported="" name="play-services-analytics-7.5.0" level="project" />
131   - <orderEntry type="library" exported="" name="play-services-panorama-7.5.0" level="project" />
132   - <orderEntry type="library" exported="" name="materialdrawer-3.0.6" level="project" />
133   - <orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
134   - <orderEntry type="library" exported="" name="play-services-appindexing-7.5.0" level="project" />
135   - <orderEntry type="library" exported="" name="play-services-location-7.5.0" level="project" />
136   - <orderEntry type="library" exported="" name="Parse-1.9.2" level="project" />
137   - <orderEntry type="library" exported="" name="play-services-ads-7.5.0" level="project" />
138   - <orderEntry type="library" exported="" name="play-services-safetynet-7.5.0" level="project" />
139   - <orderEntry type="library" exported="" name="play-services-base-7.5.0" level="project" />
140   - <orderEntry type="library" exported="" name="play-services-7.5.0" level="project" />
141   - <orderEntry type="library" exported="" name="play-services-gcm-7.5.0" level="project" />
142   - <orderEntry type="library" exported="" name="bolts-android-1.2.0" level="project" />
143   - <orderEntry type="library" exported="" name="play-services-appinvite-7.5.0" level="project" />
  123 + <orderEntry type="library" exported="" name="design-22.2.0" level="project" />
144 124 <orderEntry type="library" exported="" name="iconics-1.0.2" level="project" />
145   - <orderEntry type="library" exported="" name="fabric-1.3.4" level="project" />
146   - <orderEntry type="library" exported="" name="beta-1.1.3" level="project" />
147   - <orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
148   - <orderEntry type="library" exported="" name="universal-image-loader-1.9.3" level="project" />
  125 + <orderEntry type="library" exported="" name="play-services-base-7.5.0" level="project" />
149 126 <orderEntry type="library" exported="" name="crashlytics-core-2.3.3" level="project" />
150   - <orderEntry type="library" exported="" name="play-services-fitness-7.5.0" level="project" />
151   - <orderEntry type="library" exported="" name="play-services-nearby-7.5.0" level="project" />
  127 + <orderEntry type="library" exported="" name="Parse-1.9.2" level="project" />
  128 + <orderEntry type="library" exported="" name="play-services-appinvite-7.5.0" level="project" />
  129 + <orderEntry type="library" exported="" name="play-services-panorama-7.5.0" level="project" />
  130 + <orderEntry type="library" exported="" name="play-services-drive-7.5.0" level="project" />
152 131 <orderEntry type="library" exported="" name="crashlytics-2.4.0" level="project" />
153   - <orderEntry type="library" exported="" name="play-services-plus-7.5.0" level="project" />
  132 + <orderEntry type="library" exported="" name="answers-1.2.2" level="project" />
  133 + <orderEntry type="library" exported="" name="play-services-gcm-7.5.0" level="project" />
  134 + <orderEntry type="library" exported="" name="play-services-appindexing-7.5.0" level="project" />
  135 + <orderEntry type="library" exported="" name="MPAndroidChart-v2.1.0" level="project" />
154 136 <orderEntry type="library" exported="" name="play-services-wearable-7.5.0" level="project" />
155   - <orderEntry type="library" exported="" name="play-services-appstate-7.5.0" level="project" />
  137 + <orderEntry type="library" exported="" name="play-services-safetynet-7.5.0" level="project" />
156 138 <orderEntry type="library" exported="" name="play-services-games-7.5.0" level="project" />
157   - <orderEntry type="library" exported="" name="play-services-identity-7.5.0" level="project" />
158   - <orderEntry type="library" exported="" name="MPAndroidChart-v2.1.0" level="project" />
159   - <orderEntry type="library" exported="" name="answers-1.2.2" level="project" />
160   - <orderEntry type="library" exported="" name="design-22.2.0" level="project" />
  139 + <orderEntry type="library" exported="" name="universal-image-loader-1.9.3" level="project" />
  140 + <orderEntry type="library" exported="" name="fabric-1.3.4" level="project" />
  141 + <orderEntry type="library" exported="" name="play-services-plus-7.5.0" level="project" />
161 142 <orderEntry type="library" exported="" name="play-services-maps-7.5.0" level="project" />
  143 + <orderEntry type="library" exported="" name="play-services-fitness-7.5.0" level="project" />
  144 + <orderEntry type="library" exported="" name="mediarouter-v7-22.0.0" level="project" />
  145 + <orderEntry type="library" exported="" name="play-services-7.5.0" level="project" />
  146 + <orderEntry type="library" exported="" name="play-services-analytics-7.5.0" level="project" />
  147 + <orderEntry type="library" exported="" name="play-services-wallet-7.5.0" level="project" />
  148 + <orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
  149 + <orderEntry type="library" exported="" name="play-services-identity-7.5.0" level="project" />
  150 + <orderEntry type="library" exported="" name="bolts-android-1.2.0" level="project" />
  151 + <orderEntry type="library" exported="" name="materialdrawer-3.0.6" level="project" />
  152 + <orderEntry type="library" exported="" name="recyclerview-v7-22.2.0" level="project" />
162 153 <orderEntry type="library" exported="" name="cardview-v7-22.2.0" level="project" />
  154 + <orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
  155 + <orderEntry type="library" exported="" name="play-services-appstate-7.5.0" level="project" />
  156 + <orderEntry type="library" exported="" name="play-services-nearby-7.5.0" level="project" />
  157 + <orderEntry type="library" exported="" name="beta-1.1.3" level="project" />
  158 + <orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
  159 + <orderEntry type="library" exported="" name="play-services-cast-7.5.0" level="project" />
  160 + <orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
  161 + <orderEntry type="library" exported="" name="play-services-ads-7.5.0" level="project" />
  162 + <orderEntry type="library" exported="" name="play-services-location-7.5.0" level="project" />
163 163 </component>
164 164 </module>
165 165 \ No newline at end of file
... ...
app/build.gradle
... ... @@ -21,7 +21,7 @@ android {
21 21  
22 22 defaultConfig {
23 23 applicationId "com.monitorabrasil.monitoramunicipio"
24   - minSdkVersion 15
  24 + minSdkVersion 16
25 25 targetSdkVersion 22
26 26 versionCode 4
27 27 versionName "0.4"
... ...
app/src/main/AndroidManifest.xml
... ... @@ -65,6 +65,18 @@
65 65 android:name="android.support.PARENT_ACTIVITY"
66 66 android:value="com.monitorabrasil.monitoralegislativo.MainActivity" />
67 67 </activity>
  68 + <activity
  69 + android:name=".PoliticoFichaActivity"
  70 + android:label="@string/title_activity_politico_ficha"
  71 + android:parentActivityName=".PoliticosActivity" >
  72 + <meta-data
  73 + android:name="android.support.PARENT_ACTIVITY"
  74 + android:value="com.monitorabrasil.monitoralegislativo.PoliticosActivity" />
  75 + </activity>
  76 + <activity
  77 + android:name=".ComentarioActivity"
  78 + android:label="@string/title_activity_comentario" >
  79 + </activity>
68 80 </application>
69 81  
70 82 </manifest>
... ...
app/src/main/ic_action_comment-web.png 0 → 100644

5.35 KB

app/src/main/ic_action_like_gray-web.png 0 → 100644

20.2 KB

app/src/main/ic_action_like_green-web.png 0 → 100644

14.8 KB

app/src/main/ic_action_unlike_gray-web.png 0 → 100644

20.2 KB

app/src/main/ic_action_unlike_red-web.png 0 → 100644

13.5 KB

app/src/main/java/com/monitorabrasil/monitoralegislativo/ComentarioActivity.java 0 → 100644
... ... @@ -0,0 +1,39 @@
  1 +package com.monitorabrasil.monitoralegislativo;
  2 +
  3 +import android.support.v7.app.ActionBarActivity;
  4 +import android.os.Bundle;
  5 +import android.view.Menu;
  6 +import android.view.MenuItem;
  7 +
  8 +import com.monitorabrasil.monitoralegislativo.R;
  9 +
  10 +public class ComentarioActivity extends ActionBarActivity {
  11 +
  12 + @Override
  13 + protected void onCreate(Bundle savedInstanceState) {
  14 + super.onCreate(savedInstanceState);
  15 + setContentView(R.layout.activity_comentario);
  16 + }
  17 +
  18 + @Override
  19 + public boolean onCreateOptionsMenu(Menu menu) {
  20 + // Inflate the menu; this adds items to the action bar if it is present.
  21 + getMenuInflater().inflate(R.menu.menu_comentario, menu);
  22 + return true;
  23 + }
  24 +
  25 + @Override
  26 + public boolean onOptionsItemSelected(MenuItem item) {
  27 + // Handle action bar item clicks here. The action bar will
  28 + // automatically handle clicks on the Home/Up button, so long
  29 + // as you specify a parent activity in AndroidManifest.xml.
  30 + int id = item.getItemId();
  31 +
  32 + //noinspection SimplifiableIfStatement
  33 + if (id == R.id.action_settings) {
  34 + return true;
  35 + }
  36 +
  37 + return super.onOptionsItemSelected(item);
  38 + }
  39 +}
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/PoliticoFichaActivity.java 0 → 100644
... ... @@ -0,0 +1,142 @@
  1 +package com.monitorabrasil.monitoralegislativo;
  2 +
  3 +import android.content.res.Configuration;
  4 +import android.support.design.widget.CollapsingToolbarLayout;
  5 +import android.support.design.widget.CoordinatorLayout;
  6 +import android.support.design.widget.FloatingActionButton;
  7 +import android.support.design.widget.Snackbar;
  8 +import android.support.v4.app.FragmentTransaction;
  9 +import android.support.v4.widget.DrawerLayout;
  10 +import android.support.v7.app.ActionBarDrawerToggle;
  11 +import android.support.v7.app.AppCompatActivity;
  12 +import android.os.Bundle;
  13 +import android.support.v7.widget.Toolbar;
  14 +import android.view.Menu;
  15 +import android.view.MenuItem;
  16 +import android.view.View;
  17 +
  18 +import com.monitorabrasil.monitoralegislativo.R;
  19 +import com.monitorabrasil.monitoralegislativo.fragments.GastosFragment;
  20 +import com.parse.ParseObject;
  21 +import com.parse.ParseQuery;
  22 +
  23 +public class PoliticoFichaActivity extends AppCompatActivity {
  24 +
  25 + Toolbar toolbar;
  26 + CollapsingToolbarLayout collapsingToolbarLayout;
  27 +
  28 +
  29 +// ActionBarDrawerToggle drawerToggle;
  30 +
  31 + CoordinatorLayout rootLayout;
  32 + FloatingActionButton fabBtn;
  33 +
  34 + @Override
  35 + protected void onCreate(Bundle savedInstanceState) {
  36 + super.onCreate(savedInstanceState);
  37 + setContentView(R.layout.activity_politico_ficha);
  38 +
  39 + initToolbar();
  40 + initInstances();
  41 +
  42 + Bundle bundle = getIntent().getExtras();
  43 + buscaPolitico(bundle.getString("politico")) ;
  44 +
  45 + buscaGrafico();
  46 +
  47 +
  48 +
  49 + }
  50 +
  51 + private void buscaGrafico() {
  52 + GastosFragment gastos = new GastosFragment();
  53 + gastos.setArguments(getIntent().getExtras());
  54 + FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
  55 + ft.add(R.id.rl_fragment_container, gastos, "politicoFrag");
  56 + ft.commit();
  57 + }
  58 +
  59 + private ParseObject buscaPolitico(String id) {
  60 +
  61 + ParseQuery<ParseObject> query = ParseQuery.getQuery("Politico");
  62 + query.fromLocalDatastore();
  63 + try {
  64 + ParseObject politico = query.get(id);
  65 + collapsingToolbarLayout.setTitle(politico.get("nome").toString());
  66 + } catch (com.parse.ParseException e) {
  67 + e.printStackTrace();
  68 + }
  69 + return null;
  70 + }
  71 +
  72 + private void initToolbar() {
  73 + toolbar = (Toolbar) findViewById(R.id.toolbar);
  74 + setSupportActionBar(toolbar);
  75 + }
  76 +
  77 + private void initInstances() {
  78 +// drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
  79 +// drawerToggle = new ActionBarDrawerToggle(PoliticoFichaActivity.this, drawerLayout, R.string.hello_world, R.string.hello_world);
  80 +// drawerLayout.setDrawerListener(drawerToggle);
  81 +
  82 + getSupportActionBar().setHomeButtonEnabled(true);
  83 + getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  84 +
  85 + rootLayout = (CoordinatorLayout) findViewById(R.id.rootLayout);
  86 +
  87 + fabBtn = (FloatingActionButton) findViewById(R.id.fabBtn);
  88 + fabBtn.setOnClickListener(new View.OnClickListener() {
  89 + @Override
  90 + public void onClick(View v) {
  91 + Snackbar.make(rootLayout, "Hello. I am Snackbar!", Snackbar.LENGTH_SHORT)
  92 + .setAction("Undo", new View.OnClickListener() {
  93 + @Override
  94 + public void onClick(View v) {
  95 +
  96 + }
  97 + })
  98 + .show();
  99 + }
  100 + });
  101 +
  102 + collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbarLayout);
  103 +
  104 + }
  105 +
  106 + @Override
  107 + public void onPostCreate(Bundle savedInstanceState) {
  108 + super.onPostCreate(savedInstanceState);
  109 +// drawerToggle.syncState();
  110 + }
  111 +
  112 + @Override
  113 + public void onConfigurationChanged(Configuration newConfig) {
  114 + super.onConfigurationChanged(newConfig);
  115 +// drawerToggle.onConfigurationChanged(newConfig);
  116 + }
  117 +
  118 + @Override
  119 + public boolean onCreateOptionsMenu(Menu menu) {
  120 + // Inflate the menu; this adds items to the action bar if it is present.
  121 + getMenuInflater().inflate(R.menu.menu_main, menu);
  122 + return true;
  123 + }
  124 +
  125 + @Override
  126 + public boolean onOptionsItemSelected(MenuItem item) {
  127 +// if (drawerToggle.onOptionsItemSelected(item))
  128 +// return true;
  129 +
  130 + // Handle action bar item clicks here. The action bar will
  131 + // automatically handle clicks on the Home/Up button, so long
  132 + // as you specify a parent activity in AndroidManifest.xml.
  133 + int id = item.getItemId();
  134 +
  135 + //noinspection SimplifiableIfStatement
  136 + if (id == R.id.action_settings) {
  137 + return true;
  138 + }
  139 +
  140 + return super.onOptionsItemSelected(item);
  141 + }
  142 +}
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/adapters/ProjetoAdapter.java
1 1 package com.monitorabrasil.monitoralegislativo.adapters;
2 2  
  3 +import android.content.Intent;
  4 +import android.graphics.drawable.Drawable;
3 5 import android.support.design.widget.Snackbar;
  6 +import android.support.v4.content.ContextCompat;
4 7 import android.support.v7.widget.RecyclerView;
5 8 import android.view.LayoutInflater;
6 9 import android.view.View;
... ... @@ -8,9 +11,12 @@ import android.view.ViewGroup;
8 11 import android.widget.Button;
9 12 import android.widget.TextView;
10 13  
  14 +import com.monitorabrasil.monitoralegislativo.ComentarioActivity;
11 15 import com.monitorabrasil.monitoralegislativo.R;
  16 +import com.monitorabrasil.monitoralegislativo.application.MyApp;
12 17 import com.monitorabrasil.monitoralegislativo.interfaces.RecyclerViewOnClickListenerHack;
13 18 import com.parse.FindCallback;
  19 +import com.parse.GetCallback;
14 20 import com.parse.ParseException;
15 21 import com.parse.ParseObject;
16 22 import com.parse.ParseQuery;
... ... @@ -37,16 +43,24 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
37 43 public TextView data;
38 44 public TextView autor;
39 45 public TextView descricao;
  46 + public TextView numApoio;
  47 + public TextView numNaoApoio;
40 48 public Button btnConcordo;
41 49 public Button btnDiscordo;
  50 + public Button btnComentar;
  51 + public String voto;
  52 +
42 53 public ViewHolder(View v) {
43 54 super(v);
44 55 classificacao = (TextView) v.findViewById(R.id.classificacao);
45 56 data = (TextView) v.findViewById(R.id.data);
46 57 autor = (TextView) v.findViewById(R.id.autor);
  58 + numApoio = (TextView) v.findViewById(R.id.txtNumApoio);
  59 + numNaoApoio = (TextView) v.findViewById(R.id.txtNumNaoApoio);
47 60 descricao = (TextView) v.findViewById(R.id.descricao);
48 61 btnConcordo = (Button) v.findViewById(R.id.btnConcordo);
49 62 btnDiscordo = (Button) v.findViewById(R.id.btnDiscordo);
  63 + btnComentar = (Button) v.findViewById(R.id.btnComentar);
50 64  
51 65 itemView.setOnClickListener(this);
52 66 }
... ... @@ -75,6 +89,17 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
75 89  
76 90 @Override
77 91 public void onBindViewHolder(final ViewHolder viewHolder, int i) {
  92 + Drawable apoio = ContextCompat.getDrawable(MyApp.getInstance().getApplicationContext(), R.mipmap.ic_action_like_gray);
  93 + Drawable napoio = ContextCompat.getDrawable(MyApp.getInstance().getApplicationContext(), R.mipmap.ic_action_unlike_gray);
  94 + final Drawable napoioVermelho = ContextCompat.getDrawable(MyApp.getInstance().getApplicationContext(), R.mipmap.ic_action_unlike_red);
  95 + final Drawable apoioVerde = ContextCompat.getDrawable(MyApp.getInstance().getApplicationContext(), R.mipmap.ic_action_like_green);
  96 +
  97 + viewHolder.btnConcordo.setBackground(apoio);
  98 + viewHolder.btnDiscordo.setBackground(napoio);
  99 +
  100 + viewHolder.btnDiscordo.setEnabled(true);
  101 + viewHolder.btnConcordo.setEnabled(true);
  102 + viewHolder.voto = "sem_voto";
78 103 final ParseObject projeto = mDataset.get(i);
79 104 //verifica se ja votou
80 105 ParseQuery<ParseObject> query = ParseQuery.getQuery("Voto");
... ... @@ -83,13 +108,18 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
83 108 query.findInBackground(new FindCallback<ParseObject>() {
84 109 @Override
85 110 public void done(List<ParseObject> list, ParseException e) {
86   - if(list.size() > 0){
  111 + if (list.size() > 0) {
87 112 String voto = list.get(0).get("voto").toString();
88 113 viewHolder.projetoVotado = list.get(0);
89   - if(voto.equals("s")){
90   - viewHolder.btnConcordo.setText("Concordei");
91   - }else{
92   - viewHolder.btnDiscordo.setText("Discordei");
  114 + if (voto.equals("s")) {
  115 + viewHolder.btnConcordo .setBackground(apoioVerde);
  116 + viewHolder.btnConcordo.setEnabled(false);
  117 + viewHolder.voto = "apoioado";
  118 + ;
  119 + } else {
  120 + viewHolder.btnDiscordo.setBackground(napoioVermelho);
  121 + viewHolder.btnDiscordo.setEnabled(false);
  122 + viewHolder.voto = "nao_apoioado";
93 123 }
94 124 }
95 125 }
... ... @@ -99,6 +129,17 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
99 129 viewHolder.classificacao.setText(projeto.get("classificacao").toString());
100 130 viewHolder.data.setText(projeto.get("data").toString());
101 131 viewHolder.descricao.setText(projeto.get("descricao").toString());
  132 + int num=0;
  133 + if(projeto.get("apoio") != null){
  134 + num = Integer.valueOf( projeto.get("apoio").toString());
  135 + }
  136 +
  137 + viewHolder.numApoio.setText(String.valueOf(num));
  138 + num=0;
  139 + if(projeto.get("nao_apoio") != null){
  140 + num = Integer.valueOf( projeto.get("nao_apoio").toString());
  141 + }
  142 + viewHolder.numNaoApoio.setText(String.valueOf(num));
102 143 ParseObject autor = (ParseObject) projeto.get("politico");
103 144 try {
104 145 autor.fetchFromLocalDatastore();
... ... @@ -110,7 +151,7 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
110 151 viewHolder.btnConcordo.setOnClickListener(new View.OnClickListener() {
111 152 @Override
112 153 public void onClick(final View v) {
113   - registraVoto(v, projeto,"s",viewHolder);
  154 + registraVoto(v, projeto, "s", viewHolder);
114 155  
115 156 }
116 157 });
... ... @@ -121,9 +162,18 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
121 162 registraVoto(v, projeto, "n", viewHolder);
122 163 }
123 164 });
  165 +
  166 + viewHolder.btnComentar.setOnClickListener(new View.OnClickListener() {
  167 + @Override
  168 + public void onClick(View v) {
  169 + Intent mIntent =new Intent(MyApp.getInstance().getApplicationContext(), ComentarioActivity.class);
  170 + mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  171 + MyApp.getInstance().startActivity(mIntent);
  172 + }
  173 + });
124 174 }
125 175  
126   - private void registraVoto(final View v, ParseObject projeto, String tipoVoto, ViewHolder viewHolder2) {
  176 + private void registraVoto(final View v, ParseObject projeto, final String tipoVoto, final ViewHolder viewHolder2) {
127 177  
128 178 //verificar se esta logado
129 179 if(ParseUser.getCurrentUser() == null){
... ... @@ -132,11 +182,27 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
132 182 return;
133 183 }
134 184  
  185 + Drawable apoio = ContextCompat.getDrawable(MyApp.getInstance().getApplicationContext(), R.mipmap.ic_action_like_gray);
  186 + Drawable napoio = ContextCompat.getDrawable(MyApp.getInstance().getApplicationContext(), R.mipmap.ic_action_unlike_gray);
  187 + final Drawable napoioVermelho = ContextCompat.getDrawable(MyApp.getInstance().getApplicationContext(), R.mipmap.ic_action_unlike_red);
  188 + final Drawable apoioVerde = ContextCompat.getDrawable(MyApp.getInstance().getApplicationContext(), R.mipmap.ic_action_like_green);
  189 +
135 190 //verificar se ja votou nesse projeto
136   - if(viewHolder2.projetoVotado != null){
  191 + boolean votado;
  192 + if(viewHolder2.voto.equals("sem_voto")){
  193 +
  194 + votado = false;
  195 + }else{
  196 + votado=true;
  197 +
  198 + }
  199 + if(votado){
  200 +
  201 +
137 202 viewHolder2.projetoVotado.unpinInBackground();
138 203 viewHolder2.projetoVotado.deleteInBackground();
139 204  
  205 +
140 206 }
141 207  
142 208 ParseObject voto = new ParseObject("Voto");
... ... @@ -145,13 +211,33 @@ public class ProjetoAdapter extends RecyclerView.Adapter&lt;ProjetoAdapter.ViewHold
145 211 voto.put("voto", tipoVoto);
146 212 Button btnVoto = (Button) v;
147 213 if(tipoVoto.equals("s")){
  214 + if(votado){
  215 + viewHolder2.numNaoApoio.setText(String.valueOf(Integer.valueOf(viewHolder2.numNaoApoio.getText().toString()) - 1));
  216 + projeto.increment("nao_apoio", -1);
  217 + }
  218 + viewHolder2.numApoio.setText(String.valueOf(Integer.valueOf(viewHolder2.numApoio.getText().toString()) + 1));
  219 + projeto.increment("apoio");
  220 + btnVoto.setBackground(apoioVerde);
  221 + viewHolder2.btnDiscordo.setBackground(napoio);
  222 + viewHolder2.voto = "apoiado";
  223 + viewHolder2.btnConcordo.setEnabled(false);
  224 + viewHolder2.btnDiscordo.setEnabled(true);
148 225  
149   - btnVoto.setText("Concordei");
150   - viewHolder2.btnDiscordo.setText("Discordo");
151 226 }else{
152   - btnVoto.setText("Discordei");
153   - viewHolder2.btnConcordo.setText("Concordo");
  227 + if(votado){
  228 + viewHolder2.numApoio.setText(String.valueOf(Integer.valueOf(viewHolder2.numApoio.getText().toString()) - 1));
  229 + projeto.increment("apoio", -1);
  230 + }
  231 + projeto.increment("nao_apoio");
  232 + viewHolder2.numNaoApoio.setText(String.valueOf(Integer.valueOf(viewHolder2.numNaoApoio.getText().toString()) + 1));
  233 + btnVoto.setBackground(napoioVermelho);
  234 + viewHolder2.btnConcordo.setBackground(apoio);
  235 + viewHolder2.voto = "nao_apoiado";
  236 + viewHolder2.btnDiscordo.setEnabled(false);
  237 + viewHolder2.btnConcordo.setEnabled(true);
  238 +
154 239 }
  240 + projeto.saveInBackground();
155 241  
156 242 try {
157 243 voto.pin();
... ...
app/src/main/java/com/monitorabrasil/monitoralegislativo/fragments/ListaPoliticoFragment.java
1 1 package com.monitorabrasil.monitoralegislativo.fragments;
2 2  
  3 +import android.content.Intent;
3 4 import android.os.Bundle;
4 5 import android.support.v4.app.Fragment;
5 6 import android.support.v4.app.FragmentTransaction;
... ... @@ -13,6 +14,7 @@ import android.widget.ProgressBar;
13 14 import android.widget.Toast;
14 15  
15 16 import com.google.gson.Gson;
  17 +import com.monitorabrasil.monitoralegislativo.PoliticoFichaActivity;
16 18 import com.monitorabrasil.monitoralegislativo.R;
17 19 import com.monitorabrasil.monitoralegislativo.adapters.VereadorAdapter;
18 20 import com.monitorabrasil.monitoralegislativo.interfaces.RecyclerViewOnClickListenerHack;
... ... @@ -92,18 +94,21 @@ public class ListaPoliticoFragment extends Fragment implements RecyclerViewOnCli
92 94 public void onClickListener(View view, int position) {
93 95  
94 96  
95   - PoliticoFragment frag = new PoliticoFragment();
96   - Bundle bundle = new Bundle();
  97 +// PoliticoFragment frag = new PoliticoFragment();
  98 +// Bundle bundle = new Bundle();
97 99 try {
98 100 ob.get(position).pin();
99 101 } catch (ParseException e) {
100 102 e.printStackTrace();
101 103 }
102   - bundle.putString("politico", ob.get(position).getObjectId());
103   - frag.setArguments(bundle);
104   - FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
105   - ft.replace(R.id.rl_fragment_container, frag, "politicoFrag");
106   - ft.addToBackStack(null);
107   - ft.commit();
  104 +// bundle.putString("politico", ob.get(position).getObjectId());
  105 +// frag.setArguments(bundle);
  106 +// FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
  107 +// ft.replace(R.id.rl_fragment_container, frag, "politicoFrag");
  108 +// ft.addToBackStack(null);
  109 +// ft.commit();
  110 + Intent intent = new Intent(getActivity(),PoliticoFichaActivity.class);
  111 + intent.putExtra("politico", ob.get(position).getObjectId());
  112 + startActivity(intent);
108 113 }
109 114 }
... ...
app/src/main/res/layout/activity_comentario.xml 0 → 100644
... ... @@ -0,0 +1,90 @@
  1 +<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:app="http://schemas.android.com/apk/res-auto"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:id="@+id/drawerLayout"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + tools:context="com.monitorabrasil.monitoralegislativo.ComentarioActivity">
  8 +
  9 + <android.support.design.widget.CoordinatorLayout
  10 + android:id="@+id/rootLayout"
  11 + android:layout_width="match_parent"
  12 + android:layout_height="match_parent">
  13 +
  14 + <android.support.design.widget.AppBarLayout
  15 + android:layout_width="match_parent"
  16 + android:layout_height="@dimen/app_bar_height"
  17 + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
  18 +
  19 + <android.support.design.widget.CollapsingToolbarLayout
  20 + android:id="@+id/collapsingToolbarLayout"
  21 + android:layout_width="match_parent"
  22 + android:layout_height="match_parent"
  23 + app:contentScrim="?attr/colorPrimary"
  24 + app:expandedTitleMarginStart="@dimen/expanded_toolbar_title_margin_start"
  25 + app:layout_scrollFlags="scroll|exitUntilCollapsed">
  26 +
  27 + <ImageView
  28 + android:layout_width="match_parent"
  29 + android:layout_height="match_parent"
  30 + android:scaleType="centerCrop"
  31 + android:src="@drawable/pattern1"
  32 + app:layout_collapseMode="parallax"
  33 + app:layout_collapseParallaxMultiplier="0.7" />
  34 + <TextView
  35 + android:layout_width="wrap_content"
  36 + android:layout_height="wrap_content"
  37 + android:textAppearance="?android:attr/textAppearanceMedium"
  38 + android:text="Projeto"
  39 + android:id="@+id/projeto" />
  40 +
  41 +
  42 + <android.support.v7.widget.Toolbar
  43 + android:id="@+id/toolbar"
  44 + android:layout_width="match_parent"
  45 + android:layout_height="?attr/actionBarSize"
  46 + app:layout_collapseMode="pin"
  47 + app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
  48 + app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
  49 +
  50 + </android.support.design.widget.CollapsingToolbarLayout>
  51 +
  52 + </android.support.design.widget.AppBarLayout>
  53 +
  54 + <android.support.v4.widget.NestedScrollView
  55 + android:layout_width="match_parent"
  56 + android:layout_height="match_parent"
  57 + app:layout_behavior="@string/appbar_scrolling_view_behavior">
  58 +
  59 + <LinearLayout
  60 + android:layout_width="match_parent"
  61 + android:layout_height="match_parent"
  62 + android:orientation="vertical">
  63 +
  64 +
  65 + <include layout="@layout/fragment_politico_detalhe"/>
  66 + <RelativeLayout
  67 + android:id="@+id/rl_fragment_container"
  68 + android:layout_width="match_parent"
  69 + android:layout_height="400dp">
  70 +
  71 + </RelativeLayout>
  72 +
  73 + </LinearLayout>
  74 +
  75 + </android.support.v4.widget.NestedScrollView>
  76 +
  77 + <android.support.design.widget.FloatingActionButton
  78 + android:id="@+id/fabBtn"
  79 + android:layout_width="wrap_content"
  80 + android:layout_height="wrap_content"
  81 + android:layout_gravity="bottom|right"
  82 + android:layout_marginBottom="@dimen/fab_margin_bottom"
  83 + android:layout_marginRight="@dimen/fab_margin_right"
  84 + android:src="@drawable/ic_done"
  85 + app:borderWidth="0dp"
  86 + app:fabSize="normal" />
  87 +
  88 + </android.support.design.widget.CoordinatorLayout>
  89 +
  90 +</android.support.v4.widget.DrawerLayout>
0 91 \ No newline at end of file
... ...
app/src/main/res/layout/activity_politico_ficha.xml 0 → 100644
... ... @@ -0,0 +1,83 @@
  1 +<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:app="http://schemas.android.com/apk/res-auto"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:id="@+id/drawerLayout"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + tools:context="com.monitorabrasil.monitoralegislativo.PoliticoFichaActivity">
  8 +
  9 +<android.support.design.widget.CoordinatorLayout
  10 + android:id="@+id/rootLayout"
  11 + android:layout_width="match_parent"
  12 + android:layout_height="match_parent">
  13 +
  14 + <android.support.design.widget.AppBarLayout
  15 + android:layout_width="match_parent"
  16 + android:layout_height="@dimen/app_bar_height"
  17 + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
  18 +
  19 + <android.support.design.widget.CollapsingToolbarLayout
  20 + android:id="@+id/collapsingToolbarLayout"
  21 + android:layout_width="match_parent"
  22 + android:layout_height="match_parent"
  23 + app:contentScrim="?attr/colorPrimary"
  24 + app:expandedTitleMarginStart="@dimen/expanded_toolbar_title_margin_start"
  25 + app:layout_scrollFlags="scroll|exitUntilCollapsed">
  26 +
  27 + <ImageView
  28 + android:layout_width="match_parent"
  29 + android:layout_height="match_parent"
  30 + android:scaleType="centerCrop"
  31 + android:src="@drawable/pattern1"
  32 + app:layout_collapseMode="parallax"
  33 + app:layout_collapseParallaxMultiplier="0.7" />
  34 +
  35 + <android.support.v7.widget.Toolbar
  36 + android:id="@+id/toolbar"
  37 + android:layout_width="match_parent"
  38 + android:layout_height="?attr/actionBarSize"
  39 + app:layout_collapseMode="pin"
  40 + app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
  41 + app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
  42 +
  43 + </android.support.design.widget.CollapsingToolbarLayout>
  44 +
  45 + </android.support.design.widget.AppBarLayout>
  46 +
  47 + <android.support.v4.widget.NestedScrollView
  48 + android:layout_width="match_parent"
  49 + android:layout_height="match_parent"
  50 + app:layout_behavior="@string/appbar_scrolling_view_behavior">
  51 +
  52 + <LinearLayout
  53 + android:layout_width="match_parent"
  54 + android:layout_height="match_parent"
  55 + android:orientation="vertical">
  56 +
  57 +
  58 + <include layout="@layout/fragment_politico_detalhe"/>
  59 + <RelativeLayout
  60 + android:id="@+id/rl_fragment_container"
  61 + android:layout_width="match_parent"
  62 + android:layout_height="400dp">
  63 +
  64 + </RelativeLayout>
  65 +
  66 + </LinearLayout>
  67 +
  68 + </android.support.v4.widget.NestedScrollView>
  69 +
  70 + <android.support.design.widget.FloatingActionButton
  71 + android:id="@+id/fabBtn"
  72 + android:layout_width="wrap_content"
  73 + android:layout_height="wrap_content"
  74 + android:layout_gravity="bottom|right"
  75 + android:layout_marginBottom="@dimen/fab_margin_bottom"
  76 + android:layout_marginRight="@dimen/fab_margin_right"
  77 + android:src="@drawable/ic_done"
  78 + app:borderWidth="0dp"
  79 + app:fabSize="normal" />
  80 +
  81 +</android.support.design.widget.CoordinatorLayout>
  82 +
  83 + </android.support.v4.widget.DrawerLayout>
0 84 \ No newline at end of file
... ...
app/src/main/res/layout/item_projeto.xml
... ... @@ -14,7 +14,7 @@
14 14 android:layout_height="wrap_content">
15 15  
16 16 <TextView
17   - android:layout_width="match_parent"
  17 + android:layout_width="263dp"
18 18 android:layout_height="wrap_content"
19 19 android:text="Info"
20 20 android:id="@+id/classificacao"
... ... @@ -41,31 +41,64 @@
41 41 android:layout_height="wrap_content"
42 42 android:id="@+id/descricao" />
43 43  
44   - <LinearLayout
  44 + <RelativeLayout
45 45 android:orientation="horizontal"
46 46 android:layout_width="match_parent"
47 47 android:layout_height="match_parent">
48 48  
49 49 <Button
50   - android:layout_width="match_parent"
51   - android:layout_height="match_parent"
52   - android:text="Concordo"
  50 + android:layout_width="77dp"
  51 + android:layout_height="72dp"
53 52 android:id="@+id/btnConcordo"
54   -
55   -
56 53 android:layout_gravity="center_horizontal"
57 54 style="@style/Base.Widget.AppCompat.Button.ButtonBar.AlertDialog"
58   - android:layout_weight="1" />
  55 + android:background="@mipmap/ic_action_like_gray" />
59 56  
60 57 <Button
61   - style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
62   - android:layout_width="match_parent"
63   - android:layout_height="match_parent"
64   - android:text="Discordo"
  58 + android:layout_width="77dp"
  59 + android:layout_height="72dp"
  60 + android:layout_toRightOf="@+id/btnConcordo"
  61 + style="@style/Base.Widget.AppCompat.Button.ButtonBar.AlertDialog"
65 62 android:id="@+id/btnDiscordo"
66   - android:layout_gravity="center_horizontal"
67   - android:layout_weight="1" />
68   - </LinearLayout>
  63 + android:background="@mipmap/ic_action_unlike_gray" />
  64 +
  65 + <Button
  66 + style="@style/Base.Widget.AppCompat.Button.ButtonBar.AlertDialog"
  67 + android:layout_width="wrap_content"
  68 + android:layout_height="match_parent"
  69 + android:id="@+id/btnComentar"
  70 + android:background="@mipmap/ic_action_comment"
  71 + android:layout_alignParentTop="true"
  72 + android:layout_alignParentRight="true"
  73 + android:layout_alignParentEnd="true"
  74 + android:layout_alignBottom="@+id/btnDiscordo"
  75 + android:textAlignment="center" />
  76 +
  77 + <TextView
  78 + android:layout_width="wrap_content"
  79 + android:layout_height="wrap_content"
  80 + android:textAppearance="?android:attr/textAppearanceSmall"
  81 + android:text="0"
  82 + android:id="@+id/txtNumApoio"
  83 + android:layout_below="@+id/btnConcordo"
  84 + android:layout_toLeftOf="@+id/btnDiscordo"
  85 + android:layout_toStartOf="@+id/btnDiscordo"
  86 + android:layout_marginRight="32dp"
  87 + android:layout_marginEnd="32dp" />
  88 +
  89 + <TextView
  90 + android:layout_width="wrap_content"
  91 + android:layout_height="wrap_content"
  92 + android:textAppearance="?android:attr/textAppearanceSmall"
  93 + android:text="0"
  94 + android:id="@+id/txtNumNaoApoio"
  95 + android:layout_below="@+id/btnDiscordo"
  96 + android:layout_toRightOf="@+id/btnConcordo"
  97 + android:layout_toEndOf="@+id/btnConcordo"
  98 + android:layout_marginLeft="33dp"
  99 + android:layout_marginStart="33dp" />
  100 +
  101 + </RelativeLayout>
69 102  
70 103  
71 104 </LinearLayout>
... ...
app/src/main/res/menu/menu_comentario.xml 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +<menu xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:app="http://schemas.android.com/apk/res-auto"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + tools:context="com.monitorabrasil.monitoralegislativo.ComentarioActivity">
  5 + <item android:id="@+id/action_settings" android:title="@string/action_settings"
  6 + android:orderInCategory="100" app:showAsAction="never" />
  7 +</menu>
... ...
app/src/main/res/menu/menu_politico_ficha.xml 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +<menu xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:app="http://schemas.android.com/apk/res-auto"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + tools:context="com.monitorabrasil.monitoralegislativo.PoliticoFichaActivity">
  5 + <item android:id="@+id/action_settings" android:title="@string/action_settings"
  6 + android:orderInCategory="100" app:showAsAction="never" />
  7 +</menu>
... ...
app/src/main/res/mipmap-hdpi/ic_action_comment.png 0 → 100644

697 Bytes

app/src/main/res/mipmap-hdpi/ic_action_like_gray.png 0 → 100644

1.52 KB

app/src/main/res/mipmap-hdpi/ic_action_like_green.png 0 → 100644

1.12 KB

app/src/main/res/mipmap-hdpi/ic_action_unlike_gray.png 0 → 100644

1.52 KB

app/src/main/res/mipmap-hdpi/ic_action_unlike_red.png 0 → 100644

1012 Bytes

app/src/main/res/mipmap-mdpi/ic_action_comment.png 0 → 100644

500 Bytes

app/src/main/res/mipmap-mdpi/ic_action_like_gray.png 0 → 100644

1.05 KB

app/src/main/res/mipmap-mdpi/ic_action_like_green.png 0 → 100644

820 Bytes

app/src/main/res/mipmap-mdpi/ic_action_unlike_gray.png 0 → 100644

1.04 KB

app/src/main/res/mipmap-mdpi/ic_action_unlike_red.png 0 → 100644

716 Bytes

app/src/main/res/mipmap-xhdpi/ic_action_comment.png 0 → 100644

998 Bytes

app/src/main/res/mipmap-xhdpi/ic_action_like_gray.png 0 → 100644

2.22 KB

app/src/main/res/mipmap-xhdpi/ic_action_like_green.png 0 → 100644

1.65 KB

app/src/main/res/mipmap-xhdpi/ic_action_unlike_gray.png 0 → 100644

2.2 KB

app/src/main/res/mipmap-xhdpi/ic_action_unlike_red.png 0 → 100644

1.47 KB

app/src/main/res/mipmap-xxhdpi/ic_action_comment.png 0 → 100644

1.64 KB

app/src/main/res/mipmap-xxhdpi/ic_action_like_gray.png 0 → 100644

3.51 KB

app/src/main/res/mipmap-xxhdpi/ic_action_like_green.png 0 → 100644

2.57 KB

app/src/main/res/mipmap-xxhdpi/ic_action_unlike_gray.png 0 → 100644

3.5 KB

app/src/main/res/mipmap-xxhdpi/ic_action_unlike_red.png 0 → 100644

2.33 KB

app/src/main/res/mipmap-xxxhdpi/ic_action_comment.png 0 → 100644

2.48 KB

app/src/main/res/mipmap-xxxhdpi/ic_action_like_gray.png 0 → 100644

5.09 KB

app/src/main/res/mipmap-xxxhdpi/ic_action_like_green.png 0 → 100644

3.71 KB

app/src/main/res/mipmap-xxxhdpi/ic_action_unlike_gray.png 0 → 100644

5.14 KB

app/src/main/res/mipmap-xxxhdpi/ic_action_unlike_red.png 0 → 100644

3.41 KB

app/src/main/res/values-v21/dimens.xml 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +<resources>
  2 + <dimen name="fab_margin_right">16dp</dimen>
  3 + <dimen name="fab_margin_bottom">16dp</dimen>
  4 +</resources>
... ...
app/src/main/res/values/colors.xml
... ... @@ -3,15 +3,15 @@
3 3 <color name="grey">#ddd</color>
4 4 <color name="black">#000</color>
5 5  
6   - <color name="colorPrimaryLight">#00c9af</color>
7   - <color name="colorPrimary">#009688</color>
8   - <color name="colorPrimaryDark">#00796B</color>
  6 + <color name="colorPrimaryLight">#C8E6C9</color>
  7 + <color name="colorPrimary">#4CAF50</color>
  8 + <color name="colorPrimaryDark">#388E3C</color>
9 9 <color name="colorPrimarytext">#212121</color>
10   - <color name="colorSecondText">#999</color>
  10 + <color name="colorSecondText">#727272</color>
11 11 <color name="coloLink">#1ea4f7</color>
12 12 <color name="colorDivider">#ccc</color>
13 13  
14   - <color name="colorAccent">#795548</color>
  14 + <color name="colorAccent">#448AFF</color>
15 15  
16 16 <color name="colorFAB">#FF9800</color>
17 17 <color name="colorFABPressed">#F57C00</color>
... ...
app/src/main/res/values/dimens.xml
... ... @@ -7,4 +7,15 @@
7 7 <dimen name="card_margin">16dp</dimen>
8 8 <dimen name="fab_margin">16dp</dimen>
9 9 <dimen name="list_item_avatar_size">40dp</dimen>
10   -</resources>
  10 +
  11 + <dimen name="fab_margin_right">0.1dp</dimen>
  12 + <dimen name="fab_margin_bottom">0.1dp</dimen>
  13 +
  14 + <dimen name="app_bar_height">256dp</dimen>
  15 + <dimen name="nav_header_height">192dp</dimen>
  16 +
  17 +
  18 +<dimen name="expanded_toolbar_title_margin_start">64dp</dimen>
  19 +
  20 +<dimen name="nav_header_text_margin_left">16dp</dimen>
  21 + </resources>
... ...
app/src/main/res/values/strings.xml
... ... @@ -14,6 +14,11 @@
14 14 <string name="title_activity_politicos">PoliticosActivity</string>
15 15 <string name="title_activity_camara">CamaraActivity</string>
16 16 <string name="title_activity_projetos">ProjetosActivity</string>
  17 + <string name="title_activity_politico_ficha">PoliticoFichaActivity</string>
  18 +
  19 + <string name="projeto_apoio">Apoio</string>
  20 + <string name="projeto_naoapoio">Não Apoio</string>
  21 + <string name="title_activity_comentario">ComentarioActivity</string>
17 22  
18 23  
19 24 </resources>
... ...
app/src/main/res/values/styles.xml
... ... @@ -53,4 +53,9 @@
53 53 <item name="android:orientation">vertical</item>
54 54 </style>
55 55  
  56 + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  57 + <item name="windowActionBar">false</item>
  58 + <item name="windowNoTitle">true</item>
  59 + </style>
  60 +
56 61 </resources>
... ...