Directly open url without checking available packages in openInBrowser in LinkResolverActivity. Replace android:tint with app:tint.

This commit is contained in:
Alex Ning 2020-08-24 22:30:52 +08:00
parent 53ef74b70e
commit 462208066a
16 changed files with 21 additions and 37 deletions

View File

@ -262,7 +262,17 @@ public class LinkResolverActivity extends AppCompatActivity {
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri); intent.setData(uri);
List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0); try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
if (handleError) {
openInCustomTabs(uri, pm, false);
} else {
Toast.makeText(this, R.string.no_browser_found, Toast.LENGTH_SHORT).show();
}
}
/*List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0);
ArrayList<String> packageNames = new ArrayList<>(); ArrayList<String> packageNames = new ArrayList<>();
String currentPackageName = getApplicationContext().getPackageName(); String currentPackageName = getApplicationContext().getPackageName();
@ -289,10 +299,9 @@ public class LinkResolverActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(this, R.string.no_browser_found, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.no_browser_found, Toast.LENGTH_SHORT).show();
} }
} }*/
} }
private ArrayList<ResolveInfo> getCustomTabsPackages(PackageManager pm) { private ArrayList<ResolveInfo> getCustomTabsPackages(PackageManager pm) {
// Get default VIEW intent handler. // Get default VIEW intent handler.
Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.example.com")); Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.example.com"));

View File

@ -145,7 +145,6 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
app:layout_constraintStart_toEndOf="@+id/score_text_view_theme_preview_comments_fragment" app:layout_constraintStart_toEndOf="@+id/score_text_view_theme_preview_comments_fragment"
app:layout_constraintEnd_toStartOf="@id/more_button_theme_preview_comments_fragment" app:layout_constraintEnd_toStartOf="@id/more_button_theme_preview_comments_fragment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -176,7 +175,6 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_expand_less_grey_24dp" android:src="@drawable/ic_expand_less_grey_24dp"
android:tint="@android:color/tab_indicator_text"
app:layout_constraintEnd_toStartOf="@+id/save_button_theme_preview_comments_fragment" app:layout_constraintEnd_toStartOf="@+id/save_button_theme_preview_comments_fragment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintBottom_toBottomOf="parent"/>
@ -354,7 +352,6 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
app:layout_constraintStart_toEndOf="@+id/score_text_view_award_background_theme_preview_comments_fragment" app:layout_constraintStart_toEndOf="@+id/score_text_view_award_background_theme_preview_comments_fragment"
app:layout_constraintEnd_toStartOf="@id/more_button_award_background_theme_preview_comments_fragment" app:layout_constraintEnd_toStartOf="@id/more_button_award_background_theme_preview_comments_fragment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -385,7 +382,6 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_expand_less_grey_24dp" android:src="@drawable/ic_expand_less_grey_24dp"
android:tint="@android:color/tab_indicator_text"
app:layout_constraintEnd_toStartOf="@+id/save_button_award_background_theme_preview_comments_fragment" app:layout_constraintEnd_toStartOf="@+id/save_button_award_background_theme_preview_comments_fragment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintBottom_toBottomOf="parent"/>

View File

@ -233,7 +233,7 @@
android:layout_height="150dp" android:layout_height="150dp"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_link" android:src="@drawable/ic_link"
android:tint="@android:color/tab_indicator_text" /> app:tint="@android:color/tab_indicator_text" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -157,7 +157,6 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
app:layout_constraintStart_toEndOf="@+id/score_text_view_item_post_comment" app:layout_constraintStart_toEndOf="@+id/score_text_view_item_post_comment"
app:layout_constraintEnd_toStartOf="@id/more_button_item_post_comment" app:layout_constraintEnd_toStartOf="@id/more_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -186,7 +185,6 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_expand_less_grey_24dp" android:src="@drawable/ic_expand_less_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:visibility="gone" android:visibility="gone"
app:layout_constraintEnd_toStartOf="@+id/save_button_item_post_comment" app:layout_constraintEnd_toStartOf="@+id/save_button_item_post_comment"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"

View File

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground">
@ -23,7 +24,7 @@
android:layout_marginStart="32dp" android:layout_marginStart="32dp"
android:src="@drawable/ic_outline_edit_24px" android:src="@drawable/ic_outline_edit_24px"
android:visibility="gone" android:visibility="gone"
android:tint="?attr/primaryTextColor" app:tint="?attr/primaryTextColor"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" /> android:focusable="true" />

View File

@ -266,7 +266,7 @@
android:layout_height="72dp" android:layout_height="72dp"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_link" android:src="@drawable/ic_link"
android:tint="@android:color/tab_indicator_text" /> app:tint="@android:color/tab_indicator_text" />
</FrameLayout> </FrameLayout>

View File

@ -134,7 +134,7 @@
android:layout_height="72dp" android:layout_height="72dp"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_link" android:src="@drawable/ic_link"
android:tint="@android:color/tab_indicator_text" /> app:tint="@android:color/tab_indicator_text" />
</FrameLayout> </FrameLayout>

View File

@ -254,7 +254,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_upward_grey_24dp" android:src="@drawable/ic_arrow_upward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -280,7 +279,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -308,7 +306,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"

View File

@ -245,7 +245,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_upward_grey_24dp" android:src="@drawable/ic_arrow_upward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -271,7 +270,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -299,7 +297,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"

View File

@ -255,7 +255,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_upward_grey_24dp" android:src="@drawable/ic_arrow_upward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -281,7 +280,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -309,7 +307,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"

View File

@ -218,7 +218,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="150dp" android:layout_height="150dp"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_link" /> android:src="@drawable/ic_link"
app:tint="@android:color/tab_indicator_text" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -231,7 +232,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_upward_grey_24dp" android:src="@drawable/ic_arrow_upward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -257,7 +257,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -285,7 +284,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"

View File

@ -214,7 +214,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_upward_grey_24dp" android:src="@drawable/ic_arrow_upward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -240,7 +239,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -268,7 +266,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"

View File

@ -257,7 +257,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_upward_grey_24dp" android:src="@drawable/ic_arrow_upward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -283,7 +282,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -311,7 +309,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"

View File

@ -227,7 +227,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_upward_grey_24dp" android:src="@drawable/ic_arrow_upward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -253,7 +252,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:src="@drawable/ic_arrow_downward_grey_24dp" android:src="@drawable/ic_arrow_downward_grey_24dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -281,7 +279,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp" android:padding="12dp"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground" android:background="?actionBarItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"

View File

@ -244,7 +244,7 @@
android:layout_height="150dp" android:layout_height="150dp"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_link" android:src="@drawable/ic_link"
android:tint="@android:color/tab_indicator_text" app:tint="@android:color/tab_indicator_text"
android:visibility="gone" /> android:visibility="gone" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout

View File

@ -213,7 +213,7 @@
android:layout_height="150dp" android:layout_height="150dp"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_link" android:src="@drawable/ic_link"
android:tint="@android:color/tab_indicator_text" /> app:tint="@android:color/tab_indicator_text" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bottom_constraint_layout_item_post_no_preview_link_type" android:id="@+id/bottom_constraint_layout_item_post_no_preview_link_type"