Skip to content

Commit

Permalink
v1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
rignaneseleo committed Dec 20, 2015
1 parent f8a13e1 commit bbdd407
Show file tree
Hide file tree
Showing 11 changed files with 452 additions and 136 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ proguard/
*.log
/SlimFacebook - Alpha
/SlimFacebook.rar
/SlimFacebook - Copia
31 changes: 19 additions & 12 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,29 @@ v1.3.1
- Fix the launch icon

v1.4
- add swipe to refresh
- added settings:
- Add swipe to refresh
- Added settings:
- order by newest feed
- show version

- fix the utf8 in the offline page
- fix the refresh when there is no connection
- photos are opened with the browser
- add indonesian translations
- Fix the utf8 in the offline page
- Fix the refresh when there is no connection
- Photos are opened with the browser
- Add indonesian translations

v1.5
- upload of files
- improved the compatibility with older Android version
- fix translations
- fix the cache load
- add some toasts
- Upload of files
- Improved the compatibility with older Android version
- Fix translations
- Fix the cache load
- Add some toasts

v1.5.1
- Added the French, German, Spanish, Portuguese, Chinese translations!
- Added the French, German, Spanish, Portuguese, Chinese translations!

v1.6
- Geolocalizzation
- Share links with app
- Added Saving Data option
- Extended url intent
- Added Polish translation (DoctorRzepa)
323 changes: 223 additions & 100 deletions SlimFacebook/.idea/workspace.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions SlimFacebook/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "it.rignanese.leo.slimfacebook"
minSdkVersion 15
targetSdkVersion 23
versionCode 8
versionName "1.5.1"
versionCode 9
versionName "1.6"
}
buildTypes {
release {
Expand Down
36 changes: 24 additions & 12 deletions SlimFacebook/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ SlimFacebook is an Open Source app realized by Leonardo Rignanese
<!--to connect to the Internet-->
<uses-permission android:name="android.permission.INTERNET"/>
<!--to upload files-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!--gps-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>



<application
android:allowBackup="true"
Expand All @@ -23,8 +27,8 @@ SlimFacebook is an Open Source app realized by Leonardo Rignanese
android:theme="@style/SlimFacebookTheme"


android:versionCode="8"
android:versionName="1.5.1"
android:versionCode="9"
android:versionName="1.6"
><!--the official version is wrote in build.gradle-->


Expand All @@ -33,10 +37,11 @@ SlimFacebook is an Open Source app realized by Leonardo Rignanese
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:label="@string/app_name"
>
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

</intent-filter>
<intent-filter>
<!--compatibility to samsung multiwindows-->
Expand All @@ -45,22 +50,29 @@ SlimFacebook is an Open Source app realized by Leonardo Rignanese
<!--to start app when facebook site is called-->
<action android:name="android.intent.action.VIEW"/>

<!--to open the facebook link with this app-->
<!--to open facebook link with this app-->
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>

<data
android:host="m.facebook.com"
android:host="*.facebook.com"
android:scheme="http"/>
<data
android:host="*.facebook.com"
android:scheme="https"/>
<data
android:host="touch.facebook.com"
android:host="fb.me"
android:scheme="http"/>
<data
android:host="fb.me"
android:scheme="https"/>
</intent-filter>

<!--<data-->
<!--android:host="m.facebook.com"-->
<!--android:pathPrefix="/sharer.php"-->
<!--android:scheme="https"/>-->
<!--add https://www.facebook.com/sharer-->
<intent-filter>
<!--to open facebook link for sharing link-->
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
SlimFacebook is an Open Source app realized by Leonardo Rignanese
GNU GENERAL PUBLIC LICENSE Version 2, June 1991
special thanks to https://github.com/indywidualny/FaceSlim
some of the code is their work!
*/

package it.rignanese.leo.slimfacebook;
Expand All @@ -9,14 +13,18 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.GeolocationPermissions;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
Expand All @@ -41,6 +49,7 @@ public class MainActivity extends AppCompatActivity {
SwipeRefreshLayout swipeRefreshLayout;//the layout that allows the swipe refresh

private WebView webViewFacebook;//the main webView where is shown facebook

//to upload files
public static final int INPUT_FILE_REQUEST_CODE = 1;
public static final String EXTRA_FROM_NOTIFICATION = "EXTRA_FROM_NOTIFICATION";
Expand All @@ -54,6 +63,8 @@ public class MainActivity extends AppCompatActivity {
boolean noConnectionError = false;//flag: is true if there is a connection error and it should be reload not the error page but the last useful
boolean swipeRefresh = false;

boolean isSharer = false;//flag: true if the app is called from sharer
String urlSharer = "";//to save the url got from the sharer

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -69,6 +80,7 @@ protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.activity_main);//load the layout


// setup the refresh layout
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
swipeRefreshLayout.setColorSchemeResources(R.color.officialBlueFacebook, R.color.darkBlueSlimFacebookTheme);// set the colors
Expand All @@ -80,11 +92,41 @@ public void onRefresh() {
}
});


/** get a subject and text and check if this is a link trying to be shared */
String sharedSubject = getIntent().getStringExtra(Intent.EXTRA_SUBJECT);
String sharedUrl = getIntent().getStringExtra(Intent.EXTRA_TEXT);

// if we have a valid URL that was shared by us, open the sharer
if (sharedUrl != null) {
if (!sharedUrl.equals("")) {
// check if the URL being shared is a proper web URL
if (!sharedUrl.startsWith("http://") || !sharedUrl.startsWith("https://")) {
// if it's not, let's see if it includes an URL in it (prefixed with a message)
int startUrlIndex = sharedUrl.indexOf("http:");
if (startUrlIndex > 0) {
// seems like it's prefixed with a message, let's trim the start and get the URL only
sharedUrl = sharedUrl.substring(startUrlIndex);
}
}
// final step, set the proper Sharer...
urlSharer = String.format("https://m.facebook.com/sharer.php?u=%s&t=%s", sharedUrl, sharedSubject);
// ... and parse it just in case
urlSharer = Uri.parse(urlSharer).toString();
isSharer = true;
}
}


// setup the webView
webViewFacebook = (WebView) findViewById(R.id.webView);
setUpWebViewDefaults(webViewFacebook);//set the settings

goHome();//load homepage
if (isSharer) {//if is a share request
webViewFacebook.loadUrl(urlSharer);//load the sharer url
isSharer = false;
} else goHome();//load homepage


//WebViewClient that is the client callback.
webViewFacebook.setWebViewClient(new WebViewClient() {//advanced set up
Expand All @@ -101,7 +143,7 @@ public void onReceivedError(WebView view, int errorCode, String description, Str

// when I click in a external link
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url == null || url.contains("facebook.com")) {
if (url == null || url.contains("facebook.com")) {//// TODO: clear these conditions
//url is ok
return false;
} else {
Expand All @@ -111,6 +153,9 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
Toast.makeText(getApplicationContext(), getString(R.string.downloadOrShareWithBrowser),
Toast.LENGTH_LONG).show();
//TODO get bitmap from url



Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
Expand All @@ -119,9 +164,11 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
//if the link doesn't contain 'facebook.com', open it using the browser
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
}//https://www.facebook.com/dialog/return/close?#_=_
}



//START management of loading
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Expand All @@ -137,18 +184,22 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {

// show you progress image
if (!swipeRefresh) {
final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh);
refreshItem.setActionView(R.layout.circular_progress_bar);
if (optionsMenu != null) {//TODO fix this. Sometimes it is null and I don't know why
final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh);
refreshItem.setActionView(R.layout.circular_progress_bar);
}
}
swipeRefresh = false;
super.onPageStarted(view, url, favicon);
}

@Override
public void onPageFinished(WebView view, String url) {
// hide your progress image
final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh);
refreshItem.setActionView(null);
if (optionsMenu != null) {//TODO fix this. Sometimes it is null and I don't know why
final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh);
refreshItem.setActionView(null);
}

