Commit ac5bea79 authored by Drahomír Karchňák's avatar Drahomír Karchňák

Refactored html assets and build.gradle.

parent bd664d80
......@@ -48,68 +48,28 @@ dependencies {
compile 'net.sf.jopt-simple:jopt-simple:3.2'
}
task prepareDebugVersion(dependsOn: 'processDebugManifest') {
doLast{
//TODO - Find a better way
// google maps
File manifest = file("${buildDir}/intermediates/manifests/full/debug/AndroidManifest.xml")
String manifestContent = manifest.getText('UTF-8')
if (project.hasProperty('RMBT_GOOGLEMAPS_APIKEY')) {
manifestContent = manifestContent.replaceAll(/GOOGLEMAPS_APIKEY/, RMBT_GOOGLEMAPS_APIKEY)
}
manifest.write(manifestContent, 'UTF-8')
}
}
task prepareReleaseVersion(dependsOn: 'processReleaseManifest') {
doLast{
//TODO - Find a better way
// google maps
File manifest = file("${buildDir}/intermediates/manifests/full/release/AndroidManifest.xml")
String manifestContent = manifest.getText('UTF-8')
if (project.hasProperty('RMBT_GOOGLEMAPS_APIKEY')) {
manifestContent = manifestContent.replaceAll(/GOOGLEMAPS_APIKEY/, RMBT_GOOGLEMAPS_APIKEY)
}
manifest.write(manifestContent, 'UTF-8')
}
}
tasks.whenTaskAdded { task ->
if (task.name == 'processDebugResources')
task.dependsOn prepareDebugVersion
task devNDTTask(type: Copy) {
from '../RMBTClient/src/assets/'
into buildDir.getPath() + '/intermediates/assets/dev/'
include '**.properties'
}
tasks.whenTaskAdded { task ->
if (task.name == 'processReleaseResources')
task.dependsOn prepareReleaseVersion
task debugNDTTask(type: Copy) {
from '../RMBTClient/src/assets/'
into buildDir.getPath() + '/intermediates/assets/debug/'
include '**.properties'
}
// copy NDT resources to android debug
tasks.whenTaskAdded { task ->
if (task.name.startsWith("processDebugManifest")) {
task << {
copy {
from "../RMBTClient/src/assets/"
into buildDir.getPath() + "/intermediates/assets/debug/"
include "**.properties"
}
}
}
task releaseNDTTask(type: Copy) {
from '../RMBTClient/src/assets/'
into buildDir.getPath() + '/intermediates/assets/release/'
include '**.properties'
}
// copy NDT resources to android release
tasks.whenTaskAdded { task ->
if (task.name.startsWith("processReleaseManifest")) {
task << {
copy {
from "../RMBTClient/src/assets/"
into buildDir.getPath() + "/intermediates/assets/release/"
include "**.properties"
}
}
}
project.afterEvaluate {
tasks.findByName('processDevManifest')?.dependsOn devNDTTask
tasks.findByName('processDebugManifest')?.dependsOn debugNDTTask
tasks.findByName('processReleaseManifest')?.dependsOn releaseNDTTask
}
android {
......@@ -128,7 +88,7 @@ android {
srcDir 'res/main'
}
assets {
srcDir 'assets'
srcDir 'assets/main'
}
}
......
......@@ -98,7 +98,7 @@ public class RMBTHelpFragment extends Fragment
Log.w(getTag(), "error code:" + errorCode);
Log.d(getTag(), "error desc:" + description);
Log.d(getTag(), "error url:" + failingUrl);
webview.loadUrl("file:///android_res/raw/error.html");
webview.loadUrl("file:///android_asset/html/error.html");
super.onReceivedError(view, errorCode, description, failingUrl);
}
});
......
......@@ -66,7 +66,6 @@ import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
......@@ -142,8 +141,6 @@ import cz.nic.netmetr.R;
*
*/
public class RMBTMainActivity extends Activity implements MapProperties, RMBTLoopService.RMBTLoopServiceListener {
private static final String BUG_REPORT_MANIFEST_PROPERTY = "cz.nic.labs.rmbt.android.test.RMBTBugReport";
protected static final int REQUEST_PREFERENCES_ACTIVITY_RESULT = 1;
/**
......
......@@ -39,9 +39,9 @@ import cz.nic.netmetr.R;
public class RMBTCheckFragment extends Fragment
{
public enum CheckType {
NDT("file:///android_res/raw/ndt_info.html", AppConstants.PAGE_TITLE_NDT_CHECK,
NDT("file:///android_asset/html/ndt_info.html", AppConstants.PAGE_TITLE_NDT_CHECK,
R.string.terms_ndt_header, R.string.terms_ndt_accept_text, false),
INFORMATION_COMMISSIONER("file:///android_res/raw/ic_info.html", AppConstants.PAGE_TITLE_CHECK_INFORMATION_COMMISSIONER,
INFORMATION_COMMISSIONER("file:///android_asset/html/ic_info.html", AppConstants.PAGE_TITLE_CHECK_INFORMATION_COMMISSIONER,
R.string.terms_ic_header, R.string.terms_ic_accept_text, true);
private final String templateFile;
......
/*******************************************************************************
* Copyright 2013-2014 alladin-IT GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package at.alladin.rmbt.android.terms;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import at.alladin.rmbt.android.main.RMBTMainActivity;
import at.alladin.rmbt.android.util.ConfigHelper;
import cz.nic.netmetr.R;
public class RMBTNDTCheckFragment extends Fragment
{
private CheckBox ndtCheckBox;
boolean firstTime = true;
@Override
public void onSaveInstanceState(final Bundle b)
{
b.putBoolean("ndtChecked", ndtCheckBox.isChecked());
super.onSaveInstanceState(b);
}
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState)
{
if (! (getActivity() instanceof RMBTMainActivity))
firstTime = false;
final View v = inflater.inflate(R.layout.ndt_check, container, false);
if (! firstTime)
v.findViewById(R.id.termsNdtButtonBack).setVisibility(View.GONE);
ndtCheckBox = (CheckBox) v.findViewById(R.id.ndtCheckBox);
if (savedInstanceState != null)
ndtCheckBox.setChecked(savedInstanceState.getBoolean("ndtChecked"));
final Button buttonAccept = (Button) v.findViewById(R.id.termsNdtAcceptButton);
if (! firstTime)
{
ndtCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
buttonAccept.setEnabled(isChecked);
}
});
}
final WebView wv = (WebView) v.findViewById(R.id.ndtInfoWebView);
wv.loadUrl("file:///android_res/raw/ndt_info.html");
buttonAccept.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(final View v)
{
final Activity activity = getActivity();
ConfigHelper.setNDT(activity, ndtCheckBox.isChecked());
ConfigHelper.setNDTDecisionMade(activity, true);
activity.getFragmentManager().popBackStack("ndt_check", FragmentManager.POP_BACK_STACK_INCLUSIVE);
if (firstTime)
((RMBTMainActivity) activity).initApp(false);
else
{
getActivity().setResult(ndtCheckBox.isChecked() ? Activity.RESULT_OK : Activity.RESULT_CANCELED);
getActivity().finish();
}
}
});
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
buttonAccept.setEnabled(firstTime || ndtCheckBox.isChecked());
}
}, 500);
final Button buttonBack = (Button) v.findViewById(R.id.termsNdtBackButton);
buttonBack.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(final View v)
{
getActivity().getFragmentManager().popBackStack();
}
});
return v;
}
}
......@@ -55,7 +55,7 @@ public class RMBTTermsCheckFragment extends Fragment
view = inflater.inflate(R.layout.terms_check, container, false);
final WebView tcWvl = (WebView) view.findViewById(R.id.termsCheckWebViewLong);
tcWvl.loadUrl("file:///android_res/raw/terms_conditions_long.html");
tcWvl.loadUrl("file:///android_asset/html/terms_conditions_long.html");
final Activity activity = getActivity();
if (! (activity instanceof RMBTMainActivity))
......
......@@ -57,7 +57,7 @@ public class RMBTTermsFragment extends Fragment
final String failingUrl)
{
super.onReceivedError(view, errorCode, description, failingUrl);
webview.loadUrl("file:///android_res/raw/error.html");
webview.loadUrl("file:///android_asset/html/error.html");
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment