Permalink
Browse files

menu, dialog

  • Loading branch information...
migellal committed Nov 28, 2017
1 parent cea3aff commit b63024c26c5ae0ccf205047255c6f550ca056687
@@ -7,8 +7,8 @@ android {
applicationId "pl.digitalzombielab.udemyandroid"
minSdkVersion 16
targetSdkVersion 26
versionCode 3
versionName "1.0"
versionCode 4
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -1,29 +1,26 @@
package pl.digitalzombielab.udemyandroid;

import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {

@BindView(R.id.shoppingListButton)
Button shoppingListButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}

@@ -53,7 +50,7 @@ void onClickView() {

@OnClick(R.id.infoButton)
void onClickInfo() {
String url = "https://www.udemy.com";
String url = "https://www.udemy.com/praktyczny-podstawowy-kurs-programowania-android/?couponCode=Z-APLIKACJI";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
@@ -74,7 +71,17 @@ public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
if (id == R.id.action_info) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.dialog_message)
.setTitle(R.string.dialog_title)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
return true;
}

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,8 +3,9 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context="pl.digitalzombielab.udemyandroid.MainActivity">
<item
android:id="@+id/action_settings"
android:id="@+id/action_info"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
android:icon="@drawable/ic_info_white_48dp"
android:title="@string/action_info"
app:showAsAction="always" />
</menu>
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Udemy Android</string>
<string name="action_settings">Ustawienia</string>
<string name="action_info">Info</string>
<string name="shopping_list_button">Lista zakupów</string>
<string name="draw_button">Rysowanie</string>
<string name="api_button">API</string>
<string name="view_button">Widok</string>
<string name="html_button">Dane z HTML</string>
<string name="json_button">Date z JSON</string>
<string name="title_activity_shopping_list">Lista zakupów</string>
<string name="course_info">Informacja o kursie Udemy</string>
<string name="course_info">Zniżka na kurs, gdzie tworzymy tą aplikację</string>
<string name="dialog_message">Ta aplikacja jest częścią kursu Udemy: "Praktyczny podstawowy kurs tworzenia aplikacji na system operacyjny Android". Kliknij na zniżkę, aby otrzymać więcej informacji!</string>
<string name="dialog_title">Informacja</string>
<string name="ok">OK</string>
</resources>
@@ -1,12 +1,15 @@
<resources>
<string name="app_name">Udemy Android</string>
<string name="action_settings">Settings</string>
<string name="action_info">Info</string>
<string name="shopping_list_button">Shopping list</string>
<string name="draw_button">Draw</string>
<string name="api_button">API</string>
<string name="view_button">View</string>
<string name="html_button">Data from HTML</string>
<string name="json_button">Data from JSON</string>
<string name="title_activity_shopping_list">Shopping list</string>
<string name="course_info">Udemy course info</string>
<string name="course_info">Udemy course coupon</string>
<string name="dialog_message">This application is a part of Udemy course. Course is only available in polish.</string>
<string name="dialog_title">Info</string>
<string name="ok">OK</string>
</resources>
@@ -4,9 +4,10 @@ buildscript {
ext.kotlin_version = '1.1.51'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.0.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -17,6 +18,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

0 comments on commit b63024c

Please sign in to comment.