super.onPageFinished(view, url);

swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing
Expand All @@ -159,10 +210,17 @@ public void onPageFinished(WebView view, String url) {

//WebChromeClient for handling all chrome functions.
webViewFacebook.setWebChromeClient(new WebChromeClient() {
//to the geolocalizzation
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);
//todo notify when the gps is used
}

//to upload files
//thanks to gauntface
//https://github.com/GoogleChrome/chromium-webview-samples
public boolean onShowFileChooser(
//todo fix the compatibility with all versions (4.4.4 specially)
WebView webView, ValueCallback<Uri[]> filePathCallback,
WebChromeClient.FileChooserParams fileChooserParams) {
if (mFilePathCallback != null) {
Expand Down Expand Up @@ -214,6 +272,40 @@ public boolean onShowFileChooser(
});
}

// app is already running and gets a new intent (used to share link without open another activity
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);

// grab an url if opened by clicking a link
String webViewUrl = getIntent().getDataString();

/** get a subject and text and check if this is a link trying to be shared */
String sharedSubject = getIntent().getStringExtra(Intent.EXTRA_SUBJECT);
String sharedUrl = getIntent().getStringExtra(Intent.EXTRA_TEXT);

// if we have a valid URL that was shared by us, open the sharer
if (sharedUrl != null) {
if (!sharedUrl.equals("")) {
// check if the URL being shared is a proper web URL
if (!sharedUrl.startsWith("http://") || !sharedUrl.startsWith("https://")) {
// if it's not, let's see if it includes an URL in it (prefixed with a message)
int startUrlIndex = sharedUrl.indexOf("http:");
if (startUrlIndex > 0) {
// seems like it's prefixed with a message, let's trim the start and get the URL only
sharedUrl = sharedUrl.substring(startUrlIndex);
}
}
// final step, set the proper Sharer...
webViewUrl = String.format("https://m.facebook.com/sharer.php?u=%s&t=%s", sharedUrl, sharedSubject);
// ... and parse it just in case
webViewUrl = Uri.parse(webViewUrl).toString();
}
}
webViewFacebook.loadUrl(webViewUrl);
}

