Skip to content

Commit

Permalink
1,6 and 2.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
biafra23 committed Nov 13, 2011
1 parent 479389a commit e3f740c
Show file tree
Hide file tree
Showing 16 changed files with 814 additions and 255 deletions.
698 changes: 547 additions & 151 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion AmDroid/AndroidManifest.xml
Expand Up @@ -3,7 +3,7 @@
package="com.jaeckel.amenoid"
android:versionCode="18"
android:versionName="1.0-ALPHA4">
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="8"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8"/>

<application android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
Expand Down
11 changes: 4 additions & 7 deletions AmDroid/CHANGES
@@ -1,14 +1,11 @@
1.0-ALPHA4

- NEW: Subject Pages (Preview)
- NEW: Popular Feed included
- BUGFIX: Empty User details page should not crash anymore
- BUGFIX: Improved Android 1.6 and 2.1 compatibility


1.0-ALPHA3

new:
- Register for https://getamen.com/users and /topics urls. Let Amenoid handle those urls found in EMails oder elsewhere

bug fix:
- Better dispute detection
- NEW: Register for https://getamen.com/users and /topics urls. Let Amenoid handle those urls found in EMails oder elsewhere
- BUGFIX: Better dispute detection

Binary file added AmDroid/res/drawable-hdpi/ic_menu_sign_in.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AmDroid/res/drawable-ldpi/ic_menu_sign_in.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AmDroid/res/drawable-mdpi/ic_menu_sign_in.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AmDroid/res/drawable-xhdpi/ic_menu_sign_in.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions AmDroid/res/menu/menu_main.xml
Expand Up @@ -2,6 +2,12 @@

<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@+id/signin"
android:icon="@drawable/ic_menu_sign_in"
android:title="Sign In"
android:visible="true"
/>

<item android:id="@+id/refresh"
android:icon="@drawable/ic_menu_refresh"
android:title="Refresh"/>
Expand All @@ -23,9 +29,7 @@
android:visible="false"
/>

<item android:id="@+id/preference"
android:icon="@drawable/ic_menu_settings"
android:title="Preferences"/>


<item android:id="@+id/amen"
android:icon="@drawable/ic_menu_amen"
Expand All @@ -35,4 +39,7 @@
android:icon="@drawable/ic_menu_about"
android:title="About"
/>
<!--<item android:id="@+id/preference"-->
<!--android:icon="@drawable/ic_menu_settings"-->
<!--android:title="Preferences"/>-->
</menu>
63 changes: 35 additions & 28 deletions AmDroid/src/main/java/com/jaeckel/amenoid/AmenDetailActivity.java
Expand Up @@ -75,6 +75,7 @@ public void onCreate(Bundle savedInstanceState) {
list.addHeaderView(header);



Intent startingIntent = getIntent();
currentAmen = startingIntent.getParcelableExtra(Constants.EXTRA_AMEN);
if (currentAmen == null) {
Expand Down Expand Up @@ -178,48 +179,49 @@ private void populateFormWithAmen(boolean updateName) {
}

private void setAmenButtonListener() {
if (service.getMe() != null) {
amenTakeBackButton.setEnabled(true);
amenTakeBackButton.setOnClickListener(new View.OnClickListener() {

amenTakeBackButton.setEnabled(true);
amenTakeBackButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {

public void onClick(View view) {
amenTakeBackButton.setEnabled(false);

amenTakeBackButton.setEnabled(false);
if (amened(currentStatement)) {

if (amened(currentStatement)) {
Log.d(TAG, "Back taking: " + currentAmen);
new AmenDetailActivity.TakeBackTask(AmenDetailActivity.this).execute(currentStatement.getId());

Log.d(TAG, "Back taking: " + currentAmen);
new AmenDetailActivity.TakeBackTask(AmenDetailActivity.this).execute(currentStatement.getId());
} else {
Log.d(TAG, "amening: " + currentAmen);
new AmenDetailActivity.AmenTask(AmenDetailActivity.this).execute(currentAmen.getId());

} else {
Log.d(TAG, "amening: " + currentAmen);
new AmenDetailActivity.AmenTask(AmenDetailActivity.this).execute(currentAmen.getId());
}
populateFormWithAmen(false);

}
populateFormWithAmen(false);

}
});
});

hellNoButton.setEnabled(true);
hellNoButton.setOnClickListener(new View.OnClickListener() {
hellNoButton.setEnabled(true);
hellNoButton.setOnClickListener(new View.OnClickListener() {

public void onClick(View view) {
//TODO: show hellno form here to let user select different objekt
public void onClick(View view) {
//TODO: show hellno form here to let user select different objekt


populateFormWithAmen(false);
populateFormWithAmen(false);

Intent intent = new Intent(AmenDetailActivity.this, DisputeActivity.class);
intent.putExtra(Constants.EXTRA_AMEN, currentAmen);
startActivity(intent);
}
});
Intent intent = new Intent(AmenDetailActivity.this, DisputeActivity.class);
intent.putExtra(Constants.EXTRA_AMEN, currentAmen);
startActivity(intent);
}
});
}
}

private boolean amened(Statement currentStatement) {
for (User u : currentStatement.getAgreeingNetwork()) {
if (u.getId() == service.getMe().getId()) {
if (service.getMe() != null && u.getId() == service.getMe().getId()) {
return true;
}
}
Expand Down Expand Up @@ -291,7 +293,9 @@ protected void wrappedOnPostExecute(Amen result) {
thumbs = new ThumbnailAdapter(AmenDetailActivity.this, new UserListAdapter(AmenDetailActivity.this, android.R.layout.activity_list_item, users), cache, IMAGE_IDS);
setListAdapter(thumbs);
}
amenTakeBackButton.setEnabled(true);
if (service.getMe() != null) {
amenTakeBackButton.setEnabled(true);
}

}

Expand Down Expand Up @@ -331,7 +335,10 @@ protected void wrappedOnPostExecute(Amen result) {
setListAdapter(thumbs);

}
amenTakeBackButton.setEnabled(true);
if (service.getMe() != null) {
amenTakeBackButton.setEnabled(true);

}
}
}

