[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #41

Merged
merged 7 commits into from
Mar 17, 2017
Merged

Dev #41

Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adding actions to updates.
  • Loading branch information
rumboalla committed Mar 17, 2017
commit a33433a12feb88340b349a4a38d751de0fbbc98f
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public InstalledAppViewHolder onCreateViewHolder(
ViewGroup parent,
int viewType
) {
InstalledAppView v = InstalledAppView_.build(mContext);
InstalledAppView v = InstalledAppView_.build(parent.getContext());
v.setLayoutParams(new RecyclerView.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
Expand Down
55 changes: 34 additions & 21 deletions app/src/main/java/com/apkupdater/adapter/UpdaterAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

public class UpdaterAdapter
extends RecyclerView.Adapter<UpdaterAdapter.UpdateViewHolder>
implements View.OnLongClickListener, View.OnClickListener
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -80,40 +79,54 @@ public UpdateViewHolder onCreateViewHolder(
ViewGroup parent,
int viewType
) {
UpdaterView v = UpdaterView_.build(mContext);
UpdaterView v = UpdaterView_.build(parent.getContext());
v.setLayoutParams(new RecyclerView.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
));
v.setOnLongClickListener(this);
v.setOnClickListener(this);

v.setActionOneButtonListener(onActionOneClick);
v.setActionTwoButtonListener(onActionTwoClick);
return new UpdateViewHolder(v);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@Override
public boolean onLongClick(
View view
private UpdaterView getUpdaterViewParent(
View v
) {
Update update = mUpdates.get(mView.getChildLayoutPosition(view));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"https://apps.evozi.com/apk-downloader/?id=" + update.getPname()
));
mContext.startActivity(browserIntent);
return true;
while (v != null) {
v = (View) v.getParent();
if (v instanceof UpdaterView) {
return (UpdaterView) v;
}
}
return null;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

@Override
public void onClick(
View view
) {
Update update = mUpdates.get(mView.getChildLayoutPosition(view));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(update.getUrl()));
mContext.startActivity(browserIntent);
}
private View.OnClickListener View.OnClickListener() {
@Override
public void onClick(View v) {
Update update = mUpdates.get(mView.getChildLayoutPosition(getUpdaterViewParent(v)));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"https://apps.evozi.com/apk-downloader/?id=" + update.getPname()
));
mContext.startActivity(browserIntent);
}
};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

private View.OnClickListener View.OnClickListener() {
@Override
public void onClick(View v) {
Update update = mUpdates.get(mView.getChildLayoutPosition(getUpdaterViewParent(v)));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(update.getUrl()));
mContext.startActivity(browserIntent);
}
};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down
44 changes: 39 additions & 5 deletions app/src/main/java/com/apkupdater/view/UpdaterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.apkupdater.R;
import com.apkupdater.model.Update;
import com.apkupdater.util.ColorUtitl;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;
Expand Down Expand Up @@ -39,12 +40,21 @@ public class UpdaterView
@ViewById(R.id.update_url)
TextView mUrl;

@ViewById(R.id.action_one_button)
Button mActionOneButton;

@ViewById(R.id.action_two_button)
Button mActionTwoButton;

Context mContext;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public UpdaterView(
Context context
) {
super(context);
mContext = context;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -62,14 +72,38 @@ public void bind(
}

mVersion.setText(version);
mUrl.setText(update.getUrl());
mUrl.setTextColor(ColorUtitl.getColorFromTheme(getContext().getTheme(), R.attr.colorAccent));

// Build string for first action
String action = "";
if (update.getUrl().contains("apkmirror.com")) {
action = mContext.getString(R.string.action_apkmirror);
} else if (update.getUrl().contains("uptodown.com")) {
action = mContext.getString(R.string.action_uptodown);
} else if (update.getUrl().contains("apkpure.com")) {
action = mContext.getString(R.string.action_apkpure);
}
mActionOneButton.setText(action);

try {
Drawable icon = getContext().getPackageManager().getApplicationIcon(update.getPname());
mIcon.setImageDrawable(icon);
} catch (PackageManager.NameNotFoundException ignored) {
} catch (PackageManager.NameNotFoundException ignored) {}
}

}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public void setActionOneButtonListener(
View.OnClickListener listener
) {
mActionOneButton.setOnClickListener(listener);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public void setActionTwoButtonListener(
View.OnClickListener listener
) {
mActionTwoButton.setOnClickListener(listener);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
115 changes: 84 additions & 31 deletions app/src/main/res/layout/updater_item.xml
Original file line number Diff line number Diff line change
@@ -1,53 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardUseCompatPadding="true"
app:cardUseCompatPadding="false"
android:foreground="?selectableItemBackground"
android:clickable="true"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ImageView
android:layout_margin="8dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:id="@+id/installed_app_icon"
android:layout_gravity="center"
android:contentDescription="@string/content_description_app_icon"
/>

<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="8dp"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/installed_app_name"
android:textStyle="bold"
/>
<TextView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/installed_app_pname"
android:layout_weight="1"
android:orientation="vertical"
android:paddingTop="22dp"
android:paddingLeft="16dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/installed_app_name"
android:textStyle="bold"
android:textSize="22sp"
android:maxLines="1"
android:ellipsize="end"
tools:text="Title here"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/installed_app_pname"
android:textSize="14sp"
tools:text="Subtitle 1"
android:maxLines="1"
android:ellipsize="end"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/installed_app_version"
android:textSize="14sp"
tools:text="Subtitle 2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/update_url"
android:textColor="#FFFF0000"
android:visibility="gone"
/>
</LinearLayout>
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:id="@+id/installed_app_icon"
android:contentDescription="@string/content_description_app_icon"
/>
<TextView
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:id="@+id/action_one_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/installed_app_version"
android:padding="8dp"
android:textSize="14sp"
android:textColor="?attr/colorAccent"
android:background="@android:color/transparent"
/>
<TextView
<Button
android:id="@+id/action_two_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/update_url"
android:textColor="#FFFF0000"
android:padding="8dp"
android:textSize="14sp"
android:textColor="?attr/colorAccent"
android:text="@string/action_evozi"
android:background="@android:color/transparent"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.v7.widget.CardView>

4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@
<string name="num_threads_ten" translatable="false">10</string>
<string name="action_ignore_app">IGNORE</string>
<string name="action_unignore_app">UNIGNORE</string>
<string name="action_apkmirror">APKMIRROR</string>
<string name="action_apkpure">APKPURE</string>
<string name="action_uptodown">UPTODOWN</string>
<string name="action_evozi">EVOZI</string>
</resources>