Exemplo n.º 1
0
 def build(self):
     self.ads = KivMob(APP_ID)
     self.ads.add_test_device(TEST_DEVICE_ID)
     self.ads.new_banner({"unitID": BANNER_ID})
     self.ads.new_interstitial(INTERSTITIAL_ID)
     self.ads.request_banner()
     self.ads.request_interstitial()
     self.toggled = False
     return KivMobDemoUI()
Exemplo n.º 2
0
 def build(self):
     self.ads = KivMob(TestIds.APP)
     self.ads.new_banner(TestIds.BANNER, False)
     self.ads.new_interstitial(TestIds.INTERSTITIAL)
     self.ads.request_banner()
     self.ads.request_interstitial()
     self.ads.set_rewarded_ad_listener(self.rewards)
     self.ads.load_rewarded_ad(TestIds.REWARDED_VIDEO)
     self.toggled = False
     return KivMobDemoUI()
Exemplo n.º 3
0
 def __init__(self, **kwargs):
     super(MyApp, self).__init__(**kwargs)
     app_id = TestIds.APP
     self.ads = KivMob(app_id)
     banner_id = TestIds.BANNER
     interstitial_id = TestIds.INTERSTITIAL
     self.ads.new_banner(banner_id, top_pos=True)
     self.ads.new_interstitial(interstitial_id)
     self.show_ads()
     self.ads_created = True
     self.manga_text_color = (0, 0, 0, 1)
     self.start_up = True  # Use in theme_color
Exemplo n.º 4
0
    def build(self):

        self.config = Config()

        self.ads = KivMob('ca-app-pub-1818238534900904~2025018602')
        self.ads.new_banner('ca-app-pub-1818238534900904/4048546717',
                            top_pos=False)
        self.ads.request_banner()
        self.ads.show_banner()

        self.screen = Builder.load_file(self.config.screen)

        return self.screen
Exemplo n.º 5
0
class ScatterTextWidget(BoxLayout):
    APPID = 'ca-app-pub-4594686446272625~3110544260'
    BANNERID = 'ca-app-pub-4594686446272625/3787177591'
    ads = KivMob(APPID)
    ads.new_banner(BANNERID)
    ads.request_banner()
    ads.show_banner()

    pass
Exemplo n.º 6
0
class Screen2(MDScreen):
    ads = KivMob('ca-app-pub-1818238534900904~2025018602')# ADS ID 


    ads.new_interstitial('ca-app-pub-1818238534900904/8138357580')#ADS UNIT ID
    ads.add_test_device('7569F1B8DC0951A')#Test Device ID 
    ads.request_interstitial()


    def resume(self):
        self.ads.request_interstitial()

    def show_ads(self):
        self.ads.show_interstitial()
Exemplo n.º 7
0
    def build(self):
        self.theme_cls.theme_style = 'Dark'

        self.sm = Builder.load_file('main.kv')

        # ads
        self.ads = KivMob(os.environ.get('APP_ID'))
        self.ads.add_test_device('70356742')
        self.ads.new_banner(os.environ.get('BANNER_ID'), top_pos=False)
        self.ads.request_banner()
        self.ads.new_interstitial(os.environ.get('INTERSTITIAL_ID'))
        self.ads.request_interstitial()

        # dialog window to show when starting new game if active game exists
        self.dialog = Dialog(
            title='Створити нову гру?',
            text='Дані про поточну гру буде втрачено.',
            buttons=[
                TextButton(text="Назад",
                           on_release=lambda _: self.dialog.dismiss()),
                TextButton(
                    text="Так",
                    on_release=lambda _: self.drop_game_and_create_new())
            ],
        )

        Cache.append('images', 'round_background',
                     FitImage(source="assets/imgs/round.png"))

        # enable buttons only in 2 second after build to avoid bugs
        def show_menu_buttons():
            self.buttons_ready_to_use = True

        Clock.schedule_once(lambda _: show_menu_buttons(), 2)

        return self.sm
Exemplo n.º 8
0
class SimpleApp(MDApp):
    def __init__(self, **kwargs):
        self.theme_cls.theme_style = "Dark"
        super().__init__(**kwargs)
        self.rewards = Rewards_Handler(self)

    ads = KivMob(
        TestIds.APP)  # put your Admob Id in case you want to put your own ads.
    points = NumericProperty(0)

    def build(self):
        self.ads.new_banner(TestIds.BANNER, False)
        self.ads.request_banner()
        self.ads.show_banner()
        self.ads.new_interstitial(TestIds.INTERSTITIAL)
        self.ads.load_rewarded_ad(TestIds.REWARDED_VIDEO)
        self.ads.set_rewarded_ad_listener(self.rewards)

        return Screenmgr()

    def load_video(self):
        self.ads.load_rewarded_ad(TestIds.REWARDED_VIDEO)
Exemplo n.º 9
0
class OneApp(MDApp):
    def __init__(self):

        super().__init__()

        self.config = Config()

        self.id_key = self.config.id_key
        self.title = self.config.title
        self.theme_cls.primary_palette = self.config.color

    def picture_taken(self, obj, filename):
        try:

            self.picture = filename

        except:
            pass

    def take_picture(self):
        try:
            self.screen.change_screen('camerascreen')
            self.screen.nav_layout.screen_manager.camerascreen.xcamera.restore_orientation(
            )
        except:
            pass

    def build(self):

        self.config = Config()

        self.ads = KivMob('ca-app-pub-1818238534900904~2025018602')
        self.ads.new_banner('ca-app-pub-1818238534900904/4048546717',
                            top_pos=False)
        self.ads.request_banner()
        self.ads.show_banner()

        self.screen = Builder.load_file(self.config.screen)

        return self.screen
