Skip to content

Commit

Permalink
System wallpaper background
Browse files Browse the repository at this point in the history
Corrected background image aspect ratio, center the image and crop (cover style resizing)
  • Loading branch information
dvhh committed Apr 27, 2015
1 parent ce4dfd8 commit 7abe5ec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
1 change: 1 addition & 0 deletions term/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
android:launchMode="singleTop"
android:configChanges="orientation|keyboardHidden"
android:exported="true"
android:theme="@android:style/Theme.Dialog"
>
<intent-filter>
<action android:name="android.intent.action.PICK" />
Expand Down
33 changes: 25 additions & 8 deletions term/src/main/java/jackpal/androidterm/TermPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,33 @@ protected String handleURI(Uri uri) {
String result=null;
Cursor returnCursor =
getContentResolver().query(uri, null, null, null, null);
int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE);

returnCursor.moveToFirst();
String filename=null;
long filesize=-1;

String filename=returnCursor.getString(nameIndex);
long filesize=returnCursor.getLong(sizeIndex);
returnCursor.close();
returnCursor=null;
if(filename.endsWith(".ttf") || filename.endsWith(".otf")) {


if(returnCursor!=null) {
int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
int sizeIndex = returnCursor.getColumnIndex(OpenableColumns.SIZE);

returnCursor.moveToFirst();

filename = returnCursor.getString(nameIndex);
filesize = returnCursor.getLong(sizeIndex);
returnCursor.close();
returnCursor = null;
}else{
File f=new File(uri.getPath());
if(f.exists() && f.isFile()) {
filename=f.getName();
filesize=f.length();
}else {
return null;
}
}

if(filename.endsWith(".ttf") || filename.endsWith(".otf")) {
// OK the file extension pass


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public void onCreate(android.os.Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setTitle(getString(R.string.fsnavigator_title));//"File Selector");
SP=PreferenceManager.getDefaultSharedPreferences(context);
theme=SP.getInt("theme", theme);
setTheme(theme);
//SP=PreferenceManager.getDefaultSharedPreferences(context);
//theme=SP.getInt("theme", theme);
//setTheme(theme);
getWindow().setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

Intent intent= getIntent();
Expand All @@ -80,7 +80,7 @@ public void onPause()
////////////////////////////////////////////////////////////
private void doPause()
{
SP.edit().putString("lastDirectory", getCanonicalPath(cd)).commit();
//SP.edit().putString("lastDirectory", getCanonicalPath(cd)).commit();
}
////////////////////////////////////////////////////////////
public void onResume()
Expand Down Expand Up @@ -329,7 +329,7 @@ private LinearLayout directoryView(boolean up)
tv.setId(R.id.textview);
tv.setLayoutParams(
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT
LinearLayout.LayoutParams.WRAP_CONTENT
, BUTTON_SIZE
, 1
)
Expand All @@ -341,15 +341,15 @@ private LinearLayout directoryView(boolean up)
hv.setOnClickListener(directoryListener);
hv.setLayoutParams(
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT
LinearLayout.LayoutParams.WRAP_CONTENT
, BUTTON_SIZE
, 7
)
);
LinearLayout ll=new LinearLayout(context);
ll.setLayoutParams(
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT
LinearLayout.LayoutParams.WRAP_CONTENT
, BUTTON_SIZE
, 2
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ public int[] getColorScheme() {
int alpha = ( mWallpaperAlpha << 24 ) ;
int old= result[1];
result[1] = old & 0x00ffffff | alpha;
Log.d("Term",String.format("%x %x %x",result[1],old,alpha));
}
return result;
}
Expand Down

0 comments on commit 7abe5ec

Please sign in to comment.