//*********************** UPLOAD FILES ****************************
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Expand Down Expand Up @@ -246,6 +338,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
mFilePathCallback = null;
return;
}

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private File createImageFile() throws IOException {
// Create an image file name
Expand Down Expand Up @@ -301,11 +394,12 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
//add my menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
this.optionsMenu = menu;
optionsMenu = menu;
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

//management the tap on the menu's items
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Expand Down Expand Up @@ -364,6 +458,11 @@ private void setUpWebViewDefaults(WebView webView) {
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);

settings.setGeolocationDatabasePath(getBaseContext().getFilesDir().getPath() );

settings.setLoadsImagesAutomatically(!savedPreferences.getBoolean("pref_downloadImages", false));//to save data
//todo setLoadsImagesAutomatically without restart the app

// Enable pinch to zoom without the zoom buttons
settings.setBuiltInZoomControls(true);

Expand Down
2 changes: 2 additions & 0 deletions SlimFacebook/app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ SlimFacebook is an Open Source app realized by Leonardo Rignanese
<string name="prefCat_app_information_title">Informazioni dell\'App</string>
<string name="thanks">Grazie!</string>
<string name="downloadOrShareWithBrowser">Aprendo il browser è possibile scaricare o condividere questa immagine.</string>
<string name="title_downloadImages">Risparmia dati (necessita riavvio)</string>
<string name="summary_downloadImages">Non scaricare le immagini</string>

</resources>
Loading

0 comments on commit bbdd407

Please sign in to comment.