[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
Next Next commit
Added actions to cards.
Fixed issue with multiple fragments after change orientation.
  • Loading branch information
rumboalla committed Mar 16, 2017
commit 8b359216d052ff71bbe751e55480b572e101d667
3 changes: 1 addition & 2 deletions app/src/main/java/com/apkupdater/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
Expand Down Expand Up @@ -83,7 +82,7 @@ public void onCreate(
// Add the main fragment
if (!(getSupportFragmentManager().findFragmentById(R.id.container) instanceof MainFragment)) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, mMainFragment)
.replace(R.id.container, mMainFragment)
.add(R.id.container, mSettingsFragment)
.add(R.id.container, mLogFragment)
.show(mMainFragment)
Expand Down
31 changes: 25 additions & 6 deletions app/src/main/java/com/apkupdater/adapter/InstalledAppAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class InstalledAppAdapter
extends RecyclerView.Adapter<InstalledAppAdapter.InstalledAppViewHolder>
implements View.OnLongClickListener
implements View.OnClickListener
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -82,21 +82,42 @@ public InstalledAppViewHolder onCreateViewHolder(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
));
v.setOnLongClickListener(this);
v.setActionOneButtonListener(this);
//v.setOnLongClickListener(this);
return new InstalledAppViewHolder(v);
}

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

private InstalledAppView getInstalledAppViewParent(
View v
) {
while (v != null) {
v = (View) v.getParent();
if (v instanceof InstalledAppView) {
return (InstalledAppView) v;
}
}
return null;
}

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

@Override
public boolean onLongClick(
public void onClick(
View view
) {
// Get the ignore list from the options
UpdaterOptions options = new UpdaterOptions(mContext);
List<String> ignore_list = options.getIgnoreList();

InstalledApp app = mApps.get(mView.getChildLayoutPosition(view));
// Get the InstalledAppView parent
InstalledAppView parent = getInstalledAppViewParent(view);
if (parent == null) {
return;
}

InstalledApp app = mApps.get(mView.getChildLayoutPosition(parent));

// If it's on the ignore remove, otherwise add it
if (ignore_list.contains(app.getPname())) {
Expand All @@ -112,8 +133,6 @@ public boolean onLongClick(
AnimationUtil.startListAnimation(mView);
mApps = InstalledAppUtil.sort(mContext, mApps);
notifyDataSetChanged();

return true;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/apkupdater/view/InstalledAppView.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
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;
Expand Down Expand Up @@ -36,6 +38,9 @@ public class InstalledAppView
@ViewById(R.id.installed_app_icon)
ImageView mIcon;

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

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

public InstalledAppView(
Expand All @@ -61,12 +66,14 @@ public void bind(
} else {
setBackgroundColor(0x55000000);
}
mActionOneButton.setText(R.string.action_unignore_app);
} else {
if (android.os.Build.VERSION.SDK_INT >= 11) { // No alpha for old versions
setAlpha(1.0f);
} else {
setBackgroundColor(0x00FFFFFF);
}
mActionOneButton.setText(R.string.action_ignore_app);
}

try {
Expand All @@ -78,6 +85,14 @@ public void bind(
}

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

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

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
91 changes: 69 additions & 22 deletions app/src/main/res/layout/installed_app_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,92 @@
<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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardUseCompatPadding="true"
android:foreground="?selectableItemBackground"
android:clickable="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
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"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/installed_app_name"
android:textStyle="bold"
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"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/installed_app_version"
android:textSize="14sp"
tools:text="Subtitle 2"
/>
</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_pname"
android:padding="8dp"
android:textSize="14sp"
android:textColor="?attr/colorAccent"
android:text="@string/action_ignore_app"
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/installed_app_version"
android:padding="8dp"
android:textSize="14sp"
android:textColor="?attr/colorAccent"
android:text="@string/action_unignore_app"
android:background="@android:color/transparent"
android:visibility="gone"
/>
</LinearLayout>
</LinearLayout>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@
<string name="num_threads_three" translatable="false">3</string>
<string name="num_threads_five" translatable="false">5</string>
<string name="num_threads_ten" translatable="false">10</string>
<string name="action_ignore_app">IGNORE</string>
<string name="action_unignore_app">UNIGNORE</string>
</resources>