Exemple #1
0
    def createreminder(self):
        title = self.inputNewReminderTitle.text
        content = self.inputNewReminderContent.text
        year = self.inputNewReminderYear.text
        month = self.inputNewReminderMonth.text
        day = self.inputNewReminderDay.text
        hour = self.inputNewReminderHour.text
        minute = self.inputNewReminderMinute.text
        second = self.inputNewReminderSecond.text

        if title == "" or content == "" or year == "" or month == "" or day == "" or hour == "" or minute == "" or second == "":
            pass
        else:
            if year.isnumeric is False or month.isnumeric is False or day.isnumeric is False or hour.isnumeric is False or minute.isnumeric is False or second.isnumeric is False:
                pass
            else:
                c = Crypto(False, 0)
                title = c.encrypt(title)
                content = c.encrypt(content)
                r = Reminders()
                r.create(title, content, int(year), int(month), int(day),
                         int(hour), int(minute), int(second))
                reminders = self.manager.get_screen("reminders")
                reminders.latestreminder()
                self.manager.current = "reminders"
Exemple #2
0
class Settings:
    # Method - Settings init
    # Parameters - None
    # Return - None
    # Purpose - Initialises an instance of the crypto class for this class and sets up the database for editing
    def __init__(self):
        self.db = sqlite3.connect("resources/UserData.db")
        self.cursor = self.db.cursor()
        self.c = Crypto(None, 0)

    # Method - changename
    # Parameters - name: string
    # Return - None
    # Purpose - Encrypts the user's chosen name then sets the user's name in the database
    def changename(self, name):
        name = self.c.encrypt(name)
        self.cursor.execute("""UPDATE userInfo SET Name='{}'""".format(name))
        self.db.commit()

    # Method - changelocation
    # Parameters - country: string, city: string
    # Return - None
    # Purpose - Sets the user's location in the database to the country and city arguments
    def changelocation(self, country, city):
        country = self.c.encrypt(country)
        city = self.c.encrypt(city)
        self.cursor.execute(
            """UPDATE userInfo SET Country='{}'""".format(country))
        self.cursor.execute("""UPDATE userInfo SET City='{}'""".format(city))
        self.db.commit()
Exemple #3
0
 def editreminder(self):
     reminderid = self.currentreminderid
     title = self.inputEditReminderTitle.text
     content = self.inputEditReminderContent.text
     if title == "" or content == "":
         pass
     else:
         c = Crypto(False, 0)
         title = c.encrypt(title)
         content = c.encrypt(content)
         n = Reminders()
         n.edit(reminderid, title, content)
         reminders = self.manager.get_screen("reminders")
         reminders.latestreminder()
         self.manager.current = "reminders"
Exemple #4
0
 def editnote(self):
     noteid = self.currentnoteid
     title = self.inputEditNoteTitle.text
     content = self.inputEditNoteContent.text
     if title == "" or content == "":
         pass
     else:
         c = Crypto(False, 0)
         title = c.encrypt(title)
         content = c.encrypt(content)
         n = Notes()
         n.edit(noteid, title, content)
         notes = self.manager.get_screen("notes")
         notes.latestnote()
         self.manager.current = "notes"
Exemple #5
0
    def createnote(self):
        title = self.inputNewNoteTitle.text
        content = self.inputNewNoteContent.text

        if title == "" or content == "":
            pass
        else:
            c = Crypto(False, 0)
            title = c.encrypt(title)
            content = c.encrypt(content)
            n = Notes()
            n.create(title, content)
            notes = self.manager.get_screen("notes")
            notes.latestnote()
            self.manager.current = "notes"
Exemple #6
0
    def completesetup(self, name, country, city):
        c = Crypto(True, len(name))
        name = c.encrypt(name)
        country = c.encrypt(country)
        city = c.encrypt(city)
        un = c.encrypt("kedst")
        db = sqlite3.connect("resources/UserData.db")
        cursor = db.cursor()

        sql = "CREATE TABLE userInfo (Name text, Country text, City text, LastTwitterSearch text, primary key(Name))"
        cursor.execute(sql)

        sql = """INSERT INTO userInfo (Name, Country, City, LastTwitterSearch) VALUES ('{}', '{}', '{}', '{}')""".format(
            name, country, city, un)
        cursor.execute(sql)

        # Notes table
        sql = """CREATE TABLE Notes (NoteID integer, Title text, Content text, Date float, primary key(NoteID))"""
        cursor.execute(sql)

        # Reminders table
        sql = """CREATE TABLE Reminders (ReminderID integer, Title text, Content text, Date float, primary key(ReminderID))"""
        cursor.execute(sql)
        db.commit()