Exemplo n.º 10
0
class MainApp(MDApp):
    # APP
    storage_url = "https://farmzon-abdcb.appspot.com"
    database_url = "https://farmzon-abdcb.firebaseio.com/.json"
    data = {"uu": {"Joe Tilsed": "me"}}
    auth_key = "sBlt6fzvguYnrGl2FlXRK3k4vRxSfZJBV2P7yIRv"
    size_x = NumericProperty(0)
    size_y = NumericProperty(0)
    menu = ObjectProperty(None)
    count = NumericProperty(0)
    loggin_count = NumericProperty(0)
    count_update = NumericProperty(0)
    dialog = None
    dialog_phone = None
    dialog_last = None
    setter = None
    counter_image = NumericProperty(0)
    spin_active = BooleanProperty(False)
    menu_text = StringProperty("Your Location")
    loading = StringProperty("")

    # Business
    product_name = StringProperty("")
    phone_number = StringProperty("")
    location = StringProperty("")
    quantity = StringProperty("")
    total_amount = NumericProperty(0)
    order_number = StringProperty("0")
    category_tp = StringProperty("")

    # MATH
    calculator = StringProperty("0")
    calculator2 = StringProperty("0")

    # XXX-------ADMIN LOGIN VAR-------XXX
    admin_name = StringProperty("")
    admin_phone = StringProperty("")
    customer_phone = StringProperty("")
    admin_password = StringProperty("")
    admin_true = BooleanProperty(False)
    admin_product_description = StringProperty("")
    admin_product_image = StringProperty("images/picture.png")
    admin_product_name = StringProperty("")
    admin_product_price = StringProperty("")
    admin_product_id = StringProperty("")
    admin_product_url = StringProperty("")

    # ADS
    app_id = "ca-app-pub-9270156272717443~8633598837"
    interstitial = "ca-app-pub-9270156272717443/2248347409"

    # DATABASE

    def stream_handler(self, message):
        if True:
            print("hello")
            return notification.notify(title='New order', message='you have new order!')

    def notifi(self, phone):
        try:
            import firebase_admin
            firebase_admin._apps.clear()
            from firebase_admin import credentials, initialize_app, db
            id = datetime.datetime.now()
            cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
            initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})
            if phone != "0788204327":
                my_stream = db.reference("Yummy").child("Admin").child(phone).child("Orders").listen(
                    self.stream_handler)
            else:
                my_stream = db.reference("Yummy").child("Orders").listen(
                    self.stream_handler)
        except:
            print("poor me")

    def remember_me_admin(self, user, password, name):
        with open("credential/admin.txt", "w") as fl:
            fl.write(user + "\n")
            fl.write(password)
        with open("credential/admin_info.txt", "w") as ui:
            ui.write(name)
        fl.close()
        ui.close()

    def admin_memory(self):
        if self.loggin_count == 0:
            self.loggin_count = 1 + self.loggin_count
            self.admin_true = True
            file1 = open('credential/admin.txt', 'r')
            file2 = open("credential/admin_info.txt")
            Lines = file1.readlines()
            Lines2 = file2.readlines()

            # Strips the newline character
            self.admin_phone = Lines[0].strip()
            self.admin_password = Lines[1].strip()
            self.admin_name = Lines2[0]
            self.count += 1
            thread = threading.Thread(self.notifi(self.admin_phone))
            thread = threading.Thread(self.listen_db(self.admin_phone))
            thread.start()
        else:
            sm = self.root
            sm.current = "admin_main"
            self.spin_active = False

    def actively_reg(self):
        if self.spin_active:
            self.spin_active = False
            toast("Successfully Registered!")

    def permision_req(self):
        if utils.platform == 'android':
            from android.permissions import request_permissions, Permission  # todo
            request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE])

    def notifier(self):
        notification.notify(title="Welcome", message="you can also sell and buy!")

    def on_start(self):
        m = self.root
        m.current = "one"
        identity = self.root.ids.drop_item_one
        self.menu_fun(identity)
        self.keyboard_hooker()

    def menu_fun(self, identity):
        vimbweta = [
            "vimbweta vya uwanjani",
            "vimbweta vya stationary",
            "vimbweta vya girls hostel",
            "vimbweta vya boys hostel",
            "vimbweta nyuma ya ndege",
            "vimbweta vya block 16",
            "vimbweta vya adminstration",
            "class one",
            "class two",
            "class three",
            "Aviation classes"
        ]
        self.menu = MDDropdownMenu(
            caller=identity,
            width_mult=9,
            position="auto",
            callback=self.menu_callback
        )
        for i in range(vimbweta.__len__()):
            self.menu.items.append(
                {
                    "text": vimbweta[i]
                }
            )
        for i in range(22):
            if i == 0:
                pass
            else:
                self.menu.items.append(
                    {
                        "text": "Block " + "" + str(i)
                    }
                )
        self.menu.bind(
            on_release=self.menu_callback
        )

        self.setter = identity
        self.setter.set_item(self.menu_text)

    def show_alert_dialog(self):
        if not self.dialog:
            self.dialog = MDDialog(
                title="Do you real want to quit?",
                buttons=[
                    MDFlatButton(
                        text="CANCEL", text_color=self.theme_cls.primary_color, on_release=self.kill
                    ),
                    MDRaisedButton(
                        text="QUIT!", text_color=self.theme_cls.primary_color,
                        on_release=lambda x: toast("Please press the home button!", 5)
                    ),
                ],
            )
        self.dialog.open()

    def phone_number_dialog(self):
        if not self.dialog_phone:
            self.dialog_phone = phone_dialog(
                title="Enter Your phone number",
                auto_dismiss=False,
                buttons=[
                    MDFlatButton(
                        text="Cancel", text_color=self.theme_cls.primary_color, on_release=self.kill_phone
                    ),
                    MDRaisedButton(
                        text="Submit", text_color=self.theme_cls.primary_color,
                        on_release=lambda x: self.phone_number_check(self.phone_number)
                    ),
                ],
            )
        self.dialog_phone.open()

    def last_step_dialog(self):
        if not self.dialog_last:
            self.dialog_last = MDDialog(
                title="Confirm",
                type="custom",
                auto_dismiss=False,
                content_cls=last_dialog(),
                buttons=[
                    MDFlatButton(
                        text="Cancel",
                        text_color=self.theme_cls.primary_color,
                        on_release=lambda x: self.adver()
                    ),
                    MDRaisedButton(
                        text="Ok",
                        on_release=lambda x: self.adver(),
                        theme_text_color="Custom",
                        md_bg_color=[243 / 255, 189 / 255, 106 / 255, 1]
                    ),

                ],
            )
        self.dialog_last.md_bg_color = 245 / 255, 0 / 255, 72 / 255, 1
        self.dialog_last.open()

    def phone_number_check(self, phone):
        new_number = ""
        if phone != "":
            for i in range(phone.__len__()):
                if i == 0:
                    pass
                else:
                    new_number = new_number + phone[i]
            number = "+255" + new_number
            if not carrier._is_mobile(number_type(phonenumbers.parse(number))):
                toast("Please check your phone number!", 1)
                return False
            else:
                self.phone_number = phone
                thread = threading.Thread(target=self.Business(self.product_name, self.quantity, self.phone_number))
                thread.start()
                self.kill_phone()
                return True
        else:
            toast("check your number")

    def phone_number_check_admin(self, phone):
        new_number = ""
        if phone != "":
            for i in range(phone.__len__()):
                if i == 0:
                    pass
                else:
                    new_number = new_number + phone[i]
            number = "+255" + new_number
            if not carrier._is_mobile(number_type(phonenumbers.parse(number))):
                toast("Please check your phone number!", 1)
                return False
            else:
                return True
        else:
            toast("enter phone number!")

    def kill(self, *kwargs):
        self.dialog.dismiss()

    def kill_phone(self, *kwargs):
        self.ads.request_interstitial()
        self.dialog_phone.dismiss()
        self.ads.show_interstitial()

    def kill_adver(self):
        self.dialog_last.dismiss()

    def Business(self, product, quantity, phone):
        self.last_step_dialog()
        print("location:", self.location, '\n'
                                          "Product name:", product, '\n'
                                                                    "quantity:", quantity, '\n'
                                                                                           "Total amount:",
              self.total_amount, '\n'
                                 "Phone number:", phone)
        if self.category_tp != "admin":
            from helped import connection_status as CS
            if CS.Network.internet(CS.Network()):
                self.spin_active = True
                thread = threading.Thread(target=DB.upload_data,
                                          args=(
                                              DB(), self.customer_phone, phone, self.location, quantity,
                                              self.total_amount,
                                              product))
                thread.start()
                thread.join()
                toast("Ordered successfully!", 10)
                self.spin_active = False
            else:
                self.spin_active = False
                toast("Sorry try again!", 5)
        else:
            from helped import connection_status as CS
            if CS.Network.internet(CS.Network()):
                self.spin_active = True
                thread = threading.Thread(target=DB.upload_data_admin,
                                          args=(
                                              DB(), self.customer_phone, phone, self.location, quantity,
                                              self.total_amount,
                                              product))
                thread.start()
                thread.join()
                toast("Ordered successfully!", 10)
                self.spin_active = False
            else:
                self.spin_active = False
                toast("Sorry try again!", 5)

    def keyboard_hooker(self):
        EventLoop.window.bind(on_keyboard=self.hook_keyboard)

    def hook_keyboard(self, window, key, *largs):
        sm = self.root
        print(key, self.count)
        if key == 27 and self.count == 1 or self.count <= -1:
            sm.current = "one"
            print("change", self.count)
            self.count = self.count - 1
            print("current>>", self.count)
            return True
        elif key == 27 and self.count == 0:
            # Window.on_close()
            self.show_alert_dialog()
            return True

    def menu_callback(self, menu):
        self.menu_text = menu.text
        self.setter.set_item(menu.text)
        self.menu.dismiss()
        print(menu.text)
        self.location = menu.text

    def callculator_rim(self, mingapi, price):
        identity = self.root.ids.quantity
        self.calculator = mingapi + "0"
        if mingapi == "":
            pass
        elif mingapi == '.':
            identity.text = "1"
        else:
            self.total_amount = self.calculator = str(float(mingapi) * int(price))

    def callback(self, button):
        self.menu.caller = button
        self.menu.open()

    food_count = 0

    def order_spinner2(self):
        if self.front_shop_count == 0:
            self.spin_active = True
            try:
                toast("loading please wait...", 10)
                self.loading = "Loading..."
                # Clock.schedule_once(lambda x: self.front_shop(), 4)
                thread = threading.Thread(target=self.front_shop())
                thread.start()
            except:
                toast("no internet!")
                self.loading = ""
                self.spin_active = False

    def order_spinner3(self):
        if self.other_shops == 0:
            self.spin_active = True
            try:
                toast("loading please wait...", 10)
                Clock.schedule_once(lambda x: self.other_shop(), 4)
                # thread = threading.Thread(target=self.other_shop)
                # thread.start()
            except:
                toast("no internet!")
                self.spin_active = False

    def order_spinner1(self):
        sm = self.root
        file_size = os.path.getsize("credential/admin.txt")
        if file_size == 0:
            sm.current = "login"
        else:
            self.spin_active = True
            sm.current = "admin_main"
            thread = threading.Thread(target=self.admin_memory)
            thread.start()
            thread.join()
            self.spin_active = False

    def add_order(self):
        try:
            if self.food_count == 0:
                self.food_count = self.food_count + 1
                food = self.root.ids.food_cat
                import firebase_admin
                firebase_admin._apps.clear()
                from firebase_admin import credentials, initialize_app, db
                if not firebase_admin._apps:
                    cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
                    initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})

                    store = db.reference("Yummy").child("Orders")
                    stores = store.get()

                    count = 0
                    for y, x in stores.items():
                        food_categories = category()
                        del_btn = MDIconButton(icon="delete", on_release=self.remove_widgets,
                                               pos_hint={"center_x": .9, "center_y": .3}, theme_text_color="Custom",
                                               text_color={60 / 255, 66 / 255, 75 / 255}, user_font_size="26sp")
                        count += 1
                        # food_categories.md_bg_color = 245 / 255, 0 / 255, 72 / 255, 1
                        food_categories.id = y
                        del_btn.id = y
                        food_categories.md_bg_color = 121 / 255, 174 / 255, 141 / 255, 1
                        food_categories.add_widget(Labels(text="Admin-phone:" + " " + str(x['Admin phone'])))
                        food_categories.add_widget(Labels(text="Phone:" + " " + y))
                        food_categories.add_widget(MDSeparator(height="5dp"))
                        food_categories.add_widget(Labels(text="Amount:" + " " + " " + str(x['amount'])))
                        food_categories.add_widget(Labels(text="Location:" + " " + " " + str(x['location'])))
                        food_categories.add_widget(Labels(text="Product-Name:" + " " + " " + str(x['product name'])))
                        food_categories.add_widget(Labels(text="Quantity:" + " " + " " + str(x['quantity'])))
                        food_categories.add_widget(Labels(text="Time-Ordered:" + " " + " " + str(x['time'])))
                        food_categories.add_widget(del_btn)
                        food.add_widget(food_categories)
                    self.spin_active = False
                    self.order_number = str(count)

            else:
                pass
        except:
            toast("no internet")
            self.spin_active = False

    def resize_bottom_tabs(self):
        # bottom_nav
        bv = self.root.ids.bottom_nav
        bv.on_resize()

    def add_order_admin(self):
        try:
            if self.food_count == 0:
                print("num>", self.admin_phone)
                self.food_count = self.food_count + 1
                food = self.root.ids.food_cat
                import firebase_admin
                firebase_admin._apps.clear()
                from firebase_admin import credentials, initialize_app, db
                if not firebase_admin._apps:
                    cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
                    initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})

                    if self.admin_phone != "0788204327":
                        store = db.reference("Yummy").child("Admin").child(self.admin_phone).child("Orders")
                        stores = store.get()
                        print(stores)
                        count = 0
                        for y, x in stores.items():
                            print(x)
                            food_categories = category()
                            del_btn = MDIconButton(icon="delete", on_release=self.remove_widgets,
                                                   pos_hint={"center_x": .9, "center_y": .3}, theme_text_color="Custom",
                                                   text_color={60 / 255, 66 / 255, 75 / 255}, user_font_size="26sp")
                            count += 1
                            # food_categories.md_bg_color = 245 / 255, 0 / 255, 72 / 255, 1
                            food_categories.id = y
                            del_btn.id = y
                            food_categories.md_bg_color = 121 / 255, 174 / 255, 141 / 255, 1
                            food_categories.add_widget(Labels(text="Admin-phone:" + " " + str(x['Phone number'])))
                            food_categories.add_widget(Labels(text="Phone:" + " " + y))
                            food_categories.add_widget(MDSeparator(height="5dp"))
                            food_categories.add_widget(Labels(text="Amount:" + " " + " " + str(x['amount'])))
                            food_categories.add_widget(Labels(text="Location:" + " " + " " + str(x['location'])))
                            food_categories.add_widget(
                                Labels(text="Product-Name:" + " " + " " + str(x['product name'])))
                            food_categories.add_widget(Labels(text="Quantity:" + " " + " " + str(x['quantity'])))
                            food_categories.add_widget(Labels(text="Time-Ordered:" + " " + " " + str(x['time'])))
                            food_categories.add_widget(del_btn)
                            food.add_widget(food_categories)
                        self.spin_active = False
                        self.order_number = str(count)
                    else:
                        self.add_order()

            else:
                pass
        except:
            toast("no internet")
            self.spin_active = False

    all_products = {}
    front_products = {}
    front_shop_count = 0
    other_shops = 0

    def other_shop(self):
        if True:
            try:
                if self.other_shops == 0:
                    self.other_shops = self.other_shops + 1
                    import firebase_admin
                    firebase_admin._apps.clear()
                    from firebase_admin import credentials, initialize_app, db
                    if not firebase_admin._apps:
                        shop = self.root.ids.other_shop
                        cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
                        initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})
                        store = db.reference("Yummy").child("Products")
                        stores = store.get()
                        from retrive_data import Retrieve as RE
                        RE.other_shop(RE(), stores)
                        self.all_products = stores
                        for y, x in stores.items():
                            self.admin_product_name = x["product_name"]
                            self.customer_phone = x["admin_phone"]
                            self.admin_product_url = x["image_url"]
                            self.admin_product_price = x["product_price"]
                            self.admin_product_description = x["product_description"]

                            other_shops = Shops(on_release=self.selling_other)
                            other_shops.add_widget(Labels(text=self.admin_product_name))
                            other_shops.add_widget(Shop_image(source=self.admin_product_url))
                            other_shops.add_widget(Labels(text=self.admin_product_price))
                            other_shops.id = y
                            shop.add_widget(other_shops)
                            self.spin_active = False
            except:
                self.spin_active = False
                toast("no internet!")

    def other_shop_offline(self):
        filename = "helped/other.json"
        try:
            file_size = os.path.getsize(filename)
            if file_size > 0:
                shop = self.root.ids.front_shop
                with open(filename) as file:
                    line = json.load(file)
                    print(line)
                    for y, x in line.items():
                        self.admin_product_name = x["product_name"]
                        self.customer_phone = x["admin_phone"]
                        self.admin_product_url = x["image_url"]
                        self.admin_product_price = x["product_price"]
                        self.admin_product_description = x["product_description"]

                        other_shops = Shops(on_release=self.selling_other)
                        other_shops.add_widget(Labels(text=self.admin_product_name))
                        other_shops.add_widget(Shop_image(source=self.admin_product_url))
                        other_shops.add_widget(Labels(text=self.admin_product_price))
                        other_shops.id = y
                        shop.add_widget(other_shops)
                        self.spin_active = False
        except:
            self.spin_active = False
            self.order_spinner3()

    def other_shop_comparison(self):
        filename = "helped/other.json"
        try:
            file_size = os.path.getsize(filename)
            if file_size != 0:
                with open(filename) as file:
                    line = json.load(file)
                    local_len = len(line)
                    import firebase_admin
                    firebase_admin._apps.clear()
                    from firebase_admin import credentials, initialize_app, db
                    if not firebase_admin._apps:
                        cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
                        initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})
                        store = db.reference("Yummy").child("Products")
                        stores = store.get()
                        online_len = len(stores)
                        print(local_len, online_len)
                    if local_len == online_len:
                        print(local_len, online_len)
                    else:
                        self.refresh_other()
            else:
                self.refresh_other()
        except:
            toast("something is wrong!")

    def other_shop_faster(self):
        filename = "helped/other.json"
        try:
            if self.other_shops == 0:
                self.other_shops = self.other_shops + 1
                file_size = os.path.getsize(filename)
                thread = threading.Thread(target=self.other_shop_comparison)
                thread.start()
                if file_size != 0:
                    shop = self.root.ids.other_shop
                    with open(filename) as file:
                        line = json.load(file)
                        print(line)
                        self.all_products = line
                        for y, x in line.items():
                            self.admin_product_name = x["product_name"]
                            self.customer_phone = x["admin_phone"]
                            self.admin_product_url = x["image_url"]
                            self.admin_product_price = x["product_price"]
                            self.admin_product_description = x["product_description"]

                            other_shops = Shops(on_release=self.selling_other)
                            other_shops.add_widget(Labels(text=self.admin_product_name))
                            other_shops.add_widget(Shop_image(source=self.admin_product_url))
                            other_shops.add_widget(Labels(text=self.admin_product_price + "/Tsh"))
                            other_shops.id = y
                            shop.add_widget(other_shops)
                            self.spin_active = False
                else:
                    self.other_shops = 0
                    self.order_spinner3()
        except:
            self.other_shops = 0
            self.order_spinner3()

    def selling_other(self, instance):
        print(instance.id)
        # self.count = self.count + 1
        product = instance.id
        self.customer_phone = self.all_products[product]["admin_phone"]
        self.admin_product_url = self.all_products[product]["image_url"]
        self.admin_product_name = self.all_products[product]["product_name"]
        self.admin_product_price = self.all_products[product]["product_price"]
        self.admin_product_description = self.all_products[product]["product_description"]
        sm = self.root
        sm.current = "selling_other"

    def summon(self):
        sm = self.root
        sm.current = "other_shops"
        if self.other_shops == 0:
            self.spin_active = True

    def front_shop(self):
        if True:
            try:
                print("ok")
                if self.front_shop_count == 0:
                    self.front_shop_count = self.front_shop_count + 1
                    print("yess..")
                    import firebase_admin
                    firebase_admin._apps.clear()
                    from firebase_admin import credentials, initialize_app, db
                    if not firebase_admin._apps:
                        shop = self.root.ids.front_shop
                        cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
                        initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})
                        store = db.reference("Yummy").child("Products_admin")
                        print("nice")
                        stores = store.get()
                        from retrive_data import Retrieve as RE
                        thread = threading.Thread(target=RE.front_shop, args=(RE(), stores))
                        thread.start()
                        print("good")
                        self.front_products = stores
                        for y, x in stores.items():
                            self.admin_product_name = x["product_name"]
                            self.customer_phone = x["admin_phone"]
                            self.admin_product_url = x["image_url"]
                            self.admin_product_price = x["product_price"]

                            front_shops = Front_shop(on_release=self.selling_front)
                            layout = FloatLayout()
                            layout.add_widget(Labels(text=self.admin_product_name,
                                                     pos_hint={"center_x": .5, "center_y": .2},
                                                     halign="center"))
                            layout.add_widget(Cool(source=self.admin_product_url))
                            front_shops.add_widget(layout)
                            front_shops.id = y
                            shop.add_widget(front_shops)
                            time.sleep(2)
                            self.spin_active = False
                            self.loading = ""
                    else:
                        print("f**k!")


            except:
                toast("no internet!")
                self.front_shop_offline()

    def front_shop_offline(self):
        filename = "helped/admin.json"
        try:
            file_size = os.path.getsize(filename)
            if file_size > 0:
                shop = self.root.ids.front_shop
                with open(filename) as file:
                    line = json.load(file)
                    print(line)
                    for y, x in line.items():
                        self.admin_product_name = x["product_name"]
                        self.customer_phone = x["admin_phone"]
                        self.admin_product_url = x["image_url"]
                        self.admin_product_price = x["product_price"]

                        front_shops = Front_shop(on_release=self.selling_front)
                        layout = FloatLayout()
                        layout.add_widget(Labels(text=self.admin_product_name,
                                                 pos_hint={"center_x": .5, "center_y": .2},
                                                 halign="center"))
                        layout.add_widget(Cool(source=self.admin_product_url))
                        front_shops.add_widget(layout)
                        front_shops.id = y
                        shop.add_widget(front_shops)
                        time.sleep(2)
                        self.spin_active = False
                        self.loading = ""
        except:
            button = MDTextButton(text="Retry", pos_hint={"center_x": .5, "center_y": .5},
                                  on_release=lambda x: self.refresh_front())
            button.id = "you"
            button.custom_color = 40 / 255, 123 / 255, 222 / 255, 1
            shop = self.root.ids.front_shop
            shop.add_widget(button)
            self.loading = ""
            self.spin_active = False

    def front_shop_comparison(self):
        filename = "helped/admin.json"
        try:
            file_size = os.path.getsize(filename)
            if file_size != 0:
                with open(filename) as file:
                    line = json.load(file)
                    local_len = len(line)
                    import firebase_admin
                    firebase_admin._apps.clear()
                    from firebase_admin import credentials, initialize_app, db
                    if not firebase_admin._apps:
                        cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
                        initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})
                        store = db.reference("Yummy").child("Products_admin")
                        stores = store.get()
                        online_len = len(stores)
                    if local_len == online_len:
                        pass
                    else:
                        self.refresh_front()

            else:
                self.refresh_front()
        except:
            toast("something is wrong!")

    def front_shop_faster(self):
        filename = "helped/admin.json"
        try:
            if self.front_shop_count == 0:
                self.notifier()
                self.front_shop_count = self.front_shop_count + 1
                file_size = os.path.getsize(filename)
                thread = threading.Thread(target=self.front_shop_comparison)
                thread.start()
                if file_size != 0:
                    shop = self.root.ids.front_shop
                    with open(filename) as file:
                        line = json.load(file)
                        print(line)
                        self.front_products = line
                        for y, x in line.items():
                            self.admin_product_name = x["product_name"]
                            self.customer_phone = x["admin_phone"]
                            self.admin_product_url = x["image_url"]
                            self.admin_product_price = x["product_price"]

                            front_shops = Front_shop(on_release=self.selling_front)
                            layout = FloatLayout()
                            layout.add_widget(Labels(text=self.admin_product_name,
                                                     pos_hint={"center_x": .5, "center_y": .2},
                                                     halign="center"))
                            layout.add_widget(Cool(source=self.admin_product_url))
                            front_shops.add_widget(layout)
                            front_shops.id = y
                            shop.add_widget(front_shops)
                            self.spin_active = False
                            self.loading = ""
                else:
                    self.front_shop_count = 0
                    self.order_spinner2()
        except:
            self.front_shop_count = 0
            self.order_spinner2()

    def selling_front(self, instance):
        print(instance.id)
        self.count = self.count + 1
        self.category_tp = "admin"
        product = instance.id
        self.customer_phone = self.front_products[product]["admin_phone"]
        self.admin_product_url = self.front_products[product]["image_url"]
        self.admin_product_name = self.front_products[product]["product_name"]
        self.admin_product_price = self.front_products[product]["product_price"]
        sm = self.root
        sm.current = "selling"

    def success(self, *kwargs):
        self.refresh()

    def refresh(self):
        parent = self.root.ids.food_cat
        all_childs = parent.children
        identity = []
        self.food_count = 0
        for child in all_childs:
            identity.append(child.id)

        self.order_number = str(identity.__len__())

        for i in identity:
            self.remove_wide(i)

        if self.admin_phone == "0788204327":
            self.add_order()
        else:
            self.add_order_admin()

    def refresh_front(self):
        parent = self.root.ids.front_shop
        all_childs = parent.children
        identity = []
        self.front_shop_count = 0
        for child in all_childs:
            identity.append(child.id)

        for i in identity:
            print(i)
            self.remove_wide_front(i)

        self.spin_active = True
        self.order_spinner2()

    def refresh_other(self):
        parent = self.root.ids.other_shop
        all_childs = parent.children
        identity = []
        self.other_shops = 0
        for child in all_childs:
            identity.append(child.id)

        for i in identity:
            print(i)
            self.remove_wide_other(i)

        self.spin_active = True
        self.order_spinner3()

    def remove_wide_front(self, name):
        parent = self.root.ids.front_shop
        for child in parent.children:
            if name == child.id:
                parent.remove_widget(child)

    def remove_wide_other(self, name):
        parent = self.root.ids.other_shop
        for child in parent.children:
            if name == child.id:
                parent.remove_widget(child)

    def remove_wide(self, name):
        parent = self.root.ids.food_cat
        for child in parent.children:
            if name == child.id:
                parent.remove_widget(child)

    def remove_widgets(self, instance):
        name = instance.id
        parent = self.root.ids.food_cat
        for child in parent.children:
            if name == child.id:
                parent.remove_widget(child)
                self.del_entity(child.id)

    def del_entity(self, name):
        import firebase_admin
        firebase_admin._apps.clear()
        from firebase_admin import credentials, initialize_app, db
        if not firebase_admin._apps:
            cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
            initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})

            if self.admin_phone == "0788204327":
                db.reference("Yummy").child("Orders").child(name).delete()
            else:
                db.reference("Yummy").child("Admin").child(self.admin_phone).child("Orders").child(name).delete()

    def validate_user(self, phone, password):
        if phone == "" and phone.Isdigit():
            toast("please enter your phone number correctly")
        elif password == "":
            toast("please enter your password")
        else:
            self.spin_active = True
            thread = threading.Thread(target=self.Signing_in_admin_function, args=(phone, password))
            thread.start()

    def Signing_in_admin(self, phone, password):
        # thread = threading.Thread(target=self.Signing_in_admin_function, args=(phone, password))
        # thread.start()
        self.Signing_in_admin_function(phone, password)

    @mainthread
    def Signing_in_admin_function(self, phone, password):
        if DB.Signing_in_admin(DB(), phone, password):
            self.admin_name = DB.name_admin
            self.remember_me_admin(phone, password, self.admin_name)
            if not self.admin_true:
                self.listen_db(phone)
                sm = self.root
                sm.current = "admin_main"
        else:
            if self.admin_true:
                toast("no internet connection")
                self.spin_active = False
            else:
                self.spin_active = False
                toast("oops! phone number or password in correct or internet connection")

    # XXX---------CUSTOMER--------------XXX

    def id_generator(self):
        not_allowed = ".-:"
        date1 = datetime.datetime.now()
        date, time = id = str(date1).split(" ")
        self.admin_product_id = date + time
        product_id = ""
        for i in range(len(self.admin_product_id)):
            if self.admin_product_id[i] not in not_allowed:
                product_id = self.admin_product_id[i] + product_id
        id = self.admin_product_id = product_id
        print(id)
        return self.admin_product_id

    def get_info(self, phone, phone_other, name, price, product_name, image_path, password, category, description):
        if phone != "" and self.phone_number_check_admin(phone):
            if name != "" and name.isalpha() and price != "" and password != "":
                self.customer_phone = phone
                self.admin_password = password
                self.admin_name = name
                self.admin_product_image = image_path
                self.admin_product_price = price
                self.admin_product_name = product_name
                self.admin_product_id = self.id_generator()
                cate = category
                print(phone, name, price, product_name, image_path, password, self.admin_product_id)
                try:
                    thread = threading.Thread(target=self.transporter, args=(
                        phone, phone_other, name, price, product_name, image_path, password, self.admin_product_id,
                        cate, description))
                    thread.start()
                except:
                    toast("no internet")
            else:
                toast("check your info well")
                self.spin_active = False

        else:
            toast("check your mobile number")
            self.spin_active = False

    def transporter(self, phone, phone_other, name, price, product_name, image_path, password, id, cate, description):
        thread = threading.Thread(target=DB.upload_product_image, args=(
            DB(), cate, image_path, phone, phone_other, name, price, product_name, password, id, description))
        thread.start()

        thread.join()

        self.actively_reg()

    def listen_db(self, phone):
        try:
            import firebase_admin
            firebase_admin._apps.clear()
            from firebase_admin import credentials, initialize_app, db
            id = datetime.datetime.now()
            cred = credentials.Certificate("credential/farmzon-abdcb-c4c57249e43b.json")
            initialize_app(cred, {'databaseURL': 'https://farmzon-abdcb.firebaseio.com/'})
            self.admin_phone = phone
            if phone != "0788204327":
                print("i am listening......")
                my_stream = db.reference("Yummy").child("Admin").child(phone).child("Orders").listen(self.success)
            else:
                print("i am listening......")
                my_stream = db.reference("Yummy").child("Orders").listen(self.success)
        except:
            print("poor you")

    def Permission(self, android=None):
        if self.counter_image <= 0:
            if utils.platform == 'android':
                if self.count_update == 0:
                    from gallary import Gambler as GA
                    Clock.schedule_once(GA.user_select_image, 0)
                    self.admin_product_image = GA.path_of_picture
                    img = self.root.ids.product_image
                    img.source = GA.path_of_picture
                    self.count_update += self.count_update + 1
                else:
                    from gallary import Gambler as GA
                    self.count_update = self.count_update - 1
                    self.admin_product_image = GA.path_of_picture
                    img = self.root.ids.product_image
                    img.source = GA.path_of_picture

            else:
                self.counter_image = self.counter_image + 1
                for root, dirs, files in os.walk("/home/alpha9060/Downloads", topdown=False):
                    for file_ in files:
                        full_file_path = os.path.join(root, file_)
                        if full_file_path.endswith(('.png', '.jpg', '.jpeg')):
                            print(full_file_path)
                            image = full_file_path
                            cat_class = category_gal()
                            cat_class.add_widget(category_ga(source=image))
                            img = self.root.ids.images_added
                            img.add_widget(cat_class)
        else:
            pass

    ads = KivMob(TestIds.INTERSTITIAL)

    def adver(self):
        self.kill_adver()
        self.ads.show_interstitial()

    def build(self):

        self.ads.new_interstitial(TestIds.INTERSTITIAL)
        self.theme_cls.theme_style = "Light"
        self.theme_cls.primary_palette = "DeepOrange"
        self.theme_cls.accent = "Brown"
        # Window.size = (360, 640)
        self.size_x, self.size_y = Window.size
        self.title = "yummy"
