Skip to content

Commit

Permalink
Develop Native Android Layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Ciber committed Sep 5, 2021
1 parent 393fe23 commit bf79ef9
Show file tree
Hide file tree
Showing 114 changed files with 1,310 additions and 28 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ icon:
cp -r android/app/src/main/res android/app/src/development
cp -r android/app/src/main/res android/app/src/staging

.PHONY: tree
tree:
.PHONY: report
report:
rm file_structure.txt
tree lib/ > file_structure.txt
tree lib/ > file_structure.txt
rm lines_of_code.txt
find lib/ -name '*.dart' | xargs wc -l > lines_of_code.txt
5 changes: 2 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.cubanopensource"
applicationId "com.cubanopensource.todo"
minSdkVersion 16
targetSdkVersion 30
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down Expand Up @@ -91,7 +91,6 @@ android {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
debug {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cubanopensource">
package="com.cubanopensource.todo">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#2196F3" />
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#2196F3" />
</shape>
Binary file added android/app/src/development/res/drawable/bono.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/development/res/drawable/corp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions android/app/src/development/res/drawable/quick_actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/bono" />
<item android:drawable="@drawable/corp" />
<item android:drawable="@drawable/datos" />
<item android:drawable="@drawable/saldo" />

</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions android/app/src/development/res/layout/close_float_widget.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#aaFF0000"
android:gravity="bottom"
android:orientation="vertical">

<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/close" />
</LinearLayout>
9 changes: 9 additions & 0 deletions android/app/src/development/res/layout/float_window.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/float_window_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#7a000000">


</RelativeLayout>
61 changes: 61 additions & 0 deletions android/app/src/development/res/layout/todo_app_widget.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:padding="2.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout android:background="#424242" android:layout_width="fill_parent" android:layout_height="wrap_content">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true">
<LinearLayout android:orientation="horizontal" android:id="@+id/widget_layout_top" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="5.0dip" android:layout_alignParentLeft="true" android:layout_alignParentTop="true">
<RelativeLayout android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5.0dip" android:layout_marginRight="5.0dip">
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5.0dip" android:weightSum="3.0" android:layout_alignParentLeft="true">
<LinearLayout android:gravity="center" android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:id="@+id/todo_logo" android:gravity="center" android:layout_width="48.0dip" android:layout_height="48.0dip">
<ImageView android:layout_width="48.0dip" android:layout_height="48.0dip" android:src="@mipmap/launcher_icon" />
</LinearLayout>
<LinearLayout android:id="@+id/todo_logo_text" android:gravity="center" android:layout_width="48.0dip" android:layout_height="48.0dip">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="TODO" android:textColor="#FFF" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:gravity="center" android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:gravity="center" android:id="@+id/widget_button_net_datos" android:background="@drawable/back_imagen_widget_button" android:layout_width="32.0dip" android:layout_height="32.0dip">
<ImageView android:layout_width="22.0dip" android:layout_height="22.0dip" android:src="@mipmap/ic_widget_button_datos" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:gravity="center" android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:gravity="center" android:id="@+id/widget_button_net_wifi" android:background="@drawable/back_imagen_widget_button" android:layout_width="32.0dip" android:layout_height="32.0dip">
<ImageView android:layout_width="22.0dip" android:layout_height="22.0dip" android:src="@mipmap/ic_widget_button_wifi" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:id="@+id/linearLayout_button1" android:padding="15.0dip" android:paddingBottom="10.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:weightSum="5.0" android:layout_below="@id/widget_layout_top" android:layout_alignParentLeft="true">
<LinearLayout android:gravity="center" android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:gravity="center" android:id="@+id/widget_button_saldo" android:background="@drawable/back_imagen_widget" android:layout_width="@dimen/widget_button_back" android:layout_height="@dimen/widget_button_back">
<ImageView android:layout_width="@dimen/widget_button_icon" android:layout_height="@dimen/widget_button_icon" android:src="@mipmap/ic_main_list_item2" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:gravity="center" android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:gravity="center" android:id="@+id/widget_button_bonos" android:background="@drawable/back_imagen_widget" android:layout_width="@dimen/widget_button_back" android:layout_height="@dimen/widget_button_back">
<ImageView android:layout_width="@dimen/widget_button_icon" android:layout_height="@dimen/widget_button_icon" android:src="@mipmap/ic_saldo_list_item4" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:gravity="center" android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:gravity="center" android:id="@+id/widget_button_saldo_datos" android:background="@drawable/back_imagen_widget" android:layout_width="@dimen/widget_button_back" android:layout_height="@dimen/widget_button_back">
<ImageView android:layout_width="@dimen/widget_button_icon" android:layout_height="@dimen/widget_button_icon" android:src="@mipmap/ic_planes_datos_list_item1" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:gravity="center" android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:gravity="center" android:id="@+id/widget_button_saldo_voz" android:background="@drawable/back_imagen_widget" android:layout_width="@dimen/widget_button_back" android:layout_height="@dimen/widget_button_back">
<ImageView android:layout_width="@dimen/widget_button_icon" android:layout_height="@dimen/widget_button_icon" android:src="@mipmap/ic_planes_voz_list_item1" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:gravity="center" android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
<LinearLayout android:gravity="center" android:id="@+id/widget_button_saldo_sms" android:background="@drawable/back_imagen_widget" android:layout_width="@dimen/widget_button_back" android:layout_height="@dimen/widget_button_back">
<ImageView android:layout_width="@dimen/widget_button_icon" android:layout_height="@dimen/widget_button_icon" android:src="@mipmap/ic_planes_sms_list_item1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Binary file modified android/app/src/development/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/development/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/development/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/development/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/development/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions android/app/src/development/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<resources>

<style name="ThemeOverlay.Android.AppWidgetContainer" parent="">
<item name="appWidgetBackgroundColor">@color/light_blue_900</item>
<item name="appWidgetTextColor">@color/light_blue_200</item>
</style>
</resources>
6 changes: 6 additions & 0 deletions android/app/src/development/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<declare-styleable name="AppWidgetAttrs">
<attr name="appWidgetBackgroundColor" format="color" />
<attr name="appWidgetTextColor" format="color" />
</declare-styleable>
</resources>
6 changes: 6 additions & 0 deletions android/app/src/development/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<color name="light_blue_50">#FFE1F5FE</color>
<color name="light_blue_200">#FF81D4FA</color>
<color name="light_blue_600">#FF039BE5</color>
<color name="light_blue_900">#FF01579B</color>
</resources>
11 changes: 11 additions & 0 deletions android/app/src/development/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!--
Refer to App Widget Documentation for margin information
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
-->
<dimen name="widget_margin">0dp</dimen>
<dimen name="widget_button_icon">25.0dip</dimen>
<dimen name="widget_button_back">40.0dip</dimen>
</resources>
5 changes: 5 additions & 0 deletions android/app/src/development/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="appwidget_text">EXAMPLE</string>
<string name="add_widget">Add widget</string>
</resources>
7 changes: 7 additions & 0 deletions android/app/src/development/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<resources>

<style name="ThemeOverlay.Android.AppWidgetContainer" parent="">
<item name="appWidgetBackgroundColor">@color/light_blue_600</item>
<item name="appWidgetTextColor">@color/light_blue_50</item>
</style>
</resources>
10 changes: 10 additions & 0 deletions android/app/src/development/res/xml/todo_app_widget_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/todo_app_widget"
android:initialLayout="@layout/todo_app_widget"
android:minWidth="250dp"
android:minHeight="110dp"
android:previewImage="@drawable/app_widget_preview"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen"></appwidget-provider>
34 changes: 30 additions & 4 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cubanopensource">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cubanopensource.todo">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:label="TODO"
android:icon="@mipmap/launcher_icon">
android:icon="@mipmap/launcher_icon"
android:usesCleartextTraffic="true">

<receiver android:name=".TodoAppWidget" android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>

<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/todo_app_widget_info" />
</receiver>

<service android:name=".FloatingWindow" />

<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.cubanopensource.todo

import android.annotation.SuppressLint
import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.Settings
import android.widget.RemoteViews

/**
* Implementation of App Widget functionality.
*/
class TodoAppWidget : AppWidgetProvider() {
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
// There may be multiple widgets active, so update all of them
for (appWidgetId in appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId)
}
}

override fun onEnabled(context: Context) {
// Enter relevant functionality for when the first widget is created
}

override fun onDisabled(context: Context) {
// Enter relevant functionality for when the last widget is disabled
}
}

