Skip to content

Commit

Permalink
add share buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
forfolias committed Jan 22, 2012
1 parent f228fc1 commit 48653a6
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 51 deletions.
Binary file added LeleDroid/res/drawable-hdpi/ic_menu_share.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions LeleDroid/res/layout-land/details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
android:text="ONOMA STRATIOTI"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
android:textSize="16sp"
android:textColor="#FFF"
android:shadowColor="#777"
android:shadowRadius="3"
android:layout_height="wrap_content"
android:layout_margin="8dip"></TextView>
<LinearLayout
Expand Down
4 changes: 4 additions & 0 deletions LeleDroid/res/layout/details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<TextView
android:id="@+id/onoma"
android:text="ONOMA STRATIOTI"
android:textSize="16sp"
android:textColor="#FFF"
android:shadowColor="#777"
android:shadowRadius="3"
android:layout_margin="5dip"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
Expand Down
85 changes: 49 additions & 36 deletions LeleDroid/res/layout/info.xml
Original file line number Diff line number Diff line change
@@ -1,49 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:id="@+id/detailsScrollView"
android:layout_width="fill_parent" android:layout_height="fill_parent"
<ScrollView
android:id="@+id/detailsScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal">
<ImageView android:id="@+id/infoImage" android:src="@drawable/img1"
android:layout_margin="4dip" android:layout_width="wrap_content"
<ImageView
android:id="@+id/infoImage"
android:src="@drawable/img1"
android:layout_margin="4dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></ImageView>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center_horizontal">
<TextView android:text="@string/app_name" android:textSize="15sp"
android:layout_margin="5dip" android:textStyle="bold"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<TextView android:id="@+id/version"
android:layout_margin="5dip" android:textStyle="italic"
android:gravity="center" android:layout_width="wrap_content"
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:text="@string/app_name"
android:textSize="15sp"
android:layout_margin="5dip"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<TextView
android:id="@+id/version"
android:layout_margin="5dip"
android:textStyle="italic"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<TextView android:text="@string/description" android:gravity="center_horizontal"
android:layout_margin="5dip" android:layout_width="wrap_content"
<TextView
android:text="@string/description"
android:gravity="center_horizontal"
android:layout_margin="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<TextView android:text="@string/copyright"
android:layout_margin="4dip" android:layout_width="wrap_content"
<TextView
android:text="@string/copyright"
android:layout_margin="4dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<TextView android:text="@string/contact" android:id="@+id/contact"
android:layout_margin="2dip" android:layout_width="wrap_content"
<TextView
android:text="@string/contact"
android:id="@+id/contact"
android:layout_margin="2dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>

<TextView android:text="@string/site" android:layout_margin="2dip"
android:id="@+id/site" android:layout_width="wrap_content"
<TextView
android:text="@string/site"
android:layout_margin="2dip"
android:id="@+id/site"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>

<!-- LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="5dip" android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="bottom">
<Button android:text="@string/licence" android:id="@+id/licenceButton"
android:drawableLeft="@drawable/ic_menu_info_details"
android:onClick="licenceButtonClicked" android:layout_width="155dip"
android:layout_height="wrap_content"></Button>
<Button android:text="@string/donate" android:id="@+id/donateButton"
android:drawableLeft="@drawable/ic_menu_star"
android:onClick="donateButtonClicked" android:layout_width="155dip"
android:layout_height="wrap_content"></Button>
</LinearLayout -->
</LinearLayout>
</ScrollView>
5 changes: 4 additions & 1 deletion LeleDroid/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<string name="delete">Delete</string>
<string name="deleteConfirmation">Delete confirmation</string>
<string name="vathmoiInfo">Grade ranges</string>
<string name="share">Share</string>
<string name="shareAppText">Check LeleDroid, an amazing application for Android!\n
You will find it free at the Android Market and at </string>

<string name="dateOut">End date</string>
<string name="dateIn">Start date</string>
Expand Down Expand Up @@ -39,7 +42,7 @@

<string name="widgetTitle">LeleDroid Widget Configuration</string>
<string name="textColor">Text color</string>
<string name="bgColor">Χρώμα παρασκηνίου</string>
<string name="bgColor">Background color</string>
<string name="widgetDisplayVathmos">Display soldiers\' military rank</string>
<string name="widgetDisplayName">Display soldiers\' name</string>
<string name="widgetDisplayImage">Display soldiers\' military rank image</string>
Expand Down
4 changes: 4 additions & 0 deletions LeleDroid/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<string name="delete">Διαγραφή</string>
<string name="deleteConfirmation">Επιβεβαίωση διαγραφής</string>
<string name="vathmoiInfo">Κλίμακα βαθμών</string>
<string name="share">Κοινοποίηση</string>
<string name="shareAppText">Δες το LeleDroid, μια καταπληκτική εφαρμογή για Android!\n
Θα τη βρεις δωρεάν στο Android Market και στο </string>
<string name="shareStrText"></string>

<string name="dateOut">Ημερομηνία απόλυσης</string>
<string name="dateIn">Ημερομηνία κατάταξης</string>
Expand Down
51 changes: 39 additions & 12 deletions LeleDroid/src/com/vasilakos/LeleDroid/Details.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.vasilakos.LeleDroid;