Exemplo n.º 11
0
class KivMobDemo(MDApp):

    def __init__(self,**kwargs):
        self.theme_cls.theme_style = "Dark"
        super().__init__(**kwargs)
        self.rewards = Rewards_Handler(self)

    Points = NumericProperty(0)
    show_banner = False

    def build(self):
        self.ads = KivMob(TestIds.APP)
        self.ads.new_banner(TestIds.BANNER, False)
        self.ads.new_interstitial(TestIds.INTERSTITIAL)
        self.ads.request_banner()
        self.ads.request_interstitial()
        self.ads.set_rewarded_ad_listener(self.rewards)
        self.ads.load_rewarded_ad(TestIds.REWARDED_VIDEO)
        self.toggled = False
        return KivMobDemoUI()

    def toggle_banner(self):
        self.show_banner = not self.show_banner
        if self.show_banner:
            self.ads.show_banner()
        else:
            self.ads.hide_banner()

    def load_video(self):
        self.ads.load_rewarded_ad(TestIds.REWARDED_VIDEO)
Exemplo n.º 12
0
class AliasApp(MDApp):
    '''
    Alias application class

    ...

    Attributes
    ----------
    store : JsonStore
        Instance of application store
    sm : ScreenManager
        Instance of screen manager
    active_game : BooleanProperty
        Indicator if active game exists
    dict_idxs : dict
        dict with dictionaries names and indexes of current word in them
    buttons_ready_to_use : BooleanProperty
        buttons enabled or not on the menu screen
    ads : KivMob
        instance of KivMob to manage advertisements

    Methods
    -------
    create_main_game(round_duration, selected_dictionary, teams, penalty,
                     last_word, points_to_win):
        create instance of MainGameScreen and swith to it

    to_game_config():
        switch to the team config screen

    load_main_game():
        load active game configuration from the `store` and switch to it

    start_main_game():
        switch to the main game screen

    save_current_game():
        save configuration of active game to the `store` and toggle `active_game` indicator

    delete_current_game():
        remove configuration of active game from the `store` and toggle `active_game` indicator

    toggle_banner():
        toggle ads banner

    show_interstitial():
        show ads interstitial

    drop_game_and_create_new():
        delete current game and start configuring new

    on_start():
        kivy method

    on_pause():
        kivy method

    on_stop():
        kivy method

    build():
        kivy method
    '''
    store = JsonStore('app_store.json')
    sm = None
    active_game = BooleanProperty(False)
    dict_idxs = None
    buttons_ready_to_use = BooleanProperty(False)
    dialog = None
    ads = None

    def create_main_game(self, round_duration, selected_dictionary, teams,
                         penalty, last_word, points_to_win):
        '''
        Create main game of the application

        Parameters
        ----------
        round_duration : int
            duration of one round in the game
        selected_dictionary : str
            selected dictionary for game words
        teams : list
            list of team names
        penalty : bool
            penalty for skipped word
        last_word : str
            word in the round after time is expired
        points_to_win : int
            amount of points to win the game
        '''
        main_game = self.sm.get_screen('main_game')
        main_game.load_configuration(
            round_duration=round_duration,
            dictionary_name=selected_dictionary,
            dict_idx=self.store.get('dicts_idxs')[selected_dictionary],
            teams=teams,
            penalty=penalty,
            last_word=last_word,
            points_to_win=points_to_win,
            score=[0 for _ in teams],
            current_round=1,
            current_turn=0)
        self.show_interstitial()
        self.start_main_game()
        self.active_game = True

    def to_game_config(self):
        '''
        Route to team config screen with dialog box if `active_game` is True
        '''
        if self.active_game:
            self.dialog.open()
        else:
            self.sm.current = "team_config"

    def load_main_game(self):
        '''
        Load main game of the application
        '''
        active_game_cofig = self.store.get('active_game')
        main_game = self.sm.get_screen('main_game')
        main_game.load_configuration(**active_game_cofig)
        self.show_interstitial()
        self.start_main_game()

    def start_main_game(self):
        '''
        Switch to main game screen
        '''
        self.sm.current = 'main_game'

    def save_current_game(self):
        '''
        Save main game of the application
        '''
        main_game = self.sm.get_screen('main_game')
        self.save_dict_idx(main_game.dictionary_name, main_game.dict_idx)
        self.store.put(
            'active_game', **{
                key: getattr(main_game, key)
                for key in (
                    'round_duration',
                    'dictionary_name',
                    'dict_idx',
                    'teams',
                    'penalty',
                    'last_word',
                    'points_to_win',
                    'score',
                    'current_round',
                    'current_turn',
                )
            })

    def save_dict_idx(self, current_dict, current_dict_idx):
        '''
        Save index of the current dictionary to the app store

        Parameters
        ----------
        current_dict : str
            name of current dictionary
        current_dict_idx : int
            index of current word in the dictionary
        '''
        dict_idxs = self.store.get('dicts_idxs')
        dict_idxs[current_dict] = current_dict_idx
        self.store.put('dicts_idxs', **dict_idxs)

    def delete_current_game(self):
        '''
        Delete main game of the application
        '''
        try:
            self.store.delete('active_game')
        except KeyError:
            pass
        self.active_game = False

    def toggle_banner(self, show):
        '''
        Toggle banner on the screen

        Parameters
        ----------
        show : bool
            whether to show banner or hide
        '''
        if show:
            self.ads.show_banner()
        else:
            self.ads.hide_banner()

    def drop_game_and_create_new(self):
        '''
        Delete current game and start configuring new when dialog applied
        '''
        self.delete_current_game()
        self.dialog.dismiss()
        self.to_game_config()

    def show_interstitial(self):
        '''
        Show ads interstitial
        '''
        if self.ads.is_interstitial_loaded():
            self.ads.show_interstitial()
        else:
            self.ads.request_interstitial()

    def on_start(self):
        try:
            self.store.get('active_game')
            self.active_game = True
        except KeyError:
            pass

        try:
            self.dict_idxs = self.store.get('dicts_idxs')
        except KeyError:
            with open('./constants/words.json', encoding='utf-8') as f:
                dicts = json.load(f)
                idxs = {}
                for dictionary_name, words in dicts.items():
                    shuffle(words)
                    dicts[dictionary_name] = words
                    idxs[dictionary_name] = 0
            with open('./constants/words.json', 'w', encoding='utf-8') as f:
                json.dump(dicts, f)
            self.store.put('dicts_idxs', **idxs)

    def on_pause(self):
        if self.active_game:
            self.save_current_game()
        return True

    def on_stop(self):
        self.on_pause()

    def build(self):
        self.theme_cls.theme_style = 'Dark'

        self.sm = Builder.load_file('main.kv')

        # ads
        self.ads = KivMob(os.environ.get('APP_ID'))
        self.ads.add_test_device('70356742')
        self.ads.new_banner(os.environ.get('BANNER_ID'), top_pos=False)
        self.ads.request_banner()
        self.ads.new_interstitial(os.environ.get('INTERSTITIAL_ID'))
        self.ads.request_interstitial()

        # dialog window to show when starting new game if active game exists
        self.dialog = Dialog(
            title='Створити нову гру?',
            text='Дані про поточну гру буде втрачено.',
            buttons=[
                TextButton(text="Назад",
                           on_release=lambda _: self.dialog.dismiss()),
                TextButton(
                    text="Так",
                    on_release=lambda _: self.drop_game_and_create_new())
            ],
        )

        Cache.append('images', 'round_background',
                     FitImage(source="assets/imgs/round.png"))

        # enable buttons only in 2 second after build to avoid bugs
        def show_menu_buttons():
            self.buttons_ready_to_use = True

        Clock.schedule_once(lambda _: show_menu_buttons(), 2)

        return self.sm