Exemple #7
0
class RemindersScreen(Screen):
    # Method - RemindersScreen init
    # Parameters - None
    # Return - None
    # Purpose -  Initialises instances of the reminders and crypto classes, connects to the database, and runs the
    #            latestreminder method
    def __init__(self, **kwargs):
        super(RemindersScreen, self).__init__(**kwargs)
        self.c = Crypto(False, 0)
        self.r = Reminders()
        self.latestreminder()
        self.db = sqlite3.connect("resources/UserData.db")
        self.cursor = self.db.cursor()

    # Method - latestreminder
    # Parameters - data: list of strings
    # Return - None
    # Purpose - If the user has any reminders, display the most recent one in labels
    def latestreminder(self):
        data = self.r.mostrecent()
        if data is False:
            self.lblLastReminderTitle.text = "No reminders found!"
            self.lblLastReminderContent.text = " "
        else:
            recenttitle = data[0]
            recentcontent = data[1]
            recenttitle = self.c.decrypt(recenttitle)
            recentcontent = self.c.decrypt(recentcontent)
            self.lblLastReminderTitle.text = recenttitle
            self.lblLastReminderContent.text = recentcontent

    # Method - newreminder
    # Parameters - None
    # Return - None
    # Purpose - Clears the content of the text inputs of the newreminder screen, then displays it
    def newreminder(self):
        newreminders = self.manager.get_screen("newreminders")
        newreminders.inputNewReminderTitle.text = ""
        newreminders.inputNewReminderContent.text = ""
        newreminders.inputNewReminderYear.text = ""
        newreminders.inputNewReminderMonth.text = ""
        newreminders.inputNewReminderDay.text = ""
        newreminders.inputNewReminderHour.text = ""
        newreminders.inputNewReminderMinute.text = ""
        newreminders.inputNewReminderSecond.text = ""
        self.parent.current = "newreminders"

    # Method - remindersbytime
    # Parameters - data: list of strings
    # Return - None
    # Purpose - Retrieves a list of the user's reminders sorted by time, then passes it to the setupmorereminders
    # function
    def remindersbytime(self):
        data = self.r.sort("Date")
        count = len(data)
        self.setupmorereminders(count, data)

    # Method - remindersbytime
    # Parameters - data: list of strings
    # Return - None
    # Purpose - Retrieves a list of the user's reminders sorted by title alphabetically, then passes it to the
    #           setupmorereminders function
    def remindersbytitle(self):
        data = self.r.sort("Title")
        count = len(data)
        self.setupmorereminders(count, data)

    # Method - searchreminders
    # Parameters - searchterm: string, data: list of strings
    # Return - None
    # Purpose - Gets a list of the user's reminders containing a given search term, then passes it to the
    # setupmorereminders function
    def searchreminders(self):
        searchterm = self.inputSearchReminders.text
        if searchterm == "":
            pass
        else:
            searchterm = self.c.encrypt(searchterm)
            data = self.r.search(searchterm)
            count = len(data)
            self.setupmorereminders(count, data)

    # Method - setupmorereminders
    # Parameters - count: integer , data: list of strings
    # Return - None
    # Purpose - Adds widgets displaying the title and content of each reminder within the given list, as well as their
    # corresponding edit and delete buttons to the morereminders screen. A "back" button is then added and the screen is
    # displayed.
    def setupmorereminders(self, count, data):
        morereminders = self.manager.get_screen("morereminders")
        morereminders.layoutMoreReminders.clear_widgets(
            morereminders.layoutMoreReminders.children)

        for i in range(count):
            reminderid = data[i][0]
            title = data[i][1]
            title = self.c.decrypt(title)
            content = data[i][2]
            content = self.c.decrypt(content)
            date = data[i][3]
            date = datetime.datetime.fromtimestamp(date)

            lbltitle = Label(text=title, size_hint_y=None)
            lbltitle.texture_update()
            morereminders.layoutMoreReminders.add_widget(lbltitle)

            lbltext = Label(text=content, size_hint_y=None)
            lbltext.texture_update()
            morereminders.layoutMoreReminders.add_widget(lbltext)

            lbldate = Label(text=str(date), size_hint_y=None)
            lbldate.texture_update()
            morereminders.layoutMoreReminders.add_widget(lbldate)

            grid = GridLayout(cols=2, size_hint_y=None)
            btnedit = Button(text="Edit",
                             size_hint_y=None,
                             on_press=lambda a: self.edit(reminderid))
            btndelete = Button(text="Delete",
                               size_hint_y=None,
                               on_press=lambda a: self.delete(reminderid))
            btnedit.texture_update()
            btndelete.texture_update()
            grid.add_widget(btnedit)
            grid.add_widget(btndelete)
            morereminders.layoutMoreReminders.add_widget(grid)

        grid = GridLayout(cols=2, size_hint_y=None)
        btnback = (Button(text="Back",
                          height=dp(80),
                          on_press=lambda a: self.back()))
        grid.add_widget(btnback)
        morereminders.layoutMoreReminders.add_widget(grid)
        self.manager.current = "morereminders"

    # Method - back
    # Parameters - None
    # Return - None
    # Purpose - Runs the latestreminder method, then displays the reminders screen
    def back(self):
        self.latestreminder()
        self.manager.current = "reminders"

    # Method - delete
    # Parameters - reminderid: string
    # Return - None
    # Purpose - Deletes the reminder corresponding to the given reminderid, then calls the latestreminder method and
    # displays the reminders screen
    def delete(self, reminderid):
        self.r.delete(reminderid)
        self.latestreminder()
        self.manager.current = "reminders"

    # Method - edit
    # Parameters - reminderid: string
    # Return - None
    # Purpose - Displays the editreminders screen, and passes reminderid to it
    def edit(self, reminderid):
        editreminders = self.manager.get_screen("editreminders")
        editreminders.currentreminderid = reminderid
        self.manager.current = "editreminders"
