Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ libs/AndroidPushRefresh/bin/
libs/AndroidPushRefresh/gen/
libs/ViewPagerIndicator/bin/
libs/ViewPagerIndicator/gen/
server.properties
4 changes: 4 additions & 0 deletions code/assets/server.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Modelo para server.properties. Faça uma cópia deste arquivo no mesmo diretório(assets),
#renomeie-o para server.properties, e adicione as informações corretas do servidor.
ip_address=192.168.168.168
port=3000
2 changes: 1 addition & 1 deletion code/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-16
target=android-21
android.library.reference.1=../libs/redu-android
android.library.reference.2=../libs/ViewPagerIndicator
android.library.reference.3=../libs/AndroidPushRefresh
Expand Down
1 change: 1 addition & 0 deletions code/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
<string name="new_lectures_key">new_lectures</string>
<string name="new_lectures_title">Novas Aulas</string>
<string name="new_lectures_summary">Novas Aulas nas Disciplinas que participo</string>
<string name="error_server_file">Arquivo server.properties inexistente ou incorretamente configurado.</string>

</resources>
9 changes: 7 additions & 2 deletions code/src/br/com/redu/redumobile/activities/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import br.com.developer.redu.http.ServerInfo;
import br.com.redu.redumobile.R;
import br.com.redu.redumobile.ReduApplication;
import br.com.redu.redumobile.data.LoadStatusesFromWebTask;
Expand Down Expand Up @@ -110,12 +111,16 @@ public void onItemClick(AdapterView<?> parent, View view, int position,
case 1:
i = new Intent(getApplicationContext(), WebViewActivity.class);
i.putExtra(WebViewActivity.EXTRAS_TITLE, "Termos de Uso");
i.putExtra(WebViewActivity.EXTRAS_URL, "http://www.redu.com.br/paginas/termos_uso");
i.putExtra(WebViewActivity.EXTRAS_URL, String.format(
"http://%s:%s/paginas/termos_uso",
ServerInfo.getIpAddress(), ServerInfo.getPort()));
break;
case 2:
i = new Intent(getApplicationContext(), WebViewActivity.class);
i.putExtra(WebViewActivity.EXTRAS_TITLE, "Política de Privacidade");
i.putExtra(WebViewActivity.EXTRAS_URL, "http://www.redu.com.br/paginas/politica_privacidade");
i.putExtra(WebViewActivity.EXTRAS_URL, String.format(
"http://%s:%s/paginas/politica_privacidade",
ServerInfo.getIpAddress(), ServerInfo.getPort()));
break;
case 3:
i = new Intent(getApplicationContext(), LoginWebViewActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import br.com.developer.redu.DefaultReduClient;
import br.com.developer.redu.http.ServerInfo;
import br.com.developer.redu.models.User;
import br.com.redu.redumobile.R;
import br.com.redu.redumobile.ReduApplication;
Expand All @@ -23,43 +25,61 @@ public class LoginWebViewActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if(PinCodeHelper.has(this)) {
startActivity(new Intent(this, HomeActivity.class));
if (!ServerInfo.init(this)) {
Toast.makeText(this, R.string.error_server_file, Toast.LENGTH_LONG)
.show();
finish();
} else {
setContentView(R.layout.activity_login_web);

mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");

mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (url.equals("http://www.redu.com.br/oauth/authorize")) {
showProgressDialog("Aguarde alguns instantes enquanto você é redirecionado ao aplicativo Redu Mobile…", false);
if (PinCodeHelper.has(this)) {
startActivity(new Intent(this, HomeActivity.class));
finish();
} else {
setContentView(R.layout.activity_login_web);

mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new MyJavaScriptInterface(),
"HTMLOUT");

mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url,
Bitmap favicon) {
if (url.equals(String.format(
"http://%s:%s/oauth/authorize",
ServerInfo.getIpAddress(), ServerInfo.getPort()))) {
showProgressDialog(
"Aguarde alguns instantes enquanto você é redirecionado ao aplicativo Redu Mobile…",
false);
}
}
}
@Override
public void onPageFinished(WebView view, String url) {
// This call inject JavaScript into the page which just finished loading.
if (url.equals("http://www.redu.com.br/oauth/authorize")) {
mWebView.loadUrl("javascript:window.HTMLOUT.processHTML(document.getElementsByTagName('code')[0].innerHTML);");

@Override
public void onPageFinished(WebView view, String url) {
// This call inject JavaScript into the page which just
// finished loading.
if (url.equals(String.format(
"http://%s:%s/oauth/authorize",
ServerInfo.getIpAddress(), ServerInfo.getPort()))) {
mWebView.loadUrl("javascript:window.HTMLOUT.processHTML(document.getElementsByTagName('code')[0].innerHTML);");
}
}
}
});

new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
DefaultReduClient client = ReduApplication.getReduClient(LoginWebViewActivity.this);
return client.getAuthorizeUrl();
}
@Override
protected void onPostExecute(String authorizeUrl) {
mWebView.loadUrl(authorizeUrl);
}
}.execute();
});