Exemplo n.º 13
0
class MyApp(App):
    def __init__(self, **kwargs):
        super(MyApp, self).__init__(**kwargs)
        app_id = TestIds.APP
        self.ads = KivMob(app_id)
        banner_id = TestIds.BANNER
        interstitial_id = TestIds.INTERSTITIAL
        self.ads.new_banner(banner_id, top_pos=True)
        self.ads.new_interstitial(interstitial_id)
        self.show_ads()
        self.ads_created = True
        self.manga_text_color = (0, 0, 0, 1)
        self.start_up = True  # Use in theme_color

    def build(self):
        self.title = "Manga Updates By Israel Quimson"
        self.phone = Phone()
        self.init_check_folder()
        self.use_kivy_settings = False  # Disable kivy default settings
        self.phone.check_servers()
        self.theme_color()
        Clock.schedule_interval(self.check_internet, 30)
        return self.phone

    def show_ads(self):
        """Method to create ads"""
        self.ads.request_banner()
        self.ads.show_banner()

    def check_internet(self, *args):
        """Method to check internet"""
        url = 'https://1.1.1.1'  # url to check
        timeout = 5  # timeout in seconds
        try:
            r = requests.head(url, timeout=timeout)  # check the connection
            if not self.ads_created:  # check if the ads is created
                self.show_ads()  # Call this method to create ads
                self.ads_created = True  # set the ads_created to true
        except:
            self.ads_created = False  # If no internet set the ads created to false

    def build_config(self, config):
        """Method to define default values in Settings"""
        with open('version.txt', 'r') as file:
            version_num = file.read()
        config.setdefaults('basicsettings', {
            'Servers': 'Mangahub',
            'Version': version_num,
            'darkmode': False
        })

    def build_settings(self, settings):
        """Method to add Panel in the Settings using import file as data"""
        settings.add_json_panel('Settings', self.config, data=settings_json)

    def on_config_change(self, config, section, key, value):
        """Method on change config value in the Settings"""
        if key == 'Servers':
            self.phone.check_servers()
        if key == 'darkmode':
            self.theme_color()

    def theme_color(self):
        """Method to set the theme color and change the theme to dark mode"""
        mode = self.config.get(
            'basicsettings',
            'darkmode')  # Get the value of config darkmode boolean
        if mode == '1':  # Dark mode
            self.manga_text_color = (1, 1, 1, 1)
            self.nav_text_color = (1, 1, 1, 1)
            self.bg1_color = (68 / 255, 68 / 255, 68 / 255, 1)
            self.line_color = (0, 0, 0, 1)
            self.nav_bg_color = (51 / 255, 51 / 255, 51 / 255, 1)
            self.storage_line_color = (1, 1, 1, 1)
        else:  # White mode
            self.manga_text_color = (0, 0, 0, 1)
            self.nav_text_color = (0, 0, 0, 1)
            self.bg1_color = (228 / 255, 241 / 255, 254 / 255, 1)
            self.line_color = (1, 1, 1, 1)
            self.nav_bg_color = (1, 1, 1, 1)
            self.storage_line_color = (0, 0, 0, 1)
        with self.phone.ids.phone_float.canvas.before:
            Color(self.bg1_color[0], self.bg1_color[1], self.bg1_color[2],
                  self.bg1_color[3])
            Rectangle(size=Window.size)
        with self.phone.ids.phone_anchor.canvas.before:
            Color(self.line_color[0], self.line_color[1], self.line_color[2],
                  self.line_color[3])
            Line(points=(0, Window.height * 0.08, Window.width,
                         Window.height * 0.08))
        with self.phone.ids.phone_grid.canvas.before:
            Color(self.nav_bg_color[0], self.nav_bg_color[1],
                  self.nav_bg_color[2], self.nav_bg_color[3])
            Rectangle(size=(Window.width, Window.height * 0.08),
                      pos=self.phone.pos)
        with self.phone.ids.home_window.ids.home_float.canvas.before:
            Color(self.bg1_color[0], self.bg1_color[1], self.bg1_color[2],
                  self.bg1_color[3])
            Rectangle(size=Window.size)
        with self.phone.ids.search_window.ids.search_float.canvas.before:
            Color(self.bg1_color[0], self.bg1_color[1], self.bg1_color[2],
                  self.bg1_color[3])
            Rectangle(size=Window.size)
        with self.phone.ids.storage_window.ids.storage_float.canvas.before:
            Color(self.bg1_color[0], self.bg1_color[1], self.bg1_color[2],
                  self.bg1_color[3])
            Rectangle(size=Window.size)
        with self.phone.ids.storage_window.ids.storage_float.canvas:
            Color(self.storage_line_color[0], self.storage_line_color[1],
                  self.storage_line_color[2], self.storage_line_color[3])
            height = (Window.height -
                      dp(self.ads.determine_banner_height())) * 0.92 * 0.9
            Line(points=(0, height, Window.width, height))
        with self.phone.ids.display_manga.ids.displaymanga_float.canvas.before:
            Color(self.bg1_color[0], self.bg1_color[1], self.bg1_color[2],
                  self.bg1_color[3])
            Rectangle(size=Window.size)
        self.phone.ids.storage_window.ids.storage_label.color = self.manga_text_color
        self.phone.ids.phone_home.color = self.nav_text_color
        self.phone.ids.phone_search.color = self.nav_text_color
        self.phone.ids.phone_favorite.color = self.nav_text_color
        self.phone.ids.phone_settings.color = self.nav_text_color
        if not self.start_up:  # Check if startup
            self.phone.restore_default()
        else:
            self.start_up = False

    def close_settings(self, *settings):
        """Method fire when the close button in settings"""
        super(MyApp, self).close_settings(settings)
        self.ads.show_banner()

    def init_check_folder(self):
        """Method to check if the folder exist and create it if not"""
        if not os.path.exists('imagetemp'):
            os.mkdir('imagetemp')
        if not os.path.exists('imagerelease'):
            os.mkdir('imagerelease')
        if not os.path.exists(os.path.join('..', 'imagemanga', 'mangahub')):
            os.makedirs(os.path.join('..', 'imagemanga', 'mangahub'))
        # if not os.path.exists(os.path.join('..', 'imagemanga', 'mangareader')):
        #     os.makedirs(os.path.join('..', 'imagemanga', 'mangareader'))
        # if not os.path.exists(os.path.join('..', 'imagemanga', 'mangapark')):
        #     os.makedirs(os.path.join('..', 'imagemanga', 'mangapark'))

    def on_pause(self):
        return True  # If True the App will not close when pause

    def on_stop(self):
        self.root.stop.set()  # Set a stop signal for secondary python threads

    def on_resume(self):
        self.ads.request_interstitial()
