diff --git a/Apk/app-debug.apk b/Apk/app-debug.apk index 4ac65ad..78f646a 100644 Binary files a/Apk/app-debug.apk and b/Apk/app-debug.apk differ diff --git a/OriginalDogManager/.gitignore b/OriginalDogManager/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/OriginalDogManager/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/OriginalDogManager/.idea/.gitignore b/OriginalDogManager/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/OriginalDogManager/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/OriginalDogManager/.idea/caches/build_file_checksums.ser b/OriginalDogManager/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..0d55f89 Binary files /dev/null and b/OriginalDogManager/.idea/caches/build_file_checksums.ser differ diff --git a/OriginalDogManager/.idea/compiler.xml b/OriginalDogManager/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/OriginalDogManager/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OriginalDogManager/.idea/gradle.xml b/OriginalDogManager/.idea/gradle.xml new file mode 100644 index 0000000..9bba60d --- /dev/null +++ b/OriginalDogManager/.idea/gradle.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/OriginalDogManager/.idea/jarRepositories.xml b/OriginalDogManager/.idea/jarRepositories.xml new file mode 100644 index 0000000..94436be --- /dev/null +++ b/OriginalDogManager/.idea/jarRepositories.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OriginalDogManager/.idea/misc.xml b/OriginalDogManager/.idea/misc.xml new file mode 100644 index 0000000..635999d --- /dev/null +++ b/OriginalDogManager/.idea/misc.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OriginalDogManager/.idea/modules.xml b/OriginalDogManager/.idea/modules.xml new file mode 100644 index 0000000..f296d82 --- /dev/null +++ b/OriginalDogManager/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/OriginalDogManager/.idea/runConfigurations.xml b/OriginalDogManager/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/OriginalDogManager/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/OriginalDogManager/app/.gitignore b/OriginalDogManager/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/OriginalDogManager/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/OriginalDogManager/app/build.gradle b/OriginalDogManager/app/build.gradle new file mode 100644 index 0000000..7f132c2 --- /dev/null +++ b/OriginalDogManager/app/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 29 + defaultConfig { + applicationId "com.chanresti.originaldogmanager" + minSdkVersion 16 + targetSdkVersion 29 + versionCode 2 + versionName "1.1" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' +} + + + + diff --git a/app/libs/YouTubeAndroidPlayerApi.jar b/OriginalDogManager/app/libs/YouTubeAndroidPlayerApi.jar similarity index 100% rename from app/libs/YouTubeAndroidPlayerApi.jar rename to OriginalDogManager/app/libs/YouTubeAndroidPlayerApi.jar diff --git a/app/proguard-rules.pro b/OriginalDogManager/app/proguard-rules.pro similarity index 97% rename from app/proguard-rules.pro rename to OriginalDogManager/app/proguard-rules.pro index 6e7ffa9..f1b4245 100644 --- a/app/proguard-rules.pro +++ b/OriginalDogManager/app/proguard-rules.pro @@ -1,21 +1,21 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/chanresti/originaldogmanager/ExampleInstrumentedTest.java b/OriginalDogManager/app/src/androidTest/java/com/chanresti/originaldogmanager/ExampleInstrumentedTest.java similarity index 83% rename from app/src/androidTest/java/com/chanresti/originaldogmanager/ExampleInstrumentedTest.java rename to OriginalDogManager/app/src/androidTest/java/com/chanresti/originaldogmanager/ExampleInstrumentedTest.java index 1cfefb9..30deada 100644 --- a/app/src/androidTest/java/com/chanresti/originaldogmanager/ExampleInstrumentedTest.java +++ b/OriginalDogManager/app/src/androidTest/java/com/chanresti/originaldogmanager/ExampleInstrumentedTest.java @@ -1,26 +1,26 @@ -package com.chanresti.originaldogmanager; - -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() throws Exception { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); - - assertEquals("com.chanresti.originaldogmanager", appContext.getPackageName()); - } -} +package com.chanresti.originaldogmanager; + +import android.content.Context; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.chanresti.originaldogmanager", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/OriginalDogManager/app/src/main/AndroidManifest.xml similarity index 97% rename from app/src/main/AndroidManifest.xml rename to OriginalDogManager/app/src/main/AndroidManifest.xml index e876664..187e74e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/OriginalDogManager/app/src/main/AndroidManifest.xml @@ -1,43 +1,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/ic_launcher-web.png b/OriginalDogManager/app/src/main/ic_launcher-web.png similarity index 100% rename from app/src/main/ic_launcher-web.png rename to OriginalDogManager/app/src/main/ic_launcher-web.png diff --git a/app/src/main/java/com/chanresti/originaldogmanager/AlarmPage.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/AlarmPage.java similarity index 88% rename from app/src/main/java/com/chanresti/originaldogmanager/AlarmPage.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/AlarmPage.java index 3b5a46b..ad37ac8 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/AlarmPage.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/AlarmPage.java @@ -1,27 +1,27 @@ -package com.chanresti.originaldogmanager; - -import android.media.MediaPlayer; -import android.os.Bundle; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.widget.TextView; - -public class AlarmPage extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_alarmpage); -//hide action bar: - ActionBar actionBar = getSupportActionBar(); - actionBar.hide(); - //set the reminder text received from the intent to the textbox - TextView textView=findViewById(R.id.intentstring); - String intentsting=getIntent().getExtras().getString("intentstring"); - textView.setText("\n"+"Please Remember To:"+"\n"+intentsting); - //play the sound of a dog howling - MediaPlayer mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.dogsound); - mediaPlayer.start(); - } - -} +package com.chanresti.originaldogmanager; + +import android.media.MediaPlayer; +import android.os.Bundle; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import android.widget.TextView; + +public class AlarmPage extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_alarmpage); +//hide action bar: + ActionBar actionBar = getSupportActionBar(); + actionBar.hide(); + //set the reminder text received from the intent to the textbox + TextView textView=findViewById(R.id.intentstring); + String intentsting=getIntent().getExtras().getString("intentstring"); + textView.setText("\n"+"Please Remember To:"+"\n"+intentsting); + //play the sound of a dog howling + MediaPlayer mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.dogsound); + mediaPlayer.start(); + } + +} diff --git a/app/src/main/java/com/chanresti/originaldogmanager/AlarmReceiver.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/AlarmReceiver.java similarity index 96% rename from app/src/main/java/com/chanresti/originaldogmanager/AlarmReceiver.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/AlarmReceiver.java index ce82c45..9c01d1e 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/AlarmReceiver.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/AlarmReceiver.java @@ -1,100 +1,100 @@ -package com.chanresti.originaldogmanager; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.os.Build; -import android.support.annotation.RequiresApi; -import android.util.Log; -import android.widget.Toast; - -import java.util.ArrayList; -import java.util.Date; - -public class AlarmReceiver extends BroadcastReceiver { -public static String currentdate; - String TAG = "AlarmReceiver"; - - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) - @Override - public void onReceive(Context context, Intent intent) { - // TODO Auto-generated method stub - RemindersDbAdapter adapter=new RemindersDbAdapter(context); - adapter.open(); - - - Log.d("MainTag"+TAG, " onReceive has been called"+"\t"); - - - if (intent.getAction() != null && context != null) { - - - if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) { - adapter.open(); - //On boot completed,the next alarm is scheduled - Log.d("MainTag"+TAG, "onReceive: BOOT_COMPLETED"); - //first get the current time - Date date3=new Date(); - Log.d("MainTag"+TAG, "onReceive here is the tome I will use to see if the next reminder is eligible"+"\t"+date3.toString()); - //get the next date to be scheduled - Date date=NotificationScheduler.nextalarm(adapter.fetchDates()); - Log.d("MainTag"+TAG, "onReceive here is latest date"+"\t"+date.toString()); - //check whether the next date is after the current date - if (date.after(date3)){ - //if it is set an alarm to fire at that time - NotificationScheduler.setReminder(context, AlarmReceiver.class, date); - Log.d("MainTag"+TAG, " onReceive i have set next alarm to"+"\t"+date.toString()); - } - else { - Log.d("MainTag"+TAG, "onReceive I didn't set the alarm this date was before this time"+"\t"+date3.toString()); - } - adapter.close(); - }} - - - -//on receive: - //whenever a reminder is set in notificationscheduler, the public static variable :datestring is updated to the corresponding reminder's date as it is in the database - Log.d("MainTag"+TAG, "onReceive i am about to fetch reminders by this datestring:"+"\t"+currentdate); - //this datestring is used to identify the corresponding reminder in the database so that the reminder text for this particular time is acquired - ArrayList reminder=adapter.fetchReminderByDateString(currentdate); - int x=0; - //the sting that will be passed to the alarmpage class through the intent - String intentstring; - StringBuilder stringBuilder=new StringBuilder(); - while(x>=0 && x<=reminder.size()-1){ - Log.d("MainTag"+TAG, " onReceive I am about to call NotificationScheduler.showNotification "+"\t"); - //show notification with the reminder text - NotificationScheduler.showNotification(context, RemindersActivity.class, - " DogManager", reminder.get(x).getContent()); - if(x>=1){ - stringBuilder.append(" and "); - } - stringBuilder.append(reminder.get(x).getContent()); - - - Log.d("MainTag"+TAG, " onReceive in while"+"\t"+"Reminder"+x+"\t"+reminder.get(x).getDatestring()); - Log.d("MainTag"+TAG, " onReceive in while"+"\t"+"This is the text to show:"+x+"\t"+reminder.get(x).getContent()); - - Toast.makeText(context,"Remember To:"+"\t"+reminder.get(x).getContent(),Toast.LENGTH_LONG).show(); - x=x+1; - } - intentstring=stringBuilder.toString(); - //start the alarmpage activity - NotificationScheduler.showalarmpage(intentstring,context); -//get the next date to be scheduled and set a reminder for that date: - Date date3=new Date(); - Log.d("MainTag"+TAG, "onReceive here is the tome I will use to see if the next reminder is eligible"+"\t"+date3.toString()); - Date date=NotificationScheduler.nextalarm(adapter.fetchDates()); - Log.d("MainTag"+TAG, "onReceive here is latest date"+"\t"+date.toString()); - if (date.after(date3)){ - NotificationScheduler.setReminder(context, AlarmReceiver.class, date); - Log.d("MainTag"+TAG, " onReceive i have set next alarm to"+"\t"+date.toString()); - } - else { - Log.d("MainTag"+TAG, "onReceive I didn't set the alarm this date was before this time"+"\t"+date3.toString()); - } - adapter.close(); - } -} - +package com.chanresti.originaldogmanager; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Build; +import androidx.annotation.RequiresApi; +import android.util.Log; +import android.widget.Toast; + +import java.util.ArrayList; +import java.util.Date; + +public class AlarmReceiver extends BroadcastReceiver { +public static String currentdate; + String TAG = "AlarmReceiver"; + + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) + @Override + public void onReceive(Context context, Intent intent) { + // TODO Auto-generated method stub + RemindersDbAdapter adapter=new RemindersDbAdapter(context); + adapter.open(); + + + Log.d("MainTag"+TAG, " onReceive has been called"+"\t"); + + + if (intent.getAction() != null && context != null) { + + + if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) { + adapter.open(); + //On boot completed,the next alarm is scheduled + Log.d("MainTag"+TAG, "onReceive: BOOT_COMPLETED"); + //first get the current time + Date date3=new Date(); + Log.d("MainTag"+TAG, "onReceive here is the tome I will use to see if the next reminder is eligible"+"\t"+date3.toString()); + //get the next date to be scheduled + Date date=NotificationScheduler.nextalarm(adapter.fetchDates()); + Log.d("MainTag"+TAG, "onReceive here is latest date"+"\t"+date.toString()); + //check whether the next date is after the current date + if (date.after(date3)){ + //if it is set an alarm to fire at that time + NotificationScheduler.setReminder(context, AlarmReceiver.class, date); + Log.d("MainTag"+TAG, " onReceive i have set next alarm to"+"\t"+date.toString()); + } + else { + Log.d("MainTag"+TAG, "onReceive I didn't set the alarm this date was before this time"+"\t"+date3.toString()); + } + adapter.close(); + }} + + + +//on receive: + //whenever a reminder is set in notificationscheduler, the public static variable :datestring is updated to the corresponding reminder's date as it is in the database + Log.d("MainTag"+TAG, "onReceive i am about to fetch reminders by this datestring:"+"\t"+currentdate); + //this datestring is used to identify the corresponding reminder in the database so that the reminder text for this particular time is acquired + ArrayList reminder=adapter.fetchReminderByDateString(currentdate); + int x=0; + //the sting that will be passed to the alarmpage class through the intent + String intentstring; + StringBuilder stringBuilder=new StringBuilder(); + while(x>=0 && x<=reminder.size()-1){ + Log.d("MainTag"+TAG, " onReceive I am about to call NotificationScheduler.showNotification "+"\t"); + //show notification with the reminder text + NotificationScheduler.showNotification(context, RemindersActivity.class, + " DogManager", reminder.get(x).getContent()); + if(x>=1){ + stringBuilder.append(" and "); + } + stringBuilder.append(reminder.get(x).getContent()); + + + Log.d("MainTag"+TAG, " onReceive in while"+"\t"+"Reminder"+x+"\t"+reminder.get(x).getDatestring()); + Log.d("MainTag"+TAG, " onReceive in while"+"\t"+"This is the text to show:"+x+"\t"+reminder.get(x).getContent()); + + Toast.makeText(context,"Remember To:"+"\t"+reminder.get(x).getContent(),Toast.LENGTH_LONG).show(); + x=x+1; + } + intentstring=stringBuilder.toString(); + //start the alarmpage activity + NotificationScheduler.showalarmpage(intentstring,context); +//get the next date to be scheduled and set a reminder for that date: + Date date3=new Date(); + Log.d("MainTag"+TAG, "onReceive here is the tome I will use to see if the next reminder is eligible"+"\t"+date3.toString()); + Date date=NotificationScheduler.nextalarm(adapter.fetchDates()); + Log.d("MainTag"+TAG, "onReceive here is latest date"+"\t"+date.toString()); + if (date.after(date3)){ + NotificationScheduler.setReminder(context, AlarmReceiver.class, date); + Log.d("MainTag"+TAG, " onReceive i have set next alarm to"+"\t"+date.toString()); + } + else { + Log.d("MainTag"+TAG, "onReceive I didn't set the alarm this date was before this time"+"\t"+date3.toString()); + } + adapter.close(); + } +} + diff --git a/app/src/main/java/com/chanresti/originaldogmanager/Dog.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/Dog.java similarity index 95% rename from app/src/main/java/com/chanresti/originaldogmanager/Dog.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/Dog.java index dd6fbdc..d215e12 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/Dog.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/Dog.java @@ -1,91 +1,91 @@ -package com.chanresti.originaldogmanager; - -/** - * Created by Mwangi on 07/04/2018. - */ -//class defining the dog model -public class Dog { - private int dId; - private String mUriString; - private String mDogName; - private String mWeight; - private String mGender; - private String mBreed; - private String mHabits; - private String mAge; - - public Dog(int dId, String mUriString, String mDogName, String mWeight, String mGender, String mBreed, String mHabits, String mAge) { - this.dId = dId; - this.mUriString = mUriString; - this.mDogName = mDogName; - this.mWeight = mWeight; - this.mGender = mGender; - this.mBreed = mBreed; - this.mHabits = mHabits; - this.mAge = mAge; - } - - public int getdId() { - return dId; - } - - public void setdId(int dId) { - this.dId = dId; - } - - public String getUriString() { - return mUriString; - } - - public void setUriString(String mUriString) { - this.mUriString = mUriString; - } - - public String getDogName() { - return mDogName; - } - - public void setDogName(String mDogName) { - this.mDogName = mDogName; - } - - public String getWeight() { - return mWeight; - } - - public void setWeight(String mWeight) { - this.mWeight = mWeight; - } - - public String getGender() { - return mGender; - } - - public void setGender(String mGender) { - this.mGender = mGender; - } - - public String getBreed() { - return mBreed; - } - - public void setBreed(String mBreed) { - this.mBreed = mBreed; - } - - public String getHabits() { - return mHabits; - } - - public void setHabits(String mHabits) { - this.mHabits = mHabits; - } - - public String getAge() { - return mAge; - } - - public void setAge(String mAge) { - this.mAge = mAge; - } -} +package com.chanresti.originaldogmanager; + +/** + * Created by Mwangi on 07/04/2018. + */ +//class defining the dog model +public class Dog { + private int dId; + private String mUriString; + private String mDogName; + private String mWeight; + private String mGender; + private String mBreed; + private String mHabits; + private String mAge; + + public Dog(int dId, String mUriString, String mDogName, String mWeight, String mGender, String mBreed, String mHabits, String mAge) { + this.dId = dId; + this.mUriString = mUriString; + this.mDogName = mDogName; + this.mWeight = mWeight; + this.mGender = mGender; + this.mBreed = mBreed; + this.mHabits = mHabits; + this.mAge = mAge; + } + + public int getdId() { + return dId; + } + + public void setdId(int dId) { + this.dId = dId; + } + + public String getUriString() { + return mUriString; + } + + public void setUriString(String mUriString) { + this.mUriString = mUriString; + } + + public String getDogName() { + return mDogName; + } + + public void setDogName(String mDogName) { + this.mDogName = mDogName; + } + + public String getWeight() { + return mWeight; + } + + public void setWeight(String mWeight) { + this.mWeight = mWeight; + } + + public String getGender() { + return mGender; + } + + public void setGender(String mGender) { + this.mGender = mGender; + } + + public String getBreed() { + return mBreed; + } + + public void setBreed(String mBreed) { + this.mBreed = mBreed; + } + + public String getHabits() { + return mHabits; + } + + public void setHabits(String mHabits) { + this.mHabits = mHabits; + } + + public String getAge() { + return mAge; + } + + public void setAge(String mAge) { + this.mAge = mAge; + } +} diff --git a/app/src/main/java/com/chanresti/originaldogmanager/DogsDbAdapter.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/DogsDbAdapter.java similarity index 97% rename from app/src/main/java/com/chanresti/originaldogmanager/DogsDbAdapter.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/DogsDbAdapter.java index 1d1eca8..d52a2a1 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/DogsDbAdapter.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/DogsDbAdapter.java @@ -1,168 +1,168 @@ -package com.chanresti.originaldogmanager; - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.SQLException; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.util.Log; - -import java.util.ArrayList; - -/** - * Created by Mwangi on 07/04/2018. - */ -//a class containing methods for CRUD operations in the dogs database -public class DogsDbAdapter { - public static final String COL_ID = "_id"; - public static final String COL_URISTRING = "uristring"; - public static final String COL_NAME="dogname"; - public static final String COL_WEIGHT = "weight"; - public static final String COL_GENDER="gender"; - public static final String COL_BREED="breed"; - public static final String COL_HABITS="habits"; - public static final String COL_AGE="age"; - //these are the corresponding indices - public static final int INDEX_ID = 0; - public static final int INDEX_URISTRING = INDEX_ID + 1; - public static final int INDEX_NAME = INDEX_ID + 2; - public static final int INDEX_WEIGHT = INDEX_ID + 3; - public static final int INDEX_GENDER = INDEX_ID + 4; - public static final int INDEX_BREED = INDEX_ID + 5; - public static final int INDEX_HABITS = INDEX_ID + 6; - public static final int INDEX_AGE = INDEX_ID + 7; - //used for logging - private static final String TAG = "RemindersAdapter"; - - private DogsDbAdapter.DatabaseHelper mDbHelper; - private SQLiteDatabase mDb; - private static final String DATABASE_NAME = "dba_dgs"; - private static final String TABLE_NAME = "tbl_dgs"; - private static final int DATABASE_VERSION = 1; - private final Context mCtx; - //SQL statement used to create the database - private static final String DATABASE_CREATE = - "CREATE TABLE if not exists " + TABLE_NAME + " ( " + - COL_ID + " INTEGER PRIMARY KEY autoincrement, " + - COL_URISTRING + " TEXT, " + - COL_NAME + " TEXT, " + - COL_WEIGHT + " TEXT, " + - COL_GENDER + " TEXT, " + - COL_BREED + " TEXT, " + - COL_HABITS + " TEXT, " + - COL_AGE + " TEXT );"; - public DogsDbAdapter(Context mCtx) { - this.mCtx = mCtx; - } - public void open() throws SQLException { - Log.d("MainTag"+TAG, "open database"); - mDbHelper = new DogsDbAdapter.DatabaseHelper(mCtx); - mDb = mDbHelper.getWritableDatabase(); - } - //close - public void close() { - if (mDbHelper != null) { - mDbHelper.close(); - }} - - public void createDog(String URISTRING,String NAME ,String WEIGHT,String GENDER,String BREED,String HABITS,String AGE ) { - ContentValues values = new ContentValues(); - values.put(COL_URISTRING, URISTRING); - values.put(COL_NAME , NAME ); - values.put(COL_WEIGHT, WEIGHT); - values.put(COL_GENDER, GENDER); - values.put(COL_BREED, BREED); - values.put(COL_HABITS, HABITS); - values.put(COL_AGE, AGE); - - - mDb.insert(TABLE_NAME, null, values); - } - public Cursor fetchDogByName(String Name) { - Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID,COL_URISTRING, COL_NAME, COL_WEIGHT, COL_GENDER, COL_BREED, COL_HABITS, - COL_AGE}, COL_NAME + "=?", - new String[]{Name}, null, null, null, null - ); - if (cursor != null) - cursor.moveToFirst(); - return cursor; - - } - - public void updateDog(Dog dog) { - ContentValues values = new ContentValues(); - values.put(COL_URISTRING, dog.getUriString()); - values.put(COL_NAME, dog.getDogName()); - values.put(COL_WEIGHT, dog.getWeight()); - values.put(COL_GENDER, dog.getGender()); - values.put(COL_BREED, dog.getBreed()); - values.put(COL_HABITS, dog.getHabits()); - values.put(COL_AGE, dog.getAge()); - - mDb.update(TABLE_NAME, values, - COL_ID + "=?", new String[]{String.valueOf(dog.getdId())}); - } - - public ArrayList fetchDogNames() { - ArrayList a=new ArrayList<>(); - - Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID,COL_URISTRING, COL_NAME, COL_WEIGHT, COL_GENDER, COL_BREED, COL_HABITS, - COL_AGE}, null, - null, null, null, null - ); - if (cursor != null){ - while (cursor.moveToNext()){ - - String dog=cursor.getString(INDEX_NAME); - a.add(dog); - } - - } - if(a.size()<=0){ - a.add("No Dogs"); - } - - - return a; - } - public Dog getDogFromCursor (Cursor cursor){ - Dog dog=null; - if (cursor != null){ - - dog=new Dog( - cursor.getInt(INDEX_ID), - cursor.getString(INDEX_URISTRING), - cursor.getString(INDEX_NAME), - cursor.getString(INDEX_WEIGHT), - cursor.getString( INDEX_GENDER), - cursor.getString(INDEX_BREED), - cursor.getString(INDEX_HABITS ), - cursor.getString(INDEX_AGE)); - } - return dog; - } - public void deleteDogById(int nId) { - mDb.delete(TABLE_NAME, COL_ID + "=?", new String[]{String.valueOf(nId)}); - - } - - private static class DatabaseHelper extends SQLiteOpenHelper { - DatabaseHelper(Context context) { - super(context, DATABASE_NAME, null, DATABASE_VERSION); - } - @Override - public void onCreate(SQLiteDatabase db) { - Log.v(TAG, DATABASE_CREATE); - db.execSQL(DATABASE_CREATE); - } - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - Log.w(TAG, "Upgrading database from version " + oldVersion + " to " - + newVersion + ", which will destroy all old data"); - db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); - onCreate(db); - } - } - -} +package com.chanresti.originaldogmanager; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.SQLException; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; +import android.util.Log; + +import java.util.ArrayList; + +/** + * Created by Mwangi on 07/04/2018. + */ +//a class containing methods for CRUD operations in the dogs database +public class DogsDbAdapter { + public static final String COL_ID = "_id"; + public static final String COL_URISTRING = "uristring"; + public static final String COL_NAME="dogname"; + public static final String COL_WEIGHT = "weight"; + public static final String COL_GENDER="gender"; + public static final String COL_BREED="breed"; + public static final String COL_HABITS="habits"; + public static final String COL_AGE="age"; + //these are the corresponding indices + public static final int INDEX_ID = 0; + public static final int INDEX_URISTRING = INDEX_ID + 1; + public static final int INDEX_NAME = INDEX_ID + 2; + public static final int INDEX_WEIGHT = INDEX_ID + 3; + public static final int INDEX_GENDER = INDEX_ID + 4; + public static final int INDEX_BREED = INDEX_ID + 5; + public static final int INDEX_HABITS = INDEX_ID + 6; + public static final int INDEX_AGE = INDEX_ID + 7; + //used for logging + private static final String TAG = "RemindersAdapter"; + + private DogsDbAdapter.DatabaseHelper mDbHelper; + private SQLiteDatabase mDb; + private static final String DATABASE_NAME = "dba_dgs"; + private static final String TABLE_NAME = "tbl_dgs"; + private static final int DATABASE_VERSION = 1; + private final Context mCtx; + //SQL statement used to create the database + private static final String DATABASE_CREATE = + "CREATE TABLE if not exists " + TABLE_NAME + " ( " + + COL_ID + " INTEGER PRIMARY KEY autoincrement, " + + COL_URISTRING + " TEXT, " + + COL_NAME + " TEXT, " + + COL_WEIGHT + " TEXT, " + + COL_GENDER + " TEXT, " + + COL_BREED + " TEXT, " + + COL_HABITS + " TEXT, " + + COL_AGE + " TEXT );"; + public DogsDbAdapter(Context mCtx) { + this.mCtx = mCtx; + } + public void open() throws SQLException { + Log.d("MainTag"+TAG, "open database"); + mDbHelper = new DogsDbAdapter.DatabaseHelper(mCtx); + mDb = mDbHelper.getWritableDatabase(); + } + //close + public void close() { + if (mDbHelper != null) { + mDbHelper.close(); + }} + + public void createDog(String URISTRING,String NAME ,String WEIGHT,String GENDER,String BREED,String HABITS,String AGE ) { + ContentValues values = new ContentValues(); + values.put(COL_URISTRING, URISTRING); + values.put(COL_NAME , NAME ); + values.put(COL_WEIGHT, WEIGHT); + values.put(COL_GENDER, GENDER); + values.put(COL_BREED, BREED); + values.put(COL_HABITS, HABITS); + values.put(COL_AGE, AGE); + + + mDb.insert(TABLE_NAME, null, values); + } + public Cursor fetchDogByName(String Name) { + Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID,COL_URISTRING, COL_NAME, COL_WEIGHT, COL_GENDER, COL_BREED, COL_HABITS, + COL_AGE}, COL_NAME + "=?", + new String[]{Name}, null, null, null, null + ); + if (cursor != null) + cursor.moveToFirst(); + return cursor; + + } + + public void updateDog(Dog dog) { + ContentValues values = new ContentValues(); + values.put(COL_URISTRING, dog.getUriString()); + values.put(COL_NAME, dog.getDogName()); + values.put(COL_WEIGHT, dog.getWeight()); + values.put(COL_GENDER, dog.getGender()); + values.put(COL_BREED, dog.getBreed()); + values.put(COL_HABITS, dog.getHabits()); + values.put(COL_AGE, dog.getAge()); + + mDb.update(TABLE_NAME, values, + COL_ID + "=?", new String[]{String.valueOf(dog.getdId())}); + } + + public ArrayList fetchDogNames() { + ArrayList a=new ArrayList<>(); + + Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID,COL_URISTRING, COL_NAME, COL_WEIGHT, COL_GENDER, COL_BREED, COL_HABITS, + COL_AGE}, null, + null, null, null, null + ); + if (cursor != null){ + while (cursor.moveToNext()){ + + String dog=cursor.getString(INDEX_NAME); + a.add(dog); + } + + } + if(a.size()<=0){ + a.add("No Dogs"); + } + + + return a; + } + public Dog getDogFromCursor (Cursor cursor){ + Dog dog=null; + if (cursor != null){ + + dog=new Dog( + cursor.getInt(INDEX_ID), + cursor.getString(INDEX_URISTRING), + cursor.getString(INDEX_NAME), + cursor.getString(INDEX_WEIGHT), + cursor.getString( INDEX_GENDER), + cursor.getString(INDEX_BREED), + cursor.getString(INDEX_HABITS ), + cursor.getString(INDEX_AGE)); + } + return dog; + } + public void deleteDogById(int nId) { + mDb.delete(TABLE_NAME, COL_ID + "=?", new String[]{String.valueOf(nId)}); + + } + + private static class DatabaseHelper extends SQLiteOpenHelper { + DatabaseHelper(Context context) { + super(context, DATABASE_NAME, null, DATABASE_VERSION); + } + @Override + public void onCreate(SQLiteDatabase db) { + Log.v(TAG, DATABASE_CREATE); + db.execSQL(DATABASE_CREATE); + } + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + + newVersion + ", which will destroy all old data"); + db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); + onCreate(db); + } + } + +} diff --git a/app/src/main/java/com/chanresti/originaldogmanager/MyListAdapter.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/MyListAdapter.java similarity index 93% rename from app/src/main/java/com/chanresti/originaldogmanager/MyListAdapter.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/MyListAdapter.java index fdb0516..955f771 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/MyListAdapter.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/MyListAdapter.java @@ -1,79 +1,79 @@ -package com.chanresti.originaldogmanager; - -/** - * Created by Mwangi on 14/03/2018. - */ - -import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.TextView; - -import java.util.List; - -import static com.chanresti.originaldogmanager.VideoList.intent; - -//an adapter for the VideoList In the dog-training activity - public class MyListAdapter extends ArrayAdapter { - - - List videoList; - - - //activity context - Context context; - - //the layout resource file for the list items - int resource; - - //constructor initializing the values - public MyListAdapter(Context context, int resource, List videoList) { - super(context, resource, videoList); - this.context = context; - this.resource = resource; - this.videoList = videoList; - } - - //this will return the ListView Item as a View - @NonNull - @Override - public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) { - - - LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View view = layoutInflater.inflate(R.layout.custom_listlayout, null, false); - ImageView imageView = view.findViewById(R.id.imageView); - TextView content=view.findViewById(R.id.tag); - Button play=view.findViewById(R.id.playbutton); - final YVideo video = videoList.get(position); - content.setText(video.getTag()); - imageView.setImageDrawable(context.getResources().getDrawable(video.getImage())); - play.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - - intent.putExtra("Activeimage", video.getVideo()); - context.startActivity(intent); - } - }); - imageView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - - intent.putExtra("Activeimage", video.getVideo()); - context.startActivity(intent); - } - }); - return view; - } - - -} +package com.chanresti.originaldogmanager; + +/** + * Created by Mwangi on 14/03/2018. + */ + +import android.content.Context; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.List; + +import static com.chanresti.originaldogmanager.VideoList.intent; + +//an adapter for the VideoList In the dog-training activity + public class MyListAdapter extends ArrayAdapter { + + + List videoList; + + + //activity context + Context context; + + //the layout resource file for the list items + int resource; + + //constructor initializing the values + public MyListAdapter(Context context, int resource, List videoList) { + super(context, resource, videoList); + this.context = context; + this.resource = resource; + this.videoList = videoList; + } + + //this will return the ListView Item as a View + @NonNull + @Override + public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) { + + + LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + View view = layoutInflater.inflate(R.layout.custom_listlayout, null, false); + ImageView imageView = view.findViewById(R.id.imageView); + TextView content=view.findViewById(R.id.tag); + Button play=view.findViewById(R.id.playbutton); + final YVideo video = videoList.get(position); + content.setText(video.getTag()); + imageView.setImageDrawable(context.getResources().getDrawable(video.getImage())); + play.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + + intent.putExtra("Activeimage", video.getVideo()); + context.startActivity(intent); + } + }); + imageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + + intent.putExtra("Activeimage", video.getVideo()); + context.startActivity(intent); + } + }); + return view; + } + + +} diff --git a/app/src/main/java/com/chanresti/originaldogmanager/NotificationScheduler.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/NotificationScheduler.java similarity index 96% rename from app/src/main/java/com/chanresti/originaldogmanager/NotificationScheduler.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/NotificationScheduler.java index 53b0dee..d50775a 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/NotificationScheduler.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/NotificationScheduler.java @@ -1,155 +1,155 @@ -package com.chanresti.originaldogmanager; - -import android.app.AlarmManager; -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.media.RingtoneManager; -import android.net.Uri; -import android.os.Build; -import android.support.annotation.RequiresApi; -import android.support.v4.app.TaskStackBuilder; -import android.util.Log; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; - -import static android.content.Context.ALARM_SERVICE; - -/** - * Created by Mwangi on 21/03/2018. - */ - -public class NotificationScheduler { - static DateFormat df=new SimpleDateFormat("HH:mm dd/MM/yyyy"); - public static final int DAILY_REMINDER_REQUEST_CODE=100; - public static int UNIQUE_NOTIFICATION_REQUEST_CODE=100; - public static final String TAG="NotifiScheduler"; - -//method for setting a reminder to a certain date(notice that the date has time within it) - public static void setReminder(Context context, Class cls,Date datestring) - { - Log.d("MainTag"+TAG, " setReminder has been called"+"\t"+"with this date:"+"\t"+datestring.toString()); - //getting the current time - Calendar calendar = Calendar.getInstance(); - Calendar setcalendar = Calendar.getInstance(); - //getting the time of the reminder - setcalendar.setTime(datestring); - if(setcalendar.after(calendar)){ - //setting the public static variable currentdate in alarmreceiver so that it can be used to identify the reminder - AlarmReceiver.currentdate=df.format(datestring); - Log.d("MainTag"+TAG, " setReminder I have set AlarmReceiver.currentdate to"+"\t"+df.format(datestring)+"\t"+"see?: "+AlarmReceiver.currentdate); - // cancel already scheduled reminders - cancelReminder(context,cls); - Log.d("MainTag"+TAG, " setReminder I have canceled the previous alarm"+"\t"); - - - // Enable a receiver - - ComponentName receiver = new ComponentName(context, cls); - PackageManager pm = context.getPackageManager(); - - pm.setComponentEnabledSetting(receiver, - PackageManager.COMPONENT_ENABLED_STATE_ENABLED, - PackageManager.DONT_KILL_APP); - - - Intent intent1 = new Intent(context, cls); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, DAILY_REMINDER_REQUEST_CODE, intent1, PendingIntent.FLAG_UPDATE_CURRENT); - AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE); - am.set(AlarmManager.RTC_WAKEUP, setcalendar.getTimeInMillis(), pendingIntent);} - - } -//a method to cancel already set reminders - public static void cancelReminder(Context context,Class cls) - { - // Disable a receiver - Log.d("MainTag"+TAG, " cancelReminder has been called"+"\t"); - ComponentName receiver = new ComponentName(context, cls); - PackageManager pm = context.getPackageManager(); - - pm.setComponentEnabledSetting(receiver, - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - PackageManager.DONT_KILL_APP); - - Intent intent1 = new Intent(context, cls); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, DAILY_REMINDER_REQUEST_CODE, intent1, PendingIntent.FLAG_UPDATE_CURRENT); - AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE); - am.cancel(pendingIntent); - pendingIntent.cancel(); - } -//a method to show notifications - @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) - public static void showNotification(Context context, Class cls, String title, String content) - { - Log.d("MainTag"+TAG, " showNotification has been called"+"\t"+"to show"+"\t"+title+"\t"+content); - Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); - - ++UNIQUE_NOTIFICATION_REQUEST_CODE; - Intent notificationIntent = new Intent(context, cls); - - - TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); - stackBuilder.addParentStack(cls); - stackBuilder.addNextIntent(notificationIntent); - - PendingIntent pendingIntent = stackBuilder.getPendingIntent(UNIQUE_NOTIFICATION_REQUEST_CODE, PendingIntent.FLAG_ONE_SHOT); - - - - Notification notification = new Notification.Builder(context).setContentTitle(title) - .setContentText(content) - .setAutoCancel(true) - .setSound(alarmSound) - .setSmallIcon(R.mipmap.ic_launcher_round) - .setContentIntent(pendingIntent).build(); - - NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.notify(UNIQUE_NOTIFICATION_REQUEST_CODE, notification); - - }// a method to show the alarmpage activity - public static void showalarmpage(String Doggiewords,Context context){ - Intent intent67=new Intent(context,AlarmPage.class); - intent67.putExtra("intentstring",Doggiewords); - intent67.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(intent67); - - } - //a method to get the next date to be scheduled - public static Date nextalarm(ArrayList a){ - Log.d("MainTag"+TAG, " nextAlarm has been called"+"\t"+"with this arraylist"+"\t"+a.toString()); - - DateCompare compare = new DateCompare(); - - Collections.sort(a, compare); - Log.d("MainTag"+TAG, "nextAlarm here is the sorted arraylist I am using:"+"\t"+a.toString()); - Date date=new Date(); - if(a.size()>0){ - date=a.get(0);} - else { - Log.d("MainTag"+TAG, " nextAlarm the size of arraylist is less or equal to zero"+"\t"); - } - Log.d("MainTag"+TAG, " nextAlarm here is the date I will return"+"\t"+date.toString()); - return date; - } -//a comparator class for sorting the arraylist - static class DateCompare implements Comparator { - - public int compare(Date one, Date two){ - - return one.compareTo(two); - - } - } - -} - +package com.chanresti.originaldogmanager; + +import android.app.AlarmManager; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.media.RingtoneManager; +import android.net.Uri; +import android.os.Build; +import androidx.annotation.RequiresApi; +import androidx.core.app.TaskStackBuilder; +import android.util.Log; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; + +import static android.content.Context.ALARM_SERVICE; + +/** + * Created by Mwangi on 21/03/2018. + */ + +public class NotificationScheduler { + static DateFormat df=new SimpleDateFormat("HH:mm dd/MM/yyyy"); + public static final int DAILY_REMINDER_REQUEST_CODE=100; + public static int UNIQUE_NOTIFICATION_REQUEST_CODE=100; + public static final String TAG="NotifiScheduler"; + +//method for setting a reminder to a certain date(notice that the date has time within it) + public static void setReminder(Context context, Class cls,Date datestring) + { + Log.d("MainTag"+TAG, " setReminder has been called"+"\t"+"with this date:"+"\t"+datestring.toString()); + //getting the current time + Calendar calendar = Calendar.getInstance(); + Calendar setcalendar = Calendar.getInstance(); + //getting the time of the reminder + setcalendar.setTime(datestring); + if(setcalendar.after(calendar)){ + //setting the public static variable currentdate in alarmreceiver so that it can be used to identify the reminder + AlarmReceiver.currentdate=df.format(datestring); + Log.d("MainTag"+TAG, " setReminder I have set AlarmReceiver.currentdate to"+"\t"+df.format(datestring)+"\t"+"see?: "+AlarmReceiver.currentdate); + // cancel already scheduled reminders + cancelReminder(context,cls); + Log.d("MainTag"+TAG, " setReminder I have canceled the previous alarm"+"\t"); + + + // Enable a receiver + + ComponentName receiver = new ComponentName(context, cls); + PackageManager pm = context.getPackageManager(); + + pm.setComponentEnabledSetting(receiver, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + + + Intent intent1 = new Intent(context, cls); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, DAILY_REMINDER_REQUEST_CODE, intent1, PendingIntent.FLAG_UPDATE_CURRENT); + AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE); + am.set(AlarmManager.RTC_WAKEUP, setcalendar.getTimeInMillis(), pendingIntent);} + + } +//a method to cancel already set reminders + public static void cancelReminder(Context context,Class cls) + { + // Disable a receiver + Log.d("MainTag"+TAG, " cancelReminder has been called"+"\t"); + ComponentName receiver = new ComponentName(context, cls); + PackageManager pm = context.getPackageManager(); + + pm.setComponentEnabledSetting(receiver, + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + PackageManager.DONT_KILL_APP); + + Intent intent1 = new Intent(context, cls); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, DAILY_REMINDER_REQUEST_CODE, intent1, PendingIntent.FLAG_UPDATE_CURRENT); + AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE); + am.cancel(pendingIntent); + pendingIntent.cancel(); + } +//a method to show notifications + @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) + public static void showNotification(Context context, Class cls, String title, String content) + { + Log.d("MainTag"+TAG, " showNotification has been called"+"\t"+"to show"+"\t"+title+"\t"+content); + Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); + + ++UNIQUE_NOTIFICATION_REQUEST_CODE; + Intent notificationIntent = new Intent(context, cls); + + + TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); + stackBuilder.addParentStack(cls); + stackBuilder.addNextIntent(notificationIntent); + + PendingIntent pendingIntent = stackBuilder.getPendingIntent(UNIQUE_NOTIFICATION_REQUEST_CODE, PendingIntent.FLAG_ONE_SHOT); + + + + Notification notification = new Notification.Builder(context).setContentTitle(title) + .setContentText(content) + .setAutoCancel(true) + .setSound(alarmSound) + .setSmallIcon(R.mipmap.ic_launcher_round) + .setContentIntent(pendingIntent).build(); + + NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + notificationManager.notify(UNIQUE_NOTIFICATION_REQUEST_CODE, notification); + + }// a method to show the alarmpage activity + public static void showalarmpage(String Doggiewords,Context context){ + Intent intent67=new Intent(context,AlarmPage.class); + intent67.putExtra("intentstring",Doggiewords); + intent67.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent67); + + } + //a method to get the next date to be scheduled + public static Date nextalarm(ArrayList a){ + Log.d("MainTag"+TAG, " nextAlarm has been called"+"\t"+"with this arraylist"+"\t"+a.toString()); + + DateCompare compare = new DateCompare(); + + Collections.sort(a, compare); + Log.d("MainTag"+TAG, "nextAlarm here is the sorted arraylist I am using:"+"\t"+a.toString()); + Date date=new Date(); + if(a.size()>0){ + date=a.get(0);} + else { + Log.d("MainTag"+TAG, " nextAlarm the size of arraylist is less or equal to zero"+"\t"); + } + Log.d("MainTag"+TAG, " nextAlarm here is the date I will return"+"\t"+date.toString()); + return date; + } +//a comparator class for sorting the arraylist + static class DateCompare implements Comparator { + + public int compare(Date one, Date two){ + + return one.compareTo(two); + + } + } + +} + diff --git a/app/src/main/java/com/chanresti/originaldogmanager/Profile.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/Profile.java similarity index 96% rename from app/src/main/java/com/chanresti/originaldogmanager/Profile.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/Profile.java index 7098d60..1499133 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/Profile.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/Profile.java @@ -1,318 +1,318 @@ -package com.chanresti.originaldogmanager; - -import android.app.Dialog; -import android.content.DialogInterface; -import android.content.Intent; -import android.database.Cursor; -import android.graphics.Bitmap; -import android.net.Uri; -import android.os.Bundle; -import android.provider.MediaStore; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.ListView; -import android.widget.SimpleCursorAdapter; -import android.widget.Toast; - -import java.io.IOException; -import java.util.ArrayList; - -public class Profile extends AppCompatActivity { - - private int PICK_IMAGE_REQUEST = 1; - public Uri DogPicUri; - ListView mListView; - public boolean iseditopp; - Cursor Activecursor; -private DogsDbAdapter mDbAdapter; - - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_profile); - mListView=findViewById(R.id.dogdetails); - mDbAdapter=new DogsDbAdapter(this); - - setdefaults(); - mDbAdapter.open(); - Button button=findViewById(R.id.button4); - Button buttondel=findViewById(R.id.buttondel); - buttondel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - if (Activecursor!=null){ - showDeleteDialog(); - } - else { - Toast.makeText(getApplicationContext(),"please view or add a dogfile first",Toast.LENGTH_LONG).show(); - } - } - }); - button.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (Activecursor!=null){ - iseditopp=true; - showImagePicker(); - } - else { - Toast.makeText(getApplicationContext(),"please view or add a dogfile first",Toast.LENGTH_LONG).show(); - } - } - }); - - } -//a method to show a dialog to confirm if a user wants to delete a dog file and delete it - private void showDeleteDialog() { - AlertDialog.Builder builder = new AlertDialog.Builder(Profile.this); - builder.setTitle("Delete"); - builder.setMessage("Are You Sure you want to delete this dogfile?"); - builder.setPositiveButton("DELETE", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - - mDbAdapter.deleteDogById(Activecursor.getInt(0)); - Toast.makeText(getApplicationContext(),"DogFile Deleted Successfully",Toast.LENGTH_SHORT).show(); - setdefaults(); - dialogInterface.dismiss(); - } - }); - builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - dialogInterface.dismiss(); - } - }); - final Dialog dialog = builder.create(); - dialog.show(); - } -// a method used to set all views to their default states - private void setdefaults() { - ImageView imageView = (ImageView) findViewById(R.id.ImageView); - imageView.setImageDrawable(getResources().getDrawable(R.drawable.defaultdog)); - String[] defaults={"name","weight","gender","breed","habits","age"}; - ArrayAdapter adapter2=new ArrayAdapter(Profile.this,android.R.layout.simple_list_item_1,defaults); - - mListView.setAdapter(adapter2); - } -// a method to show the imagepicker - public void showImagePicker(){ - Toast.makeText(getApplicationContext(),"Please select an Image of your Dog",Toast.LENGTH_LONG).show(); - Intent intent = new Intent(); -// Show only images, no videos or anything else - intent.setType("image/*"); - intent.setAction(Intent.ACTION_GET_CONTENT); -// Always show the chooser (if there are multiple options available) - startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); - - } -// when an image is picked: the dialog to collect all the information about the dog is shown - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { - - Uri uri = data.getData(); - DogPicUri=uri; - if(iseditopp){ - Dog dog=(mDbAdapter.getDogFromCursor(Activecursor)); - fireCustomDialog(dog);} - else { - fireCustomDialog(null);} - } - else {Toast.makeText(getApplicationContext(),"Please pick an image",Toast.LENGTH_LONG).show();} - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.profile_options_menu,menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.newfile: - iseditopp=false; - showImagePicker(); - return true; - case R.id.viewfile: - showViewDialog(); - return true; - default: - return false; - } - } - //a method to show dialog to collect all the information about the dog is shown and this information plus the uri in string form is inserted into the database -//this method also shows the dialog for editing a dogfile - private void fireCustomDialog(final Dog dog){ - - final Dialog dialog = new Dialog(this); - dialog.setContentView(R.layout.profile_dialog); - dialog.setTitle("New Dog"); - final boolean isEditOperation = (dog != null); - final EditText name,weight,gender,breed,age,habits; - name=dialog.findViewById(R.id.name_profiledialog); - weight=dialog.findViewById(R.id.weight_profiledialog); - gender=dialog.findViewById(R.id.gender_profiledialog); - breed=dialog.findViewById(R.id.breed_profiledialog); - age=dialog.findViewById(R.id.age_profiledialog); - habits=dialog.findViewById(R.id.habits_profiledialog); - if (isEditOperation){ - name.setText(dog.getDogName()); - weight.setText(dog.getWeight()); - gender.setText(dog.getGender()); - breed.setText(dog.getBreed()); - age.setText(dog.getAge()); - dialog.setTitle("Edit DogFile"); - } - - - Button cancel,commit; - cancel=dialog.findViewById(R.id.profiledialog_cancel); - commit=dialog.findViewById(R.id.profiledialog_commit); - commit.setOnClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - final String uristring=DogPicUri.toString(); - final String dogname=name.getText().toString(); - final String dogweight= weight.getText().toString(); - final String doggender=gender.getText().toString(); - final String dogbreed= breed.getText().toString(); - final String dogage= age.getText().toString(); - final String doghabits= habits.getText().toString(); - if (isEditOperation) { - Dog dogEdited = new Dog(dog.getdId(),uristring,dogname,dogweight,doggender,dogbreed,doghabits,dogage); - mDbAdapter.updateDog(dogEdited); - updateViews(Uri.parse(uristring),mDbAdapter.fetchDogByName(dogname)); -//this is for new reminder - } else { - mDbAdapter.createDog(uristring,dogname,dogweight,doggender,dogbreed,doghabits,dogage); - Toast.makeText(getApplicationContext(),"A dogfile has been successfully added",Toast.LENGTH_LONG).show(); - updateViews(Uri.parse(uristring),mDbAdapter.fetchDogByName(dogname)); - } - - - dialog.dismiss(); - } - }); - cancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } - }); -dialog.show(); - -} - -// a method to set the listview and imageview to the data of a particular dogfile selected -public void updateViews(Uri uri, Cursor cursor){ - - - if (uri!=null){ -// if (ActivityCompat.checkSelfPermission(this, Manifest.permission.MANAGE_DOCUMENTS) != PackageManager.PERMISSION_GRANTED) { -// // TODO: Consider calling -// // ActivityCompat#requestPermissions -// // here to request the missing permissions, and then overriding -// // public void onRequestPermissionsResult(int requestCode, String[] permissions, -// // int[] grantResults) -// // to handle the case where the user grants the permission. See the documentation -// // for ActivityCompat#requestPermissions for more details. -// return; -// } - try { - Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri); - // Log.d(TAG, String.valueOf(bitmap)); - ImageView imageView = (ImageView) findViewById(R.id.ImageView); - imageView.setImageBitmap(bitmap); - } catch (IOException e) { - e.printStackTrace(); - } - } - if(cursor!=null){ - Activecursor=cursor; - String[] from = new String[]{ - DogsDbAdapter.COL_NAME,DogsDbAdapter.COL_WEIGHT,DogsDbAdapter.COL_GENDER , DogsDbAdapter.COL_BREED, DogsDbAdapter.COL_HABITS, DogsDbAdapter.COL_AGE - }; - int[] to = new int[]{ - R.id.name_dogdetails, R.id.weight_dogdetails, R.id.gender_dogdetails, R.id.breed_dogdetails, R.id.habits_dogdetails, R.id.age_dogdetails - }; - SimpleCursorAdapter adapter = new SimpleCursorAdapter( -//context - Profile.this, -//the layout of the row - R.layout.dogdetailist_layout, -//cursor - cursor, -//from columns defined in the db - from, -//to the ids of views in the layout - to, -//flag - not used - 0); - mListView.setAdapter(adapter); - } -} -// a method to show the dialog from which a user can select the dogfile he or she wants to view -public void showViewDialog(){ - final boolean therearedogs; - - AlertDialog.Builder builder = new AlertDialog.Builder(Profile.this); - ListView modeListView = new ListView(Profile.this); - final ArrayList dogs = mDbAdapter.fetchDogNames(); - if (dogs.get(0).equals("No Dogs")){ - therearedogs=false; - } - else { - therearedogs=true; - } - final ArrayAdapter modeAdapter = new ArrayAdapter<>(Profile.this, - android.R.layout.simple_list_item_1, android.R.id.text1, dogs); - modeListView.setAdapter(modeAdapter); - builder.setView(modeListView); - final Dialog dialog = builder.create(); - dialog.show(); - modeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { -//edit reminder - if(therearedogs){ - String dogname=dogs.get(position); - Cursor cursor=mDbAdapter.fetchDogByName(dogname); - updateViews(Uri.parse(cursor.getString(1)),cursor); - } - else { - Toast.makeText(getApplicationContext(),"Please Add a Dog File",Toast.LENGTH_LONG).show(); - } - - dialog.dismiss(); - } - }); - - -} - - -} - - - - - - - - - +package com.chanresti.originaldogmanager; + +import android.app.Dialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.net.Uri; +import android.os.Bundle; +import android.provider.MediaStore; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.SimpleCursorAdapter; +import android.widget.Toast; + +import java.io.IOException; +import java.util.ArrayList; + +public class Profile extends AppCompatActivity { + + private int PICK_IMAGE_REQUEST = 1; + public Uri DogPicUri; + ListView mListView; + public boolean iseditopp; + Cursor Activecursor; +private DogsDbAdapter mDbAdapter; + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_profile); + mListView=findViewById(R.id.dogdetails); + mDbAdapter=new DogsDbAdapter(this); + + setdefaults(); + mDbAdapter.open(); + Button button=findViewById(R.id.button4); + Button buttondel=findViewById(R.id.buttondel); + buttondel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + if (Activecursor!=null){ + showDeleteDialog(); + } + else { + Toast.makeText(getApplicationContext(),"please view or add a dogfile first",Toast.LENGTH_LONG).show(); + } + } + }); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (Activecursor!=null){ + iseditopp=true; + showImagePicker(); + } + else { + Toast.makeText(getApplicationContext(),"please view or add a dogfile first",Toast.LENGTH_LONG).show(); + } + } + }); + + } +//a method to show a dialog to confirm if a user wants to delete a dog file and delete it + private void showDeleteDialog() { + AlertDialog.Builder builder = new AlertDialog.Builder(Profile.this); + builder.setTitle("Delete"); + builder.setMessage("Are You Sure you want to delete this dogfile?"); + builder.setPositiveButton("DELETE", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + + mDbAdapter.deleteDogById(Activecursor.getInt(0)); + Toast.makeText(getApplicationContext(),"DogFile Deleted Successfully",Toast.LENGTH_SHORT).show(); + setdefaults(); + dialogInterface.dismiss(); + } + }); + builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.dismiss(); + } + }); + final Dialog dialog = builder.create(); + dialog.show(); + } +// a method used to set all views to their default states + private void setdefaults() { + ImageView imageView = (ImageView) findViewById(R.id.ImageView); + imageView.setImageDrawable(getResources().getDrawable(R.drawable.defaultdog)); + String[] defaults={"name","weight","gender","breed","habits","age"}; + ArrayAdapter adapter2=new ArrayAdapter(Profile.this,android.R.layout.simple_list_item_1,defaults); + + mListView.setAdapter(adapter2); + } +// a method to show the imagepicker + public void showImagePicker(){ + Toast.makeText(getApplicationContext(),"Please select an Image of your Dog",Toast.LENGTH_LONG).show(); + Intent intent = new Intent(); +// Show only images, no videos or anything else + intent.setType("image/*"); + intent.setAction(Intent.ACTION_GET_CONTENT); +// Always show the chooser (if there are multiple options available) + startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); + + } +// when an image is picked: the dialog to collect all the information about the dog is shown + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { + + Uri uri = data.getData(); + DogPicUri=uri; + if(iseditopp){ + Dog dog=(mDbAdapter.getDogFromCursor(Activecursor)); + fireCustomDialog(dog);} + else { + fireCustomDialog(null);} + } + else {Toast.makeText(getApplicationContext(),"Please pick an image",Toast.LENGTH_LONG).show();} + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.profile_options_menu,menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.newfile: + iseditopp=false; + showImagePicker(); + return true; + case R.id.viewfile: + showViewDialog(); + return true; + default: + return false; + } + } + //a method to show dialog to collect all the information about the dog is shown and this information plus the uri in string form is inserted into the database +//this method also shows the dialog for editing a dogfile + private void fireCustomDialog(final Dog dog){ + + final Dialog dialog = new Dialog(this); + dialog.setContentView(R.layout.profile_dialog); + dialog.setTitle("New Dog"); + final boolean isEditOperation = (dog != null); + final EditText name,weight,gender,breed,age,habits; + name=dialog.findViewById(R.id.name_profiledialog); + weight=dialog.findViewById(R.id.weight_profiledialog); + gender=dialog.findViewById(R.id.gender_profiledialog); + breed=dialog.findViewById(R.id.breed_profiledialog); + age=dialog.findViewById(R.id.age_profiledialog); + habits=dialog.findViewById(R.id.habits_profiledialog); + if (isEditOperation){ + name.setText(dog.getDogName()); + weight.setText(dog.getWeight()); + gender.setText(dog.getGender()); + breed.setText(dog.getBreed()); + age.setText(dog.getAge()); + dialog.setTitle("Edit DogFile"); + } + + + Button cancel,commit; + cancel=dialog.findViewById(R.id.profiledialog_cancel); + commit=dialog.findViewById(R.id.profiledialog_commit); + commit.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + final String uristring=DogPicUri.toString(); + final String dogname=name.getText().toString(); + final String dogweight= weight.getText().toString(); + final String doggender=gender.getText().toString(); + final String dogbreed= breed.getText().toString(); + final String dogage= age.getText().toString(); + final String doghabits= habits.getText().toString(); + if (isEditOperation) { + Dog dogEdited = new Dog(dog.getdId(),uristring,dogname,dogweight,doggender,dogbreed,doghabits,dogage); + mDbAdapter.updateDog(dogEdited); + updateViews(Uri.parse(uristring),mDbAdapter.fetchDogByName(dogname)); +//this is for new reminder + } else { + mDbAdapter.createDog(uristring,dogname,dogweight,doggender,dogbreed,doghabits,dogage); + Toast.makeText(getApplicationContext(),"A dogfile has been successfully added",Toast.LENGTH_LONG).show(); + updateViews(Uri.parse(uristring),mDbAdapter.fetchDogByName(dogname)); + } + + + dialog.dismiss(); + } + }); + cancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + } + }); +dialog.show(); + +} + +// a method to set the listview and imageview to the data of a particular dogfile selected +public void updateViews(Uri uri, Cursor cursor){ + + + if (uri!=null){ +// if (ActivityCompat.checkSelfPermission(this, Manifest.permission.MANAGE_DOCUMENTS) != PackageManager.PERMISSION_GRANTED) { +// // TODO: Consider calling +// // ActivityCompat#requestPermissions +// // here to request the missing permissions, and then overriding +// // public void onRequestPermissionsResult(int requestCode, String[] permissions, +// // int[] grantResults) +// // to handle the case where the user grants the permission. See the documentation +// // for ActivityCompat#requestPermissions for more details. +// return; +// } + try { + Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri); + // Log.d(TAG, String.valueOf(bitmap)); + ImageView imageView = (ImageView) findViewById(R.id.ImageView); + imageView.setImageBitmap(bitmap); + } catch (IOException e) { + e.printStackTrace(); + } + } + if(cursor!=null){ + Activecursor=cursor; + String[] from = new String[]{ + DogsDbAdapter.COL_NAME,DogsDbAdapter.COL_WEIGHT,DogsDbAdapter.COL_GENDER , DogsDbAdapter.COL_BREED, DogsDbAdapter.COL_HABITS, DogsDbAdapter.COL_AGE + }; + int[] to = new int[]{ + R.id.name_dogdetails, R.id.weight_dogdetails, R.id.gender_dogdetails, R.id.breed_dogdetails, R.id.habits_dogdetails, R.id.age_dogdetails + }; + SimpleCursorAdapter adapter = new SimpleCursorAdapter( +//context + Profile.this, +//the layout of the row + R.layout.dogdetailist_layout, +//cursor + cursor, +//from columns defined in the db + from, +//to the ids of views in the layout + to, +//flag - not used + 0); + mListView.setAdapter(adapter); + } +} +// a method to show the dialog from which a user can select the dogfile he or she wants to view +public void showViewDialog(){ + final boolean therearedogs; + + AlertDialog.Builder builder = new AlertDialog.Builder(Profile.this); + ListView modeListView = new ListView(Profile.this); + final ArrayList dogs = mDbAdapter.fetchDogNames(); + if (dogs.get(0).equals("No Dogs")){ + therearedogs=false; + } + else { + therearedogs=true; + } + final ArrayAdapter modeAdapter = new ArrayAdapter<>(Profile.this, + android.R.layout.simple_list_item_1, android.R.id.text1, dogs); + modeListView.setAdapter(modeAdapter); + builder.setView(modeListView); + final Dialog dialog = builder.create(); + dialog.show(); + modeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { +//edit reminder + if(therearedogs){ + String dogname=dogs.get(position); + Cursor cursor=mDbAdapter.fetchDogByName(dogname); + updateViews(Uri.parse(cursor.getString(1)),cursor); + } + else { + Toast.makeText(getApplicationContext(),"Please Add a Dog File",Toast.LENGTH_LONG).show(); + } + + dialog.dismiss(); + } + }); + + +} + + +} + + + + + + + + + diff --git a/app/src/main/java/com/chanresti/originaldogmanager/Reminder.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/Reminder.java similarity index 95% rename from app/src/main/java/com/chanresti/originaldogmanager/Reminder.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/Reminder.java index a6179b5..ffce6c8 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/Reminder.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/Reminder.java @@ -1,54 +1,54 @@ -package com.chanresti.originaldogmanager; - -/** - * Created by Mwangi on 13/03/2018. - */ - -// a class defining the reminder model -public class Reminder { - - private int mId; - private String mContent; - private String mDatestring; - private int mImportant; - - public Reminder(int mId, String mContent, String mDatestring, int mImportant) { - this.mId = mId; - this.mContent = mContent; - this.mDatestring = mDatestring; - this.mImportant = mImportant; - } - - public int getId() { - return mId; - } - - public void setId(int mId) { - this.mId = mId; - } - - public String getContent() { - return mContent; - } - - public void setContent(String mContent) { - this.mContent = mContent; - } - - public String getDatestring() { - return mDatestring; - } - - public void setDatestring(String mDatestring) { - this.mDatestring = mDatestring; - } - - public int getImportant() { - return mImportant; - } - - public void setImportant(int mImportant) { - this.mImportant = mImportant; - } -} - +package com.chanresti.originaldogmanager; + +/** + * Created by Mwangi on 13/03/2018. + */ + +// a class defining the reminder model +public class Reminder { + + private int mId; + private String mContent; + private String mDatestring; + private int mImportant; + + public Reminder(int mId, String mContent, String mDatestring, int mImportant) { + this.mId = mId; + this.mContent = mContent; + this.mDatestring = mDatestring; + this.mImportant = mImportant; + } + + public int getId() { + return mId; + } + + public void setId(int mId) { + this.mId = mId; + } + + public String getContent() { + return mContent; + } + + public void setContent(String mContent) { + this.mContent = mContent; + } + + public String getDatestring() { + return mDatestring; + } + + public void setDatestring(String mDatestring) { + this.mDatestring = mDatestring; + } + + public int getImportant() { + return mImportant; + } + + public void setImportant(int mImportant) { + this.mImportant = mImportant; + } +} + diff --git a/app/src/main/java/com/chanresti/originaldogmanager/RemindersActivity.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/RemindersActivity.java similarity index 95% rename from app/src/main/java/com/chanresti/originaldogmanager/RemindersActivity.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/RemindersActivity.java index bae96bd..80bd4d6 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/RemindersActivity.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/RemindersActivity.java @@ -1,409 +1,409 @@ -package com.chanresti.originaldogmanager; - -import android.app.DatePickerDialog; -import android.app.Dialog; -import android.app.TimePickerDialog; -import android.content.Intent; -import android.database.Cursor; -import android.os.Build; -import android.os.Bundle; -import android.support.design.widget.NavigationView; -import android.support.v4.view.GravityCompat; -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBarDrawerToggle; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.util.Log; -import android.view.ActionMode; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.Window; -import android.widget.AbsListView; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.CheckBox; -import android.widget.DatePicker; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.TimePicker; -import android.widget.Toast; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; - -public class RemindersActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener,NavigationView.OnNavigationItemSelectedListener { - -private DrawerLayout mDraw; - - private ListView mListView; - public String MainTag="MainTag"; - - public int hh=0, mm=0, dd=0, MM=0, y=0; - public TimePickerDialog timePickerDialog; - public DatePickerDialog datePickerDialog; - Dialog dialog ; - private RemindersDbAdapter mDbAdapter; - private RemindersSimpleCursorAdapter mCursorAdapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_reminders); - -//configuring the side navigational drawer - mDraw=findViewById(R.id.drawer_layout); - Toolbar toolbar = findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( - this, mDraw, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); - mDraw.addDrawerListener(toggle); - toggle.syncState(); - NavigationView navigationView=findViewById(R.id.nav_view); - navigationView.setNavigationItemSelectedListener(this); - - //adapting the listview to the data in the database - mListView = findViewById(R.id.reminders_list_view); - mListView.setDivider(null); - mDbAdapter = new RemindersDbAdapter(this); - mDbAdapter.open(); - Cursor cursor = mDbAdapter.fetchAllReminders(); -//from columns defined in the db - String[] from = new String[]{ - RemindersDbAdapter.COL_CONTENT,RemindersDbAdapter.COL_DATESTRING - }; -//to the ids of views in the layout - int[] to = new int[]{ - R.id.row_text,R.id.row_datestring - }; - mCursorAdapter = new RemindersSimpleCursorAdapter( -//context - RemindersActivity.this, -//the layout of the row - R.layout.reminders_row, -//cursor - cursor, -//from columns defined in the db - from, -//to the ids of views in the layout - to, -//flag - not used - 0); - - mListView.setAdapter(mCursorAdapter); - -// on item click: - mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, final int masterListPosition, long id) { - AlertDialog.Builder builder = new AlertDialog.Builder(RemindersActivity.this); - ListView modeListView = new ListView(RemindersActivity.this); - String[] modes = new String[] { "Edit Reminder", "Delete Reminder" }; - ArrayAdapter modeAdapter = new ArrayAdapter<>(RemindersActivity.this, - android.R.layout.simple_list_item_1, android.R.id.text1, modes); - modeListView.setAdapter(modeAdapter); - builder.setView(modeListView); - final Dialog dialog = builder.create(); - dialog.show(); - modeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { -//edit reminder - //edit reminder - if (position == 0) { - int nId = getIdFromPosition(masterListPosition); - Reminder reminder = mDbAdapter.fetchReminderById(nId); - fireCustomDialog(reminder);} -//delete reminder - else { - mDbAdapter.deleteReminderById(getIdFromPosition(masterListPosition)); - mCursorAdapter.changeCursor(mDbAdapter.fetchAllReminders()); - Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); - NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); - Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); - } - - dialog.dismiss(); - } - }); - } - }); - - //when multiple list items are selected - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); - mListView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { - @Override - public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean - checked) { } - @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - MenuInflater inflater = mode.getMenuInflater(); - inflater.inflate(R.menu.del_menu, menu); - return true; - } - @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - return false; - } - @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_item_delete_reminder: - for (int nC = mCursorAdapter.getCount() - 1; nC >= 0; nC--) { - if (mListView.isItemChecked(nC)) { - mDbAdapter.deleteReminderById(getIdFromPosition(nC)); - - } - } - //set the next reminder - Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); - NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); - Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); - mode.finish(); - mCursorAdapter.changeCursor(mDbAdapter.fetchAllReminders()); - return true; - } - return false; - } - @Override - public void onDestroyActionMode(ActionMode mode) { } - });} -// Button button=findViewById(R.id.textid); -// button.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); -// NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); -// Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); -// } -// }); - } - - - @Override - public boolean onNavigationItemSelected(MenuItem item) { - // Handle navigation view item clicks here. - int id = item.getItemId(); - - if (id == R.id.nav_new) { - fireCustomDialog(null); - } else if (id == R.id.nav_training) { - Intent intent4=new Intent(RemindersActivity.this,VideoList.class); - startActivity(intent4); - } else if (id == R.id.nav_files) { - Intent intent=new Intent(RemindersActivity.this,Profile.class); - startActivity(intent); - } else if (id == R.id.nav_exit) { - finish(); - } - - - - mDraw.closeDrawer(GravityCompat.START); - return true; - } - -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// getMenuInflater().inflate(R.menu.menu_reminders,menu); -// -// return true; -// } -// -// @Override -// public boolean onOptionsItemSelected(MenuItem item) { -// switch (item.getItemId()) { -// case R.id.action_new: -// fireCustomDialog(null); -// Log.d(getLocalClassName(),"create new Reminder"); -// return true; -// case R.id.action_dogtraining: -// Intent intent4=new Intent(RemindersActivity.this,VideoList.class); -// startActivity(intent4); -// -// return true; -// case R.id.action_dogfiles: -// Intent intent=new Intent(RemindersActivity.this,Profile.class); -// startActivity(intent); -// return true; -// case R.id.action_exit: -// finish(); -// return true; -// default: -// return false; -// } -// } - - private int getIdFromPosition(int nC) { - return (int)mCursorAdapter.getItemId(nC); - } - - - - private void fireCustomDialog(final Reminder reminder){ - dialog = new Dialog(this); - Date date5=new Date(); - Calendar calendar2=getCalendarFromDate(date5); - int y5=calendar2.get(Calendar.YEAR); - int m5= calendar2.get(Calendar.MONTH); - int d5=calendar2.get(Calendar.DAY_OF_MONTH); - timePickerDialog=new TimePickerDialog(RemindersActivity.this, this, calendar2.get(Calendar.HOUR_OF_DAY), calendar2.get(Calendar.MINUTE), true); - datePickerDialog=new DatePickerDialog(RemindersActivity.this, this, y5, m5, d5); - timePickerDialog.setCanceledOnTouchOutside(true); - datePickerDialog.setCanceledOnTouchOutside(true); - timePickerDialog.setTitle("Time"); - - datePickerDialog.setTitle("Date"); - - - dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); - dialog.setContentView(R.layout.dialog_custom); - TextView titleView = (TextView) dialog.findViewById(R.id.custom_title); - final EditText editCustom = (EditText) dialog.findViewById(R.id.custom_edit_reminder); - - Button commitButton = (Button) dialog.findViewById(R.id.custom_button_commit); - final CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.custom_check_box); - LinearLayout rootLayout = (LinearLayout) dialog.findViewById(R.id.custom_root_layout); - final boolean isEditOperation = (reminder != null); -//this is for an edit - if (isEditOperation){ - //setting the views to match the reminder selected - Calendar calendar=getCalendarFromDateString(reminder.getDatestring()); - titleView.setText("Edit Reminder"); - checkBox.setChecked(reminder.getImportant() == 1); - editCustom.setText(reminder.getContent()); - - rootLayout.setBackgroundColor(getResources().getColor(R.color.dark_blue)); - timePickerDialog=new TimePickerDialog(RemindersActivity.this, this, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true); - datePickerDialog=new DatePickerDialog(RemindersActivity.this, this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); - - - - } - commitButton.setOnClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - String dates=getDateStringFromInts(hh,mm,dd,MM,y); - String reminderText = editCustom.getText().toString(); - if (isEditOperation) { - Reminder reminderEdited = new Reminder(reminder.getId(), - reminderText, dates, checkBox.isChecked() ? 1 : 0); - mDbAdapter.updateReminder(reminderEdited); - Toast.makeText(getApplicationContext(),"A reminder has Been Set to"+"\t"+dates,Toast.LENGTH_LONG).show(); - //set the next reminder - Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); - NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); - Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); - - -//this is for new reminder - } else { - mDbAdapter.createReminder(reminderText, dates, checkBox.isChecked()); - Toast.makeText(getApplicationContext(),"A reminder has Been Set to"+"\t"+dates,Toast.LENGTH_LONG).show(); - // set the next reminder - Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); - NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); - Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); - - } - mCursorAdapter.changeCursor(mDbAdapter.fetchAllReminders()); - - dialog.dismiss(); - } - });Button buttonCancel = (Button) dialog.findViewById(R.id.custom_button_cancel); - buttonCancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } - }); - datePickerDialog.show(); - - } - - -//a method to get a date in string format from integers from the date and time pickers - public String getDateStringFromInts(int hh,int mm,int dd,int MM,int y){ - String h; - String m; - String d; - String M; - - if( hh<10){ - h="0"+hh; - } - else { - h= String.valueOf(hh); - } - if( mm<10){ - m="0"+mm; - } - else { - m= String.valueOf(mm); - } - if( dd<10){ - d="0"+dd; - } - else { - d= String.valueOf(dd); - } - if( MM<10){ - M="0"+MM; - } - else { - M= String.valueOf(MM); - } - - String datestring=h+":"+m+" "+d+"/"+M+"/"+y; - return datestring; - } - // a method for getting a corresponding calendar from a date in string form - public Calendar getCalendarFromDateString(String datestring){ - DateFormat df=new SimpleDateFormat("HH:mm dd/MM/yyyy"); - Date date = null; - try { - date=df.parse(datestring); - } catch (ParseException e) { - e.printStackTrace(); - } - Calendar calendar=Calendar.getInstance(); - calendar.setTime(date); - return calendar; - - } - // a method for getting a corresponding calendar from a date in Date form - public Calendar getCalendarFromDate(Date date){ - Calendar calendar=Calendar.getInstance(); - calendar.setTime(date); - return calendar; - - } - - @Override - public void onDateSet(DatePicker datePicker, int i, int i1, int i2) { - y=i; - MM= i1+1; - dd=i2; - timePickerDialog.show(); - } - - @Override - public void onTimeSet(TimePicker timePicker, int i, int i1) { - hh=i; - mm=i1; - dialog.show(); - } - - - +package com.chanresti.originaldogmanager; + +import android.app.DatePickerDialog; +import android.app.Dialog; +import android.app.TimePickerDialog; +import android.content.Intent; +import android.database.Cursor; +import android.os.Build; +import android.os.Bundle; +import com.google.android.material.navigation.NavigationView; +import androidx.core.view.GravityCompat; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import android.util.Log; +import android.view.ActionMode; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.Window; +import android.widget.AbsListView; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.DatePicker; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.TimePicker; +import android.widget.Toast; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class RemindersActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener,NavigationView.OnNavigationItemSelectedListener { + +private DrawerLayout mDraw; + + private ListView mListView; + public String MainTag="MainTag"; + + public int hh=0, mm=0, dd=0, MM=0, y=0; + public TimePickerDialog timePickerDialog; + public DatePickerDialog datePickerDialog; + Dialog dialog ; + private RemindersDbAdapter mDbAdapter; + private RemindersSimpleCursorAdapter mCursorAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_reminders); + +//configuring the side navigational drawer + mDraw=findViewById(R.id.drawer_layout); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( + this, mDraw, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); + mDraw.addDrawerListener(toggle); + toggle.syncState(); + NavigationView navigationView=findViewById(R.id.nav_view); + navigationView.setNavigationItemSelectedListener(this); + + //adapting the listview to the data in the database + mListView = findViewById(R.id.reminders_list_view); + mListView.setDivider(null); + mDbAdapter = new RemindersDbAdapter(this); + mDbAdapter.open(); + Cursor cursor = mDbAdapter.fetchAllReminders(); +//from columns defined in the db + String[] from = new String[]{ + RemindersDbAdapter.COL_CONTENT,RemindersDbAdapter.COL_DATESTRING + }; +//to the ids of views in the layout + int[] to = new int[]{ + R.id.row_text,R.id.row_datestring + }; + mCursorAdapter = new RemindersSimpleCursorAdapter( +//context + RemindersActivity.this, +//the layout of the row + R.layout.reminders_row, +//cursor + cursor, +//from columns defined in the db + from, +//to the ids of views in the layout + to, +//flag - not used + 0); + + mListView.setAdapter(mCursorAdapter); + +// on item click: + mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, final int masterListPosition, long id) { + AlertDialog.Builder builder = new AlertDialog.Builder(RemindersActivity.this); + ListView modeListView = new ListView(RemindersActivity.this); + String[] modes = new String[] { "Edit Reminder", "Delete Reminder" }; + ArrayAdapter modeAdapter = new ArrayAdapter<>(RemindersActivity.this, + android.R.layout.simple_list_item_1, android.R.id.text1, modes); + modeListView.setAdapter(modeAdapter); + builder.setView(modeListView); + final Dialog dialog = builder.create(); + dialog.show(); + modeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { +//edit reminder + //edit reminder + if (position == 0) { + int nId = getIdFromPosition(masterListPosition); + Reminder reminder = mDbAdapter.fetchReminderById(nId); + fireCustomDialog(reminder);} +//delete reminder + else { + mDbAdapter.deleteReminderById(getIdFromPosition(masterListPosition)); + mCursorAdapter.changeCursor(mDbAdapter.fetchAllReminders()); + Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); + NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); + Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); + } + + dialog.dismiss(); + } + }); + } + }); + + //when multiple list items are selected + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); + mListView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { + @Override + public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean + checked) { } + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + MenuInflater inflater = mode.getMenuInflater(); + inflater.inflate(R.menu.del_menu, menu); + return true; + } + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return false; + } + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_item_delete_reminder: + for (int nC = mCursorAdapter.getCount() - 1; nC >= 0; nC--) { + if (mListView.isItemChecked(nC)) { + mDbAdapter.deleteReminderById(getIdFromPosition(nC)); + + } + } + //set the next reminder + Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); + NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); + Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); + mode.finish(); + mCursorAdapter.changeCursor(mDbAdapter.fetchAllReminders()); + return true; + } + return false; + } + @Override + public void onDestroyActionMode(ActionMode mode) { } + });} +// Button button=findViewById(R.id.textid); +// button.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); +// NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); +// Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); +// } +// }); + } + + + @Override + public boolean onNavigationItemSelected(MenuItem item) { + // Handle navigation view item clicks here. + int id = item.getItemId(); + + if (id == R.id.nav_new) { + fireCustomDialog(null); + } else if (id == R.id.nav_training) { + Intent intent4=new Intent(RemindersActivity.this,VideoList.class); + startActivity(intent4); + } else if (id == R.id.nav_files) { + Intent intent=new Intent(RemindersActivity.this,Profile.class); + startActivity(intent); + } else if (id == R.id.nav_exit) { + finish(); + } + + + + mDraw.closeDrawer(GravityCompat.START); + return true; + } + +// @Override +// public boolean onCreateOptionsMenu(Menu menu) { +// getMenuInflater().inflate(R.menu.menu_reminders,menu); +// +// return true; +// } +// +// @Override +// public boolean onOptionsItemSelected(MenuItem item) { +// switch (item.getItemId()) { +// case R.id.action_new: +// fireCustomDialog(null); +// Log.d(getLocalClassName(),"create new Reminder"); +// return true; +// case R.id.action_dogtraining: +// Intent intent4=new Intent(RemindersActivity.this,VideoList.class); +// startActivity(intent4); +// +// return true; +// case R.id.action_dogfiles: +// Intent intent=new Intent(RemindersActivity.this,Profile.class); +// startActivity(intent); +// return true; +// case R.id.action_exit: +// finish(); +// return true; +// default: +// return false; +// } +// } + + private int getIdFromPosition(int nC) { + return (int)mCursorAdapter.getItemId(nC); + } + + + + private void fireCustomDialog(final Reminder reminder){ + dialog = new Dialog(this); + Date date5=new Date(); + Calendar calendar2=getCalendarFromDate(date5); + int y5=calendar2.get(Calendar.YEAR); + int m5= calendar2.get(Calendar.MONTH); + int d5=calendar2.get(Calendar.DAY_OF_MONTH); + timePickerDialog=new TimePickerDialog(RemindersActivity.this, this, calendar2.get(Calendar.HOUR_OF_DAY), calendar2.get(Calendar.MINUTE), true); + datePickerDialog=new DatePickerDialog(RemindersActivity.this, this, y5, m5, d5); + timePickerDialog.setCanceledOnTouchOutside(true); + datePickerDialog.setCanceledOnTouchOutside(true); + timePickerDialog.setTitle("Time"); + + datePickerDialog.setTitle("Date"); + + + dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + dialog.setContentView(R.layout.dialog_custom); + TextView titleView = (TextView) dialog.findViewById(R.id.custom_title); + final EditText editCustom = (EditText) dialog.findViewById(R.id.custom_edit_reminder); + + Button commitButton = (Button) dialog.findViewById(R.id.custom_button_commit); + final CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.custom_check_box); + LinearLayout rootLayout = (LinearLayout) dialog.findViewById(R.id.custom_root_layout); + final boolean isEditOperation = (reminder != null); +//this is for an edit + if (isEditOperation){ + //setting the views to match the reminder selected + Calendar calendar=getCalendarFromDateString(reminder.getDatestring()); + titleView.setText("Edit Reminder"); + checkBox.setChecked(reminder.getImportant() == 1); + editCustom.setText(reminder.getContent()); + + rootLayout.setBackgroundColor(getResources().getColor(R.color.dark_blue)); + timePickerDialog=new TimePickerDialog(RemindersActivity.this, this, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true); + datePickerDialog=new DatePickerDialog(RemindersActivity.this, this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); + + + + } + commitButton.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + String dates=getDateStringFromInts(hh,mm,dd,MM,y); + String reminderText = editCustom.getText().toString(); + if (isEditOperation) { + Reminder reminderEdited = new Reminder(reminder.getId(), + reminderText, dates, checkBox.isChecked() ? 1 : 0); + mDbAdapter.updateReminder(reminderEdited); + Toast.makeText(getApplicationContext(),"A reminder has Been Set to"+"\t"+dates,Toast.LENGTH_LONG).show(); + //set the next reminder + Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); + NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); + Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); + + +//this is for new reminder + } else { + mDbAdapter.createReminder(reminderText, dates, checkBox.isChecked()); + Toast.makeText(getApplicationContext(),"A reminder has Been Set to"+"\t"+dates,Toast.LENGTH_LONG).show(); + // set the next reminder + Date nextala=NotificationScheduler.nextalarm(mDbAdapter.fetchDates()); + NotificationScheduler.setReminder(RemindersActivity.this,AlarmReceiver.class,nextala); + Log.d(MainTag, "A reminder has been set to"+"\t"+nextala); + + } + mCursorAdapter.changeCursor(mDbAdapter.fetchAllReminders()); + + dialog.dismiss(); + } + });Button buttonCancel = (Button) dialog.findViewById(R.id.custom_button_cancel); + buttonCancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + } + }); + datePickerDialog.show(); + + } + + +//a method to get a date in string format from integers from the date and time pickers + public String getDateStringFromInts(int hh,int mm,int dd,int MM,int y){ + String h; + String m; + String d; + String M; + + if( hh<10){ + h="0"+hh; + } + else { + h= String.valueOf(hh); + } + if( mm<10){ + m="0"+mm; + } + else { + m= String.valueOf(mm); + } + if( dd<10){ + d="0"+dd; + } + else { + d= String.valueOf(dd); + } + if( MM<10){ + M="0"+MM; + } + else { + M= String.valueOf(MM); + } + + String datestring=h+":"+m+" "+d+"/"+M+"/"+y; + return datestring; + } + // a method for getting a corresponding calendar from a date in string form + public Calendar getCalendarFromDateString(String datestring){ + DateFormat df=new SimpleDateFormat("HH:mm dd/MM/yyyy"); + Date date = null; + try { + date=df.parse(datestring); + } catch (ParseException e) { + e.printStackTrace(); + } + Calendar calendar=Calendar.getInstance(); + calendar.setTime(date); + return calendar; + + } + // a method for getting a corresponding calendar from a date in Date form + public Calendar getCalendarFromDate(Date date){ + Calendar calendar=Calendar.getInstance(); + calendar.setTime(date); + return calendar; + + } + + @Override + public void onDateSet(DatePicker datePicker, int i, int i1, int i2) { + y=i; + MM= i1+1; + dd=i2; + timePickerDialog.show(); + } + + @Override + public void onTimeSet(TimePicker timePicker, int i, int i1) { + hh=i; + mm=i1; + dialog.show(); + } + + + } \ No newline at end of file diff --git a/app/src/main/java/com/chanresti/originaldogmanager/RemindersDbAdapter.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/RemindersDbAdapter.java similarity index 97% rename from app/src/main/java/com/chanresti/originaldogmanager/RemindersDbAdapter.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/RemindersDbAdapter.java index 159888c..b60ce5f 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/RemindersDbAdapter.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/RemindersDbAdapter.java @@ -1,217 +1,217 @@ -package com.chanresti.originaldogmanager; - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.SQLException; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.util.Log; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; - -/** - * Created by Mwangi on 13/03/2018. - */ - -public class RemindersDbAdapter { - //these are the column names - public static final String COL_ID = "_id"; - public static final String COL_CONTENT = "content"; - public static final String COL_DATESTRING="datestring"; - public static final String COL_IMPORTANT = "important"; - public static final String COL_MILLS="tmills"; - - //these are the corresponding indices - public static final int INDEX_ID = 0; - public static final int INDEX_CONTENT = INDEX_ID + 1; - public static final int INDEX_DATESTRING = INDEX_ID + 2; - public static final int INDEX_IMPORTANT = INDEX_ID + 3; - //used for logging - private static final String TAG = "RemindersAdapter"; - - private DatabaseHelper mDbHelper; - private SQLiteDatabase mDb; - private static final String DATABASE_NAME = "dba_remindrs"; - private static final String TABLE_NAME = "tbl_remindrs"; - private static final int DATABASE_VERSION = 1; - private final Context mCtx; - //SQL statement used to create the database - private static final String DATABASE_CREATE = - "CREATE TABLE if not exists " + TABLE_NAME + " ( " + - COL_ID + " INTEGER PRIMARY KEY autoincrement, " + - COL_CONTENT + " TEXT, " + - COL_DATESTRING + " TEXT, " + - COL_IMPORTANT + " INTEGER, " + - COL_MILLS + " INTEGER );"; - - public RemindersDbAdapter(Context mCtx) { - this.mCtx = mCtx; - } - //open - public void open() throws SQLException { - Log.d("MainTag"+TAG, "open database"); - mDbHelper = new DatabaseHelper(mCtx); - mDb = mDbHelper.getWritableDatabase(); - } - //close - public void close() { - if (mDbHelper != null) { - mDbHelper.close(); - }} - //CREATE - - public void createReminder(String name,String datetime, boolean important) { - ContentValues values = new ContentValues(); - long mills=gettimeinmills(datetime); - values.put(COL_CONTENT, name); - values.put(COL_DATESTRING, datetime); - values.put(COL_IMPORTANT, important ? 1 : 0); - values.put(COL_MILLS,mills); - mDb.insert(TABLE_NAME, null, values); - } -// a method to get time in mills from a date in string form - private long gettimeinmills(String datetime) { - DateFormat df=new SimpleDateFormat("HH:mm dd/MM/yyyy"); - Date date=null; - try { - date=df.parse(datetime); - } catch (ParseException e) { - e.printStackTrace(); - } - Calendar calendar=Calendar.getInstance(); - calendar.setTime(date); - return calendar.getTimeInMillis(); - } - - //READ - public Reminder fetchReminderById(int id) { - Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID, - COL_CONTENT, COL_DATESTRING, COL_IMPORTANT}, COL_ID + "=?", - new String[]{String.valueOf(id)}, null, null, null, null - ); - if (cursor != null) - cursor.moveToFirst(); - return new Reminder( - cursor.getInt(INDEX_ID), - cursor.getString(INDEX_CONTENT), - cursor.getString(INDEX_DATESTRING), - cursor.getInt(INDEX_IMPORTANT) - ); - } - //a method Getting Reminders with the given datestring it returns an arraylist because many reminders could be scheduled for the same time - public ArrayList fetchReminderByDateString(String datedata) { - - Log.d("MainTag"+TAG, "fetchreminderbydatestring has been called"+datedata); - - Reminder reminder; - ArrayList a=new ArrayList<>(); - Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID, - COL_CONTENT, COL_DATESTRING, COL_IMPORTANT}, COL_DATESTRING+ "=?", - new String[]{datedata}, null, null, null, null - ); - if (cursor != null){ - while (cursor.moveToNext()){ - reminder= new Reminder(cursor.getInt(INDEX_ID), cursor.getString(INDEX_CONTENT), cursor.getString(INDEX_DATESTRING), cursor.getInt(INDEX_IMPORTANT)); - Log.d("MainTag"+TAG, "While loop in fetchreminderbydatestring: This is the reminder:"+reminder.getContent()+","+reminder.getDatestring()); - a.add(reminder);} - } - if (a.size()>0){ - Log.d("MainTag"+TAG, "fetchreminderbydatestring I am returning "+"\t"+a.size()+"Reminders"+a);} - else { - Log.d("MainTag"+TAG, " We have no reminders"+"\t"+a.size()); - } - return a; - - } - //a method Returning an arraylist of dates that are eligible for scheduling - public ArrayList fetchDates() { - Log.d("MainTag"+TAG, " fetchdates has been called"+"\t"); - Date date1=new Date(); - Log.d("MainTag"+TAG, " fetchdates this is the time I am using to add dates to the arraylist. If it is before this date I skip it"+"\t"+date1.toString()); - ArrayList a = new ArrayList(); - Date date = null; - a.clear(); - Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID, - COL_CONTENT, COL_DATESTRING, COL_IMPORTANT}, null, - null, null, null, null - ); - if (cursor != null){ - while (cursor.moveToNext()){ - - String dtime=cursor.getString(INDEX_DATESTRING); - Log.d("MainTag"+TAG, " fetchdates in while loop"+"\t"+dtime); - DateFormat df=new SimpleDateFormat("HH:mm dd/MM/yyyy"); - try { - date = df.parse(dtime); - } catch (ParseException e) { - e.printStackTrace(); - } - if(date.after(date1)){ - a.add(date); - Log.d("MainTag"+TAG, " fetchdates in while loop"+"\t"+"This date has been added"+date.toString());} - else{ - Log.d("MainTag"+TAG, " fetchdates in while loop"+"\t"+"This date has not been added"+date.toString()); - } - } - - } - if (a.size()>0){ - Log.d("MainTag"+TAG, " fetchdates ArrayList returning:"+"\t"+"Size"+"\t"+a.size()+"\t"+"content"+"\t"+a);} - else { - Log.d("MainTag"+TAG, " fetchdates ArrayList returning:"+"\t"+"Size"+"\t"+a.size()+"\t"+"content"+"\t"+"Nothing here"); - } - return a; - } - //a method to get a cursor containing all reminders in the database. This cursor will be used in the adapter of the listview in RemindersActivity - public Cursor fetchAllReminders() { - Cursor mCursor = mDb.query(TABLE_NAME, new String[]{COL_ID, - COL_CONTENT, COL_DATESTRING, COL_IMPORTANT,COL_MILLS}, - null, null, null, null, COL_MILLS+" DESC" - ); - if (mCursor != null) { - mCursor.moveToFirst(); - } - return mCursor; - } - //UPDATE - public void updateReminder(Reminder reminder) { - ContentValues values = new ContentValues(); - long mills=gettimeinmills(reminder.getDatestring()); - values.put(COL_CONTENT, reminder.getContent()); - values.put(COL_DATESTRING, reminder.getDatestring()); - values.put(COL_IMPORTANT, reminder.getImportant()); - values.put(COL_MILLS,mills); - mDb.update(TABLE_NAME, values, - COL_ID + "=?", new String[]{String.valueOf(reminder.getId())}); - } - //DELETE - public void deleteReminderById(int nId) { - mDb.delete(TABLE_NAME, COL_ID + "=?", new String[]{String.valueOf(nId)}); - - } - - - - private static class DatabaseHelper extends SQLiteOpenHelper { - DatabaseHelper(Context context) { - super(context, DATABASE_NAME, null, DATABASE_VERSION); - } - @Override - public void onCreate(SQLiteDatabase db) { - Log.v(TAG, DATABASE_CREATE); - db.execSQL(DATABASE_CREATE); - } - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - Log.w(TAG, "Upgrading database from version " + oldVersion + " to " - + newVersion + ", which will destroy all old data"); - db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); - onCreate(db); - } - }} +package com.chanresti.originaldogmanager; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.SQLException; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; +import android.util.Log; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; + +/** + * Created by Mwangi on 13/03/2018. + */ + +public class RemindersDbAdapter { + //these are the column names + public static final String COL_ID = "_id"; + public static final String COL_CONTENT = "content"; + public static final String COL_DATESTRING="datestring"; + public static final String COL_IMPORTANT = "important"; + public static final String COL_MILLS="tmills"; + + //these are the corresponding indices + public static final int INDEX_ID = 0; + public static final int INDEX_CONTENT = INDEX_ID + 1; + public static final int INDEX_DATESTRING = INDEX_ID + 2; + public static final int INDEX_IMPORTANT = INDEX_ID + 3; + //used for logging + private static final String TAG = "RemindersAdapter"; + + private DatabaseHelper mDbHelper; + private SQLiteDatabase mDb; + private static final String DATABASE_NAME = "dba_remindrs"; + private static final String TABLE_NAME = "tbl_remindrs"; + private static final int DATABASE_VERSION = 1; + private final Context mCtx; + //SQL statement used to create the database + private static final String DATABASE_CREATE = + "CREATE TABLE if not exists " + TABLE_NAME + " ( " + + COL_ID + " INTEGER PRIMARY KEY autoincrement, " + + COL_CONTENT + " TEXT, " + + COL_DATESTRING + " TEXT, " + + COL_IMPORTANT + " INTEGER, " + + COL_MILLS + " INTEGER );"; + + public RemindersDbAdapter(Context mCtx) { + this.mCtx = mCtx; + } + //open + public void open() throws SQLException { + Log.d("MainTag"+TAG, "open database"); + mDbHelper = new DatabaseHelper(mCtx); + mDb = mDbHelper.getWritableDatabase(); + } + //close + public void close() { + if (mDbHelper != null) { + mDbHelper.close(); + }} + //CREATE + + public void createReminder(String name,String datetime, boolean important) { + ContentValues values = new ContentValues(); + long mills=gettimeinmills(datetime); + values.put(COL_CONTENT, name); + values.put(COL_DATESTRING, datetime); + values.put(COL_IMPORTANT, important ? 1 : 0); + values.put(COL_MILLS,mills); + mDb.insert(TABLE_NAME, null, values); + } +// a method to get time in mills from a date in string form + private long gettimeinmills(String datetime) { + DateFormat df=new SimpleDateFormat("HH:mm dd/MM/yyyy"); + Date date=null; + try { + date=df.parse(datetime); + } catch (ParseException e) { + e.printStackTrace(); + } + Calendar calendar=Calendar.getInstance(); + calendar.setTime(date); + return calendar.getTimeInMillis(); + } + + //READ + public Reminder fetchReminderById(int id) { + Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID, + COL_CONTENT, COL_DATESTRING, COL_IMPORTANT}, COL_ID + "=?", + new String[]{String.valueOf(id)}, null, null, null, null + ); + if (cursor != null) + cursor.moveToFirst(); + return new Reminder( + cursor.getInt(INDEX_ID), + cursor.getString(INDEX_CONTENT), + cursor.getString(INDEX_DATESTRING), + cursor.getInt(INDEX_IMPORTANT) + ); + } + //a method Getting Reminders with the given datestring it returns an arraylist because many reminders could be scheduled for the same time + public ArrayList fetchReminderByDateString(String datedata) { + + Log.d("MainTag"+TAG, "fetchreminderbydatestring has been called"+datedata); + + Reminder reminder; + ArrayList a=new ArrayList<>(); + Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID, + COL_CONTENT, COL_DATESTRING, COL_IMPORTANT}, COL_DATESTRING+ "=?", + new String[]{datedata}, null, null, null, null + ); + if (cursor != null){ + while (cursor.moveToNext()){ + reminder= new Reminder(cursor.getInt(INDEX_ID), cursor.getString(INDEX_CONTENT), cursor.getString(INDEX_DATESTRING), cursor.getInt(INDEX_IMPORTANT)); + Log.d("MainTag"+TAG, "While loop in fetchreminderbydatestring: This is the reminder:"+reminder.getContent()+","+reminder.getDatestring()); + a.add(reminder);} + } + if (a.size()>0){ + Log.d("MainTag"+TAG, "fetchreminderbydatestring I am returning "+"\t"+a.size()+"Reminders"+a);} + else { + Log.d("MainTag"+TAG, " We have no reminders"+"\t"+a.size()); + } + return a; + + } + //a method Returning an arraylist of dates that are eligible for scheduling + public ArrayList fetchDates() { + Log.d("MainTag"+TAG, " fetchdates has been called"+"\t"); + Date date1=new Date(); + Log.d("MainTag"+TAG, " fetchdates this is the time I am using to add dates to the arraylist. If it is before this date I skip it"+"\t"+date1.toString()); + ArrayList a = new ArrayList(); + Date date = null; + a.clear(); + Cursor cursor = mDb.query(TABLE_NAME, new String[]{COL_ID, + COL_CONTENT, COL_DATESTRING, COL_IMPORTANT}, null, + null, null, null, null + ); + if (cursor != null){ + while (cursor.moveToNext()){ + + String dtime=cursor.getString(INDEX_DATESTRING); + Log.d("MainTag"+TAG, " fetchdates in while loop"+"\t"+dtime); + DateFormat df=new SimpleDateFormat("HH:mm dd/MM/yyyy"); + try { + date = df.parse(dtime); + } catch (ParseException e) { + e.printStackTrace(); + } + if(date.after(date1)){ + a.add(date); + Log.d("MainTag"+TAG, " fetchdates in while loop"+"\t"+"This date has been added"+date.toString());} + else{ + Log.d("MainTag"+TAG, " fetchdates in while loop"+"\t"+"This date has not been added"+date.toString()); + } + } + + } + if (a.size()>0){ + Log.d("MainTag"+TAG, " fetchdates ArrayList returning:"+"\t"+"Size"+"\t"+a.size()+"\t"+"content"+"\t"+a);} + else { + Log.d("MainTag"+TAG, " fetchdates ArrayList returning:"+"\t"+"Size"+"\t"+a.size()+"\t"+"content"+"\t"+"Nothing here"); + } + return a; + } + //a method to get a cursor containing all reminders in the database. This cursor will be used in the adapter of the listview in RemindersActivity + public Cursor fetchAllReminders() { + Cursor mCursor = mDb.query(TABLE_NAME, new String[]{COL_ID, + COL_CONTENT, COL_DATESTRING, COL_IMPORTANT,COL_MILLS}, + null, null, null, null, COL_MILLS+" DESC" + ); + if (mCursor != null) { + mCursor.moveToFirst(); + } + return mCursor; + } + //UPDATE + public void updateReminder(Reminder reminder) { + ContentValues values = new ContentValues(); + long mills=gettimeinmills(reminder.getDatestring()); + values.put(COL_CONTENT, reminder.getContent()); + values.put(COL_DATESTRING, reminder.getDatestring()); + values.put(COL_IMPORTANT, reminder.getImportant()); + values.put(COL_MILLS,mills); + mDb.update(TABLE_NAME, values, + COL_ID + "=?", new String[]{String.valueOf(reminder.getId())}); + } + //DELETE + public void deleteReminderById(int nId) { + mDb.delete(TABLE_NAME, COL_ID + "=?", new String[]{String.valueOf(nId)}); + + } + + + + private static class DatabaseHelper extends SQLiteOpenHelper { + DatabaseHelper(Context context) { + super(context, DATABASE_NAME, null, DATABASE_VERSION); + } + @Override + public void onCreate(SQLiteDatabase db) { + Log.v(TAG, DATABASE_CREATE); + db.execSQL(DATABASE_CREATE); + } + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + + newVersion + ", which will destroy all old data"); + db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); + onCreate(db); + } + }} diff --git a/app/src/main/java/com/chanresti/originaldogmanager/RemindersSimpleCursorAdapter.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/RemindersSimpleCursorAdapter.java similarity index 93% rename from app/src/main/java/com/chanresti/originaldogmanager/RemindersSimpleCursorAdapter.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/RemindersSimpleCursorAdapter.java index 79c288b..76cd14e 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/RemindersSimpleCursorAdapter.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/RemindersSimpleCursorAdapter.java @@ -1,45 +1,45 @@ -package com.chanresti.originaldogmanager; - -import android.content.Context; -import android.database.Cursor; -import android.support.v4.widget.SimpleCursorAdapter; -import android.view.View; -import android.view.ViewGroup; - -/** - * Created by Mwangi on 21/03/2018. - */ -// a cursor adapter for the listview in reminders activity -public class RemindersSimpleCursorAdapter extends SimpleCursorAdapter { - public RemindersSimpleCursorAdapter(Context context, int layout, Cursor c, String[] - from, int[] to, int flags) { - super(context, layout, c, from, to, flags); - } - - @Override - public View newView(Context context, Cursor cursor, ViewGroup parent) { - return super.newView(context, cursor, parent); - } - @Override - public void bindView(View view, Context context, Cursor cursor) { - super.bindView(view, context, cursor); - ViewHolder holder = (ViewHolder) view.getTag(); - if (holder == null) { - holder = new ViewHolder(); - holder.colImp = cursor.getColumnIndexOrThrow(RemindersDbAdapter.COL_IMPORTANT); - holder.listTab = view.findViewById(R.id.row_tab); - view.setTag(holder); - } - if (cursor.getInt(holder.colImp) > 0) { - holder.listTab.setBackgroundColor(context.getResources().getColor(R.color.purple)); - } else { - holder.listTab.setBackgroundColor(context.getResources().getColor(R.color.green_r)); - } - } - static class ViewHolder { - - int colImp; - - View listTab; - } -} +package com.chanresti.originaldogmanager; + +import android.content.Context; +import android.database.Cursor; +import androidx.cursoradapter.widget.SimpleCursorAdapter; +import android.view.View; +import android.view.ViewGroup; + +/** + * Created by Mwangi on 21/03/2018. + */ +// a cursor adapter for the listview in reminders activity +public class RemindersSimpleCursorAdapter extends SimpleCursorAdapter { + public RemindersSimpleCursorAdapter(Context context, int layout, Cursor c, String[] + from, int[] to, int flags) { + super(context, layout, c, from, to, flags); + } + + @Override + public View newView(Context context, Cursor cursor, ViewGroup parent) { + return super.newView(context, cursor, parent); + } + @Override + public void bindView(View view, Context context, Cursor cursor) { + super.bindView(view, context, cursor); + ViewHolder holder = (ViewHolder) view.getTag(); + if (holder == null) { + holder = new ViewHolder(); + holder.colImp = cursor.getColumnIndexOrThrow(RemindersDbAdapter.COL_IMPORTANT); + holder.listTab = view.findViewById(R.id.row_tab); + view.setTag(holder); + } + if (cursor.getInt(holder.colImp) > 0) { + holder.listTab.setBackgroundColor(context.getResources().getColor(R.color.purple)); + } else { + holder.listTab.setBackgroundColor(context.getResources().getColor(R.color.green_r)); + } + } + static class ViewHolder { + + int colImp; + + View listTab; + } +} diff --git a/app/src/main/java/com/chanresti/originaldogmanager/VideoList.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/VideoList.java similarity index 92% rename from app/src/main/java/com/chanresti/originaldogmanager/VideoList.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/VideoList.java index 3973664..b303e04 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/VideoList.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/VideoList.java @@ -1,54 +1,54 @@ -package com.chanresti.originaldogmanager; - -import android.content.Intent; -import android.os.Bundle; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ListView; - -import java.util.ArrayList; -import java.util.List; - -public class VideoList extends AppCompatActivity { - List videoList; - ListView listView; - public static Intent intent; - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_videolist); - - ActionBar actionBar = getSupportActionBar(); - actionBar.hide(); - intent=new Intent(VideoList.this,YTPlayer.class); - videoList=new ArrayList<>(); - listView=findViewById(R.id.listView3); - listView.setDivider(null); - - videoList.add(new YVideo(R.drawable.introp,"GrFSqOyp3nU","Introduction to Dog Training")); - videoList.add(new YVideo(R.drawable.fetchp,"hpmrfOOMjyA","Teach Your Dog How to Fetch")); - videoList.add(new YVideo(R.drawable.inp,"VmtI1y90HrI","Teach Your Dog to get into the Crate")); - videoList.add(new YVideo(R.drawable.sitp,"5-MA-rGbt9k","Teach Your Dog To Sit When Told")); - videoList.add(new YVideo(R.drawable.stayp,"vYRlD8uB1yg","Teach Your Dog How to Stay")); - - MyListAdapter adapter=new MyListAdapter(VideoList.this,R.layout.custom_listlayout,videoList); - listView.setAdapter(adapter); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View view, int i, long l) { - YVideo hero=videoList.get(i); - - intent.putExtra("Activeimage", hero.getVideo()); - startActivity(intent); - } - }); - - - } - - -} +package com.chanresti.originaldogmanager; + +import android.content.Intent; +import android.os.Bundle; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ListView; + +import java.util.ArrayList; +import java.util.List; + +public class VideoList extends AppCompatActivity { + List videoList; + ListView listView; + public static Intent intent; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_videolist); + + ActionBar actionBar = getSupportActionBar(); + actionBar.hide(); + intent=new Intent(VideoList.this,YTPlayer.class); + videoList=new ArrayList<>(); + listView=findViewById(R.id.listView3); + listView.setDivider(null); + + videoList.add(new YVideo(R.drawable.introp,"GrFSqOyp3nU","Introduction to Dog Training")); + videoList.add(new YVideo(R.drawable.fetchp,"hpmrfOOMjyA","Teach Your Dog How to Fetch")); + videoList.add(new YVideo(R.drawable.inp,"VmtI1y90HrI","Teach Your Dog to get into the Crate")); + videoList.add(new YVideo(R.drawable.sitp,"5-MA-rGbt9k","Teach Your Dog To Sit When Told")); + videoList.add(new YVideo(R.drawable.stayp,"vYRlD8uB1yg","Teach Your Dog How to Stay")); + + MyListAdapter adapter=new MyListAdapter(VideoList.this,R.layout.custom_listlayout,videoList); + listView.setAdapter(adapter); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + YVideo hero=videoList.get(i); + + intent.putExtra("Activeimage", hero.getVideo()); + startActivity(intent); + } + }); + + + } + + +} diff --git a/app/src/main/java/com/chanresti/originaldogmanager/YTPlayer.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/YTPlayer.java similarity index 96% rename from app/src/main/java/com/chanresti/originaldogmanager/YTPlayer.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/YTPlayer.java index 7929248..df80cab 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/YTPlayer.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/YTPlayer.java @@ -1,110 +1,110 @@ -package com.chanresti.originaldogmanager; - -import android.os.Bundle; -import android.widget.Toast; - -import com.google.android.youtube.player.YouTubeBaseActivity; -import com.google.android.youtube.player.YouTubeInitializationResult; -import com.google.android.youtube.player.YouTubePlayer; -import com.google.android.youtube.player.YouTubePlayerView; - -//an activity for playing youtube videos -public class YTPlayer extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener { - public static final String API_KEY="AIzaSyB1flxtSbJNsnVEaVBNVvV-8rkLi355l1s"; - - private String r; - - public String getR() { - return r; - } - - public void setR(String r) { - this.r = r; - } - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_ytplayer); - r=getIntent().getExtras().getString("Activeimage"); - YouTubePlayerView youTubePlayerView=findViewById(R.id.youtube_player); - youTubePlayerView.initialize(API_KEY,this); - } - - @Override - public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) { - youTubePlayer.setPlayerStateChangeListener(playerStateChangeListener); - youTubePlayer.setPlaybackEventListener(playbackEventListener); - if(!b){ -youTubePlayer.loadVideo(r); - } - } -private YouTubePlayer.PlaybackEventListener playbackEventListener= new YouTubePlayer.PlaybackEventListener() { - @Override - public void onPlaying() { - - } - - @Override - public void onPaused() { - - } - - @Override - public void onStopped() { - - } - - @Override - public void onBuffering(boolean b) { - - } - - @Override - public void onSeekTo(int i) { - - } -}; - private YouTubePlayer.PlayerStateChangeListener playerStateChangeListener=new YouTubePlayer.PlayerStateChangeListener() { - @Override - public void onLoading() { - - } - - @Override - public void onLoaded(String s) { - - } - - @Override - public void onAdStarted() { - - } - - @Override - public void onVideoStarted() { - - } - - @Override - public void onVideoEnded() { - - } - - @Override - public void onError(YouTubePlayer.ErrorReason errorReason) { - - } - }; - @Override - public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) { - if (youTubeInitializationResult.isUserRecoverableError()) { - youTubeInitializationResult.getErrorDialog(this,1).show(); - } - else - { - String errorMessage = String.format(youTubeInitializationResult.toString()); - Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();} - } -} +package com.chanresti.originaldogmanager; + +import android.os.Bundle; +import android.widget.Toast; + +import com.google.android.youtube.player.YouTubeBaseActivity; +import com.google.android.youtube.player.YouTubeInitializationResult; +import com.google.android.youtube.player.YouTubePlayer; +import com.google.android.youtube.player.YouTubePlayerView; + +//an activity for playing youtube videos +public class YTPlayer extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener { + public static final String API_KEY="AIzaSyB1flxtSbJNsnVEaVBNVvV-8rkLi355l1s"; + + private String r; + + public String getR() { + return r; + } + + public void setR(String r) { + this.r = r; + } + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_ytplayer); + r=getIntent().getExtras().getString("Activeimage"); + YouTubePlayerView youTubePlayerView=findViewById(R.id.youtube_player); + youTubePlayerView.initialize(API_KEY,this); + } + + @Override + public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) { + youTubePlayer.setPlayerStateChangeListener(playerStateChangeListener); + youTubePlayer.setPlaybackEventListener(playbackEventListener); + if(!b){ +youTubePlayer.loadVideo(r); + } + } +private YouTubePlayer.PlaybackEventListener playbackEventListener= new YouTubePlayer.PlaybackEventListener() { + @Override + public void onPlaying() { + + } + + @Override + public void onPaused() { + + } + + @Override + public void onStopped() { + + } + + @Override + public void onBuffering(boolean b) { + + } + + @Override + public void onSeekTo(int i) { + + } +}; + private YouTubePlayer.PlayerStateChangeListener playerStateChangeListener=new YouTubePlayer.PlayerStateChangeListener() { + @Override + public void onLoading() { + + } + + @Override + public void onLoaded(String s) { + + } + + @Override + public void onAdStarted() { + + } + + @Override + public void onVideoStarted() { + + } + + @Override + public void onVideoEnded() { + + } + + @Override + public void onError(YouTubePlayer.ErrorReason errorReason) { + + } + }; + @Override + public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) { + if (youTubeInitializationResult.isUserRecoverableError()) { + youTubeInitializationResult.getErrorDialog(this,1).show(); + } + else + { + String errorMessage = String.format(youTubeInitializationResult.toString()); + Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();} + } +} diff --git a/app/src/main/java/com/chanresti/originaldogmanager/YVideo.java b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/YVideo.java similarity index 95% rename from app/src/main/java/com/chanresti/originaldogmanager/YVideo.java rename to OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/YVideo.java index 2864462..d117c42 100644 --- a/app/src/main/java/com/chanresti/originaldogmanager/YVideo.java +++ b/OriginalDogManager/app/src/main/java/com/chanresti/originaldogmanager/YVideo.java @@ -1,39 +1,39 @@ -package com.chanresti.originaldogmanager; - -/** - * Created by Mwangi on 14/03/2018. - */ -// a class defining the You Tube video model - public class YVideo { - private int image; - private String video; - private String tag; - public YVideo(int image, String video, String tag) { - this.image = image; - this.video = video; - this.tag = tag; - } - - public String getTag() { - return tag; - } - - public void setTag(String tag) { - this.tag = tag; - } - public int getImage() { - return image; - } - - public void setImage(int image) { - this.image = image; - } - - public String getVideo() { - return video; - } - - public void setVideo(String video) { - this.video = video; - } -} +package com.chanresti.originaldogmanager; + +/** + * Created by Mwangi on 14/03/2018. + */ +// a class defining the You Tube video model + public class YVideo { + private int image; + private String video; + private String tag; + public YVideo(int image, String video, String tag) { + this.image = image; + this.video = video; + this.tag = tag; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + public int getImage() { + return image; + } + + public void setImage(int image) { + this.image = image; + } + + public String getVideo() { + return video; + } + + public void setVideo(String video) { + this.video = video; + } +} diff --git a/app/src/main/res/drawable-v21/ic_menu_camera.xml b/OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_camera.xml similarity index 100% rename from app/src/main/res/drawable-v21/ic_menu_camera.xml rename to OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_camera.xml diff --git a/app/src/main/res/drawable-v21/ic_menu_gallery.xml b/OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_gallery.xml similarity index 100% rename from app/src/main/res/drawable-v21/ic_menu_gallery.xml rename to OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_gallery.xml diff --git a/app/src/main/res/drawable-v21/ic_menu_manage.xml b/OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_manage.xml similarity index 100% rename from app/src/main/res/drawable-v21/ic_menu_manage.xml rename to OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_manage.xml diff --git a/app/src/main/res/drawable-v21/ic_menu_send.xml b/OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_send.xml similarity index 100% rename from app/src/main/res/drawable-v21/ic_menu_send.xml rename to OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_send.xml diff --git a/app/src/main/res/drawable-v21/ic_menu_share.xml b/OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_share.xml similarity index 100% rename from app/src/main/res/drawable-v21/ic_menu_share.xml rename to OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_share.xml diff --git a/app/src/main/res/drawable-v21/ic_menu_slideshow.xml b/OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_slideshow.xml similarity index 100% rename from app/src/main/res/drawable-v21/ic_menu_slideshow.xml rename to OriginalDogManager/app/src/main/res/drawable-v21/ic_menu_slideshow.xml diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/OriginalDogManager/app/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 98% rename from app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to OriginalDogManager/app/src/main/res/drawable-v24/ic_launcher_foreground.xml index ddb26ad..c7bd21d 100644 --- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ b/OriginalDogManager/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -1,34 +1,34 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/app/src/main/res/drawable/addp.png b/OriginalDogManager/app/src/main/res/drawable/addp.png similarity index 100% rename from app/src/main/res/drawable/addp.png rename to OriginalDogManager/app/src/main/res/drawable/addp.png diff --git a/app/src/main/res/drawable/cloud.png b/OriginalDogManager/app/src/main/res/drawable/cloud.png similarity index 100% rename from app/src/main/res/drawable/cloud.png rename to OriginalDogManager/app/src/main/res/drawable/cloud.png diff --git a/app/src/main/res/drawable/defaultdog.png b/OriginalDogManager/app/src/main/res/drawable/defaultdog.png similarity index 100% rename from app/src/main/res/drawable/defaultdog.png rename to OriginalDogManager/app/src/main/res/drawable/defaultdog.png diff --git a/app/src/main/res/drawable/deletereal.png b/OriginalDogManager/app/src/main/res/drawable/deletereal.png similarity index 100% rename from app/src/main/res/drawable/deletereal.png rename to OriginalDogManager/app/src/main/res/drawable/deletereal.png diff --git a/app/src/main/res/drawable/dogface.png b/OriginalDogManager/app/src/main/res/drawable/dogface.png similarity index 100% rename from app/src/main/res/drawable/dogface.png rename to OriginalDogManager/app/src/main/res/drawable/dogface.png diff --git a/app/src/main/res/drawable/editreal.png b/OriginalDogManager/app/src/main/res/drawable/editreal.png similarity index 100% rename from app/src/main/res/drawable/editreal.png rename to OriginalDogManager/app/src/main/res/drawable/editreal.png diff --git a/app/src/main/res/drawable/exi.png b/OriginalDogManager/app/src/main/res/drawable/exi.png similarity index 100% rename from app/src/main/res/drawable/exi.png rename to OriginalDogManager/app/src/main/res/drawable/exi.png diff --git a/app/src/main/res/drawable/fetchp.png b/OriginalDogManager/app/src/main/res/drawable/fetchp.png similarity index 100% rename from app/src/main/res/drawable/fetchp.png rename to OriginalDogManager/app/src/main/res/drawable/fetchp.png diff --git a/app/src/main/res/drawable/fol.png b/OriginalDogManager/app/src/main/res/drawable/fol.png similarity index 100% rename from app/src/main/res/drawable/fol.png rename to OriginalDogManager/app/src/main/res/drawable/fol.png diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/OriginalDogManager/app/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from app/src/main/res/drawable/ic_launcher_background.xml rename to OriginalDogManager/app/src/main/res/drawable/ic_launcher_background.xml diff --git a/app/src/main/res/drawable/inp.png b/OriginalDogManager/app/src/main/res/drawable/inp.png similarity index 100% rename from app/src/main/res/drawable/inp.png rename to OriginalDogManager/app/src/main/res/drawable/inp.png diff --git a/app/src/main/res/drawable/introp.png b/OriginalDogManager/app/src/main/res/drawable/introp.png similarity index 100% rename from app/src/main/res/drawable/introp.png rename to OriginalDogManager/app/src/main/res/drawable/introp.png diff --git a/app/src/main/res/drawable/playcustom.png b/OriginalDogManager/app/src/main/res/drawable/playcustom.png similarity index 100% rename from app/src/main/res/drawable/playcustom.png rename to OriginalDogManager/app/src/main/res/drawable/playcustom.png diff --git a/app/src/main/res/drawable/side_nav_bar.xml b/OriginalDogManager/app/src/main/res/drawable/side_nav_bar.xml similarity index 100% rename from app/src/main/res/drawable/side_nav_bar.xml rename to OriginalDogManager/app/src/main/res/drawable/side_nav_bar.xml diff --git a/app/src/main/res/drawable/sitp.png b/OriginalDogManager/app/src/main/res/drawable/sitp.png similarity index 100% rename from app/src/main/res/drawable/sitp.png rename to OriginalDogManager/app/src/main/res/drawable/sitp.png diff --git a/app/src/main/res/drawable/stayp.png b/OriginalDogManager/app/src/main/res/drawable/stayp.png similarity index 100% rename from app/src/main/res/drawable/stayp.png rename to OriginalDogManager/app/src/main/res/drawable/stayp.png diff --git a/app/src/main/res/layout-v11/reminders_row.xml b/OriginalDogManager/app/src/main/res/layout-v11/reminders_row.xml similarity index 97% rename from app/src/main/res/layout-v11/reminders_row.xml rename to OriginalDogManager/app/src/main/res/layout-v11/reminders_row.xml index ca6b017..5da425e 100644 --- a/app/src/main/res/layout-v11/reminders_row.xml +++ b/OriginalDogManager/app/src/main/res/layout-v11/reminders_row.xml @@ -1,75 +1,75 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_alarmpage.xml b/OriginalDogManager/app/src/main/res/layout/activity_alarmpage.xml similarity index 96% rename from app/src/main/res/layout/activity_alarmpage.xml rename to OriginalDogManager/app/src/main/res/layout/activity_alarmpage.xml index dcf533b..a05b14b 100644 --- a/app/src/main/res/layout/activity_alarmpage.xml +++ b/OriginalDogManager/app/src/main/res/layout/activity_alarmpage.xml @@ -1,41 +1,41 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_profile.xml b/OriginalDogManager/app/src/main/res/layout/activity_profile.xml similarity index 97% rename from app/src/main/res/layout/activity_profile.xml rename to OriginalDogManager/app/src/main/res/layout/activity_profile.xml index c1bb799..615e5fb 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/OriginalDogManager/app/src/main/res/layout/activity_profile.xml @@ -1,110 +1,110 @@ - - - - - - - - - - - - - - - - - - - - - -