Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
Added support for custom application settings.
Browse files Browse the repository at this point in the history
Fixed push notifications with links.
Enable remote debugging.
  • Loading branch information
luissilvaos committed Nov 12, 2015
1 parent 72719eb commit da8035a
Show file tree
Hide file tree
Showing 15 changed files with 737 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="18" android:versionName="1.1.7" android:windowSoftInputMode="adjustPan" package="com.outsystems.android" xmlns:android="http://schemas.android.com/apk/res/android">
<manifest android:hardwareAccelerated="true" android:versionCode="19" android:versionName="1.1.8" android:windowSoftInputMode="adjustPan" package="com.outsystems.android" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
Expand Down
55 changes: 54 additions & 1 deletion outsystems-app-android/Outsystems/platforms/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ android {
compileSdkVersion 20
buildToolsVersion "20.0.0"


defaultConfig{

if (project.hasProperty('APPLICATION_ID') && !((String)APPLICATION_ID).isEmpty()) {
applicationId APPLICATION_ID
}

if (project.hasProperty('APPLICATION_VERSION') && !((String)APPLICATION_VERSION).isEmpty()){
versionName APPLICATION_VERSION
}

if (project.hasProperty('APPLICATION_CODE') && !((String)APPLICATION_CODE).isEmpty()){
versionCode APPLICATION_CODE.toInteger()
}
}

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
Expand All @@ -35,4 +51,41 @@ android {
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}


buildTypes {

if( project.hasProperty('OUTPUT_DIR') && !((String)OUTPUT_DIR).isEmpty()){

// this is used to alter output directory and file name. If you don't need it
// you can safely comment it out.
applicationVariants.all { variant ->

variant.outputs.each { output ->
def file = output.outputFile

String parent = file.parent
if ( new File( (String)OUTPUT_DIR ).exists() ) {
parent = OUTPUT_DIR
}

if( project.hasProperty('APPLICATION_NAME') && !((String)APPLICATION_NAME).isEmpty()){
output.outputFile = new File(
parent,
(String)(APPLICATION_NAME + "-" + defaultConfig.versionName + ".apk")
)
}
else{
output.outputFile = new File(
parent,
(String)("OutsystemsNow.apk")
)
}

}
}
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APPLICATION_NAME=
APPLICATION_ID=
APPLICATION_VERSION=
APPLICATION_CODE=
OUTPUT_DIR=
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
android:gravity="center_horizontal"
android:orientation="vertical" >


<ImageView
android:id="@+id/image_view_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:background="@drawable/logo"
android:contentDescription="@string/image_logo"
android:visibility="gone"/>

<com.outsystems.android.widgets.CustomFontTextView
android:id="@+id/text_view_label_application"
android:layout_width="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
android:layout_width="fill_parent"
android:layout_height="5dp"
android:orientation="horizontal"
android:layout_above="@+id/toolbar"
android:layout_alignBottom="@+id/mainView"

android:layout_marginLeft="-5dp"
android:layout_marginRight="-5dp">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
android:layout_height="wrap_content">

<ProgressBar
android:id="@+id/progress_bar"
android:id="@+id/networkErrorProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"SkipNativeLogin": false,
"SkipApplicationList": false,
"HideNavigationBar": false,
"DefaultHostname": null,
"DefaultApplicationURL": null,
"BackgroundColor": null,
"ForegroundColor": null,
"TintColor": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.View;
Expand All @@ -30,9 +36,11 @@
import com.outsystems.android.adapters.ApplicationsAdapter;
import com.outsystems.android.core.WSRequestHandler;
import com.outsystems.android.core.WebServicesClient;
import com.outsystems.android.helpers.ApplicationSettingsController;
import com.outsystems.android.helpers.DeepLinkController;
import com.outsystems.android.helpers.HubManagerHelper;
import com.outsystems.android.helpers.OfflineSupport;
import com.outsystems.android.model.AppSettings;
import com.outsystems.android.model.Application;
import com.outsystems.android.widgets.ActionBarAlert;

Expand Down Expand Up @@ -96,6 +104,13 @@ protected void onCreate(Bundle savedInstanceState) {

setupActionBar();

boolean hideActionBar = ApplicationSettingsController.getInstance().hideActionBar(this);

if(hideActionBar) {
// Hide action bar
getSupportActionBar().hide();
}

mLoadingView = findViewById(R.id.loading_spinner);
gridView = (GridView) findViewById(R.id.grid_view_applications);

Expand Down Expand Up @@ -132,6 +147,64 @@ protected void onCreate(Bundle savedInstanceState) {

this.registerReceiver(this.mConnReceiver,
new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));


// Application Settings

boolean hasValidSettings = ApplicationSettingsController.getInstance().hasValidSettings();

if(hasValidSettings){

boolean hideNavigationBar = ApplicationSettingsController.getInstance().hideNavigationBar();
if(hideNavigationBar){

View navigationBar = findViewById(R.id.toolbar);
if(navigationBar != null)
navigationBar.setVisibility(View.GONE);

View divider = findViewById(R.id.divider_toolbar);
if(divider != null)
divider.setVisibility(View.GONE);

}

AppSettings appSettings = ApplicationSettingsController.getInstance().getSettings();


boolean customBgColor = appSettings.getBackgroundColor() != null && !appSettings.getBackgroundColor().isEmpty();
if(customBgColor){
int newColor = Color.parseColor(appSettings.getBackgroundColor());
PorterDuff.Mode mMode = PorterDuff.Mode.SRC_ATOP;
}

boolean customFgColor = appSettings.getForegroundColor() != null && !appSettings.getForegroundColor().isEmpty();
if(customFgColor){
int newColor = Color.parseColor(appSettings.getForegroundColor());
PorterDuff.Mode mMode = PorterDuff.Mode.SRC_ATOP;

// TODO: Offline Alert
}

boolean customTintColor = appSettings.getTintColor() != null && !appSettings.getTintColor().isEmpty();

if(customTintColor){
int newColor = Color.parseColor(appSettings.getTintColor());
PorterDuff.Mode mMode = PorterDuff.Mode.SRC_ATOP;

Spannable text = new SpannableString(getActionBar().getTitle());
text.setSpan(new ForegroundColorSpan(newColor), 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
getActionBar().setTitle(text);


Drawable drawable = getResources().getDrawable(R.drawable.icon_chevron_back);
drawable.setColorFilter(newColor ,mMode);
getActionBar().setLogo(drawable);

}


}

}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,17 @@ public void onClick(DialogInterface dialog, int which) {
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
} else if(messageJson.has("l")) {
try {
String url = messageJson.getString("l");
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
}
catch(Exception e)
{
EventLogger.logError(getClass(), e);
}
}

}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
import com.outsystems.android.helpers.HubManagerHelper;
import com.outsystems.android.model.Infrastructure;

import java.net.MalformedURLException;
import java.net.URL;

/**
* Class Hub App Activity.
*
Expand Down Expand Up @@ -88,7 +85,7 @@ public void requestFinish(Object result, boolean error, int statusCode) {
app.setDemoApplications(false);
// Start Login Activity
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
intent.putExtra(LoginActivity.KEY_AUTOMATICLY_LOGIN, false);
intent.putExtra(LoginActivity.KEY_AUTOMATICALLY_LOGIN, false);
if (infrastructure != null) {
intent.putExtra(LoginActivity.KEY_INFRASTRUCTURE_NAME, infrastructure.getName());
}
Expand Down
Loading

0 comments on commit da8035a

Please sign in to comment.