Last active
April 21, 2024 16:30
-
-
Save Xnuvers007/044671ced762160d0a700d50658b316b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[app] | |
# (str) Title of your application | |
title = ShortLinkApp | |
# (str) Package name | |
package.name = shortlinkapp | |
# (str) Package domain (needed for android/ios packaging) | |
package.domain = org.shortlink | |
# (str) Source code where the main.py lives | |
source.dir = . | |
# (str) Source code entry point in main.py | |
source.include_exts = py,png,jpg,kv,atlas | |
source.exclude_exts = spec, txt, md, gitignore | |
source.exclude_patterns = assets/*, images/*, .git/* | |
# (list) Application requirements | |
requirements = kivy, requests | |
# (str) Application versioning (method 1) | |
version = 1.0 | |
# (int) Target Android API, should be as high as possible. | |
# Make sure to use a google API version for the latest features | |
api = 30 | |
# (int) Minimum API required | |
minapi = 21 | |
# (int) Android SDK version to use | |
sdk = 27 | |
# (str) Supported orientations (landscape, portrait or all) | |
orientation = portrait | |
# (bool) Indicate whether the application should be fullscreen or not | |
fullscreen = 0 | |
# (str) Android logcat filters to use | |
logcat_filters = *:S python:D | |
# (list) Permissions | |
android.permissions = INTERNET | |
# (list) Features (adds uses-feature -tags to manifest) | |
# android.features = android.hardware.camera | |
# (str) Application icon | |
icon.filename = %(source.dir)s/icon.png | |
# (str) Android Oreo notification channel for the foreground service | |
# android.notification_channel = | |
# (str) Android Oreo notification channel name for the foreground service | |
# android.notification_channel_name = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.mediafire.com/file/pac87dkfmkhiseu/shortlinkapp-0.1.apk/file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ShortLinkApp>: | |
orientation: 'vertical' | |
padding: 20 | |
Label: | |
text: "Shorten Link" | |
size_hint: 1, 0.5 | |
TextInput: | |
id: url_input | |
text: "https://google.com" | |
hint_text: "Enter URL" | |
multiline: False | |
size_hint: 1, 0.2 | |
Button: | |
text: "Shorten" | |
size_hint: 1, 0.1 | |
on_press: root.shorten_url() | |
Label: | |
id: shortlink_label | |
text: "" | |
size_hint: 1, 0.2 | |
Button: | |
text: "Copy Shortlink" | |
size_hint: 1, 0.1 | |
on_press: root.copy_shortlink() | |
Button: | |
text: "Clear" | |
size_hint: 1, 0.1 | |
on_press: root.clear_url() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.uix.label import Label | |
from kivy.uix.textinput import TextInput | |
from kivy.uix.button import Button | |
from kivy.core.clipboard import Clipboard | |
import requests | |
class ShortLinkApp(App): | |
def build(self): | |
# Layout | |
layout = BoxLayout(orientation='vertical', padding=20) | |
# Judul | |
title = Label(text="Shorten Link", size_hint=(1, 0.5)) | |
layout.add_widget(title) | |
# Input URL | |
self.url_input = TextInput(text="https://google.com", hint_text="Enter URL", multiline=False, size_hint=(1, 0.2)) | |
layout.add_widget(self.url_input) | |
# Tombol Shorten | |
shorten_button = Button(text="Shorten", size_hint=(1, 0.1)) | |
shorten_button.bind(on_press=self.shorten_url) | |
layout.add_widget(shorten_button) | |
# Output Shortlink | |
self.shortlink_label = Label(text="", size_hint=(1, 0.2)) | |
layout.add_widget(self.shortlink_label) | |
# Tombol Copy | |
copy_button = Button(text="Copy Shortlink", size_hint=(1, 0.1)) | |
copy_button.bind(on_press=self.copy_shortlink) # Bind to copy_shortlink function | |
layout.add_widget(copy_button) | |
# Tombol Hapus | |
clear_button = Button(text="Clear URL", size_hint=(1, 0.1)) | |
clear_button.bind(on_press=self.clear_url) | |
layout.add_widget(clear_button) | |
return layout | |
def shorten_url(self, instance): | |
# Ambil URL dari input | |
url = self.url_input.text | |
# Periksa apakah input kosong | |
if not url: | |
self.shortlink_label.text = "Error: Input is empty" | |
return | |
try: | |
# Kirim permintaan ke layanan shortlink | |
response = requests.get(f"https://ouo.io/api/R6ZNU7m1?s={url}") | |
# Periksa respon | |
if response.status_code == 200: | |
# Ambil shortlink dari respons | |
shortlink = response.text.strip() | |
# Tampilkan shortlink | |
self.shortlink_label.text = f"Shortlink: {shortlink}" | |
else: | |
# Tampilkan pesan kesalahan jika permintaan gagal | |
self.shortlink_label.text = "Error: Failed to shorten link" | |
except Exception as e: | |
# Tangani kesalahan umum | |
self.shortlink_label.text = f"Error: {str(e)}" | |
def copy_shortlink(self, instance): | |
# Ambil teks dari shortlink_label | |
shortlink_text = self.shortlink_label.text | |
# Periksa apakah teks mengandung "Shortlink" | |
if "Shortlink" in shortlink_text: | |
# Pisahkan teks untuk mendapatkan shortlink saja | |
shortlink = shortlink_text.split(": ")[1] | |
# Salin shortlink ke clipboard | |
Clipboard.copy(shortlink) | |
self.shortlink_label.text = "Shortlink copied!\n" + shortlink | |
else: | |
self.shortlink_label.text = "Error: Shortlink not found" | |
def clear_url(self, instance): | |
# Kosongkan isian URL | |
self.url_input.text = "" | |
if __name__ == '__main__': | |
ShortLinkApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
icon.png