Skip to content

Commit

Permalink
Update to version 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquitolabs committed Sep 19, 2017
1 parent 32b72d3 commit eed5a9f
Show file tree
Hide file tree
Showing 25 changed files with 294 additions and 17 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*/build
*/*.iml
*.iml
.gradle
.idea
.idea/**
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Referèndum 1-O

L'1 d'Octubre ja s'acosta i a causa de la censura i la persecució de drets democràtics fonamentals com són la llibertat d'expressió (tancament de pàgines web, requisaments de cartells...) i la llibertat de correspondència (vulnerant així la privacitat), un grup de professionals de les TIC ens hem vist empesos a crear una aplicació per tal de mantenir informada la població i garantir que tothom pugui exercir el seu dret a decidir.
L'1 d'Octubre ja s'acosta i a causa de la censura i la persecució de drets democràtics fonamentals com són la llibertat d'expressió (tancament de pàgines web, requises de cartells...) i la llibertat de correspondència (vulnerant així la privacitat), un grup de professionals de les TIC ens hem vist empesos a crear una aplicació per tal de mantenir informada la població i garantir que tothom pugui exercir el seu dret a decidir.

Funcionalitats:

Expand Down
2 changes: 1 addition & 1 deletion android-maps-extensions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
buildToolsVersion '26.0.1'

defaultConfig {
minSdkVersion 21
minSdkVersion 14
}
dexOptions {
preDexLibraries = true
Expand Down
9 changes: 6 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ android {

defaultConfig {
applicationId "com.referendum.uoctubre"
minSdkVersion 21
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionCode 4
versionName "1.1"
vectorDrawables.useSupportLibrary = true
}

Expand Down Expand Up @@ -50,6 +50,9 @@ dependencies {

//Image downloading
compile 'com.github.bumptech.glide:glide:4.1.1'

//WebView
compile 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
}

apply plugin: 'com.google.gms.google-services'
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
package="com.referendum.uoctubre">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
android:name=".UOctubreApplication"
Expand Down
150 changes: 150 additions & 0 deletions app/src/main/java/com/referendum/uoctubre/fragments/WebFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package com.referendum.uoctubre.fragments;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.SslErrorHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.referendum.uoctubre.R;
import com.referendum.uoctubre.main.Constants;

import im.delight.android.webview.AdvancedWebView;

public class WebFragment extends BaseFragment implements AdvancedWebView.Listener {

public static final String TAG = "web_fragment";

public static WebFragment newInstance() {
Bundle args = new Bundle();
WebFragment fragment = new WebFragment();
fragment.setArguments(args);
return fragment;
}

private AdvancedWebView mWebView;
private View loadingLayout;
private View errorLayout;

@SuppressLint("SetJavaScriptEnabled")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_web, container, false);

mWebView = view.findViewById(R.id.webview);
loadingLayout = view.findViewById(R.id.loading_layout);
errorLayout = view.findViewById(R.id.error_layout);

errorLayout.findViewById(R.id.error_retry_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
errorLayout.setVisibility(View.GONE);
loadingLayout.setVisibility(View.VISIBLE);
mWebView.setVisibility(View.VISIBLE);
mWebView.loadUrl("about:blank");

//Allow to change URL via Firebase
FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
String webUrl = firebaseRemoteConfig.getString(Constants.FIREBASE_CONFIG_WEB_URL);

mWebView.loadUrl(webUrl);
}
});

mWebView.setListener(getActivity(), this);
mWebView.setGeolocationEnabled(false);
mWebView.setMixedContentAllowed(true);
mWebView.setCookiesEnabled(true);
mWebView.setThirdPartyCookiesEnabled(true);

mWebView.setWebViewClient(new WebViewClient(){
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
if (view.getUrl()==null || view.getUrl().startsWith("https://")) {
handler.proceed();
}
else{
handler.cancel();
}
}
});

// Enable Javascript
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);

//Allow to change URL via Firebase
FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
String webUrl = firebaseRemoteConfig.getString(Constants.FIREBASE_CONFIG_WEB_URL);

mWebView.loadUrl(webUrl);

return view;
}

@Override
public void onResume() {
super.onResume();
mWebView.onResume();
}

@Override
public void onPause() {
mWebView.onPause();
super.onPause();
}

@Override
public void onDestroy() {
mWebView.onDestroy();
super.onDestroy();
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
mWebView.onActivityResult(requestCode, resultCode, intent);
}

@Override
public void onPageStarted(String url, Bitmap favicon) {
loadingLayout.setVisibility(View.VISIBLE);
}

@Override
public void onPageFinished(String url) {
loadingLayout.setVisibility(View.GONE);
}

@Override
public void onPageError(int errorCode, String description, String failingUrl) {
errorLayout.setVisibility(View.VISIBLE);
loadingLayout.setVisibility(View.GONE);
mWebView.setVisibility(View.GONE);
}

@Override
public void onDownloadRequested(String url, String suggestedFilename, String mimeType, long contentLength, String contentDisposition, String userAgent) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}

@Override
public void onExternalPageRequest(String url) {
//Nothing
}

public boolean onBackPressed() {
return !mWebView.onBackPressed();
}
}
11 changes: 7 additions & 4 deletions app/src/main/java/com/referendum/uoctubre/main/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.referendum.uoctubre.main;

import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
Expand All @@ -24,9 +25,11 @@ public void setContentView(int layoutResID) {
}

public void setStatusBarColor(int color) {
Window window = this.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(this, color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = this.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(this, color));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public class Constants {

public static final String FIREBASE_CONFIG_TWITTER_LOGIN_REQUIRED = "twitter_login_required";
public static final String FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED = "share_app_message";
public static final String FIREBASE_CONFIG_WEB_URL = "web_url";
}
37 changes: 36 additions & 1 deletion app/src/main/java/com/referendum/uoctubre/main/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.referendum.uoctubre.main;

import android.annotation.SuppressLint;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.internal.BottomNavigationItemView;
import android.support.design.internal.BottomNavigationMenuView;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
Expand All @@ -25,12 +28,14 @@
import com.referendum.uoctubre.fragments.InfoFragment;
import com.referendum.uoctubre.fragments.ShareFragment;
import com.referendum.uoctubre.fragments.VoteFragment;
import com.referendum.uoctubre.fragments.WebFragment;

public class MainActivity extends BaseActivity implements BottomNavigationView.OnNavigationItemSelectedListener {

public static final String TAB_TWITTER = "twitter";
public static final String TAB_VOTE = "vote";
public static final String TAB_SHARE = "share";
public static final String TAB_WEB = "web";
private BottomNavigationView mNavigationView;
private Fragment mFragment;
private SearchView searchView;
Expand All @@ -39,8 +44,9 @@ public class MainActivity extends BaseActivity implements BottomNavigationView.O
private final static int INFORMAT_FRAGMENT = 0;
private final static int VOTA_FRAGMENT = 1;
private final static int COMPARTEIX_FRAGMENT = 2;
public static final int LOCATION_PERMISSION_ID = 1001;
private final static int WEB_FRAGMENT = 3;

@SuppressLint("RestrictedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -51,6 +57,13 @@ protected void onCreate(Bundle savedInstanceState) {
mNavigationView = findViewById(R.id.navigation);
mNavigationView.setOnNavigationItemSelectedListener(this);

BottomNavigationMenuView menuView = (BottomNavigationMenuView) mNavigationView.getChildAt(0);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(false);
}

if (savedInstanceState == null) {
showFirstFragment();
} else {
Expand All @@ -61,6 +74,11 @@ protected void onCreate(Bundle savedInstanceState) {
mFragment = getSupportFragmentManager().findFragmentByTag(InfoFragment.TAG);
mNavigationView.getMenu().getItem(INFORMAT_FRAGMENT).setChecked(true);
break;
case TAB_WEB:
getSupportActionBar().setTitle(R.string.title_web);
mFragment = getSupportFragmentManager().findFragmentByTag(WebFragment.TAG);
mNavigationView.getMenu().getItem(WEB_FRAGMENT).setChecked(true);
break;
case TAB_VOTE:
getSupportActionBar().setTitle(R.string.title_vote);
mFragment = getSupportFragmentManager().findFragmentByTag(VoteFragment.TAG);
Expand All @@ -78,6 +96,17 @@ protected void onCreate(Bundle savedInstanceState) {
fetchRemoteConfig();
}

@Override
public void onBackPressed() {
if (mFragment != null && mFragment instanceof WebFragment) {
if (!((WebFragment)mFragment).onBackPressed()) {
super.onBackPressed();
}
} else {
super.onBackPressed();
}
}

private void fetchRemoteConfig() {
final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
Expand Down Expand Up @@ -189,6 +218,10 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
showFragment(ShareFragment.TAG);
getSupportActionBar().setTitle(R.string.title_share);
mCurrentScreen = TAB_SHARE;
} else if (itemId == R.id.navigation_web) {
showFragment(WebFragment.TAG);
getSupportActionBar().setTitle(R.string.title_web);
mCurrentScreen = TAB_WEB;
}
return true;
}
Expand All @@ -210,6 +243,8 @@ public void showFragment(String tag) {
mFragment = InfoFragment.newInstance();
} else if (tag.equalsIgnoreCase(VoteFragment.TAG)) {
mFragment = VoteFragment.newInstance();
} else if (tag.equalsIgnoreCase(WebFragment.TAG)) {
mFragment = WebFragment.newInstance();
}
} else {
mFragment = f;
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/drawable-v21/ic_wrapper_poi_cluster.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_vector_poi_cluster" />
</selector>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/bg_splash.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="@color/colorPrimary" />
<item android:gravity="center">
<bitmap
<item>
<bitmap android:gravity="center"
android:src="@drawable/bg_splash_main" />
</item>
</layer-list>
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_vector_poi_cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="24"
android:viewportHeight="24"
android:width="24dp"
android:height="24dp">
android:width="26dp"
android:height="26dp">
<group
android:scaleX="0.7647059"
android:scaleY="0.7647059"
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM15,18L4,18v-4h11v4zM15,13L4,13L4,9h11v4zM20,18h-4L16,9h4v9z"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_wrapper_poi_cluster.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_vector_poi_cluster" />
<item android:drawable="@drawable/ic_legacy_poi_cluster" />
</selector>

0 comments on commit eed5a9f

Please sign in to comment.