Skip to content

Commit

Permalink
improved icon credits by using own "About Icons" library
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Jul 25, 2020
1 parent 2158028 commit 6f25651
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 56 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'com.mikepenz.aboutlibraries.plugin'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.cyb3rko.logviewerforopenhab"
minSdkVersion 23
Expand All @@ -30,7 +30,7 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.amitshekhar.android:android-networking:1.0.2'
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.0'
implementation 'com.github.GrenderG:Toasty:1.4.2'
implementation 'com.github.GrenderG:Toasty:7be5e09'
implementation 'com.github.medyo:android-about-page:1.3'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.firebase:firebase-analytics:17.4.3'
Expand All @@ -39,4 +39,5 @@ dependencies {
implementation 'com.mikepenz:aboutlibraries-core:8.3.0'
implementation 'com.mikepenz:aboutlibraries:8.3.0'
implementation 'org.adw.library:discrete-seekbar:1.0.1'
implementation 'com.github.cyb3rko:about-icons:a9e4ccc'
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/cyb3rko/logviewerforopenhab/About.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ protected void onCreate(Bundle savedInstanceState) {
// first group
.addGroup(getString(R.string.about_group_1))
// second item
.addItem(new Element().setTitle(getString(R.string.about_element_2)).setIconDrawable(R.drawable.icon_libraries).setOnClickListener(showLibraries()))
.addItem(new Element().setTitle(getString(R.string.about_element_2)).setIconDrawable(R.drawable._icon_libraries).setOnClickListener(showLibraries()))
// third item
.addItem(new Element().setTitle(getString(R.string.about_element_3)).setIconDrawable(R.drawable.icon_question).setOnClickListener(showIcons()))
.addItem(new Element().setTitle(getString(R.string.about_element_3)).setIconDrawable(R.drawable._icon_question).setOnClickListener(showIcons()))
// second group
.addGroup(getString(R.string.about_group_2))
// feddback item
Expand Down
47 changes: 3 additions & 44 deletions app/src/main/java/com/cyb3rko/logviewerforopenhab/IconCredits.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package com.cyb3rko.logviewerforopenhab;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.cyb3rko.abouticons.AboutIcons;

public class IconCredits extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -27,40 +20,6 @@ protected void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(mySPR.getInt("orientation", ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED));

// set view
setContentView(R.layout.activity_icon_credits);

// set text of textviews and add links to authors
TextView[] textViews = new TextView[9];
String[] credits = getResources().getStringArray(R.array.credits_icons);
String[] creditsLinks = getResources().getStringArray(R.array.credits_icons_links);

for (int i = 1; i <= 9; i++) {
// find textviews and set text
textViews[i-1] = findViewById(getResources().getIdentifier("credits_icons_" + i, "id", getPackageName()));
textViews[i-1].setText(getResources().getStringArray(R.array.credits_icons)[i-1]);

// split string array items into link, authorAlias and authorName
String link = creditsLinks[i-1].split(",")[0];
String authorAlias = creditsLinks[i-1].split(",")[1].split(";")[0];
String authorName = creditsLinks[i-1].split(",")[1].split(";")[1];

// add clickable links
setSpans(textViews[i-1], credits[i-1], link, credits[i-1].indexOf(authorAlias), credits[i-1].indexOf(authorAlias) + authorName.length());
}
}

// method to add clickable links
private void setSpans(TextView textView, String string, final String link, int startChar, int endChar) {
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View view) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
}
};

SpannableString spannableString = new SpannableString(string);
spannableString.setSpan(clickableSpan, startChar, endChar != 0 ? endChar : string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(spannableString);
textView.setMovementMethod(LinkMovementMethod.getInstance());
setContentView(new AboutIcons(this, R.drawable.class).get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ public void run() {
private void setOrientationIcon() {
switch (mySPR.getInt("orientation", ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)) {
case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
orientation.setImageResource(R.drawable.icon_landscape_orientation);
orientation.setImageResource(R.drawable._icon_landscape_orientation);
break;
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
orientation.setImageResource(R.drawable.icon_portrait_orientation);
orientation.setImageResource(R.drawable._icon_portrait_orientation);
break;
case ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED:
orientation.setImageResource(R.drawable.icon_auto_orientation);
orientation.setImageResource(R.drawable._icon_auto_orientation);
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ private void setViewButtonClickListener() {
public void onClick(View view) {
// if scrolling locked
if (viewLocked) {
viewButton.setImageResource(R.drawable.icon_lock_2);
viewButton.setImageResource(R.drawable._icon_lock_2);
viewLocked = false;
setTouchable(true);

// show toast
Toasty.info(view.getContext(), getString(R.string.lock_button_1), Toasty.LENGTH_SHORT).show();
} else {
viewButton.setImageResource(R.drawable.icon_lock);
viewButton.setImageResource(R.drawable._icon_lock);
viewLocked = true;
setTouchable(false);

Expand Down
Binary file added app/src/main/res/drawable-v24/_icon_eye.webp
Binary file not shown.
Binary file added app/src/main/res/drawable-v24/_icon_log.webp
Binary file not shown.
6 changes: 3 additions & 3 deletions app/src/main/res/layout/fragment_web_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:src="@drawable/icon_lock"
android:src="@drawable/_icon_lock"
app:backgroundTint="#A6FF7E29"
app:elevation="0.01dp"
app:layout_constraintBottom_toBottomOf="@id/webview"
Expand All @@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:src="@drawable/icon_font"
android:src="@drawable/_icon_font"
app:backgroundTint="#A6FF7E29"
app:elevation="0.01dp"
app:layout_constraintEnd_toEndOf="@+id/webview"
Expand All @@ -35,7 +35,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:src="@drawable/icon_arrow_left"
android:src="@drawable/_icon_arrow_left"
app:backgroundTint="#80FF7E29"
app:elevation="0.01dp"
app:fabSize="mini"
Expand Down
79 changes: 79 additions & 0 deletions app/src/main/res/values/about_icons.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="icon_arrow_left">
<item>Lyolya</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/left-arrow_109618</item>
<item>false</item>
</string-array>

<string-array name="icon_auto_orientation">
<item>Freepik</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/orientation_1302037</item>
<item>false</item>
</string-array>

<string-array name="icon_eye">
<item>Dave Gandy</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/eye-open_25186</item>
<item>false</item>
</string-array>

<string-array name="icon_font">
<item>Those Icons</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/font_2087728</item>
<item>false</item>
</string-array>

<string-array name="icon_landscape_orientation">
<item>Freepik</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/orientation_1302037</item>
<item>true</item>
</string-array>

<string-array name="icon_libraries">
<item>Freepik</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/books-stack-of-three_29302</item>
<item>false</item>
</string-array>

<string-array name="icon_lock">
<item>Those Icons</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/lock_483408</item>
<item>false</item>
</string-array>

<string-array name="icon_lock_2">
<item>Those Icons</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/lock_483412</item>
<item>false</item>
</string-array>

<string-array name="icon_log">
<item>Smartline</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/files_569837</item>
<item>true</item>
</string-array>

<string-array name="icon_portrait_orientation">
<item>Freepik</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/orientation_1302037</item>
<item>true</item>
</string-array>

<string-array name="icon_question">
<item>Freepik</item>
<item>flaticon.com</item>
<item>https://www.flaticon.com/free-icon/information_906794</item>
<item>false</item>
</string-array>
</resources>

0 comments on commit 6f25651

Please sign in to comment.