Expand Down Expand Up @@ -415,7 +422,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

case R.id.subject_page: {
Intent intent = new Intent(this, SubjectPageActivity.class);

Toast.makeText(this, "id: " + currentAmen.getStatement().getObjekt().getId(), Toast.LENGTH_SHORT).show();

intent.putExtra(Constants.EXTRA_OBJEKT_ID, currentAmen.getStatement().getObjekt().getId());
Expand Down
20 changes: 11 additions & 9 deletions AmDroid/src/main/java/com/jaeckel/amenoid/AmenListActivity.java
Expand Up @@ -96,6 +96,8 @@ public void onCreate(Bundle savedInstanceState) {

prefs = PreferenceManager.getDefaultSharedPreferences(this);



final String authToken = readAuthTokenFromPrefs();
final User me = readMeFromPrefs();
if (AmenoidApp.DEVELOPER_MODE) {
Expand All @@ -113,20 +115,20 @@ public void onCreate(Bundle savedInstanceState) {
registerForContextMenu(getListView());

// if (feedType != AmenService.FEED_TYPE_POPULAR) {
((PullToRefreshListView) getListView()).setOnRefreshListener(new PullToRefreshListView.OnRefreshListener() {
((PullToRefreshListView) getListView()).setOnRefreshListener(new PullToRefreshListView.OnRefreshListener() {

public void onRefresh() {
Log.v(TAG, "onRefresh()");
// Do work to refresh the list here.
new GetDataTask(AmenListActivity.this).execute();
}
});
public void onRefresh() {
Log.v(TAG, "onRefresh()");
// Do work to refresh the list here.
new GetDataTask(AmenListActivity.this).execute();
}
});
// }
}

private AlertDialog createEnterCredentialsDialog() {
return new AlertDialog.Builder(this)
.setMessage("Please enter your Amen credentials in the preferences and sign in!")
.setMessage("Please enter your Amen credentials and sign in!")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialogInterface, int i) {
Expand Down Expand Up @@ -263,7 +265,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

case R.id.preference:
case R.id.signin:
startActivity(new Intent(this, SettingsActivity.class));

return true;
Expand Down
15 changes: 7 additions & 8 deletions AmDroid/src/main/java/com/jaeckel/amenoid/UrlResolver.java
Expand Up @@ -4,7 +4,6 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;

import java.util.List;

Expand All @@ -21,7 +20,7 @@ public void onCreate(Bundle savedInstanceState) {
// check if this intent is started via custom scheme link
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
Toast.makeText(this, "uri: " + uri, Toast.LENGTH_LONG).show();
// Toast.makeText(this, "uri: " + uri, Toast.LENGTH_LONG).show();
// may be some test here with your custom uri
List<String> pathSegments = uri.getPathSegments();
if ("users".equalsIgnoreCase(pathSegments.get(0))) {
Expand All @@ -37,15 +36,15 @@ public void onCreate(Bundle savedInstanceState) {
}
if ("topics".equalsIgnoreCase(pathSegments.get(0))) {

Long id = Long.valueOf(pathSegments.get(1));
Long id = Long.valueOf(pathSegments.get(1));

Intent startScoreboard = new Intent(this, ScoreBoardActivity.class);
startScoreboard.putExtra(Constants.EXTRA_TOPIC_ID, id);
Intent startScoreboard = new Intent(this, ScoreBoardActivity.class);
startScoreboard.putExtra(Constants.EXTRA_TOPIC_ID, id);

startActivity(startScoreboard);
startActivity(startScoreboard);

finish();
}
finish();
}

}

Expand Down
52 changes: 50 additions & 2 deletions AmDroid/src/main/java/com/jaeckel/amenoid/app/AmenoidApp.java
Expand Up @@ -24,8 +24,16 @@
import com.jaeckel.amenoid.cwac.cache.SimpleWebImageCache;
import com.jaeckel.amenoid.cwac.thumbnail.ThumbnailBus;
import com.jaeckel.amenoid.cwac.thumbnail.ThumbnailMessage;
import com.jaeckel.amenoid.api.AmenHttpClient;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;

/**
Expand Down Expand Up @@ -65,6 +73,7 @@ public class AmenoidApp extends Application {
private AlertDialog.Builder builder;

private SharedPreferences prefs;
private DefaultHttpClient amenHttpClient;

public AmenoidApp() {
super();
Expand All @@ -86,6 +95,40 @@ public void onCreate() {
}
super.onCreate();

Log.i(TAG, "-------------------------------- - - - - - -- - - -----------------");
// Instantiate the custom HttpClient
InputStream in = getResources().openRawResource(R.raw.amenkeystore);
amenHttpClient = new AmenHttpClient(in, "mysecret");
HttpGet get = new HttpGet("https://getamen.com/amen/popular.json");
// Execute the GET call and obtain the response
HttpResponse getResponse = null;
try {
getResponse = amenHttpClient.execute(get);

HttpEntity responseEntity = getResponse.getEntity();

BufferedReader br = new BufferedReader(new InputStreamReader(responseEntity.getContent(), "utf-8"));
StringBuilder builder = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {

Log.i(TAG, "makeStringFromEntity | " + line);

if ("<!DOCTYPE html>".equals(line)) {
//no JSON => Server error
Log.i(TAG, "Received HTML!");
}
builder.append(line);

}

Log.d(TAG, builder.toString());


} catch (IOException e) {
e.printStackTrace();
}
Log.i(TAG, "-------------------------------- - - - - - -- - - -----------------");

amenTypeThin = Typeface.createFromAsset(getAssets(), "fonts/AmenTypeThin.ttf");
amenTypeBold = Typeface.createFromAsset(getAssets(), "fonts/AmenTypeBold.ttf");
Expand Down Expand Up @@ -127,7 +170,7 @@ public static AmenoidApp getInstance() {

if (service == null || service.getAuthToken() == null) {

service = new AmenServiceImpl();
service = new AmenServiceImpl(amenHttpClient);
try {
service.init(username, password);
} catch (IOException e) {
Expand All @@ -141,8 +184,13 @@ public static AmenoidApp getInstance() {

public AmenService getService() {
if (service == null) {
service = new AmenServiceImpl();

service = new AmenServiceImpl(amenHttpClient);
// auto einlogen wenn authoken vorhanden

// prefs =
// String authtoken = prefs.getString(Amen)
// service.init(authtoken, me);
}
return service;
}
Expand Down

0 comments on commit e3f740c

Please sign in to comment.