Some helpers

This commit is contained in:
Thomas 2020-02-05 17:45:18 +01:00
parent 8d42fb51e4
commit e91a7bc39b
5 changed files with 53 additions and 2 deletions

View File

@ -30,6 +30,7 @@ import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.provider.Settings;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -56,6 +57,7 @@ public class MainActivity extends AppCompatActivity {
public static String SET_OSM_HOST = "set_osm_host";
public static String DEFAULT_OSM_HOST = "www.openstreetmap.org";
public static final String APP_PREFS = "app_prefs";
private AppInfoAdapter appInfoAdapter;
//Supported domains
private String[] domains = {
@ -151,6 +153,14 @@ public class MainActivity extends AppCompatActivity {
Snackbar.make(parentLayout, R.string.instances_saved, Snackbar.LENGTH_LONG).show();
});
Button configure = findViewById(R.id.configure);
configure.setOnClickListener(v -> {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getApplicationInfo().packageName, null);
intent.setData(uri);
startActivity(intent);
});
ArrayList<AppInfo> appInfos = new ArrayList<>();
for(String domain: domains) {
AppInfo appInfo = new AppInfo();
@ -159,7 +169,7 @@ public class MainActivity extends AppCompatActivity {
appInfos.add(appInfo);
}
AppInfoAdapter appInfoAdapter = new AppInfoAdapter(appInfos);
appInfoAdapter = new AppInfoAdapter(appInfos);
list_apps.setAdapter(appInfoAdapter);
final LinearLayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(MainActivity.this);
@ -212,4 +222,12 @@ public class MainActivity extends AppCompatActivity {
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume(){
super.onResume();
if( appInfoAdapter != null) {
appInfoAdapter.notifyDataSetChanged();
}
}
}

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M19.1,12.9a2.8,2.8 0,0 0,0.1 -0.9,2.8 2.8,0 0,0 -0.1,-0.9l2.1,-1.6a0.7,0.7 0,0 0,0.1 -0.6L19.4,5.5a0.7,0.7 0,0 0,-0.6 -0.2l-2.4,1a6.5,6.5 0,0 0,-1.6 -0.9l-0.4,-2.6a0.5,0.5 0,0 0,-0.5 -0.4H10.1a0.5,0.5 0,0 0,-0.5 0.4L9.3,5.4a5.6,5.6 0,0 0,-1.7 0.9l-2.4,-1a0.4,0.4 0,0 0,-0.5 0.2l-2,3.4c-0.1,0.2 0,0.4 0.2,0.6l2,1.6a2.8,2.8 0,0 0,-0.1 0.9,2.8 2.8,0 0,0 0.1,0.9L2.8,14.5a0.7,0.7 0,0 0,-0.1 0.6l1.9,3.4a0.7,0.7 0,0 0,0.6 0.2l2.4,-1a6.5,6.5 0,0 0,1.6 0.9l0.4,2.6a0.5,0.5 0,0 0,0.5 0.4h3.8a0.5,0.5 0,0 0,0.5 -0.4l0.3,-2.6a5.6,5.6 0,0 0,1.7 -0.9l2.4,1a0.4,0.4 0,0 0,0.5 -0.2l2,-3.4c0.1,-0.2 0,-0.4 -0.2,-0.6ZM12,15.6A3.6,3.6 0,1 1,15.6 12,3.6 3.6,0 0,1 12,15.6Z"/>
</vector>

View File

@ -158,12 +158,34 @@
android:id="@+id/enable_osm"/>
</LinearLayout>
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:textColor="@android:color/white"
android:id="@+id/configure"
android:layout_marginTop="20dp"
android:drawableStart="@drawable/ic_settings"
android:drawableLeft="@drawable/ic_settings"
android:drawablePadding="5dp"
android:paddingEnd="20dp"
android:paddingRight="20dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/button_save"
app:layout_constraintTop_toBottomOf="@+id/osm_container"
android:text="@string/configure"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:textColor="@android:color/white"
android:drawableStart="@drawable/ic_save"
android:drawableLeft="@drawable/ic_save"
android:drawablePadding="5dp"
android:paddingEnd="20dp"
android:paddingRight="20dp"
android:id="@+id/button_save"
android:layout_marginTop="20dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintLeft_toRightOf="@+id/configure"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/osm_container"
android:text="@string/save"

View File

@ -25,4 +25,5 @@
<string name="custom_osm">Custom OSM hostname</string>
<string name="redirect_youtube_to_invidious">Redirect YouTube to Invidious</string>
<string name="redirect_twitter_to_nitter">Redirect Twitter to Nitter</string>
<string name="configure">Configure</string>
</resources>