Exemple #8
0
class TwitterScreen(Screen):

    # Method - TwitterScreen init
    # Parameters - None
    # Return - None
    # Purpose - When kivy has built the screen, initialises instances of the Crypto and Twitter classes for this class,
    #           then calls the latesttweet function
    def __init__(self, **kwargs):
        super(TwitterScreen, self).__init__(**kwargs)
        self.db = sqlite3.connect("resources/UserData.db")
        self.cursor = self.db.cursor()
        self.c = Crypto(False, 0)
        self.t = Twitter()
        self.latesttweet()

    # Method - latesttweet
    # Parameters - username
    # Return - None
    # Purpose - Retrieves the username the user last searched for, fetches their latest tweet from the API, then
    #           displays their username latest tweet in labels
    def latesttweet(self):
        self.cursor.execute("SELECT LastTwitterSearch FROM userInfo")
        username = self.cursor.fetchone()
        username = self.c.decrypt(username[0])
        self.lblRecentTweet.text = self.t.userlatest(username)
        self.lblRecentUsername.text = "Latest tweet from @" + username

    # Method - getmoretweets
    # Parameters - un:string
    # Return - None
    # Purpose - Obtains and displays the data on the moretweets screen using the user's chosen location
    def getmoretweets(self):
        un = self.inputTwitterUsername.text
        if un == "":
            pass
        else:
            moretwitter = self.manager.get_screen("moretwitter")
            moretwitter.layoutMoreTwitter.clear_widgets(
                moretwitter.layoutMoreTwitter.children)

            tweets = self.t.user10(un)
            lblun = Label(text=("Latest tweets from @" + un), size_hint_y=None)
            moretwitter.layoutMoreTwitter.add_widget(lblun)

            for i in range(len(tweets)):
                lbltweet = Label(text=tweets[i], size_hint_y=None)
                lbltweet.texture_update()
                moretwitter.layoutMoreTwitter.add_widget(lbltweet)

            btnback = Button(text="Back",
                             height=dp(40),
                             size_hint_y=None,
                             on_press=lambda a: self.back())
            moretwitter.layoutMoreTwitter.add_widget(btnback)
            self.manager.current = "moretwitter"

    # Method - back
    # Parameters - username: string, secureusername:s tring
    # Return - None
    # Purpose - Updates the main twitter screen with the latest tweet from the username the user last searched for,
    #           then displays the twitter screen.
    def back(self):
        username = self.inputTwitterUsername.text
        secureusername = self.c.encrypt(username)
        sql = """UPDATE userInfo SET LastTwitterSearch='{}'""".format(
            secureusername)
        self.cursor.execute(sql)
        self.db.commit()
        self.lblRecentUsername.text = "Latest tweet from @{}".format(username)
        self.lblRecentTweet.text = self.t.userlatest(username)
        self.manager.current = "twitter"