Skip to content

Commit

Permalink
Implementa tres mensajes diferentes y inhibe rotacion pantalla.
Browse files Browse the repository at this point in the history
Esta version inhibe la rotación de pantalla, mantiene siempre la orientacion
vertical.
Ademas, incluye un nuevo mensaje para la segunda vez que pulsas el
boton no tocar y una imagen nueva.
  • Loading branch information
Wewannado committed Sep 28, 2016
1 parent 8bc7e45 commit 0f8db20
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

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

5 changes: 1 addition & 4 deletions .idea/misc.xml

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

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:24.1.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
}
9 changes: 7 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".RobotActivity">
<activity android:name=".RobotActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</activity><!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
package com.exemple.profedam.aboutrobots2017;

import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.appindexing.Thing;
import com.google.android.gms.common.api.GoogleApiClient;

public class RobotActivity extends AppCompatActivity implements View.OnClickListener {

private int numeroVeces = 0;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -20,6 +33,12 @@ protected void onCreate(Bundle savedInstanceState) {
Button btnNoTocar = (Button) findViewById(R.id.btnNoTocar);
btnNoTocar.setOnClickListener(this);

ImageButton btnSalir = (ImageButton) findViewById(R.id.imageButtonSalir);
btnSalir.setOnClickListener(this);

// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}

/* Método que se ejecuta cuando algún botón vigilado
Expand All @@ -29,24 +48,64 @@ protected void onCreate(Bundle savedInstanceState) {

public void onClick(View v) {

Button btnNoTocar = (Button) v;
TextView textView = (TextView) findViewById (R.id.textView);
numeroVeces++;
if (numeroVeces==1)
{
btnNoTocar.setText ("¡Que no me toques!!!");
textView.setText ("Parece ser que los humanos no son muy inteligentes");
if (v.getId()==R.id.btnNoTocar) {
Button btnNoTocar = (Button) v;
TextView cajaTexto = (TextView) findViewById(R.id.textView);
ImageView imageRob = (ImageView) findViewById(R.id.imageView);
numeroVeces++;
if (numeroVeces == 1) {
btnNoTocar.setText("¡Que no me toques!!!");
cajaTexto.setText("Parece ser que los humanos no son muy inteligentes");
imageRob.setImageResource(R.mipmap.robot_enfadado);
}

if (numeroVeces == 2) {
btnNoTocar.setVisibility(View.INVISIBLE);
cajaTexto.setText("Te lo advertí!");
imageRob.setImageResource(R.mipmap.robot_fumando);
}
}
if (v.getId() == R.id.imageButtonSalir) {
finish();

if (numeroVeces==2)
{
btnNoTocar.setVisibility(View.INVISIBLE);
}


}

/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
public Action getIndexApiAction() {
Thing object = new Thing.Builder()
.setName("Robot Page") // TODO: Define a title for the content shown.
// TODO: Make sure this auto-generated URL is correct.
.setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
.build();
return new Action.Builder(Action.TYPE_VIEW)
.setObject(object)
.setActionStatus(Action.STATUS_TYPE_COMPLETED)
.build();
}

@Override
public void onStart() {
super.onStart();

// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client.connect();
AppIndex.AppIndexApi.start(client, getIndexApiAction());
}

@Override
public void onStop() {
super.onStop();

// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
AppIndex.AppIndexApi.end(client, getIndexApiAction());
client.disconnect();
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_robot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,14 @@
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="60dp" />

<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/ic_lock_power_off"
android:layout_below="@+id/imageView"
android:layout_alignRight="@+id/imageView"
android:layout_alignEnd="@+id/imageView"
android:layout_marginTop="31dp"
android:id="@+id/imageButtonSalir" />
</RelativeLayout>
Binary file modified app/src/main/res/mipmap-hdpi/robot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-hdpi/robot_enfadado.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-hdpi/robot_fumando.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-rc2'
classpath 'com.android.tools.build:gradle:2.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 0f8db20

Please sign in to comment.