Exemplo n.º 14
0
class KivMobDemo(App):

    theme_cls = ThemeManager()

    show_banner = False

    def build(self):
        self.ads = KivMob(TestIds.APP)
        self.ads.new_banner(TestIds.BANNER, False)
        self.ads.new_interstitial(TestIds.INTERSTITIAL)
        self.ads.request_banner()
        self.ads.request_interstitial()
        self.ads.set_rewarded_ad_listener(RewardedListenerInterface())
        self.ads.load_rewarded_ad(TestIds.REWARDED_VIDEO)
        self.toggled = False
        return KivMobDemoUI()

    def toggle_banner(self):
        self.show_banner = not self.show_banner
        if self.show_banner:
            self.ads.show_banner()
        else:
            self.ads.hide_banner()
Exemplo n.º 15
0
class KivMobDemo(App):

    APP_ID = "ca-app-pub-COPY APP ID HERE"
    BANNER_ID = "ca-app-pub-COPY BANNER ID HERE"
    INTERSTITIAL_ID = "ca-app-pub-COPY INTERSTITIAL ID HERE"
    TEST_DEVICE_ID = "COPY DEVICE ID HERE"

    def build(self):
        self.ads = KivMob(APP_ID)
        self.ads.add_test_device(TEST_DEVICE_ID)
        self.ads.new_banner({"unitID": BANNER_ID})
        self.ads.new_interstitial(INTERSTITIAL_ID)
        self.ads.request_banner()
        self.ads.request_interstitial()
        self.toggled = False
        return KivMobDemoUI()

    def on_start(self):
        """Called on application start.
        """
        if platform not in ("android", "ios"):
            self.desktop_warning()

    def desktop_warning(self):
        layout = BoxLayout(orientation='vertical')
        layout.add_widget(Label(text='KivMob will not display ads on ' +\
                          'nonmobile platforms. You must build an ' +\
                          'Android project to demo ads. (iOS not yet ' +\
                          'supported)',
                          size_hint_y=1,
                          text_size=(250,  None),
                          halign='left',
                          valign='middle'))
        button_layout = BoxLayout()
        button1 = Button(text="Open Build Steps", size_hint=(0.8, 0.2))
        button1.bind(
            on_release=lambda x: webbrowser.open("https://www.google.com"))
        button_layout.add_widget(button1)
        button2 = Button(text="Close", size_hint=(0.8, 0.2))
        button2.bind(on_release=lambda x: popup.dismiss())
        button_layout.add_widget(button2)
        layout.add_widget(button_layout)
        popup = Popup(title='KivMob Demo Alert',
                      content=layout,
                      size_hint=(0.9, 0.9))
        popup.open()

    def interstitial_warning(self):
        layout = BoxLayout(orientation='vertical')
        layout.add_widget(Label(text="Ad has not loaded. " +\
                                    "Wait a few seconds and then " +\
                                    "try again.",
                                    size_hint_y=1,
                                    text_size=(250,  None),
                                    halign='left',
                                    valign='middle'))
        button_layout = BoxLayout()
        close = Button(text="Close", size_hint=(0.8, 0.2))
        close.bind(on_release=lambda x: popup.dismiss())
        button_layout.add_widget(close)
        layout.add_widget(button_layout)
        popup = Popup(title='KivMob Demo Alert',
                      content=layout,
                      size_hint=(0.9, 0.9))
        popup.open()

    def on_pause(self):
        """Android specific method. Save important app data on pause.
        """
        return True

    def on_resume(self):
        """Android specific method. Resume paused app.
        """
        self.ads.request_interstitial()

    def toggle_banner(self):
        if not self.toggled:
            self.ads.show_banner()
        else:
            self.ads.hide_banner()
        self.toggled = not self.toggled

    def show_interstitial(self):
        if self.ads.is_interstitial_loaded():
            self.ads.show_interstitial()
        else:
            self.interstitial_warning()
