Added button to launch application

This commit is contained in:
M66B 2015-10-30 12:41:05 +01:00
parent d9f06bf824
commit 9e8f8958aa
10 changed files with 29 additions and 0 deletions

View File

@ -1,7 +1,9 @@
package eu.faircode.netguard;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.preference.PreferenceManager;
@ -11,6 +13,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Filter;
@ -44,6 +47,7 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
public ImageView ivUsing;
public LinearLayout llConfiguration;
public CheckBox cbUsing;
public Button btnLaunch;
public ViewHolder(View itemView) {
super(itemView);
@ -59,6 +63,7 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
ivUsing = (ImageView) itemView.findViewById(R.id.ivUsing);
llConfiguration = (LinearLayout) itemView.findViewById(R.id.llConfiguration);
cbUsing = (CheckBox) itemView.findViewById(R.id.cbUsing);
btnLaunch = (Button) itemView.findViewById(R.id.btnLaunch);
}
}
@ -169,6 +174,16 @@ public class RuleAdapter extends RecyclerView.Adapter<RuleAdapter.ViewHolder> im
SinkholeService.reload(null, context);
}
});
PackageManager pm = context.getPackageManager();
final Intent launch = pm.getLaunchIntentForPackage(rule.info.packageName);
holder.btnLaunch.setEnabled(launch != null);
holder.btnLaunch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.startActivity(launch);
}
});
}
@Override

View File

@ -104,5 +104,11 @@
android:layout_height="wrap_content"
android:text="@string/title_using"
android:textAppearance="@android:style/TextAppearance.Material.Small" />
<Button
android:id="@+id/btnLaunch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_launch" />
</LinearLayout>
</LinearLayout>

View File

@ -16,4 +16,5 @@
<string name="msg_revoked">NetGuard has been disabled</string>
<string name="title_using">السماح عند استخدام الجهاز</string>
<string name="title_launch">Start application</string>
</resources>

View File

@ -16,4 +16,5 @@
<string name="msg_revoked">NetGuard has been disabled</string>
<string name="title_using">Allow when device in use</string>
<string name="title_launch">Start application</string>
</resources>

View File

@ -16,4 +16,5 @@
<string name="msg_revoked">NetGuard has been disabled</string>
<string name="title_using">Consenti quando il dispositivo è in uso</string>
<string name="title_launch">Start application</string>
</resources>

View File

@ -16,4 +16,5 @@
<string name="msg_revoked">NetGuard is uitgezet</string>
<string name="title_using">Sta toe als apparaat in gebruik</string>
<string name="title_launch">Start applicatie</string>
</resources>

View File

@ -16,4 +16,5 @@
<string name="msg_revoked">NetGuard has been disabled</string>
<string name="title_using">Permite cand dispozitivul este folosit</string>
<string name="title_launch">Start application</string>
</resources>

View File

@ -16,4 +16,5 @@
<string name="msg_revoked">NetGuard je vypnutý</string>
<string name="title_using">Povoliť pri používaní zariadenia</string>
<string name="title_launch">Start application</string>
</resources>

View File

@ -16,5 +16,6 @@
<string name="msg_revoked">NetGuard has been disabled</string>
<string name="title_using">Allow when device in use</string>
<string name="title_launch">Start application</string>
</resources>

View File

@ -17,4 +17,5 @@
<string name="msg_revoked">NetGuard has been disabled</string>
<string name="title_using">Allow when device in use</string>
<string name="title_launch">Start application</string>
</resources>