Skip to content
This repository has been archived by the owner on Sep 15, 2019. It is now read-only.

Commit

Permalink
Merge branch 'release/0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudloff committed Feb 19, 2019
2 parents 32b79cc + 6a056f6 commit 8776c8f
Show file tree
Hide file tree
Showing 25 changed files with 108 additions and 15 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ It allows you to use Hangouts on an Android phone without Play Services.

![Screenshot](screenshot.png)

## 2-Step Verification

hangups only supports the following 2FA methods:

* OTP (Google Authenticator)
* SMS

If none of these methods are available for your account, login will fail with `GoogleAuthError: Authorization code cookie not found`.

## Warning

Never give your Google account credentials to any application or device that you don’t trust. Logging into Google grants hangups unrestricted access to your account. hangups works this way because Google does not provide any other method to access the Hangouts API.
11 changes: 9 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
minSdkVersion 16
targetSdkVersion 28

versionCode 10
versionName "0.1.0"
versionCode 11
versionName "0.1.1"

python {
version '3.6.5'
Expand All @@ -24,6 +24,11 @@ android {
abiFilters "x86", "armeabi-v7a"
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
Expand All @@ -34,6 +39,8 @@ dependencies {
exclude group: 'com.android.support'
}
implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
implementation "ch.acra:acra-mail:5.2.1"
implementation "ch.acra:acra-dialog:5.2.1"

implementation 'com.android.support:design:28.0.0'
}
22 changes: 22 additions & 0 deletions app/src/main/java/pro/rudloff/hangupsdroid/App.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package pro.rudloff.hangupsdroid;

import android.app.ProgressDialog;
import android.content.Context;
import com.chaquo.python.PyObject;
import com.chaquo.python.Python;
import com.chaquo.python.android.PyApplication;
import org.acra.ACRA;
import org.acra.annotation.AcraCore;
import org.acra.annotation.AcraDialog;
import org.acra.annotation.AcraMailSender;
import org.acra.data.StringFormat;

/** Main application object. */
@AcraCore(reportFormat = StringFormat.KEY_VALUE_LIST)
@AcraDialog(resText = R.string.acra_dialog_text)
@AcraMailSender(mailTo = "[email protected]")
public class App extends PyApplication {

/** Python hangupsdroid.App instance. */
Expand All @@ -15,11 +24,24 @@ public class App extends PyApplication {
public ProgressDialog progressDialog;

/** Called when the app is started. */
@Override
public void onCreate() {
super.onCreate();
Python py = Python.getInstance();
PyObject hangupsdroid = py.getModule("hangupsdroid");

pythonApp = hangupsdroid.callAttr("App");
}

/**
* Set the base context for this ContextWrapper.
*
* @param base The new base context for this wrapper
*/
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);

ACRA.init(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class AvatarLoader implements ImageLoader {
* @param imageView View to load the image into.
* @param url URL of the image
*/
@Override
public void loadImage(ImageView imageView, String url) {
Picasso.get().load(url).into(imageView);
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/pro/rudloff/hangupsdroid/Conversation.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public Conversation(PyObject newConversation) {
*
* @return ID
*/
@Override
public String getId() {
return conversation.get("id_").toString();
}
Expand All @@ -48,6 +49,7 @@ public User getSelfUser() {
*
* @return Thumbnail URL
*/
@Override
public String getDialogPhoto() {
Python py = Python.getInstance();
PyObject builtins = py.getBuiltins();
Expand All @@ -71,6 +73,7 @@ public String getDialogPhoto() {
*
* @return Conversation title
*/
@Override
public String getDialogName() {
Python py = Python.getInstance();
PyObject utils = py.getModule("hangups.ui.utils");
Expand All @@ -83,6 +86,7 @@ public String getDialogName() {
*
* @return List of users
*/
@Override
public ArrayList<User> getUsers() {
Python py = Python.getInstance();
PyObject builtins = py.getBuiltins();
Expand Down Expand Up @@ -114,6 +118,7 @@ public ArrayList<User> getUsers() {
*
* @return Last message
*/
@Override
public IMessage getLastMessage() {
Python py = Python.getInstance();
PyObject hangupsdroid = py.getModule("hangupsdroid");
Expand Down Expand Up @@ -152,6 +157,7 @@ public IMessage getFirstMessage() {
*
* @param message Message
*/
@Override
public void setLastMessage(IMessage message) {
// We use the hangups conversation object to manage the last message.
}
Expand All @@ -161,6 +167,7 @@ public void setLastMessage(IMessage message) {
*
* @return Number of unread messages
*/
@Override
public int getUnreadCount() {
Python py = Python.getInstance();
PyObject hangupsdroid = py.getModule("hangupsdroid");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public String get_verification_code() {
* @param dialog Verification code dialog
* @param which Button that was clicked
*/
@Override
public void onClick(DialogInterface dialog, int which) {
verificationCode = verificationCodeInput.getText().toString();
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/pro/rudloff/hangupsdroid/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public Message(PyObject newMessage, User newMessageUser) {
*
* @return ID
*/
@Override
public String getId() {
return message.get("id_").toString();
}
Expand All @@ -46,6 +47,7 @@ public String getId() {
*
* @return Content
*/
@Override
public String getText() {
return message.get("text").toString();
}
Expand All @@ -55,6 +57,7 @@ public String getText() {
*
* @return Image URL
*/
@Override
public String getImageUrl() {
Python py = Python.getInstance();
PyObject hangupsdroid = py.getModule("hangupsdroid");
Expand All @@ -72,6 +75,7 @@ public String getImageUrl() {
*
* @return User
*/
@Override
public User getUser() {
return user;
}
Expand All @@ -81,6 +85,7 @@ public User getUser() {
*
* @return Creation date
*/
@Override
public Date getCreatedAt() {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS", Locale.US);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public MessageDateFormatter(Activity newActivity) {
* @param date Date to format
* @return Formatted date
*/
@Override
public String format(Date date) {
if (DateFormatter.isToday(date)) {
return DateFormatter.format(date, DateFormatter.Template.TIME);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/pro/rudloff/hangupsdroid/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public User(PyObject newUser) {
*
* @return ID
*/
@Override
public String getId() {
return user.get("id_").toString();
}
Expand All @@ -32,6 +33,7 @@ public String getId() {
*
* @return Full name
*/
@Override
public String getName() {
return user.get("full_name").toString();
}
Expand All @@ -41,6 +43,7 @@ public String getName() {
*
* @return Avatar URL
*/
@Override
public String getAvatar() {
PyObject photoUrl = user.get("photo_url");
if (photoUrl != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
abstract class Activity extends AppCompatActivity {

/** Called when the activity is destroyed. */
@Override
protected void onDestroy() {
super.onDestroy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ConversationActivity extends Activity implements OnLoadMoreListener
* @param savedInstanceState Saved state of the activity if it has been previously killed by the
* OS.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.conversation);
Expand Down Expand Up @@ -86,6 +87,7 @@ public void onNewMessages(PyObject messageList) {
* @param page Next page to load
* @param totalItemsCount Current messages counter
*/
@Override
public void onLoadMore(int page, int totalItemsCount) {
App app = (App) getApplicationContext();

Expand Down Expand Up @@ -123,6 +125,7 @@ public void onChatMessageEvent(PyObject event) {
* @param text Message content
* @return Is the message valid?
*/
@Override
public boolean onSubmit(CharSequence text) {
App app = (App) getApplicationContext();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pro.rudloff.hangupsdroid.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.chaquo.python.PyObject;
Expand All @@ -27,14 +26,10 @@ public class ConversationListActivity extends Activity
/** ChatKit adapter used to inject the conversations in the view. */
private DialogsListAdapter<Conversation> conversationAdapter;

/**
* Called when the activity is created.
*
* @param savedInstanceState Saved state of the activity if it has been previously killed by the
* OS.
*/
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/** Called when the activity is created. */
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.conversation_list);

App app = (App) getApplicationContext();
Expand Down Expand Up @@ -64,6 +59,7 @@ protected void onCreate(Bundle savedInstanceState) {
*
* @param conversation Conversation clicked
*/
@Override
public void onDialogClick(Conversation conversation) {
Intent intent = new Intent(this, ConversationActivity.class);
intent.putExtra("conversationId", conversation.getId());
Expand Down Expand Up @@ -109,6 +105,7 @@ public void onChatMessageEvent(PyObject event) {
* @param menu Menu
* @return Was the menu created?
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.conversation_list, menu);

Expand All @@ -121,6 +118,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
* @param item Menu item that was selected.
* @return Was the action consumed?
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
App app = (App) getApplicationContext();
RefreshTokenCache cache = new RefreshTokenCache(this);
Expand All @@ -133,6 +131,14 @@ public boolean onOptionsItemSelected(MenuItem item) {
Intent intent = new Intent(this, LoginActivity.class);
finishAffinity();
startActivity(intent);
return true;
} else if (item.getItemId() == R.id.action_refresh) {
// We force refresh the conversation list.
runOnUiThread(
new ProgressDialogRunnable(this, getString(R.string.conversation_list_dialog)));

app.pythonApp.callAttr("add_conversations", this, true);

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class LoginActivity extends Activity implements OnClickListener, OnEditor
* @param savedInstanceState Saved state of the activity if it has been previously killed by the
* OS.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
Expand Down Expand Up @@ -71,6 +72,7 @@ public void login() {
*
* @param view [description]
*/
@Override
public void onClick(View view) {
login();
}
Expand All @@ -83,6 +85,7 @@ public void onClick(View view) {
* @param event Event corresponding to the entered key
* @return Did we consume the action?
*/
@Override
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
login();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public AddConversationRunnable(
}

/** Called to run the runnable. */
@Override
public void run() {
Python py = Python.getInstance();
PyObject builtins = py.getBuiltins();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public AddMessageRunnable(
}

/** Called to run the runnable. */
@Override
public void run() {
App app = (App) activity.getApplicationContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public HideViewRunnable(View newView) {
}

/** Called to run the runnable. */
@Override
public void run() {
view.animate().alpha(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public ProgressDialogRunnable(Activity newActivity, String newMessage) {
}

/** Called to run the runnable. */
@Override
public void run() {
App app = (App) activity.getApplicationContext();
if (app.progressDialog != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public ShowDialogRunnable(Builder newBuilder) {
}

/** Called to run the runnable. */
@Override
public void run() {
builder.show();
}
Expand Down
Loading

0 comments on commit 8776c8f

Please sign in to comment.