Exemplo n.º 16
0
class OneApp(MDApp):
    try:
        ads = KivMob('ca-app-pub-1818238534900904~2025018602')

        def __init__(self):
            try:
                super().__init__()
                #Declaring MDApp object
                self.theme_cls = ThemeManager()
                self.theme_cls.primary_palette = 'Orange'

                self.theme_cls.primary_style = 'Light'
                self.title = 'Type To Write'
                self.screen = Builder.load_file('main.kv')

                self.setup()

                # Put Banner Ads
            except:
                pass

        def animate_card(self, widget, text_field, spinn):
            anim = Animation(pos_hint={'center_y': 0.53})

            anim.start(widget)
            anim1 = Animation(pos_hint={'center_y': 0.75})
            anim1.start(text_field)
            anim2 = Animation(pos_hint={'center_y': 0.65})
            anim2.start(spinn)

        def picture_taken(self, obj, filename):

            try:
                self.picture = filename
                from google.cloud import storage
                """Uploads a file to the bucket."""
                bucket_name = 'online-server-test'
                destination_blob_name = "test-storage-blob.png"
                debug = True
                if not debug:
                    storage_client = storage.Client()
                else:
                    cred_file = 'key.json'
                    storage_client = storage.Client.from_service_account_json(
                        cred_file)

                bucket = storage_client.bucket(bucket_name)
                blob = bucket.blob(destination_blob_name)

                blob.upload_from_filename(self.picture)
                print("File {} uploaded to {}.".format(self.picture,
                                                       destination_blob_name))

                self.hit_cloud_function(destination_blob_name)
                self.screen.ids.firebaseloginscreen.display_loading_screen()

            except:
                pass

        @mainthread
        def hit_cloud_function(self, blob_name):

            try:
                from urllib.parse import urlencode
                msg_data = urlencode({'message': blob_name})
                headers = {
                    'Content-type': 'application/x-www-form-urlencoded',
                    'Accept': 'text/plain'
                }

                print("Sending trigger request")
                trigger_url = "https://us-central1-endless-theorem-297112.cloudfunctions.net/detect_handwriting"
                UrlRequest(trigger_url,
                           req_body=msg_data,
                           req_headers=headers,
                           ca_file=certifi.where(),
                           on_failure=self.error,
                           on_error=self.error,
                           on_success=self.success)
            except:
                pass

        def error(self, *args):
            try:
                print("Error", args)
            except:
                pass

        def success(self, request, response):

            print("Success!")
            try:
                self.screen.ids.typetowritescreen.change_values(response)
                self.hide_screen()
                self.screen.ids.typetowritescreen.change_screen('screen1')
            except:
                pass

        def setup(self):
            try:

                self.screen.ids.firebaseloginscreen.web_api_key = "AIzaSyBmrGpiwimYZ-HT_BSesv4gMjuPJcG3omM"
                self.screen.ids.firebaseloginscreen.debug = False
                self.screen.ids.firebaseloginscreen.remember_user = True
                self.screen.ids.firebaseloginscreen.require_email_verification = True
            except:
                pass

        def call(self, button):
            if button.icon == 'typewriter':

                try:
                    self.screen.ids.typetowritescreen.check_data_login()
                except:
                    pass

            if button.icon == 'notebook':
                try:
                    self.screen.ids.typetowritescreen.grammar_check()
                except:
                    pass
            if button.icon == 'google-photos':
                try:
                    self.screen.ids.typetowritescreen.see_recent_images()
                except:
                    pass

            if button.icon == 'camera':
                try:
                    self.screen.ids.typetowritescreen.ids.screen1.go_camera()
                except:
                    pass

            if button.icon == 'ship-wheel':
                try:
                    self.screen.ids.typetowritescreen.ids.screen1.go_addscreen(
                    )
                except:
                    pass

            if button.icon == 'content-save':
                try:
                    self.screen.ids.typetowritescreen.make_json()
                except:
                    pass

            if button.icon == 'view-list':
                try:
                    self.screen.ids.typetowritescreen.visualize_json()

                    self.screen.ids.typetowritescreen.ids.addscreen.go_friend()
                except:
                    pass

            if button.icon == 'exit-to-app':
                try:
                    self.screen.ids.typetowritescreen.ids.addscreen.go_back()
                except:
                    pass

            if button.icon == 'delete':
                try:
                    self.screen.ids.typetowritescreen.delete()
                except:
                    pass
            if button.icon == 'email-alert':
                try:
                    self.screen.ids.typetowritescreen.change_email()
                except:
                    pass
            if button.icon == 'chart-bar':
                try:
                    self.screen.ids.typetowritescreen.ids.screen1.go_pie_chart(
                    )
                except:
                    pass
            if button.icon == 'truck-delivery':
                try:
                    self.screen.ids.typetowritescreen.change_screen(
                        'ongkirscreen')
                except:
                    pass

        def show_dialog(self):
            try:
                #Make A PopUp Dialog to warn user
                self.dialog = MDDialog(
                    title='LOGOUT',
                    text='Are you sure to log out',
                    size_hint=(0.5, 1),
                    buttons=[
                        MDFlatButton(text='Close',
                                     on_release=self.close_dialog),
                        MDRaisedButton(text='Sign Out',
                                       on_release=self.sign_out)
                    ])
                #Show It On The Screen
                self.dialog.open()
            except:
                pass

        def making_banner(self):
            try:
                self.ads.new_banner('ca-app-pub-1818238534900904/4048546717',
                                    top_pos=False)
                # Requesting New Ads

                self.ads.request_banner()
                from plyer import uniqueid
                self.ads.add_test_device(uniqueid.id.decode('utf-8'))
                self.ads.show_banner()
            except:
                pass

        def close_dialog(self, *args):
            #Closing Dialog
            try:
                self.dialog.dismiss()
            except:
                pass

        def sign_out(self, obj):
            #Make Firebase To Be Logged Out
            try:

                self.screen.ids.firebaseloginscreen.log_out()
                self.screen.current = "firebaseloginscreen"
                self.dialog.dismiss()
            except:
                pass

        def loading_screen(self, *args):
            #Show The Loading Screen
            try:
                self.screen.ids.firebaseloginscreen.display_loading_screen()
            except:
                pass

        def hide_screen(self, *args):
            #Hide The Loading Screen
            try:
                self.screen.ids.firebaseloginscreen.hide_loading_screen()
            except:
                pass

        def on_resume(self):
            self.ads.request_banner()

        def build(self):
            try:
                self.making_banner()
                self.screen.ids.typetowritescreen.setup()

                self.screen.ids.typetowritescreen.ids.ongkirscreen.ids.search_provinsi.setup(
                )
                self.screen.ids.typetowritescreen.store_data_online()
            except:
                pass

            return self.screen
            # Showing Ads To The Screen

    except:
        pass