@SuppressLint("UnspecifiedImmutableFlag")
internal fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int) {
// Construct the RemoteViews object
val views = RemoteViews(context.packageName, R.layout.todo_app_widget)

val pendingIntentSaldo = PendingIntent.getActivity(context, 0,
Intent(Intent.ACTION_CALL, Uri.parse("tel:*222${Uri.encode("#")}")), 0)

val pendingIntentBono = PendingIntent.getActivity(context, 0,
Intent(Intent.ACTION_CALL, Uri.parse("tel:*222*266${Uri.encode("#")}")), 0)

val pendingIntentDatos = PendingIntent.getActivity(context, 0,
Intent(Intent.ACTION_CALL, Uri.parse("tel:*222*328${Uri.encode("#")}")), 0)

val pendingIntentVoz = PendingIntent.getActivity(context, 0,
Intent(Intent.ACTION_CALL, Uri.parse("tel:*222*869${Uri.encode("#")}")), 0)

val pendingIntentSms = PendingIntent.getActivity(context, 0,
Intent(Intent.ACTION_CALL, Uri.parse("tel:*222*767${Uri.encode("#")}")), 0)

val pendingIntentTODO = PendingIntent.getActivity(context, 0,
Intent(context, MainActivity::class.java), 0)

val pendingIntentWifi = PendingIntent.getActivity(context, 0, Intent(Settings.ACTION_WIFI_SETTINGS), 0)

val dataUseIntent = Intent(Intent.ACTION_MAIN)
dataUseIntent.component = (ComponentName(
"com.android.settings",
"com.android.settings.Settings\$DataUsageSummaryActivity"
))
dataUseIntent.flags = (Intent.FLAG_ACTIVITY_NEW_TASK and Intent.FLAG_ACTIVITY_CLEAR_TOP)

val pendingIntentData: PendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
PendingIntent.getActivity(context, 0, Intent(Settings.ACTION_DATA_USAGE_SETTINGS), 0)
else
PendingIntent.getActivity(context, 0, dataUseIntent, 0)

views.setOnClickPendingIntent(R.id.widget_button_saldo, pendingIntentSaldo)
views.setOnClickPendingIntent(R.id.widget_button_bonos, pendingIntentBono)
views.setOnClickPendingIntent(R.id.widget_button_saldo_datos, pendingIntentDatos)
views.setOnClickPendingIntent(R.id.widget_button_saldo_voz, pendingIntentVoz)
views.setOnClickPendingIntent(R.id.widget_button_saldo_sms, pendingIntentSms)
views.setOnClickPendingIntent(R.id.todo_logo, pendingIntentTODO)
views.setOnClickPendingIntent(R.id.widget_button_net_wifi, pendingIntentWifi)
views.setOnClickPendingIntent(R.id.widget_button_net_datos, pendingIntentData)

// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views)
}

This file was deleted.

Loading

0 comments on commit bf79ef9

Please sign in to comment.