Improve content

This commit is contained in:
Thomas 2020-02-17 13:59:11 +01:00
parent 418b9402f4
commit 23481e1ae4
8 changed files with 80 additions and 15 deletions

View File

@ -21,10 +21,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TransformActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar">
<!-- The app should handle these domains, more can be added here -->
<activity
android:name=".TransformActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:noHistory="true">
<!-- The app should handle these domains, more can be added here -->²
<!-- t.co -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View File

@ -14,6 +14,7 @@ package app.fedilab.nitterizeme;
* You should have received a copy of the GNU General Public License along with NitterizeMe; if not,
* see <http://www.gnu.org/licenses>. */
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@ -83,10 +84,18 @@ public class AppInfoAdapter extends RecyclerView.Adapter {
holder.app_icon.setImageResource(R.drawable.ic_android);
holder.valid.setContentDescription(context.getString(R.string.warning));
holder.valid.setImageResource(R.drawable.ic_warning);
holder.main_container.setOnClickListener(v -> {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("nitterizeme","test");
String url = "https://"+appInfo.getDomain();
if( appInfo.getDomain().contains("google.com")) {
url += "/maps/";
}
intent.setData(Uri.parse(url));
context.startActivity(intent);
});
}
}
@Override

View File

@ -35,6 +35,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import com.google.android.material.snackbar.Snackbar;
@ -58,6 +59,7 @@ public class MainActivity extends AppCompatActivity {
public static String DEFAULT_OSM_HOST = "www.openstreetmap.org";
public static final String APP_PREFS = "app_prefs";
private AppInfoAdapter appInfoAdapter;
private RecyclerView list_apps;
//Supported domains
private String[] domains = {
@ -102,7 +104,7 @@ public class MainActivity extends AppCompatActivity {
enable_osm.setChecked(osm_enabled);
Button button_save = findViewById(R.id.button_save);
RecyclerView list_apps = findViewById(R.id.list_apps);
list_apps = findViewById(R.id.list_apps);
String nitterHost = sharedpreferences.getString(SET_NITTER_HOST, null);
String invidiousHost = sharedpreferences.getString(SET_INVIDIOUS_HOST, null);
String osmHost = sharedpreferences.getString(SET_OSM_HOST, null);
@ -162,6 +164,17 @@ public class MainActivity extends AppCompatActivity {
startActivity(intent);
});
ImageButton buttonExpand = findViewById(R.id.button_expand);
buttonExpand.setOnClickListener(v -> {
if( list_apps.getVisibility() == View.VISIBLE){
list_apps.setVisibility(View.GONE);
buttonExpand.setContentDescription(getString(R.string.display_supported_links));
}else{
list_apps.setVisibility(View.VISIBLE);
buttonExpand.setContentDescription(getString(R.string.hide_supported_links));
}
});
ArrayList<AppInfo> appInfos = new ArrayList<>();
for(String domain: domains) {
AppInfo appInfo = new AppInfo();
@ -227,8 +240,16 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onResume(){
super.onResume();
if( appInfoAdapter != null) {
appInfoAdapter.notifyDataSetChanged();
if( list_apps != null) {
ArrayList<AppInfo> appInfos = new ArrayList<>();
for(String domain: domains) {
AppInfo appInfo = new AppInfo();
appInfo.setDomain(domain);
appInfo.setApplicationInfo(getDefaultApp("https://"+domain));
appInfos.add(appInfo);
}
appInfoAdapter = new AppInfoAdapter(appInfos);
list_apps.setAdapter(appInfoAdapter);
}
}
}

View File

@ -48,6 +48,11 @@ public class TransformActivity extends Activity {
super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = getSharedPreferences(MainActivity.APP_PREFS, Context.MODE_PRIVATE);
Intent intent = getIntent();
if( intent != null && intent.getStringExtra("nitterizeme") != null ) {
finish();
return;
}
assert intent != null;
if( Objects.requireNonNull(intent.getAction()).equals(Intent.ACTION_VIEW)){
String action = intent.getAction();
String url = Objects.requireNonNull(intent.getData()).toString();

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="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/>
</vector>

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="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
</vector>

View File

@ -25,11 +25,13 @@
tools:context=".MainActivity"
tools:showIn="@layout/activity_main"
android:scrollbars="none"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:animateLayoutChanges="true"
>
<TextView
@ -167,8 +169,7 @@
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"
@ -181,18 +182,34 @@
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_toRightOf="@+id/configure"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintRight_toRightOf="@+id/button_expand"
app:layout_constraintTop_toBottomOf="@+id/osm_container"
android:text="@string/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton
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:id="@+id/button_expand"
android:layout_marginTop="20dp"
app:layout_constraintLeft_toRightOf="@+id/button_save"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/osm_container"
android:src="@drawable/ic_expand_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/display_supported_links" />
<androidx.recyclerview.widget.RecyclerView
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"

View File

@ -26,4 +26,6 @@
<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>
<string name="display_supported_links">Display supported links</string>
<string name="hide_supported_links">Hide supported links</string>
</resources>