|
|
Autor |
Wiadomość |
matix77
Administrator
Dołączył: 21 Kwi 2008
Posty: 82
Przeczytał: 0 tematów
Pomógł: 4 razy
Ostrzeżeń: 0/5
|
Wysłany:
Sob 18:48, 09 Kwi 2016 |
|
Nie zwiazane z sieciami, ale co tam ;D Dodaje moja aplikacje napisana w android studio. Jak ktos ma jakies pytania walic na priva ; D A oto ponizej kod prezentuje:
Adapter.java
package com.example.mateusz.anty_zapominacz;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import java.util.List;
import android.widget.TextView;
public class Adapter extends ArrayAdapter<Remind>{
private List<Remind> list;
private Activity activity;
public Adapter(Context context, List<Remind> p_list, Activity activity ) {
super(context,R.layout.list);
this.list = p_list;
this.activity = activity;
}
public void update(List<Remind> p_list){
list = p_list;
}
public Remind getPosition(int position){
return list.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
View row = convertView;
Remind_Holder holder = null;
if (row == null) {
LayoutInflater inflater = activity.getLayoutInflater();
row = inflater.inflate(R.layout.list, null);
holder = new Remind_Holder();
holder.name = (TextView) row.findViewById(R.id.nazwaLeku);
row.setTag(holder);
}
else{
holder = (Remind_Holder) row.getTag();
}
Remind remind = list.get(position);
holder.name.setText((CharSequence) remind.medicine_name);
return row;
}
@Override
public int getCount(){
return this.list.size();
}
static class Remind_Holder {
TextView name;
}
}
Clock.java
package com.example.mateusz.anty_zapominacz;
import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
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.TextView;
import java.util.Calendar;
import java.util.Date;
public class Clock extends AppCompatActivity {
private TextView name_medicine;
private TextView dosage;
private Button stop;
private int id;
private Ringtone r;
public static final String collectionFile = "collectionFile.dat";
public static final String receiveBundle = "lkjhhiuh2352390dsgu908su43";
private Serialization serialization;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alarm);
serialization = new Serialization(getApplicationContext());
id = getIntent().getIntExtra(receiveBundle, -2);
name_medicine = (TextView)findViewById(R.id.tv_nazwaLeku);
dosage = (TextView)findViewById(R.id.tv_dawkaLeku);
stop = (Button)findViewById(R.id.b_alarm);
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
Provider.deleteAlarm(getApplicationContext(), id);
Collection remindcollection = serialization.readCollection2(collectionFile);
for (int i = 0; i < remindcollection.list.size(); i++)
{
if ( remindcollection.list.get(i).ID == id ){
name_medicine.setText(remindcollection.list.get(i).medicine_name);
dosage.setText(remindcollection.list.get(i).dosage);
if (remindcollection.list.get(i).frequency < 1){
remindcollection.list.remove(i);
}
else {
repeat(remindcollection.list.get(i));
}
break;
}
}
serialization.SaveCollection2(collectionFile, remindcollection);
stop.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
r.stop();
Intent intent = new Intent(getApplicationContext(), Main_activity.class);
startActivity(intent);
finish();
}
});
}
@Override
protected void onStart(){
super.onStart();
}
private void repeat(Remind remind){
if (remind.frequency < 1 ){
return;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date(remind.dateTime.y, remind.dateTime.m, remind.dateTime.d ));
calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
remind.takenTime.h+= remind.frequency;
while ( remind.takenTime.h > 23 ){
remind.takenTime.h-=24;
remind.dateTime.d++;
}
while (calendar.getActualMaximum(Calendar.DAY_OF_MONTH) < remind.dateTime.d){
remind.dateTime.d = remind.dateTime.d - calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
remind.dateTime.m++;
if (remind.dateTime.m > 11) {
remind.dateTime.m = 0;
remind.dateTime.y++;
}
calendar.setTime(new Date(remind.dateTime.y, remind.dateTime.m, remind.dateTime.d ));
}
Provider.setAlarmForRemind(getApplicationContext(), remind);
}
}
Collection.java
package com.example.mateusz.anty_zapominacz;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class Collection implements Serializable {
public List<Remind> list;
Collection(List<Remind> p_lista)
{
list = new ArrayList<Remind>();
for (int i=0; i < p_lista.size(); i++)
{
list.add(p_lista.get(i));
}
}
Collection()
{
list = new ArrayList<Remind>();
}
}
Date.java
package com.example.mateusz.anty_zapominacz;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.DatePicker;
public class Date extends AppCompatActivity {
private DatePicker datePicker;
public static final String temporalFile = "temporalFile1.dat";
private Serialization serialization;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.date);
datePicker = (DatePicker)findViewById(R.id.datePicker);
serialization = new Serialization(getApplicationContext());
}
@Override
protected void onPause()
{
super.onPause();
Remind edit = serialization.readRemind2(temporalFile);
edit.dateTime.d = datePicker.getDayOfMonth();
edit.dateTime.m = datePicker.getMonth();
edit.dateTime.y = datePicker.getYear();
serialization.saveRemind2(temporalFile, edit);
}
}
Main_activity.java
package com.example.mateusz.anty_zapominacz;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.*;
import android.view.View;
import android.view.View.OnClickListener;
import android.content.*;
import java.util.List;
import android.widget.AdapterView.OnItemClickListener;
public class Main_activity extends AppCompatActivity {
private Button add;
private ListView list;
Context mainActivityContext;
public static final String temporalFile = "temporalFile1.dat";
public static final String collectionFile = "collectionFile.dat";
public static final String bundleID = "23546derwyw34y673q46er43265";
private Serialization serialization;
private Adapter adapter;
private List<Remind> remind_list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mainActivityContext = getApplicationContext();
serialization = new Serialization(mainActivityContext);
add = (Button) findViewById(R.id.addNewRemind);
list = (ListView) findViewById(R.id.listView);
Collection remindcollection = serialization.readCollection2(collectionFile);
this.remind_list = remindcollection.list;
adapter = new Adapter(mainActivityContext, remind_list, this);
list.setAdapter(adapter);
adapter.notifyDataSetChanged();
add.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view){
Intent intent = new Intent(mainActivityContext, Remind_Activity.class);
intent.putExtra(bundleID, "-1");
startActivity(intent);
}
});
list.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> adapterr, View v, int position, long arg3){
Remind remind = adapter.getPosition(position);
Intent intent = new Intent(mainActivityContext, Remind_Activity.class);
String s_position = Integer.toString(position);
intent.putExtra(bundleID, s_position);
startActivity(intent);
}
});
}
@Override
protected void onResume() {
super.onResume();
this.Refresh();
adapter.notifyDataSetChanged();
list.invalidateViews();
}
private void Refresh()
{
Collection remindcollection = serialization.readCollection2(collectionFile);
this.remind_list = remindcollection.list;
this.adapter.update(remind_list);
}
}
Provider.java
package com.example.mateusz.anty_zapominacz;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.SystemClock;
import android.content.Context;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
import static java.lang.System.currentTimeMillis;
public class Provider {
static void setAlarm(Context context, int ID, long time) {
Intent broadcastIntent = new Intent(context, Receiver.class);
broadcastIntent.putExtra(Receiver.receiveBundle, ID);
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, ID, broadcastIntent, 0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + time, alarmIntent);
}
static void deleteAlarm(Context context, int ID){
Intent broadcastIntent = new Intent(context, Receiver.class);
broadcastIntent.putExtra(Receiver.receiveBundle, ID);
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, ID, broadcastIntent, 0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(alarmIntent);
}
static void setAlarmForRemind(Context context, Remind remind){
currentTimeMillis();
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Calendar c = Calendar.getInstance();
int s = c.get(Calendar.SECOND);
int m = c.get(Calendar.MINUTE);
int h = c.get(Calendar.HOUR_OF_DAY);
int dd = c.get(Calendar.DAY_OF_MONTH);
int mm = c.get(Calendar.MONTH)+1;
int yy = c.get(Calendar.YEAR);
String currentDate = "";
if (mm < 10) {
currentDate +="0";
}
currentDate += Integer.toString(mm);
currentDate += "/";
if (dd < 10) {
currentDate +="0";
}
currentDate += Integer.toString(dd);
currentDate += "/";
currentDate += Integer.toString(yy);
currentDate += " ";
if (h < 10) {
currentDate +="0";
}
currentDate += Integer.toString(h);
currentDate += ":";
if (m < 10) {
currentDate +="0";
}
currentDate += Integer.toString(m);
currentDate += ":";
if (s < 10) {
currentDate +="0";
}
currentDate += Integer.toString(s);
m = remind.takenTime.m;
h = remind.takenTime.h;
dd = remind.dateTime.d;
mm = remind.dateTime.m + 1;
yy = remind.dateTime.y;
String alarmDate = "";
if (mm < 10) {
alarmDate +="0";
}
alarmDate += Integer.toString(mm);
alarmDate += "/";
if (dd < 10) {
alarmDate +="0";
}
alarmDate += Integer.toString(dd);
alarmDate += "/";
alarmDate += Integer.toString(yy);
alarmDate += " ";
if (h < 10) {
alarmDate += "0";
}
alarmDate += Integer.toString(h);
alarmDate += ":";
if (m < 10) {
alarmDate += "0";
}
alarmDate += Integer.toString(m);
alarmDate += ":00";
Date d1 = null;
Date d2 = null;
try {
d1 = format.parse(currentDate);
d2 = format.parse(alarmDate);
}
catch (Exception e) {
}
long diff = d2.getTime() - d1.getTime();
int id = remind.ID;
setAlarm(context, id, diff);
}
}
Receiver.java
package com.example.mateusz.anty_zapominacz;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class Receiver extends BroadcastReceiver {
public static final String receiveBundle = "47bgay453jhvg2f47f";
@Override
public void onReceive(Context context, Intent intent){
Intent newIntent = new Intent (context, Clock.class);
int id = intent.getIntExtra(receiveBundle, -1);
newIntent.putExtra(Clock.receiveBundle, id);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
}
}
Remind.java
package com.example.mateusz.anty_zapominacz;
import java.io.*;
class Taken_Time implements Serializable
{
public int h;
public int m;
Taken_Time(int ph, int pm)
{
h=ph;
m=pm;
}
}
class Date_Time implements Serializable
{
public int d;
public int m;
public int y;
Date_Time(int pd, int pm, int py)
{
d=pd;
m=pm;
y=py;
}
}
public class Remind implements Serializable{
public int ID;
public String medicine_name;
public String dosage;
public Date_Time dateTime;
public Taken_Time takenTime;
public int frequency;
Remind()
{
ID = 0;
medicine_name = "Vicodin";
dosage = "2 tabletki";
takenTime = new Taken_Time(2,10);
dateTime = new Date_Time(10,10,2017);
frequency = 12;
}
}
Remind_Activity.java
package com.example.mateusz.anty_zapominacz;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.content.*;
import java.util.Random;
public class Remind_Activity extends AppCompatActivity {
private EditText medicine_name;
private EditText dosage;
private Button taken_time;
private Button date_time;
private EditText frequency;
private Button save;
private Button delete;
private TextView taken_time2;
private TextView date_time2;
private Context ActivityContext;
public static final String temporalFile = "temporalFile1.dat";
public static final String collectionFile = "collectionFile.dat";
public static final String bundleID = "23546derwyw34y673q46er43265";
private Serialization serialization;
private int edit_number = -1;
private Remind edit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add);
ActivityContext = getApplicationContext();
serialization = new Serialization(ActivityContext);
medicine_name = (EditText)findViewById(R.id.NazwaLeku);
dosage = (EditText)findViewById(R.id.DawkaLeku);
taken_time = (Button)findViewById(R.id.GodzinaZazycia);
date_time = (Button)findViewById(R.id.DataZazycia);
frequency = (EditText)findViewById(R.id.Czestotliwosc);
save = (Button)findViewById(R.id.Zapisz);
delete = (Button)findViewById(R.id.Usun);
taken_time2 = (TextView)findViewById(R.id.tv_godzinaZazycia);
date_time2 = (TextView)findViewById(R.id.tv_dataZazycia);
Bundle extras = getIntent().getExtras();
if (extras != null) {
String str = extras.getString(bundleID);
edit_number = Integer.parseInt(str);
}
if (edit_number != -1){
Collection remindcollection = serialization.readCollection2(collectionFile);
Remind remind = remindcollection.list.get(edit_number);
serialization.saveRemind2(temporalFile, remind);
}
edit = serialization.readRemind2(temporalFile);
RefreshTextView();
medicine_name.setText(edit.medicine_name);
dosage.setText(edit.dosage);
frequency.setText(Integer.toString(edit.frequency));
taken_time.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ActivityContext, Time.class);
startActivity(intent);
}
});
date_time.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ActivityContext, Date.class);
startActivity(intent);
}
});
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Remind edit = serialization.readRemind2(temporalFile);
edit.medicine_name = medicine_name.getText().toString();
edit.dosage = dosage.getText().toString();
edit.frequency = Integer.parseInt(frequency.getText().toString());
Collection remindcollection = serialization.readCollection2(collectionFile);
if (edit_number == -1) {
Random generator = new Random();
int random = generator.nextInt(9999);
for (int i = 0; i < remindcollection.list.size(); i++){
if (random == remindcollection.list.get(i).ID)
{
i=0;
random = generator.nextInt(9999);
}
}
edit.ID = random;
Provider.setAlarmForRemind(getApplicationContext(), edit);
remindcollection.list.add(edit);
}
else{
remindcollection.list.remove(edit_number);
Provider.deleteAlarm(getApplicationContext(), edit.ID);
Provider.setAlarmForRemind(getApplicationContext(), edit);
remindcollection.list.add(edit_number, edit);
}
serialization.SaveCollection2(collectionFile, remindcollection);
Toast.makeText(ActivityContext, "Zapisano",Toast.LENGTH_SHORT).show();
finish();
}
});
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (edit_number == -1){
finish();
}
else{
Collection remindcollection = serialization.readCollection2(collectionFile);
Provider.deleteAlarm(getApplicationContext(), remindcollection.list.get(edit_number).ID);
remindcollection.list.remove(edit_number);
serialization.SaveCollection2(collectionFile, remindcollection);
}
Toast.makeText(ActivityContext, "Usunięto",Toast.LENGTH_SHORT).show();
finish();
}
});
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
@Override
protected void onResume(){
super.onResume();
onNewIntent(getIntent());
RefreshTextView();
}
private void RefreshTextView(){
Remind edit = serialization.readRemind2(temporalFile);
int m = edit.takenTime.m;
int h = edit.takenTime.h;
int dd = edit.dateTime.d;
int mm = edit.dateTime.m + 1;
int yy = edit.dateTime.y;
String alarmDate = "";
String hourAlarm = "";
if (dd < 10) {
alarmDate +="0";
}
alarmDate += Integer.toString(dd);
alarmDate += "/";
if (mm < 10) {
alarmDate +="0";
}
alarmDate += Integer.toString(mm);
alarmDate += "/";
alarmDate += Integer.toString(yy);
if (h < 10) {
hourAlarm += "0";
}
hourAlarm += Integer.toString(h);
hourAlarm += ":";
if (m < 10) {
hourAlarm += "0";
}
hourAlarm += Integer.toString(m);
date_time2.setText(alarmDate);
taken_time2.setText(hourAlarm);
}
}
Serialization.java
package com.example.mateusz.anty_zapominacz;
import java.io.*;
import android.content.*;
public class Serialization {
private Context context;
Serialization(Context p_context)
{
context = p_context;
}
void saveRemind(String file_name, Remind saveObject) throws IOException {
FileOutputStream primary_input = context.openFileOutput(file_name, Context.MODE_PRIVATE);
ObjectOutputStream object_input = new ObjectOutputStream(primary_input);
object_input.writeObject(saveObject);
object_input.close();
primary_input.close();
}
void saveRemind2(String file_name, Remind saveObject){
try {
saveRemind(file_name, saveObject);
} catch (IOException e) {
e.printStackTrace();
}
}
Remind readRemind(String file_name) throws IOException, ClassNotFoundException {
FileInputStream primary_input = context.openFileInput(file_name);
ObjectInputStream object_input = new ObjectInputStream(primary_input);
Remind retVal = (Remind) object_input.readObject();
object_input.close();
primary_input.close();
return retVal;
}
Remind readRemind2(String file_name)
{
Remind edit = new Remind();
try {
edit = readRemind(file_name);
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return edit;
}
void saveCollection(String file_name, Collection save_object) throws IOException {
FileOutputStream primary_input = context.openFileOutput(file_name, Context.MODE_PRIVATE);
ObjectOutputStream object_input = new ObjectOutputStream(primary_input);
object_input.writeObject(save_object);
object_input.close();
primary_input.close();
}
void SaveCollection2(String file_name, Collection save_object){
try {
saveCollection(file_name, save_object);
} catch (IOException e) {
e.printStackTrace();
}
}
Collection readCollection(String file_name) throws IOException, ClassNotFoundException {
FileInputStream primaryInput = context.openFileInput(file_name);
ObjectInputStream input_object = new ObjectInputStream(primaryInput);
Collection retVal = (Collection) input_object.readObject();
input_object.close();
primaryInput.close();
return retVal;
}
Collection readCollection2(String file_name) {
Collection remindcollection = new Collection();
try {
remindcollection = readCollection(file_name);
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return remindcollection;
}
}
Time.java
package com.example.mateusz.anty_zapominacz;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TimePicker;
public class Time extends AppCompatActivity {
private TimePicker timePicker;
public static final String temporalFile = "temporalFile1.dat";
public Serialization serialization;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hour);
serialization = new Serialization(getApplicationContext());
timePicker = (TimePicker) findViewById(R.id.timePicker);
timePicker.setIs24HourView(true);
}
@Override
protected void onPause()
{
super.onPause();
Remind edit = serialization.readRemind2(temporalFile);
edit.takenTime.h = timePicker.getCurrentHour();
edit.takenTime.m = timePicker.getCurrentMinute();
serialization.saveRemind2(temporalFile, edit);
}
}
|
Post został pochwalony 0 razy
Ostatnio zmieniony przez matix77 dnia Czw 16:25, 14 Gru 2017, w całości zmieniany 5 razy
|
|
|
|
|
|
matix77
Administrator
Dołączył: 21 Kwi 2008
Posty: 82
Przeczytał: 0 tematów
Pomógł: 4 razy
Ostrzeżeń: 0/5
|
Wysłany:
Czw 16:27, 14 Gru 2017 |
|
Z racji sporego zainteresowania owym tematem zmieniłem format kodu i dołączyłem nazewnictwo klas. Dołączam też pliki konfiguracyjne xml, bo o to też mnie niektórzy pytali
add.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_add_remind"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mateusz.anty_zapominacz.Remind_Activity">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Nazwa Leku"
android:ems="10"
android:id="@+id/NazwaLeku"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignLeft="@+id/DawkaLeku"
android:layout_alignStart="@+id/DawkaLeku" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Dawka Leku"
android:ems="10"
android:layout_below="@+id/NazwaLeku"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="19dp"
android:id="@+id/DawkaLeku"
android:layout_alignLeft="@+id/GodzinaZazycia"
android:layout_alignStart="@+id/GodzinaZazycia" />
<Button
android:text="Godzina Zażycia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/DawkaLeku"
android:layout_marginTop="27dp"
android:id="@+id/GodzinaZazycia"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="Data Zazycia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/DataZazycia"
android:layout_below="@+id/GodzinaZazycia"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="23dp"
android:layout_alignLeft="@+id/GodzinaZazycia"
android:layout_alignStart="@+id/GodzinaZazycia" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:layout_marginTop="28dp"
android:id="@+id/Czestotliwosc"
android:layout_below="@+id/DataZazycia"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:text="12" />
<Button
android:text="Zapisz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Zapisz"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="Usuń"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/Usun" />
<TextView
android:text="Co ile godzin:"
android:textSize="44px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:layout_alignBaseline="@+id/Czestotliwosc"
android:layout_alignBottom="@+id/Czestotliwosc"
android:layout_toLeftOf="@+id/Czestotliwosc"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="Nazwa leku:"
android:textSize="44px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView5"
android:layout_alignBaseline="@+id/NazwaLeku"
android:layout_alignBottom="@+id/NazwaLeku"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="Dawka leku:"
android:textSize="44px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView4"
android:layout_alignBaseline="@+id/DawkaLeku"
android:layout_alignBottom="@+id/DawkaLeku"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="00:00"
android:textSize="44px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_godzinaZazycia"
android:layout_alignBaseline="@+id/GodzinaZazycia"
android:layout_alignBottom="@+id/GodzinaZazycia"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="01.01.2010"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="44px"
android:id="@+id/tv_dataZazycia"
android:layout_alignBaseline="@+id/DataZazycia"
android:layout_alignBottom="@+id/DataZazycia"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
alarm.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_alarm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mateusz.anty_zapominacz.Clock">
<Button
android:text="Wyłącz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/b_alarm"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="27dp"
android:textSize="70px"
android:id="@+id/tv_nazwaLeku" />
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="227dp"
android:textSize="60px"
android:id="@+id/tv_dawkaLeku" />
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mateusz.anty_zapominacz">
<application
android:allowBackup="true"
android:icon="@mipmap/launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.example.mateusz.anty_zapominacz.Main_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.mateusz.anty_zapominacz.Remind_Activity" />
<activity android:name="com.example.mateusz.anty_zapominacz.Time" />
<activity android:name="com.example.mateusz.anty_zapominacz.Date" />
<receiver android:name="com.example.mateusz.anty_zapominacz.Receiver" />
<activity android:name="com.example.mateusz.anty_zapominacz.Clock"></activity>
</application>
</manifest>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#9933cc</color>
<color name="colorPrimaryDark">#9900ff</color>
<color name="colorAccent">#FF4081</color>
</resources>
date.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_data"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mateusz.anty_zapominacz.Date">
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:id="@+id/datePicker" />
</RelativeLayout>
dimens.xml
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
hour.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_godzina"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mateusz.anty_zapominacz.Time">
<TimePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:id="@+id/timePicker" />
</RelativeLayout>
list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/nazwaLeku"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="przykladowy tekst"
android:textSize="24sp"
/>
</LinearLayout>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mateusz.anty_zapominacz.Main_activity">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="@+id/addNewRemind" />
<Button
android:id="@+id/addNewRemind"
android:text="Dodaj nowy lek"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
strings.xml
<resources>
<string name="app_name">Anty-zapominacz</string>
</resources>
styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
|
Post został pochwalony 0 razy
Ostatnio zmieniony przez matix77 dnia Czw 16:32, 14 Gru 2017, w całości zmieniany 1 raz
|
|
|
|
|
fora.pl - załóż własne forum dyskusyjne za darmo
Powered by phpBB
© 2001/3 phpBB Group :: FI Theme ::
Wszystkie czasy w strefie EET (Europa)
| |