import java.text.DecimalFormat;
import java.util.GregorianCalendar;
import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
Expand Down Expand Up @@ -41,6 +42,8 @@ public class Details extends Activity {
TextView posostoTv;
ProgressBar posostoPB;
Str str;

DecimalFormat twoDigit;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -57,7 +60,9 @@ public void onCreate(Bundle savedInstanceState) {
monthsTv = (TextView) findViewById(R.id.months);
posostoPB = (ProgressBar) findViewById(R.id.posostoProgress);
posostoTv = (TextView) findViewById(R.id.pososto);


twoDigit = new DecimalFormat("#,##0.00");

setLabels();

MyCount counter = new MyCount(Long.parseLong((String) secondsTv
Expand Down Expand Up @@ -130,11 +135,11 @@ public void setChart(Integer adeia, Integer ipiretisimoYpoloipo,
if (adeia < 0) {
adeia = 0;
}

if (ipiretisimoYpoloipo == 0 && adeia == 0 && perasan == 0) {
perasan = 1;
}

String[] labels = { adeia.toString(), ipiretisimoYpoloipo.toString(),
perasan.toString() };
GraphicalView mChartView;
Expand All @@ -161,25 +166,45 @@ public void onClick(View v) {
}
});
}

public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 1, 0, R.string.delete).setIcon(R.drawable.ic_menu_delete);
menu.add(0, 1, 0, R.string.share).setIcon(R.drawable.ic_menu_share);
menu.add(0, 2, 0, R.string.edit).setIcon(R.drawable.ic_menu_edit);
menu.add(0, 3, 0, R.string.delete).setIcon(R.drawable.ic_menu_delete);
return true;
}

public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
deleteButtonClicked(null);
shareButtonClicked();
return true;
case 2:
editButtonClicked(null);
return true;
case 3:
deleteButtonClicked(null);
return true;
}
return false;
}

public void shareButtonClicked() {
Intent intent = new Intent(Intent.ACTION_SEND);

intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT,
getResources().getString(R.string.share));
intent.putExtra(
Intent.EXTRA_TEXT,
getResources().getString(str.getVathmo()) + " " + str.getName()
+ "\n" + str.getRestDays() + " "
+ getResources().getString(R.string.plusToday)
+ " (" + twoDigit.format(str.getPososto()) + "%)"
);
startActivity(Intent.createChooser(intent, getString(R.string.share)));
}

public void editButtonClicked(View v) {
Bundle b = new Bundle();
Intent edit = new Intent(this, com.vasilakos.LeleDroid.Properties.class);
Expand Down Expand Up @@ -219,24 +244,26 @@ public void deleteButtonOk() {

public void setName(Float totalPososto) {
ImageView img = (ImageView) findViewById(R.id.vathmosImg);

img.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
Intent view = new Intent(getBaseContext(), com.vasilakos.LeleDroid.Vathmoi.class);
Intent view = new Intent(getBaseContext(),
com.vasilakos.LeleDroid.Vathmoi.class);
startActivity(view);
}
});

img.setImageDrawable(getResources().getDrawable(str.getImg()));
nameTv.setText(getResources().getString(str.getVathmo()) + " " + str.getName());
nameTv.setText(getResources().getString(str.getVathmo()) + " "
+ str.getName());
}

public void setPososto(Float totalPososto) {
if (totalPososto < 0)
totalPososto = (float) 0;
posostoPB.setProgress(totalPososto.intValue());
posostoTv.setText(totalPososto.intValue() + "%");
posostoTv.setText(twoDigit.format(totalPososto) + "%");
}

public void setRestOfTv() {
Expand Down
19 changes: 17 additions & 2 deletions LeleDroid/src/com/vasilakos/LeleDroid/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,25 @@ public void onClick(DialogInterface arg0, int arg1) {
});
alertbox.show();
}

public void shareButtonClicked() {
Intent intent = new Intent(Intent.ACTION_SEND);

intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT,
getResources().getString(R.string.share));
intent.putExtra(Intent.EXTRA_TEXT,getResources().getString(R.string.shareAppText) + " " + getResources().getString(R.string.site) );

startActivity(Intent.createChooser(intent, getString(R.string.share)));
}

public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 1, 0, R.string.licence).setIcon(
R.drawable.ic_menu_info_details);
menu.add(0, 2, 0, R.string.donate).setIcon(R.drawable.ic_menu_star);
menu.add(0, 2, 0, R.string.share).setIcon(R.drawable.ic_menu_share);
menu.add(0, 3, 0, R.string.vathmoiInfo).setIcon(
R.drawable.ic_menu_view);
menu.add(0, 4, 0, R.string.donate).setIcon(R.drawable.ic_menu_star);
return true;
}

Expand All @@ -121,11 +133,14 @@ public boolean onOptionsItemSelected(MenuItem item) {
licenceButtonClicked(null);
return true;
case 2:
donateButtonClicked(null);
shareButtonClicked();
return true;
case 3:
vathmoiButtonClicked(null);
return true;
case 4:
donateButtonClicked(null);
return true;
}
return false;
}
Expand Down

0 comments on commit 48653a6

Please sign in to comment.