new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
DefaultReduClient client = ReduApplication
.getReduClient(LoginWebViewActivity.this);
return client.getAuthorizeUrl();
}

@Override
protected void onPostExecute(String authorizeUrl) {
mWebView.loadUrl(authorizeUrl);
}
}.execute();
}
}
}

Expand Down
41 changes: 24 additions & 17 deletions code/src/br/com/redu/redumobile/db/DbHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import br.com.developer.redu.http.ServerInfo;
import br.com.developer.redu.models.Link;
import br.com.developer.redu.models.Status;
import br.com.developer.redu.models.Thumbnail;
Expand Down Expand Up @@ -264,14 +265,17 @@ synchronized public List<Status> getStatusesBySpace(long timestamp, boolean olde
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor;

String query = "SELECT * FROM " + StatusTable.NAME +
" WHERE " + StatusTable.COLUMN_CREATED_AT_IN_MILLIS + (olderThan ? "<" : ">") + timestamp + " AND " +
StatusTable.COLUMN_ID + " IN " +
"(SELECT " + LinkTable.COLUMN_STATUS_ID + " FROM " + LinkTable.NAME +
" WHERE " + LinkTable.COLUMN_REL + " = \"" + Link.REL_SPACE + "\" AND " +
LinkTable.COLUMN_HREF + " = " + "\"http://www.redu.com.br/api/spaces/" + spaceId + "\")" +
" ORDER BY " + StatusTable.COLUMN_CREATED_AT_IN_MILLIS + " DESC" +
" LIMIT " + count;
String query = "SELECT * FROM " + StatusTable.NAME + " WHERE "
+ StatusTable.COLUMN_CREATED_AT_IN_MILLIS
+ (olderThan ? "<" : ">") + timestamp + " AND "
+ StatusTable.COLUMN_ID + " IN " + "(SELECT "
+ LinkTable.COLUMN_STATUS_ID + " FROM " + LinkTable.NAME
+ " WHERE " + LinkTable.COLUMN_REL + " = \"" + Link.REL_SPACE
+ "\" AND " + LinkTable.COLUMN_HREF + " = " + "\"http://"
+ ServerInfo.getIpAddress() + ":" + ServerInfo.getPort()
+ "/api/spaces/" + spaceId + "\")" + " ORDER BY "
+ StatusTable.COLUMN_CREATED_AT_IN_MILLIS + " DESC" + " LIMIT "
+ count;

cursor = db.rawQuery(query, null);

Expand All @@ -291,15 +295,18 @@ synchronized public List<Status> getStatusesByLecture(long timestamp, boolean ol

SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor;

String query = "SELECT * FROM " + StatusTable.NAME +
" WHERE " + StatusTable.COLUMN_CREATED_AT_IN_MILLIS + (olderThan ? "<" : ">") + timestamp + " AND " +
StatusTable.COLUMN_ID + " IN " +
"(SELECT " + LinkTable.COLUMN_STATUS_ID + " FROM " + LinkTable.NAME +
" WHERE " + LinkTable.COLUMN_REL + " = \"" + Link.REL_LECTURE + "\" AND " +
LinkTable.COLUMN_HREF + " LIKE " + "\"http://www.redu.com.br/api/lectures/" + lectureId + "%\")" +
"ORDER BY " + StatusTable.COLUMN_CREATED_AT_IN_MILLIS + " DESC " +
"LIMIT " + count;

String query = "SELECT * FROM " + StatusTable.NAME + " WHERE "
+ StatusTable.COLUMN_CREATED_AT_IN_MILLIS
+ (olderThan ? "<" : ">") + timestamp + " AND "
+ StatusTable.COLUMN_ID + " IN " + "(SELECT "
+ LinkTable.COLUMN_STATUS_ID + " FROM " + LinkTable.NAME
+ " WHERE " + LinkTable.COLUMN_REL + " = \"" + Link.REL_LECTURE
+ "\" AND " + LinkTable.COLUMN_HREF + " LIKE " + "\"http://"
+ ServerInfo.getIpAddress() + ":" + ServerInfo.getPort()
+ "/api/lectures/" + lectureId + "%\")" + "ORDER BY "
+ StatusTable.COLUMN_CREATED_AT_IN_MILLIS + " DESC " + "LIMIT "
+ count;

cursor = db.rawQuery(query, null);

Expand Down
2 changes: 1 addition & 1 deletion libs/AndroidPushRefresh/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
# project structure.

# Project target.
target=android-16
target=android-21
android.library=true
2 changes: 1 addition & 1 deletion libs/ViewPagerIndicator/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

android.library=true
# Project target.
target=android-16
target=android-21
2 changes: 1 addition & 1 deletion libs/WebCachedImageView/code/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
target=